diff --git a/src/components/ADempiere/Field/FieldNumber.vue b/src/components/ADempiere/Field/FieldNumber.vue
index 264f0a74..0248820d 100644
--- a/src/components/ADempiere/Field/FieldNumber.vue
+++ b/src/components/ADempiere/Field/FieldNumber.vue
@@ -160,6 +160,12 @@ export default {
return this.$store.getters.getCountryLanguage
},
currencyCode() {
+ if (!this.isEmptyValue(this.metadata.labelCurrency)) {
+ if (this.metadata.labelCurrency.iSOCode === this.currencyDefinition.iSOCode) {
+ return this.currencyDefinition.iSOCode
+ }
+ return this.metadata.labelCurrency.iSOCode
+ }
return this.currencyDefinition.iSOCode
},
currencyDefinition() {
diff --git a/src/components/ADempiere/Form/VPOS/Collection/index.vue b/src/components/ADempiere/Form/VPOS/Collection/index.vue
index 59b7899b..a11d1c02 100644
--- a/src/components/ADempiere/Form/VPOS/Collection/index.vue
+++ b/src/components/ADempiere/Form/VPOS/Collection/index.vue
@@ -73,7 +73,10 @@
@@ -93,6 +96,7 @@
:is-add-type-pay="listPayments"
:currency="currencyPoint"
:list-types-payment="fieldsList[2]"
+ :is-loaded="isLoadedPayments"
/>
{
return pay.isVisible
@@ -373,7 +380,10 @@ export default {
return missing
}
const pending = this.currentOrder.grandTotal <= this.pay ? 0 : this.currentOrder.grandTotal
- return pending
+ return pending / this.convertion
+ },
+ convertion() {
+ return this.$store.getters.getDivideRateCollection
},
isMandatory() {
const containerUuid = this.containerUuid
@@ -508,15 +518,14 @@ export default {
currencyToUuid: value
})
}
- if (!this.isEmptyValue(value)) {
- this.$store.dispatch('conversionMultiplyRate', {
+ if (this.isEmptyValue(value)) {
+ this.$store.commit('setFieldCurrency', this.currencyPoint)
+ this.$store.dispatch('conversionDivideRate', {
containerUuid: 'Collection',
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value
})
- } else {
- this.$store.commit('currencyMultiplyRateCollection', 1)
}
},
convertAllPayment(value) {
@@ -525,18 +534,6 @@ export default {
}
this.allPayCurrency = this.pay
},
- converCurrency(value) {
- if (!this.isEmptyValue(value)) {
- this.$store.dispatch('conversionMultiplyRate', {
- containerUuid: 'Collection',
- conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
- currencyFromUuid: this.currencyPoint.uuid,
- currencyToUuid: value
- })
- } else {
- this.$store.commit('currencyMultiplyRate', 1)
- }
- },
isLoaded(value) {
if (value) {
this.$store.commit('updateValueOfField', {
@@ -551,19 +548,16 @@ export default {
this.unsubscribe = this.subscribeChanges()
this.defaultValueCurrency()
},
- mounted() {
- setTimeout(() => {
- this.convertCurrency()
- }, 2000)
- },
methods: {
formatDate,
formatPrice,
sumCash(cash) {
let sum = 0
- cash.forEach((pay) => {
- sum += pay.amount
- })
+ if (cash) {
+ cash.forEach((pay) => {
+ sum += pay.amount
+ })
+ }
return sum
},
notSubmitForm(event) {
@@ -612,7 +606,7 @@ export default {
orderUuid,
bankUuid,
referenceNo,
- amount: this.amontSend,
+ amount: this.amontSend * this.convertion,
paymentDate,
tenderTypeCode,
currencyUuid
@@ -623,7 +617,7 @@ export default {
orderUuid,
bankUuid,
referenceNo,
- amount: this.amontSend,
+ amount: this.amontSend * this.convertion,
paymentDate,
tenderTypeCode,
currencyUuid: this.currencyDisplay(currencyToPay)
@@ -669,7 +663,7 @@ export default {
})
})
this.defaultValueCurrency()
- this.$store.dispatch('conversionDivideRate', 1)
+ this.$store.commit('currencyDivideRateCollection', 1)
this.$store.commit('currencyMultiplyRate', 1)
this.cancel()
},
@@ -697,7 +691,7 @@ export default {
value: this.pending
})
this.defaultValueCurrency()
- this.$store.dispatch('conversionDivideRate', 1)
+ this.$store.commit('currencyDivideRateCollection', 1)
this.$store.commit('currencyMultiplyRate', 1)
},
exit() {
@@ -764,14 +758,6 @@ export default {
}
return currency
},
- convertCurrency() {
- const convertCurrency = this.currencyDisplay(100)
- this.$store.dispatch('convertionPayment', {
- conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
- currencyFromUuid: this.currencyPoint.uuid,
- currencyToUuid: convertCurrency.currencyUuid
- })
- },
undoPatment() {
const list = this.listPayments[this.listPayments.length - 1]
const orderUuid = list.orderUuid
diff --git a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue
index ec5c2125..d3988376 100644
--- a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue
+++ b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue
@@ -39,7 +39,7 @@
{{
tenderTypeFind({
currentPayment: value.tenderTypeCode,
- listTypePayment: typesPayment
+ listTypePayment: labelTypesPayment
})
}}
@@ -62,11 +62,7 @@
{{ formatDate(value.paymentDate) }}
-
+
- {{
- formatPrice(
- (amountConvertion(value)),
- currencyFind({
- currencyCurrent: value.currencyUuid,
- listCurrency: listCurrency,
- defaultCurrency: currency
- }).currencyDisplay
- )
- }}
-
-
-
-
-
-
- {{ formatPrice(value.amount, currency.iSOCode) }}
+ {{ formatPrice(value.amountConvertion, value.currencyConvertion.iSOCode) }}
@@ -116,6 +96,9 @@ import {
formatDate,
formatPrice
} from '@/utils/ADempiere/valueFormat.js'
+import {
+ requestGetConversionRate
+} from '@/api/ADempiere/form/point-of-sales.js'
export default {
name: 'TypeCollection',
@@ -131,11 +114,17 @@ export default {
listTypesPayment: {
type: Object,
default: undefined
+ },
+ isLoaded: {
+ type: Boolean,
+ default: false
}
},
data() {
return {
- conevertion: 0
+ conevertion: 0,
+ loginCovertion: false,
+ labelTypesPayment: []
}
},
computed: {
@@ -149,16 +138,42 @@ export default {
return this.$store.getters.getConvertionPayment
}
},
- watch: {
- listTypesPayment(value) {
- if (!this.isEmptyValue(value) && this.typesPayment.length <= 1) {
- this.tenderTypeDisplaye(value)
- }
+ created() {
+ this.convertingPaymentMethods()
+ if (this.isEmptyValue(this.labelTypesPayment)) {
+ this.tenderTypeDisplaye(this.listTypesPayment)
}
},
methods: {
formatDate,
formatPrice,
+ convertingPaymentMethods() {
+ const currencyUuid = this.isAddTypePay.find(pay => pay.currencyUuid !== this.currency.uuid)
+ if (!this.isEmptyValue(currencyUuid)) {
+ requestGetConversionRate({
+ conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
+ currencyFromUuid: this.currency.uuid,
+ currencyToUuid: currencyUuid.currencyUuid
+ })
+ .then(response => {
+ this.isAddTypePay.forEach(element => {
+ if (element.currencyUuid !== this.$store.getters.getCurrentPOS.priceList.currency.uuid) {
+ element.amountConvertion = element.amount / response.divideRate
+ element.currencyConvertion = response.currencyTo
+ } else {
+ element.currencyConvertion = {}
+ }
+ })
+ this.$store.commit('setListPayments', {
+ payments: this.isAddTypePay
+ })
+ })
+ .catch(error => {
+ console.warn(`conversion: ${error.message}. Code: ${error.code}.`)
+ })
+ }
+ this.loginCovertion = true
+ },
getImageFromTenderType(typePay) {
// A: Direct Deposit: ACH Automatic Clearing House
// C: Credit Card:
@@ -209,9 +224,6 @@ export default {
paymentUuid
})
},
- amountConvertion(payment) {
- return payment.amount * this.conevertionAmount.multiplyRate
- },
tenderTypeDisplaye(value) {
if (!this.isEmptyValue(value.reference)) {
const tenderType = value.reference
@@ -222,7 +234,7 @@ export default {
filters: []
})
.then(response => {
- this.$store.dispatch('tenderTypeDisplaye', response)
+ this.labelTypesPayment = response
})
}
}
diff --git a/src/components/ADempiere/Form/VPOS/Options/index.vue b/src/components/ADempiere/Form/VPOS/Options/index.vue
index 9aba30f7..bf9c4f17 100644
--- a/src/components/ADempiere/Form/VPOS/Options/index.vue
+++ b/src/components/ADempiere/Form/VPOS/Options/index.vue
@@ -397,7 +397,9 @@ export default {
}).finally(() => {
const { templateBusinessPartner } = this.$store.getters.getCurrentPOS
// TODO: Set order with POS Terminal default values
- this.$store.commit('setListPayments', [])
+ this.$store.commit('setListPayments', {
+ payments: []
+ })
this.$store.dispatch('setOrder', {
documentType: {},
documentStatus: {
diff --git a/src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js b/src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js
index 49e5d7bc..6ff40f2a 100644
--- a/src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js
+++ b/src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js
@@ -82,7 +82,7 @@ export default [
// isActiveLogics: false,
// isMandatory: true
// }
- // },
+ // }
// // TenderType
// {
// tableName: 'C_Payment',
diff --git a/src/components/ADempiere/Form/VPOS/Order/index.vue b/src/components/ADempiere/Form/VPOS/Order/index.vue
index a72b3417..67e188c0 100644
--- a/src/components/ADempiere/Form/VPOS/Order/index.vue
+++ b/src/components/ADempiere/Form/VPOS/Order/index.vue
@@ -428,27 +428,6 @@ export default {
}
},
watch: {
- currencyUuid(value) {
- if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPoint)) {
- this.$store.dispatch('conversionDivideRate', {
- conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
- currencyFromUuid: this.currencyPoint.uuid,
- currencyToUuid: value
- })
- }
- },
- converCurrency(value) {
- if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPoint)) {
- this.$store.dispatch('conversionMultiplyRate', {
- containerUuid: 'Order',
- conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
- currencyFromUuid: this.currencyPoint.uuid,
- currencyToUuid: value
- })
- } else {
- this.$store.commit('currencyMultiplyRate', 1)
- }
- },
namePo1intOfSales(value) {
if (!this.isEmptyValue(value)) {
this.$router.push({
@@ -463,9 +442,6 @@ export default {
if (!this.isEmptyValue(this.$route.query.action)) {
this.$store.dispatch('reloadOrder', { orderUuid: this.$route.query.action })
}
- // setTimeout(() => {
- // this.currencyDisplaye()
- // }, 1500)
},
methods: {
changePos(posElement) {
@@ -490,7 +466,9 @@ export default {
}
}).catch(() => {
}).finally(() => {
- this.$store.commit('setListPayments', [])
+ this.$store.commit('setListPayments', {
+ payments: []
+ })
const { templateBusinessPartner } = this.currentPoint
this.$store.commit('updateValuesOfContainer', {
containerUuid: this.metadata.containerUuid,
@@ -535,34 +513,6 @@ export default {
if (!this.seeConversion) {
this.seeConversion = true
}
- // },
- // tenderTypeDisplaye() {
- // if (!this.isEmptyValue(this.fieldsList)) {
- // const tenderType = this.fieldsList[5].reference
- // if (!this.isEmptyValue(tenderType)) {
- // this.$store.dispatch('getLookupListFromServer', {
- // tableName: tenderType.tableName,
- // query: tenderType.query
- // })
- // .then(response => {
- // this.$store.dispatch('tenderTypeDisplaye', response)
- // })
- // }
- // }
- // },
- // currencyDisplaye() {
- // if (!this.isEmptyValue(this.fieldsList)) {
- // const currency = this.fieldsList[4].reference
- // if (!this.isEmptyValue(currency)) {
- // this.$store.dispatch('getLookupListFromServer', {
- // tableName: currency.tableName,
- // query: currency.query
- // })
- // .then(response => {
- // this.$store.dispatch('currencyDisplaye', response)
- // })
- // }
- // }
}
}
}
diff --git a/src/store/modules/ADempiere/pointOfSales/payments/actions.js b/src/store/modules/ADempiere/pointOfSales/payments/actions.js
index e062f22d..cb3ed6ff 100644
--- a/src/store/modules/ADempiere/pointOfSales/payments/actions.js
+++ b/src/store/modules/ADempiere/pointOfSales/payments/actions.js
@@ -103,11 +103,12 @@ export default {
currencyToUuid: params.currencyToUuid
})
.then(response => {
+ commit('setFieldCurrency', response.currencyTo)
const divideRate = isEmptyValue(response.divideRate) ? 1 : response.divideRate
if (params.containerUuid === 'Collection') {
commit('currencyDivideRateCollection', divideRate)
} else {
- commit('currencyDivideRate', divideRate)
+ commit('currencyDivideRateCollection', divideRate)
}
})
.catch(error => {
@@ -167,7 +168,7 @@ export default {
tenderTypeCode,
currencyUuid
}) {
- const listPayments = getters.getListPayments.find(payment => {
+ const listPayments = getters.getListPayments.payments.find(payment => {
if ((payment.tenderTypeCode === tenderTypeCode) && (payment.tenderTypeCode === 'X') && (currencyUuid === payment.currencyUuid)) {
return payment
}
@@ -248,7 +249,10 @@ export default {
orderUuid
})
.then(response => {
- commit('setListPayments', response.listPayments)
+ commit('setListPayments', {
+ payments: response.listPayments.reverse(),
+ isLoaded: true
+ })
})
.catch(error => {
console.warn(`ListPaymentsFromServer: ${error.message}. Code: ${error.code}.`)
@@ -257,15 +261,6 @@ export default {
dispatch('updatePaymentPos', false)
})
},
- tenderTypeDisplaye({ commit }, tenderType) {
- const displayTenderType = tenderType.map(item => {
- return {
- tenderTypeCode: item.id,
- tenderTypeDisplay: item.label
- }
- })
- commit('setTenderTypeDisplaye', displayTenderType)
- },
currencyDisplaye({ commit }, currency) {
const displaycurrency = currency.map(item => {
return {
diff --git a/src/store/modules/ADempiere/pointOfSales/payments/getters.js b/src/store/modules/ADempiere/pointOfSales/payments/getters.js
index 45e7d036..bbc651a2 100644
--- a/src/store/modules/ADempiere/pointOfSales/payments/getters.js
+++ b/src/store/modules/ADempiere/pointOfSales/payments/getters.js
@@ -22,13 +22,13 @@ export default {
getListPayments: (state) => {
return state.listPayments
},
- getListsPaymentTypes: (state) => {
- return state.tenderTypeDisplaye
- },
getListCurrency: (state) => {
return state.currency
},
getConvertionPayment: (state) => {
return state.convertion
+ },
+ getFieldCuerrency: (state) => {
+ return state.fieldCurrency
}
}
diff --git a/src/store/modules/ADempiere/pointOfSales/payments/mutations.js b/src/store/modules/ADempiere/pointOfSales/payments/mutations.js
index 870e0d1c..215f9c4e 100644
--- a/src/store/modules/ADempiere/pointOfSales/payments/mutations.js
+++ b/src/store/modules/ADempiere/pointOfSales/payments/mutations.js
@@ -22,13 +22,13 @@ export default {
setListPayments(state, list) {
state.listPayments = list
},
- setTenderTypeDisplaye(state, tenderTypeDisplaye) {
- state.tenderTypeDisplaye = tenderTypeDisplaye
- },
setCurrencyDisplaye(state, currency) {
state.currency = currency
},
setConvertionPayment(state, convertion) {
state.convertion = convertion
+ },
+ setFieldCurrency(state, currency) {
+ state.fieldCurrency = currency
}
}
diff --git a/src/store/modules/ADempiere/pointOfSales/payments/state.js b/src/store/modules/ADempiere/pointOfSales/payments/state.js
index cb96ac00..117e8bfd 100644
--- a/src/store/modules/ADempiere/pointOfSales/payments/state.js
+++ b/src/store/modules/ADempiere/pointOfSales/payments/state.js
@@ -8,13 +8,11 @@ export default {
divideRate: 1,
multiplyRateCollection: 1,
divideRateCollection: 1,
- listPayments: [],
- tenderTypeDisplaye: [
- {
- tenderTypeCode: 0,
- tenderTypeDisplay: ''
- }
- ],
+ listPayments: {
+ payments: [],
+ isLoaded: false
+ },
currency: [],
- convertion: {}
+ convertion: {},
+ fieldCurrency: {}
}
diff --git a/src/utils/ADempiere/valueUtils.js b/src/utils/ADempiere/valueUtils.js
index b69c34b7..373e2007 100644
--- a/src/utils/ADempiere/valueUtils.js
+++ b/src/utils/ADempiere/valueUtils.js
@@ -534,12 +534,12 @@ export function tenderTypeFind({
listTypePayment
}) {
const payment = listTypePayment.find(item => {
- if (item.tenderTypeCode === currentPayment) {
- return item.tenderTypeDisplay
+ if (item.id === currentPayment) {
+ return item.label
}
})
if (payment) {
- return payment.tenderTypeDisplay
+ return payment.label
}
return currentPayment
}