diff --git a/src/components/ADempiere/Form/VPOS/Collection/convertAmount/index.vue b/src/components/ADempiere/Form/VPOS/Collection/convertAmount/index.vue index 6e1f0a6d..197d854b 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(amount * convert, displayCurrency) }} + {{ formatPrice(amountConvertionTotal, displayCurrency) }} @@ -80,11 +80,16 @@ export default { containerUuid: 'Collection-Convert-Amount' } } + }, + isOpen: { + type: Boolean, + default: false } }, data() { return { - fieldsList: fieldsListConvertAmountCollection + fieldsList: fieldsListConvertAmountCollection, + amountConvertionTotal: 0 } }, computed: { @@ -105,6 +110,55 @@ export default { containerUuid: 'Collection-Convert-Amount', columnName: 'C_Currency_ID_UUID' }) + }, + currentPointOfSales() { + return this.$store.getters.posAttributes.currentPointOfSales + }, + pointOfSalesCurrency() { + // const currency = this.currentPointOfSales + if (!this.isEmptyValue(this.currentPointOfSales.priceList)) { + return { + ...this.currentPointOfSales.priceList.currency, + amountConvertion: 1 + } + } + return { + uuid: '', + iSOCode: '', + curSymbol: '', + amountConvertion: 1 + } + }, + dateRate() { + return this.$store.getters.getConvertionRate.find(currency => { + if (currency.id === this.typeCurrency) { + return currency + } + }) + } + }, + watch: { + dateRate(value) { + if (value && !this.isEmptyValue(value.amountConvertion)) { + this.amountConvertionTotal = this.amount / value.amountConvertion + } else { + this.amountConvertionTotal = this.amount + } + }, + 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() { @@ -112,6 +166,18 @@ export default { }, methods: { formatPrice, + formatDate(date) { + let month = '' + (date.getMonth() + 1) + let day = '' + date.getDate() + const year = date.getFullYear() + if (month.length < 2) { + month = '0' + month + } + if (day.length < 2) { + day = '0' + day + } + return [year, month, day].join('-') + }, defaultValueCurrency() { this.$store.commit('updateValueOfField', { containerUuid: this.containerUuid, diff --git a/src/components/ADempiere/Form/VPOS/Collection/index.vue b/src/components/ADempiere/Form/VPOS/Collection/index.vue index a94377b1..63189fea 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/index.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/index.vue @@ -545,7 +545,10 @@ export default { columnName: 'DisplayColumn_PaymentType' }) if (!this.isEmptyValue(value.reference) && this.isEmptyValue(displayPaymentType)) { - value.reference.directQuery = value.reference.query + this.$store.dispatch('getLookupListFromServer', { + tableName: value.reference.tableName, + query: value.reference.query + }) } } }, diff --git a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue index cd5b6670..9163705d 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue @@ -162,7 +162,7 @@ export default { }, created() { this.convertingPaymentMethods() - if (this.isEmptyValue(this.labelTypesPayment)) { + if (this.isEmptyValue(this.labelTypesPayment.reference) && !this.isEmptyValue(this.listPaymentType.reference)) { this.tenderTypeDisplaye({ tableName: this.listPaymentType.reference.tableName, query: this.listPaymentType.reference.query @@ -182,7 +182,9 @@ export default { }) .then(response => { this.isAddTypePay.forEach(element => { + console.log({ element }) if (element.currencyUuid !== this.pointOfSalesCurrency.uuid) { + element.amount = element.amount / response.multiplyRate element.amountConvertion = element.amount / response.divideRate element.currencyConvertion = response.currencyTo } else { diff --git a/src/components/ADempiere/Form/VPOS/Order/index.vue b/src/components/ADempiere/Form/VPOS/Order/index.vue index 6cfc0b7e..c37a59d2 100644 --- a/src/components/ADempiere/Form/VPOS/Order/index.vue +++ b/src/components/ADempiere/Form/VPOS/Order/index.vue @@ -228,6 +228,7 @@ :convert="multiplyRate" :amount="currentOrder.grandTotal" :currency="pointOfSalesCurrency" + :is-open="seeConversion" /> {{ formatPrice(currentOrder.grandTotal, pointOfSalesCurrency.iSOCode) }} diff --git a/src/store/modules/ADempiere/pointOfSales/order/actions.js b/src/store/modules/ADempiere/pointOfSales/order/actions.js index fcfb3ee3..341e3d6b 100644 --- a/src/store/modules/ADempiere/pointOfSales/order/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/order/actions.js @@ -81,7 +81,7 @@ export default { }) .catch(error => { console.error(error.message) - this.$message({ + showMessage({ type: 'error', message: error.message, showClose: true @@ -114,7 +114,6 @@ export default { }) .then(orderLine => { dispatch('updateOrderLines', orderLine) - // this.fillOrderLine(orderLine) this.reloadOrder(true, orderUuid) }) .catch(error => {