diff --git a/src/components/ADempiere/Form/VPOS/Collection/index.vue b/src/components/ADempiere/Form/VPOS/Collection/index.vue index d7eea26c..fa7470b0 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/index.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/index.vue @@ -66,15 +66,25 @@ - + +
@@ -172,6 +182,7 @@ import fieldsListCollection from './fieldsListCollection.js' import typeCollection from '@/components/ADempiere/Form/VPOS/Collection/typeCollection' import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index' import { formatDate, formatPrice } from '@/utils/ADempiere/valueFormat.js' +import { requestProcessOrder } from '@/api/ADempiere/form/point-of-sales.js' export default { name: 'Collection', @@ -449,6 +460,9 @@ export default { }, convert() { return this.$store.getters.getConvertionPayment + }, + updateOrderPaymentPos() { + return this.$store.getters.getUpdatePaymentPos } }, watch: { @@ -744,6 +758,46 @@ export default { paymentUuid }) }, + completePreparedOrder(payment) { + const posUuid = this.$store.getters.getCurrentPOS.uuid + const orderUuid = this.$route.query.action + this.$store.dispatch('updateOrderPos', true) + this.$store.dispatch('updatePaymentPos', true) + this.$message({ + type: 'info', + message: this.$t('notifications.processing'), + showClose: true + }) + requestProcessOrder({ + posUuid, + orderUuid, + createPayments: !this.isEmptyValue(payment), + payments: payment + }) + .then(response => { + this.$store.dispatch('reloadOrder', response.uuid) + this.$message({ + type: 'success', + message: this.$t('notifications.completed'), + showClose: true + }) + }) + .catch(error => { + this.$message({ + type: 'error', + message: error.message, + showClose: true + }) + console.log(error) + }) + .finally(() => { + this.$store.dispatch('listOrdersFromServer', { + posUuid: this.$store.getters.getCurrentPOS.uuid + }) + this.$store.dispatch('updateOrderPos', false) + this.$store.dispatch('updatePaymentPos', false) + }) + }, subscribeChanges() { return this.$store.subscribe((mutation, state) => { if (mutation.type === 'updateValueOfField') { diff --git a/src/components/ADempiere/Form/VPOS/Options/index.vue b/src/components/ADempiere/Form/VPOS/Options/index.vue index 6d69c3ad..97441534 100644 --- a/src/components/ADempiere/Form/VPOS/Options/index.vue +++ b/src/components/ADempiere/Form/VPOS/Options/index.vue @@ -423,6 +423,7 @@ export default { completePreparedOrder() { const posUuid = this.currentPoint.uuid this.$store.dispatch('updateOrderPos', true) + this.$store.dispatch('updatePaymentPos', true) this.$message({ type: 'info', message: this.$t('notifications.processing'), @@ -436,20 +437,26 @@ export default { }) .then(response => { this.$store.dispatch('reloadOrder', response.uuid) + this.$message({ + type: 'success', + message: this.$t('notifications.completed'), + showClose: true + }) }) .catch(error => { + this.$message({ + type: 'error', + message: error.message, + showClose: true + }) console.log(error) }) .finally(() => { this.$store.dispatch('listOrdersFromServer', { posUuid: this.$store.getters.getCurrentPOS.uuid }) - this.$message({ - type: 'success', - message: this.$t('notifications.completed'), - showClose: true - }) this.$store.dispatch('updateOrderPos', false) + this.$store.dispatch('updatePaymentPos', false) }) }, reverseSalesTransaction() { diff --git a/src/store/modules/ADempiere/pointOfSales/payments/actions.js b/src/store/modules/ADempiere/pointOfSales/payments/actions.js index 2be8ecfc..74213995 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/actions.js @@ -241,7 +241,8 @@ export default { }) }) }, - listPayments({ commit, rootGetters }, { posUuid, orderUuid }) { + listPayments({ commit, dispatch }, { posUuid, orderUuid }) { + dispatch('updatePaymentPos', true) requestListPayments({ posUuid, orderUuid @@ -252,6 +253,9 @@ export default { .catch(error => { console.warn(`ListPaymentsFromServer: ${error.message}. Code: ${error.code}.`) }) + .finally(() => { + dispatch('updatePaymentPos', false) + }) }, tenderTypeDisplaye({ commit }, tenderType) { const displayTenderType = tenderType.map(item => { diff --git a/src/store/modules/ADempiere/utils.js b/src/store/modules/ADempiere/utils.js index 51fe3384..06627f62 100644 --- a/src/store/modules/ADempiere/utils.js +++ b/src/store/modules/ADempiere/utils.js @@ -28,7 +28,8 @@ const initStateUtils = { splitWidthRight: 3, splitWidthLeft: 3, parametersProcessPos: [], - updateOrder: false + updateOrder: false, + updatePayment: false } export default { @@ -97,6 +98,9 @@ export default { }, setUpdateOrder(state, order) { state.updateOrder = order + }, + setUpdatePayment(state, payment) { + state.updatePayment = payment } }, actions: { @@ -160,6 +164,9 @@ export default { }, updateOrderPos({ commit }, params) { commit('setUpdateOrder', params) + }, + updatePaymentPos({ commit }, params) { + commit('setUpdatePayment', params) } }, getters: { @@ -229,6 +236,9 @@ export default { }, getUpdateOrderPos: (state) => { return state.updateOrder + }, + getUpdatePaymentPos: (state) => { + return state.updatePayment } } }