From 72a945613affdee69e012a863ecf5f798043c30c Mon Sep 17 00:00:00 2001 From: edmondlang Date: Tue, 2 Jan 2024 19:32:02 +0800 Subject: [PATCH] fix po --- .../pages/pdfs/purchase_order_table.blade.php | 3 ++- routes/web.php | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/resources/views/pages/pdfs/purchase_order_table.blade.php b/resources/views/pages/pdfs/purchase_order_table.blade.php index 20fac9b8..69083e93 100644 --- a/resources/views/pages/pdfs/purchase_order_table.blade.php +++ b/resources/views/pages/pdfs/purchase_order_table.blade.php @@ -15,11 +15,12 @@ $subtotal = "0"; $voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0"; $displayedSubtotal = 0; + $currency_id = $transaction->currency_id @endphp @foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail) @php - $exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 7); + $exactUnitPrice = ($currency_id) === 1 : $transaction_detail->price : 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); diff --git a/routes/web.php b/routes/web.php index 674f8f0e..bf2892bb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -112,7 +112,7 @@ Route::get('/transfer/{marking}', function ($marking) { return view('pages.bookings.profile', ['marking' => $marking]); })->name('booking.details'); -Route::get('/transfer/{marking}/latest-invoice', function ($marking) { +Route::get('/transfer/{marking}/latest/{document_type}', function ($marking, $document_type) { $booking= Booking::where('marking', $marking)->first(); $purchaseOrder = $booking->transactions() @@ -126,7 +126,23 @@ Route::get('/transfer/{marking}/latest-invoice', function ($marking) { $supplier = Company::where('id', $transaction->receiver)->first(); - $lowercaseDocumentType = strtolower(DocumentType::INVOICE); + $lowercaseDocumentType = null; + switch ($document_type) { + case 'po': + $lowercaseDocumentType = DocumentType::PURCHASE_ORDER; + break; + case 'do': + $lowercaseDocumentType = DocumentType::DELIVER_ORDER; + break; + case 'sdo': + $lowercaseDocumentType = DocumentType::SUPPLIER_DELIVER_ORDER; + break; + default: + $lowercaseDocumentType = DocumentType::INVOICE; + break; + } + + $lowercaseDocumentType = strtolower($lowercaseDocumentType); $voucherRedemption = $transaction->voucherRedemption;