@classytic/revenue 1.1.2 → 1.1.3
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/README.md +8 -7
- package/dist/application/services/index.d.mts +4 -0
- package/dist/application/services/index.mjs +3 -0
- package/dist/base-CsTlVQJe.d.mts +136 -0
- package/dist/base-DCoyIUj6.mjs +152 -0
- package/dist/category-resolver-DV83N8ok.mjs +284 -0
- package/dist/commission-split-BzB8cd39.mjs +485 -0
- package/dist/core/events.d.mts +294 -0
- package/dist/core/events.mjs +100 -0
- package/dist/core/index.d.mts +9 -0
- package/dist/core/index.mjs +8 -0
- package/dist/enums/index.d.mts +157 -0
- package/dist/enums/index.mjs +56 -0
- package/dist/errors-CorrWz7A.d.mts +787 -0
- package/dist/escrow.enums-CZGrrdg7.mjs +101 -0
- package/dist/{escrow.enums-CE0VQsfe.d.ts → escrow.enums-DwdLuuve.d.mts} +30 -28
- package/dist/idempotency-DaYcUGY1.mjs +172 -0
- package/dist/index-Dsp7H5Wb.d.mts +471 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +38 -0
- package/dist/infrastructure/plugins/{index.d.ts → index.d.mts} +81 -109
- package/dist/infrastructure/plugins/index.mjs +345 -0
- package/dist/money-CvrDOijQ.mjs +271 -0
- package/dist/money-DPG8AtJ8.d.mts +112 -0
- package/dist/{payment.enums-C1BiGlRa.d.ts → payment.enums-HAuAS9Pp.d.mts} +14 -13
- package/dist/payment.enums-tEFVa-Xp.mjs +69 -0
- package/dist/plugin-BbK0OVHy.d.mts +327 -0
- package/dist/plugin-Cd_V04Em.mjs +210 -0
- package/dist/providers/index.d.mts +3 -0
- package/dist/providers/index.mjs +3 -0
- package/dist/reconciliation/{index.d.ts → index.d.mts} +90 -112
- package/dist/reconciliation/index.mjs +192 -0
- package/dist/retry-HHCOXYdn.d.mts +186 -0
- package/dist/revenue-9scqKSef.mjs +553 -0
- package/dist/schemas/index.d.mts +2665 -0
- package/dist/schemas/index.mjs +717 -0
- package/dist/schemas/validation.d.mts +375 -0
- package/dist/schemas/validation.mjs +325 -0
- package/dist/{settlement.enums-ByC1x0ye.d.ts → settlement.enums-DFhkqZEY.d.mts} +31 -29
- package/dist/settlement.schema-D5uWB5tP.d.mts +344 -0
- package/dist/settlement.service-BxuiHpNC.d.mts +594 -0
- package/dist/settlement.service-CUxbUTzT.mjs +2510 -0
- package/dist/split.enums-BrjabxIX.mjs +86 -0
- package/dist/split.enums-DmskfLOM.d.mts +43 -0
- package/dist/tax-BoCt5cEd.d.mts +61 -0
- package/dist/tax-EQ15DO81.mjs +162 -0
- package/dist/transaction.enums-pCyMFT4Z.mjs +96 -0
- package/dist/utils/{index.d.ts → index.d.mts} +91 -161
- package/dist/utils/index.mjs +346 -0
- package/package.json +38 -36
- package/dist/application/services/index.d.ts +0 -6
- package/dist/application/services/index.js +0 -3288
- package/dist/application/services/index.js.map +0 -1
- package/dist/core/events.d.ts +0 -455
- package/dist/core/events.js +0 -122
- package/dist/core/events.js.map +0 -1
- package/dist/core/index.d.ts +0 -13
- package/dist/core/index.js +0 -4591
- package/dist/core/index.js.map +0 -1
- package/dist/enums/index.d.ts +0 -159
- package/dist/enums/index.js +0 -296
- package/dist/enums/index.js.map +0 -1
- package/dist/index-DxIK0UmZ.d.ts +0 -633
- package/dist/index-EnfKzDbs.d.ts +0 -806
- package/dist/index-cLJBLUvx.d.ts +0 -478
- package/dist/index.d.ts +0 -43
- package/dist/index.js +0 -4864
- package/dist/index.js.map +0 -1
- package/dist/infrastructure/plugins/index.js +0 -292
- package/dist/infrastructure/plugins/index.js.map +0 -1
- package/dist/money-widWVD7r.d.ts +0 -111
- package/dist/plugin-Bb9HOE10.d.ts +0 -336
- package/dist/providers/index.d.ts +0 -145
- package/dist/providers/index.js +0 -141
- package/dist/providers/index.js.map +0 -1
- package/dist/reconciliation/index.js +0 -140
- package/dist/reconciliation/index.js.map +0 -1
- package/dist/retry-D4hFUwVk.d.ts +0 -194
- package/dist/schemas/index.d.ts +0 -2655
- package/dist/schemas/index.js +0 -841
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/validation.d.ts +0 -384
- package/dist/schemas/validation.js +0 -303
- package/dist/schemas/validation.js.map +0 -1
- package/dist/settlement.schema-CpamV7ZY.d.ts +0 -343
- package/dist/split.enums-DG3TxQf9.d.ts +0 -42
- package/dist/tax-CV8A0sxl.d.ts +0 -60
- package/dist/utils/index.js +0 -1202
- package/dist/utils/index.js.map +0 -1
package/dist/schemas/index.js
DELETED
|
@@ -1,841 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'mongoose';
|
|
2
|
-
|
|
3
|
-
// @classytic/revenue - Enterprise Revenue Management System
|
|
4
|
-
|
|
5
|
-
var baseMetadataSchema = new Schema(
|
|
6
|
-
{
|
|
7
|
-
// Flexible key-value metadata
|
|
8
|
-
},
|
|
9
|
-
{ _id: false, strict: false }
|
|
10
|
-
);
|
|
11
|
-
var gatewaySchema = new Schema(
|
|
12
|
-
{
|
|
13
|
-
type: {
|
|
14
|
-
type: String,
|
|
15
|
-
required: true
|
|
16
|
-
},
|
|
17
|
-
sessionId: {
|
|
18
|
-
type: String,
|
|
19
|
-
sparse: true
|
|
20
|
-
},
|
|
21
|
-
paymentIntentId: {
|
|
22
|
-
type: String,
|
|
23
|
-
sparse: true
|
|
24
|
-
},
|
|
25
|
-
provider: {
|
|
26
|
-
type: String
|
|
27
|
-
},
|
|
28
|
-
metadata: {
|
|
29
|
-
type: Schema.Types.Mixed,
|
|
30
|
-
default: {}
|
|
31
|
-
},
|
|
32
|
-
verificationData: {
|
|
33
|
-
type: Schema.Types.Mixed
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{ _id: false }
|
|
37
|
-
);
|
|
38
|
-
var gateway_schema_default = gatewaySchema;
|
|
39
|
-
|
|
40
|
-
// src/enums/transaction.enums.ts
|
|
41
|
-
var TRANSACTION_FLOW = {
|
|
42
|
-
INFLOW: "inflow",
|
|
43
|
-
OUTFLOW: "outflow"
|
|
44
|
-
};
|
|
45
|
-
var TRANSACTION_FLOW_VALUES = Object.values(
|
|
46
|
-
TRANSACTION_FLOW
|
|
47
|
-
);
|
|
48
|
-
var TRANSACTION_STATUS = {
|
|
49
|
-
PENDING: "pending",
|
|
50
|
-
PAYMENT_INITIATED: "payment_initiated",
|
|
51
|
-
PROCESSING: "processing",
|
|
52
|
-
REQUIRES_ACTION: "requires_action",
|
|
53
|
-
VERIFIED: "verified",
|
|
54
|
-
COMPLETED: "completed",
|
|
55
|
-
FAILED: "failed",
|
|
56
|
-
CANCELLED: "cancelled",
|
|
57
|
-
EXPIRED: "expired",
|
|
58
|
-
REFUNDED: "refunded",
|
|
59
|
-
PARTIALLY_REFUNDED: "partially_refunded"
|
|
60
|
-
};
|
|
61
|
-
var TRANSACTION_STATUS_VALUES = Object.values(
|
|
62
|
-
TRANSACTION_STATUS
|
|
63
|
-
);
|
|
64
|
-
var LIBRARY_CATEGORIES = {
|
|
65
|
-
SUBSCRIPTION: "subscription",
|
|
66
|
-
PURCHASE: "purchase"
|
|
67
|
-
};
|
|
68
|
-
var LIBRARY_CATEGORY_VALUES = Object.values(
|
|
69
|
-
LIBRARY_CATEGORIES
|
|
70
|
-
);
|
|
71
|
-
new Set(TRANSACTION_FLOW_VALUES);
|
|
72
|
-
new Set(
|
|
73
|
-
TRANSACTION_STATUS_VALUES
|
|
74
|
-
);
|
|
75
|
-
new Set(LIBRARY_CATEGORY_VALUES);
|
|
76
|
-
|
|
77
|
-
// src/enums/payment.enums.ts
|
|
78
|
-
var PAYMENT_STATUS = {
|
|
79
|
-
PENDING: "pending",
|
|
80
|
-
VERIFIED: "verified",
|
|
81
|
-
FAILED: "failed",
|
|
82
|
-
REFUNDED: "refunded",
|
|
83
|
-
CANCELLED: "cancelled"
|
|
84
|
-
};
|
|
85
|
-
var PAYMENT_STATUS_VALUES = Object.values(
|
|
86
|
-
PAYMENT_STATUS
|
|
87
|
-
);
|
|
88
|
-
var PAYMENT_GATEWAY_TYPE = {
|
|
89
|
-
MANUAL: "manual",
|
|
90
|
-
STRIPE: "stripe",
|
|
91
|
-
SSLCOMMERZ: "sslcommerz"
|
|
92
|
-
};
|
|
93
|
-
var PAYMENT_GATEWAY_TYPE_VALUES = Object.values(
|
|
94
|
-
PAYMENT_GATEWAY_TYPE
|
|
95
|
-
);
|
|
96
|
-
new Set(PAYMENT_STATUS_VALUES);
|
|
97
|
-
new Set(
|
|
98
|
-
PAYMENT_GATEWAY_TYPE_VALUES
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// src/enums/subscription.enums.ts
|
|
102
|
-
var SUBSCRIPTION_STATUS = {
|
|
103
|
-
ACTIVE: "active",
|
|
104
|
-
PAUSED: "paused",
|
|
105
|
-
CANCELLED: "cancelled",
|
|
106
|
-
EXPIRED: "expired",
|
|
107
|
-
PENDING: "pending",
|
|
108
|
-
PENDING_RENEWAL: "pending_renewal",
|
|
109
|
-
INACTIVE: "inactive"
|
|
110
|
-
};
|
|
111
|
-
var SUBSCRIPTION_STATUS_VALUES = Object.values(
|
|
112
|
-
SUBSCRIPTION_STATUS
|
|
113
|
-
);
|
|
114
|
-
var PLAN_KEYS = {
|
|
115
|
-
MONTHLY: "monthly",
|
|
116
|
-
QUARTERLY: "quarterly",
|
|
117
|
-
YEARLY: "yearly"
|
|
118
|
-
};
|
|
119
|
-
var PLAN_KEY_VALUES = Object.values(PLAN_KEYS);
|
|
120
|
-
new Set(
|
|
121
|
-
SUBSCRIPTION_STATUS_VALUES
|
|
122
|
-
);
|
|
123
|
-
new Set(PLAN_KEY_VALUES);
|
|
124
|
-
|
|
125
|
-
// src/enums/monetization.enums.ts
|
|
126
|
-
var MONETIZATION_TYPES = {
|
|
127
|
-
FREE: "free",
|
|
128
|
-
PURCHASE: "purchase",
|
|
129
|
-
SUBSCRIPTION: "subscription"
|
|
130
|
-
};
|
|
131
|
-
var MONETIZATION_TYPE_VALUES = Object.values(
|
|
132
|
-
MONETIZATION_TYPES
|
|
133
|
-
);
|
|
134
|
-
new Set(MONETIZATION_TYPE_VALUES);
|
|
135
|
-
|
|
136
|
-
// src/enums/escrow.enums.ts
|
|
137
|
-
var HOLD_STATUS = {
|
|
138
|
-
PENDING: "pending",
|
|
139
|
-
HELD: "held",
|
|
140
|
-
RELEASED: "released",
|
|
141
|
-
CANCELLED: "cancelled",
|
|
142
|
-
EXPIRED: "expired",
|
|
143
|
-
PARTIALLY_RELEASED: "partially_released"
|
|
144
|
-
};
|
|
145
|
-
var HOLD_STATUS_VALUES = Object.values(HOLD_STATUS);
|
|
146
|
-
var RELEASE_REASON = {
|
|
147
|
-
PAYMENT_VERIFIED: "payment_verified",
|
|
148
|
-
MANUAL_RELEASE: "manual_release",
|
|
149
|
-
AUTO_RELEASE: "auto_release",
|
|
150
|
-
DISPUTE_RESOLVED: "dispute_resolved"
|
|
151
|
-
};
|
|
152
|
-
var RELEASE_REASON_VALUES = Object.values(
|
|
153
|
-
RELEASE_REASON
|
|
154
|
-
);
|
|
155
|
-
var HOLD_REASON = {
|
|
156
|
-
PAYMENT_VERIFICATION: "payment_verification",
|
|
157
|
-
FRAUD_CHECK: "fraud_check",
|
|
158
|
-
MANUAL_REVIEW: "manual_review",
|
|
159
|
-
DISPUTE: "dispute",
|
|
160
|
-
COMPLIANCE: "compliance"
|
|
161
|
-
};
|
|
162
|
-
var HOLD_REASON_VALUES = Object.values(HOLD_REASON);
|
|
163
|
-
new Set(HOLD_STATUS_VALUES);
|
|
164
|
-
new Set(RELEASE_REASON_VALUES);
|
|
165
|
-
new Set(HOLD_REASON_VALUES);
|
|
166
|
-
|
|
167
|
-
// src/enums/split.enums.ts
|
|
168
|
-
var SPLIT_TYPE = {
|
|
169
|
-
PLATFORM_COMMISSION: "platform_commission",
|
|
170
|
-
AFFILIATE_COMMISSION: "affiliate_commission",
|
|
171
|
-
REFERRAL_COMMISSION: "referral_commission",
|
|
172
|
-
PARTNER_COMMISSION: "partner_commission",
|
|
173
|
-
CUSTOM: "custom"
|
|
174
|
-
};
|
|
175
|
-
var SPLIT_TYPE_VALUES = Object.values(SPLIT_TYPE);
|
|
176
|
-
var SPLIT_STATUS = {
|
|
177
|
-
PENDING: "pending",
|
|
178
|
-
DUE: "due",
|
|
179
|
-
PAID: "paid",
|
|
180
|
-
WAIVED: "waived",
|
|
181
|
-
CANCELLED: "cancelled"
|
|
182
|
-
};
|
|
183
|
-
var SPLIT_STATUS_VALUES = Object.values(
|
|
184
|
-
SPLIT_STATUS
|
|
185
|
-
);
|
|
186
|
-
var PAYOUT_METHOD = {
|
|
187
|
-
BANK_TRANSFER: "bank_transfer",
|
|
188
|
-
MOBILE_WALLET: "mobile_wallet",
|
|
189
|
-
PLATFORM_BALANCE: "platform_balance",
|
|
190
|
-
CRYPTO: "crypto",
|
|
191
|
-
CHECK: "check",
|
|
192
|
-
MANUAL: "manual"
|
|
193
|
-
};
|
|
194
|
-
var PAYOUT_METHOD_VALUES = Object.values(PAYOUT_METHOD);
|
|
195
|
-
new Set(SPLIT_TYPE_VALUES);
|
|
196
|
-
new Set(SPLIT_STATUS_VALUES);
|
|
197
|
-
new Set(PAYOUT_METHOD_VALUES);
|
|
198
|
-
|
|
199
|
-
// src/enums/settlement.enums.ts
|
|
200
|
-
var SETTLEMENT_STATUS = {
|
|
201
|
-
PENDING: "pending",
|
|
202
|
-
PROCESSING: "processing",
|
|
203
|
-
COMPLETED: "completed",
|
|
204
|
-
FAILED: "failed",
|
|
205
|
-
CANCELLED: "cancelled"
|
|
206
|
-
};
|
|
207
|
-
var SETTLEMENT_STATUS_VALUES = Object.values(SETTLEMENT_STATUS);
|
|
208
|
-
var SETTLEMENT_TYPE = {
|
|
209
|
-
SPLIT_PAYOUT: "split_payout",
|
|
210
|
-
// Payout to split recipient (vendor/affiliate)
|
|
211
|
-
PLATFORM_WITHDRAWAL: "platform_withdrawal",
|
|
212
|
-
// Platform withdraws commission
|
|
213
|
-
MANUAL_PAYOUT: "manual_payout",
|
|
214
|
-
// Manual vendor payout
|
|
215
|
-
ESCROW_RELEASE: "escrow_release"
|
|
216
|
-
// Release from escrow hold
|
|
217
|
-
};
|
|
218
|
-
var SETTLEMENT_TYPE_VALUES = Object.values(SETTLEMENT_TYPE);
|
|
219
|
-
|
|
220
|
-
// src/schemas/transaction/payment.schema.ts
|
|
221
|
-
var paymentEntrySchema = new Schema(
|
|
222
|
-
{
|
|
223
|
-
method: {
|
|
224
|
-
type: String,
|
|
225
|
-
required: true
|
|
226
|
-
},
|
|
227
|
-
amount: {
|
|
228
|
-
type: Number,
|
|
229
|
-
required: true,
|
|
230
|
-
min: 0
|
|
231
|
-
},
|
|
232
|
-
reference: {
|
|
233
|
-
type: String,
|
|
234
|
-
trim: true
|
|
235
|
-
},
|
|
236
|
-
details: {
|
|
237
|
-
type: Schema.Types.Mixed
|
|
238
|
-
// For method-specific data: walletNumber, bankName, trxId, etc.
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
{ _id: false }
|
|
242
|
-
);
|
|
243
|
-
var currentPaymentSchema = new Schema(
|
|
244
|
-
{
|
|
245
|
-
transactionId: {
|
|
246
|
-
type: Schema.Types.ObjectId,
|
|
247
|
-
ref: "Transaction"
|
|
248
|
-
},
|
|
249
|
-
amount: {
|
|
250
|
-
type: Number,
|
|
251
|
-
min: 0
|
|
252
|
-
// Total amount (sum of all payments for split payments)
|
|
253
|
-
},
|
|
254
|
-
status: {
|
|
255
|
-
type: String,
|
|
256
|
-
enum: PAYMENT_STATUS_VALUES,
|
|
257
|
-
default: "pending"
|
|
258
|
-
},
|
|
259
|
-
method: {
|
|
260
|
-
type: String
|
|
261
|
-
// Primary method for single payments, or 'split' when multiple methods
|
|
262
|
-
},
|
|
263
|
-
reference: {
|
|
264
|
-
type: String,
|
|
265
|
-
trim: true
|
|
266
|
-
},
|
|
267
|
-
// Split payments support - array of individual payment entries
|
|
268
|
-
payments: {
|
|
269
|
-
type: [paymentEntrySchema],
|
|
270
|
-
default: void 0
|
|
271
|
-
// Not set for single payments (backward compat)
|
|
272
|
-
},
|
|
273
|
-
verifiedAt: {
|
|
274
|
-
type: Date
|
|
275
|
-
},
|
|
276
|
-
verifiedBy: {
|
|
277
|
-
type: Schema.Types.ObjectId,
|
|
278
|
-
ref: "User"
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
{ _id: false }
|
|
282
|
-
);
|
|
283
|
-
var paymentSummarySchema = new Schema(
|
|
284
|
-
{
|
|
285
|
-
totalPayments: {
|
|
286
|
-
type: Number,
|
|
287
|
-
default: 0,
|
|
288
|
-
min: 0
|
|
289
|
-
},
|
|
290
|
-
totalAmountPaid: {
|
|
291
|
-
type: Number,
|
|
292
|
-
default: 0,
|
|
293
|
-
min: 0
|
|
294
|
-
},
|
|
295
|
-
lastPaymentDate: {
|
|
296
|
-
type: Date
|
|
297
|
-
},
|
|
298
|
-
lastPaymentAmount: {
|
|
299
|
-
type: Number,
|
|
300
|
-
min: 0
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
{ _id: false }
|
|
304
|
-
);
|
|
305
|
-
var paymentDetailsSchema = new Schema(
|
|
306
|
-
{
|
|
307
|
-
provider: { type: String },
|
|
308
|
-
walletNumber: { type: String },
|
|
309
|
-
walletType: { type: String },
|
|
310
|
-
trxId: { type: String },
|
|
311
|
-
bankName: { type: String },
|
|
312
|
-
accountNumber: { type: String },
|
|
313
|
-
accountName: { type: String },
|
|
314
|
-
proofUrl: { type: String }
|
|
315
|
-
},
|
|
316
|
-
{ _id: false }
|
|
317
|
-
);
|
|
318
|
-
var tenantSnapshotSchema = new Schema(
|
|
319
|
-
{
|
|
320
|
-
paymentInstructions: { type: String },
|
|
321
|
-
bkashNumber: { type: String },
|
|
322
|
-
nagadNumber: { type: String },
|
|
323
|
-
bankAccount: { type: String }
|
|
324
|
-
},
|
|
325
|
-
{ _id: false }
|
|
326
|
-
);
|
|
327
|
-
var payment_schema_default = {
|
|
328
|
-
paymentEntrySchema,
|
|
329
|
-
currentPaymentSchema,
|
|
330
|
-
paymentSummarySchema,
|
|
331
|
-
paymentDetailsSchema,
|
|
332
|
-
tenantSnapshotSchema
|
|
333
|
-
};
|
|
334
|
-
var commissionSchema = new Schema(
|
|
335
|
-
{
|
|
336
|
-
// Commission rate (e.g., 0.10 for 10%)
|
|
337
|
-
rate: {
|
|
338
|
-
type: Number,
|
|
339
|
-
min: 0,
|
|
340
|
-
max: 1
|
|
341
|
-
},
|
|
342
|
-
// Gross commission amount (before gateway fees)
|
|
343
|
-
grossAmount: {
|
|
344
|
-
type: Number,
|
|
345
|
-
min: 0
|
|
346
|
-
},
|
|
347
|
-
// Gateway fee rate (e.g., 0.029 for 2.9%)
|
|
348
|
-
gatewayFeeRate: {
|
|
349
|
-
type: Number,
|
|
350
|
-
min: 0,
|
|
351
|
-
max: 1
|
|
352
|
-
},
|
|
353
|
-
// Gateway fee amount deducted from commission
|
|
354
|
-
gatewayFeeAmount: {
|
|
355
|
-
type: Number,
|
|
356
|
-
min: 0
|
|
357
|
-
},
|
|
358
|
-
// Net commission (grossAmount - gatewayFeeAmount)
|
|
359
|
-
netAmount: {
|
|
360
|
-
type: Number,
|
|
361
|
-
min: 0
|
|
362
|
-
},
|
|
363
|
-
// Commission status
|
|
364
|
-
status: {
|
|
365
|
-
type: String,
|
|
366
|
-
enum: ["pending", "paid", "waived", "reversed"],
|
|
367
|
-
default: "pending"
|
|
368
|
-
},
|
|
369
|
-
// For affiliate tracking
|
|
370
|
-
affiliate: {
|
|
371
|
-
recipientId: String,
|
|
372
|
-
recipientType: {
|
|
373
|
-
type: String,
|
|
374
|
-
enum: ["user", "organization", "partner"]
|
|
375
|
-
},
|
|
376
|
-
rate: Number,
|
|
377
|
-
grossAmount: Number,
|
|
378
|
-
netAmount: Number
|
|
379
|
-
},
|
|
380
|
-
// For multi-party splits
|
|
381
|
-
splits: [
|
|
382
|
-
{
|
|
383
|
-
type: String,
|
|
384
|
-
recipientId: String,
|
|
385
|
-
rate: Number,
|
|
386
|
-
grossAmount: Number,
|
|
387
|
-
netAmount: Number
|
|
388
|
-
}
|
|
389
|
-
]
|
|
390
|
-
},
|
|
391
|
-
{ _id: false }
|
|
392
|
-
);
|
|
393
|
-
var commission_schema_default = commissionSchema;
|
|
394
|
-
var taxBreakdownSchema = new Schema({
|
|
395
|
-
/** Is tax applicable for this transaction? */
|
|
396
|
-
isApplicable: {
|
|
397
|
-
type: Boolean,
|
|
398
|
-
default: false
|
|
399
|
-
},
|
|
400
|
-
/** Tax rate used (0-1, e.g., 0.15 = 15%) */
|
|
401
|
-
rate: {
|
|
402
|
-
type: Number,
|
|
403
|
-
default: 0,
|
|
404
|
-
min: 0,
|
|
405
|
-
max: 1
|
|
406
|
-
},
|
|
407
|
-
/** Base amount (before tax) */
|
|
408
|
-
baseAmount: {
|
|
409
|
-
type: Number,
|
|
410
|
-
default: 0,
|
|
411
|
-
min: 0
|
|
412
|
-
},
|
|
413
|
-
/** Tax amount */
|
|
414
|
-
taxAmount: {
|
|
415
|
-
type: Number,
|
|
416
|
-
default: 0,
|
|
417
|
-
min: 0
|
|
418
|
-
},
|
|
419
|
-
/** Total amount (base + tax) */
|
|
420
|
-
totalAmount: {
|
|
421
|
-
type: Number,
|
|
422
|
-
default: 0,
|
|
423
|
-
min: 0
|
|
424
|
-
},
|
|
425
|
-
/** Were prices tax-inclusive? */
|
|
426
|
-
pricesIncludeTax: {
|
|
427
|
-
type: Boolean
|
|
428
|
-
},
|
|
429
|
-
/** Tax type: collected (revenue), paid (expense), or exempt */
|
|
430
|
-
type: {
|
|
431
|
-
type: String,
|
|
432
|
-
enum: ["collected", "paid", "exempt"]
|
|
433
|
-
}
|
|
434
|
-
}, { _id: false });
|
|
435
|
-
var tax_schema_default = taxBreakdownSchema;
|
|
436
|
-
|
|
437
|
-
// src/schemas/transaction/index.ts
|
|
438
|
-
var transaction_default = {
|
|
439
|
-
baseMetadataSchema,
|
|
440
|
-
gatewaySchema: gateway_schema_default,
|
|
441
|
-
commissionSchema: commission_schema_default,
|
|
442
|
-
taxBreakdownSchema: tax_schema_default,
|
|
443
|
-
...payment_schema_default
|
|
444
|
-
};
|
|
445
|
-
var planSchema = new Schema(
|
|
446
|
-
{
|
|
447
|
-
key: {
|
|
448
|
-
type: String,
|
|
449
|
-
enum: PLAN_KEY_VALUES,
|
|
450
|
-
required: true
|
|
451
|
-
},
|
|
452
|
-
name: {
|
|
453
|
-
type: String,
|
|
454
|
-
required: true
|
|
455
|
-
},
|
|
456
|
-
description: {
|
|
457
|
-
type: String
|
|
458
|
-
},
|
|
459
|
-
amount: {
|
|
460
|
-
type: Number,
|
|
461
|
-
required: true,
|
|
462
|
-
min: 0
|
|
463
|
-
},
|
|
464
|
-
currency: {
|
|
465
|
-
type: String,
|
|
466
|
-
default: "BDT"
|
|
467
|
-
},
|
|
468
|
-
interval: {
|
|
469
|
-
type: String,
|
|
470
|
-
enum: ["day", "week", "month", "year"],
|
|
471
|
-
default: "month"
|
|
472
|
-
},
|
|
473
|
-
intervalCount: {
|
|
474
|
-
type: Number,
|
|
475
|
-
default: 1,
|
|
476
|
-
min: 1
|
|
477
|
-
},
|
|
478
|
-
features: [
|
|
479
|
-
{
|
|
480
|
-
type: String
|
|
481
|
-
}
|
|
482
|
-
],
|
|
483
|
-
metadata: {
|
|
484
|
-
type: Schema.Types.Mixed,
|
|
485
|
-
default: {}
|
|
486
|
-
},
|
|
487
|
-
isActive: {
|
|
488
|
-
type: Boolean,
|
|
489
|
-
default: true
|
|
490
|
-
}
|
|
491
|
-
},
|
|
492
|
-
{ _id: false }
|
|
493
|
-
);
|
|
494
|
-
var plan_schema_default = planSchema;
|
|
495
|
-
var subscriptionInfoSchema = new Schema(
|
|
496
|
-
{
|
|
497
|
-
planKey: {
|
|
498
|
-
type: String,
|
|
499
|
-
enum: PLAN_KEY_VALUES,
|
|
500
|
-
required: true
|
|
501
|
-
},
|
|
502
|
-
status: {
|
|
503
|
-
type: String,
|
|
504
|
-
enum: SUBSCRIPTION_STATUS_VALUES,
|
|
505
|
-
default: "pending"
|
|
506
|
-
},
|
|
507
|
-
isActive: {
|
|
508
|
-
type: Boolean,
|
|
509
|
-
default: false
|
|
510
|
-
},
|
|
511
|
-
startDate: {
|
|
512
|
-
type: Date
|
|
513
|
-
},
|
|
514
|
-
endDate: {
|
|
515
|
-
type: Date
|
|
516
|
-
},
|
|
517
|
-
canceledAt: {
|
|
518
|
-
type: Date
|
|
519
|
-
},
|
|
520
|
-
cancelAt: {
|
|
521
|
-
type: Date
|
|
522
|
-
},
|
|
523
|
-
pausedAt: {
|
|
524
|
-
type: Date
|
|
525
|
-
},
|
|
526
|
-
lastPaymentDate: {
|
|
527
|
-
type: Date
|
|
528
|
-
},
|
|
529
|
-
lastPaymentAmount: {
|
|
530
|
-
type: Number
|
|
531
|
-
},
|
|
532
|
-
renewalCount: {
|
|
533
|
-
type: Number,
|
|
534
|
-
default: 0
|
|
535
|
-
}
|
|
536
|
-
},
|
|
537
|
-
{ _id: false }
|
|
538
|
-
);
|
|
539
|
-
var info_schema_default = subscriptionInfoSchema;
|
|
540
|
-
|
|
541
|
-
// src/schemas/subscription/index.ts
|
|
542
|
-
var subscription_default = {
|
|
543
|
-
planSchema: plan_schema_default,
|
|
544
|
-
subscriptionInfoSchema: info_schema_default
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
// src/schemas/escrow/hold.schema.ts
|
|
548
|
-
var holdSchema = {
|
|
549
|
-
status: {
|
|
550
|
-
type: String,
|
|
551
|
-
enum: HOLD_STATUS_VALUES,
|
|
552
|
-
default: HOLD_STATUS.PENDING
|
|
553
|
-
},
|
|
554
|
-
heldAmount: {
|
|
555
|
-
type: Number,
|
|
556
|
-
required: false
|
|
557
|
-
},
|
|
558
|
-
releasedAmount: {
|
|
559
|
-
type: Number,
|
|
560
|
-
default: 0
|
|
561
|
-
},
|
|
562
|
-
reason: {
|
|
563
|
-
type: String,
|
|
564
|
-
enum: HOLD_REASON_VALUES,
|
|
565
|
-
required: false
|
|
566
|
-
},
|
|
567
|
-
holdUntil: {
|
|
568
|
-
type: Date,
|
|
569
|
-
required: false
|
|
570
|
-
},
|
|
571
|
-
heldAt: Date,
|
|
572
|
-
releasedAt: Date,
|
|
573
|
-
cancelledAt: Date,
|
|
574
|
-
releases: [
|
|
575
|
-
{
|
|
576
|
-
amount: Number,
|
|
577
|
-
recipientId: String,
|
|
578
|
-
recipientType: String,
|
|
579
|
-
releasedAt: Date,
|
|
580
|
-
releasedBy: String,
|
|
581
|
-
reason: String,
|
|
582
|
-
metadata: Object
|
|
583
|
-
}
|
|
584
|
-
],
|
|
585
|
-
metadata: {
|
|
586
|
-
type: Object,
|
|
587
|
-
default: {}
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
var hold_schema_default = holdSchema;
|
|
591
|
-
|
|
592
|
-
// src/schemas/escrow/index.ts
|
|
593
|
-
var escrow_default = {
|
|
594
|
-
holdSchema: hold_schema_default
|
|
595
|
-
};
|
|
596
|
-
var splitSchema = new Schema(
|
|
597
|
-
{
|
|
598
|
-
type: {
|
|
599
|
-
type: String,
|
|
600
|
-
enum: SPLIT_TYPE_VALUES,
|
|
601
|
-
required: true
|
|
602
|
-
},
|
|
603
|
-
recipientId: {
|
|
604
|
-
type: String,
|
|
605
|
-
required: true
|
|
606
|
-
},
|
|
607
|
-
recipientType: {
|
|
608
|
-
type: String,
|
|
609
|
-
enum: ["platform", "organization", "user", "affiliate", "partner"],
|
|
610
|
-
required: true
|
|
611
|
-
},
|
|
612
|
-
rate: {
|
|
613
|
-
type: Number,
|
|
614
|
-
required: true,
|
|
615
|
-
min: 0,
|
|
616
|
-
max: 1
|
|
617
|
-
},
|
|
618
|
-
grossAmount: {
|
|
619
|
-
type: Number,
|
|
620
|
-
required: true,
|
|
621
|
-
min: 0
|
|
622
|
-
},
|
|
623
|
-
gatewayFeeRate: {
|
|
624
|
-
type: Number,
|
|
625
|
-
default: 0,
|
|
626
|
-
min: 0,
|
|
627
|
-
max: 1
|
|
628
|
-
},
|
|
629
|
-
gatewayFeeAmount: {
|
|
630
|
-
type: Number,
|
|
631
|
-
default: 0,
|
|
632
|
-
min: 0
|
|
633
|
-
},
|
|
634
|
-
netAmount: {
|
|
635
|
-
type: Number,
|
|
636
|
-
required: true,
|
|
637
|
-
min: 0
|
|
638
|
-
},
|
|
639
|
-
status: {
|
|
640
|
-
type: String,
|
|
641
|
-
enum: SPLIT_STATUS_VALUES,
|
|
642
|
-
default: SPLIT_STATUS.PENDING
|
|
643
|
-
},
|
|
644
|
-
dueDate: {
|
|
645
|
-
type: Date
|
|
646
|
-
},
|
|
647
|
-
paidDate: {
|
|
648
|
-
type: Date
|
|
649
|
-
},
|
|
650
|
-
payoutMethod: {
|
|
651
|
-
type: String,
|
|
652
|
-
enum: PAYOUT_METHOD_VALUES
|
|
653
|
-
},
|
|
654
|
-
payoutTransactionId: {
|
|
655
|
-
type: String
|
|
656
|
-
},
|
|
657
|
-
metadata: {
|
|
658
|
-
type: Schema.Types.Mixed,
|
|
659
|
-
default: {}
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
{ _id: false }
|
|
663
|
-
);
|
|
664
|
-
var split_schema_default = splitSchema;
|
|
665
|
-
|
|
666
|
-
// src/schemas/split/index.ts
|
|
667
|
-
var split_default = {
|
|
668
|
-
splitSchema: split_schema_default
|
|
669
|
-
};
|
|
670
|
-
var settlementSchema = new Schema({
|
|
671
|
-
// ============ IDENTIFICATION ============
|
|
672
|
-
organizationId: {
|
|
673
|
-
type: Schema.Types.ObjectId,
|
|
674
|
-
required: true,
|
|
675
|
-
index: true
|
|
676
|
-
// The organization responsible for this payout
|
|
677
|
-
},
|
|
678
|
-
recipientId: {
|
|
679
|
-
type: Schema.Types.ObjectId,
|
|
680
|
-
required: true,
|
|
681
|
-
index: true
|
|
682
|
-
// Who receives the payout (vendor, affiliate, partner)
|
|
683
|
-
},
|
|
684
|
-
recipientType: {
|
|
685
|
-
type: String,
|
|
686
|
-
enum: ["platform", "organization", "user", "affiliate", "partner"],
|
|
687
|
-
required: true
|
|
688
|
-
// Type of recipient
|
|
689
|
-
},
|
|
690
|
-
// ============ CLASSIFICATION ============
|
|
691
|
-
type: {
|
|
692
|
-
type: String,
|
|
693
|
-
enum: SETTLEMENT_TYPE_VALUES,
|
|
694
|
-
required: true
|
|
695
|
-
// split_payout | platform_withdrawal | manual_payout | escrow_release
|
|
696
|
-
},
|
|
697
|
-
status: {
|
|
698
|
-
type: String,
|
|
699
|
-
enum: SETTLEMENT_STATUS_VALUES,
|
|
700
|
-
default: "pending",
|
|
701
|
-
index: true
|
|
702
|
-
// pending | processing | completed | failed | cancelled
|
|
703
|
-
},
|
|
704
|
-
payoutMethod: {
|
|
705
|
-
type: String,
|
|
706
|
-
enum: PAYOUT_METHOD_VALUES,
|
|
707
|
-
required: true
|
|
708
|
-
// bank_transfer | mobile_wallet | platform_balance | crypto | manual
|
|
709
|
-
},
|
|
710
|
-
// ============ AMOUNT ============
|
|
711
|
-
amount: {
|
|
712
|
-
type: Number,
|
|
713
|
-
required: true,
|
|
714
|
-
min: 0
|
|
715
|
-
// Amount in smallest currency unit (cents, paisa, etc.)
|
|
716
|
-
},
|
|
717
|
-
currency: {
|
|
718
|
-
type: String,
|
|
719
|
-
required: true,
|
|
720
|
-
default: "USD"
|
|
721
|
-
// ISO 4217 currency code
|
|
722
|
-
},
|
|
723
|
-
// ============ SOURCE LINKAGE ============
|
|
724
|
-
sourceTransactionIds: [{
|
|
725
|
-
type: Schema.Types.ObjectId,
|
|
726
|
-
ref: "Transaction"
|
|
727
|
-
// Transactions this settlement pays out from
|
|
728
|
-
}],
|
|
729
|
-
sourceSplitIds: [{
|
|
730
|
-
type: String
|
|
731
|
-
// Split IDs within transactions (if applicable)
|
|
732
|
-
}],
|
|
733
|
-
// ============ BANK TRANSFER DETAILS ============
|
|
734
|
-
bankTransferDetails: {
|
|
735
|
-
accountNumber: { type: String },
|
|
736
|
-
accountName: { type: String },
|
|
737
|
-
bankName: { type: String },
|
|
738
|
-
routingNumber: { type: String },
|
|
739
|
-
swiftCode: { type: String },
|
|
740
|
-
iban: { type: String },
|
|
741
|
-
transferReference: { type: String },
|
|
742
|
-
// Bank confirmation reference
|
|
743
|
-
transferredAt: { type: Date }
|
|
744
|
-
},
|
|
745
|
-
// ============ MOBILE WALLET DETAILS ============
|
|
746
|
-
mobileWalletDetails: {
|
|
747
|
-
provider: { type: String },
|
|
748
|
-
// bKash, Nagad, Rocket, etc.
|
|
749
|
-
phoneNumber: { type: String },
|
|
750
|
-
accountNumber: { type: String },
|
|
751
|
-
// Wallet account number
|
|
752
|
-
transactionId: { type: String },
|
|
753
|
-
// Provider transaction ID
|
|
754
|
-
transferredAt: { type: Date }
|
|
755
|
-
},
|
|
756
|
-
// ============ CRYPTO DETAILS ============
|
|
757
|
-
cryptoDetails: {
|
|
758
|
-
network: { type: String },
|
|
759
|
-
// Ethereum, Bitcoin, etc.
|
|
760
|
-
walletAddress: { type: String },
|
|
761
|
-
transactionHash: { type: String },
|
|
762
|
-
transferredAt: { type: Date }
|
|
763
|
-
},
|
|
764
|
-
// ============ PLATFORM BALANCE ============
|
|
765
|
-
platformBalanceDetails: {
|
|
766
|
-
balanceId: { type: Schema.Types.ObjectId },
|
|
767
|
-
// Reference to balance record
|
|
768
|
-
appliedAt: { type: Date }
|
|
769
|
-
},
|
|
770
|
-
// ============ DATES ============
|
|
771
|
-
scheduledAt: {
|
|
772
|
-
type: Date,
|
|
773
|
-
index: true
|
|
774
|
-
// When this payout is scheduled for
|
|
775
|
-
},
|
|
776
|
-
processedAt: {
|
|
777
|
-
type: Date
|
|
778
|
-
// When processing started
|
|
779
|
-
},
|
|
780
|
-
completedAt: {
|
|
781
|
-
type: Date
|
|
782
|
-
// When successfully completed
|
|
783
|
-
},
|
|
784
|
-
failedAt: {
|
|
785
|
-
type: Date
|
|
786
|
-
// When it failed
|
|
787
|
-
},
|
|
788
|
-
cancelledAt: {
|
|
789
|
-
type: Date
|
|
790
|
-
// When it was cancelled
|
|
791
|
-
},
|
|
792
|
-
// ============ FAILURE INFO ============
|
|
793
|
-
failureReason: {
|
|
794
|
-
type: String
|
|
795
|
-
// Human-readable failure reason
|
|
796
|
-
},
|
|
797
|
-
failureCode: {
|
|
798
|
-
type: String
|
|
799
|
-
// Machine-readable error code
|
|
800
|
-
},
|
|
801
|
-
retryCount: {
|
|
802
|
-
type: Number,
|
|
803
|
-
default: 0,
|
|
804
|
-
min: 0
|
|
805
|
-
// Number of retry attempts
|
|
806
|
-
},
|
|
807
|
-
// ============ NOTES & METADATA ============
|
|
808
|
-
notes: {
|
|
809
|
-
type: String
|
|
810
|
-
// Admin notes about this settlement
|
|
811
|
-
},
|
|
812
|
-
metadata: {
|
|
813
|
-
type: Schema.Types.Mixed,
|
|
814
|
-
default: {}
|
|
815
|
-
// Flexible metadata for app-specific data
|
|
816
|
-
}
|
|
817
|
-
}, {
|
|
818
|
-
timestamps: true
|
|
819
|
-
// Adds createdAt and updatedAt
|
|
820
|
-
});
|
|
821
|
-
settlementSchema.index({ organizationId: 1, status: 1 });
|
|
822
|
-
settlementSchema.index({ recipientId: 1, status: 1 });
|
|
823
|
-
settlementSchema.index({ type: 1, status: 1, scheduledAt: 1 });
|
|
824
|
-
settlementSchema.index({ sourceTransactionIds: 1 });
|
|
825
|
-
settlementSchema.index({ status: 1, scheduledAt: 1 });
|
|
826
|
-
|
|
827
|
-
// src/schemas/settlement/index.ts
|
|
828
|
-
var settlement_default = { settlementSchema };
|
|
829
|
-
|
|
830
|
-
// src/schemas/index.ts
|
|
831
|
-
var schemas_default = {
|
|
832
|
-
...transaction_default,
|
|
833
|
-
...subscription_default,
|
|
834
|
-
...escrow_default,
|
|
835
|
-
...split_default,
|
|
836
|
-
...settlement_default
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
export { baseMetadataSchema, commissionSchema, currentPaymentSchema, schemas_default as default, gatewaySchema, holdSchema, paymentDetailsSchema, paymentEntrySchema, paymentSummarySchema, planSchema, settlementSchema, splitSchema, subscriptionInfoSchema, taxBreakdownSchema, tenantSnapshotSchema };
|
|
840
|
-
//# sourceMappingURL=index.js.map
|
|
841
|
-
//# sourceMappingURL=index.js.map
|