diff --git a/resources/views/pages/pdfs/InvoiceHelpers.php b/resources/views/pages/pdfs/InvoiceHelpers.php deleted file mode 100644 index ae407479..00000000 --- a/resources/views/pages/pdfs/InvoiceHelpers.php +++ /dev/null @@ -1,24 +0,0 @@ -transactionDetails as $transaction_detail) { - $unitPrice = bcdiv((string)$transaction_detail->price, (string)$currencyRate, 5); - $itemTotal = bcmul($unitPrice, (string)$transaction_detail->quantity, 5); - $subtotal = bcadd($subtotal, $itemTotal, 5); - } - return $subtotal; -} - -function getVoucherDiscount($voucher_redemption) { - return $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0"; -} -function roundUp($number, $decimals) -{ - $factor = pow(10, $decimals); - if ($number > 0) { - return ceil($number * $factor) / $factor; - } else { - return floor($number * $factor) / $factor; - } -} diff --git a/resources/views/pages/pdfs/deliver_order.blade.php b/resources/views/pages/pdfs/deliver_order.blade.php index 75d0d936..c59cc5a9 100644 --- a/resources/views/pages/pdfs/deliver_order.blade.php +++ b/resources/views/pages/pdfs/deliver_order.blade.php @@ -1,4 +1,3 @@ -@include('./InvoiceHelpers') @extends('layouts.base_pdf') @section('inner_content')
@@ -83,8 +82,8 @@ @php - $subtotal = calculateSubtotal($po_order_transaction, $transaction->currency_rate); - $voucherDiscount = getVoucherDiscount($voucher_redemption); + $subtotal = calculateDoSubtotal($po_order_transaction, $transaction->currency_rate); + $voucherDiscount = getDoVoucherDiscount($voucher_redemption); $displayedSubtotal = 0; @endphp @@ -111,7 +110,7 @@ @php - $voucherDiscount = getVoucherDiscount($voucher_redemption); + $voucherDiscount = getDoVoucherDiscount($voucher_redemption); $subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); // Use bcsub to subtract @endphp @@ -149,7 +148,7 @@ Adjustment - {{ roundUp($discrepancy,2) }} + {{ roundUpDo($discrepancy,2) }} @@ -168,4 +167,28 @@ + @php + function calculateDoSubtotal($po_order_transaction, $currencyRate) { + $subtotal = "0"; + foreach ($po_order_transaction->transactionDetails as $transaction_detail) { + $unitPrice = bcdiv((string)$transaction_detail->price, (string)$currencyRate, 5); + $itemTotal = bcmul($unitPrice, (string)$transaction_detail->quantity, 5); + $subtotal = bcadd($subtotal, $itemTotal, 5); + } + return $subtotal; + } + + function getDoVoucherDiscount($voucher_redemption) { + return $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0"; + } + function roundUpDo($number, $decimals) { + $factor = pow(10, $decimals); + if ($number > 0) { + return ceil($number * $factor) / $factor; + } else { + return floor($number * $factor) / $factor; + } + } + + @endphp @endsection diff --git a/resources/views/pages/pdfs/invoice.blade.php b/resources/views/pages/pdfs/invoice.blade.php index cc12d8e6..066fb971 100644 --- a/resources/views/pages/pdfs/invoice.blade.php +++ b/resources/views/pages/pdfs/invoice.blade.php @@ -1,4 +1,3 @@ -@include('./InvoiceHelpers') @extends('layouts.base_pdf') @section('inner_content') diff --git a/resources/views/pages/pdfs/purchase_order.blade.php b/resources/views/pages/pdfs/purchase_order.blade.php index 63ab0db6..e9d1c8fd 100644 --- a/resources/views/pages/pdfs/purchase_order.blade.php +++ b/resources/views/pages/pdfs/purchase_order.blade.php @@ -1,4 +1,3 @@ -@include('./InvoiceHelpers') @extends('layouts.base_pdf') @section('inner_content')
@@ -91,8 +90,8 @@ @php - $subtotal = calculateSubtotal($po_order_transaction, $transaction->currency_rate); - $voucherDiscount = getVoucherDiscount($voucher_redemption); + $subtotal = calculatePoSubtotal($po_order_transaction, $transaction->currency_rate); + $voucherDiscount = getPoVoucherDiscount($voucher_redemption); $displayedSubtotal = 0; @endphp @@ -119,7 +118,7 @@ @php - $voucherDiscount = getVoucherDiscount($voucher_redemption); + $voucherDiscount = getPoVoucherDiscount($voucher_redemption); $subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); // Use bcsub to subtract @endphp @@ -157,7 +156,7 @@ Adjustment - {{ roundUp($discrepancy,2) }} + {{ roundUpPo($discrepancy,2) }} @@ -176,4 +175,28 @@ + @php + function calculatePoSubtotal($po_order_transaction, $currencyRate) { + $subtotal = "0"; + foreach ($po_order_transaction->transactionDetails as $transaction_detail) { + $unitPrice = bcdiv((string)$transaction_detail->price, (string)$currencyRate, 5); + $itemTotal = bcmul($unitPrice, (string)$transaction_detail->quantity, 5); + $subtotal = bcadd($subtotal, $itemTotal, 5); + } + return $subtotal; + } + + function getPoVoucherDiscount($voucher_redemption) { + return $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0"; + } + function roundUpPo($number, $decimals) { + $factor = pow(10, $decimals); + if ($number > 0) { + return ceil($number * $factor) / $factor; + } else { + return floor($number * $factor) / $factor; + } + } + + @endphp @endsection