From b1bd5c8e1104e188738b439f67483a85642596f5 Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Tue, 2 Mar 2021 00:18:10 -0400 Subject: [PATCH] Verify empty fields before processing payment (#618) Co-authored-by: Elsio Sanchez --- .../ADempiere/Form/VPOS/Collection/index.vue | 7 +++++-- src/store/modules/ADempiere/panel/getters.js | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/components/ADempiere/Form/VPOS/Collection/index.vue b/src/components/ADempiere/Form/VPOS/Collection/index.vue index d6a402cd..b8a640d0 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/index.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/index.vue @@ -363,9 +363,12 @@ export default { }, validPay() { const containerUuid = this.containerUuid + // filter by visible fields + const fieldLogic = this.fieldsList.filter(field => field.isDisplayedFromLogic === true) const fieldsEmpty = this.$store.getters.getFieldsListEmptyMandatory({ containerUuid, - fieldsList: this.fieldsList + fieldsList: fieldLogic, + isValidate: true }) return !this.isEmptyValue(fieldsEmpty) }, @@ -565,7 +568,7 @@ export default { columnName: 'C_Currency_ID' }) const currencyToPay = this.isEmptyValue(currencyUuid) ? currencyId : currencyUuid - if (this.currencyDisplay(currencyToPay).currencyUuid !== this.currencyPoint.uuid) { + if (this.isEmptyValue(this.currencyDisplay(currencyToPay)) && this.currencyDisplay(currencyToPay).currencyUuid !== this.currencyPoint.uuid) { this.amontSend = this.convert.divideRate * this.amontSend } if (this.sendToServer) { diff --git a/src/store/modules/ADempiere/panel/getters.js b/src/store/modules/ADempiere/panel/getters.js index 91085534..2a4b1e24 100644 --- a/src/store/modules/ADempiere/panel/getters.js +++ b/src/store/modules/ADempiere/panel/getters.js @@ -82,12 +82,13 @@ const getters = { getFieldsListEmptyMandatory: (state, getters) => ({ containerUuid, fieldsList, - formatReturn = 'name' + formatReturn = 'name', + isValidate = false }) => { if (isEmptyValue(fieldsList)) { fieldsList = getters.getFieldsListFromPanel(containerUuid) } - + const fieldsEmpty = [] // all optionals (not mandatory) fields const fieldsNameEmpty = fieldsList.filter(fieldItem => { const value = getters.getValueOfField({ @@ -95,7 +96,12 @@ const getters = { containerUuid, columnName: fieldItem.columnName }) - + if (isValidate && isEmptyValue(value)) { + const isMandatory = fieldItem.isMandatory || fieldItem.isMandatoryFromLogic + if (fieldIsDisplayed(fieldItem) && isMandatory) { + fieldsEmpty.push(fieldItem.name) + } + } if (isEmptyValue(value)) { const isMandatory = fieldItem.isMandatory || fieldItem.isMandatoryFromLogic if (fieldIsDisplayed(fieldItem) && isMandatory) { @@ -103,7 +109,9 @@ const getters = { } } }) - + if (isValidate) { + return fieldsEmpty + } if (formatReturn) { return fieldsList.map(fieldItem => { return fieldItem[formatReturn]