ofpos-shared-core 2.0.0-alpha.0 → 2.0.0-alpha.2
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.
- package/dist/DomainServices.d.ts +2 -1
- package/dist/PosCore.d.ts +5 -0
- package/dist/finance/offinanceProjection.d.ts +159 -0
- package/dist/index.browser.mjs +3 -3
- package/dist/index.browser.mjs.LEGAL.txt +1 -1
- package/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.LEGAL.txt +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +3 -3
- package/dist/index.esm.js.LEGAL.txt +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.LEGAL.txt +1 -1
- package/dist/integration/backupScheduler.d.ts +18 -0
- package/dist/services/expenseService.d.ts +4 -1
- package/dist/services/purchaseService.d.ts +4 -1
- package/dist/services/returnService.d.ts +4 -1
- package/dist/services/runtimeSupport.d.ts +12 -0
- package/dist/services/saleService.d.ts +4 -1
- package/dist/services/settlementService.d.ts +4 -1
- package/dist/services/transactionService.d.ts +4 -1
- package/package.json +3 -2
|
@@ -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,12 @@ 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>;
|
|
75
93
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PosCore } from '../PosCore';
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Expense, ExpenseData } from '../models/Expense';
|
|
4
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
4
5
|
/** Service interface for Expense operations. */
|
|
5
6
|
export interface IExpenseService {
|
|
6
7
|
/** Add new Expense. */
|
|
@@ -22,13 +23,15 @@ export interface IExpenseService {
|
|
|
22
23
|
/** Service implementation for Expense operations. */
|
|
23
24
|
export declare class ExpenseService implements IExpenseService {
|
|
24
25
|
private context;
|
|
26
|
+
private readonly _runtimeOptions;
|
|
25
27
|
private dbAdapter;
|
|
26
28
|
private changeQueue;
|
|
27
29
|
/**
|
|
28
30
|
* Initialize ExpenseService.
|
|
29
31
|
* @param context - PosCore context
|
|
30
32
|
*/
|
|
31
|
-
constructor(context: PosCore);
|
|
33
|
+
constructor(context: PosCore, _runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
34
|
+
private emitFinanceProjection;
|
|
32
35
|
/** Add new Expense. */
|
|
33
36
|
addExpense(data: ExpenseData, tx?: DbAdapter): Promise<Expense>;
|
|
34
37
|
/** Update existing Expense. */
|
|
@@ -2,6 +2,7 @@ import { PosCore } from '../PosCore';
|
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Purchase, PurchaseData } from '../models/Purchase';
|
|
4
4
|
import { PurchaseItem } from '../models/PurchaseItem';
|
|
5
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
5
6
|
export interface PurchaseCart {
|
|
6
7
|
supplierId: string;
|
|
7
8
|
items: Array<{
|
|
@@ -77,6 +78,7 @@ export interface IPurchaseService {
|
|
|
77
78
|
/** Service implementation for Purchase operations. */
|
|
78
79
|
export declare class PurchaseService implements IPurchaseService {
|
|
79
80
|
private context;
|
|
81
|
+
private readonly _runtimeOptions;
|
|
80
82
|
private dbAdapter;
|
|
81
83
|
private changeQueue;
|
|
82
84
|
private docNumberPolicy;
|
|
@@ -85,11 +87,12 @@ export declare class PurchaseService implements IPurchaseService {
|
|
|
85
87
|
* Initialize PurchaseService.
|
|
86
88
|
* @param context - PosCore context
|
|
87
89
|
*/
|
|
88
|
-
constructor(context: PosCore);
|
|
90
|
+
constructor(context: PosCore, _runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
89
91
|
private roundCurrencyAmount;
|
|
90
92
|
private resolveCurrencySnapshot;
|
|
91
93
|
private toBaseQuantity;
|
|
92
94
|
private toBaseUnitCost;
|
|
95
|
+
private emitFinanceProjection;
|
|
93
96
|
private getCostingMethod;
|
|
94
97
|
private applyCostingPolicy;
|
|
95
98
|
/** Add new Purchase. */
|
|
@@ -2,6 +2,7 @@ import { PosCore } from '../PosCore';
|
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Return, ReturnData } from '../models/Return';
|
|
4
4
|
import { ReturnType } from '../models/Return';
|
|
5
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
5
6
|
export interface ProcessReturnInput {
|
|
6
7
|
/** saleId atau purchaseId – salah satu wajib diisi */
|
|
7
8
|
saleId?: string | null;
|
|
@@ -72,13 +73,14 @@ export interface IReturnService {
|
|
|
72
73
|
/** Service implementation for Return operations. */
|
|
73
74
|
export declare class ReturnService implements IReturnService {
|
|
74
75
|
private context;
|
|
76
|
+
private readonly _runtimeOptions;
|
|
75
77
|
private dbAdapter;
|
|
76
78
|
private changeQueue;
|
|
77
79
|
/**
|
|
78
80
|
* Initialize ReturnService.
|
|
79
81
|
* @param context - PosCore context
|
|
80
82
|
*/
|
|
81
|
-
constructor(context: PosCore);
|
|
83
|
+
constructor(context: PosCore, _runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
82
84
|
/** Add new Return. */
|
|
83
85
|
addReturn(data: ReturnData, tx?: DbAdapter): Promise<Return>;
|
|
84
86
|
/** Update existing Return. */
|
|
@@ -101,6 +103,7 @@ export declare class ReturnService implements IReturnService {
|
|
|
101
103
|
private getFraudGuardPolicy;
|
|
102
104
|
private shouldTriggerFraudGuardForRefund;
|
|
103
105
|
private shouldTriggerFraudGuardForCancel;
|
|
106
|
+
private emitFinanceProjection;
|
|
104
107
|
processReturn(input: ProcessReturnInput): Promise<{
|
|
105
108
|
returnId: string;
|
|
106
109
|
queued: boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LoggerAdapter } from 'ofcore';
|
|
2
|
+
import type { PosCashAdjustmentAccountMapping, PosCashAdjustmentFinanceProjection, PosExpenseAccountMapping, PosExpenseFinanceProjection, PosPurchaseAccountMapping, PosPurchaseFinanceProjection, PosReturnAccountMapping, PosReturnFinanceProjection, PosSaleAccountMapping, PosSettlementAccountMapping, PosSettlementFinanceProjection, ScopedAccountMapping, ScopedPosSaleFinanceProjection } from '../finance/offinanceProjection';
|
|
3
|
+
export interface ServiceRuntimeOptions {
|
|
4
|
+
logger?: LoggerAdapter;
|
|
5
|
+
financeProjectionSink?: (projection: ScopedPosSaleFinanceProjection | PosPurchaseFinanceProjection | PosReturnFinanceProjection | PosExpenseFinanceProjection | PosSettlementFinanceProjection | PosCashAdjustmentFinanceProjection) => Promise<void> | void;
|
|
6
|
+
saleAccountMapping?: ScopedAccountMapping<PosSaleAccountMapping>;
|
|
7
|
+
purchaseAccountMapping?: ScopedAccountMapping<PosPurchaseAccountMapping>;
|
|
8
|
+
returnAccountMapping?: ScopedAccountMapping<PosReturnAccountMapping>;
|
|
9
|
+
expenseAccountMapping?: ScopedAccountMapping<PosExpenseAccountMapping>;
|
|
10
|
+
settlementAccountMapping?: ScopedAccountMapping<PosSettlementAccountMapping>;
|
|
11
|
+
cashAdjustmentAccountMapping?: ScopedAccountMapping<PosCashAdjustmentAccountMapping>;
|
|
12
|
+
}
|
|
@@ -2,6 +2,7 @@ import { PosCore } from '../PosCore';
|
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Sale, SaleData } from '../models/Sale';
|
|
4
4
|
import { SaleItem } from '../models/SaleItem';
|
|
5
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
5
6
|
/** Service interface for Sale operations. */
|
|
6
7
|
export interface ISaleService {
|
|
7
8
|
/** Add new Sale. */
|
|
@@ -70,6 +71,7 @@ export interface ISaleService {
|
|
|
70
71
|
/** Service implementation for Sale operations. */
|
|
71
72
|
export declare class SaleService implements ISaleService {
|
|
72
73
|
private context;
|
|
74
|
+
private readonly runtimeOptions;
|
|
73
75
|
private dbAdapter;
|
|
74
76
|
private changeQueue;
|
|
75
77
|
private docNumberPolicy;
|
|
@@ -78,7 +80,7 @@ export declare class SaleService implements ISaleService {
|
|
|
78
80
|
* Initialize SaleService.
|
|
79
81
|
* @param context - PosCore context
|
|
80
82
|
*/
|
|
81
|
-
constructor(context: PosCore);
|
|
83
|
+
constructor(context: PosCore, runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
82
84
|
private roundCurrencyAmount;
|
|
83
85
|
private resolveCurrencySnapshot;
|
|
84
86
|
private isExpiredLot;
|
|
@@ -86,6 +88,7 @@ export declare class SaleService implements ISaleService {
|
|
|
86
88
|
private enforceTempoCustomerCreditPolicy;
|
|
87
89
|
private normalizeDocNo;
|
|
88
90
|
private toBaseQuantity;
|
|
91
|
+
private emitFinanceProjection;
|
|
89
92
|
getDuplicateDocumentNumbers(options?: {
|
|
90
93
|
dateFrom?: string;
|
|
91
94
|
dateTo?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PosCore } from '../PosCore';
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Settlement, SettlementData } from '../models/Settlement';
|
|
4
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
4
5
|
/** Service interface for Settlement operations. */
|
|
5
6
|
export interface ISettlementService {
|
|
6
7
|
/** Add new Settlement. */
|
|
@@ -32,6 +33,7 @@ export interface ISettlementService {
|
|
|
32
33
|
/** Service implementation for Settlement operations. */
|
|
33
34
|
export declare class SettlementService implements ISettlementService {
|
|
34
35
|
private context;
|
|
36
|
+
private readonly runtimeOptions;
|
|
35
37
|
private dbAdapter;
|
|
36
38
|
private changeQueue;
|
|
37
39
|
private runInTransaction;
|
|
@@ -39,7 +41,8 @@ export declare class SettlementService implements ISettlementService {
|
|
|
39
41
|
* Initialize SettlementService.
|
|
40
42
|
* @param context - PosCore context
|
|
41
43
|
*/
|
|
42
|
-
constructor(context: PosCore);
|
|
44
|
+
constructor(context: PosCore, runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
45
|
+
private emitFinanceProjection;
|
|
43
46
|
/** Add new Settlement. */
|
|
44
47
|
addSettlement(data: SettlementData, tx?: DbAdapter): Promise<Settlement>;
|
|
45
48
|
/** Update existing Settlement. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PosCore } from '../PosCore';
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Transaction, TransactionData } from '../models/Transaction';
|
|
4
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
4
5
|
/** Service interface for Transaction operations. */
|
|
5
6
|
export interface ITransactionService {
|
|
6
7
|
/** Add new Transaction. */
|
|
@@ -48,6 +49,7 @@ export interface ITransactionService {
|
|
|
48
49
|
/** Service implementation for Transaction operations. */
|
|
49
50
|
export declare class TransactionService implements ITransactionService {
|
|
50
51
|
private context;
|
|
52
|
+
private readonly runtimeOptions;
|
|
51
53
|
private dbAdapter;
|
|
52
54
|
private changeQueue;
|
|
53
55
|
private readonly allowedReferenceTypes;
|
|
@@ -55,7 +57,8 @@ export declare class TransactionService implements ITransactionService {
|
|
|
55
57
|
* Initialize TransactionService.
|
|
56
58
|
* @param context - PosCore context
|
|
57
59
|
*/
|
|
58
|
-
constructor(context: PosCore);
|
|
60
|
+
constructor(context: PosCore, runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
61
|
+
private emitCashAdjustmentFinanceProjection;
|
|
59
62
|
private getIdempotentTransaction;
|
|
60
63
|
private saveIdempotencyMarker;
|
|
61
64
|
private getActorId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ofpos-shared-core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
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,7 +64,8 @@
|
|
|
64
64
|
"dist"
|
|
65
65
|
],
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"ofcore": "0.2.0-alpha.0"
|
|
67
|
+
"ofcore": "0.2.0-alpha.0",
|
|
68
|
+
"offinance-shared-core": "0.1.0-alpha.1"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
71
|
"ofauth-shared-core": "0.2.0-alpha.0"
|