@classytic/revenue 1.1.3 → 2.0.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 +90 -0
- package/README.md +638 -632
- package/dist/audit-B39B0Sdq.mjs +53 -0
- package/dist/audit-DZ0eTr9g.d.mts +89 -0
- package/dist/bridges/index.d.mts +2 -0
- package/dist/bridges/index.mjs +1 -0
- package/dist/context-DRqSeTPM.d.mts +35 -0
- package/dist/core/state-machines.d.mts +35 -0
- package/dist/core/state-machines.mjs +134 -0
- package/dist/engine-types-CcjIb4Fy.d.mts +611 -0
- package/dist/enums/index.d.mts +3 -157
- package/dist/enums/index.mjs +3 -55
- package/dist/errors-DHa8JVQ-.mjs +92 -0
- package/dist/escrow.schema-BBv9oVEW.mjs +322 -0
- package/dist/escrow.schema-CC8XuD46.d.mts +629 -0
- package/dist/event-constants-CEMitnIV.mjs +53 -0
- package/dist/events/index.d.mts +3 -0
- package/dist/events/index.mjs +4 -0
- package/dist/index.d.mts +77 -9
- package/dist/index.mjs +465 -29
- package/dist/monetization.enums-BtiU3t8o.mjs +39 -0
- package/dist/monetization.enums-D2xbxXJM.d.mts +34 -0
- package/dist/plugins/plugin.interface.d.mts +28 -0
- package/dist/plugins/plugin.interface.mjs +26 -0
- package/dist/providers/index.d.mts +2 -3
- package/dist/providers/index.mjs +2 -2
- package/dist/{base-DCoyIUj6.mjs → registry-DhFMsSn5.mjs} +34 -36
- package/dist/{base-CsTlVQJe.d.mts → registry-SvIGPAx_.d.mts} +73 -66
- package/dist/repositories/create-repositories.d.mts +21 -0
- package/dist/repositories/create-repositories.mjs +12 -0
- package/dist/revenue-bridges-sdlrR85c.d.mts +145 -0
- package/dist/revenue-event-catalog-BX3g7RUi.d.mts +823 -0
- package/dist/revenue-event-catalog-LqxPnsU_.mjs +388 -0
- package/dist/settlement.repository-Cy3mMWGH.mjs +771 -0
- package/dist/shared/index.d.mts +2 -0
- package/dist/shared/index.mjs +4 -0
- package/dist/split.enums-CQE3ekH1.mjs +172 -0
- package/dist/split.enums-Dw4zCrcZ.d.mts +154 -0
- package/dist/splits-BAfY-a9P.mjs +123 -0
- package/dist/validators/index.d.mts +2 -0
- package/dist/validators/index.mjs +3 -0
- package/package.json +32 -36
- package/dist/application/services/index.d.mts +0 -4
- package/dist/application/services/index.mjs +0 -3
- package/dist/category-resolver-DV83N8ok.mjs +0 -284
- package/dist/commission-split-BzB8cd39.mjs +0 -485
- package/dist/core/events.d.mts +0 -294
- package/dist/core/events.mjs +0 -100
- package/dist/core/index.d.mts +0 -9
- package/dist/core/index.mjs +0 -8
- package/dist/errors-CorrWz7A.d.mts +0 -787
- package/dist/escrow.enums-CZGrrdg7.mjs +0 -101
- package/dist/escrow.enums-DwdLuuve.d.mts +0 -78
- package/dist/idempotency-DaYcUGY1.mjs +0 -172
- package/dist/index-Dsp7H5Wb.d.mts +0 -471
- package/dist/infrastructure/plugins/index.d.mts +0 -239
- package/dist/infrastructure/plugins/index.mjs +0 -345
- package/dist/money-CvrDOijQ.mjs +0 -271
- package/dist/money-DPG8AtJ8.d.mts +0 -112
- package/dist/payment.enums-HAuAS9Pp.d.mts +0 -70
- package/dist/payment.enums-tEFVa-Xp.mjs +0 -69
- package/dist/plugin-BbK0OVHy.d.mts +0 -327
- package/dist/plugin-Cd_V04Em.mjs +0 -210
- package/dist/reconciliation/index.d.mts +0 -193
- package/dist/reconciliation/index.mjs +0 -192
- package/dist/retry-HHCOXYdn.d.mts +0 -186
- package/dist/revenue-9scqKSef.mjs +0 -553
- package/dist/schemas/index.d.mts +0 -2665
- package/dist/schemas/index.mjs +0 -717
- package/dist/schemas/validation.d.mts +0 -375
- package/dist/schemas/validation.mjs +0 -325
- package/dist/settlement.enums-DFhkqZEY.d.mts +0 -132
- package/dist/settlement.schema-D5uWB5tP.d.mts +0 -344
- package/dist/settlement.service-BxuiHpNC.d.mts +0 -594
- package/dist/settlement.service-CUxbUTzT.mjs +0 -2510
- package/dist/split.enums-BrjabxIX.mjs +0 -86
- package/dist/split.enums-DmskfLOM.d.mts +0 -43
- package/dist/tax-BoCt5cEd.d.mts +0 -61
- package/dist/tax-EQ15DO81.mjs +0 -162
- package/dist/transaction.enums-pCyMFT4Z.mjs +0 -96
- package/dist/utils/index.d.mts +0 -428
- package/dist/utils/index.mjs +0 -346
package/dist/schemas/index.mjs
DELETED
|
@@ -1,717 +0,0 @@
|
|
|
1
|
-
import { d as SETTLEMENT_STATUS_VALUES, i as HOLD_STATUS_VALUES, n as HOLD_REASON_VALUES, p as SETTLEMENT_TYPE_VALUES, r as HOLD_STATUS } from "../escrow.enums-CZGrrdg7.mjs";
|
|
2
|
-
import { d as PLAN_KEY_VALUES, i as SPLIT_STATUS_VALUES, n as PAYOUT_METHOD_VALUES, o as SPLIT_TYPE_VALUES, p as SUBSCRIPTION_STATUS_VALUES, r as SPLIT_STATUS } from "../split.enums-BrjabxIX.mjs";
|
|
3
|
-
import { o as PAYMENT_STATUS_VALUES } from "../payment.enums-tEFVa-Xp.mjs";
|
|
4
|
-
import mongoose, { Schema } from "mongoose";
|
|
5
|
-
|
|
6
|
-
//#region src/schemas/transaction/common.schema.ts
|
|
7
|
-
/**
|
|
8
|
-
* Common Transaction Schemas
|
|
9
|
-
* @classytic/revenue
|
|
10
|
-
*
|
|
11
|
-
* Base schemas shared across transaction types
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Base metadata schema for transactions
|
|
15
|
-
*/
|
|
16
|
-
const baseMetadataSchema = new Schema({}, {
|
|
17
|
-
_id: false,
|
|
18
|
-
strict: false
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/schemas/transaction/gateway.schema.ts
|
|
23
|
-
/**
|
|
24
|
-
* Gateway Schema
|
|
25
|
-
* @classytic/revenue
|
|
26
|
-
*
|
|
27
|
-
* Schema for payment gateway information
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Gateway Schema - Embedded in Transaction
|
|
31
|
-
* Tracks payment gateway details
|
|
32
|
-
*/
|
|
33
|
-
const gatewaySchema = new Schema({
|
|
34
|
-
type: {
|
|
35
|
-
type: String,
|
|
36
|
-
required: true
|
|
37
|
-
},
|
|
38
|
-
sessionId: {
|
|
39
|
-
type: String,
|
|
40
|
-
sparse: true
|
|
41
|
-
},
|
|
42
|
-
paymentIntentId: {
|
|
43
|
-
type: String,
|
|
44
|
-
sparse: true
|
|
45
|
-
},
|
|
46
|
-
provider: { type: String },
|
|
47
|
-
metadata: {
|
|
48
|
-
type: Schema.Types.Mixed,
|
|
49
|
-
default: {}
|
|
50
|
-
},
|
|
51
|
-
verificationData: { type: Schema.Types.Mixed }
|
|
52
|
-
}, { _id: false });
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/schemas/transaction/payment.schema.ts
|
|
56
|
-
/**
|
|
57
|
-
* Payment Schemas for Transaction Model
|
|
58
|
-
* @classytic/revenue
|
|
59
|
-
*
|
|
60
|
-
* Schemas for payment tracking in transactions
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* Individual Payment Entry Schema
|
|
64
|
-
* For split/multi-payment scenarios (e.g., cash + bank + mobile wallet)
|
|
65
|
-
*
|
|
66
|
-
* Use in currentPaymentSchema.payments array
|
|
67
|
-
*/
|
|
68
|
-
const paymentEntrySchema = new Schema({
|
|
69
|
-
method: {
|
|
70
|
-
type: String,
|
|
71
|
-
required: true
|
|
72
|
-
},
|
|
73
|
-
amount: {
|
|
74
|
-
type: Number,
|
|
75
|
-
required: true,
|
|
76
|
-
min: 0
|
|
77
|
-
},
|
|
78
|
-
reference: {
|
|
79
|
-
type: String,
|
|
80
|
-
trim: true
|
|
81
|
-
},
|
|
82
|
-
details: { type: Schema.Types.Mixed }
|
|
83
|
-
}, { _id: false });
|
|
84
|
-
/**
|
|
85
|
-
* Current Payment Schema
|
|
86
|
-
* Use this in your model: currentPayment: { type: currentPaymentSchema }
|
|
87
|
-
*
|
|
88
|
-
* Tracks the latest payment transaction for an entity
|
|
89
|
-
* Supports both single payments and multi-payment (split) scenarios
|
|
90
|
-
*/
|
|
91
|
-
const currentPaymentSchema = new Schema({
|
|
92
|
-
transactionId: {
|
|
93
|
-
type: Schema.Types.ObjectId,
|
|
94
|
-
ref: "Transaction"
|
|
95
|
-
},
|
|
96
|
-
amount: {
|
|
97
|
-
type: Number,
|
|
98
|
-
min: 0
|
|
99
|
-
},
|
|
100
|
-
status: {
|
|
101
|
-
type: String,
|
|
102
|
-
enum: PAYMENT_STATUS_VALUES,
|
|
103
|
-
default: "pending"
|
|
104
|
-
},
|
|
105
|
-
method: { type: String },
|
|
106
|
-
reference: {
|
|
107
|
-
type: String,
|
|
108
|
-
trim: true
|
|
109
|
-
},
|
|
110
|
-
payments: {
|
|
111
|
-
type: [paymentEntrySchema],
|
|
112
|
-
default: void 0
|
|
113
|
-
},
|
|
114
|
-
verifiedAt: { type: Date },
|
|
115
|
-
verifiedBy: {
|
|
116
|
-
type: Schema.Types.ObjectId,
|
|
117
|
-
ref: "User"
|
|
118
|
-
}
|
|
119
|
-
}, { _id: false });
|
|
120
|
-
/**
|
|
121
|
-
* Payment Summary Schema
|
|
122
|
-
* Use this in your model: paymentSummary: { type: paymentSummarySchema }
|
|
123
|
-
*
|
|
124
|
-
* Tracks payment history and totals
|
|
125
|
-
*/
|
|
126
|
-
const paymentSummarySchema = new Schema({
|
|
127
|
-
totalPayments: {
|
|
128
|
-
type: Number,
|
|
129
|
-
default: 0,
|
|
130
|
-
min: 0
|
|
131
|
-
},
|
|
132
|
-
totalAmountPaid: {
|
|
133
|
-
type: Number,
|
|
134
|
-
default: 0,
|
|
135
|
-
min: 0
|
|
136
|
-
},
|
|
137
|
-
lastPaymentDate: { type: Date },
|
|
138
|
-
lastPaymentAmount: {
|
|
139
|
-
type: Number,
|
|
140
|
-
min: 0
|
|
141
|
-
}
|
|
142
|
-
}, { _id: false });
|
|
143
|
-
/**
|
|
144
|
-
* Payment Details Schema (for manual payments)
|
|
145
|
-
* Embedded in Transaction model
|
|
146
|
-
*/
|
|
147
|
-
const paymentDetailsSchema = new Schema({
|
|
148
|
-
provider: { type: String },
|
|
149
|
-
walletNumber: { type: String },
|
|
150
|
-
walletType: { type: String },
|
|
151
|
-
trxId: { type: String },
|
|
152
|
-
bankName: { type: String },
|
|
153
|
-
accountNumber: { type: String },
|
|
154
|
-
accountName: { type: String },
|
|
155
|
-
proofUrl: { type: String }
|
|
156
|
-
}, { _id: false });
|
|
157
|
-
/**
|
|
158
|
-
* Tenant Snapshot Schema
|
|
159
|
-
* Captures organization payment details at transaction time (audit trail)
|
|
160
|
-
*/
|
|
161
|
-
const tenantSnapshotSchema = new Schema({
|
|
162
|
-
paymentInstructions: { type: String },
|
|
163
|
-
bkashNumber: { type: String },
|
|
164
|
-
nagadNumber: { type: String },
|
|
165
|
-
bankAccount: { type: String }
|
|
166
|
-
}, { _id: false });
|
|
167
|
-
var payment_schema_default = {
|
|
168
|
-
paymentEntrySchema,
|
|
169
|
-
currentPaymentSchema,
|
|
170
|
-
paymentSummarySchema,
|
|
171
|
-
paymentDetailsSchema,
|
|
172
|
-
tenantSnapshotSchema
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/schemas/transaction/commission.schema.ts
|
|
177
|
-
/**
|
|
178
|
-
* Commission Schema
|
|
179
|
-
* @classytic/revenue
|
|
180
|
-
*
|
|
181
|
-
* Schema for platform commission tracking
|
|
182
|
-
* Embedded in Transaction model
|
|
183
|
-
*/
|
|
184
|
-
/**
|
|
185
|
-
* Commission Schema - Embedded in Transaction
|
|
186
|
-
* Tracks platform commission with gateway fee deduction
|
|
187
|
-
*
|
|
188
|
-
* Usage: commission: commissionSchema
|
|
189
|
-
*/
|
|
190
|
-
const commissionSchema = new Schema({
|
|
191
|
-
rate: {
|
|
192
|
-
type: Number,
|
|
193
|
-
min: 0,
|
|
194
|
-
max: 1
|
|
195
|
-
},
|
|
196
|
-
grossAmount: {
|
|
197
|
-
type: Number,
|
|
198
|
-
min: 0
|
|
199
|
-
},
|
|
200
|
-
gatewayFeeRate: {
|
|
201
|
-
type: Number,
|
|
202
|
-
min: 0,
|
|
203
|
-
max: 1
|
|
204
|
-
},
|
|
205
|
-
gatewayFeeAmount: {
|
|
206
|
-
type: Number,
|
|
207
|
-
min: 0
|
|
208
|
-
},
|
|
209
|
-
netAmount: {
|
|
210
|
-
type: Number,
|
|
211
|
-
min: 0
|
|
212
|
-
},
|
|
213
|
-
status: {
|
|
214
|
-
type: String,
|
|
215
|
-
enum: [
|
|
216
|
-
"pending",
|
|
217
|
-
"paid",
|
|
218
|
-
"waived",
|
|
219
|
-
"reversed"
|
|
220
|
-
],
|
|
221
|
-
default: "pending"
|
|
222
|
-
},
|
|
223
|
-
affiliate: {
|
|
224
|
-
recipientId: String,
|
|
225
|
-
recipientType: {
|
|
226
|
-
type: String,
|
|
227
|
-
enum: [
|
|
228
|
-
"user",
|
|
229
|
-
"organization",
|
|
230
|
-
"partner"
|
|
231
|
-
]
|
|
232
|
-
},
|
|
233
|
-
rate: Number,
|
|
234
|
-
grossAmount: Number,
|
|
235
|
-
netAmount: Number
|
|
236
|
-
},
|
|
237
|
-
splits: [{
|
|
238
|
-
type: String,
|
|
239
|
-
recipientId: String,
|
|
240
|
-
rate: Number,
|
|
241
|
-
grossAmount: Number,
|
|
242
|
-
netAmount: Number
|
|
243
|
-
}]
|
|
244
|
-
}, { _id: false });
|
|
245
|
-
|
|
246
|
-
//#endregion
|
|
247
|
-
//#region src/schemas/transaction/tax.schema.ts
|
|
248
|
-
/**
|
|
249
|
-
* Tax Schema
|
|
250
|
-
* @classytic/revenue
|
|
251
|
-
*
|
|
252
|
-
* Mongoose schema for tax breakdown in transactions
|
|
253
|
-
*/
|
|
254
|
-
/**
|
|
255
|
-
* Tax Breakdown Schema
|
|
256
|
-
* Embed this in Transaction model to track tax
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* ```typescript
|
|
260
|
-
* import mongoose from 'mongoose';
|
|
261
|
-
* import { taxBreakdownSchema } from '@classytic/revenue/schemas';
|
|
262
|
-
*
|
|
263
|
-
* const transactionSchema = new mongoose.Schema({
|
|
264
|
-
* amount: Number,
|
|
265
|
-
* tax: taxBreakdownSchema, // Add tax tracking
|
|
266
|
-
* // ... other fields
|
|
267
|
-
* });
|
|
268
|
-
* ```
|
|
269
|
-
*/
|
|
270
|
-
const taxBreakdownSchema = new Schema({
|
|
271
|
-
isApplicable: {
|
|
272
|
-
type: Boolean,
|
|
273
|
-
default: false
|
|
274
|
-
},
|
|
275
|
-
rate: {
|
|
276
|
-
type: Number,
|
|
277
|
-
default: 0,
|
|
278
|
-
min: 0,
|
|
279
|
-
max: 1
|
|
280
|
-
},
|
|
281
|
-
baseAmount: {
|
|
282
|
-
type: Number,
|
|
283
|
-
default: 0,
|
|
284
|
-
min: 0
|
|
285
|
-
},
|
|
286
|
-
taxAmount: {
|
|
287
|
-
type: Number,
|
|
288
|
-
default: 0,
|
|
289
|
-
min: 0
|
|
290
|
-
},
|
|
291
|
-
totalAmount: {
|
|
292
|
-
type: Number,
|
|
293
|
-
default: 0,
|
|
294
|
-
min: 0
|
|
295
|
-
},
|
|
296
|
-
pricesIncludeTax: { type: Boolean },
|
|
297
|
-
type: {
|
|
298
|
-
type: String,
|
|
299
|
-
enum: [
|
|
300
|
-
"collected",
|
|
301
|
-
"paid",
|
|
302
|
-
"exempt"
|
|
303
|
-
]
|
|
304
|
-
}
|
|
305
|
-
}, { _id: false });
|
|
306
|
-
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/schemas/transaction/index.ts
|
|
309
|
-
var transaction_default = {
|
|
310
|
-
baseMetadataSchema,
|
|
311
|
-
gatewaySchema,
|
|
312
|
-
commissionSchema,
|
|
313
|
-
taxBreakdownSchema,
|
|
314
|
-
...payment_schema_default
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/schemas/subscription/plan.schema.ts
|
|
319
|
-
/**
|
|
320
|
-
* Plan Schema
|
|
321
|
-
* @classytic/revenue
|
|
322
|
-
*
|
|
323
|
-
* Schema for subscription plans
|
|
324
|
-
*/
|
|
325
|
-
/**
|
|
326
|
-
* Plan Schema - for defining subscription plans
|
|
327
|
-
*/
|
|
328
|
-
const planSchema = new Schema({
|
|
329
|
-
key: {
|
|
330
|
-
type: String,
|
|
331
|
-
enum: PLAN_KEY_VALUES,
|
|
332
|
-
required: true
|
|
333
|
-
},
|
|
334
|
-
name: {
|
|
335
|
-
type: String,
|
|
336
|
-
required: true
|
|
337
|
-
},
|
|
338
|
-
description: { type: String },
|
|
339
|
-
amount: {
|
|
340
|
-
type: Number,
|
|
341
|
-
required: true,
|
|
342
|
-
min: 0
|
|
343
|
-
},
|
|
344
|
-
currency: {
|
|
345
|
-
type: String,
|
|
346
|
-
default: "BDT"
|
|
347
|
-
},
|
|
348
|
-
interval: {
|
|
349
|
-
type: String,
|
|
350
|
-
enum: [
|
|
351
|
-
"day",
|
|
352
|
-
"week",
|
|
353
|
-
"month",
|
|
354
|
-
"year"
|
|
355
|
-
],
|
|
356
|
-
default: "month"
|
|
357
|
-
},
|
|
358
|
-
intervalCount: {
|
|
359
|
-
type: Number,
|
|
360
|
-
default: 1,
|
|
361
|
-
min: 1
|
|
362
|
-
},
|
|
363
|
-
features: [{ type: String }],
|
|
364
|
-
metadata: {
|
|
365
|
-
type: Schema.Types.Mixed,
|
|
366
|
-
default: {}
|
|
367
|
-
},
|
|
368
|
-
isActive: {
|
|
369
|
-
type: Boolean,
|
|
370
|
-
default: true
|
|
371
|
-
}
|
|
372
|
-
}, { _id: false });
|
|
373
|
-
|
|
374
|
-
//#endregion
|
|
375
|
-
//#region src/schemas/subscription/info.schema.ts
|
|
376
|
-
/**
|
|
377
|
-
* Subscription Info Schema
|
|
378
|
-
* @classytic/revenue
|
|
379
|
-
*
|
|
380
|
-
* Schema for subscription information embedded in entities
|
|
381
|
-
*/
|
|
382
|
-
/**
|
|
383
|
-
* Subscription Info Schema
|
|
384
|
-
* Use this in your entity models that have subscriptions
|
|
385
|
-
*
|
|
386
|
-
* @example
|
|
387
|
-
* const OrganizationSchema = new Schema({
|
|
388
|
-
* name: String,
|
|
389
|
-
* subscription: { type: subscriptionInfoSchema },
|
|
390
|
-
* });
|
|
391
|
-
*/
|
|
392
|
-
const subscriptionInfoSchema = new Schema({
|
|
393
|
-
planKey: {
|
|
394
|
-
type: String,
|
|
395
|
-
enum: PLAN_KEY_VALUES,
|
|
396
|
-
required: true
|
|
397
|
-
},
|
|
398
|
-
status: {
|
|
399
|
-
type: String,
|
|
400
|
-
enum: SUBSCRIPTION_STATUS_VALUES,
|
|
401
|
-
default: "pending"
|
|
402
|
-
},
|
|
403
|
-
isActive: {
|
|
404
|
-
type: Boolean,
|
|
405
|
-
default: false
|
|
406
|
-
},
|
|
407
|
-
startDate: { type: Date },
|
|
408
|
-
endDate: { type: Date },
|
|
409
|
-
canceledAt: { type: Date },
|
|
410
|
-
cancelAt: { type: Date },
|
|
411
|
-
pausedAt: { type: Date },
|
|
412
|
-
lastPaymentDate: { type: Date },
|
|
413
|
-
lastPaymentAmount: { type: Number },
|
|
414
|
-
renewalCount: {
|
|
415
|
-
type: Number,
|
|
416
|
-
default: 0
|
|
417
|
-
}
|
|
418
|
-
}, { _id: false });
|
|
419
|
-
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region src/schemas/subscription/index.ts
|
|
422
|
-
var subscription_default = {
|
|
423
|
-
planSchema,
|
|
424
|
-
subscriptionInfoSchema
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region src/schemas/escrow/hold.schema.ts
|
|
429
|
-
/**
|
|
430
|
-
* Hold/Escrow Schema
|
|
431
|
-
* @classytic/revenue
|
|
432
|
-
*
|
|
433
|
-
* Schema for platform-as-intermediary escrow flow
|
|
434
|
-
* Spread into transaction schema when needed
|
|
435
|
-
*/
|
|
436
|
-
const holdSchema = {
|
|
437
|
-
status: {
|
|
438
|
-
type: String,
|
|
439
|
-
enum: HOLD_STATUS_VALUES,
|
|
440
|
-
default: HOLD_STATUS.PENDING
|
|
441
|
-
},
|
|
442
|
-
heldAmount: {
|
|
443
|
-
type: Number,
|
|
444
|
-
required: false
|
|
445
|
-
},
|
|
446
|
-
releasedAmount: {
|
|
447
|
-
type: Number,
|
|
448
|
-
default: 0
|
|
449
|
-
},
|
|
450
|
-
reason: {
|
|
451
|
-
type: String,
|
|
452
|
-
enum: HOLD_REASON_VALUES,
|
|
453
|
-
required: false
|
|
454
|
-
},
|
|
455
|
-
holdUntil: {
|
|
456
|
-
type: Date,
|
|
457
|
-
required: false
|
|
458
|
-
},
|
|
459
|
-
heldAt: Date,
|
|
460
|
-
releasedAt: Date,
|
|
461
|
-
cancelledAt: Date,
|
|
462
|
-
releases: [{
|
|
463
|
-
amount: Number,
|
|
464
|
-
recipientId: String,
|
|
465
|
-
recipientType: String,
|
|
466
|
-
releasedAt: Date,
|
|
467
|
-
releasedBy: String,
|
|
468
|
-
reason: String,
|
|
469
|
-
metadata: Object
|
|
470
|
-
}],
|
|
471
|
-
metadata: {
|
|
472
|
-
type: Object,
|
|
473
|
-
default: {}
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
//#endregion
|
|
478
|
-
//#region src/schemas/escrow/index.ts
|
|
479
|
-
var escrow_default = { holdSchema };
|
|
480
|
-
|
|
481
|
-
//#endregion
|
|
482
|
-
//#region src/schemas/split/split.schema.ts
|
|
483
|
-
/**
|
|
484
|
-
* Split Schema
|
|
485
|
-
* @classytic/revenue
|
|
486
|
-
*
|
|
487
|
-
* Schema for multi-party commission splits
|
|
488
|
-
*/
|
|
489
|
-
/**
|
|
490
|
-
* Split Schema - Embedded in Transaction
|
|
491
|
-
*/
|
|
492
|
-
const splitSchema = new Schema({
|
|
493
|
-
type: {
|
|
494
|
-
type: String,
|
|
495
|
-
enum: SPLIT_TYPE_VALUES,
|
|
496
|
-
required: true
|
|
497
|
-
},
|
|
498
|
-
recipientId: {
|
|
499
|
-
type: String,
|
|
500
|
-
required: true
|
|
501
|
-
},
|
|
502
|
-
recipientType: {
|
|
503
|
-
type: String,
|
|
504
|
-
enum: [
|
|
505
|
-
"platform",
|
|
506
|
-
"organization",
|
|
507
|
-
"user",
|
|
508
|
-
"affiliate",
|
|
509
|
-
"partner"
|
|
510
|
-
],
|
|
511
|
-
required: true
|
|
512
|
-
},
|
|
513
|
-
rate: {
|
|
514
|
-
type: Number,
|
|
515
|
-
required: true,
|
|
516
|
-
min: 0,
|
|
517
|
-
max: 1
|
|
518
|
-
},
|
|
519
|
-
grossAmount: {
|
|
520
|
-
type: Number,
|
|
521
|
-
required: true,
|
|
522
|
-
min: 0
|
|
523
|
-
},
|
|
524
|
-
gatewayFeeRate: {
|
|
525
|
-
type: Number,
|
|
526
|
-
default: 0,
|
|
527
|
-
min: 0,
|
|
528
|
-
max: 1
|
|
529
|
-
},
|
|
530
|
-
gatewayFeeAmount: {
|
|
531
|
-
type: Number,
|
|
532
|
-
default: 0,
|
|
533
|
-
min: 0
|
|
534
|
-
},
|
|
535
|
-
netAmount: {
|
|
536
|
-
type: Number,
|
|
537
|
-
required: true,
|
|
538
|
-
min: 0
|
|
539
|
-
},
|
|
540
|
-
status: {
|
|
541
|
-
type: String,
|
|
542
|
-
enum: SPLIT_STATUS_VALUES,
|
|
543
|
-
default: SPLIT_STATUS.PENDING
|
|
544
|
-
},
|
|
545
|
-
dueDate: { type: Date },
|
|
546
|
-
paidDate: { type: Date },
|
|
547
|
-
payoutMethod: {
|
|
548
|
-
type: String,
|
|
549
|
-
enum: PAYOUT_METHOD_VALUES
|
|
550
|
-
},
|
|
551
|
-
payoutTransactionId: { type: String },
|
|
552
|
-
metadata: {
|
|
553
|
-
type: Schema.Types.Mixed,
|
|
554
|
-
default: {}
|
|
555
|
-
}
|
|
556
|
-
}, { _id: false });
|
|
557
|
-
|
|
558
|
-
//#endregion
|
|
559
|
-
//#region src/schemas/split/index.ts
|
|
560
|
-
var split_default = { splitSchema };
|
|
561
|
-
|
|
562
|
-
//#endregion
|
|
563
|
-
//#region src/schemas/settlement/settlement.schema.ts
|
|
564
|
-
/**
|
|
565
|
-
* Settlement Schema
|
|
566
|
-
* @classytic/revenue
|
|
567
|
-
*
|
|
568
|
-
* Mongoose schema for settlement/payout tracking
|
|
569
|
-
*/
|
|
570
|
-
/**
|
|
571
|
-
* Settlement Schema
|
|
572
|
-
* Tracks payouts from platform to vendors/affiliates/partners
|
|
573
|
-
*
|
|
574
|
-
* Use in your Settlement model:
|
|
575
|
-
* ```typescript
|
|
576
|
-
* import mongoose from 'mongoose';
|
|
577
|
-
* import { settlementSchema } from '@classytic/revenue/schemas';
|
|
578
|
-
*
|
|
579
|
-
* const Settlement = mongoose.model('Settlement', settlementSchema);
|
|
580
|
-
* ```
|
|
581
|
-
*/
|
|
582
|
-
const settlementSchema = new Schema({
|
|
583
|
-
organizationId: {
|
|
584
|
-
type: Schema.Types.ObjectId,
|
|
585
|
-
required: true,
|
|
586
|
-
index: true
|
|
587
|
-
},
|
|
588
|
-
recipientId: {
|
|
589
|
-
type: Schema.Types.ObjectId,
|
|
590
|
-
required: true,
|
|
591
|
-
index: true
|
|
592
|
-
},
|
|
593
|
-
recipientType: {
|
|
594
|
-
type: String,
|
|
595
|
-
enum: [
|
|
596
|
-
"platform",
|
|
597
|
-
"organization",
|
|
598
|
-
"user",
|
|
599
|
-
"affiliate",
|
|
600
|
-
"partner"
|
|
601
|
-
],
|
|
602
|
-
required: true
|
|
603
|
-
},
|
|
604
|
-
type: {
|
|
605
|
-
type: String,
|
|
606
|
-
enum: SETTLEMENT_TYPE_VALUES,
|
|
607
|
-
required: true
|
|
608
|
-
},
|
|
609
|
-
status: {
|
|
610
|
-
type: String,
|
|
611
|
-
enum: SETTLEMENT_STATUS_VALUES,
|
|
612
|
-
default: "pending",
|
|
613
|
-
index: true
|
|
614
|
-
},
|
|
615
|
-
payoutMethod: {
|
|
616
|
-
type: String,
|
|
617
|
-
enum: PAYOUT_METHOD_VALUES,
|
|
618
|
-
required: true
|
|
619
|
-
},
|
|
620
|
-
amount: {
|
|
621
|
-
type: Number,
|
|
622
|
-
required: true,
|
|
623
|
-
min: 0
|
|
624
|
-
},
|
|
625
|
-
currency: {
|
|
626
|
-
type: String,
|
|
627
|
-
required: true,
|
|
628
|
-
default: "USD"
|
|
629
|
-
},
|
|
630
|
-
sourceTransactionIds: [{
|
|
631
|
-
type: Schema.Types.ObjectId,
|
|
632
|
-
ref: "Transaction"
|
|
633
|
-
}],
|
|
634
|
-
sourceSplitIds: [{ type: String }],
|
|
635
|
-
bankTransferDetails: {
|
|
636
|
-
accountNumber: { type: String },
|
|
637
|
-
accountName: { type: String },
|
|
638
|
-
bankName: { type: String },
|
|
639
|
-
routingNumber: { type: String },
|
|
640
|
-
swiftCode: { type: String },
|
|
641
|
-
iban: { type: String },
|
|
642
|
-
transferReference: { type: String },
|
|
643
|
-
transferredAt: { type: Date }
|
|
644
|
-
},
|
|
645
|
-
mobileWalletDetails: {
|
|
646
|
-
provider: { type: String },
|
|
647
|
-
phoneNumber: { type: String },
|
|
648
|
-
accountNumber: { type: String },
|
|
649
|
-
transactionId: { type: String },
|
|
650
|
-
transferredAt: { type: Date }
|
|
651
|
-
},
|
|
652
|
-
cryptoDetails: {
|
|
653
|
-
network: { type: String },
|
|
654
|
-
walletAddress: { type: String },
|
|
655
|
-
transactionHash: { type: String },
|
|
656
|
-
transferredAt: { type: Date }
|
|
657
|
-
},
|
|
658
|
-
platformBalanceDetails: {
|
|
659
|
-
balanceId: { type: Schema.Types.ObjectId },
|
|
660
|
-
appliedAt: { type: Date }
|
|
661
|
-
},
|
|
662
|
-
scheduledAt: {
|
|
663
|
-
type: Date,
|
|
664
|
-
index: true
|
|
665
|
-
},
|
|
666
|
-
processedAt: { type: Date },
|
|
667
|
-
completedAt: { type: Date },
|
|
668
|
-
failedAt: { type: Date },
|
|
669
|
-
cancelledAt: { type: Date },
|
|
670
|
-
failureReason: { type: String },
|
|
671
|
-
failureCode: { type: String },
|
|
672
|
-
retryCount: {
|
|
673
|
-
type: Number,
|
|
674
|
-
default: 0,
|
|
675
|
-
min: 0
|
|
676
|
-
},
|
|
677
|
-
notes: { type: String },
|
|
678
|
-
metadata: {
|
|
679
|
-
type: Schema.Types.Mixed,
|
|
680
|
-
default: {}
|
|
681
|
-
}
|
|
682
|
-
}, { timestamps: true });
|
|
683
|
-
settlementSchema.index({
|
|
684
|
-
organizationId: 1,
|
|
685
|
-
status: 1
|
|
686
|
-
});
|
|
687
|
-
settlementSchema.index({
|
|
688
|
-
recipientId: 1,
|
|
689
|
-
status: 1
|
|
690
|
-
});
|
|
691
|
-
settlementSchema.index({
|
|
692
|
-
type: 1,
|
|
693
|
-
status: 1,
|
|
694
|
-
scheduledAt: 1
|
|
695
|
-
});
|
|
696
|
-
settlementSchema.index({ sourceTransactionIds: 1 });
|
|
697
|
-
settlementSchema.index({
|
|
698
|
-
status: 1,
|
|
699
|
-
scheduledAt: 1
|
|
700
|
-
});
|
|
701
|
-
|
|
702
|
-
//#endregion
|
|
703
|
-
//#region src/schemas/settlement/index.ts
|
|
704
|
-
var settlement_default = { settlementSchema };
|
|
705
|
-
|
|
706
|
-
//#endregion
|
|
707
|
-
//#region src/schemas/index.ts
|
|
708
|
-
var schemas_default = {
|
|
709
|
-
...transaction_default,
|
|
710
|
-
...subscription_default,
|
|
711
|
-
...escrow_default,
|
|
712
|
-
...split_default,
|
|
713
|
-
...settlement_default
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
//#endregion
|
|
717
|
-
export { baseMetadataSchema, commissionSchema, currentPaymentSchema, schemas_default as default, gatewaySchema, holdSchema, paymentDetailsSchema, paymentEntrySchema, paymentSummarySchema, planSchema, settlementSchema, splitSchema, subscriptionInfoSchema, taxBreakdownSchema, tenantSnapshotSchema };
|