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.