@classytic/commerce-sdk 0.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.
Potentially problematic release.
This version of @classytic/commerce-sdk might be problematic. Click here for more details.
- package/LICENSE +14 -0
- package/README.md +104 -0
- package/dist/adjustment-DTSLM7AN.js +5 -0
- package/dist/adjustment-DTSLM7AN.js.map +1 -0
- package/dist/analytics/index.d.ts +27 -0
- package/dist/analytics/index.js +6 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics-DMcD-o8w.d.ts +76 -0
- package/dist/api-factory-B_h4RKBm.d.ts +280 -0
- package/dist/auth/index.d.ts +39 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/catalog/index.d.ts +479 -0
- package/dist/catalog/index.js +9 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-4ZQK3FFN.js +40 -0
- package/dist/chunk-4ZQK3FFN.js.map +1 -0
- package/dist/chunk-5L6EXDGH.js +465 -0
- package/dist/chunk-5L6EXDGH.js.map +1 -0
- package/dist/chunk-5ZFW3FEI.js +183 -0
- package/dist/chunk-5ZFW3FEI.js.map +1 -0
- package/dist/chunk-66OQAZSL.js +94 -0
- package/dist/chunk-66OQAZSL.js.map +1 -0
- package/dist/chunk-6RYGA6MF.js +123 -0
- package/dist/chunk-6RYGA6MF.js.map +1 -0
- package/dist/chunk-B6MPVOV7.js +328 -0
- package/dist/chunk-B6MPVOV7.js.map +1 -0
- package/dist/chunk-BDA2WSJA.js +148 -0
- package/dist/chunk-BDA2WSJA.js.map +1 -0
- package/dist/chunk-EIVYT3HM.js +126 -0
- package/dist/chunk-EIVYT3HM.js.map +1 -0
- package/dist/chunk-EPQN7ZKZ.js +27 -0
- package/dist/chunk-EPQN7ZKZ.js.map +1 -0
- package/dist/chunk-FA7QFJ2G.js +177 -0
- package/dist/chunk-FA7QFJ2G.js.map +1 -0
- package/dist/chunk-I5TIKUIQ.js +261 -0
- package/dist/chunk-I5TIKUIQ.js.map +1 -0
- package/dist/chunk-ILQUH444.js +135 -0
- package/dist/chunk-ILQUH444.js.map +1 -0
- package/dist/chunk-IXMWZJLV.js +616 -0
- package/dist/chunk-IXMWZJLV.js.map +1 -0
- package/dist/chunk-KZIGRIQG.js +75 -0
- package/dist/chunk-KZIGRIQG.js.map +1 -0
- package/dist/chunk-OF5M6R2S.js +769 -0
- package/dist/chunk-OF5M6R2S.js.map +1 -0
- package/dist/chunk-PYYLHUV6.js +3 -0
- package/dist/chunk-PYYLHUV6.js.map +1 -0
- package/dist/chunk-QO5AGZFP.js +159 -0
- package/dist/chunk-QO5AGZFP.js.map +1 -0
- package/dist/chunk-QUMTBLNE.js +76 -0
- package/dist/chunk-QUMTBLNE.js.map +1 -0
- package/dist/chunk-R5Z7NYLH.js +126 -0
- package/dist/chunk-R5Z7NYLH.js.map +1 -0
- package/dist/chunk-SZYWG5IB.js +75 -0
- package/dist/chunk-SZYWG5IB.js.map +1 -0
- package/dist/chunk-U3XT35GZ.js +202 -0
- package/dist/chunk-U3XT35GZ.js.map +1 -0
- package/dist/chunk-UGELTUIZ.js +830 -0
- package/dist/chunk-UGELTUIZ.js.map +1 -0
- package/dist/chunk-VR36QVX2.js +122 -0
- package/dist/chunk-VR36QVX2.js.map +1 -0
- package/dist/chunk-WUOQK7BO.js +13 -0
- package/dist/chunk-WUOQK7BO.js.map +1 -0
- package/dist/chunk-X6PV5MHG.js +582 -0
- package/dist/chunk-X6PV5MHG.js.map +1 -0
- package/dist/chunk-ZWLMFLLH.js +534 -0
- package/dist/chunk-ZWLMFLLH.js.map +1 -0
- package/dist/content/index.d.ts +309 -0
- package/dist/content/index.js +6 -0
- package/dist/content/index.js.map +1 -0
- package/dist/core/index.d.ts +107 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/react.d.ts +107 -0
- package/dist/core/react.js +5 -0
- package/dist/core/react.js.map +1 -0
- package/dist/coupon-CHFcw7cd.d.ts +632 -0
- package/dist/coupon-zGkvO-Xx.d.ts +129 -0
- package/dist/crud.factory-DyKaPHcU.d.ts +181 -0
- package/dist/finance/index.d.ts +81 -0
- package/dist/finance/index.js +5 -0
- package/dist/finance/index.js.map +1 -0
- package/dist/finance-BJdfKRw0.d.ts +135 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory/index.d.ts +512 -0
- package/dist/inventory/index.js +16 -0
- package/dist/inventory/index.js.map +1 -0
- package/dist/inventory-DCiIZh8P.d.ts +742 -0
- package/dist/logistics/index.d.ts +226 -0
- package/dist/logistics/index.js +7 -0
- package/dist/logistics/index.js.map +1 -0
- package/dist/logistics-V8a9lUN3.d.ts +428 -0
- package/dist/media-CNLJK93J.d.ts +721 -0
- package/dist/movement-7MV3ADY5.js +5 -0
- package/dist/movement-7MV3ADY5.js.map +1 -0
- package/dist/payment-BRboLqvU.d.ts +127 -0
- package/dist/payments/index.d.ts +55 -0
- package/dist/payments/index.js +6 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/platform/index.d.ts +645 -0
- package/dist/platform/index.js +8 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/pos-D1jkkFl0.d.ts +885 -0
- package/dist/product-p09zXkXB.d.ts +260 -0
- package/dist/purchase-24BGT2HA.js +5 -0
- package/dist/purchase-24BGT2HA.js.map +1 -0
- package/dist/request-652PS6VR.js +5 -0
- package/dist/request-652PS6VR.js.map +1 -0
- package/dist/sales/index.d.ts +585 -0
- package/dist/sales/index.js +9 -0
- package/dist/sales/index.js.map +1 -0
- package/dist/server.d.ts +120 -0
- package/dist/server.js +27 -0
- package/dist/server.js.map +1 -0
- package/dist/size-guide-DgjzjM5P.d.ts +554 -0
- package/dist/stock-DEApGC-w.d.ts +632 -0
- package/dist/stock-OOUW57VQ.js +5 -0
- package/dist/stock-OOUW57VQ.js.map +1 -0
- package/dist/supplier-OC6JAWV6.js +5 -0
- package/dist/supplier-OC6JAWV6.js.map +1 -0
- package/dist/transaction/index.d.ts +104 -0
- package/dist/transaction/index.js +8 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction-BTmoHpWh.d.ts +428 -0
- package/dist/transaction-u5oaNuav.d.ts +84 -0
- package/dist/transfer-7SYSH3RG.js +5 -0
- package/dist/transfer-7SYSH3RG.js.map +1 -0
- package/dist/user-data-DdLjAGwO.d.ts +132 -0
- package/package.json +146 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { o as Transaction, C as CreateTransactionPayload, U as UpdateTransactionPayload, F as FinancialReport, q as CashFlowReport, r as CategoryReport, s as StatementResponse } from '../transaction-BTmoHpWh.js';
|
|
2
|
+
export { a as PaymentGatewayType, p as PaymentIntent, P as PaymentMethod, S as StatementRow, i as TaxType, e as TransactionCategory, f as TransactionCategoryType, l as TransactionCommission, T as TransactionFlow, b as TransactionFlowType, k as TransactionGateway, h as TransactionPaymentDetails, n as TransactionReconciliation, g as TransactionSplitPayment, c as TransactionStatus, d as TransactionStatusType, j as TransactionTaxDetails, t as TransactionType, m as TransactionWebhook } from '../transaction-BTmoHpWh.js';
|
|
3
|
+
import { R as ReportParams, C as CashFlowParams, a as CategoryParams, S as StatementParams } from '../transaction-u5oaNuav.js';
|
|
4
|
+
export { T as TransactionApi, t as transactionApi, t as transactionApiDefault } from '../transaction-u5oaNuav.js';
|
|
5
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
|
+
import { b as CrudHooksReturn, L as ListOptions, l as ListQueryResult, D as DetailOptions, m as DetailQueryResult, d as CrudActions, N as NavigateFn } from '../crud.factory-DyKaPHcU.js';
|
|
7
|
+
import '../api-factory-B_h4RKBm.js';
|
|
8
|
+
|
|
9
|
+
declare const TRANSACTION_KEYS: {
|
|
10
|
+
all: readonly ["transactions"];
|
|
11
|
+
lists: () => readonly ["transactions", "list"];
|
|
12
|
+
list: (params: Record<string, unknown>) => readonly ["transactions", "list", Record<string, unknown>];
|
|
13
|
+
details: () => readonly ["transactions", "detail"];
|
|
14
|
+
detail: (id: string) => readonly ["transactions", "detail", string];
|
|
15
|
+
reports: () => readonly ["transactions", "reports"];
|
|
16
|
+
profitLoss: (params: ReportParams) => readonly ["transactions", "reports", "profit-loss", ReportParams];
|
|
17
|
+
cashFlow: (params: CashFlowParams) => readonly ["transactions", "reports", "cash-flow", CashFlowParams];
|
|
18
|
+
categories: (params: CategoryParams) => readonly ["transactions", "reports", "categories", CategoryParams];
|
|
19
|
+
statement: (params: StatementParams) => readonly ["transactions", "reports", "statement", StatementParams];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Transaction CRUD hooks using createCrudHooks factory
|
|
23
|
+
*
|
|
24
|
+
* Provides:
|
|
25
|
+
* - useTransactions: List transactions with filtering/pagination
|
|
26
|
+
* - useTransactionDetail: Get single transaction
|
|
27
|
+
* - useTransactionActions: Create, update, delete mutations
|
|
28
|
+
* - useTransactionNavigation: Navigation between transactions
|
|
29
|
+
*/
|
|
30
|
+
declare const transactionHooks: CrudHooksReturn<Transaction, CreateTransactionPayload, UpdateTransactionPayload>;
|
|
31
|
+
declare const useTransactions: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Transaction>;
|
|
32
|
+
declare const useTransactionDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Transaction>;
|
|
33
|
+
declare const useTransactionActions: () => CrudActions<CreateTransactionPayload, UpdateTransactionPayload>;
|
|
34
|
+
declare const useTransactionNavigation: () => NavigateFn<Transaction>;
|
|
35
|
+
interface QueryOptions {
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
staleTime?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Fetch Profit & Loss report
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* const { data, isLoading } = useProfitLoss({
|
|
45
|
+
* startDate: '2024-01-01',
|
|
46
|
+
* endDate: '2024-12-31',
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* return (
|
|
50
|
+
* <div>
|
|
51
|
+
* <p>Income: {data?.income}</p>
|
|
52
|
+
* <p>Expense: {data?.expense}</p>
|
|
53
|
+
* <p>Net: {data?.net}</p>
|
|
54
|
+
* </div>
|
|
55
|
+
* );
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare function useProfitLoss(params: ReportParams, options?: QueryOptions): _tanstack_react_query.UseQueryResult<FinancialReport, Error>;
|
|
59
|
+
/**
|
|
60
|
+
* Fetch Cash Flow report (monthly trend)
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* const { data, isLoading } = useCashFlow({ months: 6 });
|
|
65
|
+
*
|
|
66
|
+
* return (
|
|
67
|
+
* <BarChart data={data?.months} />
|
|
68
|
+
* );
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function useCashFlow(params?: CashFlowParams, options?: QueryOptions): _tanstack_react_query.UseQueryResult<CashFlowReport, Error>;
|
|
72
|
+
/**
|
|
73
|
+
* Fetch Category breakdown report
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* // Get expense categories
|
|
78
|
+
* const { data } = useCategoryReport({ flow: 'outflow', limit: 10 });
|
|
79
|
+
*
|
|
80
|
+
* return (
|
|
81
|
+
* <PieChart data={data?.categories} />
|
|
82
|
+
* );
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare function useCategoryReport(params?: CategoryParams, options?: QueryOptions): _tanstack_react_query.UseQueryResult<CategoryReport, Error>;
|
|
86
|
+
/**
|
|
87
|
+
* Fetch Statement export (JSON format)
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```tsx
|
|
91
|
+
* const { data } = useStatement({
|
|
92
|
+
* startDate: '2024-01-01',
|
|
93
|
+
* endDate: '2024-12-31',
|
|
94
|
+
* format: 'json',
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* return (
|
|
98
|
+
* <DataTable data={data?.data} />
|
|
99
|
+
* );
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function useStatement(params: StatementParams, options?: QueryOptions): _tanstack_react_query.UseQueryResult<StatementResponse, Error>;
|
|
103
|
+
|
|
104
|
+
export { CashFlowParams, CashFlowReport, CategoryParams, CategoryReport, CreateTransactionPayload, FinancialReport, ReportParams, StatementParams, StatementResponse, TRANSACTION_KEYS, Transaction, UpdateTransactionPayload, transactionHooks, useCashFlow, useCategoryReport, useProfitLoss, useStatement, useTransactionActions, useTransactionDetail, useTransactionNavigation, useTransactions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export { TRANSACTION_KEYS, TransactionApi, TransactionCategory, TransactionFlow, TransactionStatus, TransactionType, transactionApi, transaction_default as transactionApiDefault, transactionHooks, useCashFlow, useCategoryReport, useProfitLoss, useStatement, useTransactionActions, useTransactionDetail, useTransactionNavigation, useTransactions } from '../chunk-5ZFW3FEI.js';
|
|
3
|
+
import '../chunk-I5TIKUIQ.js';
|
|
4
|
+
import '../chunk-B6MPVOV7.js';
|
|
5
|
+
import '../chunk-U3XT35GZ.js';
|
|
6
|
+
import '../chunk-VR36QVX2.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction Types
|
|
3
|
+
*
|
|
4
|
+
* Transactions track cashflow events across the system.
|
|
5
|
+
* Used by: Orders, POS, Inventory, CRM, HRM, and manual entries.
|
|
6
|
+
*
|
|
7
|
+
* Sources:
|
|
8
|
+
* - modules/transaction/transaction.model.js
|
|
9
|
+
* - common/revenue/enums.js
|
|
10
|
+
* - @classytic/revenue library
|
|
11
|
+
*
|
|
12
|
+
* Key concepts:
|
|
13
|
+
* - `flow`: Direction of money ('inflow' = income, 'outflow' = expense)
|
|
14
|
+
* - `type`: Category of transaction (order_purchase, refund, rent, etc.)
|
|
15
|
+
* - Amounts in smallest unit (paisa for BDT)
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Payment methods supported by the system
|
|
19
|
+
*/
|
|
20
|
+
type PaymentMethod = 'cash' | 'bkash' | 'nagad' | 'rocket' | 'upay' | 'bank_transfer' | 'card' | 'online' | 'manual' | 'split' | 'cod';
|
|
21
|
+
type PaymentGatewayType = 'manual' | 'stripe' | 'sslcommerz' | 'bkash' | 'nagad';
|
|
22
|
+
/**
|
|
23
|
+
* Transaction Flow - Direction of money movement
|
|
24
|
+
* - inflow: Money coming in (sales, income, capital injection)
|
|
25
|
+
* - outflow: Money going out (expenses, refunds, purchases)
|
|
26
|
+
*/
|
|
27
|
+
declare enum TransactionFlow {
|
|
28
|
+
INFLOW = "inflow",
|
|
29
|
+
OUTFLOW = "outflow"
|
|
30
|
+
}
|
|
31
|
+
type TransactionFlowType = 'inflow' | 'outflow';
|
|
32
|
+
/**
|
|
33
|
+
* Transaction Status - Payment lifecycle states
|
|
34
|
+
*/
|
|
35
|
+
declare enum TransactionStatus {
|
|
36
|
+
PENDING = "pending",
|
|
37
|
+
PAYMENT_INITIATED = "payment_initiated",
|
|
38
|
+
PROCESSING = "processing",
|
|
39
|
+
REQUIRES_ACTION = "requires_action",
|
|
40
|
+
VERIFIED = "verified",
|
|
41
|
+
COMPLETED = "completed",
|
|
42
|
+
FAILED = "failed",
|
|
43
|
+
CANCELLED = "cancelled",
|
|
44
|
+
EXPIRED = "expired",
|
|
45
|
+
REFUNDED = "refunded",
|
|
46
|
+
PARTIALLY_REFUNDED = "partially_refunded"
|
|
47
|
+
}
|
|
48
|
+
type TransactionStatusType = 'pending' | 'payment_initiated' | 'processing' | 'requires_action' | 'verified' | 'completed' | 'failed' | 'cancelled' | 'expired' | 'refunded' | 'partially_refunded';
|
|
49
|
+
/**
|
|
50
|
+
* Transaction Categories
|
|
51
|
+
*
|
|
52
|
+
* The `type` field stores the category for reporting/grouping.
|
|
53
|
+
* Flow is determined by `flow` field, not by category.
|
|
54
|
+
*
|
|
55
|
+
* ┌─────────────────────────────────────────────────────────────────┐
|
|
56
|
+
* │ INFLOW (Income) │ OUTFLOW (Expense) │
|
|
57
|
+
* ├─────────────────────────────────┼───────────────────────────────┤
|
|
58
|
+
* │ order_purchase (POS/Web sales) │ inventory_purchase (stock) │
|
|
59
|
+
* │ wholesale_sale (B2B sales) │ purchase_return (refund recv) │
|
|
60
|
+
* │ capital_injection │ cogs (cost of goods sold) │
|
|
61
|
+
* │ retained_earnings │ rent, utilities, equipment... │
|
|
62
|
+
* │ other_income │ inventory_loss │
|
|
63
|
+
* │ tip_income (optional) │ marketing, maintenance... │
|
|
64
|
+
* │ │ refund (customer refunds) │
|
|
65
|
+
* └─────────────────────────────────┴───────────────────────────────┘
|
|
66
|
+
*/
|
|
67
|
+
declare enum TransactionCategory {
|
|
68
|
+
ORDER_PURCHASE = "order_purchase",
|
|
69
|
+
ORDER_SUBSCRIPTION = "order_subscription",
|
|
70
|
+
WHOLESALE_SALE = "wholesale_sale",
|
|
71
|
+
PLATFORM_SUBSCRIPTION = "platform_subscription",
|
|
72
|
+
CREATOR_SUBSCRIPTION = "creator_subscription",
|
|
73
|
+
ENROLLMENT_PURCHASE = "enrollment_purchase",
|
|
74
|
+
ENROLLMENT_SUBSCRIPTION = "enrollment_subscription",
|
|
75
|
+
INVENTORY_PURCHASE = "inventory_purchase",
|
|
76
|
+
PURCHASE_RETURN = "purchase_return",
|
|
77
|
+
INVENTORY_LOSS = "inventory_loss",
|
|
78
|
+
INVENTORY_ADJUSTMENT = "inventory_adjustment",
|
|
79
|
+
COGS = "cogs",
|
|
80
|
+
REFUND = "refund",
|
|
81
|
+
SUBSCRIPTION = "subscription",
|
|
82
|
+
PURCHASE = "purchase",
|
|
83
|
+
RENT = "rent",
|
|
84
|
+
UTILITIES = "utilities",
|
|
85
|
+
EQUIPMENT = "equipment",
|
|
86
|
+
SUPPLIES = "supplies",
|
|
87
|
+
MAINTENANCE = "maintenance",
|
|
88
|
+
MARKETING = "marketing",
|
|
89
|
+
OTHER_EXPENSE = "other_expense",
|
|
90
|
+
CAPITAL_INJECTION = "capital_injection",
|
|
91
|
+
RETAINED_EARNINGS = "retained_earnings",
|
|
92
|
+
TIP_INCOME = "tip_income",
|
|
93
|
+
OTHER_INCOME = "other_income"
|
|
94
|
+
}
|
|
95
|
+
type TransactionCategoryType = 'order_purchase' | 'order_subscription' | 'wholesale_sale' | 'platform_subscription' | 'creator_subscription' | 'enrollment_purchase' | 'enrollment_subscription' | 'refund' | 'subscription' | 'purchase' | 'inventory_purchase' | 'purchase_return' | 'inventory_loss' | 'inventory_adjustment' | 'cogs' | 'rent' | 'utilities' | 'equipment' | 'supplies' | 'maintenance' | 'marketing' | 'other_expense' | 'capital_injection' | 'retained_earnings' | 'tip_income' | 'other_income';
|
|
96
|
+
/**
|
|
97
|
+
* Transaction Split Payment - Individual payment in a split transaction
|
|
98
|
+
* Different from POS SplitPaymentEntry which has additional UI state fields
|
|
99
|
+
*/
|
|
100
|
+
interface TransactionSplitPayment {
|
|
101
|
+
method: PaymentMethod;
|
|
102
|
+
amount: number;
|
|
103
|
+
reference?: string;
|
|
104
|
+
details?: Record<string, unknown>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Payment Details - For manual/split payments
|
|
108
|
+
*/
|
|
109
|
+
interface TransactionPaymentDetails {
|
|
110
|
+
walletNumber?: string;
|
|
111
|
+
walletType?: 'personal' | 'merchant';
|
|
112
|
+
trxId?: string;
|
|
113
|
+
bankName?: string;
|
|
114
|
+
accountNumber?: string;
|
|
115
|
+
accountName?: string;
|
|
116
|
+
proofUrl?: string;
|
|
117
|
+
/** Split payment entries (when method is 'split') */
|
|
118
|
+
payments?: TransactionSplitPayment[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Tax type for transactions
|
|
122
|
+
*/
|
|
123
|
+
type TaxType = 'vat' | 'gst' | 'sales_tax' | 'income_tax' | 'withholding_tax' | 'none';
|
|
124
|
+
/**
|
|
125
|
+
* Tax Details for VAT/GST/Sales Tax tracking
|
|
126
|
+
*/
|
|
127
|
+
interface TransactionTaxDetails {
|
|
128
|
+
/** Tax type: vat, gst, sales_tax, etc. */
|
|
129
|
+
type?: TaxType;
|
|
130
|
+
/** Tax rate as decimal (0.15 = 15%) */
|
|
131
|
+
rate?: number;
|
|
132
|
+
/** Whether prices include tax (BD default: true) */
|
|
133
|
+
isInclusive?: boolean;
|
|
134
|
+
/** Tax jurisdiction code (e.g., 'BD' for Bangladesh) */
|
|
135
|
+
jurisdiction?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Gateway Details - Payment provider info
|
|
139
|
+
*/
|
|
140
|
+
interface TransactionGateway {
|
|
141
|
+
type: PaymentGatewayType | string;
|
|
142
|
+
provider?: string;
|
|
143
|
+
paymentUrl?: string;
|
|
144
|
+
transactionId?: string;
|
|
145
|
+
sessionId?: string;
|
|
146
|
+
paymentIntentId?: string;
|
|
147
|
+
metadata?: Record<string, unknown>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Commission tracking for gateway/marketplace payments
|
|
151
|
+
*/
|
|
152
|
+
interface TransactionCommission {
|
|
153
|
+
/** Commission rate as decimal */
|
|
154
|
+
rate?: number;
|
|
155
|
+
/** Gross commission amount */
|
|
156
|
+
grossAmount?: number;
|
|
157
|
+
/** Gateway fee rate as decimal */
|
|
158
|
+
gatewayFeeRate?: number;
|
|
159
|
+
/** Gateway fee amount */
|
|
160
|
+
gatewayFeeAmount?: number;
|
|
161
|
+
/** Net commission amount (grossAmount - gatewayFeeAmount) */
|
|
162
|
+
netAmount?: number;
|
|
163
|
+
/** Commission status */
|
|
164
|
+
status?: 'pending' | 'due' | 'paid' | 'waived' | 'reversed';
|
|
165
|
+
/** Commission due date (ISO 8601) */
|
|
166
|
+
dueDate?: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Webhook tracking
|
|
170
|
+
*/
|
|
171
|
+
interface TransactionWebhook {
|
|
172
|
+
eventId?: string;
|
|
173
|
+
eventType?: string;
|
|
174
|
+
receivedAt?: string;
|
|
175
|
+
processedAt?: string;
|
|
176
|
+
payload?: Record<string, unknown>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Reconciliation tracking
|
|
180
|
+
*/
|
|
181
|
+
interface TransactionReconciliation {
|
|
182
|
+
isReconciled?: boolean;
|
|
183
|
+
reconciledAt?: string;
|
|
184
|
+
reconciledBy?: string;
|
|
185
|
+
bankStatementRef?: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Transaction Document
|
|
189
|
+
*
|
|
190
|
+
* Key fields:
|
|
191
|
+
* - flow: Direction of money (inflow/outflow)
|
|
192
|
+
* - type: Category of transaction (order_purchase, refund, etc.)
|
|
193
|
+
* - amount: Gross amount in smallest unit (paisa)
|
|
194
|
+
* - fee: Platform/gateway fees deducted
|
|
195
|
+
* - tax: VAT/tax portion (informational)
|
|
196
|
+
* - net: amount - fee - tax (derived)
|
|
197
|
+
*/
|
|
198
|
+
interface Transaction {
|
|
199
|
+
_id: string;
|
|
200
|
+
organizationId?: string;
|
|
201
|
+
/**
|
|
202
|
+
* Flow direction: 'inflow' (money in) or 'outflow' (money out)
|
|
203
|
+
* Use this for Income/Expense classification in UI
|
|
204
|
+
*/
|
|
205
|
+
flow: TransactionFlowType;
|
|
206
|
+
/**
|
|
207
|
+
* Transaction category (e.g. 'order_purchase', 'refund', 'rent', 'cogs')
|
|
208
|
+
* Note: Backend stores category in the 'type' field
|
|
209
|
+
*/
|
|
210
|
+
type: TransactionCategoryType | string;
|
|
211
|
+
/** Transaction status */
|
|
212
|
+
status: TransactionStatusType | string;
|
|
213
|
+
/** Gross money that moved (in smallest unit, e.g. paisa) */
|
|
214
|
+
amount: number;
|
|
215
|
+
/** Currency code (default: 'BDT') */
|
|
216
|
+
currency?: string;
|
|
217
|
+
/** Platform/gateway fees deducted */
|
|
218
|
+
fee?: number;
|
|
219
|
+
/** VAT/tax portion (informational, for VAT reporting) */
|
|
220
|
+
tax?: number;
|
|
221
|
+
/** Net amount: amount - fee - tax */
|
|
222
|
+
net?: number;
|
|
223
|
+
/** Tax details for VAT/GST reporting */
|
|
224
|
+
taxDetails?: TransactionTaxDetails;
|
|
225
|
+
customerId?: string | null;
|
|
226
|
+
handledBy?: string | null;
|
|
227
|
+
method: PaymentMethod | string;
|
|
228
|
+
gateway?: TransactionGateway;
|
|
229
|
+
paymentDetails?: TransactionPaymentDetails;
|
|
230
|
+
/** Source model type (Order, Purchase, Manual) - polymorphic reference */
|
|
231
|
+
sourceModel?: 'Order' | 'Purchase' | 'Manual' | string;
|
|
232
|
+
/** Source document ID */
|
|
233
|
+
sourceId?: string;
|
|
234
|
+
/** Related transaction (for refunds linking to original) */
|
|
235
|
+
relatedTransactionId?: string;
|
|
236
|
+
/** Source channel: where the transaction originated */
|
|
237
|
+
source: 'web' | 'pos' | 'api';
|
|
238
|
+
/** Branch reference ID */
|
|
239
|
+
branch?: string;
|
|
240
|
+
/** Branch code for display */
|
|
241
|
+
branchCode?: string;
|
|
242
|
+
/** Commission tracking for gateway payments */
|
|
243
|
+
commission?: TransactionCommission;
|
|
244
|
+
/** Revenue splits (for marketplace use) */
|
|
245
|
+
splits?: Array<{
|
|
246
|
+
recipientId?: string;
|
|
247
|
+
recipientType?: string;
|
|
248
|
+
type?: string;
|
|
249
|
+
amount?: number;
|
|
250
|
+
status?: string;
|
|
251
|
+
paidAt?: string;
|
|
252
|
+
}>;
|
|
253
|
+
metadata?: Record<string, unknown>;
|
|
254
|
+
description?: string;
|
|
255
|
+
notes?: string;
|
|
256
|
+
idempotencyKey?: string;
|
|
257
|
+
webhook?: TransactionWebhook;
|
|
258
|
+
/** Actual transaction date (when it occurred) */
|
|
259
|
+
date?: string;
|
|
260
|
+
verifiedBy?: string;
|
|
261
|
+
verifiedAt?: string;
|
|
262
|
+
initiatedAt?: string;
|
|
263
|
+
completedAt?: string;
|
|
264
|
+
paidAt?: string;
|
|
265
|
+
failedAt?: string;
|
|
266
|
+
failureReason?: string;
|
|
267
|
+
refundedAt?: string;
|
|
268
|
+
refundedAmount?: number;
|
|
269
|
+
refundReason?: string;
|
|
270
|
+
reconciliation?: TransactionReconciliation;
|
|
271
|
+
createdAt: string;
|
|
272
|
+
updatedAt: string;
|
|
273
|
+
isPaid?: boolean;
|
|
274
|
+
amountInUnits?: number;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Payload to create a Manual Transaction (OpEx, CapEx, etc.)
|
|
278
|
+
* Most transactions are system-managed via order/POS flows.
|
|
279
|
+
*/
|
|
280
|
+
interface CreateTransactionPayload {
|
|
281
|
+
flow: TransactionFlowType;
|
|
282
|
+
type: TransactionCategoryType | string;
|
|
283
|
+
amount: number;
|
|
284
|
+
method?: PaymentMethod | string;
|
|
285
|
+
source?: 'web' | 'pos' | 'api';
|
|
286
|
+
branch?: string;
|
|
287
|
+
branchCode?: string;
|
|
288
|
+
date?: string;
|
|
289
|
+
notes?: string;
|
|
290
|
+
description?: string;
|
|
291
|
+
paymentDetails?: TransactionPaymentDetails;
|
|
292
|
+
taxDetails?: TransactionTaxDetails;
|
|
293
|
+
metadata?: Record<string, unknown>;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Payload to update a Transaction (limited fields)
|
|
297
|
+
* Editable correction fields (permissioned)
|
|
298
|
+
*/
|
|
299
|
+
interface UpdateTransactionPayload {
|
|
300
|
+
flow?: TransactionFlowType;
|
|
301
|
+
type?: TransactionCategoryType | string;
|
|
302
|
+
amount?: number;
|
|
303
|
+
fee?: number;
|
|
304
|
+
tax?: number;
|
|
305
|
+
net?: number;
|
|
306
|
+
method?: PaymentMethod | string;
|
|
307
|
+
paymentDetails?: TransactionPaymentDetails;
|
|
308
|
+
taxDetails?: TransactionTaxDetails;
|
|
309
|
+
branch?: string;
|
|
310
|
+
branchCode?: string;
|
|
311
|
+
source?: 'web' | 'pos' | 'api';
|
|
312
|
+
notes?: string;
|
|
313
|
+
description?: string;
|
|
314
|
+
metadata?: Record<string, unknown>;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Payment Intent - Returned with order/POS transactions
|
|
318
|
+
*/
|
|
319
|
+
interface PaymentIntent {
|
|
320
|
+
id: string;
|
|
321
|
+
provider: PaymentGatewayType | string;
|
|
322
|
+
status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'cancelled';
|
|
323
|
+
/** Manual payment instructions */
|
|
324
|
+
instructions?: {
|
|
325
|
+
bkash?: string;
|
|
326
|
+
nagad?: string;
|
|
327
|
+
bank?: string;
|
|
328
|
+
reference?: string;
|
|
329
|
+
note?: string;
|
|
330
|
+
};
|
|
331
|
+
/** Stripe SDK client secret */
|
|
332
|
+
clientSecret?: string | null;
|
|
333
|
+
/** Redirect URL for hosted payment pages */
|
|
334
|
+
paymentUrl?: string | null;
|
|
335
|
+
metadata?: Record<string, unknown>;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Financial Report Response (Profit & Loss)
|
|
339
|
+
* Uses flow-based totals: inflow (income) vs outflow (expense)
|
|
340
|
+
*/
|
|
341
|
+
interface FinancialReport {
|
|
342
|
+
/** Total inflow (income) */
|
|
343
|
+
income: number;
|
|
344
|
+
/** Total outflow (expense) */
|
|
345
|
+
expense: number;
|
|
346
|
+
/** Net profit (income - expense) */
|
|
347
|
+
net: number;
|
|
348
|
+
/** Breakdown by category (type field) */
|
|
349
|
+
breakdown: Record<string, number>;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Cash Flow Report Response
|
|
353
|
+
* Monthly trend of inflow vs outflow
|
|
354
|
+
*/
|
|
355
|
+
interface CashFlowReport {
|
|
356
|
+
months: Array<{
|
|
357
|
+
month: string;
|
|
358
|
+
/** Total inflow (income) for the month */
|
|
359
|
+
inflow: number;
|
|
360
|
+
/** Total outflow (expense) for the month */
|
|
361
|
+
outflow: number;
|
|
362
|
+
/** Net cash flow (inflow - outflow) */
|
|
363
|
+
net: number;
|
|
364
|
+
}>;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Category Report Response
|
|
368
|
+
*/
|
|
369
|
+
interface CategoryReport {
|
|
370
|
+
categories: Array<{
|
|
371
|
+
category: string;
|
|
372
|
+
total: number;
|
|
373
|
+
count: number;
|
|
374
|
+
}>;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Statement Row (for CSV/JSON export)
|
|
378
|
+
*/
|
|
379
|
+
interface StatementRow {
|
|
380
|
+
transactionId: string;
|
|
381
|
+
transactionDate: string | null;
|
|
382
|
+
createdAt: string | null;
|
|
383
|
+
status: string;
|
|
384
|
+
/** Flow direction: inflow/outflow */
|
|
385
|
+
flow: string;
|
|
386
|
+
/** Transaction category (type field) */
|
|
387
|
+
type: string;
|
|
388
|
+
source: string;
|
|
389
|
+
branchCode: string | null;
|
|
390
|
+
branchId: string | null;
|
|
391
|
+
method: string;
|
|
392
|
+
/** Gross amount in BDT (converted from paisa) */
|
|
393
|
+
amountBdt: number;
|
|
394
|
+
/** Fee amount in BDT */
|
|
395
|
+
feeBdt?: number;
|
|
396
|
+
/** Tax amount in BDT */
|
|
397
|
+
taxBdt?: number;
|
|
398
|
+
/** Net amount in BDT (amount - fee - tax) */
|
|
399
|
+
netBdt?: number;
|
|
400
|
+
currency: string;
|
|
401
|
+
/** Source model (Order, Purchase, Manual) */
|
|
402
|
+
sourceModel?: string;
|
|
403
|
+
/** Source document ID */
|
|
404
|
+
sourceId?: string | null;
|
|
405
|
+
orderId: string | null;
|
|
406
|
+
orderCustomerName: string | null;
|
|
407
|
+
vatInvoiceNumber: string | null;
|
|
408
|
+
vatSellerBin: string | null;
|
|
409
|
+
paymentReference: string | null;
|
|
410
|
+
narration: string | null;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Statement Export Response (JSON format)
|
|
414
|
+
*/
|
|
415
|
+
interface StatementResponse {
|
|
416
|
+
success: boolean;
|
|
417
|
+
count: number;
|
|
418
|
+
data: StatementRow[];
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* @deprecated Use TransactionFlow instead. Backend uses flow (inflow/outflow).
|
|
422
|
+
*/
|
|
423
|
+
declare enum TransactionType {
|
|
424
|
+
INCOME = "income",
|
|
425
|
+
EXPENSE = "expense"
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
export { type CreateTransactionPayload as C, type FinancialReport as F, type PaymentMethod as P, type StatementRow as S, TransactionFlow as T, type UpdateTransactionPayload as U, type PaymentGatewayType as a, type TransactionFlowType as b, TransactionStatus as c, type TransactionStatusType as d, TransactionCategory as e, type TransactionCategoryType as f, type TransactionSplitPayment as g, type TransactionPaymentDetails as h, type TaxType as i, type TransactionTaxDetails as j, type TransactionGateway as k, type TransactionCommission as l, type TransactionWebhook as m, type TransactionReconciliation as n, type Transaction as o, type PaymentIntent as p, type CashFlowReport as q, type CategoryReport as r, type StatementResponse as s, TransactionType as t };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { B as BaseApi } from './api-factory-B_h4RKBm.js';
|
|
2
|
+
import { o as Transaction, C as CreateTransactionPayload, U as UpdateTransactionPayload, F as FinancialReport, q as CashFlowReport, r as CategoryReport, s as StatementResponse } from './transaction-BTmoHpWh.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Transaction API Client
|
|
6
|
+
*
|
|
7
|
+
* Transactions track cashflow events (money in/out) across the system.
|
|
8
|
+
* Used by: Orders, POS, Inventory, CRM, HRM, and manual entries.
|
|
9
|
+
*
|
|
10
|
+
* CRUD (via BaseApi):
|
|
11
|
+
* - getAll(params) - List transactions
|
|
12
|
+
* - getById(id) - Get transaction
|
|
13
|
+
* - create(payload) - Create manual transaction (staff only)
|
|
14
|
+
* - update(id, payload) - Update transaction (limited fields)
|
|
15
|
+
* - delete(id) - Delete transaction (admin/superadmin only)
|
|
16
|
+
*
|
|
17
|
+
* Reports:
|
|
18
|
+
* - getProfitLoss(params) - P&L statement
|
|
19
|
+
* - getCashFlow(params) - Monthly trend
|
|
20
|
+
* - getCategoryReport(params) - Category breakdown
|
|
21
|
+
*
|
|
22
|
+
* Export:
|
|
23
|
+
* - getStatement(params) - CSV/JSON export for accountants
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Statement Query Params
|
|
28
|
+
*/
|
|
29
|
+
interface StatementParams {
|
|
30
|
+
startDate?: string;
|
|
31
|
+
endDate?: string;
|
|
32
|
+
branchId?: string;
|
|
33
|
+
source?: 'web' | 'pos' | 'api';
|
|
34
|
+
status?: string;
|
|
35
|
+
format?: 'csv' | 'json';
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Report Query Params
|
|
40
|
+
*/
|
|
41
|
+
interface ReportParams {
|
|
42
|
+
startDate?: string;
|
|
43
|
+
endDate?: string;
|
|
44
|
+
branchId?: string;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
interface CashFlowParams {
|
|
48
|
+
months?: number;
|
|
49
|
+
branchId?: string;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
interface CategoryParams extends ReportParams {
|
|
53
|
+
flow?: 'inflow' | 'outflow';
|
|
54
|
+
limit?: number;
|
|
55
|
+
}
|
|
56
|
+
declare class TransactionApi extends BaseApi<Transaction, CreateTransactionPayload, UpdateTransactionPayload> {
|
|
57
|
+
/**
|
|
58
|
+
* Get Profit & Loss Report
|
|
59
|
+
* Returns income (inflow), expenses (outflow), and net profit for a date range
|
|
60
|
+
*/
|
|
61
|
+
getProfitLoss(params?: ReportParams, options?: {}): Promise<FinancialReport>;
|
|
62
|
+
/**
|
|
63
|
+
* Get Cash Flow Report
|
|
64
|
+
* Returns monthly inflow, outflow, and net trend
|
|
65
|
+
*/
|
|
66
|
+
getCashFlow(params?: CashFlowParams, options?: {}): Promise<CashFlowReport>;
|
|
67
|
+
/**
|
|
68
|
+
* Get Category Breakdown
|
|
69
|
+
* Returns top spending/income categories for a date range
|
|
70
|
+
* Filter by flow='inflow' for income categories, flow='outflow' for expense categories
|
|
71
|
+
*/
|
|
72
|
+
getCategoryReport(params?: CategoryParams, options?: {}): Promise<CategoryReport>;
|
|
73
|
+
/**
|
|
74
|
+
* Get Statement Export
|
|
75
|
+
* Accountant-friendly export with branch + VAT invoice references
|
|
76
|
+
*
|
|
77
|
+
* @param params.format - 'csv' (default) or 'json'
|
|
78
|
+
* @returns CSV blob (format=csv) or StatementResponse (format=json)
|
|
79
|
+
*/
|
|
80
|
+
getStatement(params?: StatementParams, options?: {}): Promise<Blob | StatementResponse>;
|
|
81
|
+
}
|
|
82
|
+
declare const transactionApi: TransactionApi;
|
|
83
|
+
|
|
84
|
+
export { type CashFlowParams as C, type ReportParams as R, type StatementParams as S, TransactionApi as T, type CategoryParams as a, transactionApi as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-7SYSH3RG.js"}
|