mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
regenerate invoices for 2023
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
use App\Helpers\HelperClass;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
@@ -90,8 +90,8 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$subtotal = InvoiceDocumentsHelper::calculateSubtotal($po_order_transaction, $transaction->currency_rate);
|
||||
$voucherDiscount = InvoiceDocumentsHelper::getVoucherDiscount($voucher_redemption);
|
||||
$subtotal = calculatePoSubtotal($po_order_transaction, $transaction->currency_rate);
|
||||
$voucherDiscount = getPoVoucherDiscount($voucher_redemption);
|
||||
$displayedSubtotal = 0;
|
||||
@endphp
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
</tbody>
|
||||
<tfoot>
|
||||
@php
|
||||
$voucherDiscount = InvoiceDocumentsHelper::getVoucherDiscount($voucher_redemption);
|
||||
$voucherDiscount = getPoVoucherDiscount($voucher_redemption);
|
||||
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); // Use bcsub to subtract
|
||||
@endphp
|
||||
<tr class="subtotal">
|
||||
@@ -156,7 +156,7 @@
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Adjustment</td>
|
||||
<td class="right middle">{{ InvoiceDocumentsHelper::roundUp($discrepancy,2) }}</td>
|
||||
<td class="right middle">{{ roundUpPo($discrepancy,2) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
@@ -175,4 +175,28 @@
|
||||
</tr>
|
||||
</table>
|
||||
</htmlpagefooter>
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user