From e831205b0afe01863df3f42d3b7f6c63ac036f09 Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Fri, 14 May 2021 17:47:44 -0400 Subject: [PATCH] Bugfix/reload product price (#850) * Reload Product Price * minimal change * Format of values ( Date, Price, Quantity ) Co-authored-by: elsiosanchez --- .../ADempiere/Form/VPOS/Order/index.vue | 165 +++++++++++++++--- .../ADempiere/pointOfSales/point/actions.js | 9 - 2 files changed, 139 insertions(+), 35 deletions(-) diff --git a/src/components/ADempiere/Form/VPOS/Order/index.vue b/src/components/ADempiere/Form/VPOS/Order/index.vue index 2f33894b..2a178749 100644 --- a/src/components/ADempiere/Form/VPOS/Order/index.vue +++ b/src/components/ADempiere/Form/VPOS/Order/index.vue @@ -302,11 +302,16 @@ import formMixin from '@/components/ADempiere/Form/formMixin.js' import orderLineMixin from './orderLineMixin.js' import fieldsListOrder from './fieldsListOrder.js' -import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js' import BusinessPartner from '@/components/ADempiere/Form/VPOS/BusinessPartner' import fieldLine from '@/components/ADempiere/Form/VPOS/Order/line/index' import ProductInfo from '@/components/ADempiere/Form/VPOS/ProductInfo' import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index' +// Format of values ( Date, Price, Quantity ) +import { + formatDate, + formatPrice, + formatQuantity +} from '@/utils/ADempiere/valueFormat.js' export default { name: 'Order', @@ -318,8 +323,7 @@ export default { }, mixins: [ formMixin, - orderLineMixin, - posMixin + orderLineMixin ], data() { return { @@ -393,37 +397,72 @@ export default { }, labelButtonCollections() { return this.isDisabled ? this.$t('form.pos.order.collections') : this.$t('form.pos.order.collect') + }, + currentPointOfSales() { + return this.$store.getters.posAttributes.currentPointOfSales + }, + // Currency Point Of Sales + pointOfSalesCurrency() { + // const currency = this.currentPointOfSales + if (!this.isEmptyValue(this.currentPointOfSales.priceList)) { + return { + ...this.currentPointOfSales.priceList.currency, + amountConvertion: 1 + } + } + return { + uuid: '', + iSOCode: '', + curSymbol: '', + amountConvertion: 1 + } + }, + listPointOfSales() { + return this.$store.getters.posAttributes.listPointOfSales + }, + ordersList() { + if (this.isEmptyValue(this.currentPointOfSales)) { + return [] + } + return this.currentPointOfSales.listOrder + }, + currentOrder() { + if (this.isEmptyValue(this.currentPointOfSales)) { + return { + documentType: {}, + documentStatus: { + value: '' + }, + totalLines: 0, + grandTotal: 0, + salesRepresentative: {}, + businessPartner: { + value: '', + uuid: '' + } + } + } + return this.currentPointOfSales.currentOrder + }, + isDisabled() { + return this.currentPointOfSales.currentOrder.isProcessed + }, + listOrderLine() { + if (this.isEmptyValue(this.currentOrder)) { + return [] + } + return this.currentOrder.lineOrder } }, - // watch: { - // currencyUuid(value) { - // if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) { - // this.$store.dispatch('conversionDivideRate', { - // conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, - // currencyFromUuid: this.pointOfSalesCurrency.uuid, - // currencyToUuid: value - // }) - // } - // }, - // converCurrency(value) { - // if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) { - // this.$store.dispatch('conversionMultiplyRate', { - // containerUuid: 'Order', - // conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, - // currencyFromUuid: this.pointOfSalesCurrency.uuid, - // currencyToUuid: value - // }) - // } else { - // this.$store.commit('currencyMultiplyRate', 1) - // } - // } - // }, mounted() { if (!this.isEmptyValue(this.$route.query.action)) { this.$store.dispatch('reloadOrder', { orderUuid: this.$route.query.action }) } }, methods: { + formatDate, + formatPrice, + formatQuantity, openCollectionPanel() { this.isShowedPOSKeyLayout = !this.isShowedPOSKeyLayout this.$store.commit('setShowPOSCollection', true) @@ -436,6 +475,80 @@ export default { if (!this.seeConversion) { this.seeConversion = true } + }, + getOrderTax(currency) { + return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency) + }, + newOrder() { + this.$router.push({ + params: { + ...this.$route.params + }, + query: { + pos: this.currentPointOfSales.id + } + }).catch(() => { + }).finally(() => { + this.$store.commit('setListPayments', []) + const { templateBusinessPartner } = this.currentPointOfSales + this.$store.commit('updateValuesOfContainer', { + containerUuid: this.metadata.containerUuid, + attributes: [{ + columnName: 'UUID', + value: undefined + }, + { + columnName: 'ProductValue', + value: undefined + }, + { + columnName: 'C_BPartner_ID', + value: templateBusinessPartner.id + }, + { + columnName: 'DisplayColumn_C_BPartner_ID', + value: templateBusinessPartner.name + }, + { + columnName: ' C_BPartner_ID_UUID', + value: templateBusinessPartner.uuid + }] + }) + this.$store.dispatch('setOrder', { + documentType: {}, + documentStatus: { + value: '' + }, + totalLines: 0, + grandTotal: 0, + salesRepresentative: {}, + businessPartner: { + value: '', + uuid: '' + } + }) + this.$store.commit('setShowPOSCollection', false) + this.$store.dispatch('listOrderLine', []) + }) + }, + changePos(posElement) { + this.$store.dispatch('setCurrentPOS', posElement) + this.newOrder() + }, + arrowTop() { + if (this.currentTable > 0) { + this.currentTable-- + this.$refs.linesTable.setCurrentRow(this.listOrderLine[this.currentTable]) + this.currentOrderLine = this.listOrderLine[this.currentTable] + } + }, + arrowBottom() { + const top = this.listOrderLine.length - 1 + if (this.currentTable < top) { + this.currentTable++ + this.$refs.linesTable.setCurrentRow(this.listOrderLine[this.currentTable]) + this.currentOrderLine = this.listOrderLine[this.currentTable] + } } } } diff --git a/src/store/modules/ADempiere/pointOfSales/point/actions.js b/src/store/modules/ADempiere/pointOfSales/point/actions.js index c31a6ec7..e9b48dff 100644 --- a/src/store/modules/ADempiere/pointOfSales/point/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/point/actions.js @@ -60,7 +60,6 @@ export default { }, setCurrentPOS({ commit, dispatch }, posToSet) { commit('currentPointOfSales', posToSet) - const currentPOS = posToSet const oldRoute = router.app._route router.push({ name: oldRoute.name, @@ -78,13 +77,5 @@ export default { commit('setIsReloadProductPrice') commit('setIsReloadListOrders') commit('setShowPOSKeyLayout', false) - - // Maintain Order and Product List - dispatch('listOrdersFromServer', { - posUuid: currentPOS.uuid - }) - dispatch('listProductPriceFromServer', { - currentPOS - }) } }