From f0e84b92b8e55df2392e63f9481f4559ff9e326d Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Fri, 30 Sep 2022 13:28:28 +0800 Subject: [PATCH] fix proforma invoice currency rate --- .../CreateProformaInvoiceTransactionProcessor.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 87b87950..6aa7b979 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -136,7 +136,11 @@ class CreateProformaInvoiceTransactionProcessor ->where('type', TransactionType::PAYMENT) ->first(); - $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::PAYMENT); + $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){ + return $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + })->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total'); // $booking_currency_average_rate = $booking_amount / $booking->transactions()->payments()->where(function($query){ // return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>', Carbon::now())->get(); // })->orWhere(function($query){