fix Proforma Invoice

This commit is contained in:
edmondlang
2025-03-11 16:32:14 +08:00
parent 57999faf76
commit e31f708edd
@@ -34,21 +34,25 @@
return round($transaction->amount, 2);
});
$average_currency_rate = $booking->transactions()
->where('type', TransactionType::PAYMENT)
->where('status', ApprovalStatus::COMPLETED)
->get()
->sum(function ($transaction) {
return $transaction->currency_rate;
}) / $booking->transactions()
->where('type', TransactionType::PAYMENT)
->where('status', ApprovalStatus::COMPLETED)
->count();
$totalPayment = 0;
$average_currency_rate = $transaction->currency_rate;
if ($paymentSum){
$average_currency_rate = $booking->transactions()
->where('type', TransactionType::PAYMENT)
->where('status', ApprovalStatus::COMPLETED)
->get()
->sum(function ($transaction) {
return $transaction->currency_rate;
}) / $booking->transactions()
->where('type', TransactionType::PAYMENT)
->where('status', ApprovalStatus::COMPLETED)
->count();
$refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->execute($booking, 1);
$refundedServiceCharge = (App()->make(CalculatesBookingRefundServiceCharge::class))->execute($booking, 1);
$refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->execute($booking, 1);
$refundedServiceCharge = (App()->make(CalculatesBookingRefundServiceCharge::class))->execute($booking, 1);
$totalPayment = $paymentSum - $refundedAmount - $refundedServiceCharge;
$totalPayment = $paymentSum - $refundedAmount - $refundedServiceCharge;
}
?>
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
@@ -87,13 +91,18 @@
<td colspan="4"></td>
<td class="right">Service Charges</td>
<?php
$serviceCharge = $booking->transactions()
->where('type', TransactionType::PAYMENT)
->where('status', ApprovalStatus::COMPLETED)
->get()
->sum(function ($transaction) {
return $transaction->service_charge;
});
if (!$totalPayment) {
$serviceCharge = $transaction->service_charge;
}
else {
$serviceCharge = $booking->transactions()
->where('type', TransactionType::PAYMENT)
->where('status', ApprovalStatus::COMPLETED)
->get()
->sum(function ($transaction) {
return $transaction->service_charge;
});
}
?>
<td class="right">{{ number_format($serviceCharge, 2) }}</td>
</tr>