2
0
mirror of https://github.com/frappe/books.git synced 2025-01-24 07:38:25 +00:00

incr: add sections to settings

This commit is contained in:
18alantom 2023-03-01 13:24:49 +05:30
parent 469a7c932b
commit 09f194badc
7 changed files with 181 additions and 128 deletions

View File

@ -5,87 +5,100 @@
"isChild": false, "isChild": false,
"isSubmittable": false, "isSubmittable": false,
"fields": [ "fields": [
{
"label": "Full Name",
"fieldname": "fullname",
"fieldtype": "Data",
"required": true,
"section": "Default"
},
{ {
"label": "Company Name", "label": "Company Name",
"fieldname": "companyName", "fieldname": "companyName",
"fieldtype": "Data", "fieldtype": "Data",
"readOnly": true, "readOnly": true,
"required": true "required": true,
"section": "Default"
}, },
{ {
"label": "Write Off Account", "label": "Bank Name",
"fieldname": "writeOffAccount", "fieldname": "bankName",
"fieldtype": "Link", "fieldtype": "Data",
"target": "Account" "readOnly": true,
"required": true,
"section": "Default"
}, },
{ {
"label": "Round Off Account",
"fieldname": "roundOffAccount",
"fieldtype": "Link",
"target": "Account"
},
{
"fieldname": "country",
"label": "Country", "label": "Country",
"fieldname": "country",
"fieldtype": "AutoComplete", "fieldtype": "AutoComplete",
"placeholder": "Select Country", "placeholder": "Select Country",
"readOnly": true, "readOnly": true,
"required": true "required": true,
}, "section": "Default"
{
"fieldname": "fullname",
"label": "Full Name",
"fieldtype": "Data",
"required": true
}, },
{ {
"fieldname": "email", "fieldname": "email",
"label": "Email", "label": "Email",
"fieldtype": "Data", "fieldtype": "Data",
"required": true "required": true,
"section": "Default"
}, },
{ {
"fieldname": "bankName", "label": "Write Off Account",
"label": "Bank Name", "fieldname": "writeOffAccount",
"fieldtype": "Data", "fieldtype": "Link",
"readOnly": true, "target": "Account",
"required": true "section": "Accounts"
}, },
{ {
"fieldname": "fiscalYearStart", "label": "Round Off Account",
"label": "Fiscal Year Start Date", "fieldname": "roundOffAccount",
"fieldtype": "Date", "fieldtype": "Link",
"required": true "target": "Account",
"section": "Accounts"
}, },
{ {
"fieldname": "fiscalYearEnd", "label": "Discount Account",
"label": "Fiscal Year End Date", "fieldname": "discountAccount",
"fieldtype": "Date", "fieldtype": "Link",
"required": true "target": "Account",
"section": "Accounts"
}, },
{ {
"fieldname": "enableDiscounting", "fieldname": "enableDiscounting",
"label": "Enable Discount Accounting", "label": "Enable Discount Accounting",
"fieldtype": "Check", "fieldtype": "Check",
"default": false "default": false,
}, "section": "Feature Flags"
{
"fieldname": "discountAccount",
"label": "Discount Account",
"fieldtype": "Link",
"target": "Account"
}, },
{ {
"fieldname": "enableInventory", "fieldname": "enableInventory",
"label": "Enable Inventory", "label": "Enable Inventory",
"fieldtype": "Check", "fieldtype": "Check",
"default": false "default": false,
"section": "Feature Flags"
},
{
"fieldname": "fiscalYearStart",
"label": "Fiscal Year Start Date",
"fieldtype": "Date",
"required": true,
"section": "Fiscal Year"
},
{
"fieldname": "fiscalYearEnd",
"label": "Fiscal Year End Date",
"fieldtype": "Date",
"required": true,
"section": "Fiscal Year"
}, },
{ {
"fieldname": "setupComplete", "fieldname": "setupComplete",
"label": "Setup Complete", "label": "Setup Complete",
"fieldtype": "Check", "fieldtype": "Check",
"default": false "default": false,
"hidden": true
} }
], ],
"quickEditFields": [ "quickEditFields": [

View File

@ -9,73 +9,80 @@
"label": "Sales Invoice Number Series", "label": "Sales Invoice Number Series",
"fieldtype": "Link", "fieldtype": "Link",
"target": "NumberSeries", "target": "NumberSeries",
"create": true "create": true,
"section": "Number Series"
}, },
{ {
"fieldname": "purchaseInvoiceNumberSeries", "fieldname": "purchaseInvoiceNumberSeries",
"label": "Purchase Invoice Number Series", "label": "Purchase Invoice Number Series",
"fieldtype": "Link", "fieldtype": "Link",
"target": "NumberSeries", "target": "NumberSeries",
"create": true "create": true,
"section": "Number Series"
}, },
{ {
"fieldname": "journalEntryNumberSeries", "fieldname": "journalEntryNumberSeries",
"label": "Journal Entry Number Series", "label": "Journal Entry Number Series",
"fieldtype": "Link", "fieldtype": "Link",
"target": "NumberSeries", "target": "NumberSeries",
"create": true "create": true,
"section": "Number Series"
}, },
{ {
"fieldname": "paymentNumberSeries", "fieldname": "paymentNumberSeries",
"label": "Payment Number Series", "label": "Payment Number Series",
"fieldtype": "Link", "fieldtype": "Link",
"target": "NumberSeries", "target": "NumberSeries",
"create": true "create": true,
"section": "Number Series"
}, },
{ {
"fieldname": "stockMovementNumberSeries", "fieldname": "stockMovementNumberSeries",
"label": "Stock Movement Number Series", "label": "Stock Movement Number Series",
"fieldtype": "Link", "fieldtype": "Link",
"target": "NumberSeries", "target": "NumberSeries",
"create": true "create": true,
"section": "Number Series"
}, },
{ {
"fieldname": "shipmentNumberSeries", "fieldname": "shipmentNumberSeries",
"label": "Shipment Number Series", "label": "Shipment Number Series",
"fieldtype": "Link", "fieldtype": "Link",
"target": "NumberSeries", "target": "NumberSeries",
"create": true "create": true,
"section": "Number Series"
}, },
{ {
"fieldname": "purchaseReceiptNumberSeries", "fieldname": "purchaseReceiptNumberSeries",
"label": "Purchase Receipt Number Series", "label": "Purchase Receipt Number Series",
"fieldtype": "Link", "fieldtype": "Link",
"target": "NumberSeries", "target": "NumberSeries",
"create": true "create": true,
"section": "Number Series"
}, },
{ {
"fieldname": "salesInvoiceTerms", "fieldname": "salesInvoiceTerms",
"label": "Sales Invoice Terms", "label": "Sales Invoice Terms",
"fieldtype": "Text", "fieldtype": "Text",
"target": "NumberSeries" "section": "Terms"
}, },
{ {
"fieldname": "purchaseInvoiceTerms", "fieldname": "purchaseInvoiceTerms",
"label": "Purchase Invoice Terms", "label": "Purchase Invoice Terms",
"fieldtype": "Text", "fieldtype": "Text",
"target": "NumberSeries" "section": "Terms"
}, },
{ {
"fieldname": "shipmentTerms", "fieldname": "shipmentTerms",
"label": "Shipment Terms", "label": "Shipment Terms",
"fieldtype": "Text", "fieldtype": "Text",
"target": "NumberSeries" "section": "Terms"
}, },
{ {
"fieldname": "purchaseReceiptTerms", "fieldname": "purchaseReceiptTerms",
"label": "Purchase Receipt Terms", "label": "Purchase Receipt Terms",
"fieldtype": "Text", "fieldtype": "Text",
"target": "NumberSeries" "section": "Terms"
} }
] ]
} }

View File

@ -6,46 +6,36 @@
{ {
"fieldname": "logo", "fieldname": "logo",
"label": "Logo", "label": "Logo",
"fieldtype": "AttachImage" "fieldtype": "AttachImage",
"section": "Default"
}, },
{ {
"fieldname": "companyName", "fieldname": "companyName",
"label": "Company Name", "label": "Company Name",
"fieldtype": "Data" "fieldtype": "Data",
"section": "Default"
}, },
{ {
"fieldname": "email", "fieldname": "email",
"label": "Email", "label": "Email",
"fieldtype": "Data", "fieldtype": "Data",
"placeholder": "john@doe.com" "placeholder": "john@doe.com",
}, "section": "Contacts"
{
"fieldname": "displayLogo",
"label": "Display Logo in Invoice",
"fieldtype": "Check"
},
{
"fieldname": "displayTaxInvoice",
"label": "Display Tax Invoice",
"fieldtype": "Check"
},
{
"fieldname": "displayBatch",
"label": "Display Batch",
"fieldtype": "Check"
}, },
{ {
"fieldname": "phone", "fieldname": "phone",
"label": "Phone", "label": "Phone",
"fieldtype": "Data", "fieldtype": "Data",
"placeholder": "9888900000" "placeholder": "9888900000",
"section": "Contacts"
}, },
{ {
"fieldname": "address", "fieldname": "address",
"label": "Address", "label": "Address",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Address", "target": "Address",
"inline": true "inline": true,
"section": "Contacts"
}, },
{ {
"fieldname": "template", "fieldname": "template",
@ -66,7 +56,8 @@
"label": "Business" "label": "Business"
} }
], ],
"default": "Basic" "default": "Basic",
"section": "Customizations"
}, },
{ {
"fieldname": "color", "fieldname": "color",
@ -115,7 +106,8 @@
"label": "Black", "label": "Black",
"value": "#112B42" "value": "#112B42"
} }
] ],
"section": "Customizations"
}, },
{ {
"fieldname": "font", "fieldname": "font",
@ -136,7 +128,26 @@
"label": "Courier" "label": "Courier"
} }
], ],
"default": "Arial" "default": "Arial",
"section": "Customizations"
},
{
"fieldname": "displayLogo",
"label": "Display Logo in Invoice",
"fieldtype": "Check",
"section": "Customizations"
},
{
"fieldname": "displayTaxInvoice",
"label": "Display Tax Invoice",
"fieldtype": "Check",
"section": "Customizations"
},
{
"fieldname": "displayBatch",
"label": "Display Batch",
"fieldtype": "Check",
"section": "Customizations"
} }
], ],
"quickEditFields": [ "quickEditFields": [

View File

@ -19,47 +19,55 @@
} }
], ],
"default": "FIFO", "default": "FIFO",
"required": true "required": true,
"section": "Default"
}, },
{ {
"fieldname": "defaultLocation", "fieldname": "defaultLocation",
"label": "Default Location", "label": "Default Location",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Location", "target": "Location",
"create": true "create": true,
"section": "Default"
}, },
{ {
"fieldname": "stockInHand", "fieldname": "stockInHand",
"label": "Stock In Hand Acc.", "label": "Stock In Hand Acc.",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Account" "target": "Account",
"section": "Accounts"
}, },
{ {
"fieldname": "stockReceivedButNotBilled", "fieldname": "stockReceivedButNotBilled",
"label": "Stock Received But Not Billed Acc.", "label": "Stock Received But Not Billed Acc.",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Account" "target": "Account",
"section": "Accounts"
}, },
{ {
"fieldname": "costOfGoodsSold", "fieldname": "costOfGoodsSold",
"label": "Cost Of Goods Sold Acc.", "label": "Cost Of Goods Sold Acc.",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Account" "target": "Account",
"section": "Accounts"
}, },
{ {
"fieldname": "enableBarcodes", "fieldname": "enableBarcodes",
"label": "Enable Barcodes", "label": "Enable Barcodes",
"fieldtype": "Check" "fieldtype": "Check",
"section": "Feature Flags"
}, },
{ {
"fieldname": "enableBatches", "fieldname": "enableBatches",
"label": "Enable Batches", "label": "Enable Batches",
"fieldtype": "Check" "fieldtype": "Check",
"section": "Feature Flags"
}, },
{ {
"fieldname": "enableUomConversions", "fieldname": "enableUomConversions",
"label": "Enable UOM Conversion", "label": "Enable UOM Conversion",
"fieldtype": "Check" "fieldtype": "Check",
"section": "Feature Flags"
} }
] ]
} }

View File

@ -45,7 +45,23 @@
"default": "MMM d, y", "default": "MMM d, y",
"required": true, "required": true,
"allowCustom": true, "allowCustom": true,
"description": "Sets the app-wide date display format." "description": "Sets the app-wide date display format.",
"section": "Default"
},
{
"fieldname": "hideGetStarted",
"label": "Hide Get Started",
"fieldtype": "Check",
"default": false,
"description": "Hides the Get Started section from the sidebar. Change will be visible on restart or refreshing the app.",
"section": "Default"
},
{
"fieldname": "version",
"label": "Version",
"fieldtype": "Data",
"readOnly": true,
"section": "Default"
}, },
{ {
"fieldname": "locale", "fieldname": "locale",
@ -54,7 +70,8 @@
"default": "en-IN", "default": "en-IN",
"required": true, "required": true,
"allowCustom": true, "allowCustom": true,
"description": "Set the local code. This is used for number formatting." "description": "Set the local code. This is used for number formatting.",
"section": "Number Display"
}, },
{ {
"fieldname": "displayPrecision", "fieldname": "displayPrecision",
@ -64,29 +81,8 @@
"required": true, "required": true,
"minvalue": 0, "minvalue": 0,
"maxvalue": 9, "maxvalue": 9,
"description": "Sets how many digits are shown after the decimal point." "description": "Sets how many digits are shown after the decimal point.",
}, "section": "Number Display"
{
"fieldname": "internalPrecision",
"label": "Internal Precision",
"fieldtype": "Int",
"minvalue": 0,
"default": 11,
"description": "Sets the internal precision used for monetary calculations. Above 6 should be sufficient for most currencies."
},
{
"fieldname": "hideGetStarted",
"label": "Hide Get Started",
"fieldtype": "Check",
"default": false,
"description": "Hides the Get Started section from the sidebar. Change will be visible on restart or refreshing the app."
},
{
"fieldname": "countryCode",
"label": "Country Code",
"fieldtype": "Data",
"default": "in",
"description": "Country code used to initialize regional settings."
}, },
{ {
"fieldname": "currency", "fieldname": "currency",
@ -94,19 +90,32 @@
"fieldtype": "AutoComplete", "fieldtype": "AutoComplete",
"default": "INR", "default": "INR",
"readOnly": true, "readOnly": true,
"required": true "required": true,
"section": "Number Display"
}, },
{ {
"fieldname": "version", "fieldname": "internalPrecision",
"label": "Version", "label": "Internal Precision",
"fieldtype": "Int",
"minvalue": 0,
"default": 11,
"description": "Sets the internal precision used for monetary calculations. Above 6 should be sufficient for most currencies.",
"hidden": true
},
{
"fieldname": "countryCode",
"label": "Country Code",
"fieldtype": "Data", "fieldtype": "Data",
"readOnly": true "default": "in",
"description": "Country code used to initialize regional settings.",
"hidden": true
}, },
{ {
"fieldname": "instanceId", "fieldname": "instanceId",
"label": "Instance Id", "label": "Instance Id",
"fieldtype": "Data", "fieldtype": "Data",
"readOnly": true "readOnly": true,
"hidden": true
} }
], ],
"quickEditFields": [ "quickEditFields": [

View File

@ -5,7 +5,8 @@
"fieldname": "gstin", "fieldname": "gstin",
"label": "GSTIN", "label": "GSTIN",
"fieldtype": "Data", "fieldtype": "Data",
"placeholder": "27AAAAA0000A1Z5" "placeholder": "27AAAAA0000A1Z5",
"section": "Default"
} }
], ],
"quickEditFields": [ "quickEditFields": [

View File

@ -82,7 +82,7 @@ import { evaluateHidden } from 'src/utils/doc';
import { reloadWindow } from 'src/utils/ipcCalls'; import { reloadWindow } from 'src/utils/ipcCalls';
import { UIGroupedFields } from 'src/utils/types'; import { UIGroupedFields } from 'src/utils/types';
import { showToast } from 'src/utils/ui'; import { showToast } from 'src/utils/ui';
import { defineComponent, nextTick } from 'vue'; import { computed, defineComponent, nextTick } from 'vue';
import CommonFormSection from '../CommonForm/CommonFormSection.vue'; import CommonFormSection from '../CommonForm/CommonFormSection.vue';
export default defineComponent({ export default defineComponent({
@ -102,15 +102,19 @@ export default defineComponent({
quickEditDoc: null | Doc; quickEditDoc: null | Doc;
}; };
}, },
provide() {
return { doc: computed(() => this.doc) };
},
mounted() { mounted() {
this.updateGroupedFields();
if (this.fyo.store.isDevelopment) { if (this.fyo.store.isDevelopment) {
// @ts-ignore // @ts-ignore
window.settings = this; window.settings = this;
} }
this.update();
}, },
methods: { methods: {
async sync() { async sync(): Promise<void> {
const syncableDocs = this.schemas const syncableDocs = this.schemas
.map(({ name }) => this.fyo.singles[name]) .map(({ name }) => this.fyo.singles[name])
.filter((doc) => doc?.canSave) as Doc[]; .filter((doc) => doc?.canSave) as Doc[];
@ -127,7 +131,7 @@ export default defineComponent({
action: reloadWindow, action: reloadWindow,
}); });
}, },
async syncDoc(doc: Doc) { async syncDoc(doc: Doc): Promise<void> {
try { try {
await doc.sync(); await doc.sync();
this.updateGroupedFields(); this.updateGroupedFields();
@ -139,7 +143,7 @@ export default defineComponent({
await handleErrorWithDialog(err, doc); await handleErrorWithDialog(err, doc);
} }
}, },
async toggleQuickEditDoc(doc: Doc | null) { async toggleQuickEditDoc(doc: Doc | null): Promise<void> {
if (this.quickEditDoc && doc) { if (this.quickEditDoc && doc) {
this.quickEditDoc = null; this.quickEditDoc = null;
await nextTick(); await nextTick();
@ -147,7 +151,7 @@ export default defineComponent({
this.quickEditDoc = doc; this.quickEditDoc = doc;
}, },
async onValueChange(field: Field, value: DocValue) { async onValueChange(field: Field, value: DocValue): Promise<void> {
const { fieldname } = field; const { fieldname } = field;
delete this.errors[fieldname]; delete this.errors[fieldname];
@ -163,16 +167,16 @@ export default defineComponent({
this.update(); this.update();
}, },
update() { update(): void {
this.updateCanSave(); this.updateCanSave();
this.updateGroupedFields(); this.updateGroupedFields();
}, },
updateCanSave() { updateCanSave(): void {
this.canSave = this.schemas this.canSave = this.schemas
.map(({ name }) => this.fyo.singles[name]?.canSave) .map(({ name }) => this.fyo.singles[name]?.canSave)
.some(Boolean); .some(Boolean);
}, },
updateGroupedFields() { updateGroupedFields(): void {
const grouped: UIGroupedFields = new Map(); const grouped: UIGroupedFields = new Map();
const fields: Field[] = this.schemas.map((s) => s.fields).flat(); const fields: Field[] = this.schemas.map((s) => s.fields).flat();
@ -183,7 +187,7 @@ export default defineComponent({
} }
const tabbed = grouped.get(schemaName)!; const tabbed = grouped.get(schemaName)!;
const section = field.section ?? this.t`Misc`; const section = field.section ?? this.t`Miscellaneous`;
if (!tabbed.has(section)) { if (!tabbed.has(section)) {
tabbed.set(section, []); tabbed.set(section, []);
} }
@ -214,7 +218,7 @@ export default defineComponent({
}, },
tabLabels(): Record<string, string> { tabLabels(): Record<string, string> {
return { return {
[ModelNameEnum.AccountingSettings]: this.t`Accounting`, [ModelNameEnum.AccountingSettings]: this.t`General`,
[ModelNameEnum.PrintSettings]: this.t`Print`, [ModelNameEnum.PrintSettings]: this.t`Print`,
[ModelNameEnum.InventorySettings]: this.t`Inventory`, [ModelNameEnum.InventorySettings]: this.t`Inventory`,
[ModelNameEnum.Defaults]: this.t`Defaults`, [ModelNameEnum.Defaults]: this.t`Defaults`,
@ -227,9 +231,9 @@ export default defineComponent({
return [ return [
ModelNameEnum.AccountingSettings, ModelNameEnum.AccountingSettings,
ModelNameEnum.PrintSettings,
ModelNameEnum.InventorySettings, ModelNameEnum.InventorySettings,
ModelNameEnum.Defaults, ModelNameEnum.Defaults,
ModelNameEnum.PrintSettings,
ModelNameEnum.SystemSettings, ModelNameEnum.SystemSettings,
] ]
.filter((s) => .filter((s) =>
@ -237,7 +241,7 @@ export default defineComponent({
) )
.map((s) => this.fyo.schemaMap[s]!); .map((s) => this.fyo.schemaMap[s]!);
}, },
activeGroup() { activeGroup(): Map<string, Field[]> {
if (!this.groupedFields) { if (!this.groupedFields) {
return new Map(); return new Map();
} }