From 9a012207f1317149078a15700eaf1d7057130e52 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Mon, 2 May 2022 20:47:14 +0530 Subject: [PATCH] incr: clean up coa markup, show balance on leaf ac --- fyo/core/converter.ts | 18 +- .../PurchaseInvoice/PurchaseInvoice.ts | 8 +- .../baseModels/SalesInvoice/SalesInvoice.ts | 8 +- models/helpers.ts | 14 +- src/pages/ChartOfAccounts.vue | 248 ++++++++++-------- src/utils/ui.ts | 9 +- 6 files changed, 167 insertions(+), 138 deletions(-) diff --git a/fyo/core/converter.ts b/fyo/core/converter.ts index c3d71670..1c402d51 100644 --- a/fyo/core/converter.ts +++ b/fyo/core/converter.ts @@ -152,11 +152,11 @@ export class Converter { } function toDocString(value: RawValue, field: Field) { - if (typeof value === 'string') { - return value; + if (value === null) { + return null; } - if (value === null) { + if (typeof value === 'string') { return value; } @@ -164,6 +164,10 @@ function toDocString(value: RawValue, field: Field) { } function toDocDate(value: RawValue, field: Field) { + if (value === null) { + return null; + } + if (typeof value !== 'number' && typeof value !== 'string') { throwError(value, field, 'doc'); } @@ -189,6 +193,10 @@ function toDocCurrency(value: RawValue, field: Field, fyo: Fyo) { return fyo.pesa(Number(value)); } + if (value === null) { + return fyo.pesa(0); + } + throwError(value, field, 'doc'); } @@ -209,6 +217,10 @@ function toDocFloat(value: RawValue, field: Field): number { value = parseFloat(value); } + if (value === null) { + value = 0; + } + if (typeof value === 'number' && !Number.isNaN(value)) { return value; } diff --git a/models/baseModels/PurchaseInvoice/PurchaseInvoice.ts b/models/baseModels/PurchaseInvoice/PurchaseInvoice.ts index 926d91a3..569b0392 100644 --- a/models/baseModels/PurchaseInvoice/PurchaseInvoice.ts +++ b/models/baseModels/PurchaseInvoice/PurchaseInvoice.ts @@ -1,10 +1,8 @@ import { Fyo } from 'fyo'; import { Action, ListViewSettings } from 'fyo/model/types'; import { LedgerPosting } from 'models/ledgerPosting/ledgerPosting'; -import { - getTransactionActions, - getTransactionStatusColumn, -} from '../../helpers'; +import { ModelNameEnum } from 'models/types'; +import { getInvoiceActions, getTransactionStatusColumn } from '../../helpers'; import { Invoice } from '../Invoice/Invoice'; import { PurchaseInvoiceItem } from '../PurchaseInvoiceItem/PurchaseInvoiceItem'; @@ -37,7 +35,7 @@ export class PurchaseInvoice extends Invoice { } static getActions(fyo: Fyo): Action[] { - return getTransactionActions('PurchaseInvoice', fyo); + return getInvoiceActions(ModelNameEnum.PurchaseInvoice, fyo); } static getListViewSettings(): ListViewSettings { diff --git a/models/baseModels/SalesInvoice/SalesInvoice.ts b/models/baseModels/SalesInvoice/SalesInvoice.ts index abbcf294..9b5062af 100644 --- a/models/baseModels/SalesInvoice/SalesInvoice.ts +++ b/models/baseModels/SalesInvoice/SalesInvoice.ts @@ -1,10 +1,8 @@ import { Fyo } from 'fyo'; import { Action, ListViewSettings } from 'fyo/model/types'; import { LedgerPosting } from 'models/ledgerPosting/ledgerPosting'; -import { - getTransactionActions, - getTransactionStatusColumn, -} from '../../helpers'; +import { ModelNameEnum } from 'models/types'; +import { getInvoiceActions, getTransactionStatusColumn } from '../../helpers'; import { Invoice } from '../Invoice/Invoice'; import { SalesInvoiceItem } from '../SalesInvoiceItem/SalesInvoiceItem'; @@ -35,7 +33,7 @@ export class SalesInvoice extends Invoice { } static getActions(fyo: Fyo): Action[] { - return getTransactionActions('SalesInvoice', fyo); + return getInvoiceActions(ModelNameEnum.SalesInvoice, fyo); } static getListViewSettings(): ListViewSettings { diff --git a/models/helpers.ts b/models/helpers.ts index 6caa6b9b..b4cf3051 100644 --- a/models/helpers.ts +++ b/models/helpers.ts @@ -5,7 +5,7 @@ import { NotFoundError } from 'fyo/utils/errors'; import { DateTime } from 'luxon'; import Money from 'pesa/dist/types/src/money'; import { Router } from 'vue-router'; -import { InvoiceStatus } from './types'; +import { InvoiceStatus, ModelNameEnum } from './types'; export function getLedgerLinkAction(fyo: Fyo): Action { return { @@ -27,7 +27,10 @@ export function getLedgerLinkAction(fyo: Fyo): Action { }; } -export function getTransactionActions(schemaName: string, fyo: Fyo): Action[] { +export function getInvoiceActions( + schemaName: ModelNameEnum.PurchaseInvoice | ModelNameEnum.SalesInvoice, + fyo: Fyo +): Action[] { return [ { label: fyo.t`Make Payment`, @@ -64,13 +67,6 @@ export function getTransactionActions(schemaName: string, fyo: Fyo): Action[] { }); }, }, - { - label: fyo.t`Print`, - condition: (doc: Doc) => doc.submitted as boolean, - action: async (doc: Doc, router: Router) => { - router.push({ path: `/print/${doc.schemaName}/${doc.name}` }); - }, - }, getLedgerLinkAction(fyo), ]; } diff --git a/src/pages/ChartOfAccounts.vue b/src/pages/ChartOfAccounts.vue index 46090e2e..092933a4 100644 --- a/src/pages/ChartOfAccounts.vue +++ b/src/pages/ChartOfAccounts.vue @@ -1,125 +1,133 @@