diff --git a/src/api/ADempiere/form/point-of-sales.js b/src/api/ADempiere/form/point-of-sales.js index 618b0113..fac0e812 100644 --- a/src/api/ADempiere/form/point-of-sales.js +++ b/src/api/ADempiere/form/point-of-sales.js @@ -379,10 +379,7 @@ export function getKeyLayout({ keyLayoutUuid }) { export function getProductPriceList({ searchValue, businessPartnerUuid, - validFrom, posUuid, - // Query - // criteria, pageSize, pageToken }) { @@ -392,7 +389,6 @@ export function getProductPriceList({ params: { pos_uuid: posUuid, search_value: searchValue, - valid_from: validFrom, business_partner_uuid: businessPartnerUuid, page_size: pageSize, page_token: pageToken diff --git a/src/components/ADempiere/Field/mixin/mixinField.js b/src/components/ADempiere/Field/mixin/mixinField.js index 9b55968a..593f1f9b 100644 --- a/src/components/ADempiere/Field/mixin/mixinField.js +++ b/src/components/ADempiere/Field/mixin/mixinField.js @@ -158,7 +158,6 @@ export default { }, actionKeyPerformed(value) { // TODO: Delete for production - console.info('actionKeyPerformed ', value) if (this.metadata.handleActionKeyPerformed) { this.$store.dispatch('notifyActionKeyPerformed', { containerUuid: this.metadata.containerUuid, diff --git a/src/components/ADempiere/Form/VPOS/Collection/convertAmount/index.vue b/src/components/ADempiere/Form/VPOS/Collection/convertAmount/index.vue index 9e6705d8..24947ad4 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/convertAmount/index.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/convertAmount/index.vue @@ -21,7 +21,7 @@ {{ $t('form.pos.collect.convertAmount') }}: - {{ formatPrice(amountConvertionTotal, displayCurrency) }} + {{ formatPrice(amount / dayRate.divideRate, dayRate.iSOCode) }} @@ -33,12 +33,20 @@ label-width="10px" style="float: right; display: flex; line-height: 10px;" > - - - + + + + + @@ -89,10 +97,23 @@ export default { data() { return { fieldsList: fieldsListConvertAmountCollection, - amountConvertionTotal: this.amount + amountConvertionTotal: this.amount, + currentFieldCurrency: '', + grandTotalConverted: { + divideRate: 1, + currencyTo: { + iSOCode: this.currency.iSOCode + } + } } }, computed: { + listCurrency() { + return this.$store.getters.getCurrenciesList + }, + convertionsList() { + return this.$store.state['pointOfSales/point/index'].conversionsList + }, displayCurrency() { return this.$store.getters.getValueOfField({ containerUuid: 'Collection-Convert-Amount', @@ -129,37 +150,33 @@ export default { amountConvertion: 1 } }, - dateRate() { - return this.$store.getters.getConvertionRate.find(currency => { - if (currency.id === this.typeCurrency) { - return currency + dayRate() { + if (this.isEmptyValue(this.currentFieldCurrency)) { + return { + currencyTo: this.currentPointOfSales.currentPriceList.currency, + divideRate: 1, + iSOCode: this.currency.iSOCode + } + } + const currency = this.listCurrency.find(currency => currency.key === this.currentFieldCurrency) + const convert = this.convertionsList.find(convert => { + if (!this.isEmptyValue(currency) && + !this.isEmptyValue(convert.currencyTo) && + currency.id === convert.currencyTo.id && + this.currentPointOfSales.currentPriceList.currency.id !== currency.id + ) { + return convert } }) - } - }, - watch: { - dateRate(value) { - if (value && !this.isEmptyValue(value.amountConvertion)) { - this.amountConvertionTotal = this.amount / value.amountConvertion - } else { - this.amountConvertionTotal = this.amount + if (!this.isEmptyValue(convert)) { + return convert + } + return { + currencyTo: this.currentPointOfSales.currentPriceList.currency, + divideRate: 1, + iSOCode: this.currency.iSOCode } } - // currencyUuid(value) { - // const listCurrency = this.$store.getters.getConvertionRate.find(currency => { - // if (currency.uuid === value) { - // return currency - // } - // }) - // if (listCurrency === undefined) { - // this.$store.dispatch('conversionDivideRate', { - // conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, - // currencyFromUuid: this.pointOfSalesCurrency.uuid, - // conversionDate: this.formatDate(new Date()), - // currencyToUuid: value - // }) - // } - // } }, created() { this.defaultValueCurrency() @@ -189,6 +206,30 @@ export default { columnName: 'C_Currency_ID', value: this.currency.id }) + }, + amountConvert(currency) { + this.$store.dispatch('searchConversion', { + conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, + currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid, + currencyToUuid: currency.uuid + }) + }, + changeCurrency(value) { + this.currentFieldCurrency = value + const currency = this.listCurrency.find(currency => currency.key === value) + const convert = this.convertionsList.find(convert => { + if (!this.isEmptyValue(currency) && !this.isEmptyValue(convert.currencyTo) && currency.id === convert.currencyTo.id && this.currentPointOfSales.currentPriceList.currency.id !== currency.id) { + return convert + } + }) + this.grandTotalConverted = convert + if (!this.isEmptyValue(currency) && this.isEmptyValue(convert) && currency.uuid !== this.currentPointOfSales.currentPriceList.currency.uuid) { + this.$store.dispatch('searchConversion', { + conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, + currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid, + currencyToUuid: currency.uuid + }) + } } } } diff --git a/src/components/ADempiere/Form/VPOS/Collection/index.vue b/src/components/ADempiere/Form/VPOS/Collection/index.vue index 7efaa9a6..18194862 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/index.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/index.vue @@ -311,7 +311,7 @@ export default { }, computed: { listCurrency() { - return this.$store.state['pointOfSales/point/index'].currenciesList + return this.$store.getters.getCurrenciesList }, convertionList() { return this.$store.state['pointOfSales/point/index'].conversionsList diff --git a/src/components/ADempiere/Form/VPOS/Options/index.vue b/src/components/ADempiere/Form/VPOS/Options/index.vue index 55e67123..054f82de 100644 --- a/src/components/ADempiere/Form/VPOS/Options/index.vue +++ b/src/components/ADempiere/Form/VPOS/Options/index.vue @@ -330,7 +330,6 @@ import { } from '@/api/ADempiere/form/point-of-sales.js' import ModalDialog from '@/components/ADempiere/Dialog' import posProcess from '@/utils/ADempiere/constants/posProcess' -import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js' import orderLineMixin from '@/components/ADempiere/Form/VPOS/Order/orderLineMixin.js' export default { @@ -341,8 +340,7 @@ export default { ModalDialog }, mixins: [ - orderLineMixin, - posMixin + orderLineMixin ], props: { metadata: { @@ -391,6 +389,50 @@ export default { size() { const size = this.$store.getters.getWidthLeft return 24 / size + }, + currentPointOfSales() { + return this.$store.getters.posAttributes.currentPointOfSales + }, + listPointOfSales() { + return this.$store.getters.posAttributes.pointOfSalesList + }, + priceListPointOfSales() { + const list = this.$store.getters.posAttributes.currentPointOfSales.pricesList + if (this.isEmptyValue(list)) { + return [] + } + return list + }, + warehousesListPointOfSales() { + const list = this.$store.getters.posAttributes.currentPointOfSales.warehousesList + if (this.isEmptyValue(list)) { + return [] + } + return list + }, + 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 } }, created() { @@ -585,6 +627,62 @@ export default { this.$store.dispatch('getProcessFromServer', { containerUuid: item.uuid, processId: item.id }) }) } + }, + changePos(posElement) { + this.$store.dispatch('setCurrentPOS', posElement) + this.newOrder() + }, + 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', []) + }) } } } diff --git a/src/components/ADempiere/Form/VPOS/Order/index.vue b/src/components/ADempiere/Form/VPOS/Order/index.vue index d37296cb..44a325f6 100644 --- a/src/components/ADempiere/Form/VPOS/Order/index.vue +++ b/src/components/ADempiere/Form/VPOS/Order/index.vue @@ -684,7 +684,6 @@ export default { formatPrice, formatQuantity, focusPin() { - console.log(this.$refs) this.$refs.pin.focus() }, openPin(pin) { diff --git a/src/components/ADempiere/Form/VPOS/ProductInfo/productList.vue b/src/components/ADempiere/Form/VPOS/ProductInfo/productList.vue index 716d6205..0cc1ca8f 100644 --- a/src/components/ADempiere/Form/VPOS/ProductInfo/productList.vue +++ b/src/components/ADempiere/Form/VPOS/ProductInfo/productList.vue @@ -33,12 +33,11 @@ :metadata-field="field" /> - data.product.name.toLowerCase().includes(this.searchValue.toLowerCase()) || data.product.value.toLowerCase().includes(this.searchValue.toLowerCase())) + if (!this.isEmptyValue(filtersProduct)) { + return filtersProduct + } + this.isLoadedServer = true + this.timeOut = setTimeout(() => { + this.$store.dispatch('listProductPriceFromServer', { + containerUuid: 'Products-Price-List', + pageNumber: 1, + searchValue: this.searchValue + }) + .then(() => { + const recordsList = this.listWithPrice + + if (this.isEmptyValue(recordsList)) { + this.$message({ + message: 'Sin resultados coincidentes con la busqueda', + type: 'info', + showClose: true + }) + } + this.isLoadedServer = false + return recordsList + }) + }, 2000) + } + return listWithPrice + }, keyAction(event) { switch (event.srcKey) { case 'refreshList': @@ -215,6 +252,12 @@ export default { this.timeOut = setTimeout(() => { this.$store.commit('setIsReloadProductPrice') }, 1000) + } else if (mutation.type === 'addActionKeyPerformed' && mutation.payload.containerUuid === this.metadata.containerUuid) { + this.$store.dispatch('listProductPriceFromServer', { + containerUuid: mutation.payload.containerUuid, + pageNumber: 1, + searchValue: mutation.payload.value + }) } }) }, diff --git a/src/components/ADempiere/Form/VPOS/posMixin.js b/src/components/ADempiere/Form/VPOS/posMixin.js index d515933b..0469fdaa 100644 --- a/src/components/ADempiere/Form/VPOS/posMixin.js +++ b/src/components/ADempiere/Form/VPOS/posMixin.js @@ -346,7 +346,8 @@ export default { } findProduct({ searchValue: searchProduct, - priceListUuid: this.curretnPriceList.uuid + priceListUuid: this.curretnPriceList.uuid, + posUuid: this.currentPointOfSales.uuid }) .then(productPrice => { this.product = productPrice.product @@ -471,6 +472,10 @@ export default { } else if (mutation.type === 'addActionPerformed') { switch (mutation.payload.columnName) { case 'QtyEntered': + if (!this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) { + this.updateOrderLine(mutation.payload) + } + break case 'PriceEntered': case 'Discount': if (this.isPosRequiredPin && !this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) { diff --git a/src/store/modules/ADempiere/pointOfSales/getters/index.js b/src/store/modules/ADempiere/pointOfSales/getters/index.js index 3c57a702..466643ab 100644 --- a/src/store/modules/ADempiere/pointOfSales/getters/index.js +++ b/src/store/modules/ADempiere/pointOfSales/getters/index.js @@ -140,6 +140,9 @@ export default { return state.currentDocumentTypePos } return {} - } + }, // Current POS, it can be s + getCurrenciesList: (state) => { + return state.currenciesList + } } diff --git a/src/store/modules/ADempiere/pointOfSales/point/state.js b/src/store/modules/ADempiere/pointOfSales/point/state.js index cae9bc8a..c058b7a2 100644 --- a/src/store/modules/ADempiere/pointOfSales/point/state.js +++ b/src/store/modules/ADempiere/pointOfSales/point/state.js @@ -35,6 +35,7 @@ export default { currentWarehousePos: {}, currentDocumentTypePos: {}, listCurrency: [], + currenciesList: [], conversionsList: [], currentPointOfSales: {}, showPOSOptions: false, diff --git a/src/store/modules/ADempiere/pointOfSales/productPrice/actions.js b/src/store/modules/ADempiere/pointOfSales/productPrice/actions.js index 55dee86b..55f2200a 100644 --- a/src/store/modules/ADempiere/pointOfSales/productPrice/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/productPrice/actions.js @@ -71,7 +71,7 @@ export default { return new Promise(resolve => { getProductPriceList({ searchValue, - posUuid: currentPointOfSales.uuid, + posUuid, businessPartnerUuid, pageToken }).then(responseProductPrice => { @@ -103,9 +103,10 @@ export default { listProductPriceFromServerProductInfo({ state, commit, rootGetters }, { containerUuid = 'Products-Price-List-ProductInfo', pageNumber, // 1 - searchValue + searchValue, + currentPOS }) { - const posUuid = rootGetters.posAttributes.currentPointOfSales.uuid + const posUuid = isEmptyValue(currentPOS) ? rootGetters.posAttributes.currentPointOfSales.uuid : currentPOS.uuid if (isEmptyValue(posUuid)) { const message = 'Sin punto de venta seleccionado' showMessage({ @@ -142,7 +143,7 @@ export default { return new Promise(resolve => { getProductPriceList({ searchValue, - posUuid: rootGetters.currentPointOfSales.uuid, + posUuid: posUuid, businessPartnerUuid, pageToken }).then(responseProductPrice => {