diff --git a/src/components/ADempiere/Dialog/index.vue b/src/components/ADempiere/Dialog/index.vue index 3840496b..442791e8 100644 --- a/src/components/ADempiere/Dialog/index.vue +++ b/src/components/ADempiere/Dialog/index.vue @@ -180,7 +180,7 @@ export default { this.$store.dispatch('processPos', { action: action, // process metadata parentUuid: this.parentUuid, - idProcess: this.$store.getters.getFindOrder.id, + idProcess: this.$store.getters.posAttributes.currentOrder.id, containerUuid: this.containerUuid, panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) parametersList: this.$store.getters.getPosParameters diff --git a/src/components/ADempiere/Form/PriceChecking/index.vue b/src/components/ADempiere/Form/PriceChecking/index.vue index 8e78aed5..879fa283 100644 --- a/src/components/ADempiere/Form/PriceChecking/index.vue +++ b/src/components/ADempiere/Form/PriceChecking/index.vue @@ -143,7 +143,7 @@ export default { return this.currentImageOfProduct }, currentPoint() { - return this.$store.getters.getCurrentPOS + return this.$store.getters.posAttributes.currentPointOfSales } }, created() { diff --git a/src/components/ADempiere/Form/ProductInfo/index.vue b/src/components/ADempiere/Form/ProductInfo/index.vue index 063a2427..2d6d7843 100644 --- a/src/components/ADempiere/Form/ProductInfo/index.vue +++ b/src/components/ADempiere/Form/ProductInfo/index.vue @@ -71,7 +71,7 @@ export default { return [] }, currentPos() { - return this.$store.getters.getCurrentPOS + return this.$store.getters.posAttributes.currentPointOfSales }, keyShortcuts() { return { diff --git a/src/components/ADempiere/Form/ProductInfo/productList.vue b/src/components/ADempiere/Form/ProductInfo/productList.vue index 84f5cacc..192f39e7 100644 --- a/src/components/ADempiere/Form/ProductInfo/productList.vue +++ b/src/components/ADempiere/Form/ProductInfo/productList.vue @@ -199,7 +199,7 @@ export default { return this.$store.state['pointOfSales/listProductPrice'].productPrice[this.attribute] }, currentPoint() { - return this.$store.getters.getCurrentPOS + return this.$store.getters.posAttributes.currentPointOfSales }, productPrice() { return this.$store.getters.getProductPrice @@ -223,7 +223,7 @@ export default { return (!isLoaded || isReload) // && this.isShowProductsPriceList }, listPrice() { - const pos = this.$store.getters.getCurrentPOS + const pos = this.currentPoint if (!this.isEmptyValue(pos)) { return pos.priceList.id } @@ -403,7 +403,6 @@ export default { * @param {object} PointOfSales */ validatePos(PointOfSales) { - console.log(this.isEmptyValue(PointOfSales), this.isReadyFromGetData) if (this.isEmptyValue(PointOfSales)) { const message = this.$t('notifications.errorPointOfSale') this.$store.commit('setListProductPrice', { diff --git a/src/components/ADempiere/Form/VPOS/BusinessPartner/mixinBusinessPartner.js b/src/components/ADempiere/Form/VPOS/BusinessPartner/mixinBusinessPartner.js index 2ebd0bd7..5f6be212 100644 --- a/src/components/ADempiere/Form/VPOS/BusinessPartner/mixinBusinessPartner.js +++ b/src/components/ADempiere/Form/VPOS/BusinessPartner/mixinBusinessPartner.js @@ -119,7 +119,7 @@ export default { } }) - valuesToSend['posUuid'] = this.$store.getters.getPointOfSalesUuid + valuesToSend['posUuid'] = this.$store.getters.posAttributes.currentPointOfSales.uuid return valuesToSend }, setBusinessPartner({ id, name, uuid }, isCloseForm = true) { diff --git a/src/components/ADempiere/Form/VPOS/Collection/index.vue b/src/components/ADempiere/Form/VPOS/Collection/index.vue index a11d1c02..1b756054 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/index.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/index.vue @@ -32,10 +32,10 @@ - {{ formatPrice(currentOrder.grandTotal, currencyPoint.iSOCode) }} + {{ formatPrice(currentOrder.grandTotal, pointOfSalesCurrency.iSOCode) }} @@ -50,10 +50,10 @@ - {{ formatPrice(pending, currencyPoint.iSOCode) }} + {{ formatPrice(pending, pointOfSalesCurrency.iSOCode) }} @@ -75,7 +75,7 @@ :key="field.columnName" :metadata-field="field.columnName === 'PayAmt' ? { ...field, - labelCurrency: isEmptyValue($store.getters.getFieldCuerrency) ? currencyPoint : $store.getters.getFieldCuerrency + labelCurrency: isEmptyValue($store.getters.getFieldCuerrency) ? pointOfSalesCurrency : $store.getters.getFieldCuerrency } : field" /> @@ -94,7 +94,7 @@ @@ -125,10 +125,10 @@ - {{ formatPrice(currentOrder.grandTotal, currencyPoint.iSOCode) }} + {{ formatPrice(currentOrder.grandTotal, pointOfSalesCurrency.iSOCode) }} @@ -144,10 +144,10 @@ - {{ formatPrice(pending, currencyPoint.iSOCode) }} + {{ formatPrice(pending, pointOfSalesCurrency.iSOCode) }} @@ -163,10 +163,10 @@ - {{ formatPrice(pay, currencyPoint.iSOCode) }} + {{ formatPrice(pay, pointOfSalesCurrency.iSOCode) }} @@ -181,10 +181,10 @@ - {{ formatPrice(change, currencyPoint.iSOCode) }} + {{ formatPrice(change, pointOfSalesCurrency.iSOCode) }} @@ -205,6 +205,7 @@ import typeCollection from '@/components/ADempiere/Form/VPOS/Collection/typeColl import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index' import { formatDate, formatPrice } from '@/utils/ADempiere/valueFormat.js' import { processOrder } from '@/api/ADempiere/form/point-of-sales.js' +import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js' export default { name: 'Collection', @@ -213,7 +214,8 @@ export default { convertAmount }, mixins: [ - formMixin + formMixin, + posMixin ], props: { isLoadedPanel: { @@ -261,7 +263,6 @@ export default { } } return collection - // return false }, fullCopper() { if ((this.change > this.isCashAmt) && this.pay > this.currentOrder.grandTotal) { @@ -284,14 +285,14 @@ export default { }, listPayments() { const listLocal = this.$store.getters.getPaymentBox - const listServer = this.$store.getters.getPos.listPayments + const listServer = this.currentOrder.listPayments if (!this.sendToServer) { return listServer.payments } return listLocal }, isLoadedPayments() { - return this.$store.getters.getPos.listPayments.isLoaded + return this.currentOrder.listPayments.isLoaded }, paymentBox() { const payment = this.listPayments.filter(pay => { @@ -418,21 +419,6 @@ export default { } return 0 }, - currencyPoint() { - const currency = this.$store.getters.getCurrentPOS - if (!this.isEmptyValue(currency)) { - return currency.priceList.currency - } - return { - uuid: '', - iSOCode: '', - curSymbol: '', - id: 0 - } - }, - currentOrder() { - return this.$store.getters.getPos.currentOrder - }, typeCurrency() { return this.$store.getters.getValueOfField({ containerUuid: this.containerUuid, @@ -445,12 +431,6 @@ export default { columnName: 'C_Currency_ID_UUID' }) }, - displayeTypeCurrency() { - return this.$store.getters.getValueOfField({ - containerUuid: this.containerUuid, - columnName: 'DisplayColumn_C_Currency_ID' - }) - }, multiplyRate() { return this.$store.getters.getMultiplyRate }, @@ -479,9 +459,6 @@ export default { } return true }, - fieldpending() { - return this.pending - }, displayCurrency() { return this.$store.getters.getListCurrency }, @@ -491,18 +468,11 @@ export default { updateOrderPaymentPos() { return this.$store.getters.getUpdatePaymentPos }, - isDisabled() { - return this.$store.getters.getPos.isProcessed + currentPointOfSales() { + return this.$store.getters.posAttributes.currentPointOfSales } }, watch: { - fieldpending(value) { - this.$store.commit('updateValueOfField', { - containerUuid: this.containerUuid, - columnName: 'PayAmt', - value: value - }) - }, pending(value) { this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, @@ -513,17 +483,17 @@ export default { currencyUuid(value) { if (!this.isEmptyValue(value)) { this.$store.dispatch('conversionDivideRate', { - conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, - currencyFromUuid: this.currencyPoint.uuid, + conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, + currencyFromUuid: this.pointOfSalesCurrency.uuid, currencyToUuid: value }) } if (this.isEmptyValue(value)) { - this.$store.commit('setFieldCurrency', this.currencyPoint) + this.$store.commit('setFieldCurrency', this.pointOfSalesCurrency) this.$store.dispatch('conversionDivideRate', { containerUuid: 'Collection', - conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, - currencyFromUuid: this.currencyPoint.uuid, + conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, + currencyFromUuid: this.pointOfSalesCurrency.uuid, currencyToUuid: value }) } @@ -534,6 +504,18 @@ export default { } this.allPayCurrency = this.pay }, + converCurrency(value) { + if (!this.isEmptyValue(value)) { + this.$store.dispatch('conversionMultiplyRate', { + containerUuid: 'Collection', + conversionTypeUuid: this.currentPointOfSales, + currencyFromUuid: this.pointOfSalesCurrency.uuid, + currencyToUuid: value + }) + } else { + this.$store.commit('currencyMultiplyRate', 1) + } + }, isLoaded(value) { if (value) { this.$store.commit('updateValueOfField', { @@ -566,7 +548,7 @@ export default { }, addCollectToList() { const containerUuid = this.containerUuid - const posUuid = this.$store.getters.getCurrentPOS.uuid + const posUuid = this.currentPointOfSales.uuid const orderUuid = this.$route.query.action const bankUuid = this.$store.getters.getValueOfField({ containerUuid, @@ -597,7 +579,7 @@ export default { columnName: 'C_Currency_ID' }) const currencyToPay = this.isEmptyValue(currencyUuid) ? currencyId : currencyUuid - if (this.isEmptyValue(this.currencyDisplay(currencyToPay)) && this.currencyDisplay(currencyToPay).currencyUuid !== this.currencyPoint.uuid) { + if (this.isEmptyValue(this.currencyDisplay(currencyToPay)) && this.currencyDisplay(currencyToPay).currencyUuid !== this.pointOfSalesCurrency.uuid) { this.amontSend = this.convert.divideRate * this.amontSend } if (this.sendToServer) { @@ -626,8 +608,7 @@ export default { this.addCollect() }, updateServer(listPaymentsLocal) { - // const listLocal = this.$store.getters.getPaymentBox - const posUuid = this.$store.getters.getCurrentPOS.uuid + const posUuid = this.currentPointOfSales.uuid const orderUuid = this.$route.query.action this.$store.dispatch('uploadOrdersToServer', { listPaymentsLocal, posUuid, orderUuid }) }, @@ -648,7 +629,7 @@ export default { this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, columnName: 'C_Currency_ID', - value: this.currencyPoint.id + value: this.pointOfSalesCurrency.id }) this.$store.commit('updateValueOfField', { parentUuid: '', @@ -683,7 +664,7 @@ export default { this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, columnName: 'C_Currency_ID', - value: this.currencyPoint.id + value: this.pointOfSalesCurrency.id }) this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, @@ -723,17 +704,17 @@ export default { this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, columnName: 'DisplayColumn_C_Currency_ID', - value: this.currencyPoint.iSOCode + value: this.pointOfSalesCurrency.iSOCode }) this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, columnName: 'C_Currency_ID', - value: this.currencyPoint.id + value: this.pointOfSalesCurrency.id }) this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, columnName: 'C_Currency_ID_UUID', - value: this.currencyPoint.uuid + value: this.pointOfSalesCurrency.uuid }) }, defaulTenderType() { @@ -753,11 +734,19 @@ export default { if (display) { return display } - if (currency === this.currencyPoint.id) { - return this.currencyPoint.uuid + if (currency === this.pointOfSalesCurrency.id) { + return this.pointOfSalesCurrency.uuid } return currency }, + convertCurrency() { + const convertCurrency = this.currencyDisplay(100) + this.$store.dispatch('convertionPayment', { + conversionTypeUuid: this.currentPointOfSales, + currencyFromUuid: this.pointOfSalesCurrency.uuid, + currencyToUuid: convertCurrency.currencyUuid + }) + }, undoPatment() { const list = this.listPayments[this.listPayments.length - 1] const orderUuid = list.orderUuid @@ -768,7 +757,7 @@ export default { }) }, completePreparedOrder(payment) { - const posUuid = this.$store.getters.getCurrentPOS.uuid + const posUuid = this.currentPointOfSales.uuid const orderUuid = this.$route.query.action this.$store.dispatch('updateOrderPos', true) this.$store.dispatch('updatePaymentPos', true) @@ -800,7 +789,7 @@ export default { }) .finally(() => { this.$store.dispatch('listOrdersFromServer', { - posUuid: this.$store.getters.getCurrentPOS.uuid + posUuid: this.currentPointOfSales.uuid }) this.$store.dispatch('updateOrderPos', false) this.$store.dispatch('updatePaymentPos', false) diff --git a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue index d3988376..6d76fa85 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue @@ -99,9 +99,13 @@ import { import { requestGetConversionRate } from '@/api/ADempiere/form/point-of-sales.js' +import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js' export default { name: 'TypeCollection', + mixins: [ + posMixin + ], props: { isAddTypePay: { type: Array, @@ -151,7 +155,7 @@ export default { const currencyUuid = this.isAddTypePay.find(pay => pay.currencyUuid !== this.currency.uuid) if (!this.isEmptyValue(currencyUuid)) { requestGetConversionRate({ - conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, + conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, currencyFromUuid: this.currency.uuid, currencyToUuid: currencyUuid.currencyUuid }) diff --git a/src/components/ADempiere/Form/VPOS/KeyLayout/index.vue b/src/components/ADempiere/Form/VPOS/KeyLayout/index.vue index 1e351d75..842e16a8 100644 --- a/src/components/ADempiere/Form/VPOS/KeyLayout/index.vue +++ b/src/components/ADempiere/Form/VPOS/KeyLayout/index.vue @@ -126,11 +126,8 @@ export default { defaultImage() { return require('@/image/ADempiere/pos/no-image.jpg') }, - currentPoint() { - return this.$store.getters.getCurrentPOS - }, - listOrderLine() { - return this.$store.getters.getPos.lineOrder + currentPointOfSales() { + return this.$store.getters.posAttributes.currentPointOfSales }, getKeyLayout() { return this.$store.getters.getKeyLayout @@ -176,7 +173,7 @@ export default { methods: { formatQuantity, loadKeyLayout(uuid = null) { - const currentPOS = this.currentPoint + const currentPOS = this.currentPointOfSales if (this.isEmptyValue(currentPOS) || this.isEmptyValue(currentPOS.uuid)) { this.$message({ type: 'warn', @@ -254,10 +251,10 @@ export default { } }, handleCommand(command) { - const point = this.$store.getters.getPointOfSalesUuid.keyLayoutUuid + const point = this.$store.getters.posAttributes.currentPointOfSales.uuid const toReturn = this.getKeyList.find(keyLayoutItem => keyLayoutItem.subKeyLayoutUuid === point) - let keyLayoutUuid = this.currentPoint.keyLayoutUuid + let keyLayoutUuid = this.currentPointOfSales.keyLayoutUuid if (!this.isEmptyValue(toReturn)) { keyLayoutUuid = toReturn.subKeyLayoutUuid } diff --git a/src/components/ADempiere/Form/VPOS/Options/index.vue b/src/components/ADempiere/Form/VPOS/Options/index.vue index bf9c4f17..40502149 100644 --- a/src/components/ADempiere/Form/VPOS/Options/index.vue +++ b/src/components/ADempiere/Form/VPOS/Options/index.vue @@ -238,7 +238,7 @@

@@ -260,7 +260,6 @@ :is-selectable="false" popover-name="isShowPopoverMenu" /> -
{ - console.info(`VPOS/Options component (New Order): ${error.message}`) - }).finally(() => { - const { templateBusinessPartner } = this.$store.getters.getCurrentPOS - // TODO: Set order with POS Terminal default values - this.$store.commit('setListPayments', { - payments: [] - }) - this.$store.dispatch('setOrder', { - documentType: {}, - documentStatus: { - value: '' - }, - totalLines: 0, - grandTotal: 0, - salesRepresentative: {}, - businessPartner: { - value: '', - uuid: '' - } - }) - this.$store.dispatch('listOrderLine', []) - this.$store.commit('setShowPOSCollection', false) - 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: this.$store.getters['user/getUserUuid'] - }] - }) - }) - }, printOrder() { printOrder({ orderUuid: this.$route.query.action @@ -454,7 +378,7 @@ export default { }) }, completePreparedOrder() { - const posUuid = this.currentPoint.uuid + const posUuid = this.currentPointOfSales.uuid this.$store.dispatch('updateOrderPos', true) this.$store.dispatch('updatePaymentPos', true) this.$message({ @@ -465,8 +389,8 @@ export default { processOrder({ posUuid, orderUuid: this.$route.query.action, - createPayments: !this.isEmptyValue(this.$store.getters.getPos.listPayments), - payments: this.$store.getters.getPos.listPayments + createPayments: !this.isEmptyValue(this.currentOrder.listPayments), + payments: this.currentOrder.listPayments }) .then(response => { this.$store.dispatch('reloadOrder', response.uuid) @@ -485,7 +409,7 @@ export default { }) .finally(() => { this.$store.dispatch('listOrdersFromServer', { - posUuid: this.$store.getters.getCurrentPOS.uuid + posUuid: this.currentPointOfSales.uuid }) this.$store.dispatch('updateOrderPos', false) this.$store.dispatch('updatePaymentPos', false) @@ -497,11 +421,11 @@ export default { const parametersList = [ { columnName: 'C_Order_ID', - value: this.$store.getters.getPos.currentOrder.id + value: this.currentOrder.id }, { columnName: 'Bill_BPartner_ID', - value: this.$store.getters.getPos.currentOrder.businessPartner.id + value: this.currentOrder.businessPartner.id }, { columnName: 'IsCancelled', @@ -542,16 +466,16 @@ export default { }, copyOrder() { this.processPos = posProcess[1].uuid - const posUuid = this.currentPoint.uuid + const posUuid = this.currentPointOfSales.uuid const parametersList = [{ columnName: 'C_Order_ID', - value: this.$store.getters.getPos.currentOrder.id + value: this.currentOrder.id }] this.$store.dispatch('addParametersProcessPos', parametersList) requestCreateOrder({ posUuid, - customerUuid: this.currentPOS.businessPartner.uuid, - salesRepresentativeUuid: this.currentPOS.salesRepresentative.uuid + customerUuid: this.currentPointOfSales.businessPartner.uuid, + salesRepresentativeUuid: this.currentPointOfSales.salesRepresentative.uuid }) .then(order => { this.$store.dispatch('currentOrder', order) @@ -600,11 +524,11 @@ export default { orderUuid: this.$route.query.action }) .then(response => { - this.changePos(this.$store.getters.getCurrentPOS) + this.changePos(this.currentPointOfSales) }) .finally(() => { this.$store.dispatch('listOrdersFromServer', { - posUuid: this.$store.getters.getCurrentPOS.uuid + posUuid: this.currentPointOfSales.uuid }) this.$message({ type: 'success', @@ -615,7 +539,7 @@ export default { }) }, seeOrderList() { - if (this.$store.getters.getPos.listOrder.recordCount <= 0) { + if (this.ordersList.recordCount <= 0) { this.$store.dispatch('listOrdersFromServer', {}) } }, diff --git a/src/components/ADempiere/Form/VPOS/Order/index.vue b/src/components/ADempiere/Form/VPOS/Order/index.vue index 67e188c0..2ef6b65c 100644 --- a/src/components/ADempiere/Form/VPOS/Order/index.vue +++ b/src/components/ADempiere/Form/VPOS/Order/index.vue @@ -52,11 +52,11 @@ - - {{ getOrder.documentStatus.name }} + + {{ currentOrder.documentStatus.name }} @@ -74,7 +74,7 @@
{{ $t('form.productInfo.price') }}: - {{ formatPrice(currentOrderLine.product.priceStandard, currencyPoint.iSOCode) }} + {{ formatPrice(currentOrderLine.product.priceStandard, pointOfSalesCurrency.iSOCode) }}
{{ $t('form.productInfo.taxAmount') }}: {{ currentOrderLine.taxIndicator }} @@ -191,9 +191,9 @@
- +

- {{ $t('form.pos.order.pointSale') }}: {{ namePointOfSales.name }} + {{ $t('form.pos.order.pointSale') }}: {{ currentPointOfSales.name }}

@@ -225,11 +226,11 @@

{{ $t('form.pos.order.seller') }}: - {{ getOrder.salesRepresentative.name }} + {{ currentOrder.salesRepresentative.name }}

-

{{ $t('form.pos.order.subTotal') }}:{{ formatPrice(getOrder.totalLines, currencyPoint.iSOCode) }}

-

{{ $t('form.pos.order.discount') }}:{{ formatPrice(0, currencyPoint.iSOCode) }}

-

{{ $t('form.pos.order.tax') }}:{{ getOrderTax(currencyPoint.iSOCode) }}

+

{{ $t('form.pos.order.subTotal') }}:{{ formatPrice(currentOrder.totalLines, pointOfSalesCurrency.iSOCode) }}

+

{{ $t('form.pos.order.discount') }}:{{ formatPrice(0, pointOfSalesCurrency.iSOCode) }}

+

{{ $t('form.pos.order.tax') }}:{{ getOrderTax(pointOfSalesCurrency.iSOCode) }}

{{ $t('form.pos.order.total') }}: @@ -242,25 +243,25 @@ - {{ formatPrice(getOrder.grandTotal, currencyPoint.iSOCode) }} + {{ formatPrice(currentOrder.grandTotal, pointOfSalesCurrency.iSOCode) }}

-

{{ $t('form.pos.order.order') }}: {{ getOrder.documentNo }}

+

{{ $t('form.pos.order.order') }}: {{ currentOrder.documentNo }}

{{ $t('form.pos.order.date') }}: {{ orderDate }}

-

{{ $t('form.pos.order.type') }}:{{ getOrder.documentType.name }}

+

{{ $t('form.pos.order.type') }}:{{ currentOrder.documentType.name }}

{{ $t('form.pos.order.itemQuantity') }} @@ -348,30 +349,17 @@ export default { } return 'padding-left: 0px; padding-right: 0px; padding-top: 2.2%;margin-right: 1%;float: right;' }, - namePointOfSales() { - const currentPOS = this.$store.getters.getCurrentPOS - if (currentPOS && !this.isEmptyValue(currentPOS.name)) { - return currentPOS - } - return { - name: '', - uuid: '' - } - }, - sellingPointsList() { - return this.$store.getters.getSellingPointsList - }, orderDate() { - if (this.isEmptyValue(this.getOrder) || this.isEmptyValue(this.getOrder.dateOrdered)) { + if (this.isEmptyValue(this.currentOrder) || this.isEmptyValue(this.currentOrder.dateOrdered)) { return this.formatDate(new Date()) } - return this.formatDate(this.getOrder.dateOrdered) + return this.formatDate(this.currentOrder.dateOrdered) }, getItemQuantity() { - if (this.isEmptyValue(this.getOrder)) { + if (this.isEmptyValue(this.currentOrder)) { return 0 } - const result = this.allOrderLines.map(order => { + const result = this.listOrderLine.map(order => { return order.quantityOrdered }) @@ -383,21 +371,10 @@ export default { return 0 }, numberOfLines() { - if (this.isEmptyValue(this.getOrder)) { + if (this.isEmptyValue(this.currentOrder)) { return } - return this.allOrderLines.length - }, - currencyPoint() { - const currency = this.currentPoint - if (!this.isEmptyValue(currency)) { - return currency.priceList.currency - } - return { - uuid: '', - iSOCode: '', - curSymbol: '' - } + return this.listOrderLine.length }, multiplyRate() { return this.$store.getters.getMultiplyRate @@ -414,28 +391,31 @@ export default { columnName: 'C_Currency_ID_UUID' }) }, - displayeTypeCurrency() { - return this.$store.getters.getValueOfField({ - containerUuid: this.containerUuid, - columnName: 'DisplayColumn_C_Currency_ID' - }) - }, - isDisabled() { - return this.$store.getters.getIsProcessed - }, labelButtonCollections() { return this.isDisabled ? this.$t('form.pos.order.collections') : this.$t('form.pos.order.collect') } }, watch: { - namePo1intOfSales(value) { - if (!this.isEmptyValue(value)) { - this.$router.push({ - query: { - pos: value.id - } + 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() { @@ -444,10 +424,6 @@ export default { } }, methods: { - changePos(posElement) { - this.$store.dispatch('setCurrentPOS', posElement) - this.newOrder() - }, openCollectionPanel() { this.isShowedPOSKeyLayout = !this.isShowedPOSKeyLayout this.$store.commit('setShowPOSCollection', true) @@ -456,59 +432,6 @@ export default { this.isShowedPOSKeyLaout = !this.isShowedPOSKeyLaout this.$store.commit('setShowPOSOptions', false) }, - newOrder() { - this.$router.push({ - params: { - ...this.$route.params - }, - query: { - pos: this.currentPoint.id - } - }).catch(() => { - }).finally(() => { - this.$store.commit('setListPayments', { - payments: [] - }) - const { templateBusinessPartner } = this.currentPoint - 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.dispatch('listOrderLine', []) - }) - }, open() { if (!this.seeConversion) { this.seeConversion = true diff --git a/src/components/ADempiere/Form/VPOS/Order/orderLineMixin.js b/src/components/ADempiere/Form/VPOS/Order/orderLineMixin.js index 8d4e3a91..7dfbec84 100644 --- a/src/components/ADempiere/Form/VPOS/Order/orderLineMixin.js +++ b/src/components/ADempiere/Form/VPOS/Order/orderLineMixin.js @@ -99,7 +99,6 @@ export default { }, listOrderLines({ uuid: orderUuid }) { if (!this.isEmptyValue(orderUuid)) { - this.$store.dispatch('listOrderLinesFromServer', orderUuid) this.orderLines = this.listOrderLine this.handleCurrentLineChange(this.currentOrderLine) } @@ -168,8 +167,7 @@ export default { if (columnName === 'LineDescription') { return row.lineDescription } - - const currency = this.currencyPoint.iSOCode + const currency = this.pointOfSalesCurrency.iSOCode if (columnName === 'CurrentPrice') { return this.formatPrice(row.priceActual, currency) } else if (columnName === 'QtyOrdered') { diff --git a/src/components/ADempiere/Form/VPOS/OrderList/index.vue b/src/components/ADempiere/Form/VPOS/OrderList/index.vue index 62aa8bca..1625578f 100644 --- a/src/components/ADempiere/Form/VPOS/OrderList/index.vue +++ b/src/components/ADempiere/Form/VPOS/OrderList/index.vue @@ -55,8 +55,8 @@ @@ -136,6 +136,7 @@ import { formatQuantity } from '@/utils/ADempiere/valueFormat.js' import Field from '@/components/ADempiere/Field' +import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js' export default { name: 'OrdersList', @@ -143,6 +144,9 @@ export default { CustomPagination, Field }, + mixins: [ + posMixin + ], props: { metadata: { type: Object, @@ -181,26 +185,18 @@ export default { } return false }, - tableOrder() { - return this.$store.getters.getPos.listOrder - }, - ordersList() { - const order = this.tableOrder - if (order && !this.isEmptyValue(order.ordersList)) { - return order.ordersList - } - return [] - }, selectOrder() { const action = this.$route.query.action - const order = this.ordersList.find(item => item.uuid === action) - if (!this.isEmptyValue(order)) { - return order + if (!this.isEmptyValue(this.ordersList.ordersList)) { + const order = this.ordersList.ordersList.find(item => item.uuid === action) + if (!this.isEmptyValue(order)) { + return order + } } return null }, isReadyFromGetData() { - const { isReload } = this.tableOrder + const { isReload } = this.ordersList return isReload }, shortsKey() { @@ -246,7 +242,7 @@ export default { containerUuid: this.metadata.containerUuid }) values = this.convertValuesToSend(values) - const point = this.$store.getters.getPointOfSalesUuid + const point = this.$store.getters.posAttributes.currentPointOfSales.uuid if (!this.isEmptyValue(point)) { this.$store.dispatch('listOrdersFromServer', { ...values diff --git a/src/components/ADempiere/Form/VPOS/ProductInfo/index.vue b/src/components/ADempiere/Form/VPOS/ProductInfo/index.vue index ce56db30..1549673b 100644 --- a/src/components/ADempiere/Form/VPOS/ProductInfo/index.vue +++ b/src/components/ADempiere/Form/VPOS/ProductInfo/index.vue @@ -73,16 +73,6 @@ - - {{ formatPrice(props.item.priceStandard, props.item.currency.iSOCode) }} @@ -90,7 +80,6 @@ {{ formatQuantity(props.item.quantityAvailable) }} - @@ -199,7 +188,6 @@ export default { } return false }) - // Remote search if (this.isEmptyValue(results) && String(stringToMatch.length > 3)) { clearTimeout(this.timeOut) diff --git a/src/components/ADempiere/Form/VPOS/ProductInfo/productList.vue b/src/components/ADempiere/Form/VPOS/ProductInfo/productList.vue index e1ab3d0c..1df7d1e7 100644 --- a/src/components/ADempiere/Form/VPOS/ProductInfo/productList.vue +++ b/src/components/ADempiere/Form/VPOS/ProductInfo/productList.vue @@ -120,8 +120,11 @@ export default { isShowProductsPriceList() { return this.$store.state['pointOfSales/listProductPrice'].productPrice[this.attribute] }, - currentPoint() { - return this.$store.getters.getCurrentPOS + // currentPoint() { + // return this.$store.getters.getCurrentPOS + // }, + currentPointOfSales() { + return this.$store.getters.posAttributes.currentPointOfSales }, productPrice() { return this.$store.getters.getProductPrice @@ -149,12 +152,12 @@ export default { if (isToLoad) { this.loadProductsPricesList() } - }, - currentPoint(value) { - if (!this.isEmptyValue(value)) { - this.loadProductsPricesList() - } } + // currentPointOfSales(value) { + // if (!this.isEmptyValue(value)) { + // this.loadProductsPricesList() + // } + // } }, created() { this.unsubscribe = this.subscribeChanges() @@ -162,7 +165,7 @@ export default { isLoaded: false }) this.timeOut = setTimeout(() => { - this.validatePos(this.currentPoint) + this.validatePos(this.currentPointOfSales) }, 3000) }, beforeDestroy() { diff --git a/src/components/ADempiere/Form/VPOS/index.vue b/src/components/ADempiere/Form/VPOS/index.vue index 7f4244e5..3fc80086 100644 --- a/src/components/ADempiere/Form/VPOS/index.vue +++ b/src/components/ADempiere/Form/VPOS/index.vue @@ -109,12 +109,8 @@ export default { showCollection() { return this.$store.getters.getShowCollectionPos }, - pointOfSalesId() { - const currentPOS = this.$store.getters.getCurrentPOS - if (currentPOS && !this.isEmptyValue(currentPOS.id)) { - return currentPOS.id - } - return undefined + listPointOfSales() { + return this.$store.getters.posAttributes.listPointOfSales } }, watch: { @@ -130,27 +126,13 @@ export default { }, created() { // load pont of sales list - if (this.isEmptyValue(this.$store.getters.getSellingPointsList)) { - let posToSet + if (this.isEmptyValue(this.listPointOfSales)) { // set pos id with query path - this.$store.dispatch('listPointOfSalesFromServer', posToSet) + this.$store.dispatch('listPointOfSalesFromServer', this.$route.query.pos) } this.unsubscribePOSList = this.posListWithOrganization() }, - mounted() { - if (this.isEmptyValue(this.$route.query) || this.isEmptyValue(this.$route.query.pos)) { - this.$router.push({ - params: { - ...this.$route.params - }, - query: { - ...this.$route.query, - pos: this.pointOfSalesId - } - }, () => {}) - } - }, beforeDestroy() { this.unsubscribePOSList() }, diff --git a/src/components/ADempiere/Form/VPOS/posMixin.js b/src/components/ADempiere/Form/VPOS/posMixin.js index 6ace2d1b..4d1ceed6 100644 --- a/src/components/ADempiere/Form/VPOS/posMixin.js +++ b/src/components/ADempiere/Form/VPOS/posMixin.js @@ -23,9 +23,13 @@ import { formatPrice, formatQuantity } from '@/utils/ADempiere/valueFormat.js' +import orderLineMixin from './Order/orderLineMixin.js' export default { name: 'POSMixin', + mixins: [ + orderLineMixin + ], props: { metadata: { type: Object, @@ -56,49 +60,6 @@ export default { } }, computed: { - allOrderLines() { - return this.listOrderLine - }, - listOrderLine() { - return this.$store.getters.getListOrderLine - }, - ordersList() { - const order = this.$store.getters.getListOrder - if (order && !this.isEmptyValue(order.ordersList)) { - return order.ordersList - } - return [] - }, - currentOrder() { - const action = this.$route.query.action - if (!this.isEmptyValue(action)) { - return this.$store.getters.getOrder - } - - return { - documentType: {}, - documentStatus: { - value: '' - }, - totalLines: 0, - grandTotal: 0, - salesRepresentative: {}, - businessPartner: { - value: '', - uuid: '' - } - } - }, - currentPoint() { - return this.$store.getters.getCurrentPOS - }, - priceListUuid() { - const currentPOS = this.currentPoint - if (this.isEmptyValue(currentPOS)) { - return undefined - } - return this.currentPoint.priceList.uuid - }, getWarehouse() { return this.$store.getters['user/getWarehouse'] }, @@ -114,14 +75,65 @@ export default { updateOrderProcessPos() { return this.$store.getters.getUpdateOrderPos }, - getOrder() { - return this.$store.getters.getPos.currentOrder + 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 + } + return { + uuid: '', + iSOCode: '', + curSymbol: '' + } + }, + 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: { - getOrder(value) { - if (!this.isEmptyValue(value)) { - // this.order = value + currentOrder(value) { + if (this.isEmptyValue(value)) { + this.orderLines = [] + this.$store.dispatch('listOrderLine', []) + this.listOrderLines() + } else { this.$store.commit('updateValuesOfContainer', { parentUuid: this.parentUuid, containerUuid: this.containerUuid, @@ -140,71 +152,24 @@ export default { }) } }, - currentOrder(value) { - if (this.isEmptyValue(value)) { - this.orderLines = [] - this.$store.dispatch('listOrderLine', []) - this.listOrderLines({}) - } else { - this.listOrderLines(value) - } - }, - currentPoint(value) { - if (!this.isEmptyValue(value)) { - this.$store.dispatch('setCurrentPOS', value) - } - }, - /** - * Used when loading/reloading the app without the order uuid - * @param {oject|boolean} bPartnerToSet - */ - isSetTemplateBP(bPartnerToSet) { - if (bPartnerToSet) { - this.setBusinessPartner(bPartnerToSet) - } - }, updateOrderProcessPos(value) { if (!value && !this.isEmptyValue(this.$route.query)) { this.reloadOrder(true) } } }, - created() { - this.getPanel() - }, beforeMount() { - if (!this.isEmptyValue(this.currentPoint)) { - if (!this.isEmptyValue(this.currentOrder)) { - this.listOrderLines(this.currentOrder) - } - } this.unsubscribe = this.subscribeChanges() }, beforeDestroy() { this.unsubscribe() }, - mounted() { - if (!this.isEmptyValue(this.$route.query)) { - this.reloadOrder(true, this.$route.query.action) - } - if (!this.isEmptyValue(this.$route.query.pos) && !this.isEmptyValue(this.allOrderLines) && this.isEmptyValue(this.$route.query.action)) { - this.$router.push({ - params: { - ...this.$route.params - }, - query: { - ...this.$route.query, - action: this.getOrder.uuid - } - }, () => {}) - } - }, methods: { formatDate, formatPrice, formatQuantity, withoutPOSTerminal() { - if (this.isEmptyValue(this.currentPoint)) { + if (this.isEmptyValue(this.currentPointOfSales)) { this.$message({ type: 'warn', message: 'Without POS Terminal', @@ -231,7 +196,7 @@ export default { }, updateOrder(update) { // user session - if (update.value !== this.getOrder.businessPartner.uuid && !this.isEmptyValue(this.currentPoint)) { + if (update.value !== this.currentOrder.businessPartner.uuid && !this.isEmptyValue(this.currentPoint)) { this.$store.dispatch('updateOrder', { orderUuid: this.$route.query.action, posUuid: this.currentPoint.uuid, @@ -267,7 +232,7 @@ export default { findProduct({ searchValue: searchProduct, - priceListUuid: this.priceListUuid + priceListUuid: this.currentPointOfSales.priceList.uuid }) .then(productPrice => { this.product = productPrice.product @@ -308,7 +273,7 @@ export default { } const orderUuid = this.$route.query.action if (this.isEmptyValue(orderUuid)) { - const posUuid = this.currentPoint.uuid + const posUuid = this.currentPointOfSales.uuid let customerUuid = this.$store.getters.getValueOfField({ containerUuid: this.containerUuid, columnName: 'C_BPartner_ID_UUID' @@ -318,14 +283,14 @@ export default { columnName: 'C_BPartner_ID' }) if (this.isEmptyValue(customerUuid) || id === 1000006) { - customerUuid = this.currentPoint.templateBusinessPartner.uuid + customerUuid = this.currentPointOfSales.templateBusinessPartner.uuid } // user session // alert(name) this.$store.dispatch('createOrder', { posUuid, customerUuid, - salesRepresentativeUuid: this.currentPoint.templateBusinessPartner.uuid + salesRepresentativeUuid: this.currentPointOfSales.templateBusinessPartner.uuid }) .then(response => { // this.order = response @@ -356,7 +321,7 @@ export default { if (this.isEmptyValue(orderUuid)) { orderUuid = this.$route.query.action // if (this.isEmptyValue(orderUuid)) { - // orderUuid = this.$store.getters.getOrder.uuid // this.currentOrder.uuid + // orderUuid = this.$store.getters.currentOrder.uuid // this.currentOrder.uuid // } } if (!this.isEmptyValue(orderUuid)) { @@ -389,7 +354,7 @@ export default { // this.order = orderToPush }, getOrderTax(currency) { - return this.formatPrice(this.getOrder.grandTotal - this.getOrder.totalLines, currency) + return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency) }, subscribeChanges() { return this.$store.subscribe((mutation, state) => { @@ -433,12 +398,6 @@ export default { } }) }, - mas() { - this.$refs.linesTable.setCurrentRow(this.listOrderLine[1]) - }, - menos() { - this.$refs.linesTable.setCurrentRow(this.listOrderLine[0]) - }, shortcutKeyMethod(event) { switch (event.srcKey) { // case 'options': @@ -489,6 +448,62 @@ export default { }) break } + }, + 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() } } } diff --git a/src/store/modules/ADempiere/pointOfSales/getters/index.js b/src/store/modules/ADempiere/pointOfSales/getters/index.js new file mode 100644 index 00000000..80197da2 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/getters/index.js @@ -0,0 +1,110 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * PointOfSales Getters + */ +import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js' + +const withoutResponse = { + isLoaded: false, + isReload: true, + recordCount: 0, + nextPageToken: undefined +} + +function isProcessed(order) { + if (!isEmptyValue(order.documentStatus.value) && + (order.documentStatus.value === 'CO' || + order.documentStatus.value === 'VO' || + order.documentStatus.value === 'IP' || + order.documentStatus.value === 'IP')) { + return true + } + return false +} +export default { + /** + * Point of Sale Attributes + * List Point Of Sales + * Current Point Of Sales + * Current Order + * List Order Lines + * List Payment Order + * Lst Order + */ + posAttributes: (state, getters) => { + return { + listPointOfSales: state.listPointOfSales, + currentPointOfSales: { + ...state.currentPointOfSales, + listOrder: state.listOrder, + currentOrder: { + ...state.order, + lineOrder: state.listOrderLine, + listPayments: state.listPayments, + isProcessed: isProcessed(state.order) + } + } + } + }, + /** + * Product Price Getters + * List Product + * Search Product + */ + getProductPrice: (state) => { + if (isEmptyValue(state.productPrice) || !state.productPrice.isLoaded) { + return { + ...withoutResponse, + productPricesList: [] + } + } + return state.productPrice + }, + getSearchProduct: (state) => { + return state.searchProduct + }, + /** + * visibility of point of sale panels + * Show Panel Options the Point Of Sales + * Show Panel Key Layout the Point Of Sales + * Show Panel Collection the Point Of Sales + */ + getIsShowPOSOptions: (state) => { + return state.showPOSOptions + }, + getShowPOSKeyLayout: (state) => { + return state.showPOSKeyLayout + }, + getShowCollectionPos: (state) => { + return state.showPOSCollection + }, + /** + * get Key Layout + * List Catalog + */ + getKeyLayout: (state) => { + if (isEmptyValue(state.keyLayout)) { + return { + ...withoutResponse, + uuid: undefined, + ordersList: [] + } + } + return state.keyLayout + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/index.js b/src/store/modules/ADempiere/pointOfSales/index.js deleted file mode 100644 index 0f2794ea..00000000 --- a/src/store/modules/ADempiere/pointOfSales/index.js +++ /dev/null @@ -1,172 +0,0 @@ -import Vue from 'vue' -import router from '@/router' -import { - requestListPointOfSales -} from '@/api/ADempiere/form/point-of-sales.js' -import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js' -import { showMessage } from '@/utils/ADempiere/notification.js' - -const withoutResponse = { - isLoaded: false, - isReload: true, - recordCount: 0, - currentPOS: {}, - nextPageToken: undefined -} - -const pointOfSales = { - state: { - showPOSOptions: false, - showPOSKeyLayout: false, - showPOSCollection: false, - pointOfSales: { - ...withoutResponse - } - }, - mutations: { - resetStatePointOfSales(state) { - state = {} - }, - setPontOfSales(state, pos) { - state.pointOfSales = pos - }, - setCurrentPOS(state, pos) { - Vue.set(state.pointOfSales, 'currentPOS', pos) - }, - setShowPOSOptions(state, isShowedOptions) { - state.showPOSOptions = isShowedOptions - }, - setShowPOSKeyLayout(state, isShowedKeyLayout) { - state.showPOSKeyLayout = isShowedKeyLayout - }, - setShowPOSCollection(state, isShowedCollection) { - state.showPOSCollection = isShowedCollection - } - }, - actions: { - /** - * List point of sales terminal - * @param {number} posToSet id to set - */ - listPointOfSalesFromServer({ commit, getters, dispatch }, posToSet = null) { - const userUuid = getters['user/getUserUuid'] - requestListPointOfSales({ - userUuid - }) - .then(response => { - // TODO: Add organization - commit('setPontOfSales', { - ...response, - userUuid - }) - const posList = response.sellingPointsList - const getterPos = getters.getPointOfSalesUuid - let pos - if (!isEmptyValue(posList)) { - if (!isEmptyValue(getterPos)) { - pos = posList.find(itemPOS => itemPOS.uuid === getterPos) - } - - // match with route.query.pos - if (isEmptyValue(pos) && !isEmptyValue(posToSet)) { - pos = posList.find(itemPOS => itemPOS.id === posToSet) - } - - // set first element in array list - if (isEmptyValue(pos)) { - pos = posList[0] - } - } - if (isEmptyValue(pos)) { - pos = { - uuid: undefined - } - } - if (pos.uuid !== getterPos) { - dispatch('setCurrentPOS', pos) - } - }) - .catch(error => { - console.warn(`listPointOfSalesFromServer: ${error.message}. Code: ${error.code}.`) - showMessage({ - type: 'error', - message: error.message, - showClose: true - }) - }) - }, - setCurrentPOS({ commit, dispatch }, posToSet) { - commit('setCurrentPOS', posToSet) - - const oldRoute = router.app._route - router.push({ - name: oldRoute.name, - params: { - ...oldRoute.params - }, - query: { - ...oldRoute.query, - pos: posToSet.id - } - }, () => {}) - - commit('setIsReloadKeyLayout') - commit('setIsReloadProductPrice') - commit('setIsReloadListOrders') - commit('setShowPOSKeyLayout', false) - dispatch('deleteAllCollectBox') - } - }, - getters: { - getPointOfSales: (state) => { - if (isEmptyValue(state.pointOfSales)) { - return { - ...withoutResponse, - sellingPointsList: [] - } - } - return state.pointOfSales - }, - // current pos uuid - getPointOfSalesUuid: (state, getters) => { - const currentPOS = getters.getCurrentPOS - if (isEmptyValue(currentPOS)) { - return undefined - } - return currentPOS.uuid - }, - // current pos info - getCurrentPOS: (state, getters) => { - const userUuid = getters['user/getUserUuid'] - let currentPOS - const sellingPointsList = state.pointOfSales.sellingPointsList - if (!isEmptyValue(sellingPointsList) && (sellingPointsList.length > 1)) { - currentPOS = state.pointOfSales.sellingPointsList.find(elem => elem.salesRepresentative.uuid === userUuid) - } - if (!isEmptyValue(currentPOS)) { - return currentPOS - } - if (isEmptyValue(state.pointOfSales.currentPOS) && (!isEmptyValue(sellingPointsList))) { - return state.pointOfSales.sellingPointsList[0] - } - if (state.pointOfSales.currentPOS) { - return state.pointOfSales.currentPOS - } - return undefined - }, - getSellingPointsList: (state, getters) => { - return getters.getPointOfSales.sellingPointsList - }, - getIsShowPOSOptions: (state) => { - return state.showPOSOptions - }, - getShowPOSKeyLayout: (state) => { - return state.showPOSKeyLayout - }, - getShowCollectionPos: (state) => { - return state.showPOSCollection - } - } -} - -export default pointOfSales diff --git a/src/store/modules/ADempiere/pointOfSales/keyLayout.js b/src/store/modules/ADempiere/pointOfSales/keyLayout.js deleted file mode 100644 index 81b48c70..00000000 --- a/src/store/modules/ADempiere/pointOfSales/keyLayout.js +++ /dev/null @@ -1,82 +0,0 @@ -import Vue from 'vue' -import { - getKeyLayout -} from '@/api/ADempiere/form/point-of-sales.js' -import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js' -import { showMessage } from '@/utils/ADempiere/notification.js' - -const withoutResponse = { - isLoaded: false, - isReload: true, - recordCount: 0, - nextPageToken: undefined -} - -const keyLayout = { - state: { - keyLayout: {} - }, - mutations: { - setKeyLayout(state, keyLayout) { - Vue.set(state, 'keyLayout', keyLayout) - }, - setIsReloadKeyLayout(state) { - Vue.set(state.keyLayout, 'isReload', true) - Vue.set(state.keyLayout, 'isLoaded', false) - } - }, - actions: { - getKeyLayoutFromServer({ commit, getters }, keyLayoutUuid) { - if (isEmptyValue(keyLayoutUuid)) { - keyLayoutUuid = getters.getKeyLayoutUuidWithPOS - } - - if (isEmptyValue(keyLayoutUuid)) { - console.info('not load key layout') - return - } - getKeyLayout({ - keyLayoutUuid - }) - .then(responseKeyLayout => { - commit('setKeyLayout', { - ...responseKeyLayout, - isLoaded: true, - isReload: false - // token, - // pageNumber - }) - }) - .catch(error => { - console.warn(`getKeyLayoutFromServer: ${error.message}. Code: ${error.code}.`) - showMessage({ - type: 'error', - message: error.message, - showClose: true - }) - }) - } - }, - getters: { - // current pos uuid - getKeyLayoutUuidWithPOS: (state, getters) => { - const currentPOS = getters.getCurrentPOS - if (isEmptyValue(currentPOS)) { - return undefined - } - return currentPOS.keyLayoutUuid - }, - getKeyLayout: (state) => { - if (isEmptyValue(state.keyLayout)) { - return { - ...withoutResponse, - uuid: undefined, - ordersList: [] - } - } - return state.keyLayout - } - } -} - -export default keyLayout diff --git a/src/store/modules/ADempiere/pointOfSales/keyLayout/actions.js b/src/store/modules/ADempiere/pointOfSales/keyLayout/actions.js new file mode 100644 index 00000000..5920505d --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/keyLayout/actions.js @@ -0,0 +1,55 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import { + getKeyLayout +} from '@/api/ADempiere/form/point-of-sales.js' +import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js' +import { showMessage } from '@/utils/ADempiere/notification.js' + +/** + * keyLayout Actions + */ +export default { + getKeyLayoutFromServer({ commit, rootGetters }, keyLayoutUuid) { + if (isEmptyValue(keyLayoutUuid)) { + keyLayoutUuid = rootGetters.posAttributes.currentPointOfSales.keyLayoutUuid + } + + if (isEmptyValue(keyLayoutUuid)) { + console.info('not load key layout') + return + } + getKeyLayout({ + keyLayoutUuid + }) + .then(responseKeyLayout => { + commit('setKeyLayout', { + ...responseKeyLayout, + isLoaded: true, + isReload: false + }) + }) + .catch(error => { + console.warn(`getKeyLayoutFromServer: ${error.message}. Code: ${error.code}.`) + showMessage({ + type: 'error', + message: error.message, + showClose: true + }) + }) + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/keyLayout/index.js b/src/store/modules/ADempiere/pointOfSales/keyLayout/index.js new file mode 100644 index 00000000..97f21eb4 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/keyLayout/index.js @@ -0,0 +1,30 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import state from './state.js' +import mutations from './mutations.js' +import actions from './actions.js' + +/** + * keyLayout Vuex Module + */ +const keyLayout = { + state, + mutations, + actions +} + +export default keyLayout diff --git a/src/store/modules/ADempiere/pointOfSales/keyLayout/mutations.js b/src/store/modules/ADempiere/pointOfSales/keyLayout/mutations.js new file mode 100644 index 00000000..c1c75648 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/keyLayout/mutations.js @@ -0,0 +1,30 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * KeyLayout Mutations + */ +import Vue from 'vue' + +export default { + setKeyLayout(state, keyLayout) { + Vue.set(state, 'keyLayout', keyLayout) + }, + setIsReloadKeyLayout(state) { + Vue.set(state.keyLayout, 'isReload', true) + Vue.set(state.keyLayout, 'isLoaded', false) + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/keyLayout/state.js b/src/store/modules/ADempiere/pointOfSales/keyLayout/state.js new file mode 100644 index 00000000..2f1ea628 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/keyLayout/state.js @@ -0,0 +1,22 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * keyLayout State + */ +export default { + keyLayout: {} +} diff --git a/src/store/modules/ADempiere/pointOfSales/listProductPrice.js b/src/store/modules/ADempiere/pointOfSales/listProductPrice.js deleted file mode 100644 index 2926b188..00000000 --- a/src/store/modules/ADempiere/pointOfSales/listProductPrice.js +++ /dev/null @@ -1,220 +0,0 @@ -import Vue from 'vue' -import { - getProductPriceList -} from '@/api/ADempiere/form/point-of-sales.js' -import { isEmptyValue, extractPagingToken } from '@/utils/ADempiere/valueUtils.js' -import { showMessage } from '@/utils/ADempiere/notification.js' -import language from '@/lang' - -const withoutResponse = { - isLoaded: false, - isReload: true, - recordCount: 0, - nextPageToken: undefined -} - -const listProductPrice = { - state: { - productPrice: { - ...withoutResponse, - isShowPopoverField: false, // with field - isShowPopoverMenu: false // with menu - }, - searchProduct: '' - }, - mutations: { - setListProductPrice(state, productsPrices) { - state.productPrice = { - ...state.productPrice, - ...productsPrices - } - }, - setProductPicePageNumber(state, pageNumber) { - state.productPrice.pageNumber = pageNumber - }, - showListProductPrice(state, payload) { - Vue.set(state.productPrice, payload.attribute, payload.isShowed) - }, - setIsReloadProductPrice(state) { - Vue.set(state.productPrice, 'isReload', true) - Vue.set(state.productPrice, 'isLoaded', false) - }, - updtaeSearchProduct(state, searchProduct) { - state.searchProduct = searchProduct - } - }, - actions: { - setProductPicePageNumber({ commit }, pageNumber) { - commit('setProductPicePageNumber', pageNumber) - commit('setIsReloadProductPrice') - - // Not reload, watch in component to reload - // dispatch('listProductPriceFromServer', {}) - }, - listProductPriceFromServer({ state, commit, rootGetters }, { - containerUuid = 'Products-Price-List', - pageNumber, // 1 - searchValue - }) { - const posUuid = rootGetters.getPointOfSalesUuid - if (isEmptyValue(posUuid)) { - const message = language.t('notifications.errorPointOfSale') - showMessage({ - type: 'info', - message - }) - console.warn(message) - return - } - commit('setIsReloadProductPrice') - let pageToken, token - if (isEmptyValue(pageNumber)) { - pageNumber = state.productPrice.pageNumber - if (isEmptyValue(pageNumber)) { - pageNumber = 1 - } - - token = state.productPrice.token - if (!isEmptyValue(token)) { - pageToken = token + '-' + pageNumber - } - } - - const { priceList, templateBusinessPartner } = rootGetters.getCurrentPOS - const { uuid: businessPartnerUuid } = templateBusinessPartner - const { uuid: priceListUuid } = priceList - const { uuid: warehouseUuid } = rootGetters['user/getWarehouse'] - - if (isEmptyValue(searchValue)) { - searchValue = rootGetters.getValueOfField({ - containerUuid, - columnName: 'ProductValue' - }) - } - return new Promise(resolve => { - getProductPriceList({ - searchValue, - priceListUuid, - businessPartnerUuid, - warehouseUuid, - pageToken - }).then(responseProductPrice => { - if (isEmptyValue(token) || isEmptyValue(pageToken)) { - token = extractPagingToken(responseProductPrice.nextPageToken) - } - - commit('setListProductPrice', { - ...responseProductPrice, - isLoaded: true, - isReload: false, - businessPartnerUuid, - warehouseUuid, - token, - pageNumber - }) - - resolve(responseProductPrice) - }).catch(error => { - console.warn(`getKeyLayoutFromServer: ${error.message}. Code: ${error.code}.`) - showMessage({ - type: 'error', - message: error.message, - showClose: true - }) - }) - }) - }, - listProductPriceFromServerProductInfo({ state, commit, rootGetters }, { - containerUuid = 'Products-Price-List-ProductInfo', - pageNumber, // 1 - searchValue - }) { - const posUuid = rootGetters.getPointOfSalesUuid - if (isEmptyValue(posUuid)) { - const message = 'Sin punto de venta seleccionado' - showMessage({ - type: 'info', - message - }) - console.warn(message) - return - } - commit('setIsReloadProductPrice') - let pageToken, token - if (isEmptyValue(pageNumber)) { - pageNumber = state.productPrice.pageNumber - if (isEmptyValue(pageNumber)) { - pageNumber = 1 - } - - token = state.productPrice.token - if (!isEmptyValue(token)) { - pageToken = token + '-' + pageNumber - } - } - - const { priceList, templateBusinessPartner } = rootGetters.getCurrentPOS - const { uuid: businessPartnerUuid } = templateBusinessPartner - const { uuid: priceListUuid } = priceList - const { uuid: warehouseUuid } = rootGetters['user/getWarehouse'] - - if (isEmptyValue(searchValue)) { - searchValue = rootGetters.getValueOfField({ - containerUuid, - columnName: 'ProductValue' - }) - } - return new Promise(resolve => { - getProductPriceList({ - searchValue, - priceListUuid, - businessPartnerUuid, - warehouseUuid, - pageToken - }).then(responseProductPrice => { - if (isEmptyValue(token) || isEmptyValue(pageToken)) { - token = extractPagingToken(responseProductPrice.nextPageToken) - } - - commit('setListProductPrice', { - ...responseProductPrice, - isLoaded: true, - isReload: false, - businessPartnerUuid, - warehouseUuid, - token, - pageNumber - }) - - resolve(responseProductPrice) - }).catch(error => { - console.warn(`getKeyLayoutFromServer: ${error.message}. Code: ${error.code}.`) - showMessage({ - type: 'error', - message: error.message, - showClose: true - }) - }) - }) - }, - updateSearch({ commit }, newValue) { - commit('updtaeSearchProduct', newValue) - } - }, - getters: { - getProductPrice: (state) => { - if (isEmptyValue(state.productPrice) || !state.productPrice.isLoaded) { - return { - ...withoutResponse, - productPricesList: [] - } - } - return state.productPrice - }, - getSearchProduct: (state) => { - return state.searchProduct - } - } -} - -export default listProductPrice diff --git a/src/store/modules/ADempiere/pointOfSales/order/actions.js b/src/store/modules/ADempiere/pointOfSales/order/actions.js index 7cbbb2cf..326b75cb 100644 --- a/src/store/modules/ADempiere/pointOfSales/order/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/order/actions.js @@ -1,3 +1,19 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + import { requestCreateOrder, requestGetOrder, @@ -10,7 +26,6 @@ import { showMessage } from '@/utils/ADempiere/notification.js' /** * Order Actions - * @author Elsio Sanchez */ export default { /** @@ -117,7 +132,7 @@ export default { */ reloadOrder({ commit, dispatch, rootGetters }, { orderUuid }) { if (isEmptyValue(orderUuid)) { - orderUuid = rootGetters.getOrder.uuid // this.currentOrder.uuid + orderUuid = rootGetters.posAttributes.currentPointOfSales.currentOrder.uuid // this.currentOrder.uuid } if (!isEmptyValue(orderUuid)) { requestGetOrder(orderUuid) @@ -188,7 +203,7 @@ export default { salesRepresentativeUuid }) { if (isEmptyValue(posUuid)) { - posUuid = getters.getPointOfSalesUuid + posUuid = getters.posAttributes.currentPointOfSales.uuid } let { pageNumber, token } = state.listOrder @@ -237,7 +252,8 @@ export default { // }) }) }, - setOrder({ commit }, order) { + setOrder({ commit, dispatch }, order) { + dispatch('listOrderLinesFromServer', order.uuid) commit('setOrder', order) }, currentOrder({ commit }, findOrder) { diff --git a/src/store/modules/ADempiere/pointOfSales/order/getters.js b/src/store/modules/ADempiere/pointOfSales/order/getters.js deleted file mode 100644 index 348d88b1..00000000 --- a/src/store/modules/ADempiere/pointOfSales/order/getters.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Order Getters - * @author Elsio Sanchez - */ -import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js' - -const withoutResponse = { - isLoaded: false, - isReload: true, - recordCount: 0, - nextPageToken: undefined -} - -export default { - getOrder: (state) => { - return state.order - }, - getPos: (state, getters) => { - const OrderPos = { - currentOrder: state.order, - listOrder: getters.getListOrder, - lineOrder: getters.getListOrderLine, - listPayments: getters.getListPayments, - isProcessed: getters.getIsProcessed - } - return OrderPos - }, - getIsProcessed: (state) => { - const order = state.order - if (!isEmptyValue(order.documentStatus.value) && - (order.documentStatus.value === 'CO' || order.documentStatus.value === 'VO' || order.documentStatus.value === 'IP' || order.documentStatus.value === 'IP')) { - return true - } - return false - }, - getListOrder: (state) => { - if (isEmptyValue(state.listOrder)) { - return { - ...withoutResponse, - ordersList: [] - } - } - return state.listOrder - }, - getFindOrder: (state) => { - return state.findOrder - } -} diff --git a/src/store/modules/ADempiere/pointOfSales/order/index.js b/src/store/modules/ADempiere/pointOfSales/order/index.js index fdec594f..365697a7 100644 --- a/src/store/modules/ADempiere/pointOfSales/order/index.js +++ b/src/store/modules/ADempiere/pointOfSales/order/index.js @@ -1,8 +1,22 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . import state from './state.js' import mutations from './mutations.js' import actions from './actions.js' -import getters from './getters.js' /** * Order Vuex Module @@ -11,13 +25,11 @@ import getters from './getters.js' * List Order * Delete Order * Reload Order - * @author Elsio Sanchez */ const ordes = { state, mutations, - actions, - getters + actions } export default ordes diff --git a/src/store/modules/ADempiere/pointOfSales/order/mutations.js b/src/store/modules/ADempiere/pointOfSales/order/mutations.js index 4bd1d154..59284da8 100644 --- a/src/store/modules/ADempiere/pointOfSales/order/mutations.js +++ b/src/store/modules/ADempiere/pointOfSales/order/mutations.js @@ -1,7 +1,21 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . /** * Order Mutations - * @author Elsio Sanchez */ export default { setOrder(state, order) { diff --git a/src/store/modules/ADempiere/pointOfSales/order/state.js b/src/store/modules/ADempiere/pointOfSales/order/state.js index 5c851d9b..aa67fa8b 100644 --- a/src/store/modules/ADempiere/pointOfSales/order/state.js +++ b/src/store/modules/ADempiere/pointOfSales/order/state.js @@ -1,6 +1,21 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + /** * Order State - * @author Elsio Sanchez */ const withoutResponse = { isLoaded: false, diff --git a/src/store/modules/ADempiere/pointOfSales/orderLine/actions.js b/src/store/modules/ADempiere/pointOfSales/orderLine/actions.js new file mode 100644 index 00000000..0891d949 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/orderLine/actions.js @@ -0,0 +1,88 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import { + requestListOrderLines +} from '@/api/ADempiere/form/point-of-sales.js' +import { showMessage } from '@/utils/ADempiere/notification.js' +/** + * Order Line Actions + */ +export default { + listOrderLine({ commit }, params) { + commit('setListOrderLine', params) + }, + listOrderLinesFromServer({ commit }, orderUuid) { + requestListOrderLines({ + orderUuid + }) + .then(response => { + const line = response.orderLineList.map(lineItem => { + return { + ...lineItem, + quantityOrdered: lineItem.quantity, + priceActual: lineItem.price, + discount: lineItem.discountRate, + product: { + ...lineItem.product, + priceStandard: lineItem.price, + help: lineItem.help + }, + taxIndicator: lineItem.taxRate.taxIndicator, + grandTotal: lineItem.lineNetAmount + } + }) + commit('setListOrderLine', line) + }) + .catch(error => { + console.warn(`listOrderLinesFromServer: ${error.message}. Code: ${error.code}.`) + showMessage({ + type: 'error', + message: error.message, + showClose: true + }) + }) + }, + updateOrderLines({ commit, rootGetters }, params) { + // const line = rootGetters.getListOrderLine + const line = rootGetters.posAttributes.currentPointOfSales.currentOrder.lineOrder + const found = line.map(element => { + if (element.uuid === params.uuid) { + return { + ...element, + uuid: params.uuid, + lineDescription: params.lineDescription, + quantityOrdered: params.quantity, + priceActual: params.price, + discount: params.discountRate, + product: { + description: params.product.description, + priceStandard: params.price, + help: params.help, + name: params.product.name, + value: params.product.value + }, + taxIndicator: params.taxRate.taxIndicator, + grandTotal: params.lineNetAmount + } + } + return { + ...element + } + }) + commit('setListOrderLine', found) + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/orderLine/index.js b/src/store/modules/ADempiere/pointOfSales/orderLine/index.js new file mode 100644 index 00000000..9d726d13 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/orderLine/index.js @@ -0,0 +1,34 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import state from './state.js' +import mutations from './mutations.js' +import actions from './actions.js' + +/** + * Order Line Vuex Module + * Create Line + * Update Line + * Delete Line + * List Line + */ +const orderLine = { + state, + mutations, + actions +} + +export default orderLine diff --git a/src/store/modules/ADempiere/pointOfSales/orderLine/mutations.js b/src/store/modules/ADempiere/pointOfSales/orderLine/mutations.js new file mode 100644 index 00000000..05f013ac --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/orderLine/mutations.js @@ -0,0 +1,25 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * Order Line Mutations + */ + +export default { + setListOrderLine(state, listOrderLine) { + state.listOrderLine = listOrderLine + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/orderLine/state.js b/src/store/modules/ADempiere/pointOfSales/orderLine/state.js new file mode 100644 index 00000000..14d123f1 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/orderLine/state.js @@ -0,0 +1,23 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * Order Line State + */ + +export default { + listOrderLine: [] +} diff --git a/src/store/modules/ADempiere/pointOfSales/orderLines.js b/src/store/modules/ADempiere/pointOfSales/orderLines.js deleted file mode 100644 index 51408d76..00000000 --- a/src/store/modules/ADempiere/pointOfSales/orderLines.js +++ /dev/null @@ -1,86 +0,0 @@ -import { - requestListOrderLines -} from '@/api/ADempiere/form/point-of-sales.js' -import { showMessage } from '@/utils/ADempiere/notification.js' - -const orderLine = { - state: { - listOrderLine: [] - }, - mutations: { - setListOrderLine(state, listOrderLine) { - state.listOrderLine = listOrderLine - } - }, - actions: { - listOrderLine({ commit }, params) { - commit('setListOrderLine', params) - }, - listOrderLinesFromServer({ commit }, orderUuid) { - requestListOrderLines({ - orderUuid - }) - .then(response => { - const line = response.orderLineList.map(lineItem => { - return { - ...lineItem, - quantityOrdered: lineItem.quantity, - priceActual: lineItem.price, - discount: lineItem.discountRate, - product: { - ...lineItem.product, - priceStandard: lineItem.price, - help: lineItem.help - }, - taxIndicator: lineItem.taxRate.taxIndicator, - grandTotal: lineItem.lineNetAmount - } - }) - commit('setListOrderLine', line) - }) - .catch(error => { - console.warn(`listOrderLinesFromServer: ${error.message}. Code: ${error.code}.`) - showMessage({ - type: 'error', - message: error.message, - showClose: true - }) - }) - }, - updateOrderLines({ commit, rootGetters }, params) { - const line = rootGetters.getListOrderLine - const found = line.map(element => { - if (element.uuid === params.uuid) { - return { - ...element, - uuid: params.uuid, - lineDescription: params.lineDescription, - quantityOrdered: params.quantity, - priceActual: params.price, - discount: params.discountRate, - product: { - description: params.product.description, - priceStandard: params.price, - help: params.help, - name: params.product.name, - value: params.product.value - }, - taxIndicator: params.taxRate.taxIndicator, - grandTotal: params.lineNetAmount - } - } - return { - ...element - } - }) - commit('setListOrderLine', found) - } - }, - getters: { - getListOrderLine: (state) => { - return state.listOrderLine - } - } -} - -export default orderLine diff --git a/src/store/modules/ADempiere/pointOfSales/payments/actions.js b/src/store/modules/ADempiere/pointOfSales/payments/actions.js index cb3ed6ff..d4f5a175 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/actions.js @@ -1,3 +1,19 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + import { requestGetConversionRate, createPayment, @@ -10,7 +26,6 @@ import { showMessage } from '@/utils/ADempiere/notification.js' /** * Payments Actions - * @author Elsio Sanchez */ export default { /** diff --git a/src/store/modules/ADempiere/pointOfSales/payments/getters.js b/src/store/modules/ADempiere/pointOfSales/payments/getters.js index bbc651a2..7c513693 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/getters.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/getters.js @@ -1,6 +1,21 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + /** * Payments Getters - * @author Elsio Sanchez */ export default { diff --git a/src/store/modules/ADempiere/pointOfSales/payments/index.js b/src/store/modules/ADempiere/pointOfSales/payments/index.js index b41bf009..56986bd8 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/index.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/index.js @@ -1,3 +1,18 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . import state from './state.js' import mutations from './mutations.js' @@ -6,7 +21,10 @@ import getters from './getters.js' /** * Payments Vuex Module - * @author Elsio Sanchez + * Create Payment + * Update Payment + * Delete Payment + * List Payment */ const collection = { state, diff --git a/src/store/modules/ADempiere/pointOfSales/payments/mutations.js b/src/store/modules/ADempiere/pointOfSales/payments/mutations.js index 215f9c4e..1b77ce17 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/mutations.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/mutations.js @@ -1,7 +1,21 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . /** * Payments Mutations - * @author Elsio Sanchez */ export default { addPaymentBox(state, paymentBox) { diff --git a/src/store/modules/ADempiere/pointOfSales/payments/state.js b/src/store/modules/ADempiere/pointOfSales/payments/state.js index 117e8bfd..c320d3df 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/state.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/state.js @@ -1,6 +1,21 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + /** * Payment State - * @author Elsio Sanchez */ export default { paymentBox: [], diff --git a/src/store/modules/ADempiere/pointOfSales/point/actions.js b/src/store/modules/ADempiere/pointOfSales/point/actions.js new file mode 100644 index 00000000..72b5fd78 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/point/actions.js @@ -0,0 +1,89 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import router from '@/router' +import { + requestListPointOfSales +} from '@/api/ADempiere/form/point-of-sales.js' +import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js' +import { showMessage } from '@/utils/ADempiere/notification.js' + +/** + * Pos Actions + */ +export default { + /** + * List point of sales terminal + * @param {number} posToSet id to set + */ + listPointOfSalesFromServer({ commit, getters, dispatch }, posToSet = null) { + const userUuid = getters['user/getUserUuid'] + let pos, listPos + requestListPointOfSales({ + userUuid + }) + .then(response => { + listPos = response.sellingPointsList + if (!isEmptyValue(posToSet)) { + pos = listPos.find(itemPOS => itemPOS.id === parseInt(posToSet)) + } + if (isEmptyValue(pos) && isEmptyValue(posToSet)) { + pos = listPos.find(itemPOS => itemPOS.salesRepresentative.uuid === userUuid) + } + if (isEmptyValue(pos)) { + pos = listPos[0] + } + commit('listPointOfSales', listPos) + dispatch('setCurrentPOS', pos) + }) + .catch(error => { + console.warn(`listPointOfSalesFromServer: ${error.message}. Code: ${error.code}.`) + showMessage({ + type: 'error', + message: error.message, + showClose: true + }) + }) + }, + setCurrentPOS({ commit, dispatch }, posToSet) { + commit('currentPointOfSales', posToSet) + const currentPOS = posToSet + const oldRoute = router.app._route + router.push({ + name: oldRoute.name, + params: { + ...oldRoute.params + }, + query: { + ...oldRoute.query, + pos: posToSet.id + } + }, () => {}) + + commit('setIsReloadKeyLayout') + commit('setIsReloadProductPrice') + commit('setIsReloadListOrders') + commit('setShowPOSKeyLayout', false) + + // Maintain Order and Product List + dispatch('listOrdersFromServer', { + posUuid: currentPOS.uuid + }) + dispatch('listProductPriceFromServer', { + currentPOS + }) + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/point/index.js b/src/store/modules/ADempiere/pointOfSales/point/index.js new file mode 100644 index 00000000..5ffc8467 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/point/index.js @@ -0,0 +1,98 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * Get Point Of Sales Vuex Module Store Data + * Search Point of Sale list + * Current Point of Sale + */ + +import state from './state.js' +import mutations from './mutations.js' +import actions from './actions.js' +import getters from '../getters/index.js' + +/** + * Get Order Vuex Module Store Data + * Create Order + * Update Order + * List Order + * Delete Order + * Reload Order + */ + +import stateOrder from '../order/state.js' +import mutationsOrder from '../order/mutations.js' + +/** + * Get Order Line Vuex Module Store Data + * Create Line + * Update Line + * Delete Line + * List Line + */ + +import stateOrderLine from '../orderLine/state.js' +import mutationsOrderLine from '../orderLine/mutations.js' + +/** + * Get Payments Vuex Module Store Data + * Create Payment + * Update Payment + * Delete Payment + * List Payment + */ + +import statePayments from '../payments/state.js' +import mutationsPayments from '../payments/mutations.js' + +/** + * Get Product Price Vuex Module Store Data + * Product List + * Search Product + */ +import stateProductPrice from '../productPrice/state.js' +import mutationsProductPrice from '../productPrice/mutations.js' + +/** + * Get keyLayout Vuex Module Store Data + * List Catalog + */ +import stateKeyLayout from '../keyLayout/state.js' +import mutationsKeyLayout from '../keyLayout/mutations.js' + +const pointOfSales = { + state: { + ...state, + ...stateOrder, + ...stateOrderLine, + ...statePayments, + ...stateProductPrice, + ...stateKeyLayout + }, + mutations: { + ...mutations, + ...mutationsOrder, + ...mutationsOrderLine, + ...mutationsPayments, + ...mutationsProductPrice, + ...mutationsKeyLayout + }, + actions, + getters +} + +export default pointOfSales diff --git a/src/store/modules/ADempiere/pointOfSales/point/mutations.js b/src/store/modules/ADempiere/pointOfSales/point/mutations.js new file mode 100644 index 00000000..997dfbb7 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/point/mutations.js @@ -0,0 +1,45 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import Vue from 'vue' + +/** + * Pos Mutations + * @author Elsio Sanchez + */ +export default { + setPontOfSales(state, pos) { + state.pointOfSales = pos + }, + setCurrentPOS(state, pos) { + Vue.set(state.pointOfSales, 'currentPOS', pos) + }, + listPointOfSales(state, listPointOfSales) { + state.listPointOfSales = listPointOfSales + }, + currentPointOfSales(state, currentPointOfSales) { + state.currentPointOfSales = currentPointOfSales + }, + setShowPOSOptions(state, isShowedOptions) { + state.showPOSOptions = isShowedOptions + }, + setShowPOSKeyLayout(state, isShowedKeyLayout) { + state.showPOSKeyLayout = isShowedKeyLayout + }, + setShowPOSCollection(state, isShowedCollection) { + state.showPOSCollection = isShowedCollection + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/point/state.js b/src/store/modules/ADempiere/pointOfSales/point/state.js new file mode 100644 index 00000000..5dd4c8e3 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/point/state.js @@ -0,0 +1,35 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * Pos State + */ +const withoutResponse = { + isLoaded: false, + isReload: true, + recordCount: 0, + nextPageToken: undefined +} +export default { + pointOfSales: { + ...withoutResponse + }, + listPointOfSales: {}, + currentPointOfSales: {}, + showPOSOptions: false, + showPOSKeyLayout: false, + showPOSCollection: false +} diff --git a/src/store/modules/ADempiere/pointOfSales/productPrice/actions.js b/src/store/modules/ADempiere/pointOfSales/productPrice/actions.js new file mode 100644 index 00000000..cebd3c40 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/productPrice/actions.js @@ -0,0 +1,180 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import { + getProductPriceList +} from '@/api/ADempiere/form/point-of-sales.js' +import { isEmptyValue, extractPagingToken } from '@/utils/ADempiere/valueUtils.js' +import { showMessage } from '@/utils/ADempiere/notification.js' +import language from '@/lang' + +/** + * Product Price Actions + */ +export default { + setProductPicePageNumber({ commit }, pageNumber) { + commit('setProductPicePageNumber', pageNumber) + commit('setIsReloadProductPrice') + }, + listProductPriceFromServer({ state, commit, rootGetters }, { + containerUuid = 'Products-Price-List', + pageNumber, // 1 + searchValue, + currentPOS + }) { + const posUuid = isEmptyValue(currentPOS) ? rootGetters.posAttributes.currentPointOfSales.uuid : currentPOS.uuid + if (isEmptyValue(posUuid)) { + const message = language.t('notifications.errorPointOfSale') + showMessage({ + type: 'info', + message + }) + console.warn(message) + return + } + commit('setIsReloadProductPrice') + let pageToken, token + if (isEmptyValue(pageNumber)) { + pageNumber = state.productPrice.pageNumber + if (isEmptyValue(pageNumber)) { + pageNumber = 1 + } + + token = state.productPrice.token + if (!isEmptyValue(token)) { + pageToken = token + '-' + pageNumber + } + } + const { priceList, templateBusinessPartner } = rootGetters.posAttributes.currentPointOfSales + const { uuid: businessPartnerUuid } = templateBusinessPartner + const { uuid: priceListUuid } = priceList + const { uuid: warehouseUuid } = rootGetters['user/getWarehouse'] + if (isEmptyValue(searchValue)) { + searchValue = rootGetters.getValueOfField({ + containerUuid, + columnName: 'ProductValue' + }) + } + return new Promise(resolve => { + getProductPriceList({ + searchValue, + priceListUuid, + businessPartnerUuid, + warehouseUuid, + pageToken + }).then(responseProductPrice => { + if (isEmptyValue(token) || isEmptyValue(pageToken)) { + token = extractPagingToken(responseProductPrice.nextPageToken) + } + + commit('setListProductPrice', { + ...responseProductPrice, + isLoaded: true, + isReload: false, + businessPartnerUuid, + warehouseUuid, + token, + pageNumber + }) + + resolve(responseProductPrice) + }).catch(error => { + console.warn(`getKeyLayoutFromServer: ${error.message}. Code: ${error.code}.`) + showMessage({ + type: 'error', + message: error.message, + showClose: true + }) + }) + }) + }, + listProductPriceFromServerProductInfo({ state, commit, rootGetters }, { + containerUuid = 'Products-Price-List-ProductInfo', + pageNumber, // 1 + searchValue + }) { + const posUuid = rootGetters.posAttributes.currentPointOfSales.uuid + if (isEmptyValue(posUuid)) { + const message = 'Sin punto de venta seleccionado' + showMessage({ + type: 'info', + message + }) + console.warn(message) + return + } + commit('setIsReloadProductPrice') + let pageToken, token + if (isEmptyValue(pageNumber)) { + pageNumber = state.productPrice.pageNumber + if (isEmptyValue(pageNumber)) { + pageNumber = 1 + } + + token = state.productPrice.token + if (!isEmptyValue(token)) { + pageToken = token + '-' + pageNumber + } + } + + const { priceList, templateBusinessPartner } = rootGetters.posAttributes.currentPointOfSales + const { uuid: businessPartnerUuid } = templateBusinessPartner + const { uuid: priceListUuid } = priceList + const { uuid: warehouseUuid } = rootGetters['user/getWarehouse'] + + if (isEmptyValue(searchValue)) { + searchValue = rootGetters.getValueOfField({ + containerUuid, + columnName: 'ProductValue' + }) + } + return new Promise(resolve => { + getProductPriceList({ + searchValue, + priceListUuid, + businessPartnerUuid, + warehouseUuid, + pageToken + }).then(responseProductPrice => { + if (isEmptyValue(token) || isEmptyValue(pageToken)) { + token = extractPagingToken(responseProductPrice.nextPageToken) + } + + commit('setListProductPrice', { + ...responseProductPrice, + isLoaded: true, + isReload: false, + businessPartnerUuid, + warehouseUuid, + token, + pageNumber + }) + + resolve(responseProductPrice) + }).catch(error => { + console.warn(`getKeyLayoutFromServer: ${error.message}. Code: ${error.code}.`) + showMessage({ + type: 'error', + message: error.message, + showClose: true + }) + }) + }) + }, + updateSearch({ commit }, newValue) { + commit('updtaeSearchProduct', newValue) + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/productPrice/index.js b/src/store/modules/ADempiere/pointOfSales/productPrice/index.js new file mode 100644 index 00000000..355f6f4d --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/productPrice/index.js @@ -0,0 +1,32 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import state from './state.js' +import mutations from './mutations.js' +import actions from './actions.js' + +/** + * Product Price Vuex Module + * Product List + * Search Product + */ +const listProductPrice = { + state, + mutations, + actions +} + +export default listProductPrice diff --git a/src/store/modules/ADempiere/pointOfSales/productPrice/mutations.js b/src/store/modules/ADempiere/pointOfSales/productPrice/mutations.js new file mode 100644 index 00000000..a3dc23e0 --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/productPrice/mutations.js @@ -0,0 +1,42 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * Product Price Mutations + */ +import Vue from 'vue' + +export default { + setListProductPrice(state, productsPrices) { + state.productPrice = { + ...state.productPrice, + ...productsPrices + } + }, + setProductPicePageNumber(state, pageNumber) { + state.productPrice.pageNumber = pageNumber + }, + showListProductPrice(state, payload) { + Vue.set(state.productPrice, payload.attribute, payload.isShowed) + }, + setIsReloadProductPrice(state) { + Vue.set(state.productPrice, 'isReload', true) + Vue.set(state.productPrice, 'isLoaded', false) + }, + updtaeSearchProduct(state, searchProduct) { + state.searchProduct = searchProduct + } +} diff --git a/src/store/modules/ADempiere/pointOfSales/productPrice/state.js b/src/store/modules/ADempiere/pointOfSales/productPrice/state.js new file mode 100644 index 00000000..b5f5895a --- /dev/null +++ b/src/store/modules/ADempiere/pointOfSales/productPrice/state.js @@ -0,0 +1,33 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/** + * Product Price State + */ +const withoutResponse = { + isLoaded: false, + isReload: true, + recordCount: 0, + nextPageToken: undefined +} +export default { + productPrice: { + ...withoutResponse, + isShowPopoverField: false, // with field + isShowPopoverMenu: false // with menu + }, + searchProduct: '' +}