1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-13 15:15:53 +08:00

upload orders to the server (#579)

* upload orders to the server

* support convert currency

* support for currency search, payment types and undoing payment

* change icon
This commit is contained in:
Elsio Sanchez 2021-02-05 17:15:22 -04:00 committed by GitHub
parent 60223ecc14
commit 6f4fc11780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 391 additions and 113 deletions

View File

@ -1,33 +1,5 @@
<template> <template>
<div> <div>
<el-popover
ref="businessPartnerCreate"
v-model="showsPopovers.isShowCreate"
placement="right"
width="400"
trigger="click"
>
<business-partner-create
v-if="showsPopovers.isShowCreate"
:parent-metadata="parentMetadata"
:shows-popovers="showsPopovers"
/>
</el-popover>
<el-popover
ref="businessPartnersList"
v-model="showsPopovers.isShowList"
placement="right"
width="800"
trigger="click"
>
<!-- v-if="showsPopovers.isShowList" -->
<business-partners-list
:parent-metadata="parentMetadata"
:shows-popovers="showsPopovers"
/>
</el-popover>
<el-form-item> <el-form-item>
<template slot="label"> <template slot="label">
{{ $t('form.pos.order.BusinessPartnerCreate.businessPartner') }} {{ $t('form.pos.order.BusinessPartnerCreate.businessPartner') }}
@ -73,6 +45,32 @@
</template> </template>
</el-autocomplete> </el-autocomplete>
</el-form-item> </el-form-item>
<el-popover
ref="businessPartnerCreate"
v-model="showsPopovers.isShowCreate"
placement="right"
width="400"
trigger="click"
>
<business-partner-create
v-if="showsPopovers.isShowCreate"
:parent-metadata="parentMetadata"
:shows-popovers="showsPopovers"
/>
</el-popover>
<el-popover
ref="businessPartnersList"
v-model="showsPopovers.isShowList"
placement="right"
width="800"
trigger="click"
>
<business-partners-list
:parent-metadata="parentMetadata"
:shows-popovers="showsPopovers"
/>
</el-popover>
</div> </div>
</template> </template>

View File

@ -15,6 +15,20 @@ export default [
isMandatory: true 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',
isActiveLogics: true,
isMandatory: true
}
},
// TenderType // TenderType
{ {
tableName, tableName,
@ -64,20 +78,6 @@ export default [
isMandatory: true 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',
isActiveLogics: true,
isMandatory: true
}
},
// ReferenceNo // ReferenceNo
{ {
tableName: 'HR_Attribute', tableName: 'HR_Attribute',

View File

@ -63,17 +63,8 @@
</div> </div>
</el-card> </el-card>
<samp style="float: right;padding-right: 10px;"> <samp style="float: right;padding-right: 10px;">
<el-checkbox v-show="fullCopper" v-model="checked">
<el-link
type="danger"
class="stylefullPayment"
>
<b>
{{ $t('form.pos.collect.fullPayment') }}
</b>
</el-link>
</el-checkbox>
<el-button type="danger" icon="el-icon-close" @click="exit" /> <el-button type="danger" icon="el-icon-close" @click="exit" />
<el-button type="info" icon="el-icon-minus" @click="undoPatment" />
<el-button type="primary" :disabled="validPay || addPay" icon="el-icon-plus" @click="addCollectToList(paymentBox)" /> <el-button type="primary" :disabled="validPay || addPay" icon="el-icon-plus" @click="addCollectToList(paymentBox)" />
<el-button type="success" :disabled="validateCompleteCollection" icon="el-icon-shopping-cart-full" /> <el-button type="success" :disabled="validateCompleteCollection" icon="el-icon-shopping-cart-full" />
</samp> </samp>
@ -228,7 +219,9 @@ export default {
allPayCurrency: 0, allPayCurrency: 0,
labelTenderType: '', labelTenderType: '',
defaultLabel: '', defaultLabel: '',
fieldsList: fieldsListCollection fieldsList: fieldsListCollection,
sendToServer: false,
amontSend: 0
} }
}, },
computed: { computed: {
@ -265,7 +258,12 @@ export default {
return false return false
}, },
listPayments() { listPayments() {
return this.$store.getters.getListPayments const listLocal = this.$store.getters.getPaymentBox
const listServer = this.$store.getters.getListPayments
if (!this.sendToServer) {
return listServer.reverse()
}
return listLocal
}, },
paymentBox() { paymentBox() {
const payment = this.isPaymentBox.filter(pay => { const payment = this.isPaymentBox.filter(pay => {
@ -451,7 +449,13 @@ export default {
return true return true
}, },
fieldpending() { fieldpending() {
return this.pending * this.multiplyRateCollection return this.pending
},
displayCurrency() {
return this.$store.getters.getListCurrency
},
convert() {
return this.$store.getters.getConvertionPayment
} }
}, },
watch: { watch: {
@ -522,7 +526,7 @@ export default {
}, },
mounted() { mounted() {
setTimeout(() => { setTimeout(() => {
this.tenderTypeDisplaye() this.convertCurrency()
}, 1000) }, 1000)
}, },
methods: { methods: {
@ -547,7 +551,7 @@ export default {
containerUuid, containerUuid,
columnName: 'C_Bank_ID_UUID' columnName: 'C_Bank_ID_UUID'
}) })
const amount = this.$store.getters.getValueOfField({ this.amontSend = this.$store.getters.getValueOfField({
containerUuid, containerUuid,
columnName: 'PayAmt' columnName: 'PayAmt'
}) })
@ -567,19 +571,46 @@ export default {
containerUuid, containerUuid,
columnName: 'C_Currency_ID_UUID' 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.currencyDisplay(currencyToPay).currencyUuid !== this.currencyPoint.uuid) {
this.amontSend = this.convert.divideRate * this.amontSend
}
if (this.sendToServer) {
this.$store.dispatch('setPaymentBox', {
posUuid,
orderUuid,
bankUuid,
referenceNo,
amount: this.amontSend,
paymentDate,
tenderTypeCode,
currencyUuid
})
} else {
this.$store.dispatch('createPayments', { this.$store.dispatch('createPayments', {
posUuid, posUuid,
orderUuid, orderUuid,
bankUuid, bankUuid,
referenceNo, referenceNo,
amount, amount: this.amontSend,
paymentDate, paymentDate,
tenderTypeCode, tenderTypeCode,
currencyUuid currencyUuid: this.currencyDisplay(currencyToPay).currencyUuid
}) })
}
this.amontSend = 0
this.addCollect() this.addCollect()
}, },
updateServer(listPaymentsLocal) {
// const listLocal = this.$store.getters.getPaymentBox
const posUuid = this.$store.getters.getCurrentPOS.uuid
const orderUuid = this.$route.query.action
this.$store.dispatch('uploadOrdersToServer', { listPaymentsLocal, posUuid, orderUuid })
},
addCollect() { addCollect() {
this.fieldsList.forEach(element => { this.fieldsList.forEach(element => {
if (element.columnName !== 'PayAmt') { if (element.columnName !== 'PayAmt') {
@ -693,17 +724,33 @@ export default {
value: this.$t('form.pos.collect.TenderType.cash') value: this.$t('form.pos.collect.TenderType.cash')
}) })
}, },
tenderTypeDisplaye() { currencyDisplay(currency) {
if (!this.isEmptyValue(this.fieldsList)) { const display = this.displayCurrency.find(item => {
const tenderType = this.fieldsList[1].reference if (item.currencyUuid === currency || (item.currencyId === currency)) {
this.$store.dispatch('getLookupListFromServer', { return item
tableName: tenderType.tableName,
query: tenderType.query
})
.then(response => {
this.$store.dispatch('tenderTypeDisplaye', response)
})
} }
})
if (display) {
return display
}
return currency
},
convertCurrency() {
const convertCurrency = this.currencyDisplay(100)
this.$store.dispatch('convertionPayment', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: convertCurrency.currencyUuid
})
},
undoPatment() {
const list = this.listPayments[this.listPayments.length - 1]
const orderUuid = list.orderUuid
const paymentUuid = list.uuid
this.$store.dispatch('deletetPayments', {
orderUuid,
paymentUuid
})
}, },
subscribeChanges() { subscribeChanges() {
return this.$store.subscribe((mutation, state) => { return this.$store.subscribe((mutation, state) => {

View File

@ -18,7 +18,14 @@
/> />
<div style="padding-right: 10px; padding-top: 10%;"> <div style="padding-right: 10px; padding-top: 10%;">
<div class="top clearfix"> <div class="top clearfix">
<span>{{ tenderTypeDisplay(value.tenderTypeCode) }}</span> <span>
{{
tenderTypeFind({
currentPayment: value.tenderTypeCode,
listTypePayment: typesPayment
})
}}
</span>
</div> </div>
<div class="bottom clearfix" style="margin-top: 0px !important!"> <div class="bottom clearfix" style="margin-top: 0px !important!">
<el-button <el-button
@ -37,17 +44,41 @@
> >
{{ formatDate(value.paymentDate) }} {{ formatDate(value.paymentDate) }}
</el-button> </el-button>
<div
<div slot="header" class="clearfix"> v-if="currencyFind({
<p class="total" :style="value.currencyUuid === currency.id ? 'padding-top: 5%;' : ''"> currencyCurrent: value.currencyUuid,
<b style="float: right; padding-bottom: 10px"> listCurrency: listCurrency,
defaultCurrency: currency
}).currencyDisplay !== currency.iSOCode"
slot="header"
class="clearfix"
style="padding-bottom: 20px;"
>
<p class="total">
<b style="float: right;">
{{ formatPrice(value.amount, currency.iSOCode) }} {{ formatPrice(value.amount, currency.iSOCode) }}
</b> </b>
</p> </p>
<br> <br>
<p v-if="value.currencyUuid !== currency.id" class="total"> <p class="total">
<b style="float: right; padding-bottom: 10px"> <b style="float: right;">
{{ formatPrice(value.quantityCahs) }} {{
formatPrice(
(amountConvertion(value)),
currencyFind({
currencyCurrent: value.currencyUuid,
listCurrency: listCurrency,
defaultCurrency: currency
}).currencyDisplay
)
}}
</b>
</p>
</div>
<div v-else slot="header" class="clearfix">
<p class="total">
<b style="float: right;padding-top: 18px;padding-bottom: 20px;">
{{ formatPrice(value.amount, currency.iSOCode) }}
</b> </b>
</p> </p>
</div> </div>
@ -81,9 +112,20 @@ export default {
default: undefined default: undefined
} }
}, },
data() {
return {
conevertion: 0
}
},
computed: { computed: {
label() { typesPayment() {
return this.$store.getters.getTenderTypeDisplaye return this.$store.getters.getListsPaymentTypes
},
listCurrency() {
return this.$store.getters.getListCurrency
},
conevertionAmount() {
return this.$store.getters.getConvertionPayment
} }
}, },
methods: { methods: {
@ -139,16 +181,8 @@ export default {
paymentUuid paymentUuid
}) })
}, },
tenderTypeDisplay(payments) { amountConvertion(payment) {
const display = this.label.find(item => { return payment.amount * this.conevertionAmount.multiplyRate
if (item.tenderTypeCode === payments) {
return item.tenderTypeDisplay
}
})
if (display) {
return display.tenderTypeDisplay
}
return payments
} }
} }
} }

View File

@ -3,10 +3,12 @@ export default [
{ {
elementColumnName: 'ProductValue', elementColumnName: 'ProductValue',
columnName: 'ProductValue', columnName: 'ProductValue',
tabindex: '1',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 24, size: 24,
sequence: 10, sequence: 10,
handleFocusGained: true,
handleActionPerformed: true, handleActionPerformed: true,
handleActionKeyPerformed: true handleActionKeyPerformed: true
} }
@ -14,6 +16,7 @@ export default [
{ {
elementColumnName: 'QtyEntered', elementColumnName: 'QtyEntered',
columnName: 'QtyEntered', columnName: 'QtyEntered',
tabindex: '2',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 24, size: 24,
@ -26,6 +29,7 @@ export default [
{ {
elementColumnName: 'PriceEntered', elementColumnName: 'PriceEntered',
columnName: 'PriceEntered', columnName: 'PriceEntered',
tabindex: '3',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 24, size: 24,
@ -39,6 +43,7 @@ export default [
{ {
elementColumnName: 'Discount', elementColumnName: 'Discount',
columnName: 'Discount', columnName: 'Discount',
tabindex: '4',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 24, size: 24,
@ -48,5 +53,34 @@ export default [
handleContentSelection: true, handleContentSelection: true,
handleActionKeyPerformed: true handleActionKeyPerformed: true
} }
},
{
tableName: 'C_Order',
columnName: 'C_Currency_ID',
isFromDictionary: true,
overwriteDefinition: {
size: 24,
handleActionKeyPerformed: true,
handleActionPerformed: true,
validationCode: 'C_Currency.C_Currency_ID = 100',
isActiveLogics: false,
isMandatory: true
}
},
// TenderType
{
tableName: 'C_Payment',
elementColumnName: 'TenderType',
columnName: 'TenderType',
isFromDictionary: true,
overwriteDefinition: {
defaultValue: 'X',
handleActionKeyPerformed: true,
handleContentSelection: true,
handleActionPerformed: true,
size: 24,
isActiveLogics: false,
isMandatory: true
}
} }
] ]

View File

@ -84,7 +84,7 @@
<i class="el-icon-arrow-down el-icon--right" /> <i class="el-icon-arrow-down el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown" style="padding-bottom: 0px;"> <el-dropdown-menu slot="dropdown" style="padding-bottom: 0px;">
<el-dropdown-item icon="el-icon-info" :command="scope.row"> <el-dropdown-item :command="scope.row">
<el-popover <el-popover
placement="right" placement="right"
trigger="click" trigger="click"
@ -126,12 +126,12 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<el-button slot="reference" type="text"> <el-button slot="reference" type="text" style="display: flex;width: 110%;padding-bottom: 5%;padding-top: 5%;">
{{ $t('form.productInfo.productInformation') }} <i class="el-icon-info" /> {{ $t('form.productInfo.productInformation') }}
</el-button> </el-button>
</el-popover> </el-popover>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item icon="el-icon-edit" :command="$t('form.pos.tableProduct.editQuantities')"> <el-dropdown-item :command="$t('form.pos.tableProduct.editQuantities')">
<el-popover <el-popover
placement="right" placement="right"
trigger="click" trigger="click"
@ -179,7 +179,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-button slot="reference" type="text"> <el-button slot="reference" type="text">
{{ $t('form.pos.tableProduct.editQuantities') }} <i class="el-icon-edit" /> {{ $t('form.pos.tableProduct.editQuantities') }}
</el-button> </el-button>
</el-popover> </el-popover>
</el-dropdown-item> </el-dropdown-item>
@ -444,6 +444,12 @@ export default {
} }
} }
}, },
mounted() {
setTimeout(() => {
this.tenderTypeDisplaye()
this.currencyDisplaye()
}, 1500)
},
methods: { methods: {
changePos(posElement) { changePos(posElement) {
this.$store.dispatch('setCurrentPOS', posElement) this.$store.dispatch('setCurrentPOS', posElement)
@ -503,6 +509,30 @@ export default {
if (!this.seeConversion) { if (!this.seeConversion) {
this.seeConversion = true this.seeConversion = true
} }
},
tenderTypeDisplaye() {
if (!this.isEmptyValue(this.fieldsList)) {
const tenderType = this.fieldsList[5].reference
this.$store.dispatch('getLookupListFromServer', {
tableName: tenderType.tableName,
query: tenderType.query
})
.then(response => {
this.$store.dispatch('tenderTypeDisplaye', response)
})
}
},
currencyDisplaye() {
if (!this.isEmptyValue(this.fieldsList)) {
const currency = this.fieldsList[4].reference
this.$store.dispatch('getLookupListFromServer', {
tableName: currency.tableName,
query: currency.query
})
.then(response => {
this.$store.dispatch('currencyDisplaye', response)
})
}
} }
} }
} }

View File

@ -3,6 +3,7 @@ const tableName = 'C_Order'
export default [ export default [
{ {
tableName, tableName,
elementColumnName: 'DocumentNo',
columnName: 'DocumentNo', columnName: 'DocumentNo',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
@ -12,6 +13,7 @@ export default [
}, },
{ {
tableName, tableName,
elementColumnName: 'C_BPartner_ID',
columnName: 'C_BPartner_ID', columnName: 'C_BPartner_ID',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
@ -22,6 +24,7 @@ export default [
{ {
tableName, tableName,
columnName: 'GrandTotal', columnName: 'GrandTotal',
elementColumnName: 'GrandTotal',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 8, size: 8,
@ -48,7 +51,7 @@ export default [
}, },
{ {
tableName, tableName,
columnName: 'Processed', elementColumnName: 'Processed',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 8, size: 8,
@ -66,7 +69,8 @@ export default [
}, },
{ {
tableName, tableName,
columnName: 'IsInvoiced', elementColumnName: 'IsInvoiced',
columnName: 'IsInvoiced ',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 8, size: 8,
@ -75,6 +79,7 @@ export default [
}, },
{ {
tableName, tableName,
elementColumnName: 'DateOrdered',
columnName: 'DateOrdered', columnName: 'DateOrdered',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
@ -85,7 +90,8 @@ export default [
}, },
{ {
tableName, tableName,
columnName: 'DateOrdered', elementColumnName: 'DateOrdered',
columnName: 'DateOrderedTo',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
columnName: 'DateOrderedTo', columnName: 'DateOrderedTo',
@ -95,6 +101,7 @@ export default [
}, },
{ {
tableName, tableName,
elementColumnName: 'SalesRep_ID',
columnName: 'SalesRep_ID', columnName: 'SalesRep_ID',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {

View File

@ -17,7 +17,14 @@ const collection = {
multiplyRateCollection: 1, multiplyRateCollection: 1,
divideRateCollection: 1, divideRateCollection: 1,
listPayments: [], listPayments: [],
tenderTypeDisplaye: [] tenderTypeDisplaye: [
{
tenderTypeCode: 0,
tenderTypeDisplay: ''
}
],
currency: [],
convertion: {}
}, },
mutations: { mutations: {
addPaymentBox(state, paymentBox) { addPaymentBox(state, paymentBox) {
@ -40,6 +47,12 @@ const collection = {
}, },
setTenderTypeDisplaye(state, tenderTypeDisplaye) { setTenderTypeDisplaye(state, tenderTypeDisplaye) {
state.tenderTypeDisplaye = tenderTypeDisplaye state.tenderTypeDisplaye = tenderTypeDisplaye
},
setCurrencyDisplaye(state, currency) {
state.currency = currency
},
setConvertionPayment(state, convertion) {
state.convertion = convertion
} }
}, },
actions: { actions: {
@ -86,6 +99,38 @@ const collection = {
state.paymentBox = addPayment state.paymentBox = addPayment
} }
}, },
// upload orders to theServer
uploadOrdersToServer({ dispatch }, {
listPaymentsLocal,
posUuid,
orderUuid
}) {
listPaymentsLocal.forEach(payment => {
requestCreatePayment({
posUuid,
orderUuid,
bankUuid: payment.bankUuid,
referenceNo: payment.referenceNo,
description: payment.description,
amount: payment.amount,
paymentDate: payment.paymentDate,
tenderTypeCode: payment.tenderTypeCode,
currencyUuid: payment.currencyUuid
})
.then(response => {
const orderUuid = response.order_uuid
dispatch('listPayments', { orderUuid })
})
.catch(error => {
console.warn(`ListPaymentsFromServer: ${error.message}. Code: ${error.code}.`)
showMessage({
type: 'error',
message: error.message,
showClose: true
})
})
})
},
deleteCollectBox({ state }, key) { deleteCollectBox({ state }, key) {
const payment = state.paymentBox const payment = state.paymentBox
payment.splice(key, 1) payment.splice(key, 1)
@ -224,12 +269,10 @@ const collection = {
orderUuid, orderUuid,
paymentUuid paymentUuid
}) { }) {
console.log(paymentUuid, orderUuid)
requestDeletePayment({ requestDeletePayment({
paymentUuid paymentUuid
}) })
.then(response => { .then(response => {
console.log(response.listPayments)
dispatch('listPayments', { orderUuid }) dispatch('listPayments', { orderUuid })
}) })
.catch(error => { .catch(error => {
@ -241,13 +284,12 @@ const collection = {
}) })
}) })
}, },
listPayments({ commit }, { posUuid, orderUuid }) { listPayments({ commit, rootGetters }, { posUuid, orderUuid }) {
requestListPayments({ requestListPayments({
posUuid, posUuid,
orderUuid orderUuid
}) })
.then(response => { .then(response => {
console.log(response.listPayments)
commit('setListPayments', response.listPayments) commit('setListPayments', response.listPayments)
}) })
.catch(error => { .catch(error => {
@ -267,6 +309,38 @@ const collection = {
} }
}) })
commit('setTenderTypeDisplaye', displayTenderType) commit('setTenderTypeDisplaye', displayTenderType)
},
currencyDisplaye({ commit }, currency) {
const displaycurrency = currency.map(item => {
return {
currencyUuid: item.uuid,
currencyId: item.id,
currencyDisplay: item.label
}
})
commit('setCurrencyDisplaye', displaycurrency)
},
convertionPayment({ commit }, {
conversionTypeUuid,
currencyFromUuid,
currencyToUuid
}) {
requestGetConversionRate({
conversionTypeUuid,
currencyFromUuid,
currencyToUuid
})
.then(response => {
commit('setConvertionPayment', response)
})
.catch(error => {
console.warn(`ConvertionPayment: ${error.message}. Code: ${error.code}.`)
showMessage({
type: 'error',
message: error.message,
showClose: true
})
})
} }
}, },
getters: { getters: {
@ -286,11 +360,16 @@ const collection = {
return state.divideRateCollection return state.divideRateCollection
}, },
getListPayments: (state) => { getListPayments: (state) => {
console.log(state.listPayments)
return state.listPayments return state.listPayments
}, },
getTenderTypeDisplaye: (state) => { getListsPaymentTypes: (state) => {
return state.tenderTypeDisplaye return state.tenderTypeDisplaye
},
getListCurrency: (state) => {
return state.currency
},
getConvertionPayment: (state) => {
return state.convertion
} }
} }
} }

View File

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

View File

@ -251,6 +251,7 @@ export const recursiveTreeSearch = ({
/** /**
* Parsed value to component type * Parsed value to component type
* @author Elsio Sanchez <elsiosanches@gmail.com>
* @param {mixed} value, value to parsed * @param {mixed} value, value to parsed
* @param {string} componentPath * @param {string} componentPath
* @param {number} displayType, reference in ADempiere * @param {number} displayType, reference in ADempiere
@ -358,6 +359,7 @@ export function parsedValueComponent({
/** /**
* add a tab depending on the status of the document * add a tab depending on the status of the document
* @author Elsio Sanchez <elsiosanches@gmail.com>
* @param {string} tag, document status key * @param {string} tag, document status key
*/ */
export function tagStatus(tag) { export function tagStatus(tag) {
@ -405,7 +407,8 @@ export function tagStatus(tag) {
/** /**
* add a tab depending on the status of the document * add a tab depending on the status of the document
* @param {string} tag, document status key * @author Elsio Sanchez <elsiosanches@gmail.com>
* @param {string} iconElment, icon the Elment
*/ */
export function iconStatus(iconElment) { export function iconStatus(iconElment) {
let icon let icon
@ -479,7 +482,51 @@ export function calculationValue(value, event) {
} }
} }
} }
/**
* Search in the currency lists for the current currency
* @author Elsio Sanchez <elsiosanches@gmail.com>
* @param {string} currencyCurrent current currency to search
* @param {array} listCurrency Currency Listing
* @param {object} currencyCurrent Default Currency
*/
export function currencyFind({
currencyCurrent,
listCurrency,
defaultCurrency
}) {
if (!isEmptyValue(listCurrency)) {
const currency = listCurrency.find(item => {
if (item.currencyUuid === currencyCurrent) {
return item
}
})
if (currency) {
return currency
}
}
return defaultCurrency.iSOCode
}
/**
* Search the Payment List for the Current Payment
* @author Elsio Sanchez <elsiosanches@gmail.com>
* @param {string} currentPayment Current Payment
* @param {array} listTypePayment Payment Type Listings
*/
export function tenderTypeFind({
currentPayment,
listTypePayment
}) {
const payment = listTypePayment.find(item => {
if (item.tenderTypeCode === currentPayment) {
return item.tenderTypeDisplay
}
})
if (payment) {
return payment.tenderTypeDisplay
}
return currentPayment
}
export function clearVariables() { export function clearVariables() {
partialValue = '' partialValue = ''
} }