From f0a6e7bf9e9eea3a491bd5094bbc4a073c188bc2 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Thu, 13 Apr 2023 11:46:51 +0530 Subject: [PATCH] fix(ui): propagate row changes - type ExchangeRate.vue - add BarCode and ExchangeRate widgets to CommonForm - create (not complete) with LinkedEntries.vue --- models/baseModels/Invoice/Invoice.ts | 36 ++++++-- src/components/Controls/ExchangeRate.vue | 13 ++- src/components/Controls/Table.vue | 5 +- src/components/Controls/TableRow.vue | 15 +-- src/pages/CommonForm/CommonForm.vue | 102 ++++++++++++++++++++- src/pages/CommonForm/CommonFormSection.vue | 3 +- src/pages/CommonForm/LinkedEntries.vue | 39 ++++++++ 7 files changed, 185 insertions(+), 28 deletions(-) create mode 100644 src/pages/CommonForm/LinkedEntries.vue diff --git a/models/baseModels/Invoice/Invoice.ts b/models/baseModels/Invoice/Invoice.ts index 4037a7ab..6fa28955 100644 --- a/models/baseModels/Invoice/Invoice.ts +++ b/models/baseModels/Invoice/Invoice.ts @@ -194,7 +194,6 @@ export abstract class Invoice extends Transactional { account: string; rate: number; amount: Money; - [key: string]: DocValue; } > = {}; @@ -223,11 +222,23 @@ export abstract class Invoice extends Transactional { } } - return Object.keys(taxes) - .map((account) => { - return taxes[account]; - }) - .filter((tax) => !tax.amount.isZero()); + type Summary = typeof taxes[string] & { idx: number }; + const taxArr: Summary[] = []; + let idx = 0; + for (const account in taxes) { + const tax = taxes[account]; + if (tax.amount.isZero()) { + continue; + } + + taxArr.push({ + ...tax, + idx, + }); + idx += 1; + } + + return taxArr; } async getTax(tax: string) { @@ -419,6 +430,19 @@ export abstract class Invoice extends Transactional { discountPercent: () => true || !(this.enableDiscounting && !this.setDiscountAmount), discountAfterTax: () => !this.enableDiscounting, + taxes: () => !this.taxes?.length, + baseGrandTotal: () => + this.exchangeRate === 1 || this.baseGrandTotal!.isZero(), + grandTotal: () => !this.taxes?.length, + entryCurrency: () => !this.isMultiCurrency, + currency: () => !this.isMultiCurrency, + exchangeRate: () => !this.isMultiCurrency, + stockNotTransferred: () => !this.stockNotTransferred, + outstandingAmount: () => + !!this.outstandingAmount?.isZero() || !this.isSubmitted, + terms: () => !(this.terms || !(this.isSubmitted || this.isCancelled)), + attachment: () => + !(this.attachment || !(this.isSubmitted || this.isCancelled)), }; static defaults: DefaultMap = { diff --git a/src/components/Controls/ExchangeRate.vue b/src/components/Controls/ExchangeRate.vue index 1626dac0..ace6839a 100644 --- a/src/components/Controls/ExchangeRate.vue +++ b/src/components/Controls/ExchangeRate.vue @@ -16,7 +16,6 @@ > - diff --git a/src/pages/CommonForm/CommonFormSection.vue b/src/pages/CommonForm/CommonFormSection.vue index 8ec0a6f8..4db0e02d 100644 --- a/src/pages/CommonForm/CommonFormSection.vue +++ b/src/pages/CommonForm/CommonFormSection.vue @@ -32,6 +32,7 @@ :value="doc[field.fieldname]" @editrow="(doc: Doc) => $emit('editrow', doc)" @change="(value: DocValue) => $emit('value-change', field, value)" + @row-change="(field:Field, value:DocValue, parentfield:Field) => $emit('row-change',field, value, parentfield)" />
{{ errors[field.fieldname] }} @@ -49,7 +50,7 @@ import { focusOrSelectFormControl } from 'src/utils/ui'; import { defineComponent, PropType } from 'vue'; export default defineComponent({ - emits: ['editrow', 'value-change'], + emits: ['editrow', 'value-change', 'row-change'], props: { title: String, errors: Object as PropType>, diff --git a/src/pages/CommonForm/LinkedEntries.vue b/src/pages/CommonForm/LinkedEntries.vue new file mode 100644 index 00000000..c4ab288e --- /dev/null +++ b/src/pages/CommonForm/LinkedEntries.vue @@ -0,0 +1,39 @@ + +