From e91e770bf3a7e56dfc119d9d1ded64d8430e5555 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Sun, 30 Oct 2022 18:41:55 +0800 Subject: [PATCH] fix payment due date days filter --- app/Classes/General/Eloquent/Filters/PaymentDay.php | 3 ++- .../paymentsBilling/elements/PaymentFilterComponent.vue | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Classes/General/Eloquent/Filters/PaymentDay.php b/app/Classes/General/Eloquent/Filters/PaymentDay.php index 14b45e81..dabbd9f9 100644 --- a/app/Classes/General/Eloquent/Filters/PaymentDay.php +++ b/app/Classes/General/Eloquent/Filters/PaymentDay.php @@ -3,6 +3,7 @@ namespace App\Classes\General\Eloquent\Filters; +use App\Classes\ValueObjects\Constants\ApprovalStatus; use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder; @@ -17,7 +18,7 @@ class PaymentDay implements Filter public static function apply(Builder $builder, $value) { return $builder->whereHas('transactions', function (Builder $query) use($value) { - $query->where('transactions.type', 1)->whereRaw("DATEDIFF(NOW(), transactions.updated_at) <= $value"); + $query->where('transactions.type', 1)->where('status', ApprovalStatus::APPROVED)->whereDate('updated_at', '<=', Carbon::now()->subdays($value)); }); } } diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentFilterComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentFilterComponent.vue index f3948361..f63ad4d6 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/PaymentFilterComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentFilterComponent.vue @@ -63,7 +63,7 @@ fetchPaymentList(){ this.$store.dispatch('reloadList', {name: this.section}); - this.$store.dispatch('updateListQueue', {name: this.section, page:1, filters: {per_page:5, group_by: 'DATE(transactions.updated_at)', has_invoice_status_in:[2], payment_day:this.parameters.due, credit_term:this.parameters.segment }}); + this.$store.dispatch('updateListQueue', {name: this.section, page:1, filters: {per_page:5, has_invoice_status_in:[2], payment_day:this.parameters.due, credit_term:this.parameters.segment }}); //this.$store.dispatch('toggleSection', {name: this.section, status: true}); //this.$store.dispatch('updateListQueue', {name: this.section, page:1, filters: {per_page:5, group_by: 'transactions.id', payment_day:this.due,has_invoice_status_in:[2] /*,credit_term:[0.0]*/ }});