debug invoice pdf

This commit is contained in:
Omair Saleh
2023-08-10 12:38:11 +08:00
parent 5d1c537147
commit d7932c488a
+52 -63
View File
@@ -1,21 +1,20 @@
@extends('layouts.base_pdf')
@section('inner_content')
<br>
<htmlpageheader name="page-header">
<br><br>
<div class="separator"><strong><i>{{ $transaction->bill_no }}</i></strong></div>
</htmlpageheader>
<table>
<!-- Header Section -->
<tr>
<td class="header-logo">
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
</td>
<td class="header-cief-address">
<span class="company-name">
<strong>
CIEF WORLDWIDE SDN BHD
</strong>
</span>
<span class="company-name"><strong>CIEF WORLDWIDE SDN BHD</strong></span>
<span class="company-reg">(1134596-M)</span><br>
No. 72-3, Jalan Jalil 1,<br>
The Earth Bukit Jalil,<br>
@@ -23,14 +22,8 @@
Tel: 03-8082 1252
</td>
<td class="header-details">
<div class="title">
<strong>
Invoice
</strong>
</div>
<div class="title"><strong>Invoice</strong></div>
<div class="number">EI#: {{ $transaction->bill_no }}</div>
<div class="ref">Ref# {{ $po_order_transaction->booking->marking }}</div>
<div class="date">Date: {{ $supplier->segments->whereIn('id', [23])->first() ? \Carbon\Carbon::now() : $po_order_transaction->booking->created_at }}</div>
<div>&nbsp;</div>
@@ -38,37 +31,34 @@
</tr>
<tr>
<td colspan="3" class="bill-to">
<span class="sub-title">
Bill To
</span>
<span class="sub-title">Bill To</span>
</td>
</tr>
<tr>
<td colspan="3" class="address">
<div class="label">
{{ $supplier->name }}
</div>
<div class="label">{{ $supplier->name }}</div>
@php
$billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
@endphp
<div class="address">
@php
$billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
@endphp
{{ $billingAddress->street_one }}
{{ $billingAddress->street_two }} ,
{{ $billingAddress->street_two }},
{{ $billingAddress->district()->first()->name }},
{{ $billingAddress->postcode }}
{{ $billingAddress->state()->first()->name }},
{{ $billingAddress->country()->first()->name }}
</div>
<div>
Phone: {{ $supplier->contacts()->first()->phone }}
</div>
<div>Phone: {{ $supplier->contacts()->first()->phone }}</div>
</td>
</tr>
</table>
<br>
<br>
<!-- Invoice Table -->
<table class="line-table" style="overflow: wrap" autosize="1">
<!-- Table Header -->
<thead>
<tr>
<th width="5%">No</th>
@@ -81,11 +71,8 @@
</thead>
<tbody>
@php
$subtotal = 0;
$voucher_redemption = isset($voucher_redemption) ? $voucher_redemption : null;
$voucherDiscount = $voucher_redemption ? $voucher_redemption->value * -1 : 0;
$currencyRate = $transaction->currency_rate;
$subtotal = calculateSubtotal($po_order_transaction, $transaction->currency_rate);
$voucherDiscount = getVoucherDiscount($voucher_redemption);
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
<tr>
@@ -93,19 +80,8 @@
<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">
@php
$unitPrice = $transaction_detail->price / $currencyRate;
@endphp
{{ number_format($unitPrice, 2) }}
</td>
<td width="20%" class="right top">
@php
$itemTotal = $unitPrice * $transaction_detail->quantity;
$subtotal += $itemTotal;
@endphp
{{ number_format($itemTotal, 2) }}
</td>
<td width="15%" class="center top">{{ number_format($transaction_detail->price / $transaction->currency_rate, 2) }}</td>
<td width="20%" class="right top">{{ number_format(($transaction_detail->price / $transaction->currency_rate) * $transaction_detail->quantity, 2) }}</td>
</tr>
@endforeach
</tbody>
@@ -124,19 +100,9 @@
<tr class="voucher">
<td colspan="4"></td>
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
<td class="right middle">-{{ $voucherDiscount }}</td>
<td class="right middle">-{{ number_format($voucherDiscount, 2) }}</td>
</tr>
@endif
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@php
$adjustment = $transaction->amount - $subtotal;
@endphp
{{ number_format($adjustment, 2) }}
</td>
</tr>
@if($transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
@@ -149,19 +115,42 @@
<td class="right middle">Total</td>
<td class="total right middle">
@php
$total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount;
$total = calculateTotalInvoice($subtotal, $transaction->service_charge, $transaction->tax, $voucherDiscount);
@endphp
{{ number_format($total, 2) }}
</td>
</tr>
</tfoot>
</table>
<htmlpagefooter name="page-footer">
<table width="100%">
<tr>
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
</tr>
</table>
</htmlpagefooter>
<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.
</div>
<br><br>
<div class="bank-info">
Please transfer the payment to:<br>
Bank: Maybank Berhad<br>
Account Name: CIEF Worldwide Sdn Bhd<br>
Account No: 564892103405<br>
</div>
@endsection
@php
function calculateSubtotal($po_order_transaction, $currencyRate) {
$subtotal = 0;
foreach ($po_order_transaction->transactionDetails as $transaction_detail) {
$unitPrice = $transaction_detail->price / $currencyRate;
$itemTotal = $unitPrice * $transaction_detail->quantity;
$subtotal += $itemTotal;
}
return $subtotal;
}
function getVoucherDiscount($voucher_redemption) {
return $voucher_redemption ? $voucher_redemption->value * -1 : 0;
}
function calculateTotalInvoice($subtotal, $service_charge, $tax, $voucherDiscount) {
return $subtotal + $service_charge + $tax + $voucherDiscount;
}
@endphp