From 9d9d3db43bacc7f2430f6186f229efb602f95dcd Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 14 May 2024 17:29:15 +0200 Subject: [PATCH] fix: refs #7274 defaulterFilter --- .../Customer/Defaulter/CustomerDefaulter.vue | 33 +++++++++++++++++-- .../Defaulter/CustomerDefaulterFilter.vue | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/pages/Customer/Defaulter/CustomerDefaulter.vue b/src/pages/Customer/Defaulter/CustomerDefaulter.vue index 3817e8a49..6fc36bcff 100644 --- a/src/pages/Customer/Defaulter/CustomerDefaulter.vue +++ b/src/pages/Customer/Defaulter/CustomerDefaulter.vue @@ -5,7 +5,7 @@ import { useI18n } from 'vue-i18n'; import { QBtn, QCheckbox, useQuasar } from 'quasar'; import { useStateStore } from 'stores/useStateStore'; -import { toCurrency, toDate } from 'filters/index'; +import { toCurrency, toDate, dateRange } from 'filters/index'; import VnPaginate from 'src/components/ui/VnPaginate.vue'; import CustomerNotificationsFilter from './CustomerDefaulterFilter.vue'; import CustomerBalanceDueTotal from './CustomerBalanceDueTotal.vue'; @@ -16,7 +16,7 @@ import VnInput from 'src/components/common/VnInput.vue'; import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue'; const stateStore = useStateStore(); -const { t } = useI18n(); +const { t, locale } = useI18n(); const quasar = useQuasar(); const dataRef = ref(null); @@ -183,6 +183,34 @@ const onFetch = (data) => { balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0); }; + +function getRange(value) { + let date; + if (locale.value === 'es') { + const [day, month, year] = value.split('/'); + date = new Date(year, month - 1, day); + } else date = new Date(value); + + return dateRange(date); +} + +function exprBuilder(param, value) { + switch (param) { + case 'clientFk': + return { [`d.${param}`]: value?.id }; + case 'creditInsurance': + case 'amount': + case 'workerFk': + case 'countryFk': + case 'payMethod': + case 'salesPersonFk': + return { [`d.${param}`]: value }; + case 'date': + return { 'd.created': { between: getRange(value) } }; + case 'defaulterSinced': + return { 'd.defaulterSinced': { between: getRange(value) } }; + } +}