1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-12 22:29:59 +08:00

Validate collection (#568)

* correcting field title errors

* Validate collection

* add translation

* add traslation

* remove the function displayTenderType

* correcting translation

* remove unnecessary code
This commit is contained in:
Elsio Sanchez 2021-01-25 15:06:00 -04:00 committed by GitHub
parent ae46494f20
commit c4f3e500d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 184 additions and 102 deletions

View File

@ -6,7 +6,7 @@
<el-collapse v-model="activeAccordion" accordion> <el-collapse v-model="activeAccordion" accordion>
<el-collapse-item name="query-criteria"> <el-collapse-item name="query-criteria">
<template slot="title"> <template slot="title">
Business Partner {{ $t('form.pos.order.BusinessPartnerCreate.businessPartner') }}
<template v-if="!isEmptyValue(parentMetadata.name)"> <template v-if="!isEmptyValue(parentMetadata.name)">
({{ parentMetadata.name }}) ({{ parentMetadata.name }})
</template> </template>
@ -38,33 +38,27 @@
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
> >
<el-table-column <el-table-column
label="Key" :label="$t('form.productInfo.code')"
prop="value" prop="value"
width="180" width="100"
/> />
<el-table-column <el-table-column
label="ID" :label="$t('form.productInfo.id')"
prop="id" prop="id"
width="100" width="90"
/> />
<el-table-column <el-table-column
prop="name" prop="name"
label="Name" :label="$t('form.productInfo.name')"
/> />
<el-table-column <el-table-column
label="Last Name" :label="$t('form.productInfo.lastName')"
prop="lastName" prop="lastName"
/> />
<el-table-column <el-table-column
label="NAICS" :label="$t('form.pos.order.BusinessPartnerCreate.taxId')"
prop="naics"
width="100"
/>
<el-table-column
label="Tax ID"
prop="taxId" prop="taxId"
align="right" align="right"
width="100"
/> />
</el-table> </el-table>
<custom-pagination <custom-pagination
@ -183,8 +177,7 @@ export default {
containerUuid: mutation.payload.containerUuid, containerUuid: mutation.payload.containerUuid,
format: 'object' format: 'object'
}) })
this.searchBPartnerList({ contactName: values.Name2 })
this.searchBPartnerList(values)
} }
}) })
}, },
@ -192,7 +185,6 @@ export default {
if (isConvert && !this.isEmptyValue(values)) { if (isConvert && !this.isEmptyValue(values)) {
values = this.convertValuesToSend(values) values = this.convertValuesToSend(values)
} }
return this.$store.dispatch('listBPartnerFromServer', values) return this.$store.dispatch('listBPartnerFromServer', values)
.then(response => { .then(response => {
return response return response

View File

@ -18,15 +18,15 @@ export default [
isCustomField: true isCustomField: true
} }
}, },
{ // {
elementColumnName: 'Name2', // elementColumnName: 'Name2',
columnName: 'Name2', // columnName: 'Name2',
tableName: 'C_BPartner', // tableName: 'C_BPartner',
isFromDictionary: true, // isFromDictionary: true,
definition: { // definition: {
isCustomField: true // isCustomField: true
} // }
}, // },
{ {
elementColumnName: 'EMail', elementColumnName: 'EMail',
columnName: 'EMail', columnName: 'EMail',

View File

@ -24,7 +24,7 @@ export default [
handleActionKeyPerformed: true, handleActionKeyPerformed: true,
handleContentSelection: true, handleContentSelection: true,
handleActionPerformed: true, handleActionPerformed: true,
size: 8, size: 24,
isActiveLogics: true, isActiveLogics: true,
isMandatory: true isMandatory: true
} }
@ -39,7 +39,7 @@ export default [
handleActionPerformed: true, handleActionPerformed: true,
handleContentSelection: true, handleContentSelection: true,
displayLogic: `@TenderType@=='D'`, displayLogic: `@TenderType@=='D'`,
size: 8, size: 24,
isActiveLogics: true, isActiveLogics: true,
isMandatory: true isMandatory: true
} }
@ -50,9 +50,13 @@ export default [
elementColumnName: 'DateTrx', elementColumnName: 'DateTrx',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
handleFocusGained: true,
handleFocusLost: true,
handleKeyPressed: true,
handleKeyReleased: true,
handleActionKeyPerformed: true, handleActionKeyPerformed: true,
handleActionPerformed: true, handleActionPerformed: true,
size: 8, size: 24,
displayLogic: `@TenderType@=='K'`, displayLogic: `@TenderType@=='K'`,
isActiveLogics: true, isActiveLogics: true,
isMandatory: true isMandatory: true
@ -64,7 +68,7 @@ export default [
columnName: 'C_Currency_ID', columnName: 'C_Currency_ID',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 8, size: 24,
handleActionKeyPerformed: true, handleActionKeyPerformed: true,
handleActionPerformed: true, handleActionPerformed: true,
validationCode: 'C_Currency.C_Currency_ID = 100', validationCode: 'C_Currency.C_Currency_ID = 100',
@ -82,7 +86,7 @@ export default [
handleContentSelection: true, handleContentSelection: true,
handleActionPerformed: true, handleActionPerformed: true,
displayLogic: `@TenderType@<>'X'&@TenderType@<>'C' `, displayLogic: `@TenderType@<>'X'&@TenderType@<>'C' `,
size: 8, size: 24,
isActiveLogics: true, isActiveLogics: true,
isMandatory: true isMandatory: true
} }
@ -97,7 +101,7 @@ export default [
handleActionKeyPerformed: true, handleActionKeyPerformed: true,
handleContentSelection: true, handleContentSelection: true,
handleActionPerformed: true, handleActionPerformed: true,
size: 8, size: 24,
displayLogic: `@TenderType@=='C'`, displayLogic: `@TenderType@=='C'`,
isActiveLogics: true, isActiveLogics: true,
isMandatory: true isMandatory: true
@ -112,7 +116,7 @@ export default [
handleActionKeyPerformed: true, handleActionKeyPerformed: true,
handleContentSelection: true, handleContentSelection: true,
handleActionPerformed: true, handleActionPerformed: true,
size: 8, size: 24,
displayLogic: `@TenderType@=='C'`, displayLogic: `@TenderType@=='C'`,
isActiveLogics: true, isActiveLogics: true,
isMandatory: true isMandatory: true
@ -127,7 +131,7 @@ export default [
handleActionKeyPerformed: true, handleActionKeyPerformed: true,
handleContentSelection: true, handleContentSelection: true,
handleActionPerformed: true, handleActionPerformed: true,
size: 8, size: 24,
displayLogic: `@TenderType@=='M'`, displayLogic: `@TenderType@=='M'`,
isActiveLogics: true, isActiveLogics: true,
isMandatory: true isMandatory: true

View File

@ -63,8 +63,19 @@
</div> </div>
</el-card> </el-card>
<samp style="float: right;padding-right: 10px;"> <samp style="float: right;padding-right: 10px;">
<el-checkbox v-show="fullCopper" v-model="checked">
<el-link
type="danger"
class="stylefullPayment"
>
<b>
{{ $t('form.pos.collect.fullPayment') }}
</b>
</el-link>
</el-checkbox>
<el-button type="danger" icon="el-icon-close" @click="cancel" /> <el-button type="danger" icon="el-icon-close" @click="cancel" />
<el-button type="primary" :disabled="isValidForPay || validateConvertion" icon="el-icon-plus" @click="addCollectToList(paymentBox)" /> <el-button type="primary" :disabled="validPay || addPay" icon="el-icon-plus" @click="addCollectToList(paymentBox)" />
<el-button type="success" :disabled="validateCompleteCollection" icon="el-icon-shopping-cart-full" />
</samp> </samp>
</el-header> </el-header>
<el-main style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"> <el-main style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">
@ -211,16 +222,45 @@ export default {
data() { data() {
return { return {
isCustomForm: true, isCustomForm: true,
checked: false,
currencyConversion: 1, currencyConversion: 1,
convertAllPayment: 1, convertAllPayment: 1,
allPayCurrency: 0, allPayCurrency: 0,
labelTenderType: '',
defaultLabel: '',
fieldsList: fieldsListCollection fieldsList: fieldsListCollection
} }
}, },
computed: { computed: {
validateCompleteCollection() {
if (this.order.grandTotal === this.pay) {
return false
} else if (this.isCashAmt >= this.change) {
return false
} else if (this.pay >= this.order.grandTotal && this.checked) {
return false
}
return true
},
fullCopper() {
if ((this.change > this.isCashAmt) && this.pay > this.order.grandTotal) {
return true
}
return false
},
isPaymentBox() { isPaymentBox() {
return this.$store.getters.getPaymentBox return this.$store.getters.getPaymentBox
}, },
addPay() {
const amount = this.$store.getters.getValueOfField({
containerUuid: this.containerUuid,
columnName: 'PayAmt'
})
if (amount <= 0) {
return true
}
return false
},
paymentBox() { paymentBox() {
const payment = this.isPaymentBox.filter(pay => { const payment = this.isPaymentBox.filter(pay => {
return pay.isVisible return pay.isVisible
@ -253,7 +293,7 @@ export default {
} }
return false return false
} }
const cash = this.pending === 0 ? true : this.isMandatory const cash = this.isMandatory
return cash return cash
}, },
turned() { turned() {
@ -325,6 +365,14 @@ export default {
} }
return true return true
}, },
validPay() {
const containerUuid = this.containerUuid
const fieldsEmpty = this.$store.getters.getFieldsListEmptyMandatory({
containerUuid,
fieldsList: this.fieldsList
})
return !this.isEmptyValue(fieldsEmpty)
},
change() { change() {
const missing = this.pay - this.order.grandTotal const missing = this.pay - this.order.grandTotal
if (this.pay > 0 && this.pay > this.order.grandTotal) { if (this.pay > 0 && this.pay > this.order.grandTotal) {
@ -392,20 +440,19 @@ export default {
return false return false
} }
return true return true
},
fieldpending() {
return this.pending * this.multiplyRate
} }
// fieldpending() {
// return this.pending / this.divideRate
// }
}, },
watch: { watch: {
// fieldpending(value) { fieldpending(value) {
// this.$store.commit('updateValueOfField', { this.$store.commit('updateValueOfField', {
// containerUuid: this.containerUuid, containerUuid: this.containerUuid,
// columnName: 'PayAmt', columnName: 'PayAmt',
// value: value value: value
// }) })
// }, },
pending(value) { pending(value) {
this.$store.commit('updateValueOfField', { this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid, containerUuid: this.containerUuid,
@ -418,10 +465,18 @@ export default {
this.$store.dispatch('conversionDivideRate', { this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid, currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value, currencyToUuid: value
conversionDate: this.currentOrder.dateOrdered
}) })
} }
if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionMultiplyRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value
})
} else {
this.$store.commit('currencyMultiplyRate', 1)
}
}, },
convertAllPayment(value) { convertAllPayment(value) {
if (!this.isEmptyValue(value)) { if (!this.isEmptyValue(value)) {
@ -434,8 +489,7 @@ export default {
this.$store.dispatch('conversionMultiplyRate', { this.$store.dispatch('conversionMultiplyRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid, currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value, currencyToUuid: value
conversionDate: this.currentOrder.dateOrdered
}) })
} else { } else {
this.$store.commit('currencyMultiplyRate', 1) this.$store.commit('currencyMultiplyRate', 1)
@ -452,6 +506,7 @@ export default {
} }
}, },
created() { created() {
this.unsubscribe = this.subscribeChanges()
this.defaultValueCurrency() this.defaultValueCurrency()
}, },
methods: { methods: {
@ -468,39 +523,6 @@ export default {
event.preventDefault() event.preventDefault()
return false return false
}, },
displayTenderType(type) {
let label
switch (type) {
case 'A':
label = 'Depósito directo'
break
case 'C':
label = 'Tarjeta de crédito'
break
case 'D':
label = 'Débito directo'
break
case 'K':
label = 'Cheque'
break
case 'M':
label = 'Nota de crédito'
break
case 'P':
label = 'Pago móvil interbancario'
break
case 'T':
label = 'Cuenta'
break
case 'X':
label = 'Efectivo'
break
case 'Z':
label = 'Zelle'
break
}
return label
},
addCollectToList() { addCollectToList() {
const containerUuid = this.containerUuid const containerUuid = this.containerUuid
const amount = this.$store.getters.getValueOfField({ const amount = this.$store.getters.getValueOfField({
@ -531,7 +553,7 @@ export default {
currency = this.currencyPoint.iSOCode currency = this.currencyPoint.iSOCode
} }
const displayType = this.displayTenderType(typePay) const displayType = this.labelTenderType
this.$store.dispatch('setPaymentBox', { this.$store.dispatch('setPaymentBox', {
isVisible: true, isVisible: true,
quantityCahs: amount, quantityCahs: amount,
@ -566,6 +588,12 @@ export default {
columnName: 'C_Currency_ID', columnName: 'C_Currency_ID',
value: this.currencyPoint.id value: this.currencyPoint.id
}) })
this.$store.commit('updateValueOfField', {
parentUuid: '',
containerUuid: 'Collection',
columnName: 'DisplayColumn_TenderType',
value: this.defaultLabel
})
this.$store.commit('updateValueOfField', { this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid, containerUuid: this.containerUuid,
columnName: 'PayAmt', columnName: 'PayAmt',
@ -574,6 +602,8 @@ export default {
}) })
this.defaultValueCurrency() this.defaultValueCurrency()
this.$store.dispatch('conversionDivideRate', 1) this.$store.dispatch('conversionDivideRate', 1)
this.$store.commit('currencyMultiplyRate', 1)
this.cancel()
}, },
cancel() { cancel() {
this.fieldsList.forEach(element => { this.fieldsList.forEach(element => {
@ -600,6 +630,7 @@ export default {
}) })
this.defaultValueCurrency() this.defaultValueCurrency()
this.$store.dispatch('conversionDivideRate', 1) this.$store.dispatch('conversionDivideRate', 1)
this.$store.commit('currencyMultiplyRate', 1)
}, },
getPriceApplyingDiscount(price, discount) { getPriceApplyingDiscount(price, discount) {
if (this.isEmptyValue(price)) { if (this.isEmptyValue(price)) {
@ -639,12 +670,33 @@ export default {
columnName: 'C_Currency_ID_UUID', columnName: 'C_Currency_ID_UUID',
value: this.currencyPoint.uuid value: this.currencyPoint.uuid
}) })
},
defaulTenderType() {
this.$store.commit('updateValueOfField', {
parentUuid: '',
containerUuid: 'Collection',
columnName: 'DisplayColumn_TenderType',
value: this.$t('form.pos.collect.TenderType.cash')
})
},
subscribeChanges() {
return this.$store.subscribe((mutation, state) => {
if (mutation.type === 'updateValueOfField') {
if (mutation.payload.columnName === 'DisplayColumn_TenderType') {
this.labelTenderType = mutation.payload.value
}
}
})
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.stylefullPayment {
font-size: 15px;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif
}
.el-button--text { .el-button--text {
border-color: transparent; border-color: transparent;
color: #1890ff; color: #1890ff;

View File

@ -10,8 +10,7 @@
</el-collapse-transition> </el-collapse-transition>
<el-form-item> <el-form-item>
<template slot="label"> <template slot="label">
Código Producto {{ $t('form.productInfo.codeProduct') }}
<!-- Ver Lista de Productos Y Precios -->
<el-button <el-button
v-popover:productsList v-popover:productsList
type="text" type="text"

View File

@ -83,7 +83,7 @@ export default {
<style> <style>
.setting { .setting {
z-index: 3; z-index: 3;
width: 5%; width: 2.5%;
height: 10%; height: 10%;
right: 0%; right: 0%;
position: absolute; position: absolute;

View File

@ -83,7 +83,7 @@ export default {
<style> <style>
.setting { .setting {
z-index: 3; z-index: 3;
width: 5%; width: 2.5%;
height: 10%; height: 10%;
right: 0%; right: 0%;
position: absolute; position: absolute;

View File

@ -382,7 +382,8 @@ export default {
collect: 'Collect', collect: 'Collect',
BusinessPartnerCreate: { BusinessPartnerCreate: {
businessPartner: 'Business Partner', businessPartner: 'Business Partner',
successfullyCreated: 'Successful Business Partner' successfullyCreated: 'Socio de Negocio Creado Exitosamente',
taxId: 'Tax Identification'
} }
}, },
collect: { collect: {
@ -390,7 +391,19 @@ export default {
pending: 'Pending', pending: 'Pending',
payment: 'Payment', payment: 'Payment',
change: 'Change', change: 'Change',
convertAmount: 'Convert Quantity' convertAmount: 'Convert Quantity',
fullPayment: 'Full Payment',
TenderType: {
directDeposit: 'Direct Deposit',
creditCard: 'Credit Card',
directDebit: 'Direct Debit',
check: 'Check',
creditNote: 'Credit Note',
mobilePayment: 'Interbank mobile payment',
account: 'Account',
cash: 'Cash',
zelle: 'Zelle'
}
}, },
keyLayout: { keyLayout: {
noProducto: 'No product available. Back to top' noProducto: 'No product available. Back to top'
@ -402,9 +415,12 @@ export default {
}, },
productInfo: { productInfo: {
product: 'Product', product: 'Product',
codeProduct: 'Códe Product',
productInformation: 'Product information', productInformation: 'Product information',
code: 'Code', code: 'Code',
name: 'Name', name: 'Name',
lastName: 'Nombre2',
id: 'ID',
description: 'Description', description: 'Description',
price: 'Price', price: 'Price',
quantityOnHand: 'Quantity On Hand', quantityOnHand: 'Quantity On Hand',

View File

@ -345,7 +345,7 @@ export default {
order: { order: {
order: 'Orden', order: 'Orden',
seller: 'Vendedor', seller: 'Vendedor',
date: 'Date', date: 'Fecha',
subTotal: 'Sub-Total', subTotal: 'Sub-Total',
type: 'Tipo', type: 'Tipo',
discount: 'Descuento', discount: 'Descuento',
@ -357,7 +357,8 @@ export default {
collect: 'Cobrar', collect: 'Cobrar',
BusinessPartnerCreate: { BusinessPartnerCreate: {
businessPartner: 'Socio de Negocios', businessPartner: 'Socio de Negocios',
successfullyCreated: 'Socio de Negocio Creado Exitosamente' successfullyCreated: 'Socio de Negocio Creado Exitosamente',
taxId: 'Identificación Fiscal'
} }
}, },
collect: { collect: {
@ -365,7 +366,19 @@ export default {
pending: 'Pendiente', pending: 'Pendiente',
payment: 'Pago', payment: 'Pago',
change: 'Cambio', change: 'Cambio',
convertAmount: 'Convertir Cantidad' convertAmount: 'Convertir Cantidad',
fullPayment: 'Cobro Completo',
TenderType: {
directDeposit: 'Depósito Directo',
creditCard: 'Tarjeta de Crédito',
directDebit: 'Débito Directo',
check: 'Cheque',
creditNote: 'Nota de crédito',
mobilePayment: 'Pago Móvil Interbancario',
account: 'Cuenta',
cash: 'Efectivo',
zelle: 'Zelle'
}
}, },
keyLayout: { keyLayout: {
noProducto: 'No hay producto disponible Regresar al Principio' noProducto: 'No hay producto disponible Regresar al Principio'
@ -377,9 +390,12 @@ export default {
}, },
productInfo: { productInfo: {
product: 'Producto', product: 'Producto',
codeProduct: 'Código de Producto',
productInformation: 'Información de Producto', productInformation: 'Información de Producto',
code: 'Código', code: 'Código',
name: 'Nombre', name: 'Nombre',
id: 'ID',
lastName: 'Nombre2',
description: 'Descripción', description: 'Descripción',
quantityOnHand: 'Existencia', quantityOnHand: 'Existencia',
price: 'Precio', price: 'Precio',

View File

@ -25,11 +25,7 @@ const collection = {
* creating boxes with the payment list * creating boxes with the payment list
*/ */
setPaymentBox({ state, commit, getters }, params) { setPaymentBox({ state, commit, getters }, params) {
const payments = getters.getPaymentBox.find(element => { const payments = undefined
if (element.tenderType === params.tenderType && element.currency.id === params.currency.id) {
return element
}
})
if (isEmptyValue(payments)) { if (isEmptyValue(payments)) {
commit('addPaymentBox', params) commit('addPaymentBox', params)
} else { } else {
@ -58,8 +54,7 @@ const collection = {
requestGetConversionRate({ requestGetConversionRate({
conversionTypeUuid: params.conversionTypeUuid, conversionTypeUuid: params.conversionTypeUuid,
currencyFromUuid: params.currencyFromUuid, currencyFromUuid: params.currencyFromUuid,
currencyToUuid: params.currencyToUuid, currencyToUuid: params.currencyToUuid
conversionDate: params.conversionDate
}) })
.then(response => { .then(response => {
const divideRate = isEmptyValue(response.divideRate) ? 1 : response.divideRate const divideRate = isEmptyValue(response.divideRate) ? 1 : response.divideRate

View File

@ -1,3 +1,4 @@
import { isEmptyValue } from '../valueUtils'
export function convertContextInfo(contextInfoToConvert) { export function convertContextInfo(contextInfoToConvert) {
if (contextInfoToConvert) { if (contextInfoToConvert) {
@ -154,12 +155,19 @@ export function convertBusinessPartner(businessPartnerToConvert) {
export function convertConversionRate(conversionRateToConvert) { export function convertConversionRate(conversionRateToConvert) {
const { id, uuid } = conversionRateToConvert const { id, uuid } = conversionRateToConvert
if (isEmptyValue(conversionRateToConvert.currency_from) && isEmptyValue(conversionRateToConvert.currency_from)) {
return {
uuid,
id,
multiplyRate: conversionRateToConvert.multiply_rate,
divideRate: conversionRateToConvert.divide_rate
}
}
return { return {
uuid, uuid,
id, id,
conversionTypeUuid: conversionRateToConvert.conversion_type_uuid, conversionTypeUuid: conversionRateToConvert.conversion_type_uuid,
validFrom: conversionRateToConvert.valid_from, validFrom: conversionRateToConvert.valid_from,
validTo: conversionRateToConvert.valid_to,
currencyFrom: convertCurrency( currencyFrom: convertCurrency(
conversionRateToConvert.currency_from conversionRateToConvert.currency_from
), ),