Skip to content

Commit

Permalink
add complete order from collection (#626)
Browse files Browse the repository at this point in the history
Co-authored-by: Elsio Sanchez <elsiosanche@gmail.com>
  • Loading branch information
elsiosanchez and Elsio Sanchez committed Mar 3, 2021
1 parent f2614f7 commit a1bc8bb
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 8 deletions.
56 changes: 55 additions & 1 deletion src/components/ADempiere/Form/VPOS/Collection/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,25 @@
<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" />
<el-button type="success" :disabled="validateCompleteCollection" icon="el-icon-shopping-cart-full" @click="completePreparedOrder(listPayments)" />
</samp>
</el-header>
<el-main style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">
<type-collection
v-if="!updateOrderPaymentPos"
:is-add-type-pay="listPayments"
:currency="currencyPoint"
:list-types-payment="fieldsList[2]"
/>
<div
v-else
key="form-loading"
v-loading="updateOrderPaymentPos"
:element-loading-text="$t('notifications.loading')"
:element-loading-spinner="'el-icon-loading'"
element-loading-background="rgba(255, 255, 255, 0.8)"
class="view-loading"
/>
</el-main>

<el-footer height="auto" style="padding-left: 0px; padding-right: 0px;">
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -449,6 +460,9 @@ export default {
},
convert() {
return this.$store.getters.getConvertionPayment
},
updateOrderPaymentPos() {
return this.$store.getters.getUpdatePaymentPos
}
},
watch: {
Expand Down Expand Up @@ -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') {
Expand Down
17 changes: 12 additions & 5 deletions src/components/ADempiere/Form/VPOS/Options/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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() {
Expand Down
6 changes: 5 additions & 1 deletion src/store/modules/ADempiere/pointOfSales/payments/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ export default {
})
})
},
listPayments({ commit, rootGetters }, { posUuid, orderUuid }) {
listPayments({ commit, dispatch }, { posUuid, orderUuid }) {
dispatch('updatePaymentPos', true)
requestListPayments({
posUuid,
orderUuid
Expand All @@ -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 => {
Expand Down
12 changes: 11 additions & 1 deletion src/store/modules/ADempiere/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const initStateUtils = {
splitWidthRight: 3,
splitWidthLeft: 3,
parametersProcessPos: [],
updateOrder: false
updateOrder: false,
updatePayment: false
}

export default {
Expand Down Expand Up @@ -97,6 +98,9 @@ export default {
},
setUpdateOrder(state, order) {
state.updateOrder = order
},
setUpdatePayment(state, payment) {
state.updatePayment = payment
}
},
actions: {
Expand Down Expand Up @@ -160,6 +164,9 @@ export default {
},
updateOrderPos({ commit }, params) {
commit('setUpdateOrder', params)
},
updatePaymentPos({ commit }, params) {
commit('setUpdatePayment', params)
}
},
getters: {
Expand Down Expand Up @@ -229,6 +236,9 @@ export default {
},
getUpdateOrderPos: (state) => {
return state.updateOrder
},
getUpdatePaymentPos: (state) => {
return state.updatePayment
}
}
}

0 comments on commit a1bc8bb

Please sign in to comment.