mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-07 18:25:45 +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:
parent
e98a111e37
commit
a6197f67b2
@ -633,6 +633,19 @@ export default {
|
||||
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() {
|
||||
@ -662,8 +675,9 @@ export default {
|
||||
let sum = 0
|
||||
if (cash) {
|
||||
cash.forEach((pay) => {
|
||||
const amount = this.convertAmount(pay.currencyUuid)
|
||||
if (!this.isEmptyValue(pay.divideRate)) {
|
||||
sum += pay.amountConvertion / pay.divideRate
|
||||
sum += amount * pay.amount
|
||||
} else {
|
||||
sum += pay.amount
|
||||
}
|
||||
@ -671,6 +685,18 @@ export default {
|
||||
}
|
||||
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) {
|
||||
event.preventDefault()
|
||||
return false
|
||||
@ -699,14 +725,14 @@ export default {
|
||||
containerUuid,
|
||||
columnName: 'ReferenceNo'
|
||||
})
|
||||
this.amontSend = this.dayRate.divideRate * this.amontSend
|
||||
if (this.sendToServer) {
|
||||
this.$store.dispatch('setPaymentBox', {
|
||||
posUuid,
|
||||
orderUuid,
|
||||
bankUuid,
|
||||
referenceNo,
|
||||
amount: this.amontSend * this.convertion,
|
||||
amount: this.amontSend,
|
||||
convertedAmount: this.amontSend * this.dayRate.divideRate,
|
||||
paymentDate,
|
||||
tenderTypeCode,
|
||||
currencyUuid: this.dayRate.currencyTo.uuid
|
||||
@ -717,7 +743,8 @@ export default {
|
||||
orderUuid,
|
||||
bankUuid,
|
||||
referenceNo,
|
||||
amount: this.amontSend * this.convertion,
|
||||
amount: this.amontSend,
|
||||
convertedAmount: this.amontSend * this.dayRate.divideRate,
|
||||
paymentDate,
|
||||
tenderTypeCode,
|
||||
currencyUuid: this.dayRate.currencyTo.uuid
|
||||
@ -795,6 +822,7 @@ export default {
|
||||
this.currentFieldCurrency = this.pointOfSalesCurrency.iSOCode
|
||||
},
|
||||
exit() {
|
||||
this.cancel()
|
||||
this.$store.commit('setShowPOSCollection', false)
|
||||
},
|
||||
getPriceApplyingDiscount(price, discount) {
|
||||
@ -948,6 +976,13 @@ export default {
|
||||
if (!this.isEmptyValue(currency) && this.isEmptyValue(convert) && currency.uuid !== this.currentPointOfSales.currentPriceList.currency.uuid) {
|
||||
this.amountConvert(currency)
|
||||
}
|
||||
},
|
||||
searchConversion(value) {
|
||||
this.$store.dispatch('searchConversion', {
|
||||
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
|
||||
currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid,
|
||||
currencyToUuid: value
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,20 +62,19 @@
|
||||
{{ formatDate(value.paymentDate) }}
|
||||
</el-button>
|
||||
<div
|
||||
v-if="loginCovertion"
|
||||
slot="header"
|
||||
class="clearfix"
|
||||
style="padding-bottom: 20px;"
|
||||
>
|
||||
<p class="total">
|
||||
<p v-if="!isEmptyValue(value.currencyConvertion)" class="total">
|
||||
<b style="float: right;">
|
||||
{{ formatPrice(value.amount, currency.iSOCode) }}
|
||||
{{ amountConvertion(value) }}
|
||||
</b>
|
||||
</p>
|
||||
<br>
|
||||
<p v-if="!isEmptyValue(value.currencyConvertion)" class="total">
|
||||
<p class="total">
|
||||
<b style="float: right;">
|
||||
{{ formatPrice(value.amountConvertion, value.currencyConvertion.iSOCode) }}
|
||||
{{ formatPrice(value.amount, iSOCode(value)) }}
|
||||
</b>
|
||||
</p>
|
||||
</div>
|
||||
@ -155,6 +154,9 @@ export default {
|
||||
// Validate if there is a payment in a different type of currency to the point
|
||||
paymentCurrency() {
|
||||
return this.currentPointOfSales.currentOrder.listPayments.payments.find(pay => pay.currencyUuid !== this.currency.uuid)
|
||||
},
|
||||
convertionsList() {
|
||||
return this.$store.state['pointOfSales/point/index'].conversionsList
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -181,6 +183,26 @@ export default {
|
||||
methods: {
|
||||
formatDate,
|
||||
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
|
||||
convertingPaymentMethods() {
|
||||
if (!this.isEmptyValue(this.paymentCurrency)) {
|
||||
@ -193,7 +215,7 @@ export default {
|
||||
this.$store.getters.posAttributes.currentPointOfSales.currentOrder.listPayments.payments.forEach(element => {
|
||||
if (element.currencyUuid !== this.pointOfSalesCurrency.uuid) {
|
||||
element.multiplyRate = element.amount / response.multiplyRate
|
||||
element.amountConvertion = element.amount / response.divideRate
|
||||
element.amountConvertion = element.amount * response.divideRate
|
||||
element.divideRate = response.multiplyRate
|
||||
element.currencyConvertion = response.currencyTo
|
||||
}
|
||||
|
@ -559,6 +559,7 @@ export default {
|
||||
columnName: 'C_Order_ID',
|
||||
value: this.currentOrder.id
|
||||
}]
|
||||
this.$store.commit('setShowPOSCollection', false)
|
||||
this.$store.dispatch('addParametersProcessPos', parametersList)
|
||||
createOrder({
|
||||
posUuid,
|
||||
|
@ -37,6 +37,7 @@ export default {
|
||||
referenceNo,
|
||||
description,
|
||||
amount,
|
||||
convertedAmount,
|
||||
paymentDate,
|
||||
tenderTypeCode,
|
||||
currencyUuid
|
||||
@ -53,6 +54,7 @@ export default {
|
||||
referenceNo,
|
||||
description,
|
||||
amount,
|
||||
convertedAmount,
|
||||
paymentDate,
|
||||
tenderTypeCode,
|
||||
currencyUuid
|
||||
@ -185,6 +187,7 @@ export default {
|
||||
referenceNo,
|
||||
description,
|
||||
amount,
|
||||
convertedAmount,
|
||||
paymentDate,
|
||||
tenderTypeCode,
|
||||
currencyUuid
|
||||
@ -204,6 +207,7 @@ export default {
|
||||
referenceNo,
|
||||
description,
|
||||
amount,
|
||||
convertedAmount,
|
||||
paymentDate,
|
||||
tenderTypeCode,
|
||||
currencyUuid
|
||||
|
Loading…
x
Reference in New Issue
Block a user