{{ $t('form.pos.order.seller') }}: - {{ order.salesRepresentative.name }} + {{ getOrder.salesRepresentative.name }}
-{{ $t('form.pos.order.subTotal') }}:{{ formatPrice(order.totalLines, currencyPoint.iSOCode) }}
+{{ $t('form.pos.order.subTotal') }}:{{ formatPrice(getOrder.totalLines, currencyPoint.iSOCode) }}
{{ $t('form.pos.order.discount') }}:{{ formatPrice(0, currencyPoint.iSOCode) }}
{{ $t('form.pos.order.tax') }}:{{ getOrderTax(currencyPoint.iSOCode) }}
@@ -249,25 +249,25 @@
{{ $t('form.pos.order.order') }}: {{ order.documentNo }}
+{{ $t('form.pos.order.order') }}: {{ getOrder.documentNo }}
{{ $t('form.pos.order.date') }}: {{ orderDate }}
-{{ $t('form.pos.order.type') }}:{{ order.documentType.name }}
+{{ $t('form.pos.order.type') }}:{{ getOrder.documentType.name }}
{{ $t('form.pos.order.itemQuantity') }}
@@ -357,19 +357,22 @@ export default {
if (currentPOS && !this.isEmptyValue(currentPOS.name)) {
return currentPOS
}
- return undefined
+ return {
+ name: '',
+ uuid: ''
+ }
},
sellingPointsList() {
return this.$store.getters.getSellingPointsList
},
orderDate() {
- if (this.isEmptyValue(this.order) || this.isEmptyValue(this.order.dateOrdered)) {
+ if (this.isEmptyValue(this.getOrder) || this.isEmptyValue(this.getOrder.dateOrdered)) {
return this.formatDate(new Date())
}
- return this.formatDate(this.order.dateOrdered)
+ return this.formatDate(this.getOrder.dateOrdered)
},
getItemQuantity() {
- if (this.isEmptyValue(this.currentOrder)) {
+ if (this.isEmptyValue(this.getOrder)) {
return 0
}
const result = this.allOrderLines.map(order => {
@@ -384,7 +387,7 @@ export default {
return 0
},
numberOfLines() {
- if (this.isEmptyValue(this.currentOrder)) {
+ if (this.isEmptyValue(this.getOrder)) {
return
}
return this.allOrderLines.length
@@ -456,7 +459,6 @@ export default {
},
mounted() {
setTimeout(() => {
- this.tenderTypeDisplaye()
this.currencyDisplaye()
}, 1500)
},
@@ -468,14 +470,12 @@ export default {
openCollectionPanel() {
this.isShowedPOSKeyLayout = !this.isShowedPOSKeyLayout
this.$store.commit('setShowPOSCollection', true)
- // this.isShowedPOSKeyLayout = true
const orderUuid = this.$route.query.action
this.$store.dispatch('listPayments', { orderUuid })
this.isShowedPOSKeyLaout = !this.isShowedPOSKeyLaout
this.$store.commit('setShowPOSOptions', false)
},
newOrder() {
- this.$store.dispatch('findOrderServer', {})
this.$router.push({
params: {
...this.$route.params
@@ -486,7 +486,6 @@ export default {
}).catch(() => {
}).finally(() => {
const { templateBusinessPartner } = this.currentPoint
-
this.$store.commit('updateValuesOfContainer', {
containerUuid: this.metadata.containerUuid,
attributes: [{
@@ -510,7 +509,19 @@ export default {
value: templateBusinessPartner.uuid
}]
})
-
+ this.$store.dispatch('setOrder', {
+ documentType: {},
+ documentStatus: {
+ value: ''
+ },
+ totalLines: 0,
+ grandTotal: 0,
+ salesRepresentative: {},
+ businessPartner: {
+ value: '',
+ uuid: ''
+ }
+ })
this.$store.dispatch('listOrderLine', [])
})
},
@@ -522,25 +533,29 @@ export default {
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)
+ if (!this.isEmptyValue(tenderType)) {
+ 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)
+ if (!this.isEmptyValue(currency)) {
+ this.$store.dispatch('getLookupListFromServer', {
+ tableName: currency.tableName,
+ query: currency.query
})
+ .then(response => {
+ this.$store.dispatch('currencyDisplaye', response)
+ })
+ }
}
}
}
diff --git a/src/components/ADempiere/Form/VPOS/OrderList/index.vue b/src/components/ADempiere/Form/VPOS/OrderList/index.vue
index eb71a620..e0aa7fa4 100644
--- a/src/components/ADempiere/Form/VPOS/OrderList/index.vue
+++ b/src/components/ADempiere/Form/VPOS/OrderList/index.vue
@@ -174,7 +174,6 @@ export default {
if (!this.isEmptyValue(order)) {
return order
}
- this.$store.dispatch('listOrderLine', [])
return null
},
isReadyFromGetData() {
@@ -201,14 +200,6 @@ export default {
this.loadOrdersList()
}
},
- mounted() {
- const listOrder = this.$store.getters.getListOrderLine
- if (this.isEmptyValue(listOrder) && !this.isEmptyValue(this.$store.getters.getCurrentPOS.uuid)) {
- this.$store.dispatch('listOrdersFromServer', {
- posUuid: this.$store.getters.getCurrentPOS.uuid
- })
- }
- },
beforeDestroy() {
this.unsubscribe()
},
diff --git a/src/components/ADempiere/Form/VPOS/index.vue b/src/components/ADempiere/Form/VPOS/index.vue
index 652097aa..d5f3bee4 100644
--- a/src/components/ADempiere/Form/VPOS/index.vue
+++ b/src/components/ADempiere/Form/VPOS/index.vue
@@ -123,9 +123,6 @@ export default {
}
this.unsubscribePOSList = this.posListWithOrganization()
- if (!this.isEmptyValue(this.$route.query.action)) {
- this.$store.dispatch('findOrderServer', this.$route.query.action)
- }
},
mounted() {
if (this.isEmptyValue(this.$route.query) || this.isEmptyValue(this.$route.query.pos)) {
diff --git a/src/components/ADempiere/Form/VPOS/posMixin.js b/src/components/ADempiere/Form/VPOS/posMixin.js
index 95aa8e63..f716a553 100644
--- a/src/components/ADempiere/Form/VPOS/posMixin.js
+++ b/src/components/ADempiere/Form/VPOS/posMixin.js
@@ -1,8 +1,5 @@
import {
findProduct,
- requestCreateOrder,
- requestGetOrder,
- requestUpdateOrder,
requestUpdateOrderLine
} from '@/api/ADempiere/form/point-of-sales.js'
import {
@@ -10,7 +7,6 @@ import {
formatPrice,
formatQuantity
} from '@/utils/ADempiere/valueFormat.js'
-// import posProcess from '@/utils/ADempiere/constants/posProcess'
export default {
name: 'POSMixin',
@@ -23,18 +19,6 @@ export default {
data() {
return {
product: {},
- order: {
- documentType: {},
- documentStatus: {
- value: ''
- },
- totalLines: 0,
- grandTotal: 0,
- salesRepresentative: {},
- businessPartner: {
- value: ''
- }
- },
currentTable: 0,
currentOrderLine: {
product: {
@@ -57,9 +41,6 @@ export default {
},
computed: {
allOrderLines() {
- if (this.isEmptyValue(this.listOrderLine)) {
- return []
- }
return this.listOrderLine
},
listOrderLine() {
@@ -75,10 +56,7 @@ export default {
currentOrder() {
const action = this.$route.query.action
if (!this.isEmptyValue(action)) {
- const order = this.ordersList.find(item => item.uuid === action)
- if (!this.isEmptyValue(order)) {
- return order
- }
+ return this.$store.getters.getOrder
}
return {
@@ -90,7 +68,8 @@ export default {
grandTotal: 0,
salesRepresentative: {},
businessPartner: {
- value: ''
+ value: '',
+ uuid: ''
}
}
},
@@ -118,21 +97,39 @@ export default {
},
updateOrderProcessPos() {
return this.$store.getters.getUpdateOrderPos
+ },
+ getOrder() {
+ return this.$store.getters.getOrder
}
},
watch: {
+ getOrder(value) {
+ if (!this.isEmptyValue(value)) {
+ // this.order = value
+ this.$store.commit('updateValuesOfContainer', {
+ parentUuid: this.parentUuid,
+ containerUuid: this.containerUuid,
+ attributes: [{
+ columnName: 'C_BPartner_ID',
+ value: value.businessPartner.id
+ },
+ {
+ columnName: 'DisplayColumn_C_BPartner_ID',
+ value: value.businessPartner.name
+ },
+ {
+ columnName: ' C_BPartner_ID_UUID',
+ value: value.businessPartner.uuid
+ }]
+ })
+ }
+ },
currentOrder(value) {
if (this.isEmptyValue(value)) {
this.orderLines = []
- this.order = {
- documentType: {},
- documentStatus: {},
- salesRepresentative: {}
- }
this.$store.dispatch('listOrderLine', [])
this.listOrderLines({})
} else {
- this.fillOrder(value)
this.listOrderLines(value)
}
},
@@ -157,7 +154,6 @@ export default {
beforeMount() {
if (!this.isEmptyValue(this.currentPoint)) {
if (!this.isEmptyValue(this.currentOrder)) {
- this.fillOrder(this.currentOrder)
this.listOrderLines(this.currentOrder)
}
}
@@ -167,7 +163,6 @@ export default {
this.unsubscribe()
},
mounted() {
- // this.findProcess()
if (!this.isEmptyValue(this.$route.query)) {
this.reloadOrder(true, this.$route.query.action)
}
@@ -203,41 +198,14 @@ export default {
}
},
updateOrder(update) {
- if (this.withoutPOSTerminal()) {
- return
- }
- if (!this.$route.query || this.isEmptyValue(this.$route.query.action)) {
- return
- }
-
- const { uuid: posUuid } = this.currentPoint
-
- let customerUuid
- if (update.columnName === 'C_BPartner_ID_UUID') {
- customerUuid = update.value
- if (this.isEmptyValue(customerUuid) && !this.isEmptyValue(this.currentPoint)) {
- customerUuid = this.currentPoint.templateBusinessPartner.uuid
- }
- }
-
- requestUpdateOrder({
- orderUuid: this.$route.query.action,
- posUuid,
- customerUuid
- // documentTypeUuid: value.value,
- // description
- })
- .then(response => {
- // this.reloadOrder(true)
- })
- .catch(error => {
- console.error(error.message)
- this.$message({
- type: 'error',
- message: error.message,
- showClose: true
- })
+ // user session
+ if (update.value !== this.getOrder.businessPartner.uuid) {
+ this.$store.dispatch('updateOrder', {
+ orderUuid: this.$route.query.action,
+ posUuid: this.currentPoint.uuid,
+ customerUuid: update.value
})
+ }
},
setBusinessPartner({ name, id, uuid }) {
// Use update values of container (without subscription)
@@ -309,50 +277,43 @@ export default {
const orderUuid = this.$route.query.action
if (this.isEmptyValue(orderUuid)) {
const posUuid = this.currentPoint.uuid
-
let customerUuid = this.$store.getters.getValueOfField({
containerUuid: this.containerUuid,
columnName: 'C_BPartner_ID_UUID'
})
- if (this.isEmptyValue(customerUuid)) {
+ const id = this.$store.getters.getValueOfField({
+ containerUuid: this.containerUuid,
+ columnName: 'C_BPartner_ID'
+ })
+ if (this.isEmptyValue(customerUuid) || id === 1000006) {
customerUuid = this.currentPoint.templateBusinessPartner.uuid
}
-
// user session
- const salesRepresentativeUuid = this.$store.getters['user/getUserUuid']
- requestCreateOrder({
+ // alert(name)
+ this.$store.dispatch('createOrder', {
posUuid,
customerUuid,
- salesRepresentativeUuid
+ salesRepresentativeUuid: this.currentPoint.templateBusinessPartner.uuid
})
- .then(order => {
- this.$store.dispatch('currentOrder', order)
- this.fillOrder(order)
-
+ .then(response => {
+ // this.order = response
+ this.reloadOrder(true, response.uuid)
this.$router.push({
params: {
...this.$route.params
},
query: {
...this.$route.query,
- action: order.uuid
+ action: response.uuid
}
}).then(() => {
if (withLine) {
- this.createOrderLine(order.uuid)
+ this.createOrderLine(response.uuid)
}
+ this.$store.dispatch('listOrdersFromServer', {
+ posUuid: this.$store.getters.getCurrentPOS.uuid
+ })
}).catch(() => {})
-
- // update orders list
- this.$store.commit('setIsReloadListOrders')
- })
- .catch(error => {
- console.error(error.message)
- this.$message({
- type: 'error',
- message: error.message,
- showClose: true
- })
})
} else {
this.createOrderLine(orderUuid)
@@ -367,22 +328,8 @@ export default {
}
}
if (!this.isEmptyValue(orderUuid)) {
- requestGetOrder(orderUuid)
- .then(orderResponse => {
- this.$store.dispatch('currentOrder', orderResponse)
- this.fillOrder(orderResponse)
- this.listOrderLines(orderResponse)
- })
- .catch(error => {
- this.$message({
- type: 'error',
- message: error.message,
- showClose: true
- })
- })
+ this.$store.dispatch('reloadOrder', { orderUuid })
}
- } else {
- this.fillOrder(this.currentOrder, false)
}
},
fillOrder(order, setToStore = true) {
@@ -407,7 +354,7 @@ export default {
const { businessPartner } = order
this.setBusinessPartner(businessPartner)
}
- this.order = orderToPush
+ // this.order = orderToPush
},
getOrderTax(currency) {
if (this.isEmptyValue(this.order)) {
@@ -433,16 +380,8 @@ export default {
this.updateOrderLine(mutation.payload)
}
break
- //
- case 'C_DocType_ID':
- this.updateOrder(mutation.payload)
- break
}
} else if (mutation.type === 'updateValueOfField') {
- // if (this.metadata.containerUuid === mutation.payload.containerUuid &&
- // mutation.payload.columnName === 'ProductValue') {
- // this.findProduct(mutation.payload.value)
- // }
switch (mutation.payload.columnName) {
case 'DisplayColumn_TenderType':
this.displayType = mutation.payload.value
diff --git a/src/store/modules/ADempiere/pointOfSales/order.js b/src/store/modules/ADempiere/pointOfSales/order.js
deleted file mode 100644
index 5d06b7d8..00000000
--- a/src/store/modules/ADempiere/pointOfSales/order.js
+++ /dev/null
@@ -1,169 +0,0 @@
-import {
- requestGetOrder,
- requestListOrders
-} from '@/api/ADempiere/form/point-of-sales.js'
-import { isEmptyValue, extractPagingToken } from '@/utils/ADempiere/valueUtils.js'
-import { showMessage } from '@/utils/ADempiere/notification.js'
-
-const withoutResponse = {
- isLoaded: false,
- isReload: true,
- recordCount: 0,
- nextPageToken: undefined
-}
-
-const ordes = {
- state: {
- order: {},
- findOrder: {},
- listOrder: {
- ...withoutResponse,
- isShowPopover: false
- }
- },
- mutations: {
- setOrder(state, order) {
- state.order = order
- },
- setListOrder(state, listOrder) {
- state.listOrder = {
- ...state.listOrder,
- ...listOrder
- }
- },
- setOrdersListPageNumber(state, pageNumber) {
- state.listOrder.pageNumber = pageNumber
- },
- showListOrders(state, isShow) {
- state.listOrder.isShowPopover = isShow
- },
- setIsReloadListOrders(state) {
- state.listOrder.isReload = true
- },
- currentOrder(state, currentOrder) {
- state.currentOrder = currentOrder
- },
- findOrder(state, findOrder) {
- state.findOrder = findOrder
- }
- },
- actions: {
- /**
- * Set page number of pagination list
- * @param {number} pageNumber
- */
- setOrdersListPageNumber({ commit, dispatch }, pageNumber) {
- commit('setOrdersListPageNumber', pageNumber)
- dispatch('listOrdersFromServer', {})
- },
- listOrdersFromServer({ state, commit, getters }, {
- posUuid,
- documentNo,
- businessPartnerUuid,
- grandTotal,
- openAmount,
- isPaid,
- isProcessed,
- isAisleSeller,
- isInvoiced,
- dateOrderedFrom,
- dateOrderedTo,
- salesRepresentativeUuid
- }) {
- if (isEmptyValue(posUuid)) {
- posUuid = getters.getPointOfSalesUuid
- }
-
- let { pageNumber, token } = state.listOrder
- if (isEmptyValue(pageNumber)) {
- pageNumber = 1
- }
- let pageToken
- if (!isEmptyValue(token)) {
- pageToken = token + '-' + pageNumber
- }
- requestListOrders({
- posUuid,
- documentNo,
- businessPartnerUuid,
- grandTotal,
- openAmount,
- isPaid,
- isProcessed,
- isAisleSeller,
- isInvoiced,
- dateOrderedFrom,
- dateOrderedTo,
- salesRepresentativeUuid,
- pageToken
- })
- .then(responseOrdersList => {
- if (isEmptyValue(token) || isEmptyValue(pageToken)) {
- token = extractPagingToken(responseOrdersList.nextPageToken)
- }
-
- commit('setListOrder', {
- ...responseOrdersList,
- isLoaded: true,
- isReload: false,
- posUuid,
- token,
- pageNumber
- })
- })
- .catch(error => {
- console.warn(`listOrdersFromServer: ${error.message}. Code: ${error.code}.`)
- // showMessage({
- // type: 'info',
- // message: error.message,
- // showClose: true
- // })
- })
- },
- setOrder({ commit }, order) {
- commit('setOrder', order)
- },
- currentOrder({ commit }, findOrder) {
- commit('findOrder', findOrder)
- },
- findOrderServer({ commit }, orderUuid) {
- if (typeof orderUuid === 'string' && !isEmptyValue(orderUuid)) {
- requestGetOrder(orderUuid)
- .then(responseOrder => {
- commit('findOrder', responseOrder)
- })
- .catch(error => {
- console.warn(`findOrderServer: ${error.message}. Code: ${error.code}.`)
- showMessage({
- type: 'info',
- message: error.message,
- showClose: true
- })
- })
- }
- commit('findOrder', {})
- }
- },
- getters: {
- getOrder: (state) => {
- return state.order
- },
- getListOrder: (state) => {
- if (isEmptyValue(state.listOrder)) {
- return {
- ...withoutResponse,
- ordersList: []
- }
- }
- return state.listOrder
- },
- getCurrentOrder: (state) => {
- return state.currentOrder
- },
- getFindOrder: (state) => {
- return state.findOrder
- }
- }
-}
-
-export default ordes
diff --git a/src/store/modules/ADempiere/pointOfSales/order/actions.js b/src/store/modules/ADempiere/pointOfSales/order/actions.js
new file mode 100644
index 00000000..7cbbb2cf
--- /dev/null
+++ b/src/store/modules/ADempiere/pointOfSales/order/actions.js
@@ -0,0 +1,263 @@
+import {
+ requestCreateOrder,
+ requestGetOrder,
+ requestUpdateOrder,
+ requestCreateOrderLine,
+ requestListOrders
+} from '@/api/ADempiere/form/point-of-sales.js'
+import { isEmptyValue, extractPagingToken } from '@/utils/ADempiere/valueUtils.js'
+import { showMessage } from '@/utils/ADempiere/notification.js'
+
+/**
+ * Order Actions
+ * @author Elsio Sanchez