@classytic/revenue 2.2.0 → 2.4.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.
- package/CHANGELOG.md +45 -0
- package/dist/{bank-feed.enums-kYTLTTbe.mjs → bank-feed.enums-ByS3mjX0.mjs} +11 -4
- package/dist/{bank-feed.enums-BadqNJTC.d.mts → bank-feed.enums-CqTW2Blz.d.mts} +4 -0
- package/dist/core/state-machines.d.mts +1 -1
- package/dist/core/state-machines.mjs +15 -4
- package/dist/{engine-types-ChFPg3kw.d.mts → engine-types-BU8kkttr.d.mts} +43 -2
- package/dist/enums/index.d.mts +1 -1
- package/dist/enums/index.mjs +1 -1
- package/dist/{escrow.schema-BdDHuQ8C.d.mts → escrow.schema-Cklvlywy.d.mts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/providers/index.d.mts +1 -1
- package/dist/{registry-h8sasoLh.d.mts → registry-DSG7x-Cl.d.mts} +1 -1
- package/dist/repositories/create-repositories.d.mts +1 -1
- package/dist/repositories/create-repositories.mjs +1 -1
- package/dist/{settlement.repository-CfvgX3et.mjs → settlement.repository-DtLSBDIk.mjs} +65 -2
- package/dist/validators/index.d.mts +1 -1
- package/dist/validators/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,51 @@
|
|
|
3
3
|
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
4
4
|
adhering to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
5
|
|
|
6
|
+
## [2.4.0] - 2026-06-14
|
|
7
|
+
|
|
8
|
+
### Added — `settled` bank-feed/manual status + `settle()` / `unsettle()` verbs
|
|
9
|
+
|
|
10
|
+
New `BANK_FEED_STATUS.SETTLED` (`'settled'`) for a bank line that was reconciled
|
|
11
|
+
by a **linked document** (an invoice/bill whose payment already posted the cash
|
|
12
|
+
JE, `Dr Bank / Cr AR`). The line itself posts **no second journal entry**.
|
|
13
|
+
|
|
14
|
+
- `transaction.settle(id, { settledBy?, metadata? })` — `imported → settled`
|
|
15
|
+
(bank_feed) / `pending → settled` (manual). Does **not** call the ledger
|
|
16
|
+
bridge (no JE). Idempotent (re-running on a `settled` row is a no-op).
|
|
17
|
+
`metadata` is shallow-merged (dotted `$set`) so the host can stamp the link
|
|
18
|
+
back to the settling document.
|
|
19
|
+
- `transaction.unsettle(id, { unsettledBy?, clearMetadata? })` — reverses to the
|
|
20
|
+
birth status (`settled → imported` bank_feed / `settled → pending` manual) and
|
|
21
|
+
clears the named metadata keys.
|
|
22
|
+
|
|
23
|
+
Unlike `reconciled_external` (vendor-owned, born terminal, no edges), `settled`
|
|
24
|
+
is **reachable and reversible** but never enters the JE bridge. This replaces the
|
|
25
|
+
host-side pattern of a raw `updateOne` parking invoice-settled rows at `matched`
|
|
26
|
+
(which overloaded `matched` and forced every consumer to sniff
|
|
27
|
+
`metadata.matchedVia` to tell "done" from "needs a JE"). `status` is now the
|
|
28
|
+
single source of truth.
|
|
29
|
+
|
|
30
|
+
## [2.3.0] - 2026-06-02
|
|
31
|
+
|
|
32
|
+
### Added — `reconciled_external` terminal bank-feed status
|
|
33
|
+
|
|
34
|
+
New `BANK_FEED_STATUS.RECONCILED_EXTERNAL` (`'reconciled_external'`) for rows
|
|
35
|
+
that are already reconciled at the source vendor (e.g. synced Xero Payments or
|
|
36
|
+
bank-transfer legs whose GL the vendor already owns). It is a **terminal island**
|
|
37
|
+
in the bank-feed state machine: no inbound edge (cannot be flipped in from
|
|
38
|
+
`imported`/`matched`) and no outbound edge — so `match()`/`journalize()`/
|
|
39
|
+
`unmatch()` all throw `InvalidStateTransition`. Such rows can never post a
|
|
40
|
+
journal entry, so surfacing them for visibility can't double-count the ledger.
|
|
41
|
+
|
|
42
|
+
### Added — `initialStatus` option on `TransactionRepository.import()`
|
|
43
|
+
|
|
44
|
+
`import(rows, { …, initialStatus }, ctx)` overrides the born status of newly
|
|
45
|
+
inserted bank-feed rows (default `imported`). Pass `reconciled_external` so
|
|
46
|
+
vendor-reconciled rows are **born** terminal + non-matchable (closes the
|
|
47
|
+
race where a row could be matched in the window between insert and a later
|
|
48
|
+
status flip). Applies to `$setOnInsert` only — re-imports never overwrite an
|
|
49
|
+
existing row's status.
|
|
50
|
+
|
|
6
51
|
## [2.2.0] - 2026-05-26
|
|
7
52
|
|
|
8
53
|
### Added — auth/capture + dispute event coverage
|
|
@@ -19,7 +19,9 @@ const TRANSACTION_STATUS = {
|
|
|
19
19
|
IMPORTED: "imported",
|
|
20
20
|
MATCHED: "matched",
|
|
21
21
|
JOURNALIZED: "journalized",
|
|
22
|
-
REJECTED: "rejected"
|
|
22
|
+
REJECTED: "rejected",
|
|
23
|
+
RECONCILED_EXTERNAL: "reconciled_external",
|
|
24
|
+
SETTLED: "settled"
|
|
23
25
|
};
|
|
24
26
|
const TRANSACTION_STATUS_VALUES = Object.values(TRANSACTION_STATUS);
|
|
25
27
|
const LIBRARY_CATEGORIES = {
|
|
@@ -71,7 +73,9 @@ const BANK_FEED_STATUS = {
|
|
|
71
73
|
IMPORTED: "imported",
|
|
72
74
|
MATCHED: "matched",
|
|
73
75
|
JOURNALIZED: "journalized",
|
|
74
|
-
REJECTED: "rejected"
|
|
76
|
+
REJECTED: "rejected",
|
|
77
|
+
RECONCILED_EXTERNAL: "reconciled_external",
|
|
78
|
+
SETTLED: "settled"
|
|
75
79
|
};
|
|
76
80
|
const BANK_FEED_STATUS_VALUES = Object.values(BANK_FEED_STATUS);
|
|
77
81
|
const bankFeedStatusSet = new Set(BANK_FEED_STATUS_VALUES);
|
|
@@ -129,13 +133,16 @@ const STATUSES_BY_KIND = {
|
|
|
129
133
|
TRANSACTION_STATUS.IMPORTED,
|
|
130
134
|
TRANSACTION_STATUS.MATCHED,
|
|
131
135
|
TRANSACTION_STATUS.JOURNALIZED,
|
|
132
|
-
TRANSACTION_STATUS.REJECTED
|
|
136
|
+
TRANSACTION_STATUS.REJECTED,
|
|
137
|
+
TRANSACTION_STATUS.RECONCILED_EXTERNAL,
|
|
138
|
+
TRANSACTION_STATUS.SETTLED
|
|
133
139
|
]),
|
|
134
140
|
[TRANSACTION_KIND.MANUAL]: new Set([
|
|
135
141
|
TRANSACTION_STATUS.PENDING,
|
|
136
142
|
TRANSACTION_STATUS.MATCHED,
|
|
137
143
|
TRANSACTION_STATUS.JOURNALIZED,
|
|
138
|
-
TRANSACTION_STATUS.REJECTED
|
|
144
|
+
TRANSACTION_STATUS.REJECTED,
|
|
145
|
+
TRANSACTION_STATUS.SETTLED
|
|
139
146
|
])
|
|
140
147
|
};
|
|
141
148
|
/**
|
|
@@ -22,6 +22,8 @@ declare const TRANSACTION_STATUS: {
|
|
|
22
22
|
readonly MATCHED: "matched";
|
|
23
23
|
readonly JOURNALIZED: "journalized";
|
|
24
24
|
readonly REJECTED: "rejected";
|
|
25
|
+
readonly RECONCILED_EXTERNAL: "reconciled_external";
|
|
26
|
+
readonly SETTLED: "settled";
|
|
25
27
|
};
|
|
26
28
|
type TransactionStatus = typeof TRANSACTION_STATUS;
|
|
27
29
|
type TransactionStatusValue = TransactionStatus[keyof TransactionStatus];
|
|
@@ -69,6 +71,8 @@ declare const BANK_FEED_STATUS: {
|
|
|
69
71
|
readonly MATCHED: "matched";
|
|
70
72
|
readonly JOURNALIZED: "journalized";
|
|
71
73
|
readonly REJECTED: "rejected";
|
|
74
|
+
readonly RECONCILED_EXTERNAL: "reconciled_external";
|
|
75
|
+
readonly SETTLED: "settled";
|
|
72
76
|
};
|
|
73
77
|
type BankFeedStatusValue = (typeof BANK_FEED_STATUS)[keyof typeof BANK_FEED_STATUS];
|
|
74
78
|
declare const BANK_FEED_STATUS_VALUES: BankFeedStatusValue[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { U as HoldStatusValue, b as SplitStatusValue, c as SubscriptionStatusValue, j as SettlementStatusValue } from "../subscription.enums-k24kLpF7.mjs";
|
|
2
|
-
import { O as TransactionStatusValue, u as TransactionKindValue } from "../bank-feed.enums-
|
|
2
|
+
import { O as TransactionStatusValue, u as TransactionKindValue } from "../bank-feed.enums-CqTW2Blz.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/core/state-machines.d.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND } from "../bank-feed.enums-
|
|
1
|
+
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND } from "../bank-feed.enums-ByS3mjX0.mjs";
|
|
2
2
|
import { g as SETTLEMENT_STATUS, l as SPLIT_STATUS, r as SUBSCRIPTION_STATUS, w as HOLD_STATUS } from "../subscription.enums-95othr0i.mjs";
|
|
3
3
|
import { a as InvalidStateTransitionError } from "../errors-Bt5NRVMq.mjs";
|
|
4
4
|
import { defineStateMachine } from "@classytic/primitives/state-machine";
|
|
@@ -151,14 +151,25 @@ const SPLIT_STATE_MACHINE = new StateMachine(new Map([
|
|
|
151
151
|
]), "split");
|
|
152
152
|
const PAYMENT_FLOW_STATE_MACHINE = TRANSACTION_STATE_MACHINE;
|
|
153
153
|
const BANK_FEED_STATE_MACHINE = new StateMachine(new Map([
|
|
154
|
-
[TRANSACTION_STATUS.IMPORTED, new Set([
|
|
154
|
+
[TRANSACTION_STATUS.IMPORTED, new Set([
|
|
155
|
+
TRANSACTION_STATUS.MATCHED,
|
|
156
|
+
TRANSACTION_STATUS.REJECTED,
|
|
157
|
+
TRANSACTION_STATUS.SETTLED
|
|
158
|
+
])],
|
|
155
159
|
[TRANSACTION_STATUS.MATCHED, new Set([TRANSACTION_STATUS.IMPORTED, TRANSACTION_STATUS.JOURNALIZED])],
|
|
160
|
+
[TRANSACTION_STATUS.SETTLED, new Set([TRANSACTION_STATUS.IMPORTED])],
|
|
156
161
|
[TRANSACTION_STATUS.JOURNALIZED, /* @__PURE__ */ new Set([])],
|
|
157
|
-
[TRANSACTION_STATUS.REJECTED, /* @__PURE__ */ new Set([])]
|
|
162
|
+
[TRANSACTION_STATUS.REJECTED, /* @__PURE__ */ new Set([])],
|
|
163
|
+
[TRANSACTION_STATUS.RECONCILED_EXTERNAL, /* @__PURE__ */ new Set([])]
|
|
158
164
|
]), "transaction.bank_feed");
|
|
159
165
|
const MANUAL_STATE_MACHINE = new StateMachine(new Map([
|
|
160
|
-
[TRANSACTION_STATUS.PENDING, new Set([
|
|
166
|
+
[TRANSACTION_STATUS.PENDING, new Set([
|
|
167
|
+
TRANSACTION_STATUS.MATCHED,
|
|
168
|
+
TRANSACTION_STATUS.REJECTED,
|
|
169
|
+
TRANSACTION_STATUS.SETTLED
|
|
170
|
+
])],
|
|
161
171
|
[TRANSACTION_STATUS.MATCHED, new Set([TRANSACTION_STATUS.JOURNALIZED])],
|
|
172
|
+
[TRANSACTION_STATUS.SETTLED, new Set([TRANSACTION_STATUS.PENDING])],
|
|
162
173
|
[TRANSACTION_STATUS.JOURNALIZED, /* @__PURE__ */ new Set([])],
|
|
163
174
|
[TRANSACTION_STATUS.REJECTED, /* @__PURE__ */ new Set([])]
|
|
164
175
|
]), "transaction.manual");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as RevenueContext } from "./context-pjP1QeE3.mjs";
|
|
2
2
|
import { t as RevenueBridges } from "./revenue-bridges-BtkWFsJu.mjs";
|
|
3
|
-
import { u as TransactionKindValue } from "./bank-feed.enums-
|
|
4
|
-
import { a as BankFeedProviderRegistry, d as PaymentProvider, o as FetchTransactionsParams, r as BankFeedProvider, t as ProviderRegistry } from "./registry-
|
|
3
|
+
import { O as TransactionStatusValue, u as TransactionKindValue } from "./bank-feed.enums-CqTW2Blz.mjs";
|
|
4
|
+
import { a as BankFeedProviderRegistry, d as PaymentProvider, o as FetchTransactionsParams, r as BankFeedProvider, t as ProviderRegistry } from "./registry-DSG7x-Cl.mjs";
|
|
5
5
|
import { RepositoryPluginBundle, RevenueRepositories } from "./repositories/create-repositories.mjs";
|
|
6
6
|
import { PluginType, Repository } from "@classytic/mongokit";
|
|
7
7
|
import { TenantConfig } from "@classytic/repo-core/tenant";
|
|
@@ -583,6 +583,15 @@ declare class TransactionRepository extends RevenueRepositoryBase<TransactionDoc
|
|
|
583
583
|
source: string;
|
|
584
584
|
methodKind: PaymentMethodKind;
|
|
585
585
|
method?: string;
|
|
586
|
+
/**
|
|
587
|
+
* Override the born status of newly-inserted rows. Defaults to
|
|
588
|
+
* `initialStatusFor(bank_feed)` = `imported` (matchable). Pass
|
|
589
|
+
* `reconciled_external` for vendor-reconciled rows (Xero Payments /
|
|
590
|
+
* transfer legs) so they are BORN terminal + non-matchable and can
|
|
591
|
+
* never post a journal entry. Applies to `$setOnInsert` only — re-imports
|
|
592
|
+
* never overwrite an existing row's status.
|
|
593
|
+
*/
|
|
594
|
+
initialStatus?: TransactionStatusValue;
|
|
586
595
|
}, ctx?: RevenueContext): Promise<BankImportReport>;
|
|
587
596
|
/**
|
|
588
597
|
* Drain a bank-feed provider into the collection.
|
|
@@ -715,6 +724,38 @@ declare class TransactionRepository extends RevenueRepositoryBase<TransactionDoc
|
|
|
715
724
|
unmatch(id: string, options?: {
|
|
716
725
|
unmatchedBy?: string;
|
|
717
726
|
}, ctx?: RevenueContext): Promise<TransactionDocument>;
|
|
727
|
+
/**
|
|
728
|
+
* Reconcile a bank-feed / manual row that settled a linked document
|
|
729
|
+
* (invoice/bill) WITHOUT posting a journal entry. The document's payment
|
|
730
|
+
* already owns the cash JE (`Dr Bank / Cr AR`), so the bank line only needs
|
|
731
|
+
* its status moved to `settled` — calling `match()` here would fire
|
|
732
|
+
* `LedgerBridge.onTransactionMatched` and double-count the cash. This is the
|
|
733
|
+
* package's intended path when the JE lives elsewhere (the reachable sibling
|
|
734
|
+
* of the born-`reconciled_external` import).
|
|
735
|
+
*
|
|
736
|
+
* `imported → settled` (bank_feed) / `pending → settled` (manual). Idempotent:
|
|
737
|
+
* a row already `settled` is returned unchanged, so a best-effort caller can
|
|
738
|
+
* safely re-run. The optional `metadata` is shallow-merged onto the document's
|
|
739
|
+
* `metadata` (dotted `$set`, so sibling keys survive) — hosts stamp the link
|
|
740
|
+
* back to the settling document there. No JE bridge call, no domain event:
|
|
741
|
+
* settlement is host-initiated and the host owns the reconcile audit trail.
|
|
742
|
+
*/
|
|
743
|
+
settle(id: string, data?: {
|
|
744
|
+
settledBy?: string;
|
|
745
|
+
metadata?: Record<string, unknown>;
|
|
746
|
+
}, ctx?: RevenueContext): Promise<TransactionDocument>;
|
|
747
|
+
/**
|
|
748
|
+
* Reverse a `settle()` — the linked document's payment was undone, so the
|
|
749
|
+
* bank line returns to its birth status to re-enter the reconcile queue.
|
|
750
|
+
* `settled → imported` (bank_feed) / `settled → pending` (manual). Clears
|
|
751
|
+
* `verifiedAt`/`verifiedBy` plus any metadata keys named in `clearMetadata`
|
|
752
|
+
* (the host-stamped link back to the now-reversed document). Idempotent: a
|
|
753
|
+
* row not currently `settled` is returned unchanged.
|
|
754
|
+
*/
|
|
755
|
+
unsettle(id: string, data?: {
|
|
756
|
+
unsettledBy?: string;
|
|
757
|
+
clearMetadata?: string[];
|
|
758
|
+
}, ctx?: RevenueContext): Promise<TransactionDocument>;
|
|
718
759
|
/**
|
|
719
760
|
* Stamp the journal entry reference and transition `matched →
|
|
720
761
|
* journalized`. Typical caller is the `LedgerBridge.onTransactionMatched`
|
package/dist/enums/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { A as SettlementStatus, B as HoldReason, C as isPayoutMethod, D as SETTLEMENT_STATUS_VALUES, E as SETTLEMENT_STATUS, F as isSettlementType, G as RELEASE_REASON_VALUES, H as HoldStatus, I as HOLD_REASON, J as isHoldReason, K as ReleaseReason, L as HOLD_REASON_VALUES, M as SettlementType, N as SettlementTypeValue, O as SETTLEMENT_TYPE, P as isSettlementStatus, R as HOLD_STATUS, S as SplitTypeValue, T as isSplitType, U as HoldStatusValue, V as HoldReasonValue, W as RELEASE_REASON, X as isReleaseReason, Y as isHoldStatus, _ as SPLIT_TYPE, a as SUBSCRIPTION_STATUS, b as SplitStatusValue, c as SubscriptionStatusValue, d as PAYOUT_METHOD, f as PAYOUT_METHOD_VALUES, g as SPLIT_STATUS_VALUES, h as SPLIT_STATUS, i as PlanKeys, j as SettlementStatusValue, k as SETTLEMENT_TYPE_VALUES, l as isPlanKey, m as PayoutMethodValue, n as PLAN_KEY_VALUES, o as SUBSCRIPTION_STATUS_VALUES, p as PayoutMethod, q as ReleaseReasonValue, r as PlanKeyValue, s as SubscriptionStatus, t as PLAN_KEYS, u as isSubscriptionStatus, v as SPLIT_TYPE_VALUES, w as isSplitStatus, x as SplitType, y as SplitStatus, z as HOLD_STATUS_VALUES } from "../subscription.enums-k24kLpF7.mjs";
|
|
2
|
-
import { A as isTransactionFlow, C as TRANSACTION_STATUS, D as TransactionStatus, E as TransactionFlowValue, O as TransactionStatusValue, S as TRANSACTION_FLOW_VALUES, T as TransactionFlow, _ as LIBRARY_CATEGORIES, a as BankFeedSourceValue, b as LibraryCategoryValue, c as TRANSACTION_KIND_VALUES, d as initialStatusFor, f as isBankFeedSource, g as statusesForKind, h as isTransactionKind, i as BANK_FEED_STATUS_VALUES, j as isTransactionStatus, k as isLibraryCategory, l as TransactionKind, m as isStatusValidForKind, n as BANK_FEED_SOURCE_VALUES, o as BankFeedStatusValue, p as isBankFeedStatus, r as BANK_FEED_STATUS, s as TRANSACTION_KIND, t as BANK_FEED_SOURCE, u as TransactionKindValue, v as LIBRARY_CATEGORY_VALUES, w as TRANSACTION_STATUS_VALUES, x as TRANSACTION_FLOW, y as LibraryCategories } from "../bank-feed.enums-
|
|
2
|
+
import { A as isTransactionFlow, C as TRANSACTION_STATUS, D as TransactionStatus, E as TransactionFlowValue, O as TransactionStatusValue, S as TRANSACTION_FLOW_VALUES, T as TransactionFlow, _ as LIBRARY_CATEGORIES, a as BankFeedSourceValue, b as LibraryCategoryValue, c as TRANSACTION_KIND_VALUES, d as initialStatusFor, f as isBankFeedSource, g as statusesForKind, h as isTransactionKind, i as BANK_FEED_STATUS_VALUES, j as isTransactionStatus, k as isLibraryCategory, l as TransactionKind, m as isStatusValidForKind, n as BANK_FEED_SOURCE_VALUES, o as BankFeedStatusValue, p as isBankFeedStatus, r as BANK_FEED_STATUS, s as TRANSACTION_KIND, t as BANK_FEED_SOURCE, u as TransactionKindValue, v as LIBRARY_CATEGORY_VALUES, w as TRANSACTION_STATUS_VALUES, x as TRANSACTION_FLOW, y as LibraryCategories } from "../bank-feed.enums-CqTW2Blz.mjs";
|
|
3
3
|
import { a as isMonetizationType, c as PAYMENT_STATUS, d as PaymentGatewayTypeValue, f as PaymentStatus, h as isPaymentStatus, i as MonetizationTypes, l as PAYMENT_STATUS_VALUES, m as isPaymentGatewayType, n as MONETIZATION_TYPE_VALUES, o as PAYMENT_GATEWAY_TYPE, p as PaymentStatusValue, r as MonetizationTypeValue, s as PAYMENT_GATEWAY_TYPE_VALUES, t as MONETIZATION_TYPES, u as PaymentGatewayType } from "../monetization.enums-DzAI4sT7.mjs";
|
|
4
4
|
export { BANK_FEED_SOURCE, BANK_FEED_SOURCE_VALUES, BANK_FEED_STATUS, BANK_FEED_STATUS_VALUES, BankFeedSourceValue, BankFeedStatusValue, HOLD_REASON, HOLD_REASON_VALUES, HOLD_STATUS, HOLD_STATUS_VALUES, HoldReason, HoldReasonValue, HoldStatus, HoldStatusValue, LIBRARY_CATEGORIES, LIBRARY_CATEGORY_VALUES, LibraryCategories, LibraryCategoryValue, MONETIZATION_TYPES, MONETIZATION_TYPE_VALUES, MonetizationTypeValue, MonetizationTypes, PAYMENT_GATEWAY_TYPE, PAYMENT_GATEWAY_TYPE_VALUES, PAYMENT_STATUS, PAYMENT_STATUS_VALUES, PAYOUT_METHOD, PAYOUT_METHOD_VALUES, PLAN_KEYS, PLAN_KEY_VALUES, PaymentGatewayType, PaymentGatewayTypeValue, PaymentStatus, PaymentStatusValue, PayoutMethod, PayoutMethodValue, PlanKeyValue, PlanKeys, RELEASE_REASON, RELEASE_REASON_VALUES, ReleaseReason, ReleaseReasonValue, SETTLEMENT_STATUS, SETTLEMENT_STATUS_VALUES, SETTLEMENT_TYPE, SETTLEMENT_TYPE_VALUES, SPLIT_STATUS, SPLIT_STATUS_VALUES, SPLIT_TYPE, SPLIT_TYPE_VALUES, SUBSCRIPTION_STATUS, SUBSCRIPTION_STATUS_VALUES, SettlementStatus, SettlementStatusValue, SettlementType, SettlementTypeValue, SplitStatus, SplitStatusValue, SplitType, SplitTypeValue, SubscriptionStatus, SubscriptionStatusValue, TRANSACTION_FLOW, TRANSACTION_FLOW_VALUES, TRANSACTION_KIND, TRANSACTION_KIND_VALUES, TRANSACTION_STATUS, TRANSACTION_STATUS_VALUES, TransactionFlow, TransactionFlowValue, TransactionKind, TransactionKindValue, TransactionStatus, TransactionStatusValue, initialStatusFor, isBankFeedSource, isBankFeedStatus, isHoldReason, isHoldStatus, isLibraryCategory, isMonetizationType, isPaymentGatewayType, isPaymentStatus, isPayoutMethod, isPlanKey, isReleaseReason, isSettlementStatus, isSettlementType, isSplitStatus, isSplitType, isStatusValidForKind, isSubscriptionStatus, isTransactionFlow, isTransactionKind, isTransactionStatus, statusesForKind };
|
package/dist/enums/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, b as isTransactionFlow, c as isBankFeedSource, d as isTransactionKind, f as statusesForKind, g as TRANSACTION_FLOW_VALUES, h as TRANSACTION_FLOW, i as BANK_FEED_STATUS_VALUES, l as isBankFeedStatus, m as LIBRARY_CATEGORY_VALUES, n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES, p as LIBRARY_CATEGORIES, r as BANK_FEED_STATUS, s as initialStatusFor, t as BANK_FEED_SOURCE, u as isStatusValidForKind, v as TRANSACTION_STATUS_VALUES, x as isTransactionStatus, y as isLibraryCategory } from "../bank-feed.enums-
|
|
1
|
+
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, b as isTransactionFlow, c as isBankFeedSource, d as isTransactionKind, f as statusesForKind, g as TRANSACTION_FLOW_VALUES, h as TRANSACTION_FLOW, i as BANK_FEED_STATUS_VALUES, l as isBankFeedStatus, m as LIBRARY_CATEGORY_VALUES, n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES, p as LIBRARY_CATEGORIES, r as BANK_FEED_STATUS, s as initialStatusFor, t as BANK_FEED_SOURCE, u as isStatusValidForKind, v as TRANSACTION_STATUS_VALUES, x as isTransactionStatus, y as isLibraryCategory } from "../bank-feed.enums-ByS3mjX0.mjs";
|
|
2
2
|
import { A as isReleaseReason, C as HOLD_REASON_VALUES, D as RELEASE_REASON_VALUES, E as RELEASE_REASON, O as isHoldReason, S as HOLD_REASON, T as HOLD_STATUS_VALUES, _ as SETTLEMENT_STATUS_VALUES, a as isPlanKey, b as isSettlementStatus, c as PAYOUT_METHOD_VALUES, d as SPLIT_TYPE, f as SPLIT_TYPE_VALUES, g as SETTLEMENT_STATUS, h as isSplitType, i as SUBSCRIPTION_STATUS_VALUES, k as isHoldStatus, l as SPLIT_STATUS, m as isSplitStatus, n as PLAN_KEY_VALUES, o as isSubscriptionStatus, p as isPayoutMethod, r as SUBSCRIPTION_STATUS, s as PAYOUT_METHOD, t as PLAN_KEYS, u as SPLIT_STATUS_VALUES, v as SETTLEMENT_TYPE, w as HOLD_STATUS, x as isSettlementType, y as SETTLEMENT_TYPE_VALUES } from "../subscription.enums-95othr0i.mjs";
|
|
3
3
|
import { a as PAYMENT_GATEWAY_TYPE_VALUES, c as isPaymentGatewayType, i as PAYMENT_GATEWAY_TYPE, l as isPaymentStatus, n as MONETIZATION_TYPE_VALUES, o as PAYMENT_STATUS, r as isMonetizationType, s as PAYMENT_STATUS_VALUES, t as MONETIZATION_TYPES } from "../monetization.enums-B9HBOecd.mjs";
|
|
4
4
|
|
|
@@ -496,7 +496,6 @@ declare const settlementCreateSchema: z.ZodObject<{
|
|
|
496
496
|
affiliate: "affiliate";
|
|
497
497
|
partner: "partner";
|
|
498
498
|
}>;
|
|
499
|
-
notes: z.ZodOptional<z.ZodString>;
|
|
500
499
|
payoutMethod: z.ZodEnum<{
|
|
501
500
|
manual: "manual";
|
|
502
501
|
bank_transfer: "bank_transfer";
|
|
@@ -531,6 +530,7 @@ declare const settlementCreateSchema: z.ZodObject<{
|
|
|
531
530
|
transferredAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
532
531
|
}, z.core.$strip>>;
|
|
533
532
|
scheduledAt: z.ZodDefault<z.ZodCoercedDate<unknown>>;
|
|
533
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
534
534
|
}, z.core.$strip>;
|
|
535
535
|
declare const settlementUpdateSchema: z.ZodObject<{
|
|
536
536
|
publicId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as RevenueContext } from "./context-pjP1QeE3.mjs";
|
|
2
2
|
import { a as CurrencyBridge, c as LedgerBridge, i as CustomerBridge, o as NotificationBridge, r as AnalyticsBridge, s as TaxBridge, t as RevenueBridges } from "./revenue-bridges-BtkWFsJu.mjs";
|
|
3
3
|
import { A as SettlementStatus, B as HoldReason, C as isPayoutMethod, D as SETTLEMENT_STATUS_VALUES, E as SETTLEMENT_STATUS, F as isSettlementType, G as RELEASE_REASON_VALUES, H as HoldStatus, I as HOLD_REASON, J as isHoldReason, K as ReleaseReason, L as HOLD_REASON_VALUES, M as SettlementType, N as SettlementTypeValue, O as SETTLEMENT_TYPE, P as isSettlementStatus, R as HOLD_STATUS, S as SplitTypeValue, T as isSplitType, U as HoldStatusValue, V as HoldReasonValue, W as RELEASE_REASON, X as isReleaseReason, Y as isHoldStatus, _ as SPLIT_TYPE, a as SUBSCRIPTION_STATUS, b as SplitStatusValue, c as SubscriptionStatusValue, d as PAYOUT_METHOD, f as PAYOUT_METHOD_VALUES, g as SPLIT_STATUS_VALUES, h as SPLIT_STATUS, i as PlanKeys, j as SettlementStatusValue, k as SETTLEMENT_TYPE_VALUES, l as isPlanKey, m as PayoutMethodValue, n as PLAN_KEY_VALUES, o as SUBSCRIPTION_STATUS_VALUES, p as PayoutMethod, q as ReleaseReasonValue, r as PlanKeyValue, s as SubscriptionStatus, t as PLAN_KEYS, u as isSubscriptionStatus, v as SPLIT_TYPE_VALUES, w as isSplitStatus, x as SplitType, y as SplitStatus, z as HOLD_STATUS_VALUES } from "./subscription.enums-k24kLpF7.mjs";
|
|
4
|
-
import { A as isTransactionFlow, C as TRANSACTION_STATUS, D as TransactionStatus, E as TransactionFlowValue, O as TransactionStatusValue, S as TRANSACTION_FLOW_VALUES, T as TransactionFlow, _ as LIBRARY_CATEGORIES, a as BankFeedSourceValue, b as LibraryCategoryValue, c as TRANSACTION_KIND_VALUES, d as initialStatusFor, f as isBankFeedSource, g as statusesForKind, h as isTransactionKind, i as BANK_FEED_STATUS_VALUES, j as isTransactionStatus, k as isLibraryCategory, l as TransactionKind, m as isStatusValidForKind, n as BANK_FEED_SOURCE_VALUES, o as BankFeedStatusValue, p as isBankFeedStatus, r as BANK_FEED_STATUS, s as TRANSACTION_KIND, t as BANK_FEED_SOURCE, u as TransactionKindValue, v as LIBRARY_CATEGORY_VALUES, w as TRANSACTION_STATUS_VALUES, x as TRANSACTION_FLOW, y as LibraryCategories } from "./bank-feed.enums-
|
|
4
|
+
import { A as isTransactionFlow, C as TRANSACTION_STATUS, D as TransactionStatus, E as TransactionFlowValue, O as TransactionStatusValue, S as TRANSACTION_FLOW_VALUES, T as TransactionFlow, _ as LIBRARY_CATEGORIES, a as BankFeedSourceValue, b as LibraryCategoryValue, c as TRANSACTION_KIND_VALUES, d as initialStatusFor, f as isBankFeedSource, g as statusesForKind, h as isTransactionKind, i as BANK_FEED_STATUS_VALUES, j as isTransactionStatus, k as isLibraryCategory, l as TransactionKind, m as isStatusValidForKind, n as BANK_FEED_SOURCE_VALUES, o as BankFeedStatusValue, p as isBankFeedStatus, r as BANK_FEED_STATUS, s as TRANSACTION_KIND, t as BANK_FEED_SOURCE, u as TransactionKindValue, v as LIBRARY_CATEGORY_VALUES, w as TRANSACTION_STATUS_VALUES, x as TRANSACTION_FLOW, y as LibraryCategories } from "./bank-feed.enums-CqTW2Blz.mjs";
|
|
5
5
|
import { BANK_FEED_STATE_MACHINE, HOLD_STATE_MACHINE, MANUAL_STATE_MACHINE, PAYMENT_FLOW_STATE_MACHINE, SETTLEMENT_STATE_MACHINE, SPLIT_STATE_MACHINE, SUBSCRIPTION_STATE_MACHINE, StateChangeEvent, StateMachine, TRANSACTION_STATE_MACHINE, smFor } from "./core/state-machines.mjs";
|
|
6
6
|
import { a as isMonetizationType, c as PAYMENT_STATUS, d as PaymentGatewayTypeValue, f as PaymentStatus, h as isPaymentStatus, i as MonetizationTypes, l as PAYMENT_STATUS_VALUES, m as isPaymentGatewayType, n as MONETIZATION_TYPE_VALUES, o as PAYMENT_GATEWAY_TYPE, p as PaymentStatusValue, r as MonetizationTypeValue, s as PAYMENT_GATEWAY_TYPE_VALUES, t as MONETIZATION_TYPES, u as PaymentGatewayType } from "./monetization.enums-DzAI4sT7.mjs";
|
|
7
7
|
import { D as RevenueEventSchema, E as RevenueEventPayloadOf, T as RevenueEventDefinition, _t as InProcessRevenueBusOptions, ft as revenueEventDefinitions, gt as InProcessRevenueBus, ht as createEvent, mt as RevenueEventName, pt as REVENUE_EVENTS } from "./revenue-event-catalog-BU_KYN2-.mjs";
|
|
8
|
-
import { a as BankFeedProviderRegistry, c as ParseUploadParams, d as PaymentProvider, i as BankFeedProviderCapabilities, l as ParseUploadResult, n as createProviderRegistry, o as FetchTransactionsParams, r as BankFeedProvider, s as FetchTransactionsResult, t as ProviderRegistry, u as createBankFeedProviderRegistry } from "./registry-
|
|
9
|
-
import { a as RevenueConfig, c as SubscriptionRepository, d as RevenueSchemaOptions, f as SettlementDocument, i as RetryConfig, l as TransactionRepository, m as TransactionDocument, n as BankFeedModuleConfig, o as RevenueEngine, p as SubscriptionDocument, r as CommissionConfig, s as SettlementRepository, t as BankFeedIndexConfig, u as RevenueModels } from "./engine-types-
|
|
8
|
+
import { a as BankFeedProviderRegistry, c as ParseUploadParams, d as PaymentProvider, i as BankFeedProviderCapabilities, l as ParseUploadResult, n as createProviderRegistry, o as FetchTransactionsParams, r as BankFeedProvider, s as FetchTransactionsResult, t as ProviderRegistry, u as createBankFeedProviderRegistry } from "./registry-DSG7x-Cl.mjs";
|
|
9
|
+
import { a as RevenueConfig, c as SubscriptionRepository, d as RevenueSchemaOptions, f as SettlementDocument, i as RetryConfig, l as TransactionRepository, m as TransactionDocument, n as BankFeedModuleConfig, o as RevenueEngine, p as SubscriptionDocument, r as CommissionConfig, s as SettlementRepository, t as BankFeedIndexConfig, u as RevenueModels } from "./engine-types-BU8kkttr.mjs";
|
|
10
10
|
import { RepositoryPluginBundle, RevenueRepositories } from "./repositories/create-repositories.mjs";
|
|
11
|
-
import { A as transactionBaseSchema, C as subscriptionBaseSchema, D as TransactionCreateInput, E as subscriptionUpdateSchema, M as transactionListFilterSchema, N as transactionUpdateSchema, O as TransactionListFilter, S as SubscriptionUpdateInput, T as subscriptionListFilterSchema, _ as settlementCreateSchema, a as escrowReleaseSchema, b as SubscriptionCreateInput, c as PaymentVerifyInput, d as paymentVerifySchema, f as refundSchema, g as settlementBaseSchema, h as SettlementUpdateInput, i as escrowHoldSchema, j as transactionCreateSchema, k as TransactionUpdateInput, l as RefundInput, m as SettlementListFilter, n as EscrowReleaseInput, o as splitRuleSchema, p as SettlementCreateInput, r as SplitRuleInput, s as PaymentIntentInput, t as EscrowHoldInput, u as paymentIntentSchema, v as settlementListFilterSchema, w as subscriptionCreateSchema, x as SubscriptionListFilter, y as settlementUpdateSchema } from "./escrow.schema-
|
|
11
|
+
import { A as transactionBaseSchema, C as subscriptionBaseSchema, D as TransactionCreateInput, E as subscriptionUpdateSchema, M as transactionListFilterSchema, N as transactionUpdateSchema, O as TransactionListFilter, S as SubscriptionUpdateInput, T as subscriptionListFilterSchema, _ as settlementCreateSchema, a as escrowReleaseSchema, b as SubscriptionCreateInput, c as PaymentVerifyInput, d as paymentVerifySchema, f as refundSchema, g as settlementBaseSchema, h as SettlementUpdateInput, i as escrowHoldSchema, j as transactionCreateSchema, k as TransactionUpdateInput, l as RefundInput, m as SettlementListFilter, n as EscrowReleaseInput, o as splitRuleSchema, p as SettlementCreateInput, r as SplitRuleInput, s as PaymentIntentInput, t as EscrowHoldInput, u as paymentIntentSchema, v as settlementListFilterSchema, w as subscriptionCreateSchema, x as SubscriptionListFilter, y as settlementUpdateSchema } from "./escrow.schema-Cklvlywy.mjs";
|
|
12
12
|
import { A as SplitInfo, B as validateTaxCalculation, C as multiplyMoney, D as toCurrencyCode, E as sumMoney, F as TaxConfig, H as calculateCommission, I as TaxType, L as calculateTax, M as calculateOrganizationPayout, N as calculateSplits, O as toMajor, P as TaxCalculation, R as getTaxType, S as money, T as subtractMoney, U as reverseCommission, V as CommissionInfo, _ as isMoney, a as CurrencyCode, b as isZeroMoney, c as Money, d as addMoney, f as compareMoney, g as isCurrencyCode, h as fromSmallestUnit, i as CURRENCIES, j as SplitRule, k as toSmallestUnit, l as MoneyValue, m as fromMajor, n as getAuditTrail, o as CurrencyMismatchError, p as equalsMoney, r as getLastStateChange, s as MINOR_UNIT_FACTOR, t as appendAuditEvent, u as absMoney, v as isNegativeMoney, w as negateMoney, x as minorUnitFactor, y as isPositiveMoney, z as reverseTax } from "./audit-DRKuLBFO.mjs";
|
|
13
13
|
import { HookHandler, PluginContext, PluginManager, RevenuePluginDefinition } from "./plugins/plugin.interface.mjs";
|
|
14
14
|
import { DomainEvent, DomainEvent as DomainEvent$1, EventHandler, EventTransport } from "@classytic/primitives/events";
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, b as isTransactionFlow, c as isBankFeedSource, d as isTransactionKind, f as statusesForKind, g as TRANSACTION_FLOW_VALUES, h as TRANSACTION_FLOW, i as BANK_FEED_STATUS_VALUES, l as isBankFeedStatus, m as LIBRARY_CATEGORY_VALUES, n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES, p as LIBRARY_CATEGORIES, r as BANK_FEED_STATUS, s as initialStatusFor, t as BANK_FEED_SOURCE, u as isStatusValidForKind, v as TRANSACTION_STATUS_VALUES, x as isTransactionStatus, y as isLibraryCategory } from "./bank-feed.enums-
|
|
2
|
-
import { n as SubscriptionRepository, r as TransactionRepository, t as SettlementRepository } from "./settlement.repository-
|
|
1
|
+
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, b as isTransactionFlow, c as isBankFeedSource, d as isTransactionKind, f as statusesForKind, g as TRANSACTION_FLOW_VALUES, h as TRANSACTION_FLOW, i as BANK_FEED_STATUS_VALUES, l as isBankFeedStatus, m as LIBRARY_CATEGORY_VALUES, n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES, p as LIBRARY_CATEGORIES, r as BANK_FEED_STATUS, s as initialStatusFor, t as BANK_FEED_SOURCE, u as isStatusValidForKind, v as TRANSACTION_STATUS_VALUES, x as isTransactionStatus, y as isLibraryCategory } from "./bank-feed.enums-ByS3mjX0.mjs";
|
|
2
|
+
import { n as SubscriptionRepository, r as TransactionRepository, t as SettlementRepository } from "./settlement.repository-DtLSBDIk.mjs";
|
|
3
3
|
import { n as createEvent, t as REVENUE_EVENTS } from "./event-constants-DM_-A57b.mjs";
|
|
4
4
|
import { A as isReleaseReason, C as HOLD_REASON_VALUES, D as RELEASE_REASON_VALUES, E as RELEASE_REASON, O as isHoldReason, S as HOLD_REASON, T as HOLD_STATUS_VALUES, _ as SETTLEMENT_STATUS_VALUES, a as isPlanKey, b as isSettlementStatus, c as PAYOUT_METHOD_VALUES, d as SPLIT_TYPE, f as SPLIT_TYPE_VALUES, g as SETTLEMENT_STATUS, h as isSplitType, i as SUBSCRIPTION_STATUS_VALUES, k as isHoldStatus, l as SPLIT_STATUS, m as isSplitStatus, n as PLAN_KEY_VALUES, o as isSubscriptionStatus, p as isPayoutMethod, r as SUBSCRIPTION_STATUS, s as PAYOUT_METHOD, t as PLAN_KEYS, u as SPLIT_STATUS_VALUES, v as SETTLEMENT_TYPE, w as HOLD_STATUS, x as isSettlementType, y as SETTLEMENT_TYPE_VALUES } from "./subscription.enums-95othr0i.mjs";
|
|
5
5
|
import { _ as WrongTransactionKindError, a as InvalidStateTransitionError, c as PaymentVerificationError, d as RefundNotSupportedError, f as RevenueError, g as ValidationError, h as TransactionNotFoundError, i as ConfigurationError, l as ProviderCapabilityError, m as SubscriptionNotFoundError, n as BankFeedImportError, o as MethodKindLockedError, p as SettlementNotFoundError, r as BankFeedProviderNotFoundError, s as PaymentIntentCreationError, t as AlreadyVerifiedError, u as ProviderNotFoundError } from "./errors-Bt5NRVMq.mjs";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as BankFeedProviderRegistry, c as ParseUploadParams, d as PaymentProvider, i as BankFeedProviderCapabilities, l as ParseUploadResult, n as createProviderRegistry, o as FetchTransactionsParams, r as BankFeedProvider, s as FetchTransactionsResult, t as ProviderRegistry, u as createBankFeedProviderRegistry } from "../registry-
|
|
1
|
+
import { a as BankFeedProviderRegistry, c as ParseUploadParams, d as PaymentProvider, i as BankFeedProviderCapabilities, l as ParseUploadResult, n as createProviderRegistry, o as FetchTransactionsParams, r as BankFeedProvider, s as FetchTransactionsResult, t as ProviderRegistry, u as createBankFeedProviderRegistry } from "../registry-DSG7x-Cl.mjs";
|
|
2
2
|
export { BankFeedProvider, type BankFeedProviderCapabilities, BankFeedProviderRegistry, type FetchTransactionsParams, type FetchTransactionsResult, type ParseUploadParams, type ParseUploadResult, PaymentProvider, ProviderRegistry, createBankFeedProviderRegistry, createProviderRegistry };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BankFeedSourceValue } from "./bank-feed.enums-
|
|
1
|
+
import { a as BankFeedSourceValue } from "./bank-feed.enums-CqTW2Blz.mjs";
|
|
2
2
|
import { CreateIntentParams, PaymentIntent, PaymentResult, ProviderCapabilities, RefundResult, WebhookEvent } from "@classytic/primitives/payment-gateway";
|
|
3
3
|
import { BankStatement, BankTransaction } from "@classytic/primitives/bank-transaction";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as SubscriptionRepository, l as TransactionRepository, s as SettlementRepository, u as RevenueModels } from "../engine-types-
|
|
1
|
+
import { c as SubscriptionRepository, l as TransactionRepository, s as SettlementRepository, u as RevenueModels } from "../engine-types-BU8kkttr.mjs";
|
|
2
2
|
import { PluginType } from "@classytic/mongokit";
|
|
3
3
|
|
|
4
4
|
//#region src/repositories/create-repositories.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as SubscriptionRepository, r as TransactionRepository, t as SettlementRepository } from "../settlement.repository-
|
|
1
|
+
import { n as SubscriptionRepository, r as TransactionRepository, t as SettlementRepository } from "../settlement.repository-DtLSBDIk.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/repositories/create-repositories.ts
|
|
4
4
|
function createRevenueRepositories(models, builtInPlugins, hostPlugins = {}) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, s as initialStatusFor } from "./bank-feed.enums-
|
|
1
|
+
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, s as initialStatusFor } from "./bank-feed.enums-ByS3mjX0.mjs";
|
|
2
2
|
import { n as createEvent, t as REVENUE_EVENTS } from "./event-constants-DM_-A57b.mjs";
|
|
3
3
|
import { g as SETTLEMENT_STATUS, r as SUBSCRIPTION_STATUS, w as HOLD_STATUS } from "./subscription.enums-95othr0i.mjs";
|
|
4
4
|
import { _ as WrongTransactionKindError, g as ValidationError, h as TransactionNotFoundError, m as SubscriptionNotFoundError, n as BankFeedImportError, o as MethodKindLockedError, p as SettlementNotFoundError } from "./errors-Bt5NRVMq.mjs";
|
|
@@ -664,7 +664,7 @@ var TransactionRepository = class extends RevenueRepositoryBase {
|
|
|
664
664
|
if (row.balanceAfter !== void 0) set.balanceAfter = row.balanceAfter.amount;
|
|
665
665
|
const setOnInsert = {
|
|
666
666
|
kind: TRANSACTION_KIND.BANK_FEED,
|
|
667
|
-
status: initialStatusFor(TRANSACTION_KIND.BANK_FEED),
|
|
667
|
+
status: opts.initialStatus ?? initialStatusFor(TRANSACTION_KIND.BANK_FEED),
|
|
668
668
|
bankAccountId: opts.bankAccountId,
|
|
669
669
|
externalId: row.externalId,
|
|
670
670
|
source: opts.source,
|
|
@@ -979,6 +979,69 @@ var TransactionRepository = class extends RevenueRepositoryBase {
|
|
|
979
979
|
return claimed;
|
|
980
980
|
}
|
|
981
981
|
/**
|
|
982
|
+
* Reconcile a bank-feed / manual row that settled a linked document
|
|
983
|
+
* (invoice/bill) WITHOUT posting a journal entry. The document's payment
|
|
984
|
+
* already owns the cash JE (`Dr Bank / Cr AR`), so the bank line only needs
|
|
985
|
+
* its status moved to `settled` — calling `match()` here would fire
|
|
986
|
+
* `LedgerBridge.onTransactionMatched` and double-count the cash. This is the
|
|
987
|
+
* package's intended path when the JE lives elsewhere (the reachable sibling
|
|
988
|
+
* of the born-`reconciled_external` import).
|
|
989
|
+
*
|
|
990
|
+
* `imported → settled` (bank_feed) / `pending → settled` (manual). Idempotent:
|
|
991
|
+
* a row already `settled` is returned unchanged, so a best-effort caller can
|
|
992
|
+
* safely re-run. The optional `metadata` is shallow-merged onto the document's
|
|
993
|
+
* `metadata` (dotted `$set`, so sibling keys survive) — hosts stamp the link
|
|
994
|
+
* back to the settling document there. No JE bridge call, no domain event:
|
|
995
|
+
* settlement is host-initiated and the host owns the reconcile audit trail.
|
|
996
|
+
*/
|
|
997
|
+
async settle(id, data = {}, ctx = {}) {
|
|
998
|
+
const existing = await this.getById(id, this.optsFromCtx(ctx));
|
|
999
|
+
if (!existing) throw new TransactionNotFoundError(id);
|
|
1000
|
+
if (existing.kind !== TRANSACTION_KIND.BANK_FEED && existing.kind !== TRANSACTION_KIND.MANUAL) throw new WrongTransactionKindError(id, "bank_feed | manual", existing.kind);
|
|
1001
|
+
if (existing.status === TRANSACTION_STATUS.SETTLED) return existing;
|
|
1002
|
+
smFor(existing.kind).validate(existing.status, TRANSACTION_STATUS.SETTLED, id);
|
|
1003
|
+
const set = {
|
|
1004
|
+
verifiedAt: /* @__PURE__ */ new Date(),
|
|
1005
|
+
...data.settledBy !== void 0 ? { verifiedBy: data.settledBy } : {}
|
|
1006
|
+
};
|
|
1007
|
+
if (data.metadata) for (const [k, v] of Object.entries(data.metadata)) set[`metadata.${k}`] = v;
|
|
1008
|
+
const claimed = await this.claim(existing._id, {
|
|
1009
|
+
from: [TRANSACTION_STATUS.IMPORTED, TRANSACTION_STATUS.PENDING],
|
|
1010
|
+
to: TRANSACTION_STATUS.SETTLED,
|
|
1011
|
+
where: { kind: existing.kind }
|
|
1012
|
+
}, { $set: set }, this.optsFromCtx(ctx));
|
|
1013
|
+
if (!claimed) throw new ValidationError(`Transaction ${id} could not be settled (race-loss or illegal state)`);
|
|
1014
|
+
return claimed;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Reverse a `settle()` — the linked document's payment was undone, so the
|
|
1018
|
+
* bank line returns to its birth status to re-enter the reconcile queue.
|
|
1019
|
+
* `settled → imported` (bank_feed) / `settled → pending` (manual). Clears
|
|
1020
|
+
* `verifiedAt`/`verifiedBy` plus any metadata keys named in `clearMetadata`
|
|
1021
|
+
* (the host-stamped link back to the now-reversed document). Idempotent: a
|
|
1022
|
+
* row not currently `settled` is returned unchanged.
|
|
1023
|
+
*/
|
|
1024
|
+
async unsettle(id, data = {}, ctx = {}) {
|
|
1025
|
+
const existing = await this.getById(id, this.optsFromCtx(ctx));
|
|
1026
|
+
if (!existing) throw new TransactionNotFoundError(id);
|
|
1027
|
+
if (existing.kind !== TRANSACTION_KIND.BANK_FEED && existing.kind !== TRANSACTION_KIND.MANUAL) throw new WrongTransactionKindError(id, "bank_feed | manual", existing.kind);
|
|
1028
|
+
if (existing.status !== TRANSACTION_STATUS.SETTLED) return existing;
|
|
1029
|
+
const target = existing.kind === TRANSACTION_KIND.MANUAL ? TRANSACTION_STATUS.PENDING : TRANSACTION_STATUS.IMPORTED;
|
|
1030
|
+
smFor(existing.kind).validate(TRANSACTION_STATUS.SETTLED, target, id);
|
|
1031
|
+
const unset = {
|
|
1032
|
+
verifiedBy: 1,
|
|
1033
|
+
verifiedAt: 1
|
|
1034
|
+
};
|
|
1035
|
+
for (const k of data.clearMetadata ?? []) unset[`metadata.${k}`] = 1;
|
|
1036
|
+
const claimed = await this.claim(existing._id, {
|
|
1037
|
+
from: TRANSACTION_STATUS.SETTLED,
|
|
1038
|
+
to: target,
|
|
1039
|
+
where: { kind: existing.kind }
|
|
1040
|
+
}, { $unset: unset }, this.optsFromCtx(ctx));
|
|
1041
|
+
if (!claimed) throw new ValidationError(`Transaction ${id} could not be un-settled (current state is not 'settled')`);
|
|
1042
|
+
return claimed;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
982
1045
|
* Stamp the journal entry reference and transition `matched →
|
|
983
1046
|
* journalized`. Typical caller is the `LedgerBridge.onTransactionMatched`
|
|
984
1047
|
* implementation — after creating a JE, it calls this verb so the row
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as transactionBaseSchema, C as subscriptionBaseSchema, D as TransactionCreateInput, E as subscriptionUpdateSchema, M as transactionListFilterSchema, N as transactionUpdateSchema, O as TransactionListFilter, S as SubscriptionUpdateInput, T as subscriptionListFilterSchema, _ as settlementCreateSchema, a as escrowReleaseSchema, b as SubscriptionCreateInput, c as PaymentVerifyInput, d as paymentVerifySchema, f as refundSchema, g as settlementBaseSchema, h as SettlementUpdateInput, i as escrowHoldSchema, j as transactionCreateSchema, k as TransactionUpdateInput, l as RefundInput, m as SettlementListFilter, n as EscrowReleaseInput, o as splitRuleSchema, p as SettlementCreateInput, r as SplitRuleInput, s as PaymentIntentInput, t as EscrowHoldInput, u as paymentIntentSchema, v as settlementListFilterSchema, w as subscriptionCreateSchema, x as SubscriptionListFilter, y as settlementUpdateSchema } from "../escrow.schema-
|
|
1
|
+
import { A as transactionBaseSchema, C as subscriptionBaseSchema, D as TransactionCreateInput, E as subscriptionUpdateSchema, M as transactionListFilterSchema, N as transactionUpdateSchema, O as TransactionListFilter, S as SubscriptionUpdateInput, T as subscriptionListFilterSchema, _ as settlementCreateSchema, a as escrowReleaseSchema, b as SubscriptionCreateInput, c as PaymentVerifyInput, d as paymentVerifySchema, f as refundSchema, g as settlementBaseSchema, h as SettlementUpdateInput, i as escrowHoldSchema, j as transactionCreateSchema, k as TransactionUpdateInput, l as RefundInput, m as SettlementListFilter, n as EscrowReleaseInput, o as splitRuleSchema, p as SettlementCreateInput, r as SplitRuleInput, s as PaymentIntentInput, t as EscrowHoldInput, u as paymentIntentSchema, v as settlementListFilterSchema, w as subscriptionCreateSchema, x as SubscriptionListFilter, y as settlementUpdateSchema } from "../escrow.schema-Cklvlywy.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/validators/bank-feed.schema.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES } from "../bank-feed.enums-
|
|
1
|
+
import { n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES } from "../bank-feed.enums-ByS3mjX0.mjs";
|
|
2
2
|
import { _ as transactionListFilterSchema, a as paymentVerifySchema, c as settlementCreateSchema, d as subscriptionBaseSchema, f as subscriptionCreateSchema, g as transactionCreateSchema, h as transactionBaseSchema, i as paymentIntentSchema, l as settlementListFilterSchema, m as subscriptionUpdateSchema, n as escrowReleaseSchema, o as refundSchema, p as subscriptionListFilterSchema, r as splitRuleSchema, s as settlementBaseSchema, t as escrowHoldSchema, u as settlementUpdateSchema, v as transactionUpdateSchema } from "../escrow.schema-BcKdzrJ7.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/revenue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Payment lifecycle engine — transactions, subscriptions, escrow, settlements, commissions. MongoKit-powered, Arc-compatible, framework-agnostic.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|