Skip to content

Commit

Permalink
upload orders to the server (#579)
Browse files Browse the repository at this point in the history
* upload orders to the server

* support convert currency

* support for currency search, payment types and undoing payment

* change icon
  • Loading branch information
elsiosanchez authored Feb 5, 2021
1 parent 60223ec commit 6f4fc11
Show file tree
Hide file tree
Showing 10 changed files with 391 additions and 113 deletions.
54 changes: 26 additions & 28 deletions src/components/ADempiere/Form/VPOS/BusinessPartner/index.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
<template>
<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>
<template slot="label">
{{ $t('form.pos.order.BusinessPartnerCreate.businessPartner') }}
Expand Down Expand Up @@ -73,6 +45,32 @@
</template>
</el-autocomplete>
</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>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ 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',
isActiveLogics: true,
isMandatory: true
}
},
// TenderType
{
tableName,
Expand Down Expand Up @@ -64,20 +78,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',
isActiveLogics: true,
isMandatory: true
}
},
// ReferenceNo
{
tableName: 'HR_Attribute',
Expand Down
117 changes: 82 additions & 35 deletions src/components/ADempiere/Form/VPOS/Collection/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,8 @@
</div>
</el-card>
<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="info" icon="el-icon-minus" @click="undoPatment" />
<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" />
</samp>
Expand Down Expand Up @@ -228,7 +219,9 @@ export default {
allPayCurrency: 0,
labelTenderType: '',
defaultLabel: '',
fieldsList: fieldsListCollection
fieldsList: fieldsListCollection,
sendToServer: false,
amontSend: 0
}
},
computed: {
Expand Down Expand Up @@ -265,7 +258,12 @@ export default {
return false
},
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() {
const payment = this.isPaymentBox.filter(pay => {
Expand Down Expand Up @@ -451,7 +449,13 @@ export default {
return true
},
fieldpending() {
return this.pending * this.multiplyRateCollection
return this.pending
},
displayCurrency() {
return this.$store.getters.getListCurrency
},
convert() {
return this.$store.getters.getConvertionPayment
}
},
watch: {
Expand Down Expand Up @@ -522,7 +526,7 @@ export default {
},
mounted() {
setTimeout(() => {
this.tenderTypeDisplaye()
this.convertCurrency()
}, 1000)
},
methods: {
Expand All @@ -547,7 +551,7 @@ export default {
containerUuid,
columnName: 'C_Bank_ID_UUID'
})
const amount = this.$store.getters.getValueOfField({
this.amontSend = this.$store.getters.getValueOfField({
containerUuid,
columnName: 'PayAmt'
})
Expand All @@ -567,19 +571,46 @@ export default {
containerUuid,
columnName: 'C_Currency_ID_UUID'
})
this.$store.dispatch('createPayments', {
posUuid,
orderUuid,
bankUuid,
referenceNo,
amount,
paymentDate,
tenderTypeCode,
currencyUuid
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', {
posUuid,
orderUuid,
bankUuid,
referenceNo,
amount: this.amontSend,
paymentDate,
tenderTypeCode,
currencyUuid: this.currencyDisplay(currencyToPay).currencyUuid
})
}
this.amontSend = 0
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() {
this.fieldsList.forEach(element => {
if (element.columnName !== 'PayAmt') {
Expand Down Expand Up @@ -693,17 +724,33 @@ export default {
value: this.$t('form.pos.collect.TenderType.cash')
})
},
tenderTypeDisplaye() {
if (!this.isEmptyValue(this.fieldsList)) {
const tenderType = this.fieldsList[1].reference
this.$store.dispatch('getLookupListFromServer', {
tableName: tenderType.tableName,
query: tenderType.query
})
.then(response => {
this.$store.dispatch('tenderTypeDisplaye', response)
})
currencyDisplay(currency) {
const display = this.displayCurrency.find(item => {
if (item.currencyUuid === currency || (item.currencyId === currency)) {
return item
}
})
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() {
return this.$store.subscribe((mutation, state) => {
Expand Down
74 changes: 54 additions & 20 deletions src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
/>
<div style="padding-right: 10px; padding-top: 10%;">
<div class="top clearfix">
<span>{{ tenderTypeDisplay(value.tenderTypeCode) }}</span>
<span>
{{
tenderTypeFind({
currentPayment: value.tenderTypeCode,
listTypePayment: typesPayment
})
}}
</span>
</div>
<div class="bottom clearfix" style="margin-top: 0px !important!">
<el-button
Expand All @@ -37,17 +44,41 @@
>
{{ formatDate(value.paymentDate) }}
</el-button>

<div slot="header" class="clearfix">
<p class="total" :style="value.currencyUuid === currency.id ? 'padding-top: 5%;' : ''">
<b style="float: right; padding-bottom: 10px">
<div
v-if="currencyFind({
currencyCurrent: value.currencyUuid,
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) }}
</b>
</p>
<br>
<p v-if="value.currencyUuid !== currency.id" class="total">
<b style="float: right; padding-bottom: 10px">
{{ formatPrice(value.quantityCahs) }}
<p class="total">
<b style="float: right;">
{{
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>
</p>
</div>
Expand Down Expand Up @@ -81,9 +112,20 @@ export default {
default: undefined
}
},
data() {
return {
conevertion: 0
}
},
computed: {
label() {
return this.$store.getters.getTenderTypeDisplaye
typesPayment() {
return this.$store.getters.getListsPaymentTypes
},
listCurrency() {
return this.$store.getters.getListCurrency
},
conevertionAmount() {
return this.$store.getters.getConvertionPayment
}
},
methods: {
Expand Down Expand Up @@ -139,16 +181,8 @@ export default {
paymentUuid
})
},
tenderTypeDisplay(payments) {
const display = this.label.find(item => {
if (item.tenderTypeCode === payments) {
return item.tenderTypeDisplay
}
})
if (display) {
return display.tenderTypeDisplay
}
return payments
amountConvertion(payment) {
return payment.amount * this.conevertionAmount.multiplyRate
}
}
}
Expand Down
Loading

0 comments on commit 6f4fc11

Please sign in to comment.