@adaptware/eagles-db 0.6.14 → 0.6.15
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/client/edge.js +126 -7
- package/client/index-browser.js +121 -2
- package/client/index.d.ts +10773 -427
- package/client/index.js +126 -7
- package/client/package.json +1 -1
- package/client/schema.prisma +198 -0
- package/client/wasm.js +126 -7
- package/package.json +1 -1
- package/prisma/schema/integration.prisma +1 -0
- package/prisma/schema/licensing/purchasedLicense.prisma +3 -0
- package/prisma/schema/migrations/20261022120000_billing_failure_category_provider_neutral/migration.sql +28 -0
- package/prisma/schema/organisation.prisma +8 -0
- package/prisma/schema/payment/billingTransaction.prisma +87 -0
- package/prisma/schema/payment/invoice.prisma +68 -0
- package/prisma/schema/payment/paymentWebhookEvent.prisma +28 -0
- package/prisma/.DS_Store +0 -0
- package/prisma/schema/migrations/.DS_Store +0 -0
package/client/package.json
CHANGED
package/client/schema.prisma
CHANGED
|
@@ -2031,6 +2031,7 @@ enum IntegrationProvider {
|
|
|
2031
2031
|
MICROSOFT
|
|
2032
2032
|
ZOOM
|
|
2033
2033
|
CALENDLY
|
|
2034
|
+
RAZORPAY
|
|
2034
2035
|
|
|
2035
2036
|
@@schema("public")
|
|
2036
2037
|
}
|
|
@@ -3201,9 +3202,12 @@ model PurchasedLicensePackage {
|
|
|
3201
3202
|
created_by String
|
|
3202
3203
|
updated_by String
|
|
3203
3204
|
is_active Boolean @default(true)
|
|
3205
|
+
/// Tax invoice for a paid or zero-amount purchase. Null = Super Admin grant (no invoice).
|
|
3206
|
+
invoice_id String? @unique
|
|
3204
3207
|
|
|
3205
3208
|
organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3206
3209
|
license_package LicensePackage @relation(fields: [license_package_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3210
|
+
invoice Invoice? @relation(fields: [invoice_id], references: [id], onDelete: Restrict)
|
|
3207
3211
|
hiring_units PurchasedHiringUnit[]
|
|
3208
3212
|
|
|
3209
3213
|
@@index([organisation_id])
|
|
@@ -3845,6 +3849,11 @@ model Organisation {
|
|
|
3845
3849
|
timezone String @default("Asia/Kolkata")
|
|
3846
3850
|
/// ISO 3166-1 alpha-2 (e.g. IN).
|
|
3847
3851
|
country_code String @default("IN")
|
|
3852
|
+
/// Customer GSTIN; first 2 digits give the state for the CGST/SGST vs IGST split.
|
|
3853
|
+
/// Optional: an Indian org without one is still charged GST.
|
|
3854
|
+
gstin String?
|
|
3855
|
+
/// Currency the organisation is billed in (INR or USD). Catalogue and checkout use only packages in this currency.
|
|
3856
|
+
billing_currency String @default("INR")
|
|
3848
3857
|
/// Who may consume unused hiring units. Does not rewrite unit rows when changed.
|
|
3849
3858
|
hiring_unit_assignment_scope HiringUnitAssignmentScope @default(DEPARTMENT)
|
|
3850
3859
|
organisation_configs OrganisationConfig[]
|
|
@@ -3872,6 +3881,9 @@ model Organisation {
|
|
|
3872
3881
|
license_package_organisations LicensePackageOrganisation[]
|
|
3873
3882
|
ai_cost_ledger_entries AiCostLedgerEntry[]
|
|
3874
3883
|
consent_documents ConsentDocument[]
|
|
3884
|
+
billing_transactions BillingTransaction[]
|
|
3885
|
+
payment_webhook_events PaymentWebhookEvent[]
|
|
3886
|
+
invoices Invoice[]
|
|
3875
3887
|
|
|
3876
3888
|
@@index([name])
|
|
3877
3889
|
@@schema("public")
|
|
@@ -3891,6 +3903,192 @@ model OrganisationConfig {
|
|
|
3891
3903
|
@@schema("public")
|
|
3892
3904
|
}
|
|
3893
3905
|
|
|
3906
|
+
// PAYMENT SERVICE boundary — portable payment microservice owns these enums/columns.
|
|
3907
|
+
|
|
3908
|
+
enum BillingTransactionStatus {
|
|
3909
|
+
INITIATED
|
|
3910
|
+
ORDER_CREATED
|
|
3911
|
+
PAYMENT_PENDING
|
|
3912
|
+
SUCCESS
|
|
3913
|
+
FAILED
|
|
3914
|
+
CANCELLED
|
|
3915
|
+
REFUND_PENDING
|
|
3916
|
+
REFUND_FAILED
|
|
3917
|
+
REFUNDED
|
|
3918
|
+
|
|
3919
|
+
@@schema("public")
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
enum BillingTransactionType {
|
|
3923
|
+
PURCHASE
|
|
3924
|
+
TOP_UP
|
|
3925
|
+
REFUND
|
|
3926
|
+
|
|
3927
|
+
@@schema("public")
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
/// Provider-neutral failure stage; provider detail goes in failure_reason.
|
|
3931
|
+
enum BillingTransactionFailureCategory {
|
|
3932
|
+
ORDER
|
|
3933
|
+
PAYMENT
|
|
3934
|
+
REFUND
|
|
3935
|
+
INTERNAL
|
|
3936
|
+
|
|
3937
|
+
@@schema("public")
|
|
3938
|
+
}
|
|
3939
|
+
|
|
3940
|
+
/// Payment reconciliation state when Treadspace status is FAILED but Razorpay captured payment.
|
|
3941
|
+
enum BillingPaymentMismatchStatus {
|
|
3942
|
+
DETECTED
|
|
3943
|
+
UNFULFILLED
|
|
3944
|
+
|
|
3945
|
+
@@schema("public")
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
/// Financial transaction lifecycle for organisation billing purchases.
|
|
3949
|
+
model BillingTransaction {
|
|
3950
|
+
id String @id @default(uuid())
|
|
3951
|
+
organisation_id String
|
|
3952
|
+
/// Opaque plan/product identity supplied at checkout. Not a catalog FK.
|
|
3953
|
+
purchase_reference String
|
|
3954
|
+
/// Human-readable snapshot captured at checkout for invoices and receipts.
|
|
3955
|
+
purchase_display_name String?
|
|
3956
|
+
transaction_type BillingTransactionType
|
|
3957
|
+
status BillingTransactionStatus @default(INITIATED)
|
|
3958
|
+
failure_category BillingTransactionFailureCategory?
|
|
3959
|
+
/// Human-readable or provider detail (e.g. Razorpay error_description).
|
|
3960
|
+
failure_reason String?
|
|
3961
|
+
amount Int
|
|
3962
|
+
currency String @default("INR")
|
|
3963
|
+
razorpay_order_id String?
|
|
3964
|
+
razorpay_payment_id String? @unique
|
|
3965
|
+
/// Razorpay payment method at capture (card, netbanking, upi, wallet, etc.).
|
|
3966
|
+
payment_method String?
|
|
3967
|
+
razorpay_subscription_id String?
|
|
3968
|
+
razorpay_refund_id String?
|
|
3969
|
+
refund_reason String?
|
|
3970
|
+
refund_amount Int?
|
|
3971
|
+
idempotency_key String @unique
|
|
3972
|
+
/// Email of the org Admin who initiated checkout (bill-to).
|
|
3973
|
+
purchaser_email String?
|
|
3974
|
+
/// User id of the org Admin who started checkout; actor for fulfilment and the invoice.
|
|
3975
|
+
created_by String?
|
|
3976
|
+
/// Set when FAILED but Razorpay order/payment is captured (reconciliation path).
|
|
3977
|
+
payment_mismatch_status BillingPaymentMismatchStatus?
|
|
3978
|
+
/// Strict same-intent SUCCESS transaction that fulfilled the purchase (UNFULFILLED only).
|
|
3979
|
+
payment_mismatch_fulfilled_by_id String?
|
|
3980
|
+
created_at DateTime @default(now())
|
|
3981
|
+
updated_at DateTime @updatedAt
|
|
3982
|
+
|
|
3983
|
+
organisation Organisation @relation(fields: [organisation_id], references: [id])
|
|
3984
|
+
/// Tax invoice issued for this payment (set once fulfilled).
|
|
3985
|
+
invoice Invoice?
|
|
3986
|
+
|
|
3987
|
+
@@index([organisation_id, status])
|
|
3988
|
+
@@index([purchase_reference])
|
|
3989
|
+
@@index([razorpay_order_id])
|
|
3990
|
+
@@map("billing_transactions")
|
|
3991
|
+
@@schema("public")
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
// Tax invoices issued by Treadspace. Shared by license package purchases and (later) platform subscriptions.
|
|
3995
|
+
|
|
3996
|
+
/// What the invoice was raised for.
|
|
3997
|
+
enum InvoiceKind {
|
|
3998
|
+
PACKAGE
|
|
3999
|
+
|
|
4000
|
+
@@schema("public")
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
/// Tax invoice. Raised only after money is received (or for a zero-amount purchase). Immutable once written.
|
|
4004
|
+
/// All amounts are integer minor units (paise / cents); total = cost + tax + fee + fee_tax (not stored).
|
|
4005
|
+
model Invoice {
|
|
4006
|
+
id String @id @default(uuid())
|
|
4007
|
+
/// Sequential number, e.g. TS/26-27/000001 (at most 16 chars). The financial year is part of the number.
|
|
4008
|
+
invoice_number String @unique
|
|
4009
|
+
kind InvoiceKind
|
|
4010
|
+
organisation_id String
|
|
4011
|
+
/// Payment that funded this invoice. Null for zero-amount purchases.
|
|
4012
|
+
billing_transaction_id String? @unique
|
|
4013
|
+
currency String
|
|
4014
|
+
/// Optional line description snapshot, e.g. "Pro hiring pack (v2)".
|
|
4015
|
+
description String?
|
|
4016
|
+
quantity Int
|
|
4017
|
+
/// Net cost of the goods/service (excludes GST and processing fee).
|
|
4018
|
+
cost_amount Int
|
|
4019
|
+
/// GST on cost. 0 for non-Indian organisations.
|
|
4020
|
+
tax_amount Int
|
|
4021
|
+
/// Payment processing fee.
|
|
4022
|
+
fee_amount Int
|
|
4023
|
+
/// GST on the processing fee. 0 for non-Indian organisations.
|
|
4024
|
+
fee_tax_amount Int
|
|
4025
|
+
/// GST rate in basis points (1800 = 18%) at issue time.
|
|
4026
|
+
tax_rate_bps Int
|
|
4027
|
+
/// Processing fee rate in basis points (200 = 2%) at issue time.
|
|
4028
|
+
fee_rate_bps Int
|
|
4029
|
+
/// Buyer snapshot from the organisation at issue time.
|
|
4030
|
+
buyer_name String
|
|
4031
|
+
buyer_address String
|
|
4032
|
+
/// ISO 3166-1 alpha-2 (e.g. IN).
|
|
4033
|
+
buyer_country_code String
|
|
4034
|
+
buyer_gstin String?
|
|
4035
|
+
/// Seller snapshot at issue time: { name, gstin, address, sac }.
|
|
4036
|
+
seller_snapshot Json
|
|
4037
|
+
issued_at DateTime @default(now())
|
|
4038
|
+
created_at DateTime @default(now())
|
|
4039
|
+
/// User id that triggered the issue (checkout admin), or "system".
|
|
4040
|
+
created_by String
|
|
4041
|
+
|
|
4042
|
+
organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict)
|
|
4043
|
+
billing_transaction BillingTransaction? @relation(fields: [billing_transaction_id], references: [id], onDelete: Restrict)
|
|
4044
|
+
purchased_license_package PurchasedLicensePackage?
|
|
4045
|
+
|
|
4046
|
+
@@index([organisation_id, issued_at])
|
|
4047
|
+
@@map("invoices")
|
|
4048
|
+
@@schema("public")
|
|
4049
|
+
}
|
|
4050
|
+
|
|
4051
|
+
/// Invoice number counter: one row per financial year (e.g. "2026-27"); the key only lives here, not on Invoice.
|
|
4052
|
+
/// Incremented inside the invoice-issuing transaction: concurrent issues wait on the row lock (no duplicate
|
|
4053
|
+
/// numbers, no retries) and a rolled-back issue rolls the counter back too (no gaps).
|
|
4054
|
+
model InvoiceSequence {
|
|
4055
|
+
financial_year String @id
|
|
4056
|
+
last_sequence Int @default(0)
|
|
4057
|
+
updated_at DateTime @updatedAt
|
|
4058
|
+
|
|
4059
|
+
@@map("invoice_sequences")
|
|
4060
|
+
@@schema("public")
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4063
|
+
enum PaymentWebhookEventStatus {
|
|
4064
|
+
RECEIVED
|
|
4065
|
+
PROCESSED
|
|
4066
|
+
FAILED
|
|
4067
|
+
|
|
4068
|
+
@@schema("public")
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
/// Idempotent record of payment provider webhook deliveries.
|
|
4072
|
+
model PaymentWebhookEvent {
|
|
4073
|
+
id String @id @default(uuid())
|
|
4074
|
+
organisation_id String?
|
|
4075
|
+
provider String
|
|
4076
|
+
provider_event_id String
|
|
4077
|
+
event_type String
|
|
4078
|
+
status PaymentWebhookEventStatus @default(RECEIVED)
|
|
4079
|
+
billing_transaction_id String?
|
|
4080
|
+
error_message String?
|
|
4081
|
+
processed_at DateTime?
|
|
4082
|
+
created_at DateTime @default(now())
|
|
4083
|
+
|
|
4084
|
+
organisation Organisation? @relation(fields: [organisation_id], references: [id])
|
|
4085
|
+
|
|
4086
|
+
@@unique([provider, provider_event_id])
|
|
4087
|
+
@@index([status, created_at])
|
|
4088
|
+
@@map("payment_webhook_events")
|
|
4089
|
+
@@schema("public")
|
|
4090
|
+
}
|
|
4091
|
+
|
|
3894
4092
|
model Permission {
|
|
3895
4093
|
id String @id @default(uuid())
|
|
3896
4094
|
permissions String[] @default([])
|