mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
feat: pos settings
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -46,6 +46,7 @@ export enum ModelNameEnum {
|
||||
Location = 'Location',
|
||||
CustomForm = 'CustomForm',
|
||||
CustomField = 'CustomField',
|
||||
POSSettings = 'POSSettings',
|
||||
POSShift = 'POSShift'
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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,
|
||||
];
|
||||
|
||||
@@ -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<string, Field[]> {
|
||||
|
||||
Reference in New Issue
Block a user