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

Add Day Rate (#936)

* validate displayCurrency

* Add Day Rate

* minimal changes

* add tax to the converted amount

* add translation

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-06-23 16:05:11 -04:00 committed by GitHub
parent 8f0903dd4d
commit 79e9e6659b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 35 deletions

View File

@ -21,19 +21,21 @@
style="height: 100% !important;"
@click="focusProductValue"
>
<img
fit="contain"
:src="backgroundForm"
class="background-price-checking"
style="z-index: 5;"
>
<el-container style="height: 100% !important;">
<img
fit="contain"
:src="backgroundForm"
class="background-price-checking"
style="z-index: 2;"
>
<el-main>
<el-form
key="form-loaded"
class="inquiry-form"
label-position="top"
label-width="10px"
style="z-index: -1;"
@submit.native.prevent="notSubmitForm"
>
<field
@ -48,13 +50,11 @@
</el-form>
<div class="inquiry-product" style="z-index: 4;">
<div class="product-description">
<b> {{ productPrice.productName }} </b> <br> {{ productPrice.productDescription }}
</div>
<el-row v-if="!isEmptyValue(productPrice)" :gutter="20">
<el-col style="padding-left: 0px; padding-right: 0%;">
<div class="product-description">
{{ productPrice.productName }} {{ productPrice.productDescription }}
</div>
<br><br><br>
<el-col :span="24" style="padding-left: 0px; padding-right: 0%;">
<div class="product-price-base">
{{ $t('form.priceChecking.basePrice') }}
<span class="amount">
@ -70,10 +70,9 @@
</span>
</div>
<br><br><br>
<div class="product-price amount">
<span style="float: right;"> {{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }} </span> <br>
<span v-if="!isEmptyValue(currentPointOfSales.displayCurrency)"> {{ formatPrice(productPrice.grandTotalConverted, currentPointOfSales.displayCurrency.iSOCode) }}</span>
<span v-if="!isEmptyValue(currentPointOfSales.displayCurrency) && !isEmptyValue(convertionsList)"> {{ formatPrice(productPrice.grandTotal / converted, currentPointOfSales.displayCurrency.iso_code) }}</span>
</div>
</el-col>
</el-row>
@ -87,6 +86,18 @@
</el-col>
</el-row>
</div>
<div v-if="!isEmptyValue(productPrice) && !isEmptyValue(currentPointOfSales.displayCurrency) && !isEmptyValue(convertionsList)" class="inquiry-product" style="z-index: 4;">
<el-row>
<el-col>
<div v-if="!isEmptyValue(currentConvertion)" class="rate-date">
{{ $t('form.pos.collect.dayRate') }}: {{ formatQuantity(currentConvertion.multiplyRate) }} ~ ({{ formatPrice(1, productPrice.currency.iSOCode) }} = {{ formatPrice(currentConvertion.multiplyRate) }} {{ currentPointOfSales.displayCurrency.iso_code }})
</div>
<div v-else class="rate-date">
{{ $t('form.pos.collect.noDayRate') }} {{ currentPointOfSales.displayCurrency.description }}
</div>
</el-col>
</el-row>
</div>
</el-main>
</el-container>
</div>
@ -105,7 +116,7 @@
import formMixin from '@/components/ADempiere/Form/formMixin.js'
import fieldsList from './fieldsList.js'
import { getProductPrice } from '@/api/ADempiere/form/price-checking.js'
import { formatPercent, formatPrice } from '@/utils/ADempiere/valueFormat.js'
import { formatPercent, formatPrice, formatQuantity } from '@/utils/ADempiere/valueFormat.js'
import { getImagePath } from '@/utils/ADempiere/resource.js'
export default {
@ -143,7 +154,31 @@ export default {
return this.$store.state['pointOfSales/point/index'].conversionsList
},
currentConvertion() {
return this.convertionsList.find(convert => convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id)
if (this.isEmptyValue(this.currentPointOfSales.displayCurrency)) {
return {}
}
const convert = this.convertionsList.find(convert => {
if (!this.isEmptyValue(convert.currencyTo) && !this.isEmptyValue(this.currentPointOfSales.displayCurrency) && convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id) {
return convert
}
})
if (convert) {
return convert
}
return {}
},
converted() {
if (!this.isEmptyValue(this.convertionsList)) {
const convertion = this.convertionsList.find(convert => {
if (!this.isEmptyValue(convert.currencyTo) && !this.isEmptyValue(this.currentPointOfSales.displayCurrency) && convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id) {
return convert
}
})
if (!this.isEmptyValue(convertion)) {
return convertion.divideRate
}
}
return 1
}
},
created() {
@ -155,13 +190,6 @@ export default {
if (this.isEmptyValue(this.pointOfSalesList)) {
this.$store.dispatch('listPointOfSalesFromServer')
}
if (!this.isEmptyValue(this.pointOfSalesList) && this.isEmptyValue(this.currentConvertion)) {
this.$store.dispatch('searchConversion', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid,
currencyToUuid: this.currentPointOfSales.displayCurrency.uuid
})
}
},
beforeDestroy() {
this.unsubscribe()
@ -169,6 +197,7 @@ export default {
methods: {
formatPercent,
formatPrice,
formatQuantity,
focusProductValue() {
if (!this.isEmptyValue(this.$refs.ProductValue[0])) {
this.$refs.ProductValue[0].$children[0].$children[0].$children[1].$children[0].focus()
@ -180,14 +209,19 @@ export default {
}
const image = getImagePath({
file: fileName,
width: 250,
height: 280
width: 900,
height: 900
})
this.backgroundForm = image.uri
},
amountConvert(price, currency) {
const convertion = this.convertionsList.find(convert => convert.currencyTo.id === currency.id)
return price / convertion.divideRate
amountConvert() {
if (!this.isEmptyValue(this.currentPointOfSales) && this.isEmptyValue(this.currentConvertion) && !this.isEmptyValue(this.currentPointOfSales.displayCurrency)) {
this.$store.dispatch('searchConversion', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid,
currencyToUuid: this.currentPointOfSales.displayCurrency.uuid
})
}
},
subscribeChanges() {
return this.$store.subscribe((mutation, state) => {
@ -218,7 +252,6 @@ export default {
priceStandard: productPrice.priceStandard,
priceList: productPrice.priceList,
priceLimit: productPrice.priceLimit,
grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency),
taxRate: rate,
taxName: taxRate.name,
taxIndicator: taxRate.taxIndicator,
@ -232,6 +265,7 @@ export default {
this.productPrice = {}
})
.finally(() => {
this.amountConvert()
this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid,
columnName: 'ProductValue',
@ -271,7 +305,6 @@ export default {
priceList: productPrice.priceList,
priceLimit: productPrice.priceLimit,
schemaCurrency: productPrice.schemaCurrency,
grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency),
schemaPriceStandard: productPrice.schemaPriceStandard,
schemaPriceList: productPrice.schemaPriceList,
schemaPriceLimit: productPrice.schemaPriceLimit,
@ -287,6 +320,7 @@ export default {
this.productPrice = {}
})
.finally(() => {
this.amountConvert()
this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid,
columnName: 'ProductValue',
@ -340,7 +374,9 @@ export default {
color: #32363a;
font-size: 30px;
float: right;
padding-bottom: 0px;
padding-bottom: 1%;
text-align: end;
}
.product-price-base, .product-tax {
font-size: 30px;
@ -351,7 +387,14 @@ export default {
font-size: 50px;
float: right;
}
.rate-date {
padding-top: 30%;
font-size: 50px;
float: right;
color: black;
font-weight: bold;
text-align: end;
}
.inquiry-form {
position: absolute;
right: 5%;
@ -361,8 +404,7 @@ export default {
}
.inquiry-product {
position: absolute;
right: 20%;
width: 100%;
right: 10%;
top: 33%;
.amount {
color: black;

View File

@ -477,6 +477,7 @@ export default {
convertedAmount: 'Converted Amount',
fullPayment: 'Full Payment',
dayRate: 'Day Rate',
noDayRate: 'No daily rate has been generated for the currency.',
TenderType: {
directDeposit: 'Direct Deposit',
creditCard: 'Credit Card',

View File

@ -452,6 +452,7 @@ export default {
convertedAmount: 'Monto Convertido',
fullPayment: 'Cobro Completo',
dayRate: 'Tasa del Día',
noDayRate: 'No se a generado una tasa del día para la moneda',
TenderType: {
directDeposit: 'Depósito Directo',
creditCard: 'Tarjeta de Crédito',

View File

@ -112,7 +112,7 @@ export default {
payment.splice(0)
},
searchConversion({ commit }, params) {
requestGetConversionRate({
return requestGetConversionRate({
conversionTypeUuid: params.conversionTypeUuid,
currencyFromUuid: params.currencyFromUuid,
currencyToUuid: params.currencyToUuid,
@ -120,6 +120,7 @@ export default {
})
.then(response => {
commit('addConversionToList', response)
return response
})
.catch(error => {
console.warn(`conversionDivideRate: ${error.message}. Code: ${error.code}.`)