1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-12 22:29:59 +08:00

get the currency code to be paid (#750)

* Fixes: #736

* get the currency code to be paid

* add the correct currency symbol in the amount field

Co-authored-by: Elsio Sanchez <elsiosanche@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-04-21 12:15:15 -04:00 committed by GitHub
parent 599cfa9844
commit 6b27db091d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 106 additions and 157 deletions

View File

@ -160,6 +160,12 @@ export default {
return this.$store.getters.getCountryLanguage return this.$store.getters.getCountryLanguage
}, },
currencyCode() { 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 return this.currencyDefinition.iSOCode
}, },
currencyDefinition() { currencyDefinition() {

View File

@ -73,7 +73,10 @@
<el-col v-for="(field, index) in fieldsList" :key="index" :span="8"> <el-col v-for="(field, index) in fieldsList" :key="index" :span="8">
<field-definition <field-definition
:key="field.columnName" :key="field.columnName"
:metadata-field="field" :metadata-field="field.columnName === 'PayAmt' ? {
...field,
labelCurrency: isEmptyValue($store.getters.getFieldCuerrency) ? currencyPoint : $store.getters.getFieldCuerrency
} : field"
/> />
</el-col> </el-col>
</el-row> </el-row>
@ -93,6 +96,7 @@
:is-add-type-pay="listPayments" :is-add-type-pay="listPayments"
:currency="currencyPoint" :currency="currencyPoint"
:list-types-payment="fieldsList[2]" :list-types-payment="fieldsList[2]"
:is-loaded="isLoadedPayments"
/> />
<div <div
v-else v-else
@ -282,10 +286,13 @@ export default {
const listLocal = this.$store.getters.getPaymentBox const listLocal = this.$store.getters.getPaymentBox
const listServer = this.$store.getters.getPos.listPayments const listServer = this.$store.getters.getPos.listPayments
if (!this.sendToServer) { if (!this.sendToServer) {
return listServer.reverse() return listServer.payments
} }
return listLocal return listLocal
}, },
isLoadedPayments() {
return this.$store.getters.getPos.listPayments.isLoaded
},
paymentBox() { paymentBox() {
const payment = this.listPayments.filter(pay => { const payment = this.listPayments.filter(pay => {
return pay.isVisible return pay.isVisible
@ -373,7 +380,10 @@ export default {
return missing return missing
} }
const pending = this.currentOrder.grandTotal <= this.pay ? 0 : this.currentOrder.grandTotal const pending = this.currentOrder.grandTotal <= this.pay ? 0 : this.currentOrder.grandTotal
return pending return pending / this.convertion
},
convertion() {
return this.$store.getters.getDivideRateCollection
}, },
isMandatory() { isMandatory() {
const containerUuid = this.containerUuid const containerUuid = this.containerUuid
@ -508,15 +518,14 @@ export default {
currencyToUuid: value currencyToUuid: value
}) })
} }
if (!this.isEmptyValue(value)) { if (this.isEmptyValue(value)) {
this.$store.dispatch('conversionMultiplyRate', { this.$store.commit('setFieldCurrency', this.currencyPoint)
this.$store.dispatch('conversionDivideRate', {
containerUuid: 'Collection', containerUuid: 'Collection',
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid, currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value currencyToUuid: value
}) })
} else {
this.$store.commit('currencyMultiplyRateCollection', 1)
} }
}, },
convertAllPayment(value) { convertAllPayment(value) {
@ -525,18 +534,6 @@ export default {
} }
this.allPayCurrency = this.pay 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) { isLoaded(value) {
if (value) { if (value) {
this.$store.commit('updateValueOfField', { this.$store.commit('updateValueOfField', {
@ -551,19 +548,16 @@ export default {
this.unsubscribe = this.subscribeChanges() this.unsubscribe = this.subscribeChanges()
this.defaultValueCurrency() this.defaultValueCurrency()
}, },
mounted() {
setTimeout(() => {
this.convertCurrency()
}, 2000)
},
methods: { methods: {
formatDate, formatDate,
formatPrice, formatPrice,
sumCash(cash) { sumCash(cash) {
let sum = 0 let sum = 0
cash.forEach((pay) => { if (cash) {
sum += pay.amount cash.forEach((pay) => {
}) sum += pay.amount
})
}
return sum return sum
}, },
notSubmitForm(event) { notSubmitForm(event) {
@ -612,7 +606,7 @@ export default {
orderUuid, orderUuid,
bankUuid, bankUuid,
referenceNo, referenceNo,
amount: this.amontSend, amount: this.amontSend * this.convertion,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid currencyUuid
@ -623,7 +617,7 @@ export default {
orderUuid, orderUuid,
bankUuid, bankUuid,
referenceNo, referenceNo,
amount: this.amontSend, amount: this.amontSend * this.convertion,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid: this.currencyDisplay(currencyToPay) currencyUuid: this.currencyDisplay(currencyToPay)
@ -669,7 +663,7 @@ export default {
}) })
}) })
this.defaultValueCurrency() this.defaultValueCurrency()
this.$store.dispatch('conversionDivideRate', 1) this.$store.commit('currencyDivideRateCollection', 1)
this.$store.commit('currencyMultiplyRate', 1) this.$store.commit('currencyMultiplyRate', 1)
this.cancel() this.cancel()
}, },
@ -697,7 +691,7 @@ export default {
value: this.pending value: this.pending
}) })
this.defaultValueCurrency() this.defaultValueCurrency()
this.$store.dispatch('conversionDivideRate', 1) this.$store.commit('currencyDivideRateCollection', 1)
this.$store.commit('currencyMultiplyRate', 1) this.$store.commit('currencyMultiplyRate', 1)
}, },
exit() { exit() {
@ -764,14 +758,6 @@ export default {
} }
return currency 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() { undoPatment() {
const list = this.listPayments[this.listPayments.length - 1] const list = this.listPayments[this.listPayments.length - 1]
const orderUuid = list.orderUuid const orderUuid = list.orderUuid

View File

@ -39,7 +39,7 @@
{{ {{
tenderTypeFind({ tenderTypeFind({
currentPayment: value.tenderTypeCode, currentPayment: value.tenderTypeCode,
listTypePayment: typesPayment listTypePayment: labelTypesPayment
}) })
}} }}
</span> </span>
@ -62,11 +62,7 @@
{{ formatDate(value.paymentDate) }} {{ formatDate(value.paymentDate) }}
</el-button> </el-button>
<div <div
v-if="currencyFind({ v-if="loginCovertion"
currencyCurrent: value.currencyUuid,
listCurrency: listCurrency,
defaultCurrency: currency
}).currencyDisplay !== currency.iSOCode"
slot="header" slot="header"
class="clearfix" class="clearfix"
style="padding-bottom: 20px;" style="padding-bottom: 20px;"
@ -77,25 +73,9 @@
</b> </b>
</p> </p>
<br> <br>
<p class="total"> <p v-if="!isEmptyValue(value.currencyConvertion)" class="total">
<b style="float: right;"> <b style="float: right;">
{{ {{ formatPrice(value.amountConvertion, value.currencyConvertion.iSOCode) }}
formatPrice(
(amountConvertion(value)),
currencyFind({
currencyCurrent: value.currencyUuid,
listCurrency: listCurrency,
defaultCurrency: currency
}).currencyDisplay
)
}}
</b>
</p>
</div>
<div v-else slot="header" class="clearfix">
<p class="total">
<b style="float: right;padding-top: 18px;padding-bottom: 20px;">
{{ formatPrice(value.amount, currency.iSOCode) }}
</b> </b>
</p> </p>
</div> </div>
@ -116,6 +96,9 @@ import {
formatDate, formatDate,
formatPrice formatPrice
} from '@/utils/ADempiere/valueFormat.js' } from '@/utils/ADempiere/valueFormat.js'
import {
requestGetConversionRate
} from '@/api/ADempiere/form/point-of-sales.js'
export default { export default {
name: 'TypeCollection', name: 'TypeCollection',
@ -131,11 +114,17 @@ export default {
listTypesPayment: { listTypesPayment: {
type: Object, type: Object,
default: undefined default: undefined
},
isLoaded: {
type: Boolean,
default: false
} }
}, },
data() { data() {
return { return {
conevertion: 0 conevertion: 0,
loginCovertion: false,
labelTypesPayment: []
} }
}, },
computed: { computed: {
@ -149,16 +138,42 @@ export default {
return this.$store.getters.getConvertionPayment return this.$store.getters.getConvertionPayment
} }
}, },
watch: { created() {
listTypesPayment(value) { this.convertingPaymentMethods()
if (!this.isEmptyValue(value) && this.typesPayment.length <= 1) { if (this.isEmptyValue(this.labelTypesPayment)) {
this.tenderTypeDisplaye(value) this.tenderTypeDisplaye(this.listTypesPayment)
}
} }
}, },
methods: { methods: {
formatDate, formatDate,
formatPrice, 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) { getImageFromTenderType(typePay) {
// A: Direct Deposit: ACH Automatic Clearing House // A: Direct Deposit: ACH Automatic Clearing House
// C: Credit Card: // C: Credit Card:
@ -209,9 +224,6 @@ export default {
paymentUuid paymentUuid
}) })
}, },
amountConvertion(payment) {
return payment.amount * this.conevertionAmount.multiplyRate
},
tenderTypeDisplaye(value) { tenderTypeDisplaye(value) {
if (!this.isEmptyValue(value.reference)) { if (!this.isEmptyValue(value.reference)) {
const tenderType = value.reference const tenderType = value.reference
@ -222,7 +234,7 @@ export default {
filters: [] filters: []
}) })
.then(response => { .then(response => {
this.$store.dispatch('tenderTypeDisplaye', response) this.labelTypesPayment = response
}) })
} }
} }

View File

@ -397,7 +397,9 @@ export default {
}).finally(() => { }).finally(() => {
const { templateBusinessPartner } = this.$store.getters.getCurrentPOS const { templateBusinessPartner } = this.$store.getters.getCurrentPOS
// TODO: Set order with POS Terminal default values // TODO: Set order with POS Terminal default values
this.$store.commit('setListPayments', []) this.$store.commit('setListPayments', {
payments: []
})
this.$store.dispatch('setOrder', { this.$store.dispatch('setOrder', {
documentType: {}, documentType: {},
documentStatus: { documentStatus: {

View File

@ -82,7 +82,7 @@ export default [
// isActiveLogics: false, // isActiveLogics: false,
// isMandatory: true // isMandatory: true
// } // }
// }, // }
// // TenderType // // TenderType
// { // {
// tableName: 'C_Payment', // tableName: 'C_Payment',

View File

@ -428,27 +428,6 @@ export default {
} }
}, },
watch: { 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) { namePo1intOfSales(value) {
if (!this.isEmptyValue(value)) { if (!this.isEmptyValue(value)) {
this.$router.push({ this.$router.push({
@ -463,9 +442,6 @@ export default {
if (!this.isEmptyValue(this.$route.query.action)) { if (!this.isEmptyValue(this.$route.query.action)) {
this.$store.dispatch('reloadOrder', { orderUuid: this.$route.query.action }) this.$store.dispatch('reloadOrder', { orderUuid: this.$route.query.action })
} }
// setTimeout(() => {
// this.currencyDisplaye()
// }, 1500)
}, },
methods: { methods: {
changePos(posElement) { changePos(posElement) {
@ -490,7 +466,9 @@ export default {
} }
}).catch(() => { }).catch(() => {
}).finally(() => { }).finally(() => {
this.$store.commit('setListPayments', []) this.$store.commit('setListPayments', {
payments: []
})
const { templateBusinessPartner } = this.currentPoint const { templateBusinessPartner } = this.currentPoint
this.$store.commit('updateValuesOfContainer', { this.$store.commit('updateValuesOfContainer', {
containerUuid: this.metadata.containerUuid, containerUuid: this.metadata.containerUuid,
@ -535,34 +513,6 @@ export default {
if (!this.seeConversion) { if (!this.seeConversion) {
this.seeConversion = true 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)
// })
// }
// }
} }
} }
} }

View File

@ -103,11 +103,12 @@ export default {
currencyToUuid: params.currencyToUuid currencyToUuid: params.currencyToUuid
}) })
.then(response => { .then(response => {
commit('setFieldCurrency', response.currencyTo)
const divideRate = isEmptyValue(response.divideRate) ? 1 : response.divideRate const divideRate = isEmptyValue(response.divideRate) ? 1 : response.divideRate
if (params.containerUuid === 'Collection') { if (params.containerUuid === 'Collection') {
commit('currencyDivideRateCollection', divideRate) commit('currencyDivideRateCollection', divideRate)
} else { } else {
commit('currencyDivideRate', divideRate) commit('currencyDivideRateCollection', divideRate)
} }
}) })
.catch(error => { .catch(error => {
@ -167,7 +168,7 @@ export default {
tenderTypeCode, tenderTypeCode,
currencyUuid currencyUuid
}) { }) {
const listPayments = getters.getListPayments.find(payment => { const listPayments = getters.getListPayments.payments.find(payment => {
if ((payment.tenderTypeCode === tenderTypeCode) && (payment.tenderTypeCode === 'X') && (currencyUuid === payment.currencyUuid)) { if ((payment.tenderTypeCode === tenderTypeCode) && (payment.tenderTypeCode === 'X') && (currencyUuid === payment.currencyUuid)) {
return payment return payment
} }
@ -248,7 +249,10 @@ export default {
orderUuid orderUuid
}) })
.then(response => { .then(response => {
commit('setListPayments', response.listPayments) commit('setListPayments', {
payments: response.listPayments.reverse(),
isLoaded: true
})
}) })
.catch(error => { .catch(error => {
console.warn(`ListPaymentsFromServer: ${error.message}. Code: ${error.code}.`) console.warn(`ListPaymentsFromServer: ${error.message}. Code: ${error.code}.`)
@ -257,15 +261,6 @@ export default {
dispatch('updatePaymentPos', false) dispatch('updatePaymentPos', false)
}) })
}, },
tenderTypeDisplaye({ commit }, tenderType) {
const displayTenderType = tenderType.map(item => {
return {
tenderTypeCode: item.id,
tenderTypeDisplay: item.label
}
})
commit('setTenderTypeDisplaye', displayTenderType)
},
currencyDisplaye({ commit }, currency) { currencyDisplaye({ commit }, currency) {
const displaycurrency = currency.map(item => { const displaycurrency = currency.map(item => {
return { return {

View File

@ -22,13 +22,13 @@ export default {
getListPayments: (state) => { getListPayments: (state) => {
return state.listPayments return state.listPayments
}, },
getListsPaymentTypes: (state) => {
return state.tenderTypeDisplaye
},
getListCurrency: (state) => { getListCurrency: (state) => {
return state.currency return state.currency
}, },
getConvertionPayment: (state) => { getConvertionPayment: (state) => {
return state.convertion return state.convertion
},
getFieldCuerrency: (state) => {
return state.fieldCurrency
} }
} }

View File

@ -22,13 +22,13 @@ export default {
setListPayments(state, list) { setListPayments(state, list) {
state.listPayments = list state.listPayments = list
}, },
setTenderTypeDisplaye(state, tenderTypeDisplaye) {
state.tenderTypeDisplaye = tenderTypeDisplaye
},
setCurrencyDisplaye(state, currency) { setCurrencyDisplaye(state, currency) {
state.currency = currency state.currency = currency
}, },
setConvertionPayment(state, convertion) { setConvertionPayment(state, convertion) {
state.convertion = convertion state.convertion = convertion
},
setFieldCurrency(state, currency) {
state.fieldCurrency = currency
} }
} }

View File

@ -8,13 +8,11 @@ export default {
divideRate: 1, divideRate: 1,
multiplyRateCollection: 1, multiplyRateCollection: 1,
divideRateCollection: 1, divideRateCollection: 1,
listPayments: [], listPayments: {
tenderTypeDisplaye: [ payments: [],
{ isLoaded: false
tenderTypeCode: 0, },
tenderTypeDisplay: ''
}
],
currency: [], currency: [],
convertion: {} convertion: {},
fieldCurrency: {}
} }

View File

@ -534,12 +534,12 @@ export function tenderTypeFind({
listTypePayment listTypePayment
}) { }) {
const payment = listTypePayment.find(item => { const payment = listTypePayment.find(item => {
if (item.tenderTypeCode === currentPayment) { if (item.id === currentPayment) {
return item.tenderTypeDisplay return item.label
} }
}) })
if (payment) { if (payment) {
return payment.tenderTypeDisplay return payment.label
} }
return currentPayment return currentPayment
} }