From e81fc62fd7a22031f8f3a7ff615de3a9b0572978 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Fri, 30 Sep 2022 13:46:54 +0800 Subject: [PATCH] fix proforma invoice currency rate --- .../CreateProformaInvoiceTransactionProcessor.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 7e25680c..8c1e27a7 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -135,11 +135,14 @@ class CreateProformaInvoiceTransactionProcessor $transaction = $booking->transactions() ->where('type', TransactionType::PAYMENT) ->first(); -dd($booking->transactions()->payments() - ->where(function($query){ - $query->where('status', ApprovalStatus::PENDING_SUBMISSION); - })->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total')); - + dd($booking->transactions()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>', Carbon::now())->get()); +dd($booking->transactions()->payments()->where(function($query){ + return $query->where(function($query){ + return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>', Carbon::now()); + })->orWhere(function($query){ + return $query->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + }); +})->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total')); $booking_currency_average_rate = $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id) / $booking->transactions()->payments()->where(function($query){ return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>', Carbon::now())->get(); })->orWhere(function($query){