From bef54204ff6f3765022bb8ed45a09605caa4e07d Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 23 Aug 2024 11:38:38 +0800 Subject: [PATCH 1/2] fix proforma invoice --- ...ateProformaInvoiceTransactionProcessor.php | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php index 8dab2d24..1a48fc31 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateProformaInvoiceTransactionProcessor.php @@ -118,14 +118,20 @@ class CreateProformaInvoiceTransactionProcessor $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); + $transaction = $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->first(); - $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, - $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), - $configurations->getTotal(), $configurations->getForeignTotal(), 1, - $configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(), - $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], isset($billPlzBill) ? $billPlzBill->id : NULL); + if (!$transaction) { + $object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id, + $configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(), + $configurations->getTotal(), $configurations->getForeignTotal(), 1, + $configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(), + $configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], isset($billPlzBill) ? $billPlzBill->id : NULL + ); - $this->createsTransaction->execute($booking, $object); + $this->createsTransaction->execute($booking, $object); + } $billNumber = $this->generatesTransactionBillNumber->execute('PROFORMA-'); @@ -160,6 +166,11 @@ class CreateProformaInvoiceTransactionProcessor ->whereIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED]) ->sum('tax'); + // delete prev proforma transactions + $booking->transactions() + ->where('type', TransactionType::PROFORMA) + ->delete(); + $transaction_object = new TransactionObject( $billNumber, TransactionType::PROFORMA, @@ -178,11 +189,11 @@ class CreateProformaInvoiceTransactionProcessor ApprovalStatus::APPROVED ); - $perofrma_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object); + $proforma_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object); $supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]); - $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.proforma_invoice', ['invoice_transaction' => $perofrma_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); + $purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.proforma_invoice', ['invoice_transaction' => $proforma_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( DocumentType::PROFORMA_INVOICE, [chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))], From bedee606bc0c0970a77729eeaf9a587d59846867 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 23 Aug 2024 11:48:03 +0800 Subject: [PATCH 2/2] fix proforma invoice --- .../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 b9a0f2d6..035e37e1 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue @@ -173,7 +173,7 @@ - +