From 60223ecc147223bfde65a105d23437fca872bd59 Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Wed, 3 Feb 2021 00:35:27 -0400 Subject: [PATCH] support for payment methods (#578) --- src/api/ADempiere/form/point-of-sales.js | 108 +++++++++++ .../ADempiere/Form/VPOS/Collection/index.vue | 83 +++++---- .../Form/VPOS/Collection/typeCollection.vue | 43 +++-- .../ADempiere/Form/VPOS/Options/index.vue | 2 + .../ADempiere/Form/VPOS/Order/index.vue | 7 +- .../ADempiere/Form/VPOS/OrderList/index.vue | 3 + .../ADempiere/pointOfSales/collection.js | 170 +++++++++++++++++- src/utils/ADempiere/apiConverts/pos.js | 20 +++ 8 files changed, 382 insertions(+), 54 deletions(-) diff --git a/src/api/ADempiere/form/point-of-sales.js b/src/api/ADempiere/form/point-of-sales.js index f646d142..a98f2927 100644 --- a/src/api/ADempiere/form/point-of-sales.js +++ b/src/api/ADempiere/form/point-of-sales.js @@ -6,6 +6,7 @@ import { /** * method in api/price-checking.js as requestGetProductPrice + * @author elsiosanchez */ export { requestGetProductPrice as findProduct } from '@/api/ADempiere/form/price-checking.js' export { requestGetConversionRate } from '@/api/ADempiere/system-core.js' @@ -435,3 +436,110 @@ export function requestCashClosing({ }) { console.info(`Cash closing with POS id ${posId}, and uuid ${posUuid}`) } + +// Create Payment + +export function requestCreatePayment({ + posUuid, + orderUuid, + invoiceUuid, + bankUuid, + referenceNo, + description, + amount, + paymentDate, + tenderTypeCode, + currencyUuid +}) { + return requestRest({ + url: '/pos/create-payment', + data: { + pos_uuid: posUuid, + order_uuid: orderUuid, + invoice_uuid: invoiceUuid, + bank_uuid: bankUuid, + reference_no: referenceNo, + description: description, + amount: amount, + payment_date: paymentDate, + tender_type_code: tenderTypeCode, + currency_uuid: currencyUuid + } + }) + .then(evaluateResponse) + .then(createPaymentResponse => { + return createPaymentResponse + }) +} + +// Update Payment + +export function requestUpdatePayment({ + paymentUuid, + bankUuid, + referenceNo, + description, + amount, + paymentDate, + tenderTypeCode +}) { + return requestRest({ + url: '/pos/update-payment', + data: { + payment_uuid: paymentUuid, + bank_uuid: bankUuid, + reference_no: referenceNo, + description: description, + amount: amount, + payment_date: paymentDate, + tender_type_code: tenderTypeCode + } + }) + .then(evaluateResponse) + .then(updatePaymentResponse => { + return updatePaymentResponse + }) +} + +// Delete Payment + +export function requestDeletePayment({ + paymentUuid +}) { + return requestRest({ + url: '/pos/delete-payment', + data: { + payment_uuid: paymentUuid + } + }) + .then(evaluateResponse) + .then(deletePaymentResponse => { + return deletePaymentResponse + }) +} + +// List Payments + +export function requestListPayments({ + posUuid, + orderUuid +}) { + return requestRest({ + url: '/pos/list-payments', + data: { + pos_uuid: posUuid, + order_uuid: orderUuid + } + }) + .then(evaluateResponse) + .then(listPaymentsResponse => { + const { paymentsMethod } = require('@/utils/ADempiere/apiConverts/pos.js') + return { + nextPageToken: listPaymentsResponse.next_page_token, + recordCount: listPaymentsResponse.record_count, + listPayments: listPaymentsResponse.records.map(payments => { + return paymentsMethod(payments) + }) + } + }) +} diff --git a/src/components/ADempiere/Form/VPOS/Collection/index.vue b/src/components/ADempiere/Form/VPOS/Collection/index.vue index e44eaed9..2c741ca7 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/index.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/index.vue @@ -81,7 +81,7 @@
{ return pay.isVisible @@ -274,8 +277,8 @@ export default { return payment }, cashPayment() { - const cash = this.isPaymentBox.filter(pay => { - return pay.tenderType === 'X' + const cash = this.listPayments.filter(pay => { + return pay.tenderTypeCode === 'X' }) return this.sumCash(cash) }, @@ -319,9 +322,9 @@ export default { return false }, isCashAmt() { - const cashAmt = this.paymentBox.map(item => { - if (item.tenderType === 'X') { - return item.payAmt + const cashAmt = this.listPayments.map(item => { + if (item.tenderTypeCode === 'X') { + return item.amount } return 0 }) @@ -331,8 +334,8 @@ export default { return 0 }, isOtherPayAmt() { - const cashAmt = this.paymentBox.map(item => { - if (item.tenderType !== 'X') { + const cashAmt = this.listPayments.map(item => { + if (item.tenderTypeCode !== 'X') { return item.payAmt } return 0 @@ -343,7 +346,7 @@ export default { return 0 }, pay() { - return this.sumCash(this.isPaymentBox) + return this.sumCash(this.listPayments) }, pending() { const missing = this.order.grandTotal - this.pay @@ -517,13 +520,18 @@ export default { this.unsubscribe = this.subscribeChanges() this.defaultValueCurrency() }, + mounted() { + setTimeout(() => { + this.tenderTypeDisplaye() + }, 1000) + }, methods: { formatDate, formatPrice, sumCash(cash) { let sum = 0 cash.forEach((pay) => { - sum += pay.payAmt + sum += pay.amount }) return sum }, @@ -533,15 +541,21 @@ export default { }, addCollectToList() { const containerUuid = this.containerUuid + const posUuid = this.$store.getters.getCurrentPOS.uuid + const orderUuid = this.$route.query.action + const bankUuid = this.$store.getters.getValueOfField({ + containerUuid, + columnName: 'C_Bank_ID_UUID' + }) const amount = this.$store.getters.getValueOfField({ containerUuid, columnName: 'PayAmt' }) - const date = this.$store.getters.getValueOfField({ + const paymentDate = this.$store.getters.getValueOfField({ containerUuid, columnName: 'DateTrx' }) - const typePay = this.$store.getters.getValueOfField({ + const tenderTypeCode = this.$store.getters.getValueOfField({ containerUuid, columnName: 'TenderType' }) @@ -549,31 +563,20 @@ export default { containerUuid, columnName: 'ReferenceNo' }) - let currency = this.$store.getters.getValueOfField({ + const currencyUuid = this.$store.getters.getValueOfField({ containerUuid, - columnName: 'DisplayColumn_C_Currency_ID' + columnName: 'C_Currency_ID_UUID' }) - const currencyId = this.$store.getters.getValueOfField({ - containerUuid, - columnName: 'C_Currency_ID' - }) - if (currency === this.currencyPoint.id) { - currency = this.currencyPoint.iSOCode - } - const displayType = this.labelTenderType - this.$store.dispatch('setPaymentBox', { - isVisible: true, - quantityCahs: amount, - payAmt: amount * this.divideRate, - tenderType: typePay, - referenceNo: referenceNo, - dateTrx: date, - currency: { - currency, - id: currencyId - }, - displayTenderType: displayType + this.$store.dispatch('createPayments', { + posUuid, + orderUuid, + bankUuid, + referenceNo, + amount, + paymentDate, + tenderTypeCode, + currencyUuid }) this.addCollect() }, @@ -690,6 +693,18 @@ 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) + }) + } + }, subscribeChanges() { return this.$store.subscribe((mutation, state) => { if (mutation.type === 'updateValueOfField') { diff --git a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue index 011efe06..f613a2b1 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue @@ -3,7 +3,7 @@