diff --git a/fyo/model/doc.ts b/fyo/model/doc.ts index ff276114..b57f9d9b 100644 --- a/fyo/model/doc.ts +++ b/fyo/model/doc.ts @@ -177,11 +177,12 @@ export class Doc extends Observable { } get canSave() { - if (!!this.submitted) { + const isSubmittable = this.schema.isSubmittable; + if (isSubmittable && !!this.submitted) { return false; } - if (!!this.cancelled) { + if (isSubmittable && !!this.cancelled) { return false; } @@ -189,10 +190,6 @@ export class Doc extends Observable { return false; } - if (this.schema.isSingle) { - return false; - } - if (this.schema.isChild) { return false; } diff --git a/models/baseModels/AccountingSettings/AccountingSettings.ts b/models/baseModels/AccountingSettings/AccountingSettings.ts index f600d312..20da1baf 100644 --- a/models/baseModels/AccountingSettings/AccountingSettings.ts +++ b/models/baseModels/AccountingSettings/AccountingSettings.ts @@ -2,6 +2,7 @@ import { Doc } from 'fyo/model/doc'; import { ChangeArg, FiltersMap, + HiddenMap, ListsMap, ReadOnlyMap, ValidationMap, @@ -46,6 +47,11 @@ export class AccountingSettings extends Doc { }, }; + override hidden: HiddenMap = { + discountAccount: () => !this.enableDiscounting, + gstin: () => this.fyo.singles.SystemSettings?.countryCode !== 'in', + }; + async change(ch: ChangeArg) { const discountingEnabled = ch.changed === 'enableDiscounting' && this.enableDiscounting; diff --git a/models/baseModels/Item/Item.ts b/models/baseModels/Item/Item.ts index 513b41f8..b248476f 100644 --- a/models/baseModels/Item/Item.ts +++ b/models/baseModels/Item/Item.ts @@ -11,7 +11,6 @@ import { ValidationMap, } from 'fyo/model/types'; import { ValidationError } from 'fyo/utils/errors'; -import { ModelNameEnum } from 'models/types'; import { Money } from 'pesa'; import { AccountRootTypeEnum, AccountTypeEnum } from '../Account/types'; diff --git a/models/baseModels/PrintSettings/PrintSettings.ts b/models/baseModels/PrintSettings/PrintSettings.ts new file mode 100644 index 00000000..a8ffea2a --- /dev/null +++ b/models/baseModels/PrintSettings/PrintSettings.ts @@ -0,0 +1,8 @@ +import { Doc } from 'fyo/model/doc'; +import { HiddenMap } from 'fyo/model/types'; + +export class PrintSettings extends Doc { + override hidden: HiddenMap = { + displayBatch: () => !this.fyo.singles.InventorySettings?.enableBatches, + }; +} diff --git a/models/index.ts b/models/index.ts index e8407771..75899c29 100644 --- a/models/index.ts +++ b/models/index.ts @@ -10,6 +10,7 @@ import { JournalEntryAccount } from './baseModels/JournalEntryAccount/JournalEnt import { Party } from './baseModels/Party/Party'; import { Payment } from './baseModels/Payment/Payment'; import { PaymentFor } from './baseModels/PaymentFor/PaymentFor'; +import { PrintSettings } from './baseModels/PrintSettings/PrintSettings'; import { PurchaseInvoice } from './baseModels/PurchaseInvoice/PurchaseInvoice'; import { PurchaseInvoiceItem } from './baseModels/PurchaseInvoiceItem/PurchaseInvoiceItem'; import { SalesInvoice } from './baseModels/SalesInvoice/SalesInvoice'; @@ -17,6 +18,7 @@ import { SalesInvoiceItem } from './baseModels/SalesInvoiceItem/SalesInvoiceItem import { SetupWizard } from './baseModels/SetupWizard/SetupWizard'; import { Tax } from './baseModels/Tax/Tax'; import { TaxSummary } from './baseModels/TaxSummary/TaxSummary'; +import { Batch } from './inventory/Batch'; import { InventorySettings } from './inventory/InventorySettings'; import { Location } from './inventory/Location'; import { PurchaseReceipt } from './inventory/PurchaseReceipt'; @@ -26,7 +28,6 @@ import { ShipmentItem } from './inventory/ShipmentItem'; import { StockLedgerEntry } from './inventory/StockLedgerEntry'; import { StockMovement } from './inventory/StockMovement'; import { StockMovementItem } from './inventory/StockMovementItem'; -import { Batch } from './inventory/Batch'; export const models = { Account, @@ -41,6 +42,7 @@ export const models = { Party, Payment, PaymentFor, + PrintSettings, PurchaseInvoice, PurchaseInvoiceItem, SalesInvoice, diff --git a/schemas/app/AccountingSettings.json b/schemas/app/AccountingSettings.json index 69738a59..7bf9cddc 100644 --- a/schemas/app/AccountingSettings.json +++ b/schemas/app/AccountingSettings.json @@ -5,87 +5,100 @@ "isChild": false, "isSubmittable": false, "fields": [ + { + "label": "Full Name", + "fieldname": "fullname", + "fieldtype": "Data", + "required": true, + "section": "Default" + }, { "label": "Company Name", "fieldname": "companyName", "fieldtype": "Data", "readOnly": true, - "required": true + "required": true, + "section": "Default" }, { - "label": "Write Off Account", - "fieldname": "writeOffAccount", - "fieldtype": "Link", - "target": "Account" + "label": "Bank Name", + "fieldname": "bankName", + "fieldtype": "Data", + "readOnly": true, + "required": true, + "section": "Default" }, { - "label": "Round Off Account", - "fieldname": "roundOffAccount", - "fieldtype": "Link", - "target": "Account" - }, - { - "fieldname": "country", "label": "Country", + "fieldname": "country", "fieldtype": "AutoComplete", "placeholder": "Select Country", "readOnly": true, - "required": true - }, - { - "fieldname": "fullname", - "label": "Full Name", - "fieldtype": "Data", - "required": true + "required": true, + "section": "Default" }, { "fieldname": "email", "label": "Email", "fieldtype": "Data", - "required": true + "required": true, + "section": "Default" }, { - "fieldname": "bankName", - "label": "Bank Name", - "fieldtype": "Data", - "readOnly": true, - "required": true + "label": "Write Off Account", + "fieldname": "writeOffAccount", + "fieldtype": "Link", + "target": "Account", + "section": "Accounts" }, { - "fieldname": "fiscalYearStart", - "label": "Fiscal Year Start Date", - "fieldtype": "Date", - "required": true + "label": "Round Off Account", + "fieldname": "roundOffAccount", + "fieldtype": "Link", + "target": "Account", + "section": "Accounts" }, { - "fieldname": "fiscalYearEnd", - "label": "Fiscal Year End Date", - "fieldtype": "Date", - "required": true + "label": "Discount Account", + "fieldname": "discountAccount", + "fieldtype": "Link", + "target": "Account", + "section": "Accounts" }, { "fieldname": "enableDiscounting", "label": "Enable Discount Accounting", "fieldtype": "Check", - "default": false - }, - { - "fieldname": "discountAccount", - "label": "Discount Account", - "fieldtype": "Link", - "target": "Account" + "default": false, + "section": "Feature Flags" }, { "fieldname": "enableInventory", "label": "Enable Inventory", "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", "label": "Setup Complete", "fieldtype": "Check", - "default": false + "default": false, + "hidden": true } ], "quickEditFields": [ diff --git a/schemas/app/Defaults.json b/schemas/app/Defaults.json index aa91be4e..d68c6c79 100644 --- a/schemas/app/Defaults.json +++ b/schemas/app/Defaults.json @@ -9,73 +9,80 @@ "label": "Sales Invoice Number Series", "fieldtype": "Link", "target": "NumberSeries", - "create": true + "create": true, + "section": "Number Series" }, { "fieldname": "purchaseInvoiceNumberSeries", "label": "Purchase Invoice Number Series", "fieldtype": "Link", "target": "NumberSeries", - "create": true + "create": true, + "section": "Number Series" }, { "fieldname": "journalEntryNumberSeries", "label": "Journal Entry Number Series", "fieldtype": "Link", "target": "NumberSeries", - "create": true + "create": true, + "section": "Number Series" }, { "fieldname": "paymentNumberSeries", "label": "Payment Number Series", "fieldtype": "Link", "target": "NumberSeries", - "create": true + "create": true, + "section": "Number Series" }, { "fieldname": "stockMovementNumberSeries", "label": "Stock Movement Number Series", "fieldtype": "Link", "target": "NumberSeries", - "create": true + "create": true, + "section": "Number Series" }, { "fieldname": "shipmentNumberSeries", "label": "Shipment Number Series", "fieldtype": "Link", "target": "NumberSeries", - "create": true + "create": true, + "section": "Number Series" }, { "fieldname": "purchaseReceiptNumberSeries", "label": "Purchase Receipt Number Series", "fieldtype": "Link", "target": "NumberSeries", - "create": true + "create": true, + "section": "Number Series" }, { "fieldname": "salesInvoiceTerms", "label": "Sales Invoice Terms", "fieldtype": "Text", - "target": "NumberSeries" + "section": "Terms" }, { "fieldname": "purchaseInvoiceTerms", "label": "Purchase Invoice Terms", "fieldtype": "Text", - "target": "NumberSeries" + "section": "Terms" }, { "fieldname": "shipmentTerms", "label": "Shipment Terms", "fieldtype": "Text", - "target": "NumberSeries" + "section": "Terms" }, { "fieldname": "purchaseReceiptTerms", "label": "Purchase Receipt Terms", "fieldtype": "Text", - "target": "NumberSeries" + "section": "Terms" } ] } diff --git a/schemas/app/PrintSettings.json b/schemas/app/PrintSettings.json index 08f8f16c..cd671c4f 100644 --- a/schemas/app/PrintSettings.json +++ b/schemas/app/PrintSettings.json @@ -6,46 +6,36 @@ { "fieldname": "logo", "label": "Logo", - "fieldtype": "AttachImage" + "fieldtype": "AttachImage", + "section": "Default" }, { "fieldname": "companyName", "label": "Company Name", - "fieldtype": "Data" + "fieldtype": "Data", + "section": "Default" }, { "fieldname": "email", "label": "Email", "fieldtype": "Data", - "placeholder": "john@doe.com" - }, - { - "fieldname": "displayLogo", - "label": "Display Logo in Invoice", - "fieldtype": "Check" - }, - { - "fieldname": "displayTaxInvoice", - "label": "Display Tax Invoice", - "fieldtype": "Check" - }, - { - "fieldname": "displayBatch", - "label": "Display Batch", - "fieldtype": "Check" + "placeholder": "john@doe.com", + "section": "Contacts" }, { "fieldname": "phone", "label": "Phone", "fieldtype": "Data", - "placeholder": "9888900000" + "placeholder": "9888900000", + "section": "Contacts" }, { "fieldname": "address", "label": "Address", "fieldtype": "Link", "target": "Address", - "inline": true + "inline": true, + "section": "Contacts" }, { "fieldname": "template", @@ -66,7 +56,8 @@ "label": "Business" } ], - "default": "Basic" + "default": "Basic", + "section": "Customizations" }, { "fieldname": "color", @@ -115,7 +106,8 @@ "label": "Black", "value": "#112B42" } - ] + ], + "section": "Customizations" }, { "fieldname": "font", @@ -136,7 +128,26 @@ "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": [ diff --git a/schemas/app/inventory/InventorySettings.json b/schemas/app/inventory/InventorySettings.json index 0df7e6b4..811db4a4 100644 --- a/schemas/app/inventory/InventorySettings.json +++ b/schemas/app/inventory/InventorySettings.json @@ -19,47 +19,55 @@ } ], "default": "FIFO", - "required": true + "required": true, + "section": "Default" }, { "fieldname": "defaultLocation", "label": "Default Location", "fieldtype": "Link", "target": "Location", - "create": true + "create": true, + "section": "Default" }, { "fieldname": "stockInHand", "label": "Stock In Hand Acc.", "fieldtype": "Link", - "target": "Account" + "target": "Account", + "section": "Accounts" }, { "fieldname": "stockReceivedButNotBilled", "label": "Stock Received But Not Billed Acc.", "fieldtype": "Link", - "target": "Account" + "target": "Account", + "section": "Accounts" }, { "fieldname": "costOfGoodsSold", "label": "Cost Of Goods Sold Acc.", "fieldtype": "Link", - "target": "Account" + "target": "Account", + "section": "Accounts" }, { "fieldname": "enableBarcodes", "label": "Enable Barcodes", - "fieldtype": "Check" + "fieldtype": "Check", + "section": "Feature Flags" }, { "fieldname": "enableBatches", "label": "Enable Batches", - "fieldtype": "Check" + "fieldtype": "Check", + "section": "Feature Flags" }, { "fieldname": "enableUomConversions", "label": "Enable UOM Conversion", - "fieldtype": "Check" + "fieldtype": "Check", + "section": "Feature Flags" } ] } diff --git a/schemas/core/SystemSettings.json b/schemas/core/SystemSettings.json index 65bb5759..e597c40f 100644 --- a/schemas/core/SystemSettings.json +++ b/schemas/core/SystemSettings.json @@ -45,7 +45,23 @@ "default": "MMM d, y", "required": 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", @@ -54,7 +70,8 @@ "default": "en-IN", "required": 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", @@ -64,29 +81,8 @@ "required": true, "minvalue": 0, "maxvalue": 9, - "description": "Sets how many digits are shown after the decimal point." - }, - { - "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." + "description": "Sets how many digits are shown after the decimal point.", + "section": "Number Display" }, { "fieldname": "currency", @@ -94,19 +90,32 @@ "fieldtype": "AutoComplete", "default": "INR", "readOnly": true, - "required": true + "required": true, + "section": "Number Display" }, { - "fieldname": "version", - "label": "Version", + "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.", + "hidden": true + }, + { + "fieldname": "countryCode", + "label": "Country Code", "fieldtype": "Data", - "readOnly": true + "default": "in", + "description": "Country code used to initialize regional settings.", + "hidden": true }, { "fieldname": "instanceId", "label": "Instance Id", "fieldtype": "Data", - "readOnly": true + "readOnly": true, + "hidden": true } ], "quickEditFields": [ diff --git a/schemas/regional/in/AccountingSettings.json b/schemas/regional/in/AccountingSettings.json index 66de67ac..e1be3e8e 100644 --- a/schemas/regional/in/AccountingSettings.json +++ b/schemas/regional/in/AccountingSettings.json @@ -5,7 +5,8 @@ "fieldname": "gstin", "label": "GSTIN", "fieldtype": "Data", - "placeholder": "27AAAAA0000A1Z5" + "placeholder": "27AAAAA0000A1Z5", + "section": "Default" } ], "quickEditFields": [ diff --git a/src/pages/CommonForm/CommonForm.vue b/src/pages/CommonForm/CommonForm.vue index f40b4e20..124ea130 100644 --- a/src/pages/CommonForm/CommonForm.vue +++ b/src/pages/CommonForm/CommonForm.vue @@ -112,6 +112,8 @@ import FormHeader from 'src/components/FormHeader.vue'; import StatusBadge from 'src/components/StatusBadge.vue'; import { handleErrorWithDialog } from 'src/errorHandling'; import { getErrorMessage } from 'src/utils'; +import { docsPathMap } from 'src/utils/misc'; +import { docsPathRef, focusedDocsRef } from 'src/utils/refs'; import { ActionGroup, UIGroupedFields } from 'src/utils/types'; import { getFieldsGroupedByTabAndSection, @@ -155,8 +157,17 @@ export default defineComponent({ } await this.setDoc(); + focusedDocsRef.add(this.docOrNull); this.updateGroupedFields(); }, + activated(): void { + docsPathRef.value = docsPathMap[this.schemaName] ?? ''; + focusedDocsRef.add(this.docOrNull); + }, + deactivated(): void { + docsPathRef.value = ''; + focusedDocsRef.add(this.docOrNull); + }, computed: { hasDoc(): boolean { return !!this.docOrNull; diff --git a/src/pages/CommonForm/CommonFormSection.vue b/src/pages/CommonForm/CommonFormSection.vue index dac5dce2..091f3c39 100644 --- a/src/pages/CommonForm/CommonFormSection.vue +++ b/src/pages/CommonForm/CommonFormSection.vue @@ -18,8 +18,10 @@
- + + - diff --git a/src/pages/Settings/TabBase.vue b/src/pages/Settings/TabBase.vue deleted file mode 100644 index ae402618..00000000 --- a/src/pages/Settings/TabBase.vue +++ /dev/null @@ -1,59 +0,0 @@ - - diff --git a/src/pages/Settings/TabGeneral.vue b/src/pages/Settings/TabGeneral.vue deleted file mode 100644 index 2061393d..00000000 --- a/src/pages/Settings/TabGeneral.vue +++ /dev/null @@ -1,49 +0,0 @@ - diff --git a/src/pages/Settings/TabInvoice.vue b/src/pages/Settings/TabInvoice.vue deleted file mode 100644 index 2dde33e6..00000000 --- a/src/pages/Settings/TabInvoice.vue +++ /dev/null @@ -1,101 +0,0 @@ - - diff --git a/src/pages/Settings/TabSystem.vue b/src/pages/Settings/TabSystem.vue deleted file mode 100644 index dd87f92f..00000000 --- a/src/pages/Settings/TabSystem.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - diff --git a/src/utils/ipcCalls.ts b/src/utils/ipcCalls.ts index 7e3477af..3049c82d 100644 --- a/src/utils/ipcCalls.ts +++ b/src/utils/ipcCalls.ts @@ -10,6 +10,10 @@ import { SelectFileOptions, SelectFileReturn } from 'utils/types'; import { setLanguageMap } from './language'; import { showMessageDialog, showToast } from './ui'; +export function reloadWindow() { + return ipcRenderer.send(IPC_MESSAGES.RELOAD_MAIN_WINDOW); +} + export async function selectFile( options: SelectFileOptions ): Promise { diff --git a/src/utils/language.ts b/src/utils/language.ts index 901a0a88..4b61272a 100644 --- a/src/utils/language.ts +++ b/src/utils/language.ts @@ -2,7 +2,8 @@ import { ipcRenderer } from 'electron'; import { DEFAULT_LANGUAGE } from 'fyo/utils/consts'; import { setLanguageMapOnTranslationString } from 'fyo/utils/translation'; import { fyo } from 'src/initFyo'; -import { IPC_ACTIONS, IPC_MESSAGES } from 'utils/messages'; +import { IPC_ACTIONS } from 'utils/messages'; +import { reloadWindow } from './ipcCalls'; import { systemLanguageRef } from './refs'; import { showToast } from './ui'; @@ -47,7 +48,7 @@ export async function setLanguageMap( } if (!dontReload && success && initLanguage !== oldLanguage) { - await ipcRenderer.send(IPC_MESSAGES.RELOAD_MAIN_WINDOW); + reloadWindow(); } return success; }