From 21ee4333ba2ebf1a1d8d05191ce762ad4a013586 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Thu, 6 May 2021 14:01:01 +0800 Subject: [PATCH] fixing bugs --- .../CreatePaymentProofDocumentLogic.php | 2 +- .../CreateInvoiceTransactionProcessor.php | 19 +- .../GeneratesTransactionBillNumber.php | 2 +- .../ValueObjects/Constants/DocumentType.php | 2 +- app/Http/Resources/BookingResource.php | 10 +- .../elements/BookingStatusComponent.vue | 4 +- .../BookingDetailsSectionComponent.vue | 171 +++++++++++------- ...ment_order.blade.php => invoice.blade.php} | 0 8 files changed, 131 insertions(+), 79 deletions(-) rename resources/views/pages/pdfs/{payment_order.blade.php => invoice.blade.php} (100%) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php index 5cc0efec..111cd0db 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php @@ -76,7 +76,7 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); - $object = new DocumentObject(DocumentType::CUSTOMER_PAYMENT_PROOF, $request->input('files'), '', ApprovalStatus::APPROVED, 'china_bank_slip'); + $object = new DocumentObject(DocumentType::CURRENCY_VENDOR_PAYMENT_PROOF, $request->input('files'), '', ApprovalStatus::APPROVED, 'china_bank_slip'); /** @var Document $document */ $document = $this->createsDocument->execute($transaction, $object); diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index 3a5deda3..09bc5982 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -18,6 +18,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\DocumentType; use App\Models\Booking; +use App\Models\Document; use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; use Meneses\LaravelMpdf\Facades\LaravelMpdf; @@ -83,10 +84,10 @@ class CreateInvoiceTransactionProcessor ->first(); if ($po_order_transaction) { - $paymant_amount = $this->calculatesBookingPaidAmount->execute($booking, $booking->fix_currency_id); + $payment_amount = $this->calculatesBookingPaidAmount->execute($booking, $booking->fix_currency_id); $booking_amount = $booking->fix_amount; - if ((float) $booking_amount === (float) $paymant_amount) { + if ((float) $booking_amount === (float) $payment_amount) { $transaction = $booking->transactions() ->where('type', TransactionType::PAYMENT) @@ -113,7 +114,7 @@ class CreateInvoiceTransactionProcessor $transaction->receiver, $transaction->recipient_bank_account_id, $transaction->payment_method, - $paymant_amount, + $payment_amount, $booking_amount, $transaction->currency_id, $transaction->original_currency_id, @@ -146,17 +147,19 @@ class CreateInvoiceTransactionProcessor ApprovalStatus::COMPLETED, 'deliver_orders' ); + + /** @var Document $document */ $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object); $this->createsFile->execute($document, $document_object); - $payment_order_pdf = LaravelMpdf::loadView('pages.pdfs.payment_order', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); + $invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( - DocumentType::PAYMENT_ORDER, - [chunk_split('data:application/pdf;base64,'.base64_encode($payment_order_pdf->output()))], + DocumentType::INVOICE, + [chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))], '', ApprovalStatus::COMPLETED, - 'payment_orders' + 'invoices' ); $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object); $this->createsFile->execute($document, $document_object); @@ -172,7 +175,7 @@ class CreateInvoiceTransactionProcessor $transaction->receiver, $transaction->recipient_bank_account_id, $transaction->payment_method, - $paymant_amount, + $payment_amount, $booking_amount, $transaction->currency_id, $transaction->original_currency_id, diff --git a/app/Classes/Modules/Transactions/Services/GeneratesTransactionBillNumber.php b/app/Classes/Modules/Transactions/Services/GeneratesTransactionBillNumber.php index 6e4e79dd..7f92ab60 100644 --- a/app/Classes/Modules/Transactions/Services/GeneratesTransactionBillNumber.php +++ b/app/Classes/Modules/Transactions/Services/GeneratesTransactionBillNumber.php @@ -28,7 +28,7 @@ class GeneratesTransactionBillNumber public function execute(string $prefix): string { $date = carbon::now(); - $billNumber = $prefix.$date->format('Y').$date->format('m').$date->format('d').mt_rand(10000, 99999); + $billNumber = $prefix.$date->format('Y').$date->format('m').'-'.mt_rand(10000, 99999); return !$this->checksIfTransactionBillNumberExists->execute($billNumber) ? $billNumber : self::execute($prefix); diff --git a/app/Classes/ValueObjects/Constants/DocumentType.php b/app/Classes/ValueObjects/Constants/DocumentType.php index 1f389f59..2b053163 100644 --- a/app/Classes/ValueObjects/Constants/DocumentType.php +++ b/app/Classes/ValueObjects/Constants/DocumentType.php @@ -19,6 +19,6 @@ final class DocumentType { public const PURCHASE_ORDER = 'PURCHASE_ORDER'; public const DELIVER_ORDER = 'DELIVER_ORDER'; - public const PAYMENT_ORDER = 'PAYMENT_ORDER'; + public const INVOICE = 'INVOICE'; public const SUPPLIER_DELIVER_ORDER = 'SUPPLIER_DELIVER_ORDER'; } diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index d05d132b..b92cbac0 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -36,10 +36,12 @@ class BookingResource extends JsonResource 'fixed_currency' => new CurrencyResource($this->fixedCurrency), 'convertible_currency' => new CurrencyResource($this->convertibleCurrency), 'conversion_currency' => new CurrencyResource($this->conversionCurrency), - 'purchase_order_document' => new DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()), - 'deliver_order_document' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), - 'payment_order_document' => new DocumentResource($this->documents()->where('document_type', DocumentType::PAYMENT_ORDER)->first()), - 'supplier_order_document' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), + 'documents' => [ + 'purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()), + 'deliver_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()), + 'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()), + 'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()), + ], 'status' => $this->status, 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), $this->mergeWhen($this->relationLoaded('transactions'), [ diff --git a/resources/assets/vue/components/bookings/elements/BookingStatusComponent.vue b/resources/assets/vue/components/bookings/elements/BookingStatusComponent.vue index 6aab5d6a..25f4c2fd 100644 --- a/resources/assets/vue/components/bookings/elements/BookingStatusComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BookingStatusComponent.vue @@ -1,7 +1,5 @@