1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 20:39:48 +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
},
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() {

View File

@ -73,7 +73,10 @@
<el-col v-for="(field, index) in fieldsList" :key="index" :span="8">
<field-definition
: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-row>
@ -93,6 +96,7 @@
:is-add-type-pay="listPayments"
:currency="currencyPoint"
:list-types-payment="fieldsList[2]"
:is-loaded="isLoadedPayments"
/>
<div
v-else
@ -282,10 +286,13 @@ export default {
const listLocal = this.$store.getters.getPaymentBox
const listServer = this.$store.getters.getPos.listPayments
if (!this.sendToServer) {
return listServer.reverse()
return listServer.payments
}
return listLocal
},
isLoadedPayments() {
return this.$store.getters.getPos.listPayments.isLoaded
},
paymentBox() {
const payment = this.listPayments.filter(pay => {
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

View File

@ -39,7 +39,7 @@
{{
tenderTypeFind({
currentPayment: value.tenderTypeCode,
listTypePayment: typesPayment
listTypePayment: labelTypesPayment
})
}}
</span>
@ -62,11 +62,7 @@
{{ formatDate(value.paymentDate) }}
</el-button>
<div
v-if="currencyFind({
currencyCurrent: value.currencyUuid,
listCurrency: listCurrency,
defaultCurrency: currency
}).currencyDisplay !== currency.iSOCode"
v-if="loginCovertion"
slot="header"
class="clearfix"
style="padding-bottom: 20px;"
@ -77,25 +73,9 @@
</b>
</p>
<br>
<p class="total">
<p v-if="!isEmptyValue(value.currencyConvertion)" class="total">
<b style="float: right;">
{{
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) }}
{{ formatPrice(value.amountConvertion, value.currencyConvertion.iSOCode) }}
</b>
</p>
</div>
@ -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
})
}
}

View File

@ -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: {

View File

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

View File

@ -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)
// })
// }
// }
}
}
}

View File

@ -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 {

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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: {}
}

View File

@ -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
}