Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pos #977

Merged
merged 3 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default [
columnName: 'PayAmt',
isFromDictionary: true,
overwriteDefinition: {
sequence: 0,
handleContentSelection: true,
handleActionPerformed: true,
size: 24,
Expand All @@ -32,20 +33,6 @@ export default [
isMandatory: true
}
},
// Currency
{
tableName: 'C_Order',
columnName: 'C_Currency_ID',
isFromDictionary: true,
overwriteDefinition: {
size: 24,
handleActionKeyPerformed: true,
handleActionPerformed: true,
validationCode: 'C_Currency.C_Currency_ID = 100 OR C_Currency.C_Currency_ID = 50001',
isActiveLogics: true,
isMandatory: true
}
},
// TenderType
{
tableName,
Expand All @@ -54,6 +41,7 @@ export default [
isFromDictionary: true,
overwriteDefinition: {
defaultValue: 'X',
sequence: 1,
handleActionKeyPerformed: true,
handleContentSelection: true,
handleActionPerformed: true,
Expand All @@ -62,16 +50,18 @@ export default [
isMandatory: true
}
},
// Currency
// Bank
{
tableName,
columnName: 'C_Bank_ID',
isFromDictionary: true,
overwriteDefinition: {
sequence: 3,
handleActionKeyPerformed: true,
handleActionPerformed: true,
handleContentSelection: true,
displayLogic: `@TenderType@=='D'`,
displayLogic: `@TenderType@<>'X'`,
size: 24,
isActiveLogics: true,
isMandatory: true
Expand All @@ -83,6 +73,7 @@ export default [
elementColumnName: 'DateTrx',
isFromDictionary: true,
overwriteDefinition: {
sequence: 4,
handleFocusGained: true,
handleFocusLost: true,
handleKeyPressed: true,
Expand All @@ -102,6 +93,7 @@ export default [
columnName: 'ReferenceNo',
isFromDictionary: true,
overwriteDefinition: {
sequence: 5,
handleActionKeyPerformed: true,
handleContentSelection: true,
handleActionPerformed: true,
Expand All @@ -118,6 +110,7 @@ export default [
columnName: 'CreditCardType',
isFromDictionary: true,
overwriteDefinition: {
sequence: 6,
defaultValue: 'M',
handleActionKeyPerformed: true,
handleContentSelection: true,
Expand All @@ -135,6 +128,7 @@ export default [
columnName: 'CreditCardNumber',
isFromDictionary: true,
overwriteDefinition: {
sequence: 7,
handleActionKeyPerformed: true,
handleContentSelection: true,
handleActionPerformed: true,
Expand All @@ -151,6 +145,7 @@ export default [
columnName: 'AccountNo',
isFromDictionary: true,
overwriteDefinition: {
sequence: 8,
handleActionKeyPerformed: true,
handleContentSelection: true,
handleActionPerformed: true,
Expand Down
131 changes: 61 additions & 70 deletions src/components/ADempiere/Form/VPOS/Collection/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@
<p class="total">
<b>{{ $t('form.pos.collect.dayRate') }}:</b>
<!-- Conversion rate to date -->
<b v-if="!isEmptyValue(dateRate)" style="float: right;">
<span v-if="!isEmptyValue(dateRate.divideRate)">
<span v-if="formatConversionCurrenty(dateRate.divideRate) > 1">
<b v-if="!isEmptyValue(dayRate)" style="float: right;">
<span v-if="!isEmptyValue(dayRate.divideRate)">
<span v-if="formatConversionCurrenty(dayRate.divideRate) > 1">
{{
formatPrice(formatConversionCurrenty(dateRate.divideRate), dateRate.currencyTo.iSOCode)
formatPrice(formatConversionCurrenty(dayRate.divideRate), dayRate.currencyTo.iSOCode)
}}
</span>
<span v-else>
{{
dateRate.currencyTo.iSOCode
dayRate.currencyTo.iSOCode
}}
{{
formatConversionCurrenty(dateRate.divideRate)
formatConversionCurrenty(dayRate.divideRate)
}}
</span>
</span>
<span v-else>
{{
formatPrice(1, dateRate.iSOCode)
formatPrice(1, dayRate.iSOCode)
}}
</span>
</b>
Expand All @@ -100,11 +100,10 @@
<el-col v-for="(field, index) in fieldsList" :key="index" :span="8">
<!-- Add selected currency symbol -->
<field-definition
v-if="field.columnName === 'PayAmt' || field.columnName === 'TenderType'"
:key="field.columnName"
v-if="field.sequence <= 1"
:metadata-field="field.columnName === 'PayAmt' ? {
...field,
labelCurrency: isEmptyValue(dateRate.divideRate) ? dateRate : dateRate.currencyTo
labelCurrency: isEmptyValue(dayRate.divideRate) ? dayRate : dayRate.currencyTo
} : field"
/>
</el-col>
Expand All @@ -124,14 +123,12 @@
</el-select>
</el-form-item>
</el-col>
<el-col v-for="(field, index) in fieldsList" :key="index" :span="8">
<!-- Add selected currency symbol -->
<el-col v-for="(field, key) in fieldsList" :key="key" :span="8">
<field-definition
v-if="field.columnName !== 'PayAmt' && field.columnName !== 'TenderType' && field.columnName !== 'C_Currency_ID'"
:key="field.columnName"
v-if="field.sequence > 2"
:metadata-field="field.columnName === 'PayAmt' ? {
...field,
labelCurrency: isEmptyValue(dateRate.divideRate) ? dateRate : dateRate.currencyTo
labelCurrency: isEmptyValue(dayRate.divideRate) ? dayRate : dayRate.currencyTo
} : field"
/>
</el-col>
Expand Down Expand Up @@ -314,7 +311,7 @@ export default {
},
computed: {
listCurrency() {
return this.$store.state['pointOfSales/point/index'].listCurrency
return this.$store.state['pointOfSales/point/index'].currenciesList
},
convertionList() {
return this.$store.state['pointOfSales/point/index'].conversionsList
Expand Down Expand Up @@ -530,19 +527,41 @@ export default {
updateOrderPaymentPos() {
return this.$store.getters.getUpdatePaymentPos
},
dateRate() {
const convertion = this.convertionList.find(currency => {
if ((currency.currencyTo.iSOCode === this.currentFieldCurrency) && (this.pointOfSalesCurrency.iSOCode !== currency.currencyTo.iSOCode)) {
return currency
convertionsList() {
return this.$store.state['pointOfSales/point/index'].conversionsList
},
currentConvertion() {
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 {}
},
dayRate() {
const currency = this.listCurrency.find(currency => currency.key === this.currentFieldCurrency)
const convert = this.convertionsList.find(convert => {
if (!this.isEmptyValue(currency) && !this.isEmptyValue(convert.currencyTo) && currency.id === convert.currencyTo.id && this.currentPointOfSales.currentPriceList.currency.id !== currency.id) {
return convert
}
})
if (!this.isEmptyValue(convertion)) {
return convertion
if (!this.isEmptyValue(convert)) {
return convert
}
return {
currencyTo: this.currentPointOfSales.currentPriceList.currency,
divideRate: 1,
iSOCode: this.currentPointOfSales.currentPriceList.currency.iSOCode
}
return this.pointOfSalesCurrency
},
fieldsPaymentType() {
return this.fieldsList[2]
return this.fieldsList[1]
}
},
watch: {
Expand All @@ -553,21 +572,6 @@ export default {
value: value
})
},
// currencyUuid(value) {
// const listCurrency = this.$store.getters.getConvertionRate.find(currency => {
// if (currency.uuid === value) {
// return currency
// }
// })
// if (listCurrency === undefined) {
// this.$store.dispatch('conversionDivideRate', {
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
// conversionDate: this.formatDate(new Date()),
// currencyToUuid: value
// })
// }
// },
convertAllPayment(value) {
if (!this.isEmptyValue(value)) {
this.allPayCurrency = this.pay / value
Expand All @@ -583,7 +587,7 @@ export default {
})
}
},
dateRate(value) {
dayRate(value) {
if (!this.isEmptyValue(value.divideRate)) {
this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid,
Expand Down Expand Up @@ -618,6 +622,13 @@ export default {
this.defaultValueCurrency()
},
methods: {
amountConvert(currency) {
this.$store.dispatch('searchConversion', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid,
currencyToUuid: currency.uuid
})
},
formatNumber({ displayType, number }) {
let fixed = 0
// Amount, Costs+Prices, Number
Expand Down Expand Up @@ -668,18 +679,7 @@ export default {
containerUuid,
columnName: 'ReferenceNo'
})
const currencyUuid = this.$store.getters.getValueOfField({
containerUuid,
columnName: 'C_Currency_ID_UUID'
})
const currencyId = this.$store.getters.getValueOfField({
containerUuid,
columnName: 'C_Currency_ID'
})
const currencyToPay = this.isEmptyValue(currencyUuid) ? currencyId : currencyUuid
if (this.isEmptyValue(this.currencyDisplay(currencyToPay)) && this.currencyDisplay(currencyToPay).currencyUuid !== this.pointOfSalesCurrency.uuid) {
this.amontSend = this.convert.divideRate * this.amontSend
}
this.amontSend = this.dayRate.divideRate * this.amontSend
if (this.sendToServer) {
this.$store.dispatch('setPaymentBox', {
posUuid,
Expand All @@ -689,7 +689,7 @@ export default {
amount: this.amontSend * this.convertion,
paymentDate,
tenderTypeCode,
currencyUuid
currencyUuid: this.dayRate.currencyTo.uuid
})
} else {
this.$store.dispatch('createPayments', {
Expand All @@ -700,7 +700,7 @@ export default {
amount: this.amontSend * this.convertion,
paymentDate,
tenderTypeCode,
currencyUuid: this.currencyDisplay(currencyToPay)
currencyUuid: this.dayRate.currencyTo.uuid
})
}
this.addCollect()
Expand Down Expand Up @@ -838,14 +838,6 @@ export default {
}
return currency
},
convertCurrency() {
const convertCurrency = this.currencyDisplay(100)
this.$store.dispatch('convertionPayment', {
conversionTypeUuid: this.currentPointOfSales,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
currencyToUuid: convertCurrency.currencyUuid
})
},
undoPatment() {
const list = this.listPayments[this.listPayments.length - 1]
const orderUuid = list.orderUuid
Expand Down Expand Up @@ -918,14 +910,13 @@ export default {
changeCurrency(value) {
this.currentFieldCurrency = value
const currency = this.listCurrency.find(currency => currency.key === value)
const findCoventionList = this.convertionList.find(convertion => convertion.currencyTo.iSOCode === value)
if (!this.isEmptyValue(currency) && this.isEmptyValue(findCoventionList) && (value !== this.pointOfSalesCurrency.iSOCode)) {
this.$store.dispatch('searchConversion', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
conversionDate: this.formatDate(new Date()),
currencyToUuid: currency.uuid
})
const convert = this.convertionsList.find(convert => {
if (!this.isEmptyValue(currency) && !this.isEmptyValue(convert.currencyTo) && currency.id === convert.currencyTo.id && this.currentPointOfSales.currentPriceList.currency.id !== currency.id) {
return convert
}
})
if (!this.isEmptyValue(currency) && this.isEmptyValue(convert) && currency.uuid !== this.currentPointOfSales.currentPriceList.currency.uuid) {
this.amountConvert(currency)
}
}
}
Expand Down
Loading