2
0
mirror of https://github.com/frappe/books.git synced 2025-01-03 07:12:21 +00:00

feat: pos settings

This commit is contained in:
akshayitzme 2023-09-05 17:33:42 +05:30 committed by akshayitzme
parent db2a97d01e
commit 8186f12548
9 changed files with 78 additions and 33 deletions

View File

@ -10,6 +10,7 @@ import type { Defaults } from 'models/baseModels/Defaults/Defaults';
import type { PrintSettings } from 'models/baseModels/PrintSettings/PrintSettings'; import type { PrintSettings } from 'models/baseModels/PrintSettings/PrintSettings';
import type { InventorySettings } from 'models/inventory/InventorySettings'; import type { InventorySettings } from 'models/inventory/InventorySettings';
import type { Misc } from 'models/baseModels/Misc'; 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'; import type { POSShift } from 'models/inventory/Point of Sale/POSShift';
/** /**
@ -55,6 +56,7 @@ export interface SinglesMap {
SystemSettings?: SystemSettings; SystemSettings?: SystemSettings;
AccountingSettings?: AccountingSettings; AccountingSettings?: AccountingSettings;
InventorySettings?: InventorySettings; InventorySettings?: InventorySettings;
POSSettings?: POSSettings;
POSShift?: POSShift; POSShift?: POSShift;
PrintSettings?: PrintSettings; PrintSettings?: PrintSettings;
Defaults?: Defaults; Defaults?: Defaults;

View File

@ -2,6 +2,7 @@ import { DefaultCashDenominations } from 'models/inventory/Point of Sale/Default
import { Doc } from 'fyo/model/doc'; import { Doc } from 'fyo/model/doc';
import { FiltersMap, HiddenMap } from 'fyo/model/types'; import { FiltersMap, HiddenMap } from 'fyo/model/types';
import { ModelNameEnum } from 'models/types'; import { ModelNameEnum } from 'models/types';
import { PartyRoleEnum } from '../Party/types';
export class Defaults extends Doc { export class Defaults extends Doc {
// Auto Payments // Auto Payments
@ -37,11 +38,8 @@ export class Defaults extends Doc {
stockMovementPrintTemplate?: string; stockMovementPrintTemplate?: string;
// Point of Sale // Point of Sale
posAdjustmentAccount?: string;
posCashDenominations?: DefaultCashDenominations[]; posCashDenominations?: DefaultCashDenominations[];
posCustomer?: string; posCustomer?: string;
posInventory?: string;
posPrintTemplate?: string;
static commonFilters = { static commonFilters = {
// Auto Payments // Auto Payments
@ -81,6 +79,7 @@ export class Defaults extends Doc {
type: ModelNameEnum.PurchaseReceipt, type: ModelNameEnum.PurchaseReceipt,
}), }),
stockMovementPrintTemplate: () => ({ type: ModelNameEnum.StockMovement }), stockMovementPrintTemplate: () => ({ type: ModelNameEnum.StockMovement }),
posCustomer: () => ({ role: PartyRoleEnum.Customer }),
}; };
static filters: FiltersMap = this.commonFilters; static filters: FiltersMap = this.commonFilters;
@ -103,11 +102,8 @@ export class Defaults extends Doc {
shipmentPrintTemplate: this.getInventoryHidden(), shipmentPrintTemplate: this.getInventoryHidden(),
purchaseReceiptPrintTemplate: this.getInventoryHidden(), purchaseReceiptPrintTemplate: this.getInventoryHidden(),
stockMovementPrintTemplate: this.getInventoryHidden(), stockMovementPrintTemplate: this.getInventoryHidden(),
posAdjustmentAccount: this.getPointOfSaleHidden(),
posCashDenominations: this.getPointOfSaleHidden(), posCashDenominations: this.getPointOfSaleHidden(),
posCustomer: this.getPointOfSaleHidden(), posCustomer: this.getPointOfSaleHidden(),
posInventory: this.getPointOfSaleHidden(),
posPrintTemplate: this.getPointOfSaleHidden(),
}; };
} }

View File

@ -37,6 +37,7 @@ import { ClosingAmounts } from './inventory/Point of Sale/ClosingAmounts';
import { ClosingCash } from './inventory/Point of Sale/ClosingCash'; import { ClosingCash } from './inventory/Point of Sale/ClosingCash';
import { OpeningAmounts } from './inventory/Point of Sale/OpeningAmounts'; import { OpeningAmounts } from './inventory/Point of Sale/OpeningAmounts';
import { OpeningCash } from './inventory/Point of Sale/OpeningCash'; import { OpeningCash } from './inventory/Point of Sale/OpeningCash';
import { POSSettings } from './inventory/Point of Sale/POSSettings';
import { POSShift } from './inventory/Point of Sale/POSShift'; import { POSShift } from './inventory/Point of Sale/POSShift';
export const models = { export const models = {
@ -80,6 +81,7 @@ export const models = {
ClosingCash, ClosingCash,
OpeningAmounts, OpeningAmounts,
OpeningCash, OpeningCash,
POSSettings,
POSShift, POSShift,
} as ModelMap; } as ModelMap;

View File

@ -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,
}),
};
}

View File

@ -46,6 +46,7 @@ export enum ModelNameEnum {
Location = 'Location', Location = 'Location',
CustomForm = 'CustomForm', CustomForm = 'CustomForm',
CustomField = 'CustomField', CustomField = 'CustomField',
POSSettings = 'POSSettings',
POSShift = 'POSShift' POSShift = 'POSShift'
} }

View File

@ -173,30 +173,6 @@
"create": true, "create": true,
"section": "Point of Sale" "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", "fieldname": "posCashDenominations",
"label": "Cash Denominations", "label": "Cash Denominations",

View File

@ -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"
}
]
}

View File

@ -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 DefaultCashDenominations from './app/inventory/Point of Sale/DefaultCashDenominations.json';
import OpeningAmounts from './app/inventory/Point of Sale/OpeningAmounts.json'; import OpeningAmounts from './app/inventory/Point of Sale/OpeningAmounts.json';
import OpeningCash from './app/inventory/Point of Sale/OpeningCash.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 POSShift from './app/inventory/Point of Sale/POSShift.json';
import POSShiftAmounts from './app/inventory/Point of Sale/POSShiftAmounts.json'; import POSShiftAmounts from './app/inventory/Point of Sale/POSShiftAmounts.json';
import { Schema, SchemaStub } from './types'; import { Schema, SchemaStub } from './types';
@ -144,6 +145,7 @@ export const appSchemas: Schema[] | SchemaStub[] = [
DefaultCashDenominations as Schema, DefaultCashDenominations as Schema,
OpeningAmounts as Schema, OpeningAmounts as Schema,
OpeningCash as Schema, OpeningCash as Schema,
POSSettings as Schema,
POSShift as Schema, POSShift as Schema,
POSShiftAmounts as Schema, POSShiftAmounts as Schema,
]; ];

View File

@ -115,6 +115,7 @@ export default defineComponent({
ModelNameEnum.AccountingSettings, ModelNameEnum.AccountingSettings,
ModelNameEnum.InventorySettings, ModelNameEnum.InventorySettings,
ModelNameEnum.Defaults, ModelNameEnum.Defaults,
ModelNameEnum.POSSettings,
ModelNameEnum.PrintSettings, ModelNameEnum.PrintSettings,
ModelNameEnum.SystemSettings, ModelNameEnum.SystemSettings,
].some((s) => this.fyo.singles[s]?.canSave); ].some((s) => this.fyo.singles[s]?.canSave);
@ -133,6 +134,7 @@ export default defineComponent({
[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`,
[ModelNameEnum.POSSettings]: this.t`POS Settings`,
[ModelNameEnum.SystemSettings]: this.t`System`, [ModelNameEnum.SystemSettings]: this.t`System`,
}; };
}, },
@ -140,16 +142,26 @@ export default defineComponent({
const enableInventory = const enableInventory =
!!this.fyo.singles.AccountingSettings?.enableInventory; !!this.fyo.singles.AccountingSettings?.enableInventory;
const enablePOS = !!this.fyo.singles.InventorySettings?.enablePointOfSale;
return [ return [
ModelNameEnum.AccountingSettings, ModelNameEnum.AccountingSettings,
ModelNameEnum.InventorySettings, ModelNameEnum.InventorySettings,
ModelNameEnum.Defaults, ModelNameEnum.Defaults,
ModelNameEnum.POSSettings,
ModelNameEnum.PrintSettings, ModelNameEnum.PrintSettings,
ModelNameEnum.SystemSettings, ModelNameEnum.SystemSettings,
] ]
.filter((s) => .filter((s) => {
s === ModelNameEnum.InventorySettings ? enableInventory : true if (s === ModelNameEnum.InventorySettings && !enableInventory) {
) return false;
}
if (s === ModelNameEnum.POSSettings && !enablePOS) {
return false;
}
return true;
})
.map((s) => this.fyo.schemaMap[s]!); .map((s) => this.fyo.schemaMap[s]!);
}, },
activeGroup(): Map<string, Field[]> { activeGroup(): Map<string, Field[]> {