From b67a85a95cc6c5819bfbb50b3a0c02584ab524b8 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 19 Jul 2025 14:41:50 +0800 Subject: [PATCH 01/25] E-Invoice - Fix a problem reported by Eileen about Generate Proforma Invoice somehow can bypass filling up E-Invoice info --- ...ateProformaInvoiceTransactionProcessor.php | 6 +- .../forms/PurchaseOrderFormComponent.vue | 62 +++++++++++++++++-- resources/views/partials/footer.blade.php | 2 +- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 7880187b..70a4cec4 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -151,7 +151,8 @@ class CreateProformaInvoiceTransactionProcessor $payable_amount = $booking->transactions()->payments()->where(function ($query) { return $query->where(function ($query) { - return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString()); + // return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString()); + return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->where('expires_on', '>=', Carbon::now()); })->orWhere(function ($query) { return $query->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); }); @@ -164,7 +165,8 @@ class CreateProformaInvoiceTransactionProcessor $paymentAmount = $booking->transactions()->payments()->where(function ($query) { return $query->where(function ($query) { - return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString()); + // return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString()); + return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->where('expires_on', '>=', Carbon::now()); })->orWhere(function ($query) { return $query->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); }); diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue index 1009153b..cbac584e 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue @@ -202,7 +202,19 @@ - + + + + + @@ -321,11 +333,26 @@ this.submit(route('api.transaction.po.import', this.data.id), 'post', this.section, true, true); }, - successHandler(){ - if((Math.round((this.poTotal + Number.EPSILON) * 1000) / 1000).toFixed(3) === (Math.round((this.data.amount + Number.EPSILON) * 1000) / 1000).toFixed(3)){ - this.submitted = true; + successHandler(response, section){ + if(section === this.section + 'CheckTransferRule'){ + this.checkEInvoiceRule(); + } + else if(section === this.section + 'CheckEInvoiceRule'){ + if(response.payload.data.isPassed){ + this.submit(route('api.booking.proforma.create', this.data.id), 'post', this.section, true, true); + } + } + else{ + if((Math.round((this.poTotal + Number.EPSILON) * 1000) / 1000).toFixed(3) === (Math.round((this.data.amount + Number.EPSILON) * 1000) / 1000).toFixed(3)){ + this.submitted = true; + } + this.updateList() + } + }, + errorHandler(error, statusCode, section) { //E-Invoice + if(section === this.section + 'CheckEInvoiceRule' && statusCode === 422){ + $('#modal-einvoice-info').modal('show'); } - this.updateList() }, addProduct(){ this.products.push({ @@ -354,6 +381,31 @@ }, removeProduct(index){ this.products.splice(index, 1); + }, + handleGenerateProformaInvoice(){ + this.checkTransferRule(); + }, + checkTransferRule(){ + this.error = ''; + this.parameters = { + booking_id: this.data.id, + company_id: this.data.company.id, + }; + this.submit(route('api.rule.check.transfer'), 'post', this.section + 'CheckTransferRule', false, true); + }, + checkEInvoiceRule(){ + this.error = ''; + this.parameters = { + company_id: this.data.company.id, + }; + this.submit(route('api.rule.check.einvoice'), 'post', this.section + 'CheckEInvoiceRule', false, true); + }, + updatedEInvoiceInfo(info){ + this.$store.dispatch('reloadList', {'name': "bookingDetailSection"}); + }, + changeOfMindEInvoiceRequest(){ + this.parameters.e_invoice_request = false; + this.submit((this.route('api.company.einvoice.request.change')), 'post', this.section + 'ChangeOfMind', true, true); } }, mixins: [formHandler] diff --git a/resources/views/partials/footer.blade.php b/resources/views/partials/footer.blade.php index 0ace7afd..997cf6f4 100644 --- a/resources/views/partials/footer.blade.php +++ b/resources/views/partials/footer.blade.php @@ -3,7 +3,7 @@
- Copyright © {{ date('Y') }} CIEF Exchange. All rights reserved. Powered by Laravel Vapor. + Copyright © {{ date('Y') }} CIEF Exchange. All rights reserved.
From b2bd5f2a5cdb56e4f5327a75ca35016f3df1f0b3 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 24 Jul 2025 22:27:16 +0800 Subject: [PATCH 02/25] add route preview-unfinished-payment-orders --- routes/web.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/routes/web.php b/routes/web.php index 36aeb598..be760be6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,6 +36,7 @@ use App\Classes\Modules\Transactions\Services\DeletesTransaction; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use App\Classes\General\AWSS3Helper; +use App\Classes\Modules\Bookings\Services\CalculatesBookingPaidAmount; use Illuminate\Support\Facades\File; @@ -1369,3 +1370,45 @@ Route::get('/test-test', function () { Route::get('/maintenance', function () { return response()->view('errors.503', [], 503); }); + +Route::get('/preview-unfinished-payment-orders', function (Request $request) { + echo ''; + echo ' + + + + + + + '; + echo ''; + + $cutOffDate = $request->cut_off_date; + $cutOffDate = Carbon::parse($cutOffDate); + + $bookings = Booking::where('status', '<', ApprovalStatus::COMPLETED); + if ($cutOffDate) { + $bookings->where('created_at', '<=', $cutOffDate); + } + $bookings = $bookings->orderBy('id', 'desc')->get(); + + $calculateBookingPaidAmount = new CalculatesBookingPaidAmount(); + + foreach ($bookings as $booking) { + $paid = $calculateBookingPaidAmount->execute($booking); + $outstanding = $booking->fix_amount - $paid; + + if ($paid > 0 && $outstanding > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + + echo '
Order RefBooking AmountPaid AmountOutstanding AmountCustomerOrder Created Date
'.$booking->marking.'' . number_format($booking->fix_amount, 2) . '' . number_format($paid, 2) . '' . number_format($outstanding, 2) . ''.$booking->company->reference.'' . $booking->created_at->format('d-m-Y') . '
'; +}); \ No newline at end of file From f60241eafcb73b0af2c81c78b029511d2c75c0ce Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 24 Jul 2025 22:46:54 +0800 Subject: [PATCH 03/25] add route preview-unfinished-payment-orders --- routes/web.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index be760be6..6f1184ce 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1372,6 +1372,13 @@ Route::get('/maintenance', function () { }); Route::get('/preview-unfinished-payment-orders', function (Request $request) { + $cutOffDate = $request->cut_off_date; + + if ($cutOffDate) { + echo 'Cut Off Date: ' . $cutOffDate; + echo '

'; + } + echo ''; echo ' @@ -1383,7 +1390,6 @@ Route::get('/preview-unfinished-payment-orders', function (Request $request) { '; echo ''; - $cutOffDate = $request->cut_off_date; $cutOffDate = Carbon::parse($cutOffDate); $bookings = Booking::where('status', '<', ApprovalStatus::COMPLETED); From ed317ed176b85c16aace71d4ee3b4802f67dddbd Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Fri, 25 Jul 2025 14:55:55 +0800 Subject: [PATCH 04/25] add route preview-unfinished-payment-orders --- .../Bookings/Services/CalculatesBookingPaidAmount.php | 10 ++++++++++ routes/web.php | 9 ++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Classes/Modules/Bookings/Services/CalculatesBookingPaidAmount.php b/app/Classes/Modules/Bookings/Services/CalculatesBookingPaidAmount.php index 42ce7589..d3f36916 100644 --- a/app/Classes/Modules/Bookings/Services/CalculatesBookingPaidAmount.php +++ b/app/Classes/Modules/Bookings/Services/CalculatesBookingPaidAmount.php @@ -15,4 +15,14 @@ class CalculatesBookingPaidAmount return $booking->transactions()->payments()->complete()->sum('original_amount'); } + public function executeUntilDate(Booking $booking, Carbon $cutOffDate = null){ + $amount = $booking->transactions()->payments()->complete(); + + if($cutOffDate){ + $amount->where('created_at', '<=', $cutOffDate); + } + + return $amount->sum('original_amount'); + } + } \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 6f1184ce..521d91d1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1372,11 +1372,13 @@ Route::get('/maintenance', function () { }); Route::get('/preview-unfinished-payment-orders', function (Request $request) { - $cutOffDate = $request->cut_off_date; + $cutOffDate = $request->cut_off_date ?? null; if ($cutOffDate) { echo 'Cut Off Date: ' . $cutOffDate; echo '

'; + + $cutOffDate = Carbon::parse($cutOffDate); } echo '
Order Ref
'; @@ -1389,9 +1391,6 @@ Route::get('/preview-unfinished-payment-orders', function (Request $request) { '; echo ''; - - $cutOffDate = Carbon::parse($cutOffDate); - $bookings = Booking::where('status', '<', ApprovalStatus::COMPLETED); if ($cutOffDate) { $bookings->where('created_at', '<=', $cutOffDate); @@ -1401,7 +1400,7 @@ Route::get('/preview-unfinished-payment-orders', function (Request $request) { $calculateBookingPaidAmount = new CalculatesBookingPaidAmount(); foreach ($bookings as $booking) { - $paid = $calculateBookingPaidAmount->execute($booking); + $paid = $calculateBookingPaidAmount->executeUntilDate($booking, $cutOffDate); $outstanding = $booking->fix_amount - $paid; if ($paid > 0 && $outstanding > 0) { From 1bb0a73bd9b2ea368d762482f7c2b862b1e15a07 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Fri, 25 Jul 2025 18:59:02 +0800 Subject: [PATCH 05/25] add route preview-unfinished-payment-orders --- .../Reports/UnfinishedPaymentOrders.php | 155 ++++++++++++++++++ routes/web.php | 52 +----- 2 files changed, 162 insertions(+), 45 deletions(-) create mode 100644 app/Http/Controllers/Reports/UnfinishedPaymentOrders.php diff --git a/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php b/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php new file mode 100644 index 00000000..c3bda14a --- /dev/null +++ b/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php @@ -0,0 +1,155 @@ +input('page', 1); + $perPage = 5000; + $offset = ($page - 1) * $perPage; + $cutOffDate = $request->cut_off_date ? Carbon::parse($request->cut_off_date) : null; + + $baseQuery = Booking::with('company') + ->when($cutOffDate, fn($q) => $q->where('created_at', '<=', $cutOffDate)) + ->orderByDesc('id'); + + $total = $baseQuery->count(); + $bookings = $baseQuery->offset($offset)->limit($perPage)->get(); + + $calculator = new CalculatesBookingPaidAmount(); + + $filtered = $bookings->filter(function ($b) use ($calculator, $cutOffDate) { + $paid = $calculator->executeUntilDate($b, $cutOffDate); + $outstanding = $b->fix_amount - $paid; + return $paid > 0 && $outstanding > 0; + }); + + return response()->json([ + 'success' => true, + 'current_page' => $page, + 'next_page' => ($offset + $perPage < $total) ? $page + 1 : null, + 'count' => $filtered->count(), + 'data' => $filtered->map(function ($b) use ($calculator, $cutOffDate) { + $paid = $calculator->executeUntilDate($b, $cutOffDate); + return [ + 'id' => $b->id, + 'order_ref' => $b->marking ?? $b->id, + 'booking_amount' => number_format($b->fix_amount, 2), + 'paid_amount' => number_format($paid, 2), + 'outstanding_amount' => number_format($b->fix_amount - $paid, 2), + 'customer' => optional($b->company)->reference, + 'created_at' => $b->created_at->toDateTimeString(), + ]; + })->values(), + ]); + } + + public function loadView(Request $request) + { + $cutOffDateString = $request->cut_off_date ?? ''; + $cutOffDateParsed = $cutOffDateString ? Carbon::parse($cutOffDateString)->toDateString() : '-'; + + echo <<Cut Off Date: {$cutOffDateParsed}

+
🔄 Processing... Total 0
+
+ + + +
Order Created Date
+ + + + + + + + + + + +
Order RefBooking AmountPaid AmountOutstanding AmountCustomerOrder Created Date
+ + +HTML; + } +} diff --git a/routes/web.php b/routes/web.php index 521d91d1..b5cb1767 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,7 +36,7 @@ use App\Classes\Modules\Transactions\Services\DeletesTransaction; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use App\Classes\General\AWSS3Helper; -use App\Classes\Modules\Bookings\Services\CalculatesBookingPaidAmount; +use App\Http\Controllers\Reports\UnfinishedPaymentOrders; use Illuminate\Support\Facades\File; @@ -1371,49 +1371,11 @@ Route::get('/maintenance', function () { return response()->view('errors.503', [], 503); }); +// web route to view the result Route::get('/preview-unfinished-payment-orders', function (Request $request) { - $cutOffDate = $request->cut_off_date ?? null; - - if ($cutOffDate) { - echo 'Cut Off Date: ' . $cutOffDate; - echo '

'; - - $cutOffDate = Carbon::parse($cutOffDate); - } - - echo ''; - echo ' - - - - - - - '; - echo ''; - $bookings = Booking::where('status', '<', ApprovalStatus::COMPLETED); - if ($cutOffDate) { - $bookings->where('created_at', '<=', $cutOffDate); - } - $bookings = $bookings->orderBy('id', 'desc')->get(); - - $calculateBookingPaidAmount = new CalculatesBookingPaidAmount(); - - foreach ($bookings as $booking) { - $paid = $calculateBookingPaidAmount->executeUntilDate($booking, $cutOffDate); - $outstanding = $booking->fix_amount - $paid; - - if ($paid > 0 && $outstanding > 0) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - } - - echo '
Order RefBooking AmountPaid AmountOutstanding AmountCustomerOrder Created Date
'.$booking->marking.'' . number_format($booking->fix_amount, 2) . '' . number_format($paid, 2) . '' . number_format($outstanding, 2) . ''.$booking->company->reference.'' . $booking->created_at->format('d-m-Y') . '
'; + return (new UnfinishedPaymentOrders())->loadView($request); +}); +// web route to run the logic +Route::get('/run-batch-unfinished-payment-orders', function (Request $request) { + return (new UnfinishedPaymentOrders())->execute($request); }); \ No newline at end of file From eb9fcbdb238d3e7f7abdc16a8e88d80e70e6c570 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Fri, 25 Jul 2025 19:14:03 +0800 Subject: [PATCH 06/25] add route preview-unfinished-payment-orders --- app/Http/Controllers/Reports/UnfinishedPaymentOrders.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php b/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php index c3bda14a..515f13a4 100644 --- a/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php +++ b/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php @@ -13,7 +13,7 @@ class UnfinishedPaymentOrders extends Controller public function execute(Request $request) { $page = (int) $request->input('page', 1); - $perPage = 5000; + $perPage = 2500; $offset = ($page - 1) * $perPage; $cutOffDate = $request->cut_off_date ? Carbon::parse($request->cut_off_date) : null; From d2787964aa4b2df25a71e83c076292a832ac9db1 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Fri, 25 Jul 2025 19:22:19 +0800 Subject: [PATCH 07/25] add route preview-unfinished-payment-orders --- app/Http/Controllers/Reports/UnfinishedPaymentOrders.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php b/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php index 515f13a4..6266b4a1 100644 --- a/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php +++ b/app/Http/Controllers/Reports/UnfinishedPaymentOrders.php @@ -126,9 +126,9 @@ function runNextBatch() { const row = document.createElement('tr'); row.innerHTML = ` \${item.order_ref} - RM \${item.booking_amount} - RM \${item.paid_amount} - RM \${item.outstanding_amount} + \${item.booking_amount} + \${item.paid_amount} + \${item.outstanding_amount} \${item.customer ?? '-'} \${item.created_at} `; From 2439b8b001cc47ef513befc1f8feb9f6a44538c3 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 27 Jul 2025 18:53:02 +0800 Subject: [PATCH 08/25] E-Invoice - Fix a problem reported by Joanne on 20250721 about customer not able to edit PO details after edit booking amount --- .../components/bookings/forms/PurchaseOrderFormComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue index cbac584e..593c84be 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue @@ -275,7 +275,7 @@ //Condition 2 const paymentsMade = Math.round((this.data.paid_amount + Number.EPSILON) * 100) / 100 > 0; const outstandingAmount = Math.round((this.data.outstanding_amount + Number.EPSILON) * 100) / 100 > 0; - const allPaymentApproved = this.data.payment_history.every(payment => payment.status === 2); + const allPaymentApproved = this.data.payment_history.every(payment => (payment.status === 2 || payment.status === 3)); //Condition 3 const adminBeforeApproval = this.$store.getters.isAdmin && !(this.data.purchase_order.status === 2); From 52a2cc574603b2a67938e602e36326075a0bb48e Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 1 Aug 2025 19:36:30 +0800 Subject: [PATCH 09/25] E-Invoice - Automapping Issues, Sales Invoice Report (Export) --- .../Services/ExportsSalesInvoiceReport.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php index afcab016..685389e5 100644 --- a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php +++ b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php @@ -71,6 +71,8 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR public function map($booking): array { $records = []; + $averageCurrencyRate = 0; + $currencyId = 0; $purchaseOrder = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); $company = $booking->company()->first(); @@ -79,6 +81,29 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR if(!$lastPaymentTransaction){ return $records; } + + $currencyId = $booking->fix_currency_id; + $averageCurrencyRate = $lastPaymentTransaction->currency_rate; + $paymentSum = $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->where('status', ApprovalStatus::COMPLETED) + ->get() + ->sum(function ($transaction) { + return round($transaction->amount, 2); + }); + if ($paymentSum){ + $averageCurrencyRate = $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->where('status', ApprovalStatus::COMPLETED) + ->get() + ->sum(function ($transaction) { + return $transaction->currency_rate; + }) / $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->where('status', ApprovalStatus::COMPLETED) + ->count(); + } + $documentDate = $lastPaymentTransaction->created_at; if(Carbon::parse($booking->updated_at)->isAfter($lastPaymentTransaction->created_at)){ $documentDate = $booking->updated_at; @@ -88,6 +113,12 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR $firstItem = true; $transactionDetails = $purchaseOrder->transactionDetails; foreach ($transactionDetails as $detail) { + $detailPrice = 0; + if($averageCurrencyRate && $currencyId){ + $exactUnitPrice = ($currencyId) === 1 ? $detail->price : bcdiv($detail->price, $averageCurrencyRate, 7); + $displayUnitPrice = round($exactUnitPrice, 2); + $detailPrice = round(bcmul($displayUnitPrice, $detail->quantity, 7), 2); + } $records[] = [ $firstItem ? '<>' : '', $formattedDocumentDate, @@ -100,7 +131,7 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR '022', 'C', $detail->quantity, - number_format($detail->price, 2), + $detailPrice ? number_format($detailPrice, 2): 0, $firstItem ? 'T' : '', $company->e_invoice ? 'F' : 'T' ]; From b63ebdd1e6983d0232cf5b5eac94c42ba9156c94 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 1 Aug 2025 20:03:31 +0800 Subject: [PATCH 10/25] E-Invoice - Automapping Issues, Sales Invoice Report (Export) --- .../Modules/Exports/Services/ExportsSalesInvoiceReport.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php index 685389e5..d7cf1655 100644 --- a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php +++ b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php @@ -113,11 +113,11 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR $firstItem = true; $transactionDetails = $purchaseOrder->transactionDetails; foreach ($transactionDetails as $detail) { - $detailPrice = 0; + $displayUnitPrice = 0; if($averageCurrencyRate && $currencyId){ $exactUnitPrice = ($currencyId) === 1 ? $detail->price : bcdiv($detail->price, $averageCurrencyRate, 7); $displayUnitPrice = round($exactUnitPrice, 2); - $detailPrice = round(bcmul($displayUnitPrice, $detail->quantity, 7), 2); + // $detailPrice = round(bcmul($displayUnitPrice, $detail->quantity, 7), 2); } $records[] = [ $firstItem ? '<>' : '', @@ -131,7 +131,7 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR '022', 'C', $detail->quantity, - $detailPrice ? number_format($detailPrice, 2): 0, + $displayUnitPrice ? number_format($displayUnitPrice, 2): 0, $firstItem ? 'T' : '', $company->e_invoice ? 'F' : 'T' ]; From 0ec2c8b12221ec14230d9c7bbdee6a179d512feb Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 4 Aug 2025 16:30:37 +0800 Subject: [PATCH 11/25] E-Invoice - Automapping Issues, Sales Invoice Report (Export) --- .../Services/ExportsSalesInvoiceReport.php | 132 +++++++++++++++--- 1 file changed, 114 insertions(+), 18 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php index d7cf1655..f3ff3ac6 100644 --- a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php +++ b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php @@ -2,18 +2,17 @@ namespace App\Classes\Modules\Exports\Services; -use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Models\Booking; -use App\Models\Transaction; use Maatwebsite\Excel\Concerns\Exportable; use Maatwebsite\Excel\Concerns\FromQuery; use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithMapping; -use Illuminate\Http\Request; +use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount; +use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundServiceCharge; use Carbon\Carbon; use Illuminate\Support\Facades\Log; @@ -82,8 +81,14 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR return $records; } + $invoiceTransaction = $booking->transactions()->where('type', TransactionType::INVOICE)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->first(); + $currencyId = $booking->fix_currency_id; - $averageCurrencyRate = $lastPaymentTransaction->currency_rate; + + $subtotal = 0; + $displayedSubtotal = 0; + $totalPayment = 0; + $averageCurrencyRate = $invoiceTransaction->currency_rate; $paymentSum = $booking->transactions() ->where('type', TransactionType::PAYMENT) ->where('status', ApprovalStatus::COMPLETED) @@ -93,15 +98,20 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR }); if ($paymentSum){ $averageCurrencyRate = $booking->transactions() - ->where('type', TransactionType::PAYMENT) - ->where('status', ApprovalStatus::COMPLETED) - ->get() - ->sum(function ($transaction) { - return $transaction->currency_rate; - }) / $booking->transactions() - ->where('type', TransactionType::PAYMENT) - ->where('status', ApprovalStatus::COMPLETED) - ->count(); + ->where('type', TransactionType::PAYMENT) + ->where('status', ApprovalStatus::COMPLETED) + ->get() + ->sum(function ($transaction) { + return $transaction->currency_rate; + }) / $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->where('status', ApprovalStatus::COMPLETED) + ->count(); + + $refundedAmount = (App()->make(CalculatesBookingRefundAmount::class))->execute($booking, 1); + $refundedServiceCharge = (App()->make(CalculatesBookingRefundServiceCharge::class))->execute($booking, 1); + + $totalPayment = $paymentSum - $refundedAmount - $refundedServiceCharge; } $documentDate = $lastPaymentTransaction->created_at; @@ -117,14 +127,19 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR if($averageCurrencyRate && $currencyId){ $exactUnitPrice = ($currencyId) === 1 ? $detail->price : bcdiv($detail->price, $averageCurrencyRate, 7); $displayUnitPrice = round($exactUnitPrice, 2); - // $detailPrice = round(bcmul($displayUnitPrice, $detail->quantity, 7), 2); + $itemTotal = bcmul($exactUnitPrice, $detail->quantity, 5); + $displayedItemTotal = round(bcmul($displayUnitPrice, $detail->quantity, 7), 2); + $displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2); + $subtotal = bcadd($subtotal, $itemTotal, 5); } + + $records[] = [ $firstItem ? '<>' : '', - $formattedDocumentDate, - $company->debtor, - $booking->marking, - $booking->marking, + $firstItem ? $formattedDocumentDate : '', + $firstItem ? $company->debtor : '', + $firstItem ? $booking->marking : '', + $firstItem ? $booking->marking : '', '500-0000', 'PRODUCT NAME :', $detail->product_name, @@ -140,6 +155,87 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR $firstItem = false; } } + + + // Service Charge - Starts + $serviceCharge = 0; + if (!$totalPayment) { + $serviceCharge = $invoiceTransaction->service_charge; + } + else { + $serviceCharge = $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->where('status', ApprovalStatus::COMPLETED) + ->get() + ->sum(function ($transaction) { + return $transaction->service_charge; + }); + } + + $records[] = [ + '', + '', + '', + '', + '', + '500-0000', + 'PRODUCT NAME :', + 'Service Charge', + '022', + 'C', + '1', + $serviceCharge ? number_format($serviceCharge, 2): '0', + '', + $company->e_invoice ? 'F' : 'T' + ]; + // Service Charge - Ends + + // Adjustment - Starts + $adjustment = 0; + $voucherRedemption = $invoiceTransaction->voucherRedemption; + $voucherDiscount = $voucherRedemption ? bcmul((string)$voucherRedemption->value, "-1", 2) : "0"; + + $displayedSubtotal = is_numeric($displayedSubtotal) ? sprintf('%F', $displayedSubtotal) : '0'; + $serviceCharge = is_numeric($serviceCharge) ? sprintf('%F', $serviceCharge) : '0'; + $tax = is_numeric($invoiceTransaction->tax) ? sprintf('%F', $invoiceTransaction->tax) : '0'; + $voucherDiscount = is_numeric($voucherDiscount) ? sprintf('%F', $voucherDiscount) : '0'; + + $displayedTotal = bcadd( + bcadd( + bcadd($displayedSubtotal, $serviceCharge, 5), + $tax, + 5 + ), + $voucherDiscount, + 5 + ); + + $expectedTotal = bcadd(bcadd(bcadd($subtotal, $serviceCharge, 5), $invoiceTransaction->tax, 5), $voucherDiscount, 5); + $adjustment = bcsub($expectedTotal, $displayedTotal, 5); + + if ($totalPayment) { + $expectedTotal = $totalPayment; + $adjustment = bcsub($expectedTotal, $displayedTotal, 5); + } + + $records[] = [ + '', + '', + '', + '', + '', + '500-0000', + 'PRODUCT NAME :', + 'Adjustment', + '022', + 'C', + '1', + $adjustment ? number_format($adjustment, 2): '0', + '', + $company->e_invoice ? 'F' : 'T' + ]; + // Adjustment - Ends + return $records; } } From 0e51f4a2361417b2584a01da326d3a34da2d47df Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 4 Aug 2025 23:58:57 +0800 Subject: [PATCH 12/25] E-Invoice - One time processing to generate normal invoice for July 2025 --- ...eTimeBatchProcessEInvoicesV2CommandJob.php | 44 +++++++++++ .../RegenerateInvoiceBookingProcessor.php | 9 ++- .../CreateInvoiceDocumentProcessor.php | 8 +- .../CreateInvoiceTransactionProcessor.php | 12 ++- .../OneTimeBatchProcessEInvoicesV2Command.php | 78 +++++++++++++++++++ 5 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 app/Classes/Jobs/Commands/V2/OneTimeBatchProcessEInvoicesV2CommandJob.php create mode 100644 app/Console/Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php diff --git a/app/Classes/Jobs/Commands/V2/OneTimeBatchProcessEInvoicesV2CommandJob.php b/app/Classes/Jobs/Commands/V2/OneTimeBatchProcessEInvoicesV2CommandJob.php new file mode 100644 index 00000000..26783cbe --- /dev/null +++ b/app/Classes/Jobs/Commands/V2/OneTimeBatchProcessEInvoicesV2CommandJob.php @@ -0,0 +1,44 @@ +booking = $booking; + } + + public function handle() + { + Log::info(Carbon::now() . ': Start job - Processing single booking for E-Invoices for July 2025.'); + $start = new Carbon(); + + $isAllowNormalInvoice = true; + (App()->make(RegenerateInvoiceBookingProcessor::class))->execute($this->booking, $isAllowNormalInvoice); + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + Log::info(Carbon::now() . ': End job - Processing single booking for E-Invoices for July 2025. ElapsedTime: ' . $elapsedTime . '.'); + } +} diff --git a/app/Classes/Modules/Bookings/Processors/RegenerateInvoiceBookingProcessor.php b/app/Classes/Modules/Bookings/Processors/RegenerateInvoiceBookingProcessor.php index 38d89f08..7b392d08 100644 --- a/app/Classes/Modules/Bookings/Processors/RegenerateInvoiceBookingProcessor.php +++ b/app/Classes/Modules/Bookings/Processors/RegenerateInvoiceBookingProcessor.php @@ -14,6 +14,7 @@ use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\Booking; use App\Models\Transaction; use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Log; class RegenerateInvoiceBookingProcessor { @@ -48,7 +49,7 @@ class RegenerateInvoiceBookingProcessor $this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor; } - public function execute(Booking $booking) + public function execute(Booking $booking, bool $isAllowNormalInvoice = false) { $this->updatesBookingStatus->execute($booking, ApprovalStatus::APPROVED); @@ -58,6 +59,8 @@ class RegenerateInvoiceBookingProcessor ->orderBy('created_at', 'asc') ->first(); + Log::info('RegenerateInvoiceBookingProcessor booking: ' . json_encode($booking->marking)); + // get the first bill_no if($firstInvoice){ $firstBillNo = $firstInvoice->bill_no; @@ -90,10 +93,10 @@ class RegenerateInvoiceBookingProcessor $this->deletesDocument->execute($row); } - $this->createInvoiceTransactionProcessor->execute($booking, $firstBillNo, true); + $this->createInvoiceTransactionProcessor->execute($booking, $firstBillNo, true, $isAllowNormalInvoice); } else { - $this->createInvoiceTransactionProcessor->execute($booking); + $this->createInvoiceTransactionProcessor->execute($booking, "", false, $isAllowNormalInvoice); } } } diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index 80f963ca..daf8acce 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -43,7 +43,7 @@ class CreateInvoiceDocumentProcessor * @return void * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function execute($transaction, $purchaseOrder, $supplier, $document_type, $voucherRedemption = null) + public function execute($transaction, $purchaseOrder, $supplier, $document_type, $voucherRedemption = null, $isAllowNormalInvoice = false) { // calculate current Paid Amount $booking = $transaction->owner_type == Booking::class ? $transaction->owner : null; @@ -87,6 +87,12 @@ class CreateInvoiceDocumentProcessor $lowercaseDocumentType = strtolower($document_type); + if($document_type === DocumentType::EINVOICE){ //July 2025 workaround generate normal invoice instead of E-Invoice + if($isAllowNormalInvoice){ + $lowercaseDocumentType = strtolower(DocumentType::INVOICE); + } + } + $order_pdf = LaravelMpdf::loadView('pages.pdfs.' . $lowercaseDocumentType, [ 'transaction' => $transaction, diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index e8c7ff21..44f0dbbf 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -21,6 +21,7 @@ use App\Classes\ValueObjects\Constants\DocumentType; use App\Models\Booking; use App\Models\SegmentConstant; use Carbon\Carbon; +use Illuminate\Support\Facades\Log; class CreateInvoiceTransactionProcessor { @@ -89,7 +90,7 @@ class CreateInvoiceTransactionProcessor * @return void * @throws MalformedRequestException */ - public function execute(Booking $booking, String $invoiceNo= "", bool $isAllowEInvoice = false) + public function execute(Booking $booking, String $invoiceNo= "", bool $isAllowEInvoice = false, bool $isAllowNormalInvoice = false) { if ($booking->status === ApprovalStatus::COMPLETED) { @@ -137,11 +138,18 @@ class CreateInvoiceTransactionProcessor } // $eInvoice = true; //cief todo: 90 - for testing + if($isAllowNormalInvoice){ + $invoiceNo = ""; //July 2025 workaround generate normal invoice instead of E-Invoice + } + if($invoiceNo){ $billNumber = $invoiceNo; } else{ $billNUmberPrefix = $eInvoice ? 'EINV-' : 'INV-'; + if($isAllowNormalInvoice){ + $billNUmberPrefix = 'INV-'; //July 2025 workaround generate normal invoice instead of E-Invoice + } $billNumber = $this->generatesTransactionBillNumber->execute($billNUmberPrefix); } @@ -189,7 +197,7 @@ class CreateInvoiceTransactionProcessor if ($eInvoice) { if($isAllowEInvoice){ - $this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::EINVOICE, $voucherRedemption); + $this->invoiceDocumentProcessor->execute($invoice_transaction, $purchaseOrder, $supplier, DocumentType::EINVOICE, $voucherRedemption, $isAllowNormalInvoice); } } // invoice diff --git a/app/Console/Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php b/app/Console/Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php new file mode 100644 index 00000000..12c24ea7 --- /dev/null +++ b/app/Console/Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php @@ -0,0 +1,78 @@ +startOfDay(); + $endDate = Carbon::create(2025, 7, 31)->endOfDay(); + + $bookings = Booking::where('status', ApprovalStatus::COMPLETED) + ->whereBetween('created_at', [$startDate, $endDate]) + ->get(); + + $count = 0; + foreach ($bookings as $booking) { + $firstInvoice = $booking->transactions() + ->whereIn('type', [TransactionType::INVOICE]) + ->withTrashed() + ->whereBetween('created_at', [$startDate, $endDate]) + ->orderBy('created_at', 'asc') + ->first(); + + $normalInvoice = $booking->documents()->where('document_type', DocumentType::INVOICE)->first(); + $eInvoice = $booking->documents()->where('document_type', DocumentType::EINVOICE)->first(); + + if($firstInvoice && !$normalInvoice && !$eInvoice){ + OneTimeBatchProcessEInvoicesV2CommandJob::dispatch($booking); + $count++; + Log::info('Processed: ' . $count); + Log::info('Booking ID: ' . $booking->marking . ' | created_at: ' . $booking->created_at); + } + } + } +} From d8c6b1a33414d4ae59e3a2507179d9834eca77a4 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 5 Aug 2025 00:46:31 +0800 Subject: [PATCH 13/25] E-Invoice - One time processing to generate normal invoice for July 2025 --- .../Processors/CreateInvoiceDocumentProcessor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php index daf8acce..7ce160ac 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceDocumentProcessor.php @@ -62,9 +62,9 @@ class CreateInvoiceDocumentProcessor if ($bookingCreatedDate->isAfter($eInvoiceStartDate)) { $lastPaymentTransaction = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->latest()->first(); $documentDate = $lastPaymentTransaction->created_at; - if(Carbon::parse($booking->updated_at)->isAfter($lastPaymentTransaction->created_at)){ - $documentDate = $booking->updated_at; - } + // if(Carbon::parse($booking->updated_at)->isAfter($lastPaymentTransaction->created_at)){ //cief todo: 90 - Batch generate E-Invoice date incorrect + // $documentDate = $booking->updated_at; + // } } if($document_type === DocumentType::EINVOICE){ From c795a706c85f011561bc197becb1f78eec70ef02 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 5 Aug 2025 12:45:00 +0800 Subject: [PATCH 14/25] E-Invoice - Automapping Issues, Sales Invoice Report (Export) --- .../Services/ExportsSalesInvoiceReport.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php index f3ff3ac6..76ab6d49 100644 --- a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php +++ b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php @@ -136,10 +136,10 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR $records[] = [ $firstItem ? '<>' : '', - $firstItem ? $formattedDocumentDate : '', - $firstItem ? $company->debtor : '', - $firstItem ? $booking->marking : '', - $firstItem ? $booking->marking : '', + $formattedDocumentDate, + $company->debtor, + $booking->marking, + $booking->marking, '500-0000', 'PRODUCT NAME :', $detail->product_name, @@ -174,10 +174,10 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR $records[] = [ '', - '', - '', - '', - '', + $formattedDocumentDate, + $company->debtor, + $booking->marking, + $booking->marking, '500-0000', 'PRODUCT NAME :', 'Service Charge', @@ -220,10 +220,10 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR $records[] = [ '', - '', - '', - '', - '', + $formattedDocumentDate, + $company->debtor, + $booking->marking, + $booking->marking, '500-0000', 'PRODUCT NAME :', 'Adjustment', From 249bfc09da9ce9f16838663ef7bec79b1a7e37c0 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 5 Aug 2025 14:38:36 +0800 Subject: [PATCH 15/25] E-Invoice - One time processing to generate normal invoice for July 2025 (prevent accidental rerun) --- .../Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Console/Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php b/app/Console/Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php index 12c24ea7..f47ffd03 100644 --- a/app/Console/Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php +++ b/app/Console/Commands/V2/OneTimeBatchProcessEInvoicesV2Command.php @@ -48,6 +48,8 @@ class OneTimeBatchProcessEInvoicesV2Command extends Command */ public function handle() { + return; + $startDate = Carbon::create(2025, 7, 1)->startOfDay(); $endDate = Carbon::create(2025, 7, 31)->endOfDay(); From 45a54bacb89fc149a83f0f8da2709c6bfc32f6dd Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 5 Aug 2025 18:56:14 +0800 Subject: [PATCH 16/25] E-Invoice - Automapping Issues, Sales Invoice Report (Export) --- .../Modules/Exports/Services/ExportsSalesInvoiceReport.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php index 76ab6d49..74598a8d 100644 --- a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php +++ b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php @@ -115,9 +115,9 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR } $documentDate = $lastPaymentTransaction->created_at; - if(Carbon::parse($booking->updated_at)->isAfter($lastPaymentTransaction->created_at)){ - $documentDate = $booking->updated_at; - } + // if(Carbon::parse($booking->updated_at)->isAfter($lastPaymentTransaction->created_at)){ //cief todo: 90 - Report E-Invoice date incorrect + // $documentDate = $booking->updated_at; + // } $formattedDocumentDate = Carbon::parse($documentDate)->format('m/d/Y'); $firstItem = true; From 9f635f40bd0f7aedc21e7f2d807f987194c092c2 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 6 Aug 2025 15:17:34 +0800 Subject: [PATCH 17/25] E-Invoice - Emergency fix to allow admin to generate normal invoice instead of einvoice --- .../RegenerateInvoiceBookingLogic.php | 3 +- .../forms/RegenerateEInvoiceComponent.vue | 1 + ...generateNormalInvoiceEInvoiceComponent.vue | 42 +++++++++++++++++++ .../BookingDetailsSectionComponent.vue | 14 +++++-- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 resources/assets/vue/components/bookings/forms/RegenerateNormalInvoiceEInvoiceComponent.vue diff --git a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php index 39db1708..bf88251f 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/RegenerateInvoiceBookingLogic.php @@ -69,8 +69,9 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic 'with_transactions' => true ] ); + $normalInvoice = $request->input('normal_invoice', false); - $this->regenerateInvoiceBookingProcessor->execute($booking); + $this->regenerateInvoiceBookingProcessor->execute($booking, $normalInvoice); return $this->resourceResponse(new BookingResource($booking)); } diff --git a/resources/assets/vue/components/bookings/forms/RegenerateEInvoiceComponent.vue b/resources/assets/vue/components/bookings/forms/RegenerateEInvoiceComponent.vue index 6d6d15f9..1d2dd9af 100644 --- a/resources/assets/vue/components/bookings/forms/RegenerateEInvoiceComponent.vue +++ b/resources/assets/vue/components/bookings/forms/RegenerateEInvoiceComponent.vue @@ -29,6 +29,7 @@ export default { methods: { submitForm() { + this.parameters.normal_invoice = false; this.submit(this.route('api.booking.einvoice.regenerate', this.data.id), 'post', this.section, true, true); }, successHandler(){ diff --git a/resources/assets/vue/components/bookings/forms/RegenerateNormalInvoiceEInvoiceComponent.vue b/resources/assets/vue/components/bookings/forms/RegenerateNormalInvoiceEInvoiceComponent.vue new file mode 100644 index 00000000..b3279d3e --- /dev/null +++ b/resources/assets/vue/components/bookings/forms/RegenerateNormalInvoiceEInvoiceComponent.vue @@ -0,0 +1,42 @@ + + diff --git a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue index 68dffd3a..c7717536 100644 --- a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue @@ -334,7 +334,7 @@ -
+
Regenerate E-Invoice
@@ -342,6 +342,14 @@
+
+
+
Regenerate Normal Inv
+
+ + + +
@@ -497,7 +505,7 @@
-
+
Change Booking Owner
@@ -614,7 +622,7 @@