mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
reuse table blade
This commit is contained in:
@@ -69,109 +69,8 @@
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<!-- Table Header -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="stock-code" width="10%">Stock Code</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="10%">Quantity</th>
|
||||
<th width="15%">Unit Price (RM)</th>
|
||||
<th width="10%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$subtotal = "0";
|
||||
$voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 5) : "0";
|
||||
$displayedSubtotal = "0";
|
||||
$exactTotal = "0";
|
||||
@endphp
|
||||
@include('pages.pdfs.purchase_order_table')
|
||||
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
@php
|
||||
$exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 5);
|
||||
$itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5);
|
||||
|
||||
// Round half to even for displayed item total
|
||||
$displayedItemTotal = round(bcmul($exactUnitPrice, $transaction_detail->quantity, 2), 2, PHP_ROUND_HALF_EVEN);
|
||||
|
||||
$displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2);
|
||||
$subtotal = bcadd($subtotal, $itemTotal, 5);
|
||||
$exactTotal = bcadd($exactTotal, $displayedItemTotal, 5);
|
||||
@endphp
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
|
||||
<td class="description">{{ $transaction_detail->product_name }}</td>
|
||||
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
|
||||
<td width="15%" class="center top">
|
||||
{{ number_format($exactUnitPrice, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ number_format($itemTotal, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
@php
|
||||
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5);
|
||||
@endphp
|
||||
<tr class="subtotal">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">{{ number_format($subtotal, 2) }}</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">{{ number_format($transaction->service_charge, 2) }}</td>
|
||||
</tr>
|
||||
|
||||
@if($voucher_redemption)
|
||||
<tr class="voucher">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
|
||||
<td class="right middle">-{{ number_format($voucherDiscount, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
|
||||
@if($transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@php
|
||||
// Calculate the totals with 5 decimal places
|
||||
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
|
||||
// Calculate the displayed totals with 2 decimal places
|
||||
$displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 2), $transaction->tax, 2), $voucherDiscount, 2);
|
||||
|
||||
// Calculate the discrepancy
|
||||
$discrepancy = bcsub($expectedTotal, $displayedTotal, 5);
|
||||
|
||||
// Calculate the final total
|
||||
$total = bcadd($expectedTotal, $discrepancy, 5);
|
||||
@endphp
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Adjustment</td>
|
||||
<td class="right middle">{{number_format($discrepancy, 5)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ number_format($total, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
|
||||
@@ -58,98 +58,8 @@
|
||||
<br>
|
||||
|
||||
<!-- Invoice Table -->
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<!-- Table Header -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="stock-code" width="10%">Stock Code</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="10%">Quantity</th>
|
||||
<th width="15%">Unit Price (RM)</th>
|
||||
<th width="10%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$subtotal = "0";
|
||||
$voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0";
|
||||
$displayedSubtotal = 0;
|
||||
@endphp
|
||||
@include('pages.pdfs.purchase_order_table')
|
||||
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
@php
|
||||
$exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 7);
|
||||
$displayUnitPrice = round($exactUnitPrice, 2);
|
||||
$itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5);
|
||||
$displayedItemTotal = round(bcmul($displayUnitPrice, $transaction_detail->quantity, 7), 2);
|
||||
$displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2);
|
||||
$subtotal = bcadd($subtotal, $itemTotal, 5);
|
||||
@endphp
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
|
||||
<td class="description">{{ $transaction_detail->product_name }}</td>
|
||||
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
|
||||
<td width="15%" class="center top">
|
||||
{{ $displayUnitPrice }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ $displayedItemTotal }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
@php
|
||||
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5);
|
||||
@endphp
|
||||
<tr class="subtotal">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">{{ number_format($displayedSubtotal, 2) }}</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">{{ number_format($transaction->service_charge, 2) }}</td>
|
||||
</tr>
|
||||
|
||||
@if($voucher_redemption)
|
||||
<tr class="voucher">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
|
||||
<td class="right middle">-{{ number_format($voucherDiscount, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
|
||||
@if($transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@php
|
||||
$displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
$discrepancy = bcsub($expectedTotal, $displayedTotal, 5);
|
||||
$total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
@endphp
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Adjustment</td>
|
||||
<td class="right middle">{{number_format($discrepancy, 5)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ number_format($total, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<br>
|
||||
<div class="note">
|
||||
<strong>Note:</strong> All items purchased are subject to our Terms & Conditions. Please refer to our official website for more information.
|
||||
|
||||
@@ -76,109 +76,8 @@
|
||||
|
||||
<br>
|
||||
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<!-- Table Header -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="stock-code" width="10%">Stock Code</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="10%">Quantity</th>
|
||||
<th width="15%">Unit Price (RM)</th>
|
||||
<th width="10%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$subtotal = "0";
|
||||
$voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 5) : "0";
|
||||
$displayedSubtotal = "0";
|
||||
$exactTotal = "0";
|
||||
@endphp
|
||||
@include('pages.pdfs.purchase_order_table')
|
||||
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
@php
|
||||
$exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 5);
|
||||
$itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5);
|
||||
|
||||
// Round half to even for displayed item total
|
||||
$displayedItemTotal = round(bcmul($exactUnitPrice, $transaction_detail->quantity, 2), 2, PHP_ROUND_HALF_EVEN);
|
||||
|
||||
$displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2);
|
||||
$subtotal = bcadd($subtotal, $itemTotal, 5);
|
||||
$exactTotal = bcadd($exactTotal, $displayedItemTotal, 5);
|
||||
@endphp
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
|
||||
<td class="description">{{ $transaction_detail->product_name }}</td>
|
||||
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
|
||||
<td width="15%" class="center top">
|
||||
{{ number_format($exactUnitPrice, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ number_format($itemTotal, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
@php
|
||||
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5);
|
||||
@endphp
|
||||
<tr class="subtotal">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">{{ number_format($subtotal, 2) }}</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">{{ number_format($transaction->service_charge, 2) }}</td>
|
||||
</tr>
|
||||
|
||||
@if($voucher_redemption)
|
||||
<tr class="voucher">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
|
||||
<td class="right middle">-{{ number_format($voucherDiscount, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
|
||||
@if($transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@php
|
||||
// Calculate the totals with 5 decimal places
|
||||
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
|
||||
// Calculate the displayed totals with 2 decimal places
|
||||
$displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 2), $transaction->tax, 2), $voucherDiscount, 2);
|
||||
|
||||
// Calculate the discrepancy
|
||||
$discrepancy = bcsub($expectedTotal, $displayedTotal, 5);
|
||||
|
||||
// Calculate the final total
|
||||
$total = bcadd($expectedTotal, $discrepancy, 5);
|
||||
@endphp
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Adjustment</td>
|
||||
<td class="right middle">{{number_format($discrepancy, 5)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ number_format($total, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<!-- Table Header -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="stock-code" width="10%">Stock Code</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="10%">Quantity</th>
|
||||
<th width="15%">Unit Price (RM)</th>
|
||||
<th width="10%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$subtotal = "0";
|
||||
$voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0";
|
||||
$displayedSubtotal = 0;
|
||||
@endphp
|
||||
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
@php
|
||||
$exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 7);
|
||||
$displayUnitPrice = round($exactUnitPrice, 2);
|
||||
$itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5);
|
||||
$displayedItemTotal = round(bcmul($displayUnitPrice, $transaction_detail->quantity, 7), 2);
|
||||
$displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2);
|
||||
$subtotal = bcadd($subtotal, $itemTotal, 5);
|
||||
@endphp
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
|
||||
<td class="description">{{ $transaction_detail->product_name }}</td>
|
||||
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
|
||||
<td width="15%" class="center top">
|
||||
{{ number_format($displayUnitPrice, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ number_format($displayedItemTotal, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
@php
|
||||
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5);
|
||||
@endphp
|
||||
<tr class="subtotal">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">{{ number_format($displayedSubtotal, 2) }}</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">{{ number_format($transaction->service_charge, 2) }}</td>
|
||||
</tr>
|
||||
|
||||
@if($voucher_redemption)
|
||||
<tr class="voucher">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
|
||||
<td class="right middle">-{{ number_format($voucherDiscount, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
|
||||
@if($transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@php
|
||||
$displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
$discrepancy = bcsub($expectedTotal, $displayedTotal, 5);
|
||||
$total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
|
||||
@endphp
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Adjustment</td>
|
||||
<td class="right middle">{{number_format($discrepancy, 5)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ number_format($total, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
Reference in New Issue
Block a user