Skip to content

Commit

Permalink
Fixed syntax errors and deleting console.log (#1012)
Browse files Browse the repository at this point in the history
* Overdrawn Invoice

* rename computed

* add service Overdrawn Invoice

* Duplicate key error and deleting console.log

* fixe minor errors

* add params to router

* fixe pin

* fixe Price Checking

* fix constants

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
  • Loading branch information
elsiosanchez and elsiosanchez authored Aug 5, 2021
1 parent 12c3aef commit 553d08b
Show file tree
Hide file tree
Showing 13 changed files with 815 additions and 25 deletions.
66 changes: 66 additions & 0 deletions src/api/ADempiere/form/point-of-sales.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/components/ADempiere/Form/PriceChecking/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<el-row>
<el-col>
<div v-if="!isEmptyValue(currentConvertion)" class="rate-date">
{{ $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 }})
</div>
<div v-else class="rate-date">
{{ $t('form.pos.collect.noDayRate') }} {{ currentPointOfSales.displayCurrency.description }}
Expand Down Expand Up @@ -163,6 +163,7 @@ export default {
}
})
if (convert) {
console.log(convert)
return convert
}
return {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default [
columnName: 'C_Bank_ID',
isFromDictionary: true,
overwriteDefinition: {
sequence: 3,
sequence: 2,
handleActionKeyPerformed: true,
handleActionPerformed: true,
handleContentSelection: true,
Expand All @@ -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,
Expand Down
58 changes: 44 additions & 14 deletions src/components/ADempiere/Form/VPOS/Collection/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
<el-container style="background: white; height: 100% !important;">
<el-main style="background: white; padding: 0px; height: 100% !important; overflow: hidden">
<el-container style="background: white; padding: 0px; height: 100% !important;">
<!-- Invoice Overdrawn at time of collection -->
<overdrawn-invoice
:change="change"
:pay="pay"
:pending="pending"
:total-order="currentOrder.grandTotal"
:currency="pointOfSalesCurrency"
/>
<!-- Collection container top panel -->
<el-header style="height: auto; padding-bottom: 10px; padding-right: 0px; padding-left: 0px">
<el-card class="box-card" style="padding-left: 0px; padding-right: 0px">
Expand Down Expand Up @@ -97,21 +105,22 @@
:disabled="isDisabled"
>
<el-row id="fieldListCollection">
<el-col v-for="(field, index) in fieldsList" :key="index" :span="8">
<!-- Add selected currency symbol -->
<el-col
v-for="field in primaryFieldsList"
:key="field.sequence"
:span="8"
>
<field-definition
v-if="field.sequence <= 1"
:metadata-field="field.columnName === 'PayAmt' ? {
...field,
labelCurrency: isEmptyValue(dayRate.divideRate) ? dayRate : dayRate.currencyTo
} : field"
/>
</el-col>
<el-col :span="8">
<el-form-item :label="fieldsList[1].name">
<el-form-item :label="$t('form.pos.collect.Currency')">
<el-select
v-model="currentFieldCurrency"
:placeholder="fieldsList[1].help"
@change="changeCurrency"
>
<el-option
Expand All @@ -123,13 +132,13 @@
</el-select>
</el-form-item>
</el-col>
<el-col v-for="(field, key) in fieldsList" :key="key" :span="8">
<el-col
v-for="field in hiddenFieldsList"
:key="field.sequence"
:span="8"
>
<field-definition
v-if="field.sequence > 2"
:metadata-field="field.columnName === 'PayAmt' ? {
...field,
labelCurrency: isEmptyValue(dayRate.divideRate) ? dayRate : dayRate.currencyTo
} : field"
:metadata-field="field"
/>
</el-col>
</el-row>
Expand All @@ -140,7 +149,7 @@
<el-button type="danger" icon="el-icon-close" @click="exit" />
<el-button type="info" icon="el-icon-minus" :disabled="isDisabled" @click="undoPatment" />
<el-button type="primary" :disabled="validPay || addPay || isDisabled" icon="el-icon-plus" @click="addCollectToList(paymentBox)" />
<el-button type="success" :disabled="validateCompleteCollection || isDisabled" icon="el-icon-shopping-cart-full" @click="completePreparedOrder(listPayments)" />
<el-button type="success" :disabled="isDisabled || isDisabled" icon="el-icon-shopping-cart-full" @click="validateOrder(listPayments)" />
</samp>
</el-header>
<!-- Panel where they show the payments registered from the collection container -->
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 553d08b

Please sign in to comment.