diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php index 98b25504..b37019a5 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateProformaInvoiceTransactionLogic.php @@ -54,6 +54,7 @@ class CreateProformaInvoiceTransactionLogic extends AbstractControllerLogic * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 21f9885f..398b0de3 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -123,7 +123,9 @@ class CreateProformaInvoiceTransactionProcessor ->where('type', TransactionType::PAYMENT) ->first(); - $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::PAYMENT); + $totalPayment = $booking->fix_currency_id === 1 ? $booking->transactions()->payments()->complete()->sum('original_amount') : + $booking->transactions()->payments()->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) / $totalPayment; $total_service_charge = $booking->transactions() ->where('type', TransactionType::PAYMENT)