ofpos-shared-core 2.0.0-alpha.1 → 2.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,6 +33,18 @@ export interface IBackupScheduler {
33
33
  * Menghentikan scheduler jika sedang berjalan.
34
34
  */
35
35
  stop(): void;
36
+ /**
37
+ * Menjalankan backup manual segera.
38
+ */
39
+ backupNow(payload?: Record<string, unknown>): Promise<any>;
40
+ /**
41
+ * Menjalankan restore manual dari backup terbaru atau backupId tertentu.
42
+ */
43
+ restoreBackup(options?: {
44
+ backupId?: string;
45
+ dryRun?: boolean;
46
+ [key: string]: unknown;
47
+ }): Promise<any>;
36
48
  }
37
49
  /**
38
50
  * Scheduler untuk melakukan backup data lokal secara berkala.
@@ -70,6 +82,14 @@ export declare class BackupScheduler {
70
82
  lastRestoreDrillAt: number | null;
71
83
  started: boolean;
72
84
  };
85
+ backupNow(payload?: Record<string, unknown>): Promise<any>;
86
+ restoreBackup(options?: {
87
+ backupId?: string;
88
+ dryRun?: boolean;
89
+ [key: string]: unknown;
90
+ }): Promise<any>;
73
91
  runBackupTask(): Promise<void>;
74
92
  runRestoreDrill(): Promise<void>;
93
+ private normalizeBackupList;
94
+ private isReadyBackupStatus;
75
95
  }
@@ -6,6 +6,7 @@ export interface FinancialSetting {
6
6
  fiscalYearStart: string;
7
7
  version: number;
8
8
  lastModified: string;
9
+ deleted: boolean;
9
10
  }
10
11
  export interface FinancialSettingData {
11
12
  costingMethod: string;
@@ -0,0 +1,59 @@
1
+ import { PosCore } from '../PosCore';
2
+ export type CheckoutComputationInput = {
3
+ lines: Array<{
4
+ productId: string;
5
+ quantity: number;
6
+ uomId?: string | null;
7
+ }>;
8
+ discountCodes?: string[];
9
+ customerId?: string | null;
10
+ customerGroupId?: string | null;
11
+ paymentMethod: 'cash' | 'card' | 'bank_transfer' | 'tempo';
12
+ dueDate?: string | null;
13
+ cashReceived?: number | null;
14
+ taxMode?: 'exclusive' | 'inclusive';
15
+ };
16
+ export type CheckoutComputationResult = {
17
+ pricedItems: Array<{
18
+ productId: string;
19
+ quantity: number;
20
+ uomId?: string | null;
21
+ unitPrice: number;
22
+ lineSubTotal: number;
23
+ }>;
24
+ subTotal: number;
25
+ discount: number;
26
+ totalBeforeTax: number;
27
+ tax: {
28
+ mode: 'exclusive' | 'inclusive';
29
+ taxBase: number;
30
+ ppn: number;
31
+ pph: number;
32
+ };
33
+ finalTotal: number;
34
+ payment: {
35
+ method: 'cash' | 'card' | 'bank_transfer' | 'tempo';
36
+ amountDue: number;
37
+ cashReceived: number | null;
38
+ changeDue: number | null;
39
+ };
40
+ flags: {
41
+ requiresCustomer: boolean;
42
+ requiresDueDate: boolean;
43
+ isTaxActive: boolean;
44
+ };
45
+ };
46
+ export interface ICheckoutComputationService {
47
+ computeCheckout(input: CheckoutComputationInput): Promise<CheckoutComputationResult>;
48
+ }
49
+ export declare class CheckoutComputationService implements ICheckoutComputationService {
50
+ private context;
51
+ constructor(context: PosCore);
52
+ private get pricingService();
53
+ private get customerService();
54
+ private toNumber;
55
+ private roundMoney;
56
+ private normalizeDiscountCodes;
57
+ private resolveCustomerGroupId;
58
+ computeCheckout(input: CheckoutComputationInput): Promise<CheckoutComputationResult>;
59
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,34 @@
1
1
  import { PosCore } from '../PosCore';
2
2
  import { DbAdapter, QueryOptions } from 'ofcore';
3
3
  import { Product, ProductData } from '../models/Product';
4
+ export interface ProductCatalogImportOptions {
5
+ createMissingCategories?: boolean;
6
+ applyStockToExisting?: boolean;
7
+ source?: string | null;
8
+ }
9
+ export interface ProductCatalogImportError {
10
+ rowNumber: number;
11
+ code: string;
12
+ message: string;
13
+ row: Record<string, string>;
14
+ }
15
+ export interface ProductCatalogImportRowResult {
16
+ rowNumber: number;
17
+ action: 'created' | 'updated' | 'skipped';
18
+ productId: string | null;
19
+ productName: string;
20
+ stockApplied: number;
21
+ notes: string[];
22
+ }
23
+ export interface ProductCatalogImportResult {
24
+ processedRows: number;
25
+ createdCount: number;
26
+ updatedCount: number;
27
+ skippedCount: number;
28
+ errorCount: number;
29
+ rows: ProductCatalogImportRowResult[];
30
+ errors: ProductCatalogImportError[];
31
+ }
4
32
  /** Service interface for Product operations. */
5
33
  export interface IProductService {
6
34
  /** Add new Product. */
@@ -24,6 +52,10 @@ export interface IProductService {
24
52
  getProductsByQrCode(value: string, tx?: DbAdapter): Promise<Product[]>;
25
53
  /** Search Product by full-text keyword. */
26
54
  searchProducts(keyword: string, options?: QueryOptions, tx?: DbAdapter): Promise<Product[]>;
55
+ /** Template CSV minimal untuk onboarding katalog. */
56
+ getCatalogImportTemplateCsv(): string;
57
+ /** Impor katalog produk dari CSV. */
58
+ importProductsFromCsv(csvText: string, options?: ProductCatalogImportOptions): Promise<ProductCatalogImportResult>;
27
59
  }
28
60
  /** Service implementation for Product operations. */
29
61
  export declare class ProductService implements IProductService {
@@ -56,4 +88,6 @@ export declare class ProductService implements IProductService {
56
88
  getProductsByQrCode(value: string, tx?: DbAdapter): Promise<Product[]>;
57
89
  /** Search Product by full-text keyword. */
58
90
  searchProducts(keyword: string, options?: QueryOptions, tx?: DbAdapter): Promise<Product[]>;
91
+ getCatalogImportTemplateCsv(): string;
92
+ importProductsFromCsv(csvText: string, options?: ProductCatalogImportOptions): Promise<ProductCatalogImportResult>;
59
93
  }
@@ -1,8 +1,23 @@
1
1
  import type { LoggerAdapter } from 'ofcore';
2
2
  import type { PosCashAdjustmentAccountMapping, PosCashAdjustmentFinanceProjection, PosExpenseAccountMapping, PosExpenseFinanceProjection, PosPurchaseAccountMapping, PosPurchaseFinanceProjection, PosReturnAccountMapping, PosReturnFinanceProjection, PosSaleAccountMapping, PosSettlementAccountMapping, PosSettlementFinanceProjection, ScopedAccountMapping, ScopedPosSaleFinanceProjection } from '../finance/offinanceProjection';
3
+ export interface PosSaleFinalizedSummary {
4
+ saleId: string;
5
+ saleDate: string;
6
+ customerId: string | null;
7
+ userId: string;
8
+ total: number;
9
+ finalTotal: number;
10
+ transactionCurrencyCode: string | null;
11
+ totalInBaseCurrency: number | null;
12
+ finalTotalInBaseCurrency: number | null;
13
+ note: string | null;
14
+ tenantId?: string | null;
15
+ branchId?: string | null;
16
+ }
3
17
  export interface ServiceRuntimeOptions {
4
18
  logger?: LoggerAdapter;
5
19
  financeProjectionSink?: (projection: ScopedPosSaleFinanceProjection | PosPurchaseFinanceProjection | PosReturnFinanceProjection | PosExpenseFinanceProjection | PosSettlementFinanceProjection | PosCashAdjustmentFinanceProjection) => Promise<void> | void;
20
+ saleFinalizedSink?: (summary: PosSaleFinalizedSummary) => Promise<void> | void;
6
21
  saleAccountMapping?: ScopedAccountMapping<PosSaleAccountMapping>;
7
22
  purchaseAccountMapping?: ScopedAccountMapping<PosPurchaseAccountMapping>;
8
23
  returnAccountMapping?: ScopedAccountMapping<PosReturnAccountMapping>;
@@ -89,6 +89,7 @@ export declare class SaleService implements ISaleService {
89
89
  private normalizeDocNo;
90
90
  private toBaseQuantity;
91
91
  private emitFinanceProjection;
92
+ private emitSaleFinalizedSummary;
92
93
  getDuplicateDocumentNumbers(options?: {
93
94
  dateFrom?: string;
94
95
  dateTo?: string;
@@ -50,6 +50,7 @@ export declare class ShiftService implements IShiftService {
50
50
  * @param context - PosCore context
51
51
  */
52
52
  constructor(context: PosCore);
53
+ private computeCashMovementsForShiftWindow;
53
54
  /** Add new Shift. */
54
55
  addShift(data: ShiftData, tx?: DbAdapter): Promise<Shift>;
55
56
  /** Update existing Shift. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofpos-shared-core",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.3",
4
4
  "description": "Offline-first POS shared-core (domain and integration runtime) for of* host apps; platform and database agnostic.",
5
5
  "private": false,
6
6
  "author": {
@@ -64,11 +64,11 @@
64
64
  "dist"
65
65
  ],
66
66
  "dependencies": {
67
- "ofcore": "0.2.0-alpha.0",
68
- "offinance-shared-core": "0.1.0-alpha.1"
67
+ "ofcore": "0.2.0-alpha.1",
68
+ "offinance-shared-core": "0.1.0-alpha.2"
69
69
  },
70
70
  "peerDependencies": {
71
- "ofauth-shared-core": "0.2.0-alpha.0"
71
+ "ofauth-shared-core": "0.2.0-alpha.1"
72
72
  },
73
73
  "peerDependenciesMeta": {
74
74
  "ofauth-shared-core": {
@@ -90,7 +90,7 @@
90
90
  "jest": "^30.2.0",
91
91
  "jest-html-reporters": "^3.1.7",
92
92
  "mitt": "^3.0.1",
93
- "ofauth-shared-core": "0.2.0-alpha.0",
93
+ "ofauth-shared-core": "0.2.0-alpha.1",
94
94
  "react": "^19.2.0",
95
95
  "reflect-metadata": "^0.2.2",
96
96
  "rimraf": "^6.0.1",