debug invoice pdf

This commit is contained in:
Omair Saleh
2023-08-10 12:48:47 +08:00
parent dfd1c55136
commit 7e553e39f7
+10 -6
View File
@@ -136,21 +136,25 @@
@endsection
@php
if (!extension_loaded('bcmath')) {
throw new Exception('BCMath extension is not loaded.');
}
function calculateSubtotal($po_order_transaction, $currencyRate) {
$subtotal = 0;
$subtotal = "0";
foreach ($po_order_transaction->transactionDetails as $transaction_detail) {
$unitPrice = $transaction_detail->price / $currencyRate;
$itemTotal = $unitPrice * $transaction_detail->quantity;
$subtotal += $itemTotal;
$unitPrice = bcdiv((string)$transaction_detail->price, (string)$currencyRate, 2);
$itemTotal = bcmul($unitPrice, (string)$transaction_detail->quantity, 2);
$subtotal = bcadd($subtotal, $itemTotal, 2);
}
return $subtotal;
}
function getVoucherDiscount($voucher_redemption) {
return $voucher_redemption ? $voucher_redemption->value * -1 : 0;
return $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0";
}
function calculateTotalInvoice($subtotal, $service_charge, $tax, $voucherDiscount) {
return $subtotal + $service_charge + $tax + $voucherDiscount;
return bcadd(bcadd(bcadd($subtotal, $service_charge, 2), $tax, 2), $voucherDiscount, 2);
}
@endphp