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

Feature/add column pos (#911)

* add-column-convertedAmount

* add

* add

* Update index.vue

* Update index.vue

* Update orderLineMixin.js

* fix
This commit is contained in:
Andojeda 2021-06-11 17:13:55 -04:00 committed by GitHub
parent 6794660098
commit c467351738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import {
deleteOrderLine deleteOrderLine
} from '@/api/ADempiere/form/point-of-sales.js' } from '@/api/ADempiere/form/point-of-sales.js'
import { formatPercent } from '@/utils/ADempiere/valueFormat.js' import { formatPercent } from '@/utils/ADempiere/valueFormat.js'
import { showMessage } from '@/utils/ADempiere/notification.js'
export default { export default {
name: 'OrderLineMixin', name: 'OrderLineMixin',
@ -55,6 +56,12 @@ export default {
label: 'Total', label: 'Total',
isNumeric: true, isNumeric: true,
size: 'auto' size: 'auto'
},
convertedAmount: {
columnName: 'ConvertedAmount',
label: this.$t('form.pos.collect.convertedAmount'),
isNumeric: true,
size: 'auto'
} }
}, },
currentOrderLine: { currentOrderLine: {
@ -67,11 +74,18 @@ export default {
taxIndicator: 0, taxIndicator: 0,
quantityOrdered: 0, quantityOrdered: 0,
uuid: '' uuid: ''
},
totalAmountConvertedLine: {
} }
} }
}, },
computed: { computed: {
},
created() {
const currentCurrency = this.$store.getters.posAttributes.listPointOfSales.find(pos =>
pos.priceList.currency.uuid !== this.$store.getters.posAttributes.currentPointOfSales.priceList.currency.uuid)
this.convertedAmountAsTotal(currentCurrency.priceList.currency)
}, },
methods: { methods: {
formatPercent, formatPercent,
@ -186,6 +200,40 @@ export default {
}) })
}) })
}, },
convertedAmountAsTotal(value) {
this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
currencyToUuid: value.uuid
})
.then(response => {
if (!this.isEmptyValue(response.currencyTo)) {
const currency = {
...response.currencyTo,
amountConvertion: response.divideRate,
multiplyRate: response.multiplyRate
}
this.totalAmountConvertedLine = currency
} else {
this.totalAmountConvertedLine.multiplyRate = '1'
this.totalAmountConvertedLine.iSOCode = value.iSOCode
}
})
.catch(error => {
console.warn(`conversionDivideRate: ${error.message}. Code: ${error.code}.`)
showMessage({
type: 'error',
message: error.message,
showClose: true
})
})
},
getTotalAmount(basePrice, multiplyRate) {
if (this.isEmptyValue(basePrice) || this.isEmptyValue(multiplyRate)) {
return 0
}
return (basePrice * multiplyRate)
},
/** /**
* Show the correct display format * Show the correct display format
* @param {object} row record * @param {object} row record
@ -205,6 +253,8 @@ export default {
return this.formatPercent(row.discount / 100) return this.formatPercent(row.discount / 100)
} else if (columnName === 'GrandTotal') { } else if (columnName === 'GrandTotal') {
return this.formatPrice(row.grandTotal, currency) return this.formatPrice(row.grandTotal, currency)
} else if (columnName === 'ConvertedAmount') {
return this.formatPrice(this.getTotalAmount(row.grandTotal, this.totalAmountConvertedLine.multiplyRate), this.totalAmountConvertedLine.iSOCode)
} }
}, },
productPrice(price, discount) { productPrice(price, discount) {

View File

@ -446,6 +446,7 @@ export default {
payment: 'Pago', payment: 'Pago',
change: 'Cambio', change: 'Cambio',
convertAmount: 'Convertir Cantidad', convertAmount: 'Convertir Cantidad',
convertedAmount: 'Monto Convertido',
fullPayment: 'Cobro Completo', fullPayment: 'Cobro Completo',
dayRate: 'Tasa del Día', dayRate: 'Tasa del Día',
TenderType: { TenderType: {

View File

@ -112,7 +112,7 @@ export default {
payment.splice(0) payment.splice(0)
}, },
conversionDivideRate({ commit, dispatch }, params) { conversionDivideRate({ commit, dispatch }, params) {
requestGetConversionRate({ return requestGetConversionRate({
conversionTypeUuid: params.conversionTypeUuid, conversionTypeUuid: params.conversionTypeUuid,
currencyFromUuid: params.currencyFromUuid, currencyFromUuid: params.currencyFromUuid,
currencyToUuid: params.currencyToUuid, currencyToUuid: params.currencyToUuid,
@ -137,6 +137,7 @@ export default {
commit('currencyMultiplyRate', multiplyRate) commit('currencyMultiplyRate', multiplyRate)
commit('currencyDivideRateCollection', divideRate) commit('currencyDivideRateCollection', divideRate)
} }
return response
}) })
.catch(error => { .catch(error => {
console.warn(`conversionDivideRate: ${error.message}. Code: ${error.code}.`) console.warn(`conversionDivideRate: ${error.message}. Code: ${error.code}.`)