diff --git a/fyo/model/types.ts b/fyo/model/types.ts index 2868a5c0..9ca3a536 100644 --- a/fyo/model/types.ts +++ b/fyo/model/types.ts @@ -11,7 +11,8 @@ import type { PrintSettings } from 'models/baseModels/PrintSettings/PrintSetting 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'; +import type { POSOpeningShift } from 'models/inventory/Point of Sale/POSOpeningShift'; +import type { POSClosingShift } from 'models/inventory/Point of Sale/POSClosingShift'; /** * The functions below are used for dynamic evaluation @@ -57,7 +58,8 @@ export interface SinglesMap { AccountingSettings?: AccountingSettings; InventorySettings?: InventorySettings; POSSettings?: POSSettings; - POSShift?: POSShift; + POSOpeningShift?: POSOpeningShift; + POSClosingShift?: POSClosingShift; PrintSettings?: PrintSettings; Defaults?: Defaults; Misc?: Misc; diff --git a/models/index.ts b/models/index.ts index 260e2209..e3078d88 100644 --- a/models/index.ts +++ b/models/index.ts @@ -48,7 +48,8 @@ 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'; +import { POSOpeningShift } from './inventory/Point of Sale/POSOpeningShift'; +import { POSClosingShift } from './inventory/Point of Sale/POSClosingShift'; import { ERPNextSyncSettings } from './baseModels/ERPNextSyncSettings/ERPNextSyncSettings'; import { ERPNextSyncQueue } from './baseModels/ERPNextSyncQueue/ERPNextSyncQueue'; import { FetchFromERPNextQueue } from './baseModels/FetchFromERPNextQueue/FetchFromERPNextQueue'; @@ -105,7 +106,8 @@ export const models = { OpeningAmounts, OpeningCash, POSSettings, - POSShift, + POSOpeningShift, + POSClosingShift, // ERPNext Sync ERPNextSyncSettings, ERPNextSyncQueue, diff --git a/models/inventory/InventorySettings.ts b/models/inventory/InventorySettings.ts index 8cb64bce..bf3d90fb 100644 --- a/models/inventory/InventorySettings.ts +++ b/models/inventory/InventorySettings.ts @@ -46,7 +46,7 @@ export class InventorySettings extends Doc { return !!this.enableStockReturns; }, enablePointOfSale: () => { - return !!this.fyo.singles.POSShift?.isShiftOpen; + return !!this.fyo.singles.POSSettings?.isShiftOpen; }, }; } diff --git a/models/inventory/Point of Sale/POSClosingShift.ts b/models/inventory/Point of Sale/POSClosingShift.ts new file mode 100644 index 00000000..3d80754f --- /dev/null +++ b/models/inventory/Point of Sale/POSClosingShift.ts @@ -0,0 +1,33 @@ +import { ListViewSettings } from 'fyo/model/types'; +import { ClosingAmounts } from './ClosingAmounts'; +import { ClosingCash } from './ClosingCash'; +import { Doc } from 'fyo/model/doc'; + +export class POSClosingShift extends Doc { + closingAmounts?: ClosingAmounts[]; + closingCash?: ClosingCash[]; + closingDate?: Date; + + get closingCashAmount() { + if (!this.closingCash) { + return this.fyo.pesa(0); + } + + let closingAmount = this.fyo.pesa(0); + + this.closingCash.map((row: ClosingCash) => { + const denomination = row.denomination ?? this.fyo.pesa(0); + const count = row.count ?? 0; + + const amount = denomination.mul(count); + closingAmount = closingAmount.add(amount); + }); + return closingAmount; + } + + static getListViewSettings(): ListViewSettings { + return { + columns: ['name', 'closingDate'], + }; + } +} diff --git a/models/inventory/Point of Sale/POSShift.ts b/models/inventory/Point of Sale/POSOpeningShift.ts similarity index 58% rename from models/inventory/Point of Sale/POSShift.ts rename to models/inventory/Point of Sale/POSOpeningShift.ts index b56fc859..b9e023ad 100644 --- a/models/inventory/Point of Sale/POSShift.ts +++ b/models/inventory/Point of Sale/POSOpeningShift.ts @@ -1,14 +1,9 @@ -import { ClosingAmounts } from './ClosingAmounts'; -import { ClosingCash } from './ClosingCash'; import { Doc } from 'fyo/model/doc'; import { OpeningAmounts } from './OpeningAmounts'; import { OpeningCash } from './OpeningCash'; +import { ListViewSettings } from 'fyo/model/types'; -export class POSShift extends Doc { - closingAmounts?: ClosingAmounts[]; - closingCash?: ClosingCash[]; - closingDate?: Date; - isShiftOpen?: boolean; +export class POSOpeningShift extends Doc { openingAmounts?: OpeningAmounts[]; openingCash?: OpeningCash[]; openingDate?: Date; @@ -30,23 +25,6 @@ export class POSShift extends Doc { return openingAmount; } - get closingCashAmount() { - if (!this.closingCash) { - return this.fyo.pesa(0); - } - - let closingAmount = this.fyo.pesa(0); - - this.closingCash.map((row: ClosingCash) => { - const denomination = row.denomination ?? this.fyo.pesa(0); - const count = row.count ?? 0; - - const amount = denomination.mul(count); - closingAmount = closingAmount.add(amount); - }); - return closingAmount; - } - get openingTransferAmount() { if (!this.openingAmounts) { return this.fyo.pesa(0); @@ -58,4 +36,10 @@ export class POSShift extends Doc { return transferAmountRow.amount ?? this.fyo.pesa(0); } + + static getListViewSettings(): ListViewSettings { + return { + columns: ['name', 'openingDate'], + }; + } } diff --git a/models/inventory/Point of Sale/POSSettings.ts b/models/inventory/Point of Sale/POSSettings.ts index 4226a9db..9f8f615a 100644 --- a/models/inventory/Point of Sale/POSSettings.ts +++ b/models/inventory/Point of Sale/POSSettings.ts @@ -6,6 +6,7 @@ import { } from 'models/baseModels/Account/types'; export class POSSettings extends Doc { + isShiftOpen?: boolean; inventory?: string; cashAccount?: string; writeOffAccount?: string; diff --git a/models/types.ts b/models/types.ts index 11cf1fd2..141f5b9c 100644 --- a/models/types.ts +++ b/models/types.ts @@ -59,7 +59,8 @@ export enum ModelNameEnum { CustomForm = 'CustomForm', CustomField = 'CustomField', POSSettings = 'POSSettings', - POSShift = 'POSShift', + POSOpeningShift = 'POSOpeningShift', + POSClosingShift = 'POSClosingShift', ERPNextSyncSettings= 'ERPNextSyncSettings', ERPNextSyncQueue = 'ERPNextSyncQueue', diff --git a/schemas/app/inventory/Point of Sale/POSClosingShift.json b/schemas/app/inventory/Point of Sale/POSClosingShift.json new file mode 100644 index 00000000..16ddce86 --- /dev/null +++ b/schemas/app/inventory/Point of Sale/POSClosingShift.json @@ -0,0 +1,24 @@ +{ + "name": "POSClosingShift", + "label": "POS Closing Shift", + "naming": "random", + "fields": [ + { + "fieldname": "closingDate", + "label": "Closing Date", + "fieldtype": "Datetime" + }, + { + "fieldname": "closingCash", + "fieldtype": "Table", + "label": "Closing Cash", + "target": "ClosingCash" + }, + { + "fieldname": "closingAmounts", + "fieldtype": "Table", + "label": "Closing Amounts", + "target": "ClosingAmounts" + } + ] +} diff --git a/schemas/app/inventory/Point of Sale/POSOpeningShift.json b/schemas/app/inventory/Point of Sale/POSOpeningShift.json new file mode 100644 index 00000000..e3927926 --- /dev/null +++ b/schemas/app/inventory/Point of Sale/POSOpeningShift.json @@ -0,0 +1,24 @@ +{ + "name": "POSOpeningShift", + "label": "POS Opening Shift", + "naming": "random", + "fields": [ + { + "fieldname": "openingDate", + "label": "Opening Date", + "fieldtype": "Datetime" + }, + { + "fieldname": "openingCash", + "fieldtype": "Table", + "label": "Opening Cash", + "target": "OpeningCash" + }, + { + "fieldname": "openingAmounts", + "fieldtype": "Table", + "label": "Opening Amounts", + "target": "OpeningAmounts" + } + ] +} diff --git a/schemas/app/inventory/Point of Sale/POSSettings.json b/schemas/app/inventory/Point of Sale/POSSettings.json index b3e3746a..5f8d12d5 100644 --- a/schemas/app/inventory/Point of Sale/POSSettings.json +++ b/schemas/app/inventory/Point of Sale/POSSettings.json @@ -4,6 +4,13 @@ "isSingle": true, "isChild": false, "fields": [ + { + "fieldname": "isShiftOpen", + "label": "Is POS Shift Open", + "fieldtype": "Check", + "default": false, + "hidden": false + }, { "fieldname": "inventory", "label": "Inventory", diff --git a/schemas/app/inventory/Point of Sale/POSShift.json b/schemas/app/inventory/Point of Sale/POSShift.json deleted file mode 100644 index c17b834f..00000000 --- a/schemas/app/inventory/Point of Sale/POSShift.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "POSShift", - "isSingle": true, - "isChild": false, - "fields": [ - { - "fieldname": "isShiftOpen", - "label": "Is POS Shift Open", - "fieldtype": "Check", - "default": false - }, - { - "fieldname": "openingDate", - "label": "Opening Date", - "fieldtype": "Datetime" - }, - { - "fieldname": "closingDate", - "label": "Closing Date", - "fieldtype": "Datetime" - }, - { - "fieldname": "openingCash", - "fieldtype": "Table", - "target": "OpeningCash" - }, - { - "fieldname": "closingCash", - "fieldtype": "Table", - "target": "ClosingCash" - }, - { - "fieldname": "openingAmounts", - "fieldtype": "Table", - "target": "OpeningAmounts" - }, - { - "fieldname": "closingAmounts", - "fieldtype": "Table", - "target": "ClosingAmounts" - } - ] -} diff --git a/schemas/schemas.ts b/schemas/schemas.ts index 273988c7..b2289980 100644 --- a/schemas/schemas.ts +++ b/schemas/schemas.ts @@ -70,7 +70,8 @@ import DefaultCashDenominations from './app/inventory/Point of Sale/DefaultCashD 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 POSOpeningShift from './app/inventory/Point of Sale/POSOpeningShift.json'; +import POSClosingShift from './app/inventory/Point of Sale/POSClosingShift.json'; import POSShiftAmounts from './app/inventory/Point of Sale/POSShiftAmounts.json'; import ERPNextSyncSettings from './app/ERPNextSyncSettings.json'; import ERPNextSyncQueue from './app/ERPNextSyncQueue.json'; @@ -173,7 +174,8 @@ export const appSchemas: Schema[] | SchemaStub[] = [ OpeningAmounts as Schema, OpeningCash as Schema, POSSettings as Schema, - POSShift as Schema, + POSOpeningShift as Schema, + POSClosingShift as Schema, POSShiftAmounts as Schema, ERPNextSyncSettings as Schema, diff --git a/src/pages/POS/ClosePOSShiftModal.vue b/src/pages/POS/ClosePOSShiftModal.vue index 57b5f31e..12fba62d 100644 --- a/src/pages/POS/ClosePOSShiftModal.vue +++ b/src/pages/POS/ClosePOSShiftModal.vue @@ -13,9 +13,8 @@ :df="getField('closingCash')" :show-header="true" :border="true" - :value="posShiftDoc?.closingCash ?? []" + :value="posClosingShiftDoc?.closingCash ?? []" :read-only="false" - @row-change="handleChange" />