From 79e9e6659b7adb854c7d52e50ef25b256c2b832c Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Wed, 23 Jun 2021 16:05:11 -0400 Subject: [PATCH] Add Day Rate (#936) * validate displayCurrency * Add Day Rate * minimal changes * add tax to the converted amount * add translation Co-authored-by: elsiosanchez --- .../ADempiere/Form/PriceChecking/index.vue | 110 ++++++++++++------ src/lang/ADempiere/en.js | 1 + src/lang/ADempiere/es.js | 1 + .../pointOfSales/payments/actions.js | 3 +- 4 files changed, 80 insertions(+), 35 deletions(-) diff --git a/src/components/ADempiere/Form/PriceChecking/index.vue b/src/components/ADempiere/Form/PriceChecking/index.vue index 31c402f7..bfbc51df 100644 --- a/src/components/ADempiere/Form/PriceChecking/index.vue +++ b/src/components/ADempiere/Form/PriceChecking/index.vue @@ -21,19 +21,21 @@ style="height: 100% !important;" @click="focusProductValue" > + + -
+
+ {{ productPrice.productName }}
{{ productPrice.productDescription }} +
- -
- {{ productPrice.productName }} {{ productPrice.productDescription }} -
-


- +
{{ $t('form.priceChecking.basePrice') }} @@ -70,10 +70,9 @@



-
{{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }}
- {{ formatPrice(productPrice.grandTotalConverted, currentPointOfSales.displayCurrency.iSOCode) }} + {{ formatPrice(productPrice.grandTotal / converted, currentPointOfSales.displayCurrency.iso_code) }}
@@ -87,6 +86,18 @@
+
+ + +
+ {{ $t('form.pos.collect.dayRate') }}: {{ formatQuantity(currentConvertion.multiplyRate) }} ~ ({{ formatPrice(1, productPrice.currency.iSOCode) }} = {{ formatPrice(currentConvertion.multiplyRate) }} {{ currentPointOfSales.displayCurrency.iso_code }}) +
+
+ {{ $t('form.pos.collect.noDayRate') }} {{ currentPointOfSales.displayCurrency.description }} +
+
+
+
@@ -105,7 +116,7 @@ import formMixin from '@/components/ADempiere/Form/formMixin.js' import fieldsList from './fieldsList.js' import { getProductPrice } from '@/api/ADempiere/form/price-checking.js' -import { formatPercent, formatPrice } from '@/utils/ADempiere/valueFormat.js' +import { formatPercent, formatPrice, formatQuantity } from '@/utils/ADempiere/valueFormat.js' import { getImagePath } from '@/utils/ADempiere/resource.js' export default { @@ -143,7 +154,31 @@ export default { return this.$store.state['pointOfSales/point/index'].conversionsList }, currentConvertion() { - return this.convertionsList.find(convert => convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id) + if (this.isEmptyValue(this.currentPointOfSales.displayCurrency)) { + return {} + } + const convert = this.convertionsList.find(convert => { + if (!this.isEmptyValue(convert.currencyTo) && !this.isEmptyValue(this.currentPointOfSales.displayCurrency) && convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id) { + return convert + } + }) + if (convert) { + return convert + } + return {} + }, + converted() { + if (!this.isEmptyValue(this.convertionsList)) { + const convertion = this.convertionsList.find(convert => { + if (!this.isEmptyValue(convert.currencyTo) && !this.isEmptyValue(this.currentPointOfSales.displayCurrency) && convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id) { + return convert + } + }) + if (!this.isEmptyValue(convertion)) { + return convertion.divideRate + } + } + return 1 } }, created() { @@ -155,13 +190,6 @@ export default { 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() @@ -169,6 +197,7 @@ export default { methods: { formatPercent, formatPrice, + formatQuantity, focusProductValue() { if (!this.isEmptyValue(this.$refs.ProductValue[0])) { this.$refs.ProductValue[0].$children[0].$children[0].$children[1].$children[0].focus() @@ -180,14 +209,19 @@ export default { } const image = getImagePath({ file: fileName, - width: 250, - height: 280 + width: 900, + height: 900 }) this.backgroundForm = image.uri }, - amountConvert(price, currency) { - const convertion = this.convertionsList.find(convert => convert.currencyTo.id === currency.id) - return price / convertion.divideRate + amountConvert() { + if (!this.isEmptyValue(this.currentPointOfSales) && this.isEmptyValue(this.currentConvertion) && !this.isEmptyValue(this.currentPointOfSales.displayCurrency)) { + this.$store.dispatch('searchConversion', { + conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid, + currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid, + currencyToUuid: this.currentPointOfSales.displayCurrency.uuid + }) + } }, subscribeChanges() { return this.$store.subscribe((mutation, state) => { @@ -218,7 +252,6 @@ export default { priceStandard: productPrice.priceStandard, priceList: productPrice.priceList, priceLimit: productPrice.priceLimit, - grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency), taxRate: rate, taxName: taxRate.name, taxIndicator: taxRate.taxIndicator, @@ -232,6 +265,7 @@ export default { this.productPrice = {} }) .finally(() => { + this.amountConvert() this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, columnName: 'ProductValue', @@ -271,7 +305,6 @@ export default { priceList: productPrice.priceList, priceLimit: productPrice.priceLimit, schemaCurrency: productPrice.schemaCurrency, - grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency), schemaPriceStandard: productPrice.schemaPriceStandard, schemaPriceList: productPrice.schemaPriceList, schemaPriceLimit: productPrice.schemaPriceLimit, @@ -287,6 +320,7 @@ export default { this.productPrice = {} }) .finally(() => { + this.amountConvert() this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, columnName: 'ProductValue', @@ -340,7 +374,9 @@ export default { color: #32363a; font-size: 30px; float: right; - padding-bottom: 0px; + padding-bottom: 1%; + text-align: end; + } .product-price-base, .product-tax { font-size: 30px; @@ -351,7 +387,14 @@ export default { font-size: 50px; float: right; } - + .rate-date { + padding-top: 30%; + font-size: 50px; + float: right; + color: black; + font-weight: bold; + text-align: end; + } .inquiry-form { position: absolute; right: 5%; @@ -361,8 +404,7 @@ export default { } .inquiry-product { position: absolute; - right: 20%; - width: 100%; + right: 10%; top: 33%; .amount { color: black; diff --git a/src/lang/ADempiere/en.js b/src/lang/ADempiere/en.js index fabb2613..bbf4c763 100644 --- a/src/lang/ADempiere/en.js +++ b/src/lang/ADempiere/en.js @@ -477,6 +477,7 @@ export default { convertedAmount: 'Converted Amount', fullPayment: 'Full Payment', dayRate: 'Day Rate', + noDayRate: 'No daily rate has been generated for the currency.', TenderType: { directDeposit: 'Direct Deposit', creditCard: 'Credit Card', diff --git a/src/lang/ADempiere/es.js b/src/lang/ADempiere/es.js index 592c50a2..24ff88e4 100644 --- a/src/lang/ADempiere/es.js +++ b/src/lang/ADempiere/es.js @@ -452,6 +452,7 @@ export default { convertedAmount: 'Monto Convertido', fullPayment: 'Cobro Completo', dayRate: 'Tasa del Día', + noDayRate: 'No se a generado una tasa del día para la moneda', TenderType: { directDeposit: 'Depósito Directo', creditCard: 'Tarjeta de Crédito', diff --git a/src/store/modules/ADempiere/pointOfSales/payments/actions.js b/src/store/modules/ADempiere/pointOfSales/payments/actions.js index 236054ba..2cc5c8b1 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/actions.js @@ -112,7 +112,7 @@ export default { payment.splice(0) }, searchConversion({ commit }, params) { - requestGetConversionRate({ + return requestGetConversionRate({ conversionTypeUuid: params.conversionTypeUuid, currencyFromUuid: params.currencyFromUuid, currencyToUuid: params.currencyToUuid, @@ -120,6 +120,7 @@ export default { }) .then(response => { commit('addConversionToList', response) + return response }) .catch(error => { console.warn(`conversionDivideRate: ${error.message}. Code: ${error.code}.`)