mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Update voucher details into pdfs i.e invoice, purchase order, delivery order
This commit is contained in:
+3
-1
@@ -83,8 +83,10 @@ class CreateBulkPurchaseOrderTransactionLogic extends AbstractControllerLogic
|
||||
foreach($completed_transactions as $transaction){
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||
|
||||
$voucherRedemption = $transaction->voucherRedemption;
|
||||
|
||||
// purchase order
|
||||
$this->invoiceDocumentProcessor->execute($transaction, $purchaseOrder, $supplier, DocumentType::PURCHASE_ORDER);
|
||||
$this->invoiceDocumentProcessor->execute($transaction, $purchaseOrder, $supplier, DocumentType::PURCHASE_ORDER, $voucherRedemption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ class CreateInvoiceDocumentProcessor
|
||||
* @return void
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($transaction, $purchaseOrder, $supplier, $document_type)
|
||||
public function execute($transaction, $purchaseOrder, $supplier, $document_type, $voucherRedemption = null)
|
||||
{
|
||||
$lowercaseDocumentType = strtolower($document_type);
|
||||
|
||||
$order_pdf = LaravelMpdf::loadView('pages.pdfs.' . $lowercaseDocumentType, ['transaction' => $transaction, 'po_order_transaction' => $purchaseOrder, 'supplier' => $supplier]);
|
||||
$order_pdf = LaravelMpdf::loadView('pages.pdfs.' . $lowercaseDocumentType, ['transaction' => $transaction, 'po_order_transaction' => $purchaseOrder, 'supplier' => $supplier, 'voucher_redemption' => $voucherRedemption]);
|
||||
|
||||
if($purchaseOrder->booking->service_id === 4) {
|
||||
$purchaseOrderDocuments = $purchaseOrder->booking->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->get();
|
||||
|
||||
@@ -116,9 +116,13 @@ class CreateInvoiceTransactionProcessor
|
||||
return;
|
||||
}
|
||||
|
||||
// $transaction = $booking->transactions()
|
||||
// ->where('type', TransactionType::PAYMENT)
|
||||
// ->first();
|
||||
|
||||
$transaction = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->first();
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->latest()->get()[0];
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('INV-');
|
||||
|
||||
@@ -153,16 +157,18 @@ class CreateInvoiceTransactionProcessor
|
||||
);
|
||||
$invoice_transaction = $this->createsTransaction->execute($purchaseOrder->booking, $transaction_object);
|
||||
|
||||
$voucherRedemption = $transaction->voucherRedemption;
|
||||
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||
|
||||
// purchase order
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::PURCHASE_ORDER);
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::PURCHASE_ORDER, $voucherRedemption);
|
||||
|
||||
// deliver order
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::DELIVER_ORDER);
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::DELIVER_ORDER, $voucherRedemption);
|
||||
|
||||
// invoice
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::INVOICE);
|
||||
$this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::INVOICE, $voucherRedemption);
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('SPDO-');
|
||||
|
||||
@@ -191,7 +197,7 @@ class CreateInvoiceTransactionProcessor
|
||||
$supplier_deliver_order_transaction = $this->createsTransaction->execute($purchaseOrder->booking, $transaction_object);
|
||||
|
||||
// supply deliver order
|
||||
$this->invoiceDocumentProcessor->execute($supplier_deliver_order_transaction, $purchaseOrder, $supplier, DocumentType::SUPPLIER_DELIVER_ORDER);
|
||||
$this->invoiceDocumentProcessor->execute($supplier_deliver_order_transaction, $purchaseOrder, $supplier, DocumentType::SUPPLIER_DELIVER_ORDER, null);
|
||||
|
||||
$this->updatesBookingStatus->execute($booking, ApprovalStatus::COMPLETED);
|
||||
|
||||
|
||||
@@ -85,7 +85,18 @@
|
||||
@php
|
||||
$subtotal = 0;
|
||||
@endphp
|
||||
|
||||
@if($voucher_redemption)
|
||||
@php
|
||||
$voucher_discount = $voucher_redemption->value * -1;
|
||||
$original_price = 1 / $voucher_redemption->transaction->currency_rate;
|
||||
$currency_rate = $voucher_redemption->transaction->currency_rate;
|
||||
@endphp
|
||||
@else
|
||||
@php
|
||||
$voucher_discount = 0;
|
||||
$currency_rate = $transaction->currency_rate;
|
||||
@endphp
|
||||
@endif
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
@@ -94,7 +105,7 @@
|
||||
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
|
||||
<td width="15%" class="center top">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2) }}
|
||||
{{ number_format( (1/$currency_rate) * $transaction_detail->price, 2) }}
|
||||
@else
|
||||
{{ number_format($transaction_detail->price, 2) }}
|
||||
@endif
|
||||
@@ -102,10 +113,10 @@
|
||||
<td width="20%" class="right top">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
|
||||
{{ number_format((float)number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
{{ number_format((float)number_format( (1/$currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
|
||||
@php
|
||||
$subtotal += number_format((float)number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
|
||||
$subtotal += number_format((float)number_format( (1/$currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
|
||||
@endphp
|
||||
@else
|
||||
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
@@ -133,12 +144,21 @@
|
||||
{{ 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">
|
||||
-{{ $voucher_redemption->value }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Adjustment</td>
|
||||
<td class="right">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format((float)number_format( (1/$transaction->currency_rate) * $transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
{{ number_format((float)number_format( (1/$currency_rate) * $transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
@else
|
||||
{{ number_format((float)number_format($transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
@endif
|
||||
@@ -156,9 +176,9 @@
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format( ((1/$transaction->currency_rate) * $transaction->amount) + $transaction->service_charge + $transaction->tax, 2) }}
|
||||
{{ number_format( ((1/$currency_rate) * $transaction->amount) + $transaction->service_charge + $transaction->tax + $voucher_discount, 2) }}
|
||||
@else
|
||||
{{ number_format($transaction->amount + $transaction->service_charge + $transaction->tax, 2) }}
|
||||
{{ number_format($transaction->amount + $transaction->service_charge + $transaction->tax + $voucher_discount, 2) }}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -84,7 +84,18 @@
|
||||
@php
|
||||
$subtotal = 0;
|
||||
@endphp
|
||||
|
||||
@if($voucher_redemption)
|
||||
@php
|
||||
$voucher_discount = $voucher_redemption->value * -1;
|
||||
$original_price = 1 / $voucher_redemption->transaction->currency_rate;
|
||||
$currency_rate = $voucher_redemption->transaction->currency_rate;
|
||||
@endphp
|
||||
@else
|
||||
@php
|
||||
$voucher_discount = 0;
|
||||
$currency_rate = $transaction->currency_rate
|
||||
@endphp
|
||||
@endif
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
@@ -93,7 +104,7 @@
|
||||
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
|
||||
<td width="15%" class="center top">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2) }}
|
||||
{{ number_format( (1/$currency_rate) * $transaction_detail->price, 2) }}
|
||||
@else
|
||||
{{ number_format($transaction_detail->price, 2) }}
|
||||
@endif
|
||||
@@ -101,10 +112,10 @@
|
||||
<td width="20%" class="right top">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
|
||||
{{ number_format((float)number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
{{ number_format((float)number_format( (1/$currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
|
||||
@php
|
||||
$subtotal += number_format((float)number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
|
||||
$subtotal += number_format((float)number_format( (1/$currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
|
||||
@endphp
|
||||
@else
|
||||
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
@@ -132,12 +143,21 @@
|
||||
{{ 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">
|
||||
-{{ $voucher_redemption->value }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Adjustment</td>
|
||||
<td class="right">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format((float)number_format( (1/$transaction->currency_rate) * $transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
{{ number_format((float)number_format( (1/$currency_rate) * $transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
@else
|
||||
{{ number_format((float)number_format($transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
@endif
|
||||
@@ -155,9 +175,9 @@
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format( ((1/$transaction->currency_rate) * $transaction->amount) + $transaction->service_charge + $transaction->tax, 2) }}
|
||||
{{ number_format( ((1/$currency_rate) * $transaction->amount) + $transaction->service_charge + $transaction->tax + $voucher_discount, 2) }}
|
||||
@else
|
||||
{{ number_format($transaction->amount + $transaction->service_charge + $transaction->tax, 2) }}
|
||||
{{ number_format($transaction->amount + $transaction->service_charge + $transaction->tax + $voucher_discount, 2) }}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -91,7 +91,18 @@
|
||||
@php
|
||||
$subtotal = 0;
|
||||
@endphp
|
||||
|
||||
@if($voucher_redemption)
|
||||
@php
|
||||
$voucher_discount = $voucher_redemption->value * -1;
|
||||
$original_price = 1 / $voucher_redemption->transaction->currency_rate;
|
||||
$currency_rate = $voucher_redemption->transaction->currency_rate;
|
||||
@endphp
|
||||
@else
|
||||
@php
|
||||
$voucher_discount = 0;
|
||||
$currency_rate = $transaction->currency_rate;
|
||||
@endphp
|
||||
@endif
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
<tr>
|
||||
<td width="5%" class="center top">{{ $key + 1 }}</td>
|
||||
@@ -100,7 +111,7 @@
|
||||
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
|
||||
<td width="15%" class="center top">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2) }}
|
||||
{{ number_format( (1/$currency_rate) * $transaction_detail->price, 2) }}
|
||||
@else
|
||||
{{ number_format($transaction_detail->price, 2) }}
|
||||
@endif
|
||||
@@ -108,10 +119,10 @@
|
||||
<td width="20%" class="right top">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
|
||||
{{ number_format((float)number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
{{ number_format((float)number_format( (1/$currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
|
||||
@php
|
||||
$subtotal += number_format((float)number_format( (1/$transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
|
||||
$subtotal += number_format((float)number_format( (1/$currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
|
||||
@endphp
|
||||
@else
|
||||
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
@@ -139,12 +150,21 @@
|
||||
{{ 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">
|
||||
-{{ $voucher_redemption->value }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Adjustment</td>
|
||||
<td class="right">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format((float)number_format( (1/$transaction->currency_rate) * $transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
{{ number_format((float)number_format( (1/$currency_rate) * $transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
@else
|
||||
{{ number_format((float)number_format($transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
@endif
|
||||
@@ -162,9 +182,9 @@
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
@if($transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format( ((1/$transaction->currency_rate) * $transaction->amount) + $transaction->service_charge + $transaction->tax, 2) }}
|
||||
{{ number_format( ((1/$currency_rate) * $transaction->amount) + $transaction->service_charge + $transaction->tax + $voucher_discount, 2) }}
|
||||
@else
|
||||
{{ number_format($transaction->amount + $transaction->service_charge + $transaction->tax, 2) }}
|
||||
{{ number_format($transaction->amount + $transaction->service_charge + $transaction->tax + $voucher_discount, 2) }}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user