From 2c2e4eece825b384375a6d84656e86546a4e2bae Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 7 May 2022 20:08:22 +0800 Subject: [PATCH] update generate invoice api --- .../CreateShippingInvoiceTransactionLogic.php | 11 +++++++---- .../containers/elements/PackingListComponent.vue | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php index 1ff9a68f..687bf48c 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php @@ -117,7 +117,8 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic $base_price = $this->getConstantByKey($base_price_constant, date('Y-m-d')); $warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id; - $warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId)->amount; + $selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId); + $warehouse_rate = $selected_warehouse_rate == 0 ? 0 : $selected_warehouse_rate->amount; $stateId = $address->state_id; $state_rate_constant = $this->getConstantByKey($state_rate_constant, $stateId); @@ -127,7 +128,7 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic $this->checkPostcodeExistInConstant($center_postcode_constant, $postcode) === true ? $state_select = 'center' : '' ; $this->checkPostcodeExistInConstant($outstation_postcode_constant, $postcode) === true ? $state_select = 'outstation' : '' ; $state_rate_constant = (array)$state_rate_constant; - $state_rate = $state_rate_constant[$state_select]; + $state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select]; $price_cbm = $base_price + $warehouse_rate + $state_rate; $total_cbm = $price_cbm * ($cbm + $over_weight_cbm); @@ -202,9 +203,11 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic } function checkPostcodeExistInConstant($segmentConstantObject, $postcode) { - if ($segmentConstantObject) { - $segmentConstantObject = $segmentConstantObject->value; + $segmentConstantObject = $segmentConstantObject->value; + if (!empty($segmentConstantObject)) { return in_array($postcode, $segmentConstantObject); + } else { + return false; } } diff --git a/resources/assets/vue/components/containers/elements/PackingListComponent.vue b/resources/assets/vue/components/containers/elements/PackingListComponent.vue index e35bd710..18756ed8 100644 --- a/resources/assets/vue/components/containers/elements/PackingListComponent.vue +++ b/resources/assets/vue/components/containers/elements/PackingListComponent.vue @@ -89,7 +89,7 @@ }, methods: { generateInvoice() { - this.submit(this.route('api.transaction.supplier.create'), 'post', '', true, true); + this.submit(this.route('api.transaction.supplier.create'), 'post', this.section, true, true); }, updateStatus(status){ this.submit(this.route('api.packing_list.status.update', this.item.id, status), 'put', '', true, true)