1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 12:01:57 +08:00

Amount converted to payment (#1066)

* Correcting total amount converted in the payment

* minimal changes

* delete console

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-08-16 17:45:57 -04:00 committed by GitHub
parent e98a111e37
commit a6197f67b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 10 deletions

View File

@ -633,6 +633,19 @@ export default {
query: value.reference.query query: value.reference.query
}) })
} }
},
listPayments(payment) {
if (!this.isEmptyValue(this.convertionsList)) {
let rate
payment.forEach((pay) => {
rate = this.convertionsList.find(currency => currency.currencyTo.uuid === pay.currencyUuid)
if (!rate) {
if (this.currentPointOfSales.priceList.currency.uuid !== pay.currencyUuid) {
this.searchConversion(pay.currencyUuid)
}
}
})
}
} }
}, },
created() { created() {
@ -662,8 +675,9 @@ export default {
let sum = 0 let sum = 0
if (cash) { if (cash) {
cash.forEach((pay) => { cash.forEach((pay) => {
const amount = this.convertAmount(pay.currencyUuid)
if (!this.isEmptyValue(pay.divideRate)) { if (!this.isEmptyValue(pay.divideRate)) {
sum += pay.amountConvertion / pay.divideRate sum += amount * pay.amount
} else { } else {
sum += pay.amount sum += pay.amount
} }
@ -671,6 +685,18 @@ export default {
} }
return sum return sum
}, },
convertAmount(currencyUuid) {
const currencyPay = this.convertionsList.find(currency => {
if (!this.isEmptyValue(currency.currencyTo) && currency.currencyTo.uuid === currencyUuid) {
return currency
}
})
if (!currencyPay) {
return 0
}
const rate = (currencyPay.divideRate > currencyPay.multiplyRate) ? currencyPay.divideRate : currencyPay.multiplyRate
return rate
},
notSubmitForm(event) { notSubmitForm(event) {
event.preventDefault() event.preventDefault()
return false return false
@ -699,14 +725,14 @@ export default {
containerUuid, containerUuid,
columnName: 'ReferenceNo' columnName: 'ReferenceNo'
}) })
this.amontSend = this.dayRate.divideRate * this.amontSend
if (this.sendToServer) { if (this.sendToServer) {
this.$store.dispatch('setPaymentBox', { this.$store.dispatch('setPaymentBox', {
posUuid, posUuid,
orderUuid, orderUuid,
bankUuid, bankUuid,
referenceNo, referenceNo,
amount: this.amontSend * this.convertion, amount: this.amontSend,
convertedAmount: this.amontSend * this.dayRate.divideRate,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid: this.dayRate.currencyTo.uuid currencyUuid: this.dayRate.currencyTo.uuid
@ -717,7 +743,8 @@ export default {
orderUuid, orderUuid,
bankUuid, bankUuid,
referenceNo, referenceNo,
amount: this.amontSend * this.convertion, amount: this.amontSend,
convertedAmount: this.amontSend * this.dayRate.divideRate,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid: this.dayRate.currencyTo.uuid currencyUuid: this.dayRate.currencyTo.uuid
@ -795,6 +822,7 @@ export default {
this.currentFieldCurrency = this.pointOfSalesCurrency.iSOCode this.currentFieldCurrency = this.pointOfSalesCurrency.iSOCode
}, },
exit() { exit() {
this.cancel()
this.$store.commit('setShowPOSCollection', false) this.$store.commit('setShowPOSCollection', false)
}, },
getPriceApplyingDiscount(price, discount) { getPriceApplyingDiscount(price, discount) {
@ -948,6 +976,13 @@ export default {
if (!this.isEmptyValue(currency) && this.isEmptyValue(convert) && currency.uuid !== this.currentPointOfSales.currentPriceList.currency.uuid) { if (!this.isEmptyValue(currency) && this.isEmptyValue(convert) && currency.uuid !== this.currentPointOfSales.currentPriceList.currency.uuid) {
this.amountConvert(currency) this.amountConvert(currency)
} }
},
searchConversion(value) {
this.$store.dispatch('searchConversion', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid,
currencyToUuid: value
})
} }
} }
} }

View File

@ -62,20 +62,19 @@
{{ formatDate(value.paymentDate) }} {{ formatDate(value.paymentDate) }}
</el-button> </el-button>
<div <div
v-if="loginCovertion"
slot="header" slot="header"
class="clearfix" class="clearfix"
style="padding-bottom: 20px;" style="padding-bottom: 20px;"
> >
<p class="total"> <p v-if="!isEmptyValue(value.currencyConvertion)" class="total">
<b style="float: right;"> <b style="float: right;">
{{ formatPrice(value.amount, currency.iSOCode) }} {{ amountConvertion(value) }}
</b> </b>
</p> </p>
<br> <br>
<p v-if="!isEmptyValue(value.currencyConvertion)" class="total"> <p class="total">
<b style="float: right;"> <b style="float: right;">
{{ formatPrice(value.amountConvertion, value.currencyConvertion.iSOCode) }} {{ formatPrice(value.amount, iSOCode(value)) }}
</b> </b>
</p> </p>
</div> </div>
@ -155,6 +154,9 @@ export default {
// Validate if there is a payment in a different type of currency to the point // Validate if there is a payment in a different type of currency to the point
paymentCurrency() { paymentCurrency() {
return this.currentPointOfSales.currentOrder.listPayments.payments.find(pay => pay.currencyUuid !== this.currency.uuid) return this.currentPointOfSales.currentOrder.listPayments.payments.find(pay => pay.currencyUuid !== this.currency.uuid)
},
convertionsList() {
return this.$store.state['pointOfSales/point/index'].conversionsList
} }
}, },
watch: { watch: {
@ -181,6 +183,26 @@ export default {
methods: { methods: {
formatDate, formatDate,
formatPrice, formatPrice,
iSOCode(value) {
const currencyPay = this.convertionsList.find(currency => currency.currencyTo.uuid === value.currencyUuid)
if (!currencyPay) {
return ''
}
return currencyPay.currencyTo.iSOCode
},
amountConvertion(value) {
const currencyPay = this.convertionsList.find(currency => currency.currencyTo.uuid === value.currencyUuid)
if (!currencyPay) {
this.$store.dispatch('searchConversion', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.currency.uuid,
currencyToUuid: value.currencyUuid
})
return this.formatPrice(0)
}
const rate = (currencyPay.divideRate > currencyPay.multiplyRate) ? currencyPay.divideRate : currencyPay.multiplyRate
return this.formatPrice(value.amount * rate, this.currency.iSOCode)
},
// If there are payments in another currency, search for conversion // If there are payments in another currency, search for conversion
convertingPaymentMethods() { convertingPaymentMethods() {
if (!this.isEmptyValue(this.paymentCurrency)) { if (!this.isEmptyValue(this.paymentCurrency)) {
@ -193,7 +215,7 @@ export default {
this.$store.getters.posAttributes.currentPointOfSales.currentOrder.listPayments.payments.forEach(element => { this.$store.getters.posAttributes.currentPointOfSales.currentOrder.listPayments.payments.forEach(element => {
if (element.currencyUuid !== this.pointOfSalesCurrency.uuid) { if (element.currencyUuid !== this.pointOfSalesCurrency.uuid) {
element.multiplyRate = element.amount / response.multiplyRate element.multiplyRate = element.amount / response.multiplyRate
element.amountConvertion = element.amount / response.divideRate element.amountConvertion = element.amount * response.divideRate
element.divideRate = response.multiplyRate element.divideRate = response.multiplyRate
element.currencyConvertion = response.currencyTo element.currencyConvertion = response.currencyTo
} }

View File

@ -559,6 +559,7 @@ export default {
columnName: 'C_Order_ID', columnName: 'C_Order_ID',
value: this.currentOrder.id value: this.currentOrder.id
}] }]
this.$store.commit('setShowPOSCollection', false)
this.$store.dispatch('addParametersProcessPos', parametersList) this.$store.dispatch('addParametersProcessPos', parametersList)
createOrder({ createOrder({
posUuid, posUuid,

View File

@ -37,6 +37,7 @@ export default {
referenceNo, referenceNo,
description, description,
amount, amount,
convertedAmount,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid currencyUuid
@ -53,6 +54,7 @@ export default {
referenceNo, referenceNo,
description, description,
amount, amount,
convertedAmount,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid currencyUuid
@ -185,6 +187,7 @@ export default {
referenceNo, referenceNo,
description, description,
amount, amount,
convertedAmount,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid currencyUuid
@ -204,6 +207,7 @@ export default {
referenceNo, referenceNo,
description, description,
amount, amount,
convertedAmount,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid currencyUuid