From 587e8cb9c176df4cfd8c16b7b1f0ca80c667895d Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Mon, 21 Jun 2021 19:50:56 -0400 Subject: [PATCH] support price checking (#930) * support price checking * correcting comments Co-authored-by: elsiosanchez --- .../ADempiere/Form/PriceChecking/index.vue | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/src/components/ADempiere/Form/PriceChecking/index.vue b/src/components/ADempiere/Form/PriceChecking/index.vue index ce433af3..31c402f7 100644 --- a/src/components/ADempiere/Form/PriceChecking/index.vue +++ b/src/components/ADempiere/Form/PriceChecking/index.vue @@ -73,7 +73,7 @@
{{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }}
- {{ formatPrice(productPrice.schemaGrandTotal, productPrice.schemaCurrency.iSOCode) }} + {{ formatPrice(productPrice.grandTotalConverted, currentPointOfSales.displayCurrency.iSOCode) }}
@@ -133,8 +133,17 @@ export default { defaultImage() { return require('@/image/ADempiere/priceChecking/no-image.jpg') }, - currentPoint() { + currentPointOfSales() { return this.$store.getters.posAttributes.currentPointOfSales + }, + pointOfSalesList() { + return this.$store.getters.posAttributes.pointOfSalesList + }, + convertionsList() { + return this.$store.state['pointOfSales/point/index'].conversionsList + }, + currentConvertion() { + return this.convertionsList.find(convert => convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id) } }, created() { @@ -143,12 +152,23 @@ export default { mounted() { this.backgroundForm = this.defaultImage this.getImageFromSource(this.organizationImagePath) - this.$store.dispatch('listPointOfSalesFromServer') + if (this.isEmptyValue(this.pointOfSalesList)) { + this.$store.dispatch('listPointOfSalesFromServer') + } + if (!this.isEmptyValue(this.pointOfSalesList) && this.isEmptyValue(this.currentConvertion)) { + this.$store.dispatch('searchConversion', { + conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, + currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid, + currencyToUuid: this.currentPointOfSales.displayCurrency.uuid + }) + } }, beforeDestroy() { this.unsubscribe() }, methods: { + formatPercent, + formatPrice, focusProductValue() { if (!this.isEmptyValue(this.$refs.ProductValue[0])) { this.$refs.ProductValue[0].$children[0].$children[0].$children[1].$children[0].focus() @@ -165,8 +185,10 @@ export default { }) this.backgroundForm = image.uri }, - formatPercent, - formatPrice, + amountConvert(price, currency) { + const convertion = this.convertionsList.find(convert => convert.currencyTo.id === currency.id) + return price / convertion.divideRate + }, subscribeChanges() { return this.$store.subscribe((mutation, state) => { if ((mutation.type === 'currentPointOfSales') || (mutation.type === 'setListProductPrice') || (mutation.type === 'addFocusLost')) { @@ -178,7 +200,7 @@ export default { if (!this.isEmptyValue(this.search) && this.search.length >= 4) { getProductPrice({ searchValue: mutation.payload.value, - priceListUuid: this.currentPoint.priceList.uuid + posUuid: this.currentPointOfSales.uuid }) .then(productPrice => { this.messageError = true @@ -191,16 +213,12 @@ export default { image, grandTotal: this.getGrandTotal(priceBase, rate), productName: product.name, - productDescription: product.description, + productDescription: product.help, priceBase, priceStandard: productPrice.priceStandard, priceList: productPrice.priceList, priceLimit: productPrice.priceLimit, - schemaCurrency: productPrice.schemaCurrency, - schemaGrandTotal: this.getGrandTotal(productPrice.schemaPriceStandard, rate), - schemaPriceStandard: productPrice.schemaPriceStandard, - schemaPriceList: productPrice.schemaPriceList, - schemaPriceLimit: productPrice.schemaPriceLimit, + grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency), taxRate: rate, taxName: taxRate.name, taxIndicator: taxRate.taxIndicator, @@ -235,7 +253,7 @@ export default { } getProductPrice({ searchValue: mutation.payload.value, - priceListUuid: this.currentPoint.priceList.uuid + posUuid: this.currentPointOfSales.uuid }) .then(productPrice => { this.messageError = true @@ -253,7 +271,7 @@ export default { priceList: productPrice.priceList, priceLimit: productPrice.priceLimit, schemaCurrency: productPrice.schemaCurrency, - schemaGrandTotal: this.getGrandTotal(productPrice.schemaPriceStandard, rate), + grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency), schemaPriceStandard: productPrice.schemaPriceStandard, schemaPriceList: productPrice.schemaPriceList, schemaPriceLimit: productPrice.schemaPriceLimit,