From cc84c51825973b496917ac6320e298b16064e649 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Tue, 27 Sep 2022 15:07:11 +0530 Subject: [PATCH] incr: factorize invoice schemas --- schemas/app/Invoice.json | 137 +++++++++++++++++++++++++++ schemas/app/InvoiceItem.json | 121 +++++++++++++++++++++++ schemas/app/PurchaseInvoice.json | 115 +--------------------- schemas/app/PurchaseInvoiceItem.json | 121 +---------------------- schemas/app/SalesInvoice.json | 116 +---------------------- schemas/app/SalesInvoiceItem.json | 117 +---------------------- schemas/schemas.ts | 12 ++- 7 files changed, 271 insertions(+), 468 deletions(-) create mode 100644 schemas/app/Invoice.json create mode 100644 schemas/app/InvoiceItem.json diff --git a/schemas/app/Invoice.json b/schemas/app/Invoice.json new file mode 100644 index 00000000..d29a458e --- /dev/null +++ b/schemas/app/Invoice.json @@ -0,0 +1,137 @@ +{ + "name": "Invoice", + "label": "Invoice", + "isAbstract": true, + "isSingle": false, + "isChild": false, + "isSubmittable": true, + "fields": [ + { + "label": "Invoice No", + "fieldname": "name", + "fieldtype": "Data", + "required": true, + "readOnly": true + }, + { + "fieldname": "date", + "label": "Date", + "fieldtype": "Date", + "required": true + }, + { + "fieldname": "party", + "label": "Party", + "fieldtype": "Link", + "target": "Party", + "create": true, + "required": true + }, + { + "fieldname": "account", + "label": "Account", + "fieldtype": "Link", + "target": "Account", + "create": true, + "required": true + }, + { + "fieldname": "currency", + "label": "Customer Currency", + "fieldtype": "Link", + "target": "Currency" + }, + { + "fieldname": "exchangeRate", + "label": "Exchange Rate", + "fieldtype": "Float", + "default": 1, + "readOnly": true + }, + { + "fieldname": "netTotal", + "label": "Net Total", + "fieldtype": "Currency", + "readOnly": true + }, + { + "fieldname": "baseNetTotal", + "label": "Net Total (Company Currency)", + "fieldtype": "Currency", + "readOnly": true + }, + { + "fieldname": "taxes", + "label": "Taxes", + "fieldtype": "Table", + "target": "TaxSummary", + "readOnly": true + }, + { + "fieldname": "grandTotal", + "label": "Grand Total", + "fieldtype": "Currency", + "readOnly": true + }, + { + "fieldname": "baseGrandTotal", + "label": "Grand Total (Company Currency)", + "fieldtype": "Currency", + "readOnly": true + }, + { + "fieldname": "outstandingAmount", + "label": "Outstanding Amount", + "fieldtype": "Currency", + "readOnly": true + }, + { + "fieldname": "setDiscountAmount", + "label": "Set Discount Amount", + "fieldtype": "Check", + "default": false + }, + { + "fieldname": "discountAmount", + "label": "Discount Amount", + "fieldtype": "Currency", + "readOnly": false + }, + { + "fieldname": "discountPercent", + "label": "Discount Percent", + "fieldtype": "Float", + "readOnly": false + }, + { + "fieldname": "discountAfterTax", + "label": "Discount After Tax", + "fieldtype": "Check", + "default": false, + "readOnly": false + }, + { + "fieldname": "entryCurrency", + "label": "Entry Currency", + "fieldtype": "Select", + "options": [ + { + "value": "Party", + "label": "Party" + }, + { + "value": "Company", + "label": "Company" + } + ], + "default": "Party" + }, + { + "fieldname": "terms", + "label": "Notes", + "placeholder": "Add invoice terms", + "fieldtype": "Text" + } + ], + "keywordFields": ["name", "party"] +} diff --git a/schemas/app/InvoiceItem.json b/schemas/app/InvoiceItem.json new file mode 100644 index 00000000..261d1695 --- /dev/null +++ b/schemas/app/InvoiceItem.json @@ -0,0 +1,121 @@ +{ + "name": "InvoiceItem", + "label": "Invoice Item", + "isAbstract": true, + "isChild": true, + "fields": [ + { + "fieldname": "item", + "label": "Item", + "fieldtype": "Link", + "target": "Item", + "create": true, + "required": true + }, + { + "fieldname": "description", + "label": "Description", + "fieldtype": "Text" + }, + { + "fieldname": "quantity", + "label": "Quantity", + "fieldtype": "Float", + "required": true, + "default": 1 + }, + { + "fieldname": "rate", + "label": "Rate", + "fieldtype": "Currency", + "required": true + }, + { + "fieldname": "baseRate", + "label": "Rate (Company Currency)", + "fieldtype": "Currency", + "readOnly": true + }, + { + "fieldname": "account", + "label": "Account", + "fieldtype": "Link", + "target": "Account", + "required": true + }, + { + "fieldname": "tax", + "label": "Tax", + "fieldtype": "Link", + "create": true, + "target": "Tax" + }, + { + "fieldname": "amount", + "label": "Amount", + "fieldtype": "Currency", + "readOnly": true + }, + { + "fieldname": "baseAmount", + "label": "Amount (Company Currency)", + "fieldtype": "Currency", + "readOnly": true + }, + { + "fieldname": "setItemDiscountAmount", + "label": "Set Discount Amount", + "fieldtype": "Check", + "default": false + }, + { + "fieldname": "itemDiscountAmount", + "label": "Discount Amount", + "fieldtype": "Currency", + "readOnly": false + }, + { + "fieldname": "itemDiscountPercent", + "label": "Discount Percent", + "fieldtype": "Float", + "readOnly": false + }, + { + "fieldname": "itemDiscountedTotal", + "label": "Discounted Amount", + "fieldtype": "Currency", + "readOnly": false, + "computed": true + }, + { + "fieldname": "itemTaxedTotal", + "label": "Taxed Amount", + "fieldtype": "Currency", + "readOnly": false, + "computed": true + }, + { + "fieldname": "hsnCode", + "label": "HSN/SAC", + "fieldtype": "Int", + "placeholder": "HSN/SAC Code" + } + ], + "tableFields": ["item", "tax", "quantity", "rate", "amount"], + "keywordFields": ["item", "tax"], + "quickEditFields": [ + "item", + "account", + "description", + "hsnCode", + "tax", + "quantity", + "rate", + "amount", + "setItemDiscountAmount", + "itemDiscountAmount", + "itemDiscountPercent", + "itemDiscountedTotal", + "itemTaxedTotal" + ] +} diff --git a/schemas/app/PurchaseInvoice.json b/schemas/app/PurchaseInvoice.json index d22389ec..d1608f54 100644 --- a/schemas/app/PurchaseInvoice.json +++ b/schemas/app/PurchaseInvoice.json @@ -1,54 +1,10 @@ { "name": "PurchaseInvoice", "label": "Purchase Invoice", + "extends": "Invoice", "naming": "numberSeries", - "isSingle": false, - "isChild": false, - "isSubmittable": true, "showTitle": true, "fields": [ - { - "label": "Bill No", - "fieldname": "name", - "fieldtype": "Data", - "required": true, - "readOnly": true - }, - { - "fieldname": "date", - "label": "Date", - "fieldtype": "Date", - "required": true - }, - { - "fieldname": "party", - "label": "Party", - "fieldtype": "Link", - "target": "Party", - "create": true, - "required": true - }, - { - "fieldname": "account", - "label": "Account", - "fieldtype": "Link", - "target": "Account", - "create": true, - "required": true - }, - { - "fieldname": "currency", - "label": "Supplier Currency", - "fieldtype": "Link", - "target": "Currency", - "hidden": true - }, - { - "fieldname": "exchangeRate", - "label": "Exchange Rate", - "fieldtype": "Float", - "default": 1 - }, { "fieldname": "items", "label": "Items", @@ -57,75 +13,6 @@ "required": true, "edit": true }, - { - "fieldname": "netTotal", - "label": "Net Total", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "baseNetTotal", - "label": "Net Total (Company Currency)", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "taxes", - "label": "Taxes", - "fieldtype": "Table", - "target": "TaxSummary", - "readOnly": true - }, - { - "fieldname": "grandTotal", - "label": "Grand Total", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "baseGrandTotal", - "label": "Grand Total (Company Currency)", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "outstandingAmount", - "label": "Outstanding Amount", - "fieldtype": "Currency", - "readOnly": true, - "filter": true - }, - { - "fieldname": "setDiscountAmount", - "label": "Set Discount Amount", - "fieldtype": "Check", - "default": false - }, - { - "fieldname": "discountAmount", - "label": "Discount Amount", - "fieldtype": "Currency", - "readOnly": false - }, - { - "fieldname": "discountPercent", - "label": "Discount Percent", - "fieldtype": "Float", - "readOnly": false - }, - { - "fieldname": "discountAfterTax", - "label": "Discount After Tax", - "fieldtype": "Check", - "default": false, - "readOnly": false - }, - { - "fieldname": "terms", - "label": "Terms", - "placeholder": "Add invoice terms", - "fieldtype": "Text" - }, { "fieldname": "numberSeries", "label": "Number Series", diff --git a/schemas/app/PurchaseInvoiceItem.json b/schemas/app/PurchaseInvoiceItem.json index e3d91106..c15199e5 100644 --- a/schemas/app/PurchaseInvoiceItem.json +++ b/schemas/app/PurchaseInvoiceItem.json @@ -1,124 +1,5 @@ { "name": "PurchaseInvoiceItem", "label": "Purchase Invoice Item", - "isChild": true, - "fields": [ - { - "fieldname": "item", - "label": "Item", - "fieldtype": "Link", - "target": "Item", - "create": true, - "required": true - }, - { - "fieldname": "description", - "label": "Description", - "fieldtype": "Text", - "hidden": true - }, - { - "fieldname": "quantity", - "label": "Quantity", - "fieldtype": "Float", - "required": true, - "default": 1 - }, - { - "fieldname": "rate", - "label": "Rate", - "fieldtype": "Currency", - "required": true - }, - { - "fieldname": "baseRate", - "label": "Rate (Company Currency)", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "account", - "label": "Account", - "fieldtype": "Link", - "target": "Account", - "create": true, - "required": true, - "readOnly": true - }, - { - "fieldname": "tax", - "label": "Tax", - "fieldtype": "Link", - "create": true, - "target": "Tax" - }, - { - "fieldname": "amount", - "label": "Amount", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "baseAmount", - "label": "Amount (Company Currency)", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "setItemDiscountAmount", - "label": "Set Discount Amount", - "fieldtype": "Check", - "default": false - }, - { - "fieldname": "itemDiscountAmount", - "label": "Discount Amount", - "fieldtype": "Currency", - "readOnly": false - }, - { - "fieldname": "itemDiscountPercent", - "label": "Discount Percent", - "fieldtype": "Float", - "readOnly": false - }, - { - "fieldname": "itemDiscountedTotal", - "label": "Discounted Amount", - "fieldtype": "Currency", - "readOnly": false, - "computed": true - }, - { - "fieldname": "itemTaxedTotal", - "label": "Taxed Amount", - "fieldtype": "Currency", - "readOnly": false, - "computed": true - }, - { - "fieldname": "hsnCode", - "label": "HSN/SAC", - "fieldtype": "Int", - "placeholder": "HSN/SAC Code", - "hidden": true - } - ], - "tableFields": ["item", "tax", "quantity", "rate", "amount"], - "keywordFields": ["item", "tax"], - "quickEditFields": [ - "item", - "account", - "description", - "hsnCode", - "tax", - "quantity", - "rate", - "amount", - "setItemDiscountAmount", - "itemDiscountAmount", - "itemDiscountPercent", - "itemDiscountedTotal", - "itemTaxedTotal" - ] + "extends": "InvoiceItem" } diff --git a/schemas/app/SalesInvoice.json b/schemas/app/SalesInvoice.json index a2228307..931f780a 100644 --- a/schemas/app/SalesInvoice.json +++ b/schemas/app/SalesInvoice.json @@ -1,53 +1,10 @@ { "name": "SalesInvoice", "label": "Sales Invoice", + "extends": "Invoice", "naming": "numberSeries", - "isSingle": false, - "isChild": false, - "isSubmittable": true, + "showTitle": true, "fields": [ - { - "label": "Invoice No", - "fieldname": "name", - "fieldtype": "Data", - "required": true, - "readOnly": true - }, - { - "fieldname": "date", - "label": "Date", - "fieldtype": "Date", - "required": true - }, - { - "fieldname": "party", - "label": "Party", - "fieldtype": "Link", - "target": "Party", - "create": true, - "required": true - }, - { - "fieldname": "account", - "label": "Account", - "fieldtype": "Link", - "target": "Account", - "create": true, - "required": true - }, - { - "fieldname": "currency", - "label": "Customer Currency", - "fieldtype": "Link", - "target": "Currency" - }, - { - "fieldname": "exchangeRate", - "label": "Exchange Rate", - "fieldtype": "Float", - "default": 1, - "readOnly": true - }, { "fieldname": "items", "label": "Items", @@ -56,75 +13,6 @@ "required": true, "edit": true }, - { - "fieldname": "netTotal", - "label": "Net Total", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "baseNetTotal", - "label": "Net Total (Company Currency)", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "taxes", - "label": "Taxes", - "fieldtype": "Table", - "target": "TaxSummary", - "readOnly": true - }, - { - "fieldname": "grandTotal", - "label": "Grand Total", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "baseGrandTotal", - "label": "Grand Total (Company Currency)", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "outstandingAmount", - "label": "Outstanding Amount", - "fieldtype": "Currency", - "readOnly": true, - "filter": true - }, - { - "fieldname": "setDiscountAmount", - "label": "Set Discount Amount", - "fieldtype": "Check", - "default": false - }, - { - "fieldname": "discountAmount", - "label": "Discount Amount", - "fieldtype": "Currency", - "readOnly": false - }, - { - "fieldname": "discountPercent", - "label": "Discount Percent", - "fieldtype": "Float", - "readOnly": false - }, - { - "fieldname": "discountAfterTax", - "label": "Discount After Tax", - "fieldtype": "Check", - "default": false, - "readOnly": false - }, - { - "fieldname": "terms", - "label": "Notes", - "placeholder": "Add invoice terms", - "fieldtype": "Text" - }, { "fieldname": "numberSeries", "label": "Number Series", diff --git a/schemas/app/SalesInvoiceItem.json b/schemas/app/SalesInvoiceItem.json index ce46b5dd..bff7b705 100644 --- a/schemas/app/SalesInvoiceItem.json +++ b/schemas/app/SalesInvoiceItem.json @@ -1,120 +1,5 @@ { "name": "SalesInvoiceItem", "label": "Sales Invoice Item", - "isChild": true, - "fields": [ - { - "fieldname": "item", - "label": "Item", - "fieldtype": "Link", - "target": "Item", - "create": true, - "required": true - }, - { - "fieldname": "description", - "label": "Description", - "fieldtype": "Text" - }, - { - "fieldname": "quantity", - "label": "Quantity", - "fieldtype": "Float", - "required": true, - "default": 1 - }, - { - "fieldname": "rate", - "label": "Rate", - "fieldtype": "Currency", - "required": true - }, - { - "fieldname": "baseRate", - "label": "Rate (Company Currency)", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "account", - "label": "Account", - "fieldtype": "Link", - "target": "Account", - "required": true - }, - { - "fieldname": "tax", - "label": "Tax", - "fieldtype": "Link", - "create": true, - "target": "Tax" - }, - { - "fieldname": "amount", - "label": "Amount", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "baseAmount", - "label": "Amount (Company Currency)", - "fieldtype": "Currency", - "readOnly": true - }, - { - "fieldname": "setItemDiscountAmount", - "label": "Set Discount Amount", - "fieldtype": "Check", - "default": false - }, - { - "fieldname": "itemDiscountAmount", - "label": "Discount Amount", - "fieldtype": "Currency", - "readOnly": false - }, - { - "fieldname": "itemDiscountPercent", - "label": "Discount Percent", - "fieldtype": "Float", - "readOnly": false - }, - { - "fieldname": "itemDiscountedTotal", - "label": "Discounted Amount", - "fieldtype": "Currency", - "readOnly": false, - "computed": true - }, - { - "fieldname": "itemTaxedTotal", - "label": "Taxed Amount", - "fieldtype": "Currency", - "readOnly": false, - "computed": true - }, - { - "fieldname": "hsnCode", - "label": "HSN/SAC", - "fieldtype": "Int", - "placeholder": "HSN/SAC Code" - } - ], - "tableFields": ["item", "tax", "quantity", "rate", "amount"], - "keywordFields": ["item", "tax"], - "quickEditFields": [ - "item", - "account", - "description", - "hsnCode", - "tax", - "quantity", - "rate", - "amount", - "setItemDiscountAmount", - "itemDiscountAmount", - "itemDiscountPercent", - "itemDiscountedTotal", - "itemTaxedTotal" - ] + "extends": "InvoiceItem" } diff --git a/schemas/schemas.ts b/schemas/schemas.ts index 3fb6cc36..22935db9 100644 --- a/schemas/schemas.ts +++ b/schemas/schemas.ts @@ -7,6 +7,8 @@ import Color from './app/Color.json'; import CompanySettings from './app/CompanySettings.json'; import Currency from './app/Currency.json'; import GetStarted from './app/GetStarted.json'; +import Invoice from './app/Invoice.json'; +import InvoiceItem from './app/InvoiceItem.json'; import Item from './app/Item.json'; import JournalEntry from './app/JournalEntry.json'; import JournalEntryAccount from './app/JournalEntryAccount.json'; @@ -73,11 +75,13 @@ export const appSchemas: Schema[] | SchemaStub[] = [ JournalEntry as Schema, JournalEntryAccount as Schema, - PurchaseInvoice as Schema, - PurchaseInvoiceItem as Schema, - + Invoice as Schema, SalesInvoice as Schema, - SalesInvoiceItem as Schema, + PurchaseInvoice as Schema, + + InvoiceItem as Schema, + SalesInvoiceItem as SchemaStub, + PurchaseInvoiceItem as SchemaStub, Tax as Schema, TaxDetail as Schema,