From e0141b70d8bc823d428970e07f22e080026d19d0 Mon Sep 17 00:00:00 2001
From: 18alantom <2.alan.tom@gmail.com>
Date: Tue, 21 Feb 2023 11:04:35 +0530
Subject: [PATCH] incr: use CommonForm for a few docs - show errors - shit
setName to after validation
---
fyo/core/docHandler.ts | 5 +-
fyo/model/doc.ts | 2 +-
models/baseModels/Item/Item.ts | 1 +
models/baseModels/Payment/Payment.ts | 1 +
models/inventory/StockMovement.ts | 1 +
schemas/app/Item.json | 103 ++++++++++++---------
schemas/app/Payment.json | 42 ++++-----
schemas/app/inventory/StockMovement.json | 44 +++++----
src/components/Controls/Link.vue | 2 +-
src/pages/CommonForm/CommonForm.vue | 89 +++++++++++++++---
src/pages/CommonForm/CommonFormSection.vue | 56 +++++------
src/router.ts | 32 +++++++
src/utils/search.ts | 21 ++---
src/utils/ui.ts | 13 ++-
14 files changed, 262 insertions(+), 150 deletions(-)
diff --git a/fyo/core/docHandler.ts b/fyo/core/docHandler.ts
index 6026ae46..b8fded44 100644
--- a/fyo/core/docHandler.ts
+++ b/fyo/core/docHandler.ts
@@ -117,7 +117,10 @@ export class DocHandler {
const idx = this.#temporaryNameCounters[schema.name];
this.#temporaryNameCounters[schema.name] = idx + 1;
- return this.fyo.t`New ${schema.label ?? schema.name} - Temp No. ${idx}`;
+ return this.fyo.t`New ${schema.label ?? schema.name} ${String(idx).padStart(
+ 2,
+ '0'
+ )}`;
}
/**
diff --git a/fyo/model/doc.ts b/fyo/model/doc.ts
index 18128bfd..c5902c12 100644
--- a/fyo/model/doc.ts
+++ b/fyo/model/doc.ts
@@ -868,9 +868,9 @@ export class Doc extends Observable {
}
async _insert() {
- await setName(this, this.fyo);
this._setBaseMetaValues();
await this._preSync();
+ await setName(this, this.fyo);
const validDict = this.getValidDict(false, true);
let data: DocValueMap;
diff --git a/models/baseModels/Item/Item.ts b/models/baseModels/Item/Item.ts
index 61db702b..58b80747 100644
--- a/models/baseModels/Item/Item.ts
+++ b/models/baseModels/Item/Item.ts
@@ -111,6 +111,7 @@ export class Item extends Doc {
static getListViewSettings(): ListViewSettings {
return {
+ formRoute: ({ name }) => `/edit/Item/${name}`,
columns: ['name', 'unit', 'tax', 'rate'],
};
}
diff --git a/models/baseModels/Payment/Payment.ts b/models/baseModels/Payment/Payment.ts
index 0f928138..176b7e95 100644
--- a/models/baseModels/Payment/Payment.ts
+++ b/models/baseModels/Payment/Payment.ts
@@ -617,6 +617,7 @@ export class Payment extends Transactional {
static getListViewSettings(fyo: Fyo): ListViewSettings {
return {
+ formRoute: ({ name }) => `/edit/Payment/${name}`,
columns: ['name', getDocStatusListColumn(), 'party', 'date', 'amount'],
};
}
diff --git a/models/inventory/StockMovement.ts b/models/inventory/StockMovement.ts
index 2a157e83..b6d19a65 100644
--- a/models/inventory/StockMovement.ts
+++ b/models/inventory/StockMovement.ts
@@ -75,6 +75,7 @@ export class StockMovement extends Transfer {
static getListViewSettings(fyo: Fyo): ListViewSettings {
return {
+ formRoute: ({ name }) => `/edit/StockMovement/${name}`,
columns: [
'name',
getDocStatusListColumn(),
diff --git a/schemas/app/Item.json b/schemas/app/Item.json
index b9d81b9d..deb74828 100644
--- a/schemas/app/Item.json
+++ b/schemas/app/Item.json
@@ -4,50 +4,20 @@
"isSingle": false,
"naming": "manual",
"fields": [
+ {
+ "fieldname": "image",
+ "label": "Image",
+ "section": "Default",
+ "fieldtype": "AttachImage"
+ },
{
"fieldname": "name",
"label": "Item Name",
"fieldtype": "Data",
"placeholder": "Item Name",
+ "section": "Default",
"required": true
},
- {
- "fieldname": "image",
- "label": "Image",
- "fieldtype": "AttachImage"
- },
- {
- "fieldname": "description",
- "label": "Description",
- "placeholder": "Item Description",
- "fieldtype": "Text"
- },
- {
- "fieldname": "unit",
- "label": "Unit Type",
- "fieldtype": "Link",
- "target": "UOM",
- "create": true,
- "default": "Unit",
- "placeholder": "Unit Type"
- },
- {
- "fieldname": "itemType",
- "label": "Type",
- "placeholder": "Type",
- "fieldtype": "Select",
- "default": "Product",
- "options": [
- {
- "value": "Product",
- "label": "Product"
- },
- {
- "value": "Service",
- "label": "Service"
- }
- ]
- },
{
"fieldname": "for",
"label": "For",
@@ -67,14 +37,57 @@
}
],
"required": true,
+ "section": "Default",
"default": "Both"
},
+ {
+ "fieldname": "itemType",
+ "label": "Type",
+ "placeholder": "Type",
+ "fieldtype": "Select",
+ "default": "Product",
+ "section": "Default",
+ "options": [
+ {
+ "value": "Product",
+ "label": "Product"
+ },
+ {
+ "value": "Service",
+ "label": "Service"
+ }
+ ]
+ },
+ {
+ "fieldname": "unit",
+ "label": "Unit Type",
+ "fieldtype": "Link",
+ "target": "UOM",
+ "create": true,
+ "default": "Unit",
+ "section": "Details",
+ "placeholder": "Unit Type"
+ },
+ {
+ "fieldname": "rate",
+ "label": "Rate",
+ "section": "Details",
+ "fieldtype": "Currency"
+ },
+ {
+ "fieldname": "description",
+ "label": "Description",
+ "placeholder": "Item Description",
+ "section": "Details",
+ "fieldtype": "Text"
+ },
{
"fieldname": "incomeAccount",
"label": "Sales Acc.",
"fieldtype": "Link",
"target": "Account",
"placeholder": "Income",
+ "section": "Accounts",
"create": true,
"required": true
},
@@ -84,6 +97,7 @@
"fieldtype": "Link",
"target": "Account",
"placeholder": "Expense",
+ "section": "Accounts",
"create": true,
"required": true
},
@@ -92,31 +106,30 @@
"label": "Tax",
"fieldtype": "Link",
"target": "Tax",
+ "section": "Accounts",
"create": true,
"placeholder": "Tax"
},
- {
- "fieldname": "rate",
- "label": "Rate",
- "fieldtype": "Currency"
- },
{
"fieldname": "hsnCode",
"label": "HSN/SAC",
"fieldtype": "Int",
- "placeholder": "HSN/SAC Code"
+ "placeholder": "HSN/SAC Code",
+ "section": "Inventory"
},
{
"fieldname": "barcode",
"label": "Barcode",
"fieldtype": "Data",
- "placeholder": "Barcode"
+ "placeholder": "Barcode",
+ "section": "Inventory"
},
{
"fieldname": "trackItem",
"label": "Track Item",
"fieldtype": "Check",
- "default": false
+ "default": false,
+ "section": "Inventory"
}
],
"quickEditFields": [
diff --git a/schemas/app/Payment.json b/schemas/app/Payment.json
index fb9a2f34..336a9e8c 100644
--- a/schemas/app/Payment.json
+++ b/schemas/app/Payment.json
@@ -100,6 +100,27 @@
"required": true,
"section": "Details"
},
+ {
+ "fieldname": "clearanceDate",
+ "label": "Clearance Date",
+ "placeholder": "Clearance Date",
+ "fieldtype": "Date",
+ "section": "Details"
+ },
+ {
+ "fieldname": "referenceId",
+ "label": "Ref. / Cheque No.",
+ "placeholder": "Ref. / Cheque No.",
+ "fieldtype": "Data",
+ "section": "Details"
+ },
+ {
+ "fieldname": "referenceDate",
+ "label": "Reference Date",
+ "placeholder": "Ref. Date",
+ "fieldtype": "Date",
+ "section": "Details"
+ },
{
"fieldname": "amount",
"label": "Amount",
@@ -120,27 +141,6 @@
"computed": true,
"section": "Amounts"
},
- {
- "fieldname": "referenceId",
- "label": "Ref. / Cheque No.",
- "placeholder": "Ref. / Cheque No.",
- "fieldtype": "Data",
- "section": "References"
- },
- {
- "fieldname": "referenceDate",
- "label": "Reference Date",
- "placeholder": "Ref. Date",
- "fieldtype": "Date",
- "section": "References"
- },
- {
- "fieldname": "clearanceDate",
- "label": "Clearance Date",
- "placeholder": "Clearance Date",
- "fieldtype": "Date",
- "section": "References"
- },
{
"fieldname": "for",
"label": "Payment Reference",
diff --git a/schemas/app/inventory/StockMovement.json b/schemas/app/inventory/StockMovement.json
index 99651250..9c6ed7cc 100644
--- a/schemas/app/inventory/StockMovement.json
+++ b/schemas/app/inventory/StockMovement.json
@@ -11,13 +11,18 @@
"fieldname": "name",
"fieldtype": "Data",
"required": true,
- "readOnly": true
+ "readOnly": true,
+ "section": "Default"
},
{
- "fieldname": "date",
- "label": "Date",
- "fieldtype": "Datetime",
- "required": true
+ "fieldname": "numberSeries",
+ "label": "Number Series",
+ "fieldtype": "Link",
+ "target": "NumberSeries",
+ "create": true,
+ "required": true,
+ "default": "SMOV-",
+ "section": "Default"
},
{
"fieldname": "movementType",
@@ -41,29 +46,30 @@
"label": "Manufacture"
}
],
- "required": true
- },
- {
- "fieldname": "numberSeries",
- "label": "Number Series",
- "fieldtype": "Link",
- "target": "NumberSeries",
- "create": true,
"required": true,
- "default": "SMOV-"
+ "section": "Default"
},
{
- "fieldname": "amount",
- "label": "Total Amount",
- "fieldtype": "Currency",
- "readOnly": true
+ "fieldname": "date",
+ "label": "Date",
+ "fieldtype": "Datetime",
+ "required": true,
+ "section": "Default"
},
{
"fieldname": "items",
"label": "Items",
"fieldtype": "Table",
"target": "StockMovementItem",
- "required": true
+ "required": true,
+ "section": "Items"
+ },
+ {
+ "fieldname": "amount",
+ "label": "Total Amount",
+ "fieldtype": "Currency",
+ "readOnly": true,
+ "section": "Items"
}
],
"quickEditFields": [
diff --git a/src/components/Controls/Link.vue b/src/components/Controls/Link.vue
index a6c73231..f654ee81 100644
--- a/src/components/Controls/Link.vue
+++ b/src/components/Controls/Link.vue
@@ -116,7 +116,7 @@ export default {
},
async openNewDoc() {
const schemaName = this.df.target;
- const doc = await fyo.doc.getNewDoc(schemaName);
+ const doc = fyo.doc.getNewDoc(schemaName);
const filters = await this.getCreateFilters();
diff --git a/src/pages/CommonForm/CommonForm.vue b/src/pages/CommonForm/CommonForm.vue
index e4dd8511..5dd466d4 100644
--- a/src/pages/CommonForm/CommonForm.vue
+++ b/src/pages/CommonForm/CommonForm.vue
@@ -13,15 +13,12 @@
-