Skip to content

Commit

Permalink
Add support to list document type service (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih authored Jul 13, 2021
1 parent cba9789 commit 80b9e9e
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 98 deletions.
23 changes: 21 additions & 2 deletions src/api/ADempiere/form/point-of-sales.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,10 @@ export function validatePin({
}

/**
* list Warehouse
* list Warehouses
* @param {string} posUuidd - POS UUID reference
*/
export function listWarehouse({
export function listWarehouses({
posUuid
}) {
return request({
Expand All @@ -661,6 +661,25 @@ export function listWarehouse({
})
}

/**
* list Document Types
* @param {string} posUuidd - POS UUID reference
*/
export function listDocumentTypes({
posUuid
}) {
return request({
url: `${config.pointOfSales.endpoint}/available-document-types`,
method: 'get',
params: {
pos_uuid: posUuid
}
})
.then(response => {
return response
})
}

/**
* List Prices
* @param {string} posUuidd - POS UUID reference
Expand Down
81 changes: 0 additions & 81 deletions src/components/ADempiere/Form/VPOS/Order/fieldsListOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,86 +27,5 @@ export default [
handleActionPerformed: true,
handleActionKeyPerformed: true
}
},
{
elementColumnName: 'C_DocType_ID',
tabindex: '2',
isFromDictionary: true,
overwriteDefinition: {
size: 24,
handleActionPerformed: true,
handleContentSelection: true,
handleActionKeyPerformed: true
}
},
{
elementColumnName: 'C_DocTypeTarget_ID',
tabindex: '2',
isFromDictionary: true,
overwriteDefinition: {
size: 24,
handleFocusGained: true,
handleActionPerformed: true,
handleContentSelection: true,
handleActionKeyPerformed: true,
isReadOnly: true
}
}
// {
// elementColumnName: 'PriceEntered',
// columnName: 'PriceEntered',
// tabindex: '3',
// isFromDictionary: true,
// overwriteDefinition: {
// size: 24,
// sequence: 9,
// isReadOnly: true,
// handleActionPerformed: true,
// handleContentSelection: true,
// handleActionKeyPerformed: true
// }
// },
// {
// elementColumnName: 'Discount',
// columnName: 'Discount',
// tabindex: '4',
// isFromDictionary: true,
// overwriteDefinition: {
// size: 24,
// sequence: 10,
// isReadOnly: true,
// handleActionPerformed: true,
// handleContentSelection: true,
// handleActionKeyPerformed: true
// }
// },
// {
// tableName: 'C_Order',
// columnName: 'C_Currency_ID',
// isFromDictionary: true,
// overwriteDefinition: {
// size: 24,
// handleActionKeyPerformed: true,
// handleActionPerformed: true,
// validationCode: 'C_Currency.C_Currency_ID = 100',
// isActiveLogics: false,
// isMandatory: true
// }
// }
// // TenderType
// {
// tableName: 'C_Payment',
// elementColumnName: 'TenderType',
// columnName: 'TenderType',
// isFromDictionary: true,
// overwriteDefinition: {
// defaultValue: 'X',
// handleActionKeyPerformed: true,
// handleContentSelection: true,
// handleActionPerformed: true,
// size: 24,
// isActiveLogics: false,
// isMandatory: true
// }
// }
]
54 changes: 45 additions & 9 deletions src/components/ADempiere/Form/VPOS/Order/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,28 @@
</el-col>
<el-col :span="5" :style="styleTab">
<el-form-item>
<field
:key="fieldsList[2].columnName"
:metadata-field="fieldsList[2]"
:v-model="fieldsList[2].value"
/>
<br>
<el-dropdown
v-if="!isEmptyValue(currentWarehouse)"
trigger="click"
class="info-pos"
@command="changeDocumentType"
>
<span>
<svg-icon icon-class="tree" />
<b style="cursor: pointer"> {{ currentDocumentType.name }} </b>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="item in listDocumentTypes"
:key="item.uuid"
:command="item"
>
{{ item.name }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<br>
</el-form-item>
</el-col>
<el-col :span="isEmptyValue(currentOrder) ? 1 : 4" :style="isShowedPOSKeyLayout ? 'padding: 0px; margin-top: 3.%;' : 'padding: 0px; margin-top: 2.4%;'">
Expand Down Expand Up @@ -262,7 +279,7 @@
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="item in listWarehouse"
v-for="item in listWarehouses"
:key="item.uuid"
:command="item"
>
Expand Down Expand Up @@ -573,7 +590,6 @@ export default {
currentOrder() {
if (this.isEmptyValue(this.currentPointOfSales)) {
return {
documentType: {},
documentStatus: {
value: ''
},
Expand Down Expand Up @@ -619,15 +635,27 @@ export default {
},
currentWarehouse() {
if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.warehouse)) {
return this.$store.getters.getcurrentWarehousePos
return this.$store.getters.getCurrentWarehousePos
}
return {}
},
currentDocumentType() {
if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.documentType)) {
return this.$store.getters.getCurrentDocumentTypePos
}
return {}
},
listWarehouse() {
listWarehouses() {
if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.warehousesList)) {
return this.$store.getters.posAttributes.currentPointOfSales.warehousesList
}
return []
},
listDocumentTypes() {
if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.documentTypesList)) {
return this.$store.getters.posAttributes.currentPointOfSales.documentTypesList
}
return []
}
},
watch: {
Expand Down Expand Up @@ -768,6 +796,14 @@ export default {
}
this.visible = true
},
changeDocumentType(documentType) {
this.attributePin = {
...documentType,
action: 'changeDocumentType',
type: 'actionPos'
}
this.visible = true
},
changePriceList(priceList) {
this.attributePin = {
...priceList,
Expand Down
3 changes: 3 additions & 0 deletions src/components/ADempiere/Form/VPOS/posMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ export default {
case 'changeWarehouse':
this.$store.commit('setCurrentWarehousePos', action)
break
case 'changeDocumentType':
this.$store.commit('setCurrentDocumentTypePos', action)
break
case 'changePriceList':
this.$store.commit('setCurrentPriceList', action)
break
Expand Down
13 changes: 12 additions & 1 deletion src/store/modules/ADempiere/pointOfSales/getters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default {
...state.currentPointOfSales,
listOrder: state.listOrder,
warehousesList: state.warehousesList,
documentTypesList: state.documentTypesList,
pricesList: state.pricesList,
currentPriceList: state.currentPriceList,
currentOrder: {
Expand Down Expand Up @@ -124,11 +125,21 @@ export default {
/**
* Current Warehouse
*/
getcurrentWarehousePos: (state) => {
getCurrentWarehousePos: (state) => {
if (!isEmptyValue(state.currentWarehousePos)) {
return state.currentWarehousePos
}
return {}
},

/**
* Current Document Type
*/
getCurrentDocumentTypePos: (state) => {
if (!isEmptyValue(state.currentDocumentTypePos)) {
return state.currentDocumentTypePos
}
return {}
}
// Current POS, it can be s
}
29 changes: 24 additions & 5 deletions src/store/modules/ADempiere/pointOfSales/point/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import router from '@/router'
import {
listPointOfSales,
listWarehouse,
listWarehouses,
listDocumentTypes,
listPrices,
listCurrencies
} from '@/api/ADempiere/form/point-of-sales.js'
Expand Down Expand Up @@ -61,15 +62,31 @@ export default {
})
})
},
listWarehouseFromServer({ commit }, posUuid) {
listWarehouse({
listWarehousesFromServer({ commit }, posUuid) {
listWarehouses({
posUuid
})
.then(response => {
commit('setWarehousesList', response.records)
})
.catch(error => {
console.warn(`listWarehouseFromServer: ${error.message}. Code: ${error.code}.`)
console.warn(`listWarehousesFromServer: ${error.message}. Code: ${error.code}.`)
showMessage({
type: 'error',
message: error.message,
showClose: true
})
})
},
listDocumentTypesFromServer({ commit }, posUuid) {
listDocumentTypes({
posUuid
})
.then(response => {
commit('setDocumentTypesList', response.records)
})
.catch(error => {
console.warn(`listDocumentTypesFromServer: ${error.message}. Code: ${error.code}.`)
showMessage({
type: 'error',
message: error.message,
Expand Down Expand Up @@ -123,10 +140,12 @@ export default {
}
}, () => {})
state.currenciesList = []
dispatch('listWarehouseFromServer', posToSet.uuid)
dispatch('listWarehousesFromServer', posToSet.uuid)
dispatch('listDocumentTypesFromServer', posToSet.uuid)
dispatch('listCurrenciesFromServer', posToSet.uuid)
dispatch('listPricesFromServer', posToSet)
commit('setCurrentPriceList', posToSet.priceList)
commit('setCurrentDocumentTypePos', posToSet.documentType)
commit('setCurrentWarehousePos', rootGetters['user/getWarehouse'])
commit('resetConversionRate', [])
commit('setIsReloadKeyLayout')
Expand Down
6 changes: 6 additions & 0 deletions src/store/modules/ADempiere/pointOfSales/point/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ export default {
setWarehousesList(state, warehousesList) {
state.warehousesList = warehousesList
},
setDocumentTypesList(state, documentTypesList) {
state.documentTypesList = documentTypesList
},
setCurrentPriceList(state, currentPriceList) {
state.currentPriceList = currentPriceList
},
setCurrentWarehousePos(state, warehouse) {
state.currentWarehousePos = warehouse
},
setCurrentDocumentTypePos(state, documentType) {
state.currentDocumentTypePos = documentType
},
setPricesList(state, pricesList) {
state.pricesList = pricesList
},
Expand Down
2 changes: 2 additions & 0 deletions src/store/modules/ADempiere/pointOfSales/point/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ export default {
},
pointOfSalesList: {},
warehousesList: {},
documentTypesList: {},
pricesList: {},
currentPriceList: {},
currentWarehousePos: {},
currentDocumentTypePos: {},
listCurrency: [],
conversionsList: [],
currentPointOfSales: {},
Expand Down

0 comments on commit 80b9e9e

Please sign in to comment.