ofpos-shared-core 1.1.0

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.
Files changed (143) hide show
  1. package/README.md +37 -0
  2. package/dist/AdapterRegistry.d.ts +83 -0
  3. package/dist/DomainServices.d.ts +151 -0
  4. package/dist/IntegrationServices.d.ts +75 -0
  5. package/dist/PosCore.d.ts +216 -0
  6. package/dist/contracts/contractVersioning.d.ts +6 -0
  7. package/dist/contracts/crossDomainPrimitives.d.ts +5 -0
  8. package/dist/contracts/responseEnvelope.d.ts +6 -0
  9. package/dist/contracts/syncProtocol.d.ts +8 -0
  10. package/dist/data/DbAdapter.d.ts +7 -0
  11. package/dist/data/applyPendingMigrations.d.ts +18 -0
  12. package/dist/data/inMemoryDbAdapter.d.ts +65 -0
  13. package/dist/data/migrations.d.ts +12 -0
  14. package/dist/data/relations.d.ts +3 -0
  15. package/dist/data/schema.d.ts +9 -0
  16. package/dist/data/seed.d.ts +370 -0
  17. package/dist/index.browser.mjs +18 -0
  18. package/dist/index.browser.mjs.LEGAL.txt +46 -0
  19. package/dist/index.cjs.js +18 -0
  20. package/dist/index.cjs.js.LEGAL.txt +46 -0
  21. package/dist/index.d.ts +116 -0
  22. package/dist/index.esm.js +18 -0
  23. package/dist/index.esm.js.LEGAL.txt +46 -0
  24. package/dist/index.umd.js +18 -0
  25. package/dist/index.umd.js.LEGAL.txt +46 -0
  26. package/dist/integration/NotificationAdapter.d.ts +69 -0
  27. package/dist/integration/activityLogger.d.ts +44 -0
  28. package/dist/integration/activitySink.d.ts +8 -0
  29. package/dist/integration/apiService.d.ts +255 -0
  30. package/dist/integration/authorizationService.d.ts +225 -0
  31. package/dist/integration/backupScheduler.d.ts +75 -0
  32. package/dist/integration/checksum.d.ts +9 -0
  33. package/dist/integration/checksumAdapter.d.ts +8 -0
  34. package/dist/integration/configService.d.ts +431 -0
  35. package/dist/integration/defaultChecksumAdapter.d.ts +6 -0
  36. package/dist/integration/defaultEncryptionAdapter.d.ts +9 -0
  37. package/dist/integration/encryption.d.ts +95 -0
  38. package/dist/integration/encryptionAdapter.d.ts +8 -0
  39. package/dist/integration/httpAdapter.d.ts +9 -0
  40. package/dist/integration/loggerAdapter.d.ts +45 -0
  41. package/dist/integration/notificationService.d.ts +45 -0
  42. package/dist/integration/ofauthBridge.d.ts +29 -0
  43. package/dist/integration/ofauthCoreBridge.d.ts +19 -0
  44. package/dist/integration/platformAdapter.d.ts +8 -0
  45. package/dist/integration/roleAdapter.d.ts +61 -0
  46. package/dist/integration/socket.d.ts +60 -0
  47. package/dist/integration/socketAdapter.d.ts +8 -0
  48. package/dist/integration/userService.d.ts +126 -0
  49. package/dist/models/Bom.d.ts +17 -0
  50. package/dist/models/Category.d.ts +13 -0
  51. package/dist/models/Customer.d.ts +17 -0
  52. package/dist/models/CustomerGroup.d.ts +11 -0
  53. package/dist/models/Expense.d.ts +19 -0
  54. package/dist/models/FinancialSetting.d.ts +14 -0
  55. package/dist/models/History.d.ts +18 -0
  56. package/dist/models/InventoryLog.d.ts +23 -0
  57. package/dist/models/InventoryLot.d.ts +34 -0
  58. package/dist/models/KitchenTicket.d.ts +13 -0
  59. package/dist/models/KitchenTicketItem.d.ts +12 -0
  60. package/dist/models/LoyaltyAccount.d.ts +12 -0
  61. package/dist/models/LoyaltyLedger.d.ts +17 -0
  62. package/dist/models/Order.d.ts +45 -0
  63. package/dist/models/OrderItem.d.ts +19 -0
  64. package/dist/models/Payable.d.ts +23 -0
  65. package/dist/models/PriceHistory.d.ts +17 -0
  66. package/dist/models/PriceTier.d.ts +19 -0
  67. package/dist/models/Product.d.ts +25 -0
  68. package/dist/models/Promotion.d.ts +25 -0
  69. package/dist/models/Purchase.d.ts +29 -0
  70. package/dist/models/PurchaseItem.d.ts +21 -0
  71. package/dist/models/PurchaseOrder.d.ts +23 -0
  72. package/dist/models/PurchaseOrderItem.d.ts +19 -0
  73. package/dist/models/Receivable.d.ts +23 -0
  74. package/dist/models/ReportSchedule.d.ts +21 -0
  75. package/dist/models/Return.d.ts +57 -0
  76. package/dist/models/ReturnItem.d.ts +31 -0
  77. package/dist/models/Role.d.ts +13 -0
  78. package/dist/models/Sale.d.ts +43 -0
  79. package/dist/models/SaleItem.d.ts +19 -0
  80. package/dist/models/Settlement.d.ts +23 -0
  81. package/dist/models/Shift.d.ts +41 -0
  82. package/dist/models/StockAdjustment.d.ts +21 -0
  83. package/dist/models/StockOpname.d.ts +22 -0
  84. package/dist/models/StockOpnameItem.d.ts +27 -0
  85. package/dist/models/Supplier.d.ts +19 -0
  86. package/dist/models/TaxRate.d.ts +13 -0
  87. package/dist/models/Transaction.d.ts +32 -0
  88. package/dist/models/Uom.d.ts +15 -0
  89. package/dist/models/User.d.ts +21 -0
  90. package/dist/services/bomService.d.ts +71 -0
  91. package/dist/services/cartService.d.ts +65 -0
  92. package/dist/services/categoryService.d.ts +54 -0
  93. package/dist/services/customerGroupService.d.ts +47 -0
  94. package/dist/services/customerService.d.ts +133 -0
  95. package/dist/services/documentNumberPolicy.d.ts +15 -0
  96. package/dist/services/expenseService.d.ts +47 -0
  97. package/dist/services/exportAdapter.d.ts +48 -0
  98. package/dist/services/exportService.d.ts +263 -0
  99. package/dist/services/financialSettingService.d.ts +47 -0
  100. package/dist/services/historyService.d.ts +60 -0
  101. package/dist/services/inventoryLogService.d.ts +47 -0
  102. package/dist/services/inventoryService.d.ts +43 -0
  103. package/dist/services/orderItemService.d.ts +47 -0
  104. package/dist/services/orderService.d.ts +161 -0
  105. package/dist/services/payableService.d.ts +51 -0
  106. package/dist/services/priceHistoryService.d.ts +61 -0
  107. package/dist/services/priceTierService.d.ts +47 -0
  108. package/dist/services/pricingService.d.ts +192 -0
  109. package/dist/services/productService.d.ts +59 -0
  110. package/dist/services/promotionService.d.ts +47 -0
  111. package/dist/services/purchaseItemService.d.ts +47 -0
  112. package/dist/services/purchaseOrderItemService.d.ts +47 -0
  113. package/dist/services/purchaseOrderService.d.ts +47 -0
  114. package/dist/services/purchaseService.d.ts +130 -0
  115. package/dist/services/receivableService.d.ts +47 -0
  116. package/dist/services/reportScheduleService.d.ts +47 -0
  117. package/dist/services/reportingService.d.ts +251 -0
  118. package/dist/services/returnItemService.d.ts +47 -0
  119. package/dist/services/returnService.d.ts +123 -0
  120. package/dist/services/roleService.d.ts +47 -0
  121. package/dist/services/saleItemService.d.ts +47 -0
  122. package/dist/services/saleService.d.ts +154 -0
  123. package/dist/services/settlementService.d.ts +68 -0
  124. package/dist/services/shiftService.d.ts +92 -0
  125. package/dist/services/stockAdjustmentService.d.ts +47 -0
  126. package/dist/services/stockOpnameItemService.d.ts +47 -0
  127. package/dist/services/stockOpnameService.d.ts +51 -0
  128. package/dist/services/stockTransferService.d.ts +67 -0
  129. package/dist/services/supplierService.d.ts +51 -0
  130. package/dist/services/taxRateService.d.ts +47 -0
  131. package/dist/services/taxService.d.ts +63 -0
  132. package/dist/services/transactionService.d.ts +109 -0
  133. package/dist/services/uiProductService.d.ts +102 -0
  134. package/dist/services/uiTransactionService.d.ts +68 -0
  135. package/dist/services/uomService.d.ts +53 -0
  136. package/dist/services/userService.d.ts +47 -0
  137. package/dist/stores/cartStore.d.ts +109 -0
  138. package/dist/stores/eventBus.d.ts +55 -0
  139. package/dist/stores/sessionStore.d.ts +108 -0
  140. package/dist/stores/storageAdapter.d.ts +44 -0
  141. package/dist/stores/syncService.d.ts +90 -0
  142. package/dist/stores/syncStore.d.ts +163 -0
  143. package/package.json +82 -0
@@ -0,0 +1,32 @@
1
+ export declare const transactionTable = "transactions";
2
+ export type TransactionMethod = 'cash' | 'card' | 'voucher' | 'bank_transfer';
3
+ export type TransactionReferenceType = 'sale' | 'purchase' | 'sale_return' | 'purchase_return' | 'receivable_payment' | 'payable_payment' | 'cash_adjustment' | 'expense';
4
+ export type TransactionDirection = 'in' | 'out';
5
+ export interface Transaction {
6
+ id: string;
7
+ /** selalu positif */
8
+ amount: number;
9
+ method: TransactionMethod;
10
+ referenceType: TransactionReferenceType;
11
+ referenceId: string;
12
+ direction: TransactionDirection;
13
+ metadata: any | null;
14
+ date: string;
15
+ description: string | null;
16
+ userId: string;
17
+ version: number;
18
+ lastModified: string;
19
+ deleted: boolean;
20
+ }
21
+ export interface TransactionData {
22
+ /** selalu positif */
23
+ amount: number;
24
+ method: TransactionMethod;
25
+ referenceType: TransactionReferenceType;
26
+ referenceId: string;
27
+ direction: TransactionDirection;
28
+ metadata: any | null;
29
+ date: string;
30
+ description: string | null;
31
+ userId: string;
32
+ }
@@ -0,0 +1,15 @@
1
+ export declare const uomTable = "uoms";
2
+ export interface Uom {
3
+ id: string;
4
+ code: string;
5
+ name: string;
6
+ conversionFactor: number;
7
+ version: number;
8
+ lastModified: string;
9
+ deleted: boolean;
10
+ }
11
+ export interface UomData {
12
+ code: string;
13
+ name: string;
14
+ conversionFactor: number;
15
+ }
@@ -0,0 +1,21 @@
1
+ export declare const userTable = "users";
2
+ export interface User {
3
+ id: string;
4
+ username: string;
5
+ pinHash: string | null;
6
+ role: string;
7
+ email: string | null;
8
+ failedAttempts: number | null;
9
+ isLocked: boolean | null;
10
+ version: number;
11
+ lastModified: string;
12
+ deleted: boolean;
13
+ }
14
+ export interface UserData {
15
+ username: string;
16
+ pinHash: string | null;
17
+ role: string;
18
+ email: string | null;
19
+ failedAttempts: number | null;
20
+ isLocked: boolean | null;
21
+ }
@@ -0,0 +1,71 @@
1
+ import { PosCore } from '../PosCore';
2
+ import { DbAdapter, QueryOptions } from 'ofcore';
3
+ import { Bom, BomData } from '../models/Bom';
4
+ /** Service interface for Bom operations. */
5
+ export interface IBomService {
6
+ /** Add new Bom. */
7
+ addBom(data: BomData, tx?: DbAdapter): Promise<Bom>;
8
+ /** Update existing Bom. */
9
+ updateBom(id: string, data: Partial<BomData>): Promise<Bom>;
10
+ /** Get all Boms with complex options. */
11
+ getBoms(options?: QueryOptions, tx?: DbAdapter): Promise<Bom[]>;
12
+ /** Get Bom by ID or options. */
13
+ getBom(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<Bom | null>;
14
+ /** Delete Bom (logical). */
15
+ deleteBom(id: string, tx?: DbAdapter): Promise<{
16
+ id: string;
17
+ queued: boolean;
18
+ }>;
19
+ /** Duplicate Bom by ID. */
20
+ duplicateBom(originalId: string, tx?: DbAdapter): Promise<Bom>;
21
+ /** Get Boms by primary search key parentItemId. */
22
+ getBomsByParentItemId(value: string, tx?: DbAdapter): Promise<Bom[]>;
23
+ /** Get Boms by primary search key componentItemId. */
24
+ getBomsByComponentItemId(value: string, tx?: DbAdapter): Promise<Bom[]>;
25
+ /** Get BOMs by Product ID */
26
+ getBomsByProductId(productId: string, options?: QueryOptions): Promise<Bom[]>;
27
+ /** Expand BOM recursively */
28
+ expandBom(parentItemId: string): Promise<Array<{
29
+ componentItemId: string;
30
+ quantity: number;
31
+ uomId: string | null;
32
+ }>>;
33
+ }
34
+ /** Service implementation for Bom operations. */
35
+ export declare class BomService implements IBomService {
36
+ private context;
37
+ private dbAdapter;
38
+ private syncStore?;
39
+ /**
40
+ * Initialize BomService.
41
+ * @param context - PosCore context
42
+ */
43
+ constructor(context: PosCore);
44
+ /** Add new Bom. */
45
+ addBom(data: BomData, tx?: DbAdapter): Promise<Bom>;
46
+ /** Update existing Bom. */
47
+ updateBom(id: string, data: Partial<BomData>, tx?: DbAdapter): Promise<Bom>;
48
+ /** Get all Boms with complex options. */
49
+ getBoms(options?: QueryOptions, tx?: DbAdapter): Promise<Bom[]>;
50
+ /** Get Bom by ID or options. */
51
+ getBom(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<Bom | null>;
52
+ /** Delete Bom (logical). */
53
+ deleteBom(id: string, tx?: DbAdapter): Promise<{
54
+ id: string;
55
+ queued: boolean;
56
+ }>;
57
+ /** Duplicate Bom by ID. */
58
+ duplicateBom(originalId: string, tx?: DbAdapter): Promise<Bom>;
59
+ /** Get Boms by primary search key parentItemId. */
60
+ getBomsByParentItemId(value: string, tx?: DbAdapter): Promise<Bom[]>;
61
+ /** Get Boms by primary search key componentItemId. */
62
+ getBomsByComponentItemId(value: string, tx?: DbAdapter): Promise<Bom[]>;
63
+ /** Get BOMs by Product ID */
64
+ getBomsByProductId(productId: string, options?: QueryOptions): Promise<Bom[]>;
65
+ /** Recursively expand a product BOM into its primitive components with aggregated quantities. */
66
+ expandBom(parentItemId: string): Promise<Array<{
67
+ componentItemId: string;
68
+ quantity: number;
69
+ uomId: string | null;
70
+ }>>;
71
+ }
@@ -0,0 +1,65 @@
1
+ import { PosCore } from '../PosCore';
2
+ import { Cart, CartItem, CartMap } from '../stores/cartStore';
3
+ /**
4
+ * Antarmuka layanan keranjang belanja.
5
+ */
6
+ export interface ICartService {
7
+ /** Buat keranjang baru. */
8
+ createCart(partialCart: Omit<Cart, 'id' | 'createdAt' | 'lastModified'>): Promise<Cart>;
9
+ /** Perbarui keranjang yang ada. */
10
+ updateCart(cart: Cart): Promise<void>;
11
+ /** Hapus keranjang berdasarkan ID. */
12
+ deleteCart(cartId: string): Promise<void>;
13
+ /** Ambil keranjang berdasarkan ID. */
14
+ getCart(cartId: string): Promise<Cart | undefined>;
15
+ /** Ambil semua keranjang. */
16
+ getAllCarts(): Promise<CartMap>;
17
+ /** Bersihkan semua keranjang. */
18
+ clearAllCarts(): Promise<void>;
19
+ /** Ambil keranjang yang sedang aktif (tidak terkunci). */
20
+ getActiveCarts(): Promise<Cart[]>;
21
+ /** Ambil keranjang berdasarkan ID pelanggan. */
22
+ getCartByCustomerId(customerId: string): Promise<Cart[]>;
23
+ /** Ambil keranjang berdasarkan nomor meja. */
24
+ getCartByTableNumber(tableNumber: string): Promise<Cart[]>;
25
+ /** Tambah item ke dalam keranjang. */
26
+ addItemToCart(cartId: string, item: CartItem): Promise<Cart>;
27
+ /** Hapus item dari keranjang. */
28
+ removeItemFromCart(cartId: string, itemId: string): Promise<Cart>;
29
+ updateCartItem(cartId: string, itemId: string, data: CartItem): Promise<Cart>;
30
+ }
31
+ /**
32
+ * Implementasi layanan keranjang belanja.
33
+ */
34
+ export declare class CartService implements ICartService {
35
+ private context;
36
+ private cartStore;
37
+ /**
38
+ * Buat instance CartService.
39
+ * @param context Konteks PosCore.
40
+ */
41
+ constructor(context: PosCore);
42
+ /** Buat keranjang baru. */
43
+ createCart(partialCart: Partial<Cart>): Promise<Cart>;
44
+ /** Perbarui keranjang yang ada. */
45
+ updateCart(cart: Cart): Promise<void>;
46
+ /** Hapus keranjang berdasarkan ID. */
47
+ deleteCart(cartId: string): Promise<void>;
48
+ /** Ambil keranjang berdasarkan ID. */
49
+ getCart(cartId: string): Promise<Cart | undefined>;
50
+ /** Ambil semua keranjang. */
51
+ getAllCarts(): Promise<CartMap>;
52
+ /** Bersihkan semua keranjang. */
53
+ clearAllCarts(): Promise<void>;
54
+ /** Ambil keranjang yang sedang aktif (tidak terkunci). */
55
+ getActiveCarts(): Promise<Cart[]>;
56
+ /** Ambil keranjang berdasarkan ID pelanggan. */
57
+ getCartByCustomerId(customerId: string): Promise<Cart[]>;
58
+ /** Ambil keranjang berdasarkan nomor meja. */
59
+ getCartByTableNumber(tableNumber: string): Promise<Cart[]>;
60
+ /** Tambah item ke dalam keranjang. */
61
+ addItemToCart(cartId: string, item: CartItem): Promise<Cart>;
62
+ /** Hapus item dari keranjang. */
63
+ removeItemFromCart(cartId: string, itemId: string): Promise<Cart>;
64
+ updateCartItem(cartId: string, itemId: string, data: CartItem): Promise<Cart>;
65
+ }
@@ -0,0 +1,54 @@
1
+ import { PosCore } from '../PosCore';
2
+ import { DbAdapter, QueryOptions } from 'ofcore';
3
+ import { Category, CategoryData } from '../models/Category';
4
+ export interface CategoryTreeItem extends Category {
5
+ children: CategoryTreeItem[];
6
+ }
7
+ /** Service interface for Category operations. */
8
+ export interface ICategoryService {
9
+ /** Add new Category. */
10
+ addCategory(data: CategoryData, tx?: DbAdapter): Promise<Category>;
11
+ /** Update existing Category. */
12
+ updateCategory(id: string, data: Partial<CategoryData>): Promise<Category>;
13
+ /** Get all Categories with complex options. */
14
+ getCategories(options?: QueryOptions, tx?: DbAdapter): Promise<Category[]>;
15
+ /** Get Category by ID or options. */
16
+ getCategory(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<Category | null>;
17
+ /** Delete Category (logical). */
18
+ deleteCategory(id: string, tx?: DbAdapter): Promise<{
19
+ id: string;
20
+ queued: boolean;
21
+ }>;
22
+ /** Duplicate Category by ID. */
23
+ duplicateCategory(originalId: string, tx?: DbAdapter): Promise<Category>;
24
+ /** Fetch nested category tree */
25
+ fetchNestedCategories(): Promise<CategoryTreeItem[]>;
26
+ }
27
+ /** Service implementation for Category operations. */
28
+ export declare class CategoryService implements ICategoryService {
29
+ private context;
30
+ private dbAdapter;
31
+ private syncStore?;
32
+ /**
33
+ * Initialize CategoryService.
34
+ * @param context - PosCore context
35
+ */
36
+ constructor(context: PosCore);
37
+ /** Add new Category. */
38
+ addCategory(data: CategoryData, tx?: DbAdapter): Promise<Category>;
39
+ /** Update existing Category. */
40
+ updateCategory(id: string, data: Partial<CategoryData>, tx?: DbAdapter): Promise<Category>;
41
+ /** Get all Categories with complex options. */
42
+ getCategories(options?: QueryOptions, tx?: DbAdapter): Promise<Category[]>;
43
+ /** Get Category by ID or options. */
44
+ getCategory(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<Category | null>;
45
+ /** Delete Category (logical). */
46
+ deleteCategory(id: string, tx?: DbAdapter): Promise<{
47
+ id: string;
48
+ queued: boolean;
49
+ }>;
50
+ /** Duplicate Category by ID. */
51
+ duplicateCategory(originalId: string, tx?: DbAdapter): Promise<Category>;
52
+ /** Fetch nested category tree */
53
+ fetchNestedCategories(): Promise<CategoryTreeItem[]>;
54
+ }
@@ -0,0 +1,47 @@
1
+ import { PosCore } from '../PosCore';
2
+ import { DbAdapter, QueryOptions } from 'ofcore';
3
+ import { CustomerGroup, CustomerGroupData } from '../models/CustomerGroup';
4
+ /** Service interface for CustomerGroup operations. */
5
+ export interface ICustomerGroupService {
6
+ /** Add new CustomerGroup. */
7
+ addCustomerGroup(data: CustomerGroupData, tx?: DbAdapter): Promise<CustomerGroup>;
8
+ /** Update existing CustomerGroup. */
9
+ updateCustomerGroup(id: string, data: Partial<CustomerGroupData>): Promise<CustomerGroup>;
10
+ /** Get all CustomerGroups with complex options. */
11
+ getCustomerGroups(options?: QueryOptions, tx?: DbAdapter): Promise<CustomerGroup[]>;
12
+ /** Get CustomerGroup by ID or options. */
13
+ getCustomerGroup(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<CustomerGroup | null>;
14
+ /** Delete CustomerGroup (logical). */
15
+ deleteCustomerGroup(id: string, tx?: DbAdapter): Promise<{
16
+ id: string;
17
+ queued: boolean;
18
+ }>;
19
+ /** Duplicate CustomerGroup by ID. */
20
+ duplicateCustomerGroup(originalId: string, tx?: DbAdapter): Promise<CustomerGroup>;
21
+ }
22
+ /** Service implementation for CustomerGroup operations. */
23
+ export declare class CustomerGroupService implements ICustomerGroupService {
24
+ private context;
25
+ private dbAdapter;
26
+ private syncStore?;
27
+ /**
28
+ * Initialize CustomerGroupService.
29
+ * @param context - PosCore context
30
+ */
31
+ constructor(context: PosCore);
32
+ /** Add new CustomerGroup. */
33
+ addCustomerGroup(data: CustomerGroupData, tx?: DbAdapter): Promise<CustomerGroup>;
34
+ /** Update existing CustomerGroup. */
35
+ updateCustomerGroup(id: string, data: Partial<CustomerGroupData>, tx?: DbAdapter): Promise<CustomerGroup>;
36
+ /** Get all CustomerGroups with complex options. */
37
+ getCustomerGroups(options?: QueryOptions, tx?: DbAdapter): Promise<CustomerGroup[]>;
38
+ /** Get CustomerGroup by ID or options. */
39
+ getCustomerGroup(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<CustomerGroup | null>;
40
+ /** Delete CustomerGroup (logical). */
41
+ deleteCustomerGroup(id: string, tx?: DbAdapter): Promise<{
42
+ id: string;
43
+ queued: boolean;
44
+ }>;
45
+ /** Duplicate CustomerGroup by ID. */
46
+ duplicateCustomerGroup(originalId: string, tx?: DbAdapter): Promise<CustomerGroup>;
47
+ }
@@ -0,0 +1,133 @@
1
+ import { PosCore } from '../PosCore';
2
+ import { DbAdapter, QueryOptions } from 'ofcore';
3
+ import { Customer, CustomerData } from '../models/Customer';
4
+ /** Service interface for Customer operations. */
5
+ export interface ICustomerService {
6
+ /** Add new Customer. */
7
+ addCustomer(data: CustomerData, tx?: DbAdapter): Promise<Customer>;
8
+ /** Update existing Customer. */
9
+ updateCustomer(id: string, data: Partial<CustomerData>): Promise<Customer>;
10
+ /** Get all Customers with complex options. */
11
+ getCustomers(options?: QueryOptions, tx?: DbAdapter): Promise<Customer[]>;
12
+ /** Get Customer by ID or options. */
13
+ getCustomer(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<Customer | null>;
14
+ /** Delete Customer (logical). */
15
+ deleteCustomer(id: string, tx?: DbAdapter): Promise<{
16
+ id: string;
17
+ queued: boolean;
18
+ }>;
19
+ /** Duplicate Customer by ID. */
20
+ duplicateCustomer(originalId: string, tx?: DbAdapter): Promise<Customer>;
21
+ /** Search Customer by full-text keyword. */
22
+ searchCustomers(keyword: string, options?: QueryOptions, tx?: DbAdapter): Promise<Customer[]>;
23
+ /** Earn loyalty points from valid business event (e.g., sale posting). */
24
+ earnLoyaltyPoints(input: {
25
+ customerId: string;
26
+ referenceType: string;
27
+ referenceId: string;
28
+ baseAmount: number;
29
+ earnRate: number;
30
+ expiresAt?: string | null;
31
+ note?: string | null;
32
+ date?: string;
33
+ }): Promise<{
34
+ earnedPoints: number;
35
+ balance: number;
36
+ }>;
37
+ /** Redeem available loyalty points using FIFO on expiring buckets. */
38
+ redeemLoyaltyPoints(input: {
39
+ customerId: string;
40
+ referenceType: string;
41
+ referenceId: string;
42
+ points: number;
43
+ note?: string | null;
44
+ date?: string;
45
+ }): Promise<{
46
+ redeemedPoints: number;
47
+ balance: number;
48
+ }>;
49
+ /** Expire points that have passed expiry date. */
50
+ expireLoyaltyPoints(input?: {
51
+ customerId?: string;
52
+ asOfDate?: string;
53
+ }): Promise<{
54
+ expiredPoints: number;
55
+ affectedCustomers: number;
56
+ }>;
57
+ /** Snapshot loyalty account summary per customer. */
58
+ getLoyaltySummary(customerId: string): Promise<{
59
+ customerId: string;
60
+ pointsBalance: number;
61
+ totalEarned: number;
62
+ totalRedeemed: number;
63
+ totalExpired: number;
64
+ }>;
65
+ }
66
+ /** Service implementation for Customer operations. */
67
+ export declare class CustomerService implements ICustomerService {
68
+ private context;
69
+ private dbAdapter;
70
+ private syncStore?;
71
+ /**
72
+ * Initialize CustomerService.
73
+ * @param context - PosCore context
74
+ */
75
+ constructor(context: PosCore);
76
+ private runInTransaction;
77
+ private getOrCreateLoyaltyAccount;
78
+ /** Add new Customer. */
79
+ addCustomer(data: CustomerData, tx?: DbAdapter): Promise<Customer>;
80
+ /** Update existing Customer. */
81
+ updateCustomer(id: string, data: Partial<CustomerData>, tx?: DbAdapter): Promise<Customer>;
82
+ /** Get all Customers with complex options. */
83
+ getCustomers(options?: QueryOptions, tx?: DbAdapter): Promise<Customer[]>;
84
+ /** Get Customer by ID or options. */
85
+ getCustomer(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<Customer | null>;
86
+ /** Delete Customer (logical). */
87
+ deleteCustomer(id: string, tx?: DbAdapter): Promise<{
88
+ id: string;
89
+ queued: boolean;
90
+ }>;
91
+ /** Duplicate Customer by ID. */
92
+ duplicateCustomer(originalId: string, tx?: DbAdapter): Promise<Customer>;
93
+ /** Search Customer by full-text keyword. */
94
+ searchCustomers(keyword: string, options?: QueryOptions, tx?: DbAdapter): Promise<Customer[]>;
95
+ earnLoyaltyPoints(input: {
96
+ customerId: string;
97
+ referenceType: string;
98
+ referenceId: string;
99
+ baseAmount: number;
100
+ earnRate: number;
101
+ expiresAt?: string | null;
102
+ note?: string | null;
103
+ date?: string;
104
+ }): Promise<{
105
+ earnedPoints: number;
106
+ balance: number;
107
+ }>;
108
+ redeemLoyaltyPoints(input: {
109
+ customerId: string;
110
+ referenceType: string;
111
+ referenceId: string;
112
+ points: number;
113
+ note?: string | null;
114
+ date?: string;
115
+ }): Promise<{
116
+ redeemedPoints: number;
117
+ balance: number;
118
+ }>;
119
+ expireLoyaltyPoints(input?: {
120
+ customerId?: string;
121
+ asOfDate?: string;
122
+ }): Promise<{
123
+ expiredPoints: number;
124
+ affectedCustomers: number;
125
+ }>;
126
+ getLoyaltySummary(customerId: string): Promise<{
127
+ customerId: string;
128
+ pointsBalance: number;
129
+ totalEarned: number;
130
+ totalRedeemed: number;
131
+ totalExpired: number;
132
+ }>;
133
+ }
@@ -0,0 +1,15 @@
1
+ import { PosCore } from '../PosCore';
2
+ export type DocumentType = 'sale' | 'purchase' | 'order';
3
+ export declare class DocumentNumberPolicy {
4
+ private context;
5
+ private readonly storage;
6
+ private queue;
7
+ constructor(context: PosCore);
8
+ private getBranchSegment;
9
+ private getDateSegment;
10
+ private getCounterKey;
11
+ private withLock;
12
+ next(type: DocumentType, dateIso: string): Promise<string>;
13
+ withNote(note: string | null | undefined, docNo: string): string;
14
+ extractDocNo(note: string | null | undefined): string | null;
15
+ }
@@ -0,0 +1,47 @@
1
+ import { PosCore } from '../PosCore';
2
+ import { DbAdapter, QueryOptions } from 'ofcore';
3
+ import { Expense, ExpenseData } from '../models/Expense';
4
+ /** Service interface for Expense operations. */
5
+ export interface IExpenseService {
6
+ /** Add new Expense. */
7
+ addExpense(data: ExpenseData, tx?: DbAdapter): Promise<Expense>;
8
+ /** Update existing Expense. */
9
+ updateExpense(id: string, data: Partial<ExpenseData>): Promise<Expense>;
10
+ /** Get all Expenses with complex options. */
11
+ getExpenses(options?: QueryOptions, tx?: DbAdapter): Promise<Expense[]>;
12
+ /** Get Expense by ID or options. */
13
+ getExpense(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<Expense | null>;
14
+ /** Delete Expense (logical). */
15
+ deleteExpense(id: string, tx?: DbAdapter): Promise<{
16
+ id: string;
17
+ queued: boolean;
18
+ }>;
19
+ /** Duplicate Expense by ID. */
20
+ duplicateExpense(originalId: string, tx?: DbAdapter): Promise<Expense>;
21
+ }
22
+ /** Service implementation for Expense operations. */
23
+ export declare class ExpenseService implements IExpenseService {
24
+ private context;
25
+ private dbAdapter;
26
+ private syncStore?;
27
+ /**
28
+ * Initialize ExpenseService.
29
+ * @param context - PosCore context
30
+ */
31
+ constructor(context: PosCore);
32
+ /** Add new Expense. */
33
+ addExpense(data: ExpenseData, tx?: DbAdapter): Promise<Expense>;
34
+ /** Update existing Expense. */
35
+ updateExpense(id: string, data: Partial<ExpenseData>, tx?: DbAdapter): Promise<Expense>;
36
+ /** Get all Expenses with complex options. */
37
+ getExpenses(options?: QueryOptions, tx?: DbAdapter): Promise<Expense[]>;
38
+ /** Get Expense by ID or options. */
39
+ getExpense(idOrOptions: string | QueryOptions, tx?: DbAdapter): Promise<Expense | null>;
40
+ /** Delete Expense (logical). */
41
+ deleteExpense(id: string, tx?: DbAdapter): Promise<{
42
+ id: string;
43
+ queued: boolean;
44
+ }>;
45
+ /** Duplicate Expense by ID. */
46
+ duplicateExpense(originalId: string, tx?: DbAdapter): Promise<Expense>;
47
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Adapter ekspor dokumen, abstraksi untuk menulis dan membagikan file.
3
+ */
4
+ import { PosCore } from "../PosCore";
5
+ /**
6
+ * Antarmuka adapter ekspor dokumen.
7
+ */
8
+ export interface ExportAdapter {
9
+ /**
10
+ * Dapatkan path dokumen berdasarkan nama file.
11
+ * @param fileName Nama file yang diinginkan.
12
+ */
13
+ getDocumentPath(fileName: string): string;
14
+ /**
15
+ * Tulis konten ke file pada path tertentu.
16
+ * @param path Lokasi file.
17
+ * @param content Konten yang akan ditulis.
18
+ */
19
+ writeFile(path: string, content: string): Promise<void>;
20
+ /**
21
+ * Bagikan file melalui mekanisme platform.
22
+ * @param path Lokasi file yang akan dibagikan.
23
+ */
24
+ share(path: string): Promise<void>;
25
+ }
26
+ /**
27
+ * Implementasi default ExportAdapter yang melempar error pada operasi tertentu.
28
+ */
29
+ export declare class DefaultExportAdapter implements ExportAdapter {
30
+ private context;
31
+ /**
32
+ * Buat instance DefaultExportAdapter.
33
+ * @param context Konteks PosCore.
34
+ */
35
+ constructor(context: PosCore);
36
+ /**
37
+ * Dapatkan path dokumen (default hanya nama file).
38
+ */
39
+ getDocumentPath(fileName: string): string;
40
+ /**
41
+ * Tulis konten ke file (tidak diimplementasikan pada platform ini).
42
+ */
43
+ writeFile(path: string, content: string): Promise<void>;
44
+ /**
45
+ * Bagikan file (tidak diimplementasikan pada platform ini).
46
+ */
47
+ share(path: string): Promise<void>;
48
+ }