diff --git a/src/api/ADempiere/form/point-of-sales.js b/src/api/ADempiere/form/point-of-sales.js index cabaa634..e4639038 100644 --- a/src/api/ADempiere/form/point-of-sales.js +++ b/src/api/ADempiere/form/point-of-sales.js @@ -103,6 +103,7 @@ export function updateOrder({ orderUuid, posUuid, customerUuid, + documentTypeUuid, description, warehouseUuid }) { @@ -113,6 +114,7 @@ export function updateOrder({ order_uuid: orderUuid, pos_uuid: posUuid, customer_uuid: customerUuid, + document_type_uuid: documentTypeUuid, description, warehouse_uuid: warehouseUuid } diff --git a/src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js b/src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js index 6ff40f2a..7a77cad5 100644 --- a/src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js +++ b/src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js @@ -23,26 +23,34 @@ export default [ isFromDictionary: true, overwriteDefinition: { size: 24, - sequence: 10, handleFocusGained: true, handleActionPerformed: true, handleActionKeyPerformed: true } + }, + { + elementColumnName: 'C_DocType_ID', + tabindex: '2', + isFromDictionary: true, + overwriteDefinition: { + size: 24, + handleActionPerformed: true, + handleContentSelection: true, + handleActionKeyPerformed: true + } + }, + { + elementColumnName: 'C_DocTypeTarget_ID', + tabindex: '2', + isFromDictionary: true, + overwriteDefinition: { + size: 24, + handleActionPerformed: true, + handleContentSelection: true, + handleActionKeyPerformed: true + } } // { - // elementColumnName: 'QtyEntered', - // columnName: 'QtyEntered', - // tabindex: '2', - // isFromDictionary: true, - // overwriteDefinition: { - // size: 24, - // sequence: 8, - // handleActionPerformed: true, - // handleContentSelection: true, - // handleActionKeyPerformed: true - // } - // }, - // { // elementColumnName: 'PriceEntered', // columnName: 'PriceEntered', // tabindex: '3', diff --git a/src/components/ADempiere/Form/VPOS/Order/index.vue b/src/components/ADempiere/Form/VPOS/Order/index.vue index baacdbc7..c8caae96 100644 --- a/src/components/ADempiere/Form/VPOS/Order/index.vue +++ b/src/components/ADempiere/Form/VPOS/Order/index.vue @@ -26,7 +26,7 @@ height="auto" :style="isShowedPOSKeyLayout ? 'padding-right: 20px; padding-left: 0px;' : 'padding-right: 0px; padding-left: 0px;'" > - + - + + + + + + @@ -178,7 +192,6 @@ -
@@ -454,7 +467,7 @@ export default { styleTab() { const isShowedPOSOptions = this.$store.getters.getIsShowPOSOptions if (this.isShowedPOSKeyLayout || isShowedPOSOptions) { - return 'adding-left: 0px; padding-left: 0px; padding-right: 0px; padding: 0px; ' + return 'padding-left: 0px; padding-left: 0px; padding-right: 0px; padding: 0px; ' } return 'padding-left: 0px; padding-right: 0px; ' }, @@ -481,7 +494,7 @@ export default { }, numberOfLines() { if (this.isEmptyValue(this.currentOrder)) { - return + return 0 } return this.listOrderLine.length }, @@ -560,7 +573,10 @@ export default { }, currentLineOrder() { const line = this.$store.state['pointOfSales/orderLine/index'].line - return line + if (!this.isEmptyValue(line)) { + return line + } + return {} }, currentPriceList() { if (!this.isEmptyValue(this.$store.getters.currentPriceList)) { diff --git a/src/components/ADempiere/Form/VPOS/posMixin.js b/src/components/ADempiere/Form/VPOS/posMixin.js index b21e2db9..e45b3338 100644 --- a/src/components/ADempiere/Form/VPOS/posMixin.js +++ b/src/components/ADempiere/Form/VPOS/posMixin.js @@ -149,22 +149,22 @@ export default { this.$store.dispatch('listOrderLine', []) this.listOrderLines() } else { - this.$store.commit('updateValuesOfContainer', { - parentUuid: this.parentUuid, - containerUuid: this.containerUuid, - attributes: [{ - columnName: 'C_BPartner_ID', - value: value.businessPartner.id - }, - { - columnName: 'DisplayColumn_C_BPartner_ID', - value: value.businessPartner.name - }, - { - columnName: ' C_BPartner_ID_UUID', - value: value.businessPartner.uuid - }] + const businessPartner = this.$store.getters.getValueOfField({ + containerUuid: this.$route.meta.uuid, + columnName: 'C_BPartner_ID' // this.parentMetadata.columnName }) + const documentType = this.$store.getters.getValueOfField({ + containerUuid: this.$route.meta.uuid, + columnName: 'C_DocTypeTarget_ID' // this.parentMetadata.columnName + }) + if (!this.isEmptyValue(businessPartner) && businessPartner !== value.businessPartner.id) { + this.setBusinessPartner(value.businessPartner) + } else if (this.isEmptyValue(businessPartner) && value.businessPartner.id) { + this.setBusinessPartner(value.businessPartner) + } + if (!this.isEmptyValue(documentType) && documentType !== value.documentType.id) { + this.setDocumentType(value.documentType) + } } }, updateOrderProcessPos(value) { @@ -211,31 +211,53 @@ export default { }, updateOrder(update) { // user session + const documentTypeUuid = this.$store.getters.getValueOfField({ + containerUuid: this.$route.meta.uuid, + columnName: 'C_DocTypeTarget_ID_UUID' + }) if (!this.isEmptyValue(update.value) && update.value !== this.currentOrder.businessPartner.uuid && !this.isEmptyValue(this.currentPointOfSales)) { this.$store.dispatch('updateOrder', { orderUuid: this.$route.query.action, posUuid: this.currentPointOfSales.uuid, - customerUuid: update.value + customerUuid: update.value, + documentTypeUuid }) } }, setBusinessPartner({ name, id, uuid }) { // Use update values of container (without subscription) - this.$store.commit('updateValuesOfContainer', { - parentUuid: this.parentUuid, - containerUuid: this.containerUuid, - attributes: [{ - columnName: 'C_BPartner_ID', - value: id - }, - { - columnName: 'DisplayColumn_C_BPartner_ID', - value: name - }, - { - columnName: ' C_BPartner_ID_UUID', - value: uuid - }] + this.$store.commit('updateValueOfField', { + containerUuid: this.$route.meta.uuid, + columnName: 'C_BPartner_ID', + value: id + }) + this.$store.commit('updateValueOfField', { + containerUuid: this.$route.meta.uuid, + columnName: 'DisplayColumn_C_BPartner_ID', + value: name + }) + this.$store.commit('updateValueOfField', { + containerUuid: this.$route.meta.uuid, + columnName: 'C_BPartner_ID_UUID', + value: uuid + }) + }, + setDocumentType({ name, id, uuid }) { + // Use update values of container (without subscription) + this.$store.commit('updateValueOfField', { + containerUuid: this.$route.meta.uuid, + columnName: 'C_DocTypeTarget_ID', + value: id + }) + this.$store.commit('updateValueOfField', { + containerUuid: this.$route.meta.uuid, + columnName: 'DisplayColumn_C_DocTypeTarget_ID', + value: name + }) + this.$store.commit('updateValueOfField', { + containerUuid: this.$route.meta.uuid, + columnName: 'C_DocTypeTarget_ID_UUID', + value: uuid }) }, findProduct(searchValue) { @@ -299,6 +321,10 @@ export default { containerUuid: this.metadata.containerUuid, columnName: 'C_BPartner_ID' }) + const documentTypeUuid = this.$store.getters.getValueOfField({ + containerUuid: this.$route.meta.uuid, + columnName: 'C_DocTypeTarget_ID_UUID' + }) if (this.isEmptyValue(customerUuid) || id === 1000006) { customerUuid = this.currentPointOfSales.templateBusinessPartner.uuid } @@ -306,7 +332,8 @@ export default { this.$store.dispatch('createOrder', { posUuid, customerUuid, - salesRepresentativeUuid: this.currentPointOfSales.salesRepresentative.uuid + salesRepresentativeUuid: this.currentPointOfSales.salesRepresentative.uuid, + documentTypeUuid }) .then(response => { // this.order = response @@ -363,11 +390,6 @@ export default { ...orderToPush }) } - if (!this.isEmptyValue(order.businessPartner)) { - const { businessPartner } = order - this.setBusinessPartner(businessPartner) - } - // this.order = orderToPush }, getOrderTax(currency) { return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency) @@ -390,6 +412,20 @@ export default { this.updateOrderLine(mutation.payload) } break + case 'C_DocTypeTarget_ID': { + const documentTypeUuid = this.$store.getters.getValueOfField({ + containerUuid: mutation.payload.containerUuid, + columnName: 'C_DocTypeTarget_ID_UUID' + }) + if (!this.isEmptyValue(documentTypeUuid) && !this.isEmptyValue(this.currentOrder.documentType.uuid) && this.currentOrder.documentType.uuid !== documentTypeUuid) { + this.$store.dispatch('updateOrder', { + orderUuid: this.$route.query.action, + posUuid: this.currentPointOfSales.uuid, + documentTypeUuid + }) + } + break + } } } else if (mutation.type === 'updateValueOfField') { switch (mutation.payload.columnName) { diff --git a/src/store/modules/ADempiere/pointOfSales/order/actions.js b/src/store/modules/ADempiere/pointOfSales/order/actions.js index db9a3ed9..7c4e3e0b 100644 --- a/src/store/modules/ADempiere/pointOfSales/order/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/order/actions.js @@ -37,13 +37,15 @@ export default { createOrder({ commit, dispatch, rootGetters }, { posUuid, customerUuid, - salesRepresentativeUuid + salesRepresentativeUuid, + documentTypeUuid }) { return createOrder({ posUuid, customerUuid, salesRepresentativeUuid, - warehouseUuid: rootGetters.currentWarehouse.uuid + warehouseUuid: rootGetters.currentWarehouse.uuid, + documentTypeUuid }) .then(order => { commit('setOrder', order) @@ -70,12 +72,16 @@ export default { updateOrder({ commit, dispatch, rootGetters }, { orderUuid, posUuid, - customerUuid + customerUuid, + documentTypeUuid, + warehouseUuid }) { updateOrder({ orderUuid, posUuid, - warehouseUuid: rootGetters.currentWarehouse.uuid + documentTypeUuid, + customerUuid, + warehouseUuid }) .then(response => { dispatch('reloadOrder', { orderUuid: response.uuid })