1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-07 18:25:45 +08:00

Converting for payment methods (#749)

* Fixes: #736

* minimal changes

* minimal changes

Co-authored-by: Elsio Sanchez <elsiosanche@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-04-23 18:04:26 -04:00 committed by GitHub
parent 1e42f1ede9
commit 4c49b20144
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 134 additions and 65 deletions

View File

@ -41,7 +41,7 @@ export default [
size: 24,
handleActionKeyPerformed: true,
handleActionPerformed: true,
validationCode: 'C_Currency.C_Currency_ID = 100',
validationCode: 'C_Currency.C_Currency_ID = 100 OR C_Currency.C_Currency_ID = 50001',
isActiveLogics: true,
isMandatory: true
}

View File

@ -58,6 +58,17 @@
</el-popover>
</b>
</p>
<p class="total">
<b>Tasa del Día: </b>
<b v-if="!isEmptyValue(dateRate)" style="float: right;">
{{
dateRate.iSOCode
}}
{{
formatConversionCurrenty(dateRate.amountConvertion)
}}
</b>
</p>
</div>
<div
v-if="isLoaded"
@ -200,12 +211,13 @@
<script>
import formMixin from '@/components/ADempiere/Form/formMixin'
import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js'
import fieldsListCollection from './fieldsListCollection.js'
import typeCollection from '@/components/ADempiere/Form/VPOS/Collection/typeCollection'
import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index'
import { formatDate, formatPrice } from '@/utils/ADempiere/valueFormat.js'
import { processOrder } from '@/api/ADempiere/form/point-of-sales.js'
import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js'
import { FIELDS_DECIMALS } from '@/utils/ADempiere/references'
export default {
name: 'Collection',
@ -381,7 +393,7 @@ export default {
return missing
}
const pending = this.currentOrder.grandTotal <= this.pay ? 0 : this.currentOrder.grandTotal
return pending / this.convertion
return pending
},
convertion() {
return this.$store.getters.getDivideRateCollection
@ -437,12 +449,6 @@ export default {
multiplyRateCollection() {
return this.$store.getters.getMultiplyRateCollection
},
converCurrency() {
return this.$store.getters.getValueOfField({
containerUuid: 'Collection',
columnName: 'C_Currency_ID_UUID'
})
},
divideRate() {
return this.$store.getters.getDivideRate
},
@ -468,8 +474,12 @@ export default {
updateOrderPaymentPos() {
return this.$store.getters.getUpdatePaymentPos
},
currentPointOfSales() {
return this.$store.getters.posAttributes.currentPointOfSales
dateRate() {
return this.$store.getters.getConvertionRate.find(currency => {
if (currency.id === this.typeCurrency) {
return currency
}
})
}
},
watch: {
@ -481,22 +491,18 @@ export default {
})
},
currencyUuid(value) {
if (!this.isEmptyValue(value)) {
const alo = this.$store.getters.getConvertionRate.find(currency => {
if (currency.uuid === value) {
return currency
}
})
if (alo === undefined) {
this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
currencyToUuid: value
})
}
if (this.isEmptyValue(value)) {
this.$store.commit('setFieldCurrency', this.pointOfSalesCurrency)
this.$store.dispatch('conversionDivideRate', {
containerUuid: 'Collection',
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
currencyToUuid: value
})
}
},
convertAllPayment(value) {
if (!this.isEmptyValue(value)) {
@ -504,18 +510,6 @@ export default {
}
this.allPayCurrency = this.pay
},
converCurrency(value) {
if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionMultiplyRate', {
containerUuid: 'Collection',
conversionTypeUuid: this.currentPointOfSales,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
currencyToUuid: value
})
} else {
this.$store.commit('currencyMultiplyRate', 1)
}
},
isLoaded(value) {
if (value) {
this.$store.commit('updateValueOfField', {
@ -524,14 +518,39 @@ export default {
value: this.pending
})
}
},
dateRate(value) {
if (value && !this.isEmptyValue(value.amountConvertion)) {
this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid,
columnName: 'PayAmt',
value: this.pending / value.amountConvertion
})
} else {
this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid,
columnName: 'PayAmt',
value: this.pending
})
}
}
},
created() {
console.log(this.$store.getters.getConvertionRate)
this.$store.dispatch('addRateConvertion', this.pointOfSalesCurrency)
this.unsubscribe = this.subscribeChanges()
this.defaultValueCurrency()
},
methods: {
formatDate,
formatNumber({ displayType, number }) {
let fixed = 0
// Amount, Costs+Prices, Number
if (FIELDS_DECIMALS.includes(displayType)) {
fixed = 2
}
return new Intl.NumberFormat().format(number.toFixed(fixed))
},
formatPrice,
sumCash(cash) {
let sum = 0

View File

@ -161,7 +161,7 @@ export default {
})
.then(response => {
this.isAddTypePay.forEach(element => {
if (element.currencyUuid !== this.$store.getters.getCurrentPOS.priceList.currency.uuid) {
if (element.currencyUuid !== this.pointOfSalesCurrency.uuid) {
element.amountConvertion = element.amount / response.divideRate
element.currencyConvertion = response.currencyTo
} else {

View File

@ -253,7 +253,7 @@
</b>
</p>
</span>
<span style="float: right;padding-right: 40px;">
<span style="float: right;padding-right: 3%;">
<p class="total">{{ $t('form.pos.order.order') }}: <b class="order-info">{{ currentOrder.documentNo }}</b></p>
<p class="total">
{{ $t('form.pos.order.date') }}:
@ -395,29 +395,29 @@ export default {
return this.isDisabled ? this.$t('form.pos.order.collections') : this.$t('form.pos.order.collect')
}
},
watch: {
currencyUuid(value) {
if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) {
this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
currencyToUuid: value
})
}
},
converCurrency(value) {
if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) {
this.$store.dispatch('conversionMultiplyRate', {
containerUuid: 'Order',
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
currencyToUuid: value
})
} else {
this.$store.commit('currencyMultiplyRate', 1)
}
}
},
// watch: {
// currencyUuid(value) {
// if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) {
// this.$store.dispatch('conversionDivideRate', {
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
// currencyToUuid: value
// })
// }
// },
// converCurrency(value) {
// if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) {
// this.$store.dispatch('conversionMultiplyRate', {
// containerUuid: 'Order',
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
// currencyToUuid: value
// })
// } else {
// this.$store.commit('currencyMultiplyRate', 1)
// }
// }
// },
mounted() {
if (!this.isEmptyValue(this.$route.query.action)) {
this.$store.dispatch('reloadOrder', { orderUuid: this.$route.query.action })

View File

@ -82,12 +82,16 @@ export default {
pointOfSalesCurrency() {
// const currency = this.currentPointOfSales
if (!this.isEmptyValue(this.currentPointOfSales.priceList)) {
return this.currentPointOfSales.priceList.currency
return {
...this.currentPointOfSales.priceList.currency,
amountConvertion: 1
}
}
return {
uuid: '',
iSOCode: '',
curSymbol: ''
curSymbol: '',
amountConvertion: 1
}
},
listPointOfSales() {

View File

@ -111,18 +111,30 @@ export default {
const payment = state.paymentBox
payment.splice(0)
},
conversionDivideRate({ commit }, params) {
conversionDivideRate({ commit, dispatch }, params) {
console.log('conversionDivideRate')
requestGetConversionRate({
conversionTypeUuid: params.conversionTypeUuid,
currencyFromUuid: params.currencyFromUuid,
currencyToUuid: params.currencyToUuid
currencyToUuid: params.currencyToUuid,
conversionDate: params.conversionDate
})
.then(response => {
commit('setFieldCurrency', response.currencyTo)
if (!isEmptyValue(response.currencyTo)) {
const currency = {
...response.currencyTo,
amountConvertion: response.divideRate
}
dispatch('addRateConvertion', currency)
}
const divideRate = isEmptyValue(response.divideRate) ? 1 : response.divideRate
const multiplyRate = isEmptyValue(response.multiplyRate) ? 1 : response.multiplyRate
if (params.containerUuid === 'Collection') {
commit('currencyMultiplyRateCollection', multiplyRate)
commit('currencyDivideRateCollection', divideRate)
} else {
commit('currencyMultiplyRate', multiplyRate)
commit('currencyDivideRateCollection', divideRate)
}
})
@ -135,6 +147,9 @@ export default {
})
})
},
addRateConvertion({ commit, state, getters }, currency) {
commit('conversionRate', currency)
},
conversionMultiplyRate({ commit }, {
containerUuid,
conversionTypeUuid,
@ -149,7 +164,7 @@ export default {
// conversionDate
})
.then(response => {
const multiplyRate = isEmptyValue(response.multiplyRate) ? 0 : response.multiplyRate
const multiplyRate = isEmptyValue(response.multiplyRate) ? 1 : response.multiplyRate
if (containerUuid === 'Collection') {
commit('currencyMultiplyRateCollection', multiplyRate)
} else {

View File

@ -45,5 +45,8 @@ export default {
},
getFieldCuerrency: (state) => {
return state.fieldCurrency
},
getConvertionRate: (state) => {
return state.convertionRate
}
}

View File

@ -42,6 +42,19 @@ export default {
setConvertionPayment(state, convertion) {
state.convertion = convertion
},
conversionRate(state, currency) {
const listCurrent = state.convertionRate.find(element => {
if (element.id === currency.id) {
return element
}
})
if (listCurrent === undefined) {
state.convertionRate.push(currency)
}
},
resetConversionRate(state, currency) {
state.convertionRate = currency
},
setFieldCurrency(state, currency) {
state.fieldCurrency = currency
}

View File

@ -29,5 +29,6 @@ export default {
},
currency: [],
convertion: {},
fieldCurrency: {}
fieldCurrency: {},
convertionRate: []
}

View File

@ -73,6 +73,7 @@ export default {
}
}, () => {})
commit('resetConversionRate', [])
commit('setIsReloadKeyLayout')
commit('setIsReloadProductPrice')
commit('setIsReloadListOrders')

View File

@ -157,7 +157,7 @@ export function convertCurrency(currencyToConvert) {
id: currencyToConvert.id,
uuid: currencyToConvert.uuid,
iSOCode: currencyToConvert.iso_code,
curSymbol: currencyToConvert.cur_symbol,
curSymbol: currencyToConvert.currency_symbol,
description: currencyToConvert.description,
standardPrecision: currencyToConvert.standard_precision,
costingPrecision: currencyToConvert.costing_precision

View File

@ -23,5 +23,6 @@ export {
clearVariables,
currencyFind,
tenderTypeFind,
formatConversionCurrenty,
typeValue
} from '@/utils/ADempiere/valueUtils.js'

View File

@ -546,3 +546,15 @@ export function tenderTypeFind({
export function clearVariables() {
partialValue = ''
}
export function formatConversionCurrenty(params) {
let exponential, expre
const number = params.toString()
if (params > 0) {
if (number.includes('e')) {
expre = number.split('-')
exponential = params.toFixed(expre[1])
return exponential
}
}
return params
}