diff --git a/fyo/model/types.ts b/fyo/model/types.ts index e99858cb..13f0bc40 100644 --- a/fyo/model/types.ts +++ b/fyo/model/types.ts @@ -10,6 +10,7 @@ import type { Defaults } from 'models/baseModels/Defaults/Defaults'; import type { PrintSettings } from 'models/baseModels/PrintSettings/PrintSettings'; import type { InventorySettings } from 'models/inventory/InventorySettings'; import type { Misc } from 'models/baseModels/Misc'; +import type { POSSettings } from 'models/inventory/Point of Sale/POSSettings'; import type { POSShift } from 'models/inventory/Point of Sale/POSShift'; /** @@ -55,6 +56,7 @@ export interface SinglesMap { SystemSettings?: SystemSettings; AccountingSettings?: AccountingSettings; InventorySettings?: InventorySettings; + POSSettings?: POSSettings; POSShift?: POSShift; PrintSettings?: PrintSettings; Defaults?: Defaults; diff --git a/models/baseModels/Defaults/Defaults.ts b/models/baseModels/Defaults/Defaults.ts index 180f07c7..2515d35e 100644 --- a/models/baseModels/Defaults/Defaults.ts +++ b/models/baseModels/Defaults/Defaults.ts @@ -2,6 +2,7 @@ import { DefaultCashDenominations } from 'models/inventory/Point of Sale/Default import { Doc } from 'fyo/model/doc'; import { FiltersMap, HiddenMap } from 'fyo/model/types'; import { ModelNameEnum } from 'models/types'; +import { PartyRoleEnum } from '../Party/types'; export class Defaults extends Doc { // Auto Payments @@ -37,11 +38,8 @@ export class Defaults extends Doc { stockMovementPrintTemplate?: string; // Point of Sale - posAdjustmentAccount?: string; posCashDenominations?: DefaultCashDenominations[]; posCustomer?: string; - posInventory?: string; - posPrintTemplate?: string; static commonFilters = { // Auto Payments @@ -81,6 +79,7 @@ export class Defaults extends Doc { type: ModelNameEnum.PurchaseReceipt, }), stockMovementPrintTemplate: () => ({ type: ModelNameEnum.StockMovement }), + posCustomer: () => ({ role: PartyRoleEnum.Customer }), }; static filters: FiltersMap = this.commonFilters; @@ -103,11 +102,8 @@ export class Defaults extends Doc { shipmentPrintTemplate: this.getInventoryHidden(), purchaseReceiptPrintTemplate: this.getInventoryHidden(), stockMovementPrintTemplate: this.getInventoryHidden(), - posAdjustmentAccount: this.getPointOfSaleHidden(), posCashDenominations: this.getPointOfSaleHidden(), posCustomer: this.getPointOfSaleHidden(), - posInventory: this.getPointOfSaleHidden(), - posPrintTemplate: this.getPointOfSaleHidden(), }; } diff --git a/models/index.ts b/models/index.ts index 37cdef62..51c1c672 100644 --- a/models/index.ts +++ b/models/index.ts @@ -37,6 +37,7 @@ import { ClosingAmounts } from './inventory/Point of Sale/ClosingAmounts'; import { ClosingCash } from './inventory/Point of Sale/ClosingCash'; import { OpeningAmounts } from './inventory/Point of Sale/OpeningAmounts'; import { OpeningCash } from './inventory/Point of Sale/OpeningCash'; +import { POSSettings } from './inventory/Point of Sale/POSSettings'; import { POSShift } from './inventory/Point of Sale/POSShift'; export const models = { @@ -80,6 +81,7 @@ export const models = { ClosingCash, OpeningAmounts, OpeningCash, + POSSettings, POSShift, } as ModelMap; diff --git a/models/inventory/Point of Sale/POSSettings.ts b/models/inventory/Point of Sale/POSSettings.ts new file mode 100644 index 00000000..a36749b2 --- /dev/null +++ b/models/inventory/Point of Sale/POSSettings.ts @@ -0,0 +1,19 @@ +import { Doc } from 'fyo/model/doc'; +import { FiltersMap } from 'fyo/model/types'; +import { + AccountRootTypeEnum, + AccountTypeEnum, +} from 'models/baseModels/Account/types'; + +export class POSSettings extends Doc { + inventory?: string; + cashAccount?: string; + writeOffAccount?: string; + + static filters: FiltersMap = { + cashAccount: () => ({ + rootType: AccountRootTypeEnum.Asset, + accountType: AccountTypeEnum.Cash, + }), + }; +} diff --git a/models/types.ts b/models/types.ts index bbcc3ca9..b3fdf730 100644 --- a/models/types.ts +++ b/models/types.ts @@ -46,6 +46,7 @@ export enum ModelNameEnum { Location = 'Location', CustomForm = 'CustomForm', CustomField = 'CustomField', + POSSettings = 'POSSettings', POSShift = 'POSShift' } diff --git a/schemas/app/Defaults.json b/schemas/app/Defaults.json index 7b94b0a9..ba920134 100644 --- a/schemas/app/Defaults.json +++ b/schemas/app/Defaults.json @@ -173,30 +173,6 @@ "create": true, "section": "Point of Sale" }, - { - "fieldname": "posInventory", - "label": "Inventory", - "fieldtype": "Link", - "target": "Location", - "default": "Stores", - "section": "Point of Sale" - }, - { - "fieldname": "posPrintTemplate", - "label": "Print Template", - "fieldtype": "Link", - "target": "PrintTemplate", - "default": "Minimal - Sales Invoice", - "section": "Point of Sale" - }, - { - "fieldname": "posAdjustmentAccount", - "label": "Adjustment Account", - "fieldtype": "Link", - "target": "Account", - "default": "Write Off", - "section": "Point of Sale" - }, { "fieldname": "posCashDenominations", "label": "Cash Denominations", diff --git a/schemas/app/inventory/Point of Sale/POSSettings.json b/schemas/app/inventory/Point of Sale/POSSettings.json new file mode 100644 index 00000000..33697613 --- /dev/null +++ b/schemas/app/inventory/Point of Sale/POSSettings.json @@ -0,0 +1,35 @@ +{ + "name": "POSSettings", + "label": "POS Settings", + "isSingle": true, + "isChild": false, + "fields": [ + { + "fieldname": "inventory", + "label": "Inventory", + "fieldtype": "Link", + "target": "Location", + "create": true, + "default": "Stores", + "section": "Default" + }, + { + "fieldname": "cashAccount", + "label": "Counter Cash Account", + "fieldtype": "Link", + "target": "Account", + "required": true, + "create": true, + "section": "Default" + }, + { + "fieldname": "writeOffAccount", + "label": "Write Off Account", + "fieldtype": "Link", + "target": "Account", + "create": true, + "default": "Write Off", + "section": "Default" + } + ] +} diff --git a/schemas/schemas.ts b/schemas/schemas.ts index b3cce3bd..1e92f56c 100644 --- a/schemas/schemas.ts +++ b/schemas/schemas.ts @@ -58,6 +58,7 @@ import ClosingCash from './app/inventory/Point of Sale/ClosingCash.json'; import DefaultCashDenominations from './app/inventory/Point of Sale/DefaultCashDenominations.json'; import OpeningAmounts from './app/inventory/Point of Sale/OpeningAmounts.json'; import OpeningCash from './app/inventory/Point of Sale/OpeningCash.json'; +import POSSettings from './app/inventory/Point of Sale/POSSettings.json'; import POSShift from './app/inventory/Point of Sale/POSShift.json'; import POSShiftAmounts from './app/inventory/Point of Sale/POSShiftAmounts.json'; import { Schema, SchemaStub } from './types'; @@ -144,6 +145,7 @@ export const appSchemas: Schema[] | SchemaStub[] = [ DefaultCashDenominations as Schema, OpeningAmounts as Schema, OpeningCash as Schema, + POSSettings as Schema, POSShift as Schema, POSShiftAmounts as Schema, ]; diff --git a/src/pages/Settings/Settings.vue b/src/pages/Settings/Settings.vue index 7973cbb2..f4551221 100644 --- a/src/pages/Settings/Settings.vue +++ b/src/pages/Settings/Settings.vue @@ -115,6 +115,7 @@ export default defineComponent({ ModelNameEnum.AccountingSettings, ModelNameEnum.InventorySettings, ModelNameEnum.Defaults, + ModelNameEnum.POSSettings, ModelNameEnum.PrintSettings, ModelNameEnum.SystemSettings, ].some((s) => this.fyo.singles[s]?.canSave); @@ -133,6 +134,7 @@ export default defineComponent({ [ModelNameEnum.PrintSettings]: this.t`Print`, [ModelNameEnum.InventorySettings]: this.t`Inventory`, [ModelNameEnum.Defaults]: this.t`Defaults`, + [ModelNameEnum.POSSettings]: this.t`POS Settings`, [ModelNameEnum.SystemSettings]: this.t`System`, }; }, @@ -140,16 +142,26 @@ export default defineComponent({ const enableInventory = !!this.fyo.singles.AccountingSettings?.enableInventory; + const enablePOS = !!this.fyo.singles.InventorySettings?.enablePointOfSale; + return [ ModelNameEnum.AccountingSettings, ModelNameEnum.InventorySettings, ModelNameEnum.Defaults, + ModelNameEnum.POSSettings, ModelNameEnum.PrintSettings, ModelNameEnum.SystemSettings, ] - .filter((s) => - s === ModelNameEnum.InventorySettings ? enableInventory : true - ) + .filter((s) => { + if (s === ModelNameEnum.InventorySettings && !enableInventory) { + return false; + } + + if (s === ModelNameEnum.POSSettings && !enablePOS) { + return false; + } + return true; + }) .map((s) => this.fyo.schemaMap[s]!); }, activeGroup(): Map {