diff --git a/src/api/ADempiere/form/point-of-sales.js b/src/api/ADempiere/form/point-of-sales.js index fac0e812319..7342eb55589 100644 --- a/src/api/ADempiere/form/point-of-sales.js +++ b/src/api/ADempiere/form/point-of-sales.js @@ -615,6 +615,72 @@ export function processOrder({ }) } +/** + * Overdrawn Invoice + * This request allows you to process an order if the payment is more or less than the invoice. + * + * req.query.token - user token + * Body: + * req.body.pos_uuid - POS UUID reference + * req.body.order_uuid - Order UUID reference + * req.body.create_payments - Optional create payments (if is true then hope payments array) + * req.body.payments + * [ + * invoice_uuid - Invoice UUID reference + * bank_uuid - Bank UUID reference + * reference_no - Reference no + * description - Description for Payment + * amount - Payment Amount + * tender_type_code - Tender Type + * payment_date - Payment Date (default now) + * currency_uuid - Currency UUID reference + * ] + * req.body.customer_details [ + * key - columnName + * value - value + * ] - customer data in case of refund or voucher card + * req.body.option - reimbursement rate + */ + +export function overdrawnInvoice({ + posUuid, + orderUuid, + createPayments, + payments, + customerDetails, + option +}) { + if (!isEmptyValue(payments)) { + payments = payments.map(parameter => { + return { + invoice_uuid: parameter.invoiceUuid, + bank_uuid: parameter.bankUuid, + reference_no: parameter.referenceNo, + description: parameter.description, + amount: parameter.amount, + tender_type_code: parameter.tenderTypeCode, + payment_ate: parameter.paymentDate, + currency_uid: parameter.currencyUuid + } + }) + } + return request({ + url: '/form/addons/point-of-sales/overdrawn-invoice', + method: 'post', + data: { + pos_uuid: posUuid, + order_uuid: orderUuid, + create_payments: createPayments, + payments: payments, + customer_details: customerDetails, + option: option + } + }) + .then(processOrderResponse => { + return processOrderResponse + }) +} + /** * Validate Ping * @param {string} posUuidd - POS UUID reference diff --git a/src/components/ADempiere/Form/PriceChecking/index.vue b/src/components/ADempiere/Form/PriceChecking/index.vue index bfbc51dff27..17536a95c60 100644 --- a/src/components/ADempiere/Form/PriceChecking/index.vue +++ b/src/components/ADempiere/Form/PriceChecking/index.vue @@ -90,7 +90,7 @@
- {{ $t('form.pos.collect.dayRate') }}: {{ formatQuantity(currentConvertion.multiplyRate) }} ~ ({{ formatPrice(1, productPrice.currency.iSOCode) }} = {{ formatPrice(currentConvertion.multiplyRate) }} {{ currentPointOfSales.displayCurrency.iso_code }}) + {{ $t('form.pos.collect.dayRate') }}: {{ formatQuantity(currentConvertion.divideRate) }} ~ ({{ formatPrice(1, productPrice.currency.iSOCode) }} = {{ formatPrice(currentConvertion.divideRate) }} {{ currentPointOfSales.displayCurrency.iso_code }})
{{ $t('form.pos.collect.noDayRate') }} {{ currentPointOfSales.displayCurrency.description }} @@ -163,6 +163,7 @@ export default { } }) if (convert) { + console.log(convert) return convert } return {} diff --git a/src/components/ADempiere/Form/VPOS/Collection/fieldsListCollection.js b/src/components/ADempiere/Form/VPOS/Collection/fieldsListCollection.js index 43c747067de..10a3d38aaa2 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/fieldsListCollection.js +++ b/src/components/ADempiere/Form/VPOS/Collection/fieldsListCollection.js @@ -57,7 +57,7 @@ export default [ columnName: 'C_Bank_ID', isFromDictionary: true, overwriteDefinition: { - sequence: 3, + sequence: 2, handleActionKeyPerformed: true, handleActionPerformed: true, handleContentSelection: true, @@ -67,6 +67,20 @@ export default [ isMandatory: true } }, + // Code + { + elementColumnName: 'Value', + columnName: 'Value', + isFromDictionary: true, + tabindex: '0', + overwriteDefinition: { + sequence: 3, + isCustomField: true, + size: 24, + isMandatory: true, + displayLogic: `@TenderType@=='P'&@TenderType@=='C'&@TenderType@=='D'` + } + }, // Date { tableName, diff --git a/src/components/ADempiere/Form/VPOS/Collection/index.vue b/src/components/ADempiere/Form/VPOS/Collection/index.vue index 181948621d4..2129db55ea2 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/index.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/index.vue @@ -19,6 +19,14 @@ + + @@ -97,10 +105,12 @@ :disabled="isDisabled" > - - + - + - + @@ -140,7 +149,7 @@ - + @@ -263,12 +272,14 @@ import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAm import { formatPrice } from '@/utils/ADempiere/valueFormat.js' import { processOrder } from '@/api/ADempiere/form/point-of-sales.js' import { FIELDS_DECIMALS } from '@/utils/ADempiere/references' +import overdrawnInvoice from '@/components/ADempiere/Form/VPOS/Collection/overdrawnInvoice' export default { name: 'Collection', components: { typeCollection, - convertAmount + convertAmount, + overdrawnInvoice }, mixins: [ formMixin, @@ -562,6 +573,15 @@ export default { }, fieldsPaymentType() { return this.fieldsList[1] + }, + primaryFieldsList() { + return this.fieldsList.filter(field => field.sequence <= 1) + }, + hiddenFieldsList() { + return this.fieldsList.filter(field => field.sequence > 1) + }, + overUnderPayment() { + return this.$store.state['pointOfSales/payments/index'].dialogoInvoce.success } }, watch: { @@ -658,7 +678,7 @@ export default { addCollectToList() { const containerUuid = this.containerUuid const posUuid = this.currentPointOfSales.uuid - const orderUuid = this.$route.query.action + const orderUuid = this.$store.getters.posAttributes.currentPointOfSales.currentOrder.uuid const bankUuid = this.$store.getters.getValueOfField({ containerUuid, columnName: 'C_Bank_ID_UUID' @@ -847,6 +867,16 @@ export default { paymentUuid }) }, + validateOrder(payment) { + this.porcessInvoce = true + if (this.pay > this.currentOrder.grandTotal) { + this.$store.commit('dialogoInvoce', { show: true, type: 1 }) + } else if (this.pay < this.currentOrder.grandTotal) { + this.$store.commit('dialogoInvoce', { show: true, type: 2 }) + } else { + this.completePreparedOrder(payment) + } + }, completePreparedOrder(payment) { const posUuid = this.currentPointOfSales.uuid const orderUuid = this.$route.query.action diff --git a/src/components/ADempiere/Form/VPOS/Collection/overdrawnInvoice/fieldsListOverdrawnInvoice.js b/src/components/ADempiere/Form/VPOS/Collection/overdrawnInvoice/fieldsListOverdrawnInvoice.js new file mode 100644 index 00000000000..61261b9bec9 --- /dev/null +++ b/src/components/ADempiere/Form/VPOS/Collection/overdrawnInvoice/fieldsListOverdrawnInvoice.js @@ -0,0 +1,177 @@ +// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution +// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. +// Contributor(s): Yamel Senih ysenih@erpya.com www.erpya.com +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +const tableName = 'C_Payment' + +export default [ + // Name + { + elementColumnName: 'Name', + columnName: 'Name', + tableName: 'C_BPartner', + tabindex: '1', + isFromDictionary: true, + overwriteDefinition: { + sequence: 0, + isCustomField: true, + size: 24, + isMandatory: true + } + }, + // Code + { + elementColumnName: 'Value', + columnName: 'Value', + isFromDictionary: true, + tabindex: '0', + overwriteDefinition: { + sequence: 1, + isCustomField: true, + size: 24, + isMandatory: true + } + }, + // Phone + { + elementColumnName: 'Phone', + columnName: 'Phone', + tableName: 'AD_user', + tabindex: '4', + isFromDictionary: true, + overwriteDefinition: { + sequence: 2, + isCustomField: true, + size: 24, + isMandatory: true + } + }, + // TenderType + { + tableName, + elementColumnName: 'TenderType', + columnName: 'TenderType', + isFromDictionary: true, + overwriteDefinition: { + defaultValue: 'X', + sequence: 3, + handleActionKeyPerformed: true, + handleContentSelection: true, + handleActionPerformed: true, + size: 24, + isActiveLogics: true, + isMandatory: true + } + }, + { + elementColumnName: 'EMail', + columnName: 'EMail', + tableName: 'AD_user', + tabindex: '3', + isFromDictionary: true, + overwriteDefinition: { + sequence: 4, + isCustomField: true, + displayLogic: `@TenderType@=='D'`, + size: 24 + } + }, + { + tableName, + elementColumnName: 'DateTrx', + isFromDictionary: true, + overwriteDefinition: { + sequence: 5, + handleFocusGained: true, + handleFocusLost: true, + handleKeyPressed: true, + handleKeyReleased: true, + handleActionKeyPerformed: true, + handleActionPerformed: true, + size: 24, + displayLogic: `@TenderType@=='K'`, + isActiveLogics: true, + isMandatory: true + } + }, + // Bank + { + tableName, + columnName: 'C_Bank_ID', + isFromDictionary: true, + overwriteDefinition: { + sequence: 6, + handleActionKeyPerformed: true, + handleActionPerformed: true, + handleContentSelection: true, + displayLogic: `@TenderType@<>'X'`, + size: 24, + isActiveLogics: true, + isMandatory: true + } + }, + // type credit card + { + tableName, + elementColumnName: 'CreditCardType', + columnName: 'CreditCardType', + isFromDictionary: true, + overwriteDefinition: { + sequence: 7, + defaultValue: 'M', + handleActionKeyPerformed: true, + handleContentSelection: true, + handleActionPerformed: true, + size: 24, + displayLogic: `@TenderType@=='C'`, + isActiveLogics: true, + isMandatory: true + } + }, + // number credit card + { + tableName, + elementColumnName: 'CreditCardNumber', + columnName: 'CreditCardNumber', + isFromDictionary: true, + overwriteDefinition: { + sequence: 8, + handleActionKeyPerformed: true, + handleContentSelection: true, + handleActionPerformed: true, + size: 24, + displayLogic: `@TenderType@=='C'`, + isActiveLogics: true, + isMandatory: true + } + }, + // accountno + { + tableName, + elementColumnName: 'AccountNo', + columnName: 'AccountNo', + isFromDictionary: true, + overwriteDefinition: { + sequence: 9, + handleActionKeyPerformed: true, + handleContentSelection: true, + handleActionPerformed: true, + size: 24, + displayLogic: `@TenderType@=='M'`, + isActiveLogics: true, + isMandatory: true + } + } +] diff --git a/src/components/ADempiere/Form/VPOS/Collection/overdrawnInvoice/index.vue b/src/components/ADempiere/Form/VPOS/Collection/overdrawnInvoice/index.vue new file mode 100644 index 00000000000..162dd5c0f78 --- /dev/null +++ b/src/components/ADempiere/Form/VPOS/Collection/overdrawnInvoice/index.vue @@ -0,0 +1,425 @@ + + + + + + diff --git a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue index 55d2453f395..4ddbd04f0b4 100644 --- a/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue +++ b/src/components/ADempiere/Form/VPOS/Collection/typeCollection.vue @@ -165,9 +165,6 @@ export default { query: value.reference.query }) } - }, - labelTypesPayment(value) { - console.log(value) } }, created() { @@ -194,7 +191,6 @@ export default { }) .then(response => { this.$store.getters.posAttributes.currentPointOfSales.currentOrder.listPayments.payments.forEach(element => { - console.log({ response, element }) if (element.currencyUuid !== this.pointOfSalesCurrency.uuid) { element.multiplyRate = element.amount / response.multiplyRate element.amountConvertion = element.amount / response.divideRate @@ -273,7 +269,6 @@ export default { query }) .then(response => { - console.log(response) this.labelTypesPayment = response }) } diff --git a/src/components/ADempiere/Form/VPOS/Order/index.vue b/src/components/ADempiere/Form/VPOS/Order/index.vue index 44a325f65a2..2817013b46a 100644 --- a/src/components/ADempiere/Form/VPOS/Order/index.vue +++ b/src/components/ADempiere/Form/VPOS/Order/index.vue @@ -91,7 +91,7 @@ - + {{ $t('form.pos.optionsPoinSales.salesOrder.newOrder') }} @@ -452,6 +452,7 @@ export default { seeConversion: false, showFieldLine: false, pin: '', + attributePin: {}, validatePin: true, visible: false } @@ -678,6 +679,17 @@ export default { if (!this.isEmptyValue(this.$route.query.action)) { this.$store.dispatch('reloadOrder', { orderUuid: this.$route.query.action }) } + if (this.isEmptyValue(this.$route.query.action) && !this.isEmptyValue(this.currentOrder.uuid)) { + this.$router.push({ + params: { + ...this.$route.params + }, + query: { + ...this.$route.query, + action: this.currentOrder.uuid + } + }) + } }, methods: { formatDate, @@ -695,6 +707,7 @@ export default { this.validatePin = false this.pin = '' this.visible = false + this.pinAction(this.attributePin) }) .catch(error => { console.error(error.message) @@ -706,7 +719,7 @@ export default { this.pin = '' }) .finally(() => { - this.closePing() + this.closePin() }) }, closePin() { @@ -828,6 +841,41 @@ export default { this.$refs.linesTable.setCurrentRow(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 + } + } } } } diff --git a/src/components/ADempiere/Form/VPOS/posMixin.js b/src/components/ADempiere/Form/VPOS/posMixin.js index 0469fdaabf0..ebba71070da 100644 --- a/src/components/ADempiere/Form/VPOS/posMixin.js +++ b/src/components/ADempiere/Form/VPOS/posMixin.js @@ -427,7 +427,7 @@ export default { reloadOrder(requery, orderUuid) { if (requery) { if (this.isEmptyValue(orderUuid)) { - orderUuid = this.$route.query.action + orderUuid = this.currentOrder.uuid // if (this.isEmptyValue(orderUuid)) { // orderUuid = this.$store.getters.currentOrder.uuid // this.currentOrder.uuid // } diff --git a/src/lang/ADempiere/en.js b/src/lang/ADempiere/en.js index e87631bfaca..ddea0cde70b 100644 --- a/src/lang/ADempiere/en.js +++ b/src/lang/ADempiere/en.js @@ -473,11 +473,13 @@ export default { pending: 'Pending', payment: 'Payment', change: 'Change', + totalInvoiced: 'Total Invoiced', convertAmount: 'Convert Quantity', convertedAmount: 'Converted Amount', fullPayment: 'Full Payment', dayRate: 'Day Rate', noDayRate: 'No daily rate has been generated for the currency.', + Currency: 'Currency', TenderType: { directDeposit: 'Direct Deposit', creditCard: 'Credit Card', @@ -488,6 +490,15 @@ export default { account: 'Account', cash: 'Cash', zelle: 'Zelle' + }, + overdrawnInvoice: { + title: 'OverdrawnInvoice', + below: 'Would you like to leave the Invoice with an Open balance', + above: 'Customer Details', + returned: 'Your change is', + coupon: 'Generate a Gift Card or Vale', + returnMoney: 'Return money in another form of payment', + adjustDocument: 'You want to Adjust Document' } }, keyLayout: { diff --git a/src/lang/ADempiere/es.js b/src/lang/ADempiere/es.js index 61d887f9c2a..bc7c13841d6 100644 --- a/src/lang/ADempiere/es.js +++ b/src/lang/ADempiere/es.js @@ -449,9 +449,11 @@ export default { pending: 'Pendiente', payment: 'Pago', change: 'Cambio', + totalInvoiced: 'Total Facturado', convertAmount: 'Convertir Cantidad', convertedAmount: 'Monto Convertido', fullPayment: 'Cobro Completo', + Currency: 'Moneda', dayRate: 'Tasa del Día', noDayRate: 'No se a generado una tasa del día para la moneda', TenderType: { @@ -464,6 +466,15 @@ export default { account: 'Cuenta', cash: 'Efectivo', zelle: 'Zelle' + }, + overdrawnInvoice: { + title: 'Factura Sobregirada', + below: 'Desea dejar la Factura con un saldo Abierto', + above: 'Datos del Cliente', + returned: 'Su vuelto es', + coupon: 'Generar una Tarjeta de Regalo o Vale', + returnMoney: 'Devolver dinero en otra forma de pago', + adjustDocument: 'Desea Ajustar Documento' } }, keyLayout: { diff --git a/src/store/modules/ADempiere/pointOfSales/payments/mutations.js b/src/store/modules/ADempiere/pointOfSales/payments/mutations.js index d92ce0edcb0..6ad65ba4918 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/mutations.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/mutations.js @@ -57,5 +57,12 @@ export default { }, setFieldCurrency(state, currency) { state.fieldCurrency = currency + }, + dialogoInvoce(state, { show, type, success }) { + state.dialogoInvoce = { + show, + type, + success + } } } diff --git a/src/store/modules/ADempiere/pointOfSales/payments/state.js b/src/store/modules/ADempiere/pointOfSales/payments/state.js index 70f935ea594..e6d2da57fab 100644 --- a/src/store/modules/ADempiere/pointOfSales/payments/state.js +++ b/src/store/modules/ADempiere/pointOfSales/payments/state.js @@ -30,5 +30,10 @@ export default { currency: [], convertion: {}, fieldCurrency: {}, - convertionRate: [] + convertionRate: [], + dialogoInvoce: { + show: false, + type: 0, + success: false + } }