fix invoice

This commit is contained in:
edmondlang
2025-02-20 16:47:35 +08:00
parent d8e9e8db4a
commit 5a8c486a98
@@ -18,6 +18,26 @@
$currency_id = $transaction->owner->fix_currency_id;
@endphp
<?php
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
$booking = $po_order_transaction->owner;
$paymentSum = $booking->transactions()
->where('type', TransactionType::PAYMENT)
->where('status', ApprovalStatus::COMPLETED)
->get()
->sum(function ($transaction) {
return round($transaction->amount, 2);
});
$refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->calculateRefundAmount($booking, $booking->fix_currency_id);
$totalPayment = $paymentSum - $refundedAmount;
?>
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
@php
$exactUnitPrice = ($currency_id) === 1 ? $transaction_detail->price : bcdiv($transaction_detail->price, $transaction->currency_rate, 7);
@@ -55,10 +75,9 @@
<td class="right">Service Charges</td>
<?php
$serviceCharge = $transaction->service_charge;
if (isset($current_paid_amount)) {
$refundedServiceCharge = $subtotal + $serviceCharge - $current_paid_amount;
$serviceCharge = $serviceCharge - $refundedServiceCharge - $voucherDiscount;
}
$current_paid_amount = $totalPayment;
$refundedServiceCharge = $subtotal + $serviceCharge - $current_paid_amount;
$serviceCharge = $serviceCharge - $refundedServiceCharge - $voucherDiscount;
?>
<td class="right">{{ number_format($serviceCharge, 2) }}</td>
</tr>