1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 12:01:57 +08:00

validate terminal configurator (#1082)

* Add validation for the pin according to the configuration of the terminal of the point of sale

* validate advisor options

* validate terminal configurator

* add pin to Return Order

* remove console

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-08-19 08:00:17 -04:00 committed by GitHub
parent 0bffaa6699
commit 6f20050745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 345 additions and 109 deletions

View File

@ -906,7 +906,7 @@ export function listCurrencies({
* Tender Type * Tender Type
* @param {string} posUuidd - POS UUID reference * @param {string} posUuidd - POS UUID reference
*/ */
export function listTenderType({ export function listTenderTypes({
posUuid posUuid
}) { }) {
return request({ return request({

View File

@ -91,6 +91,26 @@ export default {
unsubscribe: () => {} unsubscribe: () => {}
} }
}, },
computed: {
adviserPin() {
const value = this.$store.getters.getValueOfField({
containerUuid: this.containerUuid,
columnName: 'Value'
})
const name = this.$store.getters.getValueOfField({
containerUuid: this.containerUuid,
columnName: 'Name'
})
const isSeller = this.$store.getters.posAttributes.currentPointOfSales.isAisleSeller
if (!this.isEmptyValue(value) && !this.isEmptyValue(name) && isSeller) {
return isSeller
}
return false
},
currentPointOfSales() {
return this.$store.getters.posAttributes.currentPointOfSales
}
},
watch: { watch: {
showField(value) { showField(value) {
if (value) { if (value) {
@ -123,7 +143,7 @@ export default {
containerUuid: this.containerUuid, containerUuid: this.containerUuid,
formatReturn: 'name' formatReturn: 'name'
}) })
if (this.isEmptyValue(emptyMandatoryFields)) { if (this.isEmptyValue(emptyMandatoryFields) || this.adviserPin) {
this.isLoadingRecord = true this.isLoadingRecord = true
createCustomer(values) createCustomer(values)
.then(responseBPartner => { .then(responseBPartner => {

View File

@ -199,6 +199,8 @@
</b> </b>
</p> </p>
<p v-if="!isEmptyValue(currentPointOfSales.displayCurrency)" class="total"> <b> {{ $t('form.pos.collect.convertedAmount') }}: </b> <b style="float: right;">{{ formatPrice(currentOrder.grandTotal / totalAmountConverted, currentPointOfSales.displayCurrency.iso_code) }}</b> </p>
<p class="total"> <p class="total">
{{ $t('form.pos.collect.pending') }}: {{ $t('form.pos.collect.pending') }}:
<b style="float: right;"> <b style="float: right;">
@ -477,6 +479,13 @@ export default {
} }
return true return true
}, },
isPosRequiredPin() {
const pos = this.$store.getters.posAttributes.currentPointOfSales
if (!this.isEmptyValue(pos.isPosRequiredPin)) {
return pos.isPosRequiredPin
}
return false
},
validPay() { validPay() {
const containerUuid = this.containerUuid const containerUuid = this.containerUuid
// filter by visible fields // filter by visible fields
@ -582,6 +591,21 @@ export default {
}, },
overUnderPayment() { overUnderPayment() {
return this.$store.state['pointOfSales/payments/index'].dialogoInvoce.success return this.$store.state['pointOfSales/payments/index'].dialogoInvoce.success
},
totalAmountConverted() {
const conversionsList = this.$store.state['pointOfSales/point/index'].conversionsList
if (this.isEmptyValue(conversionsList) && !this.isEmptyValue(this.currentPointOfSales.conversionTypeUuid)) {
return 1
}
const converted = conversionsList.find(converted => {
if (converted.conversionTypeUuid === this.currentPointOfSales.conversionTypeUuid) {
return converted
}
})
if (!this.isEmptyValue(converted)) {
return converted.divideRate
}
return 1
} }
}, },
watch: { watch: {
@ -900,6 +924,17 @@ export default {
if (this.pay > this.currentOrder.grandTotal) { if (this.pay > this.currentOrder.grandTotal) {
this.$store.commit('dialogoInvoce', { show: true, type: 1 }) this.$store.commit('dialogoInvoce', { show: true, type: 1 })
} else if (this.pay < this.currentOrder.grandTotal) { } else if (this.pay < this.currentOrder.grandTotal) {
if (this.isPosRequiredPin) {
const attributePin = {
...payment,
action: 'openBalanceInvoice',
type: 'actionPos',
label: this.$t('form.pos.pinMessage.invoiceOpen')
}
this.visible = true
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
return
}
this.$store.commit('dialogoInvoce', { show: true, type: 2 }) this.$store.commit('dialogoInvoce', { show: true, type: 2 })
} else { } else {
this.completePreparedOrder(payment) this.completePreparedOrder(payment)

View File

@ -21,7 +21,7 @@
:title="$t('form.pos.collect.overdrawnInvoice.title')" :title="$t('form.pos.collect.overdrawnInvoice.title')"
:visible.sync="showDialogo" :visible.sync="showDialogo"
:before-close="close" :before-close="close"
width="70%" width="80%"
@close="close" @close="close"
> >
<div v-if="caseOrder === 1"> <div v-if="caseOrder === 1">
@ -61,6 +61,9 @@
<el-card v-if="option === 3" class="box-card"> <el-card v-if="option === 3" class="box-card">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>{{ $t('form.pos.collect.overdrawnInvoice.above') }}</span> <span>{{ $t('form.pos.collect.overdrawnInvoice.above') }}</span>
<span style="float: right">
<b>Limite Diario USD 20,00$ = Bs.S 85.000.000,00 </b> | <b>Disponible Bs.S 85.000.000,00 </b>
</span>
</div> </div>
<div class="text item"> <div class="text item">
<el-form <el-form
@ -78,6 +81,22 @@
:metadata-field="field" :metadata-field="field"
/> />
</el-col> </el-col>
<el-col :span="8">
<el-form-item label="Tipo de pago">
<el-select
v-model="currentPaymentType"
style="width: -webkit-fill-available;"
@change="changePaymentType"
>
<el-option
v-for="item in paymentTypeList"
:key="item.uuid"
:label="item.name"
:value="item.key"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item v-if="displayeCurrency" :label="$t('form.pos.collect.Currency')"> <el-form-item v-if="displayeCurrency" :label="$t('form.pos.collect.Currency')">
<el-select <el-select
@ -193,7 +212,8 @@ export default {
return { return {
option: 1, option: 1,
fieldsList: fieldsListOverdrawnInvoice, fieldsList: fieldsListOverdrawnInvoice,
currentFieldCurrency: '' currentFieldCurrency: '',
currentPaymentType: ''
} }
}, },
computed: { computed: {
@ -214,7 +234,7 @@ export default {
return false return false
}, },
primaryFieldsList() { primaryFieldsList() {
return this.fieldsList.filter(field => field.sequence <= 3) return this.fieldsList.filter(field => field.sequence <= 2)
}, },
hiddenFieldsList() { hiddenFieldsList() {
return this.fieldsList.filter(field => field.sequence > 4) return this.fieldsList.filter(field => field.sequence > 4)
@ -237,6 +257,9 @@ export default {
}, },
emptyMandatoryFields() { emptyMandatoryFields() {
return this.$store.getters.getFieldsListEmptyMandatory({ containerUuid: 'OverdrawnInvoice', formatReturn: 'name' }) return this.$store.getters.getFieldsListEmptyMandatory({ containerUuid: 'OverdrawnInvoice', formatReturn: 'name' })
},
paymentTypeList() {
return this.$store.getters.getPaymentTypeList
} }
}, },
methods: { methods: {
@ -266,6 +289,15 @@ export default {
changeCurrency(value) { changeCurrency(value) {
this.currentFieldCurrency = value this.currentFieldCurrency = value
}, },
changePaymentType(value) {
this.$store.commit('currentTenderChange', value)
this.currentPaymentType = value
this.$store.commit('updateValueOfField', {
containerUuid: 'OverdrawnInvoice',
columnName: 'TenderType',
value: value
})
},
optionSelected({ posUuid, orderUuid, customerDetails, payments }) { optionSelected({ posUuid, orderUuid, customerDetails, payments }) {
switch (this.option) { switch (this.option) {
case 2: case 2:

View File

@ -34,7 +34,7 @@
<el-card shadow="hover"> <el-card shadow="hover">
<p <p
style="cursor: pointer; text-align: center !important; color: black;min-height: 50px;" style="cursor: pointer; text-align: center !important; color: black;min-height: 50px;"
@click="newOrder" @click="allowsCreateOrder ? '' : newOrder"
> >
<i class="el-icon-news" /> <i class="el-icon-news" />
<br> <br>
@ -90,7 +90,7 @@
<el-card shadow="hover"> <el-card shadow="hover">
<p <p
:style="blockOption" :style="blockOption"
@click="completePreparedOrder" @click="adviserPin ? '' : completePreparedOrder"
> >
<i class="el-icon-success" /> <i class="el-icon-success" />
<br> <br>
@ -103,7 +103,7 @@
<el-card shadow="hover"> <el-card shadow="hover">
<p <p
:style="blockOption" :style="blockOption"
@click="reverseSalesTransaction" @click="adviserPin ? '' : reverseSalesTransaction"
> >
<i class="el-icon-error" /> <i class="el-icon-error" />
<br> <br>
@ -129,7 +129,7 @@
<el-card shadow="hover"> <el-card shadow="hover">
<p <p
:style="blockOption" :style="blockOption"
@click="printOrder" @click="adviserPin ? '' : printOrder"
> >
<i class="el-icon-printer" /> <i class="el-icon-printer" />
<br> <br>
@ -137,8 +137,7 @@
</p> </p>
</el-card> </el-card>
</el-col> </el-col>
<el-col v-if="allowsReturnOrder" :span="size" style="padding-left: 12px;padding-right: 12px;padding-bottom: 10px;">
<el-col :span="size" style="padding-left: 12px;padding-right: 12px;padding-bottom: 10px;">
<el-card shadow="hover"> <el-card shadow="hover">
<p <p
:style="blockOption" :style="blockOption"
@ -278,7 +277,7 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item <el-dropdown-item
v-for="item in warehousesListPointOfSales" v-for="item in warehousesListPointOfSales"
:key="item.uuid" :key="item.id"
:command="item" :command="item"
> >
{{ item.name }} {{ item.name }}
@ -357,6 +356,15 @@ export default {
} }
}, },
computed: { computed: {
allowsReturnOrder() {
return this.$store.getters.posAttributes.currentPointOfSales.isAllowsReturnOrder
},
allowsCreateOrder() {
if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.isAllowsCreateOrder)) {
return this.$store.getters.posAttributes.currentPointOfSales.isAllowsCreateOrder
}
return false
},
isShowProductsPriceList: { isShowProductsPriceList: {
get() { get() {
return this.$store.state['pointOfSales/point/index'].productPrice.isShowPopoverMenu return this.$store.state['pointOfSales/point/index'].productPrice.isShowPopoverMenu
@ -380,7 +388,13 @@ export default {
} }
} }
}, },
adviserPin() {
return this.$store.getters.posAttributes.currentPointOfSales.isAisleSeller
},
blockOption() { blockOption() {
if (this.adviserPin) {
return 'cursor: not-allowed; text-align: center !important; color: gray;min-height: 50px;'
}
if (!this.isEmptyValue(this.currentOrder.uuid)) { if (!this.isEmptyValue(this.currentOrder.uuid)) {
return 'cursor: pointer; text-align: center !important; color: black;min-height: 50px;' return 'cursor: pointer; text-align: center !important; color: black;min-height: 50px;'
} }
@ -536,9 +550,11 @@ export default {
}) })
}, },
createNewCustomerReturnOrder() { createNewCustomerReturnOrder() {
createNewReturnOrder({ if (this.isPosRequiredPin) {
orderUuid: this.$route.query.action createNewReturnOrder({
}) orderUuid: this.$route.query.action
})
}
}, },
showModal(action) { showModal(action) {
this.$store.dispatch('setShowDialog', { this.$store.dispatch('setShowDialog', {

View File

@ -91,7 +91,7 @@
</el-tag> </el-tag>
</el-col> </el-col>
<el-col :span="14" style="padding-left: 0px; padding-right: 0px;"> <el-col :span="14" style="padding-left: 0px; padding-right: 0px;">
<el-button type="primary" plain @click="newOrder"> <el-button type="primary" :disabled="allowsCreateOrder" plain @click="newOrder">
{{ $t('form.pos.optionsPoinSales.salesOrder.newOrder') }} {{ $t('form.pos.optionsPoinSales.salesOrder.newOrder') }}
</el-button> </el-button>
</el-col> </el-col>
@ -148,7 +148,7 @@
label-position="top" label-position="top"
style="float: right;display: contents;line-height: 30px;" style="float: right;display: contents;line-height: 30px;"
> >
<el-row :gutter="24"> <el-row>
<el-col :span="4"> <el-col :span="4">
<div> <div>
<el-avatar v-if="isEmptyValue(scope.row.product.imageUrl)" shape="square" :size="100" src="https://#" @error="true"> <el-avatar v-if="isEmptyValue(scope.row.product.imageUrl)" shape="square" :size="100" src="https://#" @error="true">
@ -206,7 +206,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-main> </el-main>
<el-dialog ref="dialog" :title="$t('form.pos.tableProduct.pin')" width="30%" :visible.sync="visible"> <el-dialog ref="dialog" :title="$t('form.pos.pinMessage.pin') + infowOverdrawnInvoice.label" width="40%" :visible.sync="visible">
<el-input <el-input
id="pin" id="pin"
ref="pin" ref="pin"
@ -239,6 +239,7 @@
v-show="isValidForDeleteLine(listOrderLine)" v-show="isValidForDeleteLine(listOrderLine)"
type="success" type="success"
icon="el-icon-bank-card" icon="el-icon-bank-card"
:disabled="allowsCollectOrder"
@click="openCollectionPanel" @click="openCollectionPanel"
> >
{{ labelButtonCollections }} {{ labelButtonCollections }}
@ -314,20 +315,20 @@
<p class="total">{{ $t('form.pos.order.order') }}: <b class="order-info">{{ currentOrder.documentNo }}</b></p> <p class="total">{{ $t('form.pos.order.order') }}: <b class="order-info">{{ currentOrder.documentNo }}</b></p>
<p class="total"> <p class="total">
{{ $t('form.pos.order.date') }}: {{ $t('form.pos.order.date') }}:
<b class="order-info"> <b v-if="!isEmptyValue(currentOrder.uuid)" class="order-info">
{{ orderDate }} {{ orderDate }}
</b> </b>
</p> </p>
<p class="total">{{ $t('form.pos.order.type') }}:<b class="order-info">{{ currentOrder.documentType.name }}</b></p> <p class="total">{{ $t('form.pos.order.type') }}:<b class="order-info">{{ currentOrder.documentType.name }}</b></p>
<p class="total"> <p class="total">
{{ $t('form.pos.order.itemQuantity') }} {{ $t('form.pos.order.itemQuantity') }}
<b class="order-info"> <b v-if="!isEmptyValue(currentOrder.uuid)" class="order-info">
{{ getItemQuantity }} {{ getItemQuantity }}
</b> </b>
</p> </p>
<p class="total"> <p class="total">
{{ $t('form.pos.order.numberLines') }} {{ $t('form.pos.order.numberLines') }}
<b class="order-info"> <b v-if="!isEmptyValue(currentOrder.uuid)" class="order-info">
{{ numberOfLines }} {{ numberOfLines }}
</b></p> </b></p>
</span> </span>
@ -341,7 +342,7 @@
<b> <b>
{{ $t('form.pos.order.total') }}: {{ $t('form.pos.order.total') }}:
</b> </b>
<b style="float: right;"> <b v-if="!isEmptyValue(currentOrder.uuid)" style="float: right;">
<el-popover <el-popover
v-if="!isEmptyValue(currentOrder.uuid)" v-if="!isEmptyValue(currentOrder.uuid)"
:v-model="seeConversion" :v-model="seeConversion"
@ -638,7 +639,7 @@ export default {
}, },
currentWarehouse() { currentWarehouse() {
if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.warehouse)) { if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.warehouse)) {
return this.$store.getters.posAttributes.currentPointOfSales.warehouse return this.$store.getters.getCurrentWarehousePos
} }
return {} return {}
}, },
@ -659,9 +660,23 @@ export default {
return this.$store.getters.posAttributes.currentPointOfSales.documentTypesList return this.$store.getters.posAttributes.currentPointOfSales.documentTypesList
} }
return [] return []
},
showOverdrawnInvoice() {
return this.$store.getters.getOverdrawnInvoice.visible
},
infowOverdrawnInvoice() {
if (this.$store.getters.getOverdrawnInvoice.attributePin) {
return this.$store.getters.getOverdrawnInvoice.attributePin
}
return ''
} }
}, },
watch: { watch: {
showOverdrawnInvoice(value) {
if (value) {
this.visible = value
}
},
numberOfLines(value) { numberOfLines(value) {
if (value > 0) { if (value > 0) {
this.convertedAmount() this.convertedAmount()
@ -675,6 +690,8 @@ export default {
setTimeout(() => { setTimeout(() => {
this.focusPin() this.focusPin()
}, 500) }, 500)
} else {
this.$store.dispatch('changePopoverOverdrawnInvoice', { visible: value })
} }
} }
}, },
@ -701,33 +718,6 @@ export default {
focusPin() { focusPin() {
this.$refs.pin.focus() this.$refs.pin.focus()
}, },
// openPin(pin) {
// validatePin({
// posUuid: this.currentPointOfSales.uuid,
// pin
// })
// .then(response => {
// this.validatePin = false
// this.pin = ''
// this.visible = false
// this.pinAction(this.attributePin)
// })
// .catch(error => {
// console.error(error.message)
// this.$message({
// type: 'error',
// message: error.message,
// showClose: true
// })
// this.pin = ''
// })
// .finally(() => {
// this.closePin()
// })
// },
// closePin() {
// this.visible = false
// },
closeConvertion() { closeConvertion() {
this.seeConversion = false this.seeConversion = false
}, },
@ -747,35 +737,47 @@ export default {
return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency) return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency)
}, },
newOrder() { newOrder() {
this.clearOrder()
this.$store.commit('setShowPOSCollection', false) this.$store.commit('setShowPOSCollection', false)
this.createOrder({ withLine: false, newOrder: true }) this.createOrder({ withLine: false, newOrder: true, customer: this.currentPointOfSales.templateBusinessPartner.uuid })
}, },
changePos(pointOfSales) { changePos(pointOfSales) {
this.$store.dispatch('setCurrentPOS', pointOfSales) this.$store.dispatch('setCurrentPOS', pointOfSales)
this.clearOrder() this.clearOrder()
}, },
changeWarehouse(warehouse) { changeWarehouse(warehouse) {
this.attributePin = { const attributePin = {
...warehouse, ...warehouse,
action: 'changeWarehouse', action: 'changeWarehouse',
type: 'actionPos' type: 'actionPos',
label: this.$t('form.pos.pinMessage.warehouse')
} }
this.visible = true const visible = true
this.visible = visible
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
}, },
changeDocumentType(documentType) { changeDocumentType(documentType) {
this.attributePin = { if (this.adviserPin) {
...documentType, this.$store.commit('setCurrentDocumentTypePos', documentType)
action: 'changeDocumentType', } else {
type: 'actionPos' const attributePin = {
...documentType,
action: 'changeDocumentType',
type: 'actionPos',
label: this.$t('form.pos.pinMessage.documentType')
}
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
this.visible = true
} }
this.visible = true
}, },
changePriceList(priceList) { changePriceList(priceList) {
this.attributePin = { const attributePin = {
...priceList, ...priceList,
action: 'changePriceList', action: 'changePriceList',
type: 'actionPos' type: 'actionPos',
label: this.$t('form.pos.pinMessage.priceList')
} }
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
this.visible = true this.visible = true
}, },
arrowTop() { arrowTop() {
@ -797,41 +799,6 @@ export default {
this.currentOrderLine = this.listOrderLine[this.currentTable] this.currentOrderLine = this.listOrderLine[this.currentTable]
} }
} }
// pinAction(action) {
// if (action.type === 'updateOrder') {
// switch (action.columnName) {
// case 'QtyEntered':
// case 'PriceEntered':
// case 'Discount':
// this.updateOrderLine(action)
// break
// case 'C_DocTypeTarget_ID': {
// const documentTypeUuid = this.$store.getters.getValueOfField({
// containerUuid: this.$route.meta.uuid,
// columnName: 'C_DocTypeTarget_ID_UUID'
// })
// this.$store.dispatch('updateOrder', {
// orderUuid: this.$route.query.action,
// posUuid: this.currentPointOfSales.uuid,
// documentTypeUuid
// })
// break
// }
// }
// } else if (action.type === 'actionPos') {
// switch (action.action) {
// case 'changeWarehouse':
// this.$store.commit('setCurrentWarehousePos', action)
// break
// case 'changeDocumentType':
// this.$store.commit('setCurrentDocumentTypePos', action)
// break
// case 'changePriceList':
// this.$store.commit('setCurrentPriceList', action)
// break
// }
// }
// }
} }
} }
</script> </script>

View File

@ -16,7 +16,8 @@
import { import {
findProduct, findProduct,
updateOrderLine updateOrderLine,
deleteOrderLine
} from '@/api/ADempiere/form/point-of-sales.js' } from '@/api/ADempiere/form/point-of-sales.js'
import { import {
formatDate, formatDate,
@ -55,8 +56,26 @@ export default {
} }
}, },
computed: { computed: {
getWarehouse() { allowsCreateOrder() {
return this.$store.getters['user/getWarehouse'] if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.isAllowsCreateOrder)) {
return this.$store.getters.posAttributes.currentPointOfSales.isAllowsCreateOrder
}
return false
},
allowsCollectOrder() {
return this.$store.getters.posAttributes.currentPointOfSales.isAllowsCollectOrder
},
allowsModifyQuantity() {
return this.$store.getters.posAttributes.currentPointOfSales.isAllowsModifyQuantity
},
allowsReturnOrder() {
return this.$store.getters.posAttributes.currentPointOfSales.isAllowsReturnOrder
},
modifyPrice() {
return this.$store.getters.posAttributes.currentPointOfSales.isModifyPrice
},
adviserPin() {
return this.$store.getters.posAttributes.currentPointOfSales.isAisleSeller
}, },
isSetTemplateBP() { isSetTemplateBP() {
const currentPOS = this.currentPointOfSales const currentPOS = this.currentPointOfSales
@ -205,6 +224,11 @@ export default {
this.pin = '' this.pin = ''
this.visible = false this.visible = false
this.pinAction(this.attributePin) this.pinAction(this.attributePin)
this.$message({
type: 'success',
message: 'Acción a realizar',
showClose: true
})
}) })
.catch(error => { .catch(error => {
console.error(error.message) console.error(error.message)
@ -220,6 +244,7 @@ export default {
}) })
}, },
pinAction(action) { pinAction(action) {
action = this.isEmptyValue(action) ? this.$store.getters.getOverdrawnInvoice.attributePin : action
if (action.type === 'updateOrder') { if (action.type === 'updateOrder') {
switch (action.columnName) { switch (action.columnName) {
case 'QtyEntered': case 'QtyEntered':
@ -240,6 +265,8 @@ export default {
break break
} }
} }
} else if (action.type === 'addProduct') {
this.findProduct(action.value)
} else if (action.type === 'actionPos') { } else if (action.type === 'actionPos') {
switch (action.action) { switch (action.action) {
case 'changeWarehouse': case 'changeWarehouse':
@ -251,11 +278,15 @@ export default {
case 'changePriceList': case 'changePriceList':
this.$store.commit('setCurrentPriceList', action) this.$store.commit('setCurrentPriceList', action)
break break
case 'openBalanceInvoice':
this.$store.commit('dialogoInvoce', { show: true, type: 2 })
break
} }
} }
}, },
closePin() { closePin() {
this.visible = false this.visible = false
this.$store.dispatch('changePopoverOverdrawnInvoice', { visible: false })
this.setDocumentType(this.currentOrder.documentType) this.setDocumentType(this.currentOrder.documentType)
}, },
withoutPOSTerminal() { withoutPOSTerminal() {
@ -371,7 +402,7 @@ export default {
}) })
}) })
}, },
createOrder({ withLine = false, newOrder = false }) { createOrder({ withLine = false, newOrder = false, customer }) {
if (this.withoutPOSTerminal()) { if (this.withoutPOSTerminal()) {
return return
} }
@ -393,6 +424,9 @@ export default {
if (this.isEmptyValue(customerUuid) || id === 1000006) { if (this.isEmptyValue(customerUuid) || id === 1000006) {
customerUuid = this.currentPointOfSales.templateBusinessPartner.uuid customerUuid = this.currentPointOfSales.templateBusinessPartner.uuid
} }
if (customer) {
customerUuid = customer
}
// user session // user session
this.$store.dispatch('createOrder', { this.$store.dispatch('createOrder', {
posUuid, posUuid,
@ -460,30 +494,91 @@ export default {
getOrderTax(currency) { getOrderTax(currency) {
return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency) return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency)
}, },
deleteOrderLine(lineSelection) {
if (this.isPosRequiredPin) {
if (this.adviserPin) {
deleteOrderLine({
orderLineUuid: lineSelection.uuid
})
.then(response => {
this.$store.dispatch('reloadOrder', { orderUuid: this.$store.getters.posAttributes.currentPointOfSales.currentOrder.uuid })
})
.catch(error => {
console.error(error.message)
this.$message({
type: 'error',
message: error.message,
showClose: true
})
})
} else {
const attributePin = {
...lineSelection,
type: 'deleteLine',
label: this.$t('form.pos.pinMessage.delete')
}
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
this.visible = true
}
}
},
subscribeChanges() { subscribeChanges() {
return this.$store.subscribe((mutation, state) => { return this.$store.subscribe((mutation, state) => {
// TODO: Add container uuid comparison // TODO: Add container uuid comparison
if (mutation.type === 'addActionKeyPerformed') { if (mutation.type === 'addActionKeyPerformed') {
switch (mutation.payload.columnName) { switch (mutation.payload.columnName) {
case 'ProductValue': case 'ProductValue':
this.findProduct(mutation.payload.value) // this.findProduct(mutation.payload.value)
// if (this.isPosRequiredPin) {
if (!this.allowsCreateOrder) {
this.findProduct(mutation.payload.value)
} else {
const attributePin = {
...mutation.payload,
type: 'addProduct',
label: this.$t('form.pos.pinMessage.addProduct')
}
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
this.visible = true
}
// } else {
// this.findProduct(mutation.payload.value)
// }
break break
} }
} else if (mutation.type === 'addActionPerformed') { } else if (mutation.type === 'addActionPerformed') {
switch (mutation.payload.columnName) { switch (mutation.payload.columnName) {
case 'QtyEntered': case 'QtyEntered':
if (!this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) { if (this.isPosRequiredPin && !this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) {
if (this.allowsModifyQuantity) {
this.updateOrderLine(mutation.payload)
} else {
const attributePin = {
...mutation.payload,
type: 'updateOrder',
label: this.$t('form.pos.pinMessage.qtyEntered')
}
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
this.visible = true
}
} else if (!this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) {
this.updateOrderLine(mutation.payload) this.updateOrderLine(mutation.payload)
} }
break break
case 'PriceEntered': case 'PriceEntered':
case 'Discount': case 'Discount':
if (this.isPosRequiredPin && !this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) { if (this.isPosRequiredPin && !this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) {
this.attributePin = { if (this.modifyPrice) {
...mutation.payload, this.updateOrderLine(mutation.payload)
type: 'updateOrder' } else {
const attributePin = {
...mutation.payload,
type: 'updateOrder',
label: mutation.payload.columnName === 'PriceEntered' ? this.$t('form.pos.pinMessage.price') : this.$t('form.pos.pinMessage.discount')
}
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
this.visible = true
} }
this.visible = true
} else if (!this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) { } else if (!this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) {
this.updateOrderLine(mutation.payload) this.updateOrderLine(mutation.payload)
} }
@ -494,10 +589,11 @@ export default {
columnName: 'C_DocTypeTarget_ID_UUID' columnName: 'C_DocTypeTarget_ID_UUID'
}) })
if (this.isPosRequiredPin && !this.isEmptyValue(documentTypeUuid) && !this.isEmptyValue(this.currentOrder.documentType.uuid)) { if (this.isPosRequiredPin && !this.isEmptyValue(documentTypeUuid) && !this.isEmptyValue(this.currentOrder.documentType.uuid)) {
this.attributePin = { const attributePin = {
...mutation.payload, ...mutation.payload,
type: 'updateOrder' type: 'updateOrder'
} }
this.$store.dispatch('changePopoverOverdrawnInvoice', { attributePin, visible: true })
this.visible = true this.visible = true
} else if (!this.isEmptyValue(documentTypeUuid) && !this.isEmptyValue(this.currentOrder.documentType.uuid)) { } else if (!this.isEmptyValue(documentTypeUuid) && !this.isEmptyValue(this.currentOrder.documentType.uuid)) {
this.$store.dispatch('updateOrder', { this.$store.dispatch('updateOrder', {

View File

@ -505,6 +505,18 @@ export default {
}, },
keyLayout: { keyLayout: {
noProducto: 'No product available. Back to top' noProducto: 'No product available. Back to top'
},
pinMessage: {
pin: 'Enter pin for ',
documentType: 'change document type',
warehouse: 'change warehouse',
price: 'change price',
qtyEntered: 'change quantity',
priceList: 'change price list',
discount: 'add discount',
delete: 'delete product',
addProduct: 'add product',
invoiceOpen: 'generate invoice with an open balance'
} }
}, },
priceChecking: { priceChecking: {

View File

@ -481,6 +481,18 @@ export default {
}, },
keyLayout: { keyLayout: {
noProducto: 'No hay producto disponible Regresar al Principio' noProducto: 'No hay producto disponible Regresar al Principio'
},
pinMessage: {
pin: 'Ingrese pin para ',
documentType: 'cambiar tipo de documento',
warehouse: 'cambiar almacen',
price: 'cambiar precio',
qtyEntered: 'cambiar cantidad',
priceList: 'cambiar lista de precio',
discount: 'agregar descuento',
delete: 'eliminar producto',
addProduct: 'agregar producto',
invoiceOpen: 'generar factura con un saldo abierto'
} }
}, },
priceChecking: { priceChecking: {

View File

@ -144,5 +144,9 @@ export default {
// Current POS, it can be s // Current POS, it can be s
getCurrenciesList: (state) => { getCurrenciesList: (state) => {
return state.currenciesList return state.currenciesList
},
// get Payment type list
getPaymentTypeList: (state) => {
return state.tenderTypes
} }
} }

View File

@ -19,6 +19,7 @@ import {
listPointOfSales, listPointOfSales,
listWarehouses, listWarehouses,
listDocumentTypes, listDocumentTypes,
listTenderTypes,
listPrices, listPrices,
listCurrencies listCurrencies
} from '@/api/ADempiere/form/point-of-sales.js' } from '@/api/ADempiere/form/point-of-sales.js'
@ -126,6 +127,22 @@ export default {
}) })
}) })
}, },
listTenderTypesFromServer({ commit }, posUuid) {
listTenderTypes({
posUuid
})
.then(response => {
commit('setTenderTypesList', response.records)
})
.catch(error => {
console.warn(`listTenderTypesFromServer: ${error.message}. Code: ${error.code}.`)
showMessage({
type: 'error',
message: error.message,
showClose: true
})
})
},
setCurrentPOS({ commit, dispatch, state, rootGetters }, posToSet) { setCurrentPOS({ commit, dispatch, state, rootGetters }, posToSet) {
commit('setCurrentPointOfSales', posToSet) commit('setCurrentPointOfSales', posToSet)
const oldRoute = router.app._route const oldRoute = router.app._route
@ -143,10 +160,11 @@ export default {
dispatch('listWarehousesFromServer', posToSet.uuid) dispatch('listWarehousesFromServer', posToSet.uuid)
dispatch('listDocumentTypesFromServer', posToSet.uuid) dispatch('listDocumentTypesFromServer', posToSet.uuid)
dispatch('listCurrenciesFromServer', posToSet.uuid) dispatch('listCurrenciesFromServer', posToSet.uuid)
dispatch('listTenderTypesFromServer', posToSet.uuid)
dispatch('listPricesFromServer', posToSet) dispatch('listPricesFromServer', posToSet)
commit('setCurrentPriceList', posToSet.priceList) commit('setCurrentPriceList', posToSet.priceList)
commit('setCurrentDocumentTypePos', posToSet.documentType) commit('setCurrentDocumentTypePos', posToSet.documentType)
commit('setCurrentWarehousePos', rootGetters['user/getWarehouse']) commit('setCurrentWarehousePos', posToSet.warehouse)
commit('resetConversionRate', []) commit('resetConversionRate', [])
commit('setIsReloadKeyLayout') commit('setIsReloadKeyLayout')
commit('setIsReloadProductPrice') commit('setIsReloadProductPrice')

View File

@ -43,6 +43,12 @@ export default {
setCurrenciesList(state, currenciesList) { setCurrenciesList(state, currenciesList) {
state.currenciesList = currenciesList state.currenciesList = currenciesList
}, },
setTenderTypesList(state, tenderTypes) {
state.tenderTypes = tenderTypes
},
currentTenderChange(state, tenderChange) {
state.tenderChange = tenderChange
},
addConversionToList(state, conversion) { addConversionToList(state, conversion) {
state.conversionsList.push(conversion) state.conversionsList.push(conversion)
}, },

View File

@ -37,6 +37,8 @@ export default {
listCurrency: [], listCurrency: [],
currenciesList: [], currenciesList: [],
conversionsList: [], conversionsList: [],
tenderTypes: [],
tenderChange: '',
currentPointOfSales: {}, currentPointOfSales: {},
showPOSOptions: false, showPOSOptions: false,
showPOSKeyLayout: false, showPOSKeyLayout: false,

View File

@ -31,7 +31,10 @@ const initStateUtils = {
updateOrder: false, updateOrder: false,
updatePayment: false, updatePayment: false,
createBusinessPartner: false, createBusinessPartner: false,
step: 0 step: 0,
overdrawnInvoice: {
visible: false
}
} }
export default { export default {
@ -109,6 +112,9 @@ export default {
}, },
popoverCreateBusinessPartner(state, createBusinessPartner) { popoverCreateBusinessPartner(state, createBusinessPartner) {
state.createBusinessPartner = createBusinessPartner state.createBusinessPartner = createBusinessPartner
},
popoverOverdrawnInvoice(state, payload) {
state.overdrawnInvoice = payload
} }
}, },
actions: { actions: {
@ -178,6 +184,13 @@ export default {
}, },
changePopover({ commit }, params) { changePopover({ commit }, params) {
commit('popoverCreateBusinessPartner', params) commit('popoverCreateBusinessPartner', params)
},
changePopoverOverdrawnInvoice({ commit }, { attributePin, visible }) {
const overdrawn = {
attributePin,
visible
}
commit('popoverOverdrawnInvoice', overdrawn)
} }
}, },
getters: { getters: {
@ -256,6 +269,9 @@ export default {
}, },
getStepCurrent: (state) => { getStepCurrent: (state) => {
return state.step return state.step
},
getOverdrawnInvoice: (state) => {
return state.overdrawnInvoice
} }
} }
} }