1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

sends a date as yyyy-mm-dd

This commit is contained in:
Nicolas Florentin 2023-11-23 11:29:08 +01:00
parent 7c4a6781d6
commit e16cd061f2
3 changed files with 6 additions and 8 deletions

View File

@ -67,11 +67,10 @@ export const FormInput = <TFieldValues extends FieldValues, TInputType>({ id, re
return num;
}
if (type === 'date') {
const date: Date = new Date(value + 'T00:00:00');
if (Number.isNaN(date) && nullable) {
if (Number.isNaN(value) && nullable) {
return null;
}
return date;
return value;
}
setCharacterCount(value?.length || 0);
return value;

View File

@ -127,7 +127,7 @@ class Orders::OrderService
def filter_by_period(orders, filters)
return orders unless filters[:period_from].present? && filters[:period_to].present?
orders.where(created_at: Time.zone.parse(filters[:period_from])..Time.zone.parse(filters[:period_to]).end_of_day)
orders.where(created_at: Date.parse(filters[:period_from]).in_time_zone..Date.parse(filters[:period_to]).in_time_zone.end_of_day)
end
def orders_ordering(orders, filters)

View File

@ -146,10 +146,9 @@ class PaymentScheduleService
)
end
unless filters[:date].nil?
ps = ps.where(
"date_trunc('day', payment_schedules.created_at) = :search OR date_trunc('day', payment_schedule_items.due_date) = :search",
search: "%#{Time.zone.iso8601(filters[:date]).to_date}%"
)
start_at = Date.parse(filters[:date]).in_time_zone
end_at = start_at.end_of_day
ps = ps.where("(payment_schedules.created_at BETWEEN :start_at AND :end_at) OR (payment_schedule_items.due_date BETWEEN :start_at AND :end_at)", start_at: start_at, end_at: end_at).references(:payment_schedule_items)
end
ps