diff --git a/src/api/ADempiere/form/point-of-sales.js b/src/api/ADempiere/form/point-of-sales.js index a98f2927..5c9b8643 100644 --- a/src/api/ADempiere/form/point-of-sales.js +++ b/src/api/ADempiere/form/point-of-sales.js @@ -125,18 +125,20 @@ export function requestGetOrder(orderUuid) { // Create order from POS export function requestDeleteOrder({ - posUuid, - customerUuid, - documentTypeUuid, - salesRepresentativeUuid + orderUuid + // posUuid, + // customerUuid, + // documentTypeUuid, + // salesRepresentativeUuid }) { return requestRest({ url: '/pos/delete-order', data: { - pos_uuid: posUuid, - customer_uuid: customerUuid, - document_type_uuid: documentTypeUuid, - sales_representative_uuid: salesRepresentativeUuid + order_uuid: orderUuid + // pos_uuid: posUuid, + // customer_uuid: customerUuid, + // document_type_uuid: documentTypeUuid, + // sales_representative_uuid: salesRepresentativeUuid } }) .then(evaluateResponse) diff --git a/src/components/ADempiere/Dialog/index.vue b/src/components/ADempiere/Dialog/index.vue index 9bc375c0..c09c10e3 100644 --- a/src/components/ADempiere/Dialog/index.vue +++ b/src/components/ADempiere/Dialog/index.vue @@ -10,26 +10,30 @@ close-on-click-modal > {{ modalMetadata.description }}

- - + + { - this.$store.dispatch('selectionProcess', { - action: action, // process metadata - parentUuid: this.parentUuid, - containerUuid: this.containerUuid, - panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) - reportFormat: this.reportExportType, - recordUuidSelection: selection, - isProcessTableSelection: true, - routeToDelete: this.$route - }) - // }) - } else { - this.$store.dispatch('startProcess', { - action: action, // process metadata - parentUuid: this.parentUuid, - isProcessTableSelection: false, - containerUuid: this.containerUuid, - panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) - reportFormat: this.reportExportType, - routeToDelete: this.$route - }) - .catch(error => { - console.warn(error) - }) - } - } else { - this.showNotification({ - type: 'warning', - title: this.$t('notifications.emptyValues'), - name: '' + fieldNotReady.name + '. ', - message: this.$t('notifications.fieldMandatory') + if (this.panelType === 'From') { + this.$store.dispatch('processPos', { + action: action, // process metadata + parentUuid: this.parentUuid, + idProcess: this.$store.getters.getFindOrder.id, + containerUuid: this.containerUuid, + panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) + parametersList: this.$store.getters.getPosParameters }) + .catch(error => { + console.warn(error) + }) + this.closeDialog() + } else { + if (!fieldNotReady) { + this.closeDialog() + const porcesTabla = this.$store.getters.getProcessSelect.processTablaSelection + const selection = this.$store.getters.getProcessSelect + if (porcesTabla) { + // selection.forEach(element => { + this.$store.dispatch('selectionProcess', { + action: action, // process metadata + parentUuid: this.parentUuid, + containerUuid: this.containerUuid, + panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) + reportFormat: this.reportExportType, + recordUuidSelection: selection, + isProcessTableSelection: true, + routeToDelete: this.$route + }) + // }) + } else { + this.$store.dispatch('startProcess', { + action: action, // process metadata + parentUuid: this.parentUuid, + isProcessTableSelection: false, + containerUuid: this.containerUuid, + panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) + reportFormat: this.reportExportType, + routeToDelete: this.$route + }) + .catch(error => { + console.warn(error) + }) + } + } else { + this.showNotification({ + type: 'warning', + title: this.$t('notifications.emptyValues'), + name: '' + fieldNotReady.name + '. ', + message: this.$t('notifications.fieldMandatory') + }) + } } } } diff --git a/src/components/ADempiere/Form/VPOS/Options/index.vue b/src/components/ADempiere/Form/VPOS/Options/index.vue index 144745f1..155118ae 100644 --- a/src/components/ADempiere/Form/VPOS/Options/index.vue +++ b/src/components/ADempiere/Form/VPOS/Options/index.vue @@ -5,7 +5,11 @@
{{ $t('form.pos.optionsPoinSales.title') }} - + @@ -121,6 +125,30 @@

+ + +

+ +
+ {{ $t('form.pos.optionsPoinSales.salesOrder.copyOrderLine') }} +

+
+
+

{ console.info(`VPOS/Options component (New Order): ${error.message}`) }).finally(() => { - const { templateBusinessPartner } = this.currentPOS - + // const { templateBusinessPartner } = this.currentPOS this.$store.commit('updateValuesOfContainer', { containerUuid: this.metadata.containerUuid, attributes: [{ @@ -375,15 +413,15 @@ export default { }, { columnName: 'C_BPartner_ID', - value: templateBusinessPartner.id + value: 1000006 }, { columnName: 'DisplayColumn_C_BPartner_ID', - value: templateBusinessPartner.name + value: 'Cliente Unico' }, { columnName: ' C_BPartner_ID_UUID', - value: templateBusinessPartner.uuid + value: '9f6cf428-9209-11e9-8046-0242ac140002' }] }) @@ -417,9 +455,33 @@ export default { }) }, reverseSalesTransaction() { - // TODO: Add BPartner - requestReverseSalesTransaction({ - orderUuid: this.$route.query.action + const process = this.$store.getters.getProcess(posProcess[1].uuid) + this.$store.dispatch('startProcess', { + action: process, + isProcessTableSelection: false, + containerUuid: process.containerUuid, + parametersList: [ + { + columnName: 'C_Order_ID', + value: this.currentPOS.id + }, + { + columnName: 'Bill_BPartner_ID', + value: this.currentPOS.businessPartner.id + }, + { + columnName: 'IsCancelled', + value: false + }, + { + columnName: 'IsShipConfirm', + value: true + }, + { + columnName: 'C_DocTypeRMA_ID', + value: 'VO' + } + ] }) }, createWithdrawal() { @@ -435,6 +497,25 @@ export default { orderUuid: this.$route.query.action }) }, + showModal(action) { + this.$store.dispatch('setShowDialog', { + type: action.type, + action: { + ...action, + containerUuid: action.uuid + } + }) + }, + copyOrder() { + this.processPos = posProcess[5].uuid + const process = this.$store.getters.getProcess(posProcess[5].uuid) + this.showModal(process) + }, + copyLineOrder() { + this.processPos = posProcess[5].uuid + const process = this.$store.getters.getProcess(posProcess[5].uuid) + this.showModal(process) + }, cashClosing() { const { uuid: posUuid, id: posId } = this.getCurrentPOS requestCashClosing({ @@ -446,7 +527,19 @@ export default { requestDeleteOrder({ orderUuid: this.$route.query.action }) - this.newOrder() + .then(response => { + this.changePos(this.$store.getters.getCurrentPOS) + }) + .finally(() => { + this.$store.dispatch('listOrdersFromServer', { + posUuid: this.$store.getters.getCurrentPOS.uuid + }) + this.$message({ + type: 'success', + message: 'Orden Cancelada', + showClose: true + }) + }) } } } diff --git a/src/components/ADempiere/Form/VPOS/Order/index.vue b/src/components/ADempiere/Form/VPOS/Order/index.vue index 972cdee9..a6a29c05 100644 --- a/src/components/ADempiere/Form/VPOS/Order/index.vue +++ b/src/components/ADempiere/Form/VPOS/Order/index.vue @@ -50,6 +50,7 @@ { - this.tenderTypeDisplaye() - this.currencyDisplaye() - }, 1500) + // setTimeout(() => { + // this.tenderTypeDisplaye() + // this.currencyDisplaye() + // }, 1500) }, methods: { changePos(posElement) { diff --git a/src/components/ADempiere/Form/VPOS/OrderList/index.vue b/src/components/ADempiere/Form/VPOS/OrderList/index.vue index e5d2e202..97a51fa9 100644 --- a/src/components/ADempiere/Form/VPOS/OrderList/index.vue +++ b/src/components/ADempiere/Form/VPOS/OrderList/index.vue @@ -45,7 +45,8 @@ :highlight-current-row="highlightRow" :height="heightTable" @shortkey.native="keyAction" - @current-change="handleCurrentChange" + @current-change="orderPrpcess" + @row-dblclick="handleCurrentChange" > { - this.fillOrder(orderResponse) this.$store.dispatch('currentOrder', orderResponse) + this.fillOrder(orderResponse) this.listOrderLines(orderResponse) }) .catch(error => { @@ -449,7 +474,6 @@ export default { this.$refs.linesTable.setCurrentRow(this.listOrderLine[0]) }, shortcutKeyMethod(event) { - console.log(event.srcKey) switch (event.srcKey) { // case 'options': case 'up': @@ -499,6 +523,11 @@ export default { }) break } + }, + findProcess(processPos) { + processPos.forEach(item => { + this.$store.dispatch('getProcessFromServer', { containerUuid: item.uuid }) + }) } } } diff --git a/src/lang/ADempiere/en.js b/src/lang/ADempiere/en.js index c1fd3300..9ab1b1b6 100644 --- a/src/lang/ADempiere/en.js +++ b/src/lang/ADempiere/en.js @@ -346,7 +346,9 @@ export default { cancelSaleTransaction: 'Cancel Sale Transaction', createPos: 'Create Point of Sale Withdrawal', print: 'Print Document', - cancelOrder: 'Cancel Order' + cancelOrder: 'Cancel Order', + copyOrderLine: 'Copy Order Lines', + copyOrder: 'Copy Order' }, cashManagement: { title: 'Cash Management', diff --git a/src/lang/ADempiere/es.js b/src/lang/ADempiere/es.js index ccfb1471..f9cdac55 100644 --- a/src/lang/ADempiere/es.js +++ b/src/lang/ADempiere/es.js @@ -321,7 +321,9 @@ export default { cancelSaleTransaction: 'Anular Transacción de Venta', createPos: 'Crear Retiro de Punto de Venta', print: 'Imprimir Documento', - cancelOrder: 'Cancelar Orden' + cancelOrder: 'Cancelar Orden', + copyOrderLine: 'Copiar Lineas de la Orden', + copyOrder: 'Copiar Orden' }, cashManagement: { title: 'Gestión de Caja', diff --git a/src/store/modules/ADempiere/pointOfSales/collection.js b/src/store/modules/ADempiere/pointOfSales/collection.js index f5ac4cea..91673287 100644 --- a/src/store/modules/ADempiere/pointOfSales/collection.js +++ b/src/store/modules/ADempiere/pointOfSales/collection.js @@ -294,11 +294,6 @@ const collection = { }) .catch(error => { console.warn(`ListPaymentsFromServer: ${error.message}. Code: ${error.code}.`) - showMessage({ - type: 'error', - message: error.message, - showClose: true - }) }) }, tenderTypeDisplaye({ commit }, tenderType) { diff --git a/src/store/modules/ADempiere/pointOfSales/index.js b/src/store/modules/ADempiere/pointOfSales/index.js index ad045526..0f2794ea 100644 --- a/src/store/modules/ADempiere/pointOfSales/index.js +++ b/src/store/modules/ADempiere/pointOfSales/index.js @@ -10,6 +10,7 @@ const withoutResponse = { isLoaded: false, isReload: true, recordCount: 0, + currentPOS: {}, nextPageToken: undefined } @@ -58,7 +59,6 @@ const pointOfSales = { ...response, userUuid }) - const posList = response.sellingPointsList const getterPos = getters.getPointOfSalesUuid let pos @@ -138,14 +138,21 @@ const pointOfSales = { // current pos info getCurrentPOS: (state, getters) => { const userUuid = getters['user/getUserUuid'] - const sellingPointsList = state.pointOfSales.sellingPointsList.length - if (sellingPointsList > 1) { - return state.pointOfSales.sellingPointsList.find(elem => elem.salesRepresentative.uuid === userUuid) + let currentPOS + const sellingPointsList = state.pointOfSales.sellingPointsList + if (!isEmptyValue(sellingPointsList) && (sellingPointsList.length > 1)) { + currentPOS = state.pointOfSales.sellingPointsList.find(elem => elem.salesRepresentative.uuid === userUuid) } - if (isEmptyValue(state.pointOfSales)) { - return undefined + if (!isEmptyValue(currentPOS)) { + return currentPOS } - return state.pointOfSales.currentPOS + if (isEmptyValue(state.pointOfSales.currentPOS) && (!isEmptyValue(sellingPointsList))) { + return state.pointOfSales.sellingPointsList[0] + } + if (state.pointOfSales.currentPOS) { + return state.pointOfSales.currentPOS + } + return undefined }, getSellingPointsList: (state, getters) => { return getters.getPointOfSales.sellingPointsList diff --git a/src/store/modules/ADempiere/pointOfSales/order.js b/src/store/modules/ADempiere/pointOfSales/order.js index ed1b0d59..78d007ca 100644 --- a/src/store/modules/ADempiere/pointOfSales/order.js +++ b/src/store/modules/ADempiere/pointOfSales/order.js @@ -124,8 +124,8 @@ const ordes = { setOrder({ commit }, order) { commit('setOrder', order) }, - currentOrder({ commit }, current) { - commit('findOrder', current) + currentOrder({ commit }, findOrder) { + commit('findOrder', findOrder) }, findOrderServer({ commit }, orderUuid) { if (typeof orderUuid === 'string' && !isEmptyValue(orderUuid)) { diff --git a/src/store/modules/ADempiere/process/actions.js b/src/store/modules/ADempiere/process/actions.js index 518a65a3..ee9cb3a9 100644 --- a/src/store/modules/ADempiere/process/actions.js +++ b/src/store/modules/ADempiere/process/actions.js @@ -147,7 +147,7 @@ export default { processResult = { ...processResult, menuParentUuid, - processIdPath: routeToDelete.path, + processIdPath: isEmptyValue(routeToDelete) ? '' : routeToDelete.path, printFormatUuid: action.printFormatUuid, // process attributes action: processDefinition.name, @@ -1137,5 +1137,153 @@ export default { if (!isEmptyValue(reportFormat)) { commit('changeFormatReport', reportFormat) } + }, + /** + * Ejecutar Procesos del POS + */ + processPos({ commit, state, dispatch, getters, rootGetters }, { + parentUuid, + containerUuid, + panelType, + action, + parametersList, + idProcess, + isActionDocument, + menuParentUuid, + routeToDelete + }) { + return new Promise((resolve, reject) => { + const processDefinition = !isEmptyValue(isActionDocument) ? action : rootGetters.getProcess(action.uuid) + if (isEmptyValue(parametersList)) { + parametersList = rootGetters.getParametersToServer({ + containerUuid: processDefinition.uuid + }) + } + + const isSession = !isEmptyValue(getToken()) + let procesingMessage = { + close: () => false + } + if (isSession) { + procesingMessage = showNotification({ + title: language.t('notifications.processing'), + message: processDefinition.name, + summary: processDefinition.description, + type: 'info' + }) + } + const timeInitialized = (new Date()).getTime() + let processResult = { + // panel attributes from where it was executed + parentUuid, + containerUuid, + panelType, + lastRun: timeInitialized, + parametersList, + logs: [], + isError: false, + isProcessing: true, + summary: '', + resultTableName: '', + output: { + uuid: '', + name: '', + description: '', + fileName: '', + output: '', + outputStream: '', + reportType: '' + } + } + if (!isEmptyValue(isActionDocument)) { + processResult = { + ...processResult, + processUuid: action.uuid, + processId: action.id, + processName: 'Procesar Orden', + parameters: parametersList + } + } else { + // Run process on server and wait for it for notify + // uuid of process + processResult = { + ...processResult, + menuParentUuid, + processIdPath: isEmptyValue(routeToDelete) ? '' : routeToDelete.path, + printFormatUuid: action.printFormatUuid, + // process attributes + action: processDefinition.name, + name: processDefinition.name, + description: processDefinition.description, + instanceUuid: '', + processUuid: processDefinition.uuid, + processId: processDefinition.id, + processName: processDefinition.processName, + parameters: parametersList, + isReport: processDefinition.isReport + } + } + commit('addInExecution', processResult) + requestRunProcess({ + uuid: processDefinition.uuid, + recordId: idProcess, + parametersList + }) + .then(runProcessResponse => { + const { output } = runProcessResponse + let logList = [] + if (!isEmptyValue(runProcessResponse.logsList)) { + logList = runProcessResponse.logsList + } + + const link = { + href: undefined, + download: undefined + } + // assign new attributes + Object.assign(processResult, { + ...runProcessResponse, + url: link.href, + download: link.download, + logs: logList, + output + }) + resolve(processResult) + if (!isEmptyValue(processResult.output)) { + dispatch('setReportTypeToShareLink', processResult.output.reportType) + } + }) + .catch(error => { + Object.assign(processResult, { + isError: true, + message: error.message, + isProcessing: false + }) + console.warn(`Error running the process ${error.message}. Code: ${error.code}.`) + reject(error) + }) + .finally(() => { + commit('addNotificationProcess', processResult) + dispatch('finishProcess', { + processOutput: processResult, + procesingMessage, + routeToDelete + }) + + commit('deleteInExecution', { + containerUuid + }) + + dispatch('setProcessTable', { + valueRecord: 0, + tableName: '', + processTable: false + }) + dispatch('setProcessSelect', { + finish: true + }) + dispatch('updateOrderPos', true) + }) + }) } } diff --git a/src/store/modules/ADempiere/utils.js b/src/store/modules/ADempiere/utils.js index e4379cf9..51fe3384 100644 --- a/src/store/modules/ADempiere/utils.js +++ b/src/store/modules/ADempiere/utils.js @@ -26,7 +26,9 @@ const initStateUtils = { isLoaded: false }, splitWidthRight: 3, - splitWidthLeft: 3 + splitWidthLeft: 3, + parametersProcessPos: [], + updateOrder: false } export default { @@ -89,6 +91,12 @@ export default { }, setSplitWidthLeft(state, splitWidthLeft) { state.splitWidthLeft = splitWidthLeft + }, + parametersProcessPos(state, params) { + state.parametersProcessPos = params + }, + setUpdateOrder(state, order) { + state.updateOrder = order } }, actions: { @@ -146,6 +154,12 @@ export default { }, changeWidthLeft({ commit }, newWidthLeft) { commit('setSplitWidthLeft', newWidthLeft) + }, + addParametersProcessPos({ commit }, params) { + commit('parametersProcessPos', params) + }, + updateOrderPos({ commit }, params) { + commit('setUpdateOrder', params) } }, getters: { @@ -209,6 +223,12 @@ export default { }, getWidthLeft: (state) => { return state.splitWidthLeft + }, + getPosParameters: (state) => { + return state.parametersProcessPos + }, + getUpdateOrderPos: (state) => { + return state.updateOrder } } } diff --git a/src/utils/ADempiere/constants/posProcess.js b/src/utils/ADempiere/constants/posProcess.js new file mode 100644 index 00000000..8b0ac92c --- /dev/null +++ b/src/utils/ADempiere/constants/posProcess.js @@ -0,0 +1,27 @@ +const posProcess = [ + { + name: 'C_POS Generate Immediate Invoice', + uuid: 'a42cce58-fb40-11e8-a479-7a0060f0aa01' + }, + { + name: 'C_POS ReverseTheSalesTransaction', + uuid: 'a42ccebc-fb40-11e8-a479-7a0060f0aa01' + }, + { + name: 'C_POS CreateOrderBasedOnAnother', + uuid: 'a42ccc46-fb40-11e8-a479-7a0060f0aa01' + }, + { + name: 'C_POS Withdrawal', + uuid: 'a42ce0a0-fb40-11e8-a479-7a0060f0aa01' + }, + { + name: 'C_POS Bank Statement Close', + uuid: 'a42ce118-fb40-11e8-a479-7a0060f0aa01' + }, + { + name: 'C_Order CopyFrom', + uuid: 'a42ad0c6-fb40-11e8-a479-7a0060f0aa01' + } +] +export default posProcess diff --git a/src/views/ADempiere/Form/index.vue b/src/views/ADempiere/Form/index.vue index b4fc11a2..4e6f400b 100644 --- a/src/views/ADempiere/Form/index.vue +++ b/src/views/ADempiere/Form/index.vue @@ -9,6 +9,11 @@ v-if="showContextMenu" style="height: 39px; background: white;" > + import ContextMenu from '@/components/ADempiere/ContextMenu' import FormPanel from '@/components/ADempiere/Form' +import ModalDialog from '@/components/ADempiere/Dialog' export default { name: 'FormView', components: { ContextMenu, - FormPanel + FormPanel, + ModalDialog }, data() { return {