@adaptware/eagles-db 0.6.14 → 0.6.16
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 +129 -8
- package/client/index-browser.js +122 -2
- package/client/index.d.ts +10875 -428
- package/client/index.js +129 -8
- package/client/libquery_engine-darwin.dylib.node +0 -0
- package/client/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
- package/client/package.json +1 -1
- package/client/query_engine-windows.dll.node +0 -0
- package/client/schema.prisma +200 -0
- package/client/wasm.js +129 -8
- package/package.json +1 -1
- package/prisma/schema/integration.prisma +1 -0
- package/prisma/schema/interview.prisma +2 -0
- package/prisma/schema/licensing/purchasedLicense.prisma +3 -0
- package/prisma/schema/migrations/20260522120000_ongoing_evaluation_record_kind/migration.sql +25 -0
- package/prisma/schema/migrations/20260523120000_replace_record_kind_with_is_committed/migration.sql +24 -0
- package/prisma/schema/migrations/20260528120000_drop_job_description_recommendation_config/migration.sql +2 -0
- package/prisma/schema/migrations/20260710120000_add_resume_rendered_export_fields/migration.sql +9 -0
- package/prisma/schema/migrations/20260714120000_add_job_description_display_html_document/migration.sql +8 -0
- package/prisma/schema/migrations/20260716120000_add_offer_letters/migration.sql +183 -0
- package/prisma/schema/migrations/20260716140000_offer_schema_refinements/migration.sql +13 -0
- package/prisma/schema/migrations/20260716160000_offer_schema_hardening/migration.sql +95 -0
- package/prisma/schema/migrations/20260716180000_offer_letter_template_config/migration.sql +2 -0
- package/prisma/schema/migrations/20260716190000_add_evaluation_focus_areas/migration.sql +6 -0
- package/prisma/schema/migrations/20260717120000_offer_workflow_approval/migration.sql +30 -0
- package/prisma/schema/migrations/20260720120000_offer_letter_template_is_draft/migration.sql +5 -0
- package/prisma/schema/migrations/20260720140000_offer_status_split/migration.sql +51 -0
- package/prisma/schema/migrations/20260720140001_offer_status_split_backfill/migration.sql +37 -0
- package/prisma/schema/migrations/20260722120000_offer_draft_edited_html/migration.sql +13 -0
- package/prisma/schema/migrations/20260723150000_offer_withdraw_actor_no_show_reason/migration.sql +10 -0
- package/prisma/schema/migrations/20260724120000_open_job_offer_accepted_declined_counts/migration.sql +7 -0
- package/prisma/schema/migrations/20260811120000_add_integration_provider_razorpay/migration.sql +6 -0
- package/prisma/schema/migrations/20260812120000_add_billing_transactions/migration.sql +49 -0
- package/prisma/schema/migrations/20260812130000_drop_billing_transaction_gst_snapshots/migration.sql +3 -0
- package/prisma/schema/migrations/20260812180000_billing_transaction_invoice_number/migration.sql +5 -0
- package/prisma/schema/migrations/20260813120000_payment_webhooks_gst_refunds/migration.sql +79 -0
- package/prisma/schema/migrations/20260813140000_platform_gst_profiles/migration.sql +49 -0
- package/prisma/schema/migrations/20260813150000_rename_gst_profiles/migration.sql +53 -0
- package/prisma/schema/migrations/20260813160000_remove_gst_billing/migration.sql +16 -0
- package/prisma/schema/migrations/20260813170000_billing_licensing_unrecoverable/migration.sql +2 -0
- package/prisma/schema/migrations/20260813180000_billing_transaction_payment_method/migration.sql +2 -0
- package/prisma/schema/migrations/20260814090000_billing_transaction_purchaser_email/migration.sql +2 -0
- package/prisma/schema/migrations/20260816100000_billing_product_organisations/migration.sql +35 -0
- package/prisma/schema/migrations/20260816120000_merge_billing_product_organisations/migration.sql +25 -0
- package/prisma/schema/migrations/20260817120000_billing_payment_mismatch/migration.sql +7 -0
- package/prisma/schema/migrations/20260819120000_billing_product_prices/migration.sql +62 -0
- package/prisma/schema/migrations/20260819140000_billing_exchange_rates/migration.sql +25 -0
- package/prisma/schema/migrations/20260820120000_billing_transaction_failure_category/migration.sql +31 -0
- package/prisma/schema/migrations/20260820130000_backfill_billing_transaction_failure_details/migration.sql +23 -0
- package/prisma/schema/migrations/20260820140000_drop_billing_product_price_overrides/migration.sql +2 -0
- package/prisma/schema/migrations/20260821120000_drop_billing_product_and_mock_licensing/migration.sql +38 -0
- package/prisma/schema/migrations/20260824120000_billing_transaction_purchase_display_name/migration.sql +2 -0
- package/prisma/schema/migrations/20260831120000_user_communication_email/migration.sql +6 -0
- package/prisma/schema/migrations/20260901143000_assessment_question_bank_state/migration.sql +15 -0
- package/prisma/schema/migrations/20260902120000_question_category_two_values/migration.sql +16 -0
- package/prisma/schema/migrations/20260902143000_question_bank_item_key/migration.sql +17 -0
- package/prisma/schema/migrations/20260903120000_split_round_type_assessment/migration.sql +9 -0
- package/prisma/schema/migrations/20260904110000_restore_round_type_assessment_enum/migration.sql +5 -0
- package/prisma/schema/migrations/20260904120000_revert_wrong_split_assessment_round_types/migration.sql +42 -0
- package/prisma/schema/migrations/20260909140000_profile_interview_session/migration.sql +99 -0
- package/prisma/schema/migrations/20260911120000_unify_profile_interview_into_interview/migration.sql +139 -0
- package/prisma/schema/migrations/20260929120000_add_evaluation_type_in_person/migration.sql +2 -0
- package/prisma/schema/migrations/20261015130000_interview_whiteboard_scene/migration.sql +2 -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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
-- CreateEnum (idempotent: enum may already exist from a prior partial apply)
|
|
2
|
+
DO $$ BEGIN
|
|
3
|
+
CREATE TYPE "public"."ProfileInterviewSessionStatus" AS ENUM (
|
|
4
|
+
'SCHEDULED',
|
|
5
|
+
'IN_PROGRESS',
|
|
6
|
+
'COMPLETED',
|
|
7
|
+
'CANCELLED'
|
|
8
|
+
);
|
|
9
|
+
EXCEPTION
|
|
10
|
+
WHEN duplicate_object THEN NULL;
|
|
11
|
+
END $$;
|
|
12
|
+
|
|
13
|
+
-- CreateTable
|
|
14
|
+
CREATE TABLE IF NOT EXISTS "public"."ProfileInterviewSession" (
|
|
15
|
+
"id" TEXT NOT NULL,
|
|
16
|
+
"candidate_id" TEXT NOT NULL,
|
|
17
|
+
"organisation_id" TEXT,
|
|
18
|
+
"resume_id" TEXT NOT NULL,
|
|
19
|
+
"job_description_id" TEXT,
|
|
20
|
+
"purpose" TEXT NOT NULL,
|
|
21
|
+
"focus_areas" JSONB NOT NULL,
|
|
22
|
+
"duration_minutes" INTEGER NOT NULL,
|
|
23
|
+
"room_name" TEXT NOT NULL,
|
|
24
|
+
"status" "public"."ProfileInterviewSessionStatus" NOT NULL DEFAULT 'SCHEDULED',
|
|
25
|
+
"actual_start_time" TIMESTAMP(3),
|
|
26
|
+
"actual_end_time" TIMESTAMP(3),
|
|
27
|
+
"evidence_result" JSONB,
|
|
28
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
29
|
+
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
30
|
+
"created_by" TEXT NOT NULL,
|
|
31
|
+
"updated_by" TEXT NOT NULL,
|
|
32
|
+
"is_active" BOOLEAN NOT NULL DEFAULT true,
|
|
33
|
+
|
|
34
|
+
CONSTRAINT "ProfileInterviewSession_pkey" PRIMARY KEY ("id")
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
-- AlterTable
|
|
38
|
+
ALTER TABLE "public"."Transcript"
|
|
39
|
+
ADD COLUMN IF NOT EXISTS "profile_interview_session_id" TEXT;
|
|
40
|
+
|
|
41
|
+
-- CreateIndex
|
|
42
|
+
CREATE INDEX IF NOT EXISTS "ProfileInterviewSession_candidate_id_idx"
|
|
43
|
+
ON "public"."ProfileInterviewSession"("candidate_id");
|
|
44
|
+
|
|
45
|
+
CREATE INDEX IF NOT EXISTS "ProfileInterviewSession_candidate_id_status_idx"
|
|
46
|
+
ON "public"."ProfileInterviewSession"("candidate_id", "status");
|
|
47
|
+
|
|
48
|
+
CREATE INDEX IF NOT EXISTS "Transcript_profile_interview_session_id_idx"
|
|
49
|
+
ON "public"."Transcript"("profile_interview_session_id");
|
|
50
|
+
|
|
51
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "Transcript_profile_interview_session_id_order_no_key"
|
|
52
|
+
ON "public"."Transcript"("profile_interview_session_id", "order_no");
|
|
53
|
+
|
|
54
|
+
-- AddForeignKey (idempotent)
|
|
55
|
+
DO $$ BEGIN
|
|
56
|
+
ALTER TABLE "public"."ProfileInterviewSession"
|
|
57
|
+
ADD CONSTRAINT "ProfileInterviewSession_candidate_id_fkey"
|
|
58
|
+
FOREIGN KEY ("candidate_id") REFERENCES "public"."User"("id")
|
|
59
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
60
|
+
EXCEPTION
|
|
61
|
+
WHEN duplicate_object THEN NULL;
|
|
62
|
+
END $$;
|
|
63
|
+
|
|
64
|
+
DO $$ BEGIN
|
|
65
|
+
ALTER TABLE "public"."ProfileInterviewSession"
|
|
66
|
+
ADD CONSTRAINT "ProfileInterviewSession_organisation_id_fkey"
|
|
67
|
+
FOREIGN KEY ("organisation_id") REFERENCES "public"."Organisation"("id")
|
|
68
|
+
ON DELETE SET NULL ON UPDATE CASCADE;
|
|
69
|
+
EXCEPTION
|
|
70
|
+
WHEN duplicate_object THEN NULL;
|
|
71
|
+
END $$;
|
|
72
|
+
|
|
73
|
+
DO $$ BEGIN
|
|
74
|
+
ALTER TABLE "public"."ProfileInterviewSession"
|
|
75
|
+
ADD CONSTRAINT "ProfileInterviewSession_resume_id_fkey"
|
|
76
|
+
FOREIGN KEY ("resume_id") REFERENCES "public"."Resume"("id")
|
|
77
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
78
|
+
EXCEPTION
|
|
79
|
+
WHEN duplicate_object THEN NULL;
|
|
80
|
+
END $$;
|
|
81
|
+
|
|
82
|
+
DO $$ BEGIN
|
|
83
|
+
ALTER TABLE "public"."ProfileInterviewSession"
|
|
84
|
+
ADD CONSTRAINT "ProfileInterviewSession_job_description_id_fkey"
|
|
85
|
+
FOREIGN KEY ("job_description_id") REFERENCES "public"."JobDescription"("id")
|
|
86
|
+
ON DELETE SET NULL ON UPDATE CASCADE;
|
|
87
|
+
EXCEPTION
|
|
88
|
+
WHEN duplicate_object THEN NULL;
|
|
89
|
+
END $$;
|
|
90
|
+
|
|
91
|
+
DO $$ BEGIN
|
|
92
|
+
ALTER TABLE "public"."Transcript"
|
|
93
|
+
ADD CONSTRAINT "Transcript_profile_interview_session_id_fkey"
|
|
94
|
+
FOREIGN KEY ("profile_interview_session_id")
|
|
95
|
+
REFERENCES "public"."ProfileInterviewSession"("id")
|
|
96
|
+
ON DELETE SET NULL ON UPDATE SET NULL;
|
|
97
|
+
EXCEPTION
|
|
98
|
+
WHEN duplicate_object THEN NULL;
|
|
99
|
+
END $$;
|
package/prisma/schema/migrations/20260911120000_unify_profile_interview_into_interview/migration.sql
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
-- AlterTable: candidate-initiated profile AI on Interview
|
|
2
|
+
ALTER TABLE "public"."Interview" ADD COLUMN "candidate_initiated" BOOLEAN NOT NULL DEFAULT false;
|
|
3
|
+
ALTER TABLE "public"."Interview" ADD COLUMN "candidate_interview_metadata" JSONB;
|
|
4
|
+
|
|
5
|
+
-- Relax FK columns for profile rows
|
|
6
|
+
ALTER TABLE "public"."Interview" ALTER COLUMN "organisation_id" DROP NOT NULL;
|
|
7
|
+
ALTER TABLE "public"."Interview" ALTER COLUMN "job_description_id" DROP NOT NULL;
|
|
8
|
+
ALTER TABLE "public"."Interview" ALTER COLUMN "evaluation_plan_id" DROP NOT NULL;
|
|
9
|
+
|
|
10
|
+
-- Drop old composite unique (replaced by partial index below)
|
|
11
|
+
DROP INDEX IF EXISTS "public"."Interview_interviewer_id_candidate_id_evaluation_plan_id_key";
|
|
12
|
+
|
|
13
|
+
-- Backfill ProfileInterviewSession -> Interview (preserve ids for URLs)
|
|
14
|
+
INSERT INTO "public"."Interview" (
|
|
15
|
+
"id",
|
|
16
|
+
"organisation_id",
|
|
17
|
+
"candidate_id",
|
|
18
|
+
"interviewer_id",
|
|
19
|
+
"evaluation_plan_id",
|
|
20
|
+
"application_id",
|
|
21
|
+
"resume_id",
|
|
22
|
+
"job_description_id",
|
|
23
|
+
"candidate_initiated",
|
|
24
|
+
"candidate_interview_metadata",
|
|
25
|
+
"room_name",
|
|
26
|
+
"duration",
|
|
27
|
+
"actual_start_time",
|
|
28
|
+
"actual_end_time",
|
|
29
|
+
"evaluation_type",
|
|
30
|
+
"interview_status",
|
|
31
|
+
"interview_platform",
|
|
32
|
+
"ai_feedback",
|
|
33
|
+
"ai_feedback_generated_at",
|
|
34
|
+
"created_at",
|
|
35
|
+
"updated_at",
|
|
36
|
+
"created_by",
|
|
37
|
+
"updated_by",
|
|
38
|
+
"is_active",
|
|
39
|
+
"interview_summary",
|
|
40
|
+
"section_feedback",
|
|
41
|
+
"beta_section_feedback",
|
|
42
|
+
"reschedule_count",
|
|
43
|
+
"awaiting_recruiter_action"
|
|
44
|
+
)
|
|
45
|
+
SELECT
|
|
46
|
+
pis."id",
|
|
47
|
+
pis."organisation_id",
|
|
48
|
+
pis."candidate_id",
|
|
49
|
+
NULL,
|
|
50
|
+
NULL,
|
|
51
|
+
NULL,
|
|
52
|
+
pis."resume_id",
|
|
53
|
+
pis."job_description_id",
|
|
54
|
+
true,
|
|
55
|
+
jsonb_build_object(
|
|
56
|
+
'purpose', pis."purpose",
|
|
57
|
+
'focusAreas', pis."focus_areas"
|
|
58
|
+
),
|
|
59
|
+
pis."room_name",
|
|
60
|
+
pis."duration_minutes",
|
|
61
|
+
pis."actual_start_time",
|
|
62
|
+
pis."actual_end_time",
|
|
63
|
+
'TREADSPACE_FULL_AI'::"public"."EvaluationType",
|
|
64
|
+
CASE pis."status"
|
|
65
|
+
WHEN 'SCHEDULED' THEN 'SCHEDULED'::"public"."InterviewStatus"
|
|
66
|
+
WHEN 'IN_PROGRESS' THEN 'IN_PROGRESS'::"public"."InterviewStatus"
|
|
67
|
+
WHEN 'CANCELLED' THEN 'CANCELLED'::"public"."InterviewStatus"
|
|
68
|
+
WHEN 'COMPLETED' THEN
|
|
69
|
+
CASE
|
|
70
|
+
WHEN pis."evidence_result" IS NOT NULL THEN 'EVALUATED'::"public"."InterviewStatus"
|
|
71
|
+
ELSE 'EVALUATION_PENDING'::"public"."InterviewStatus"
|
|
72
|
+
END
|
|
73
|
+
ELSE 'SCHEDULED'::"public"."InterviewStatus"
|
|
74
|
+
END,
|
|
75
|
+
'TREADSPACE'::"public"."InterviewPlatform",
|
|
76
|
+
pis."evidence_result",
|
|
77
|
+
CASE WHEN pis."evidence_result" IS NOT NULL THEN pis."updated_at" ELSE NULL END,
|
|
78
|
+
pis."created_at",
|
|
79
|
+
pis."updated_at",
|
|
80
|
+
pis."created_by",
|
|
81
|
+
pis."updated_by",
|
|
82
|
+
pis."is_active",
|
|
83
|
+
ARRAY[]::TEXT[],
|
|
84
|
+
ARRAY[]::JSONB[],
|
|
85
|
+
ARRAY[]::JSONB[],
|
|
86
|
+
0,
|
|
87
|
+
false
|
|
88
|
+
FROM "public"."ProfileInterviewSession" pis
|
|
89
|
+
ON CONFLICT ("id") DO NOTHING;
|
|
90
|
+
|
|
91
|
+
-- Point transcripts at Interview rows
|
|
92
|
+
UPDATE "public"."Transcript" t
|
|
93
|
+
SET "interview_id" = t."profile_interview_session_id"
|
|
94
|
+
WHERE t."profile_interview_session_id" IS NOT NULL
|
|
95
|
+
AND t."interview_id" IS NULL;
|
|
96
|
+
|
|
97
|
+
-- Transcript: drop profile session FK
|
|
98
|
+
ALTER TABLE "public"."Transcript" DROP CONSTRAINT IF EXISTS "Transcript_profile_interview_session_id_fkey";
|
|
99
|
+
DROP INDEX IF EXISTS "public"."Transcript_profile_interview_session_id_order_no_key";
|
|
100
|
+
DROP INDEX IF EXISTS "public"."Transcript_profile_interview_session_id_idx";
|
|
101
|
+
ALTER TABLE "public"."Transcript" DROP COLUMN IF EXISTS "profile_interview_session_id";
|
|
102
|
+
|
|
103
|
+
-- Drop profile session table
|
|
104
|
+
DROP TABLE IF EXISTS "public"."ProfileInterviewSession";
|
|
105
|
+
DROP TYPE IF EXISTS "public"."ProfileInterviewSessionStatus";
|
|
106
|
+
|
|
107
|
+
-- Interview FK: organisation / job_description ON DELETE SET NULL
|
|
108
|
+
ALTER TABLE "public"."Interview" DROP CONSTRAINT IF EXISTS "Interview_organisation_id_fkey";
|
|
109
|
+
ALTER TABLE "public"."Interview" ADD CONSTRAINT "Interview_organisation_id_fkey"
|
|
110
|
+
FOREIGN KEY ("organisation_id") REFERENCES "public"."Organisation"("id")
|
|
111
|
+
ON DELETE SET NULL ON UPDATE CASCADE;
|
|
112
|
+
|
|
113
|
+
ALTER TABLE "public"."Interview" DROP CONSTRAINT IF EXISTS "Interview_job_description_id_fkey";
|
|
114
|
+
ALTER TABLE "public"."Interview" ADD CONSTRAINT "Interview_job_description_id_fkey"
|
|
115
|
+
FOREIGN KEY ("job_description_id") REFERENCES "public"."JobDescription"("id")
|
|
116
|
+
ON DELETE SET NULL ON UPDATE CASCADE;
|
|
117
|
+
|
|
118
|
+
-- Hiring row invariants
|
|
119
|
+
ALTER TABLE "public"."Interview" ADD CONSTRAINT "interview_hiring_required_fks"
|
|
120
|
+
CHECK (
|
|
121
|
+
"candidate_initiated" = true
|
|
122
|
+
OR (
|
|
123
|
+
"organisation_id" IS NOT NULL
|
|
124
|
+
AND "job_description_id" IS NOT NULL
|
|
125
|
+
AND "evaluation_plan_id" IS NOT NULL
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
-- Partial unique for hiring triple only
|
|
130
|
+
CREATE UNIQUE INDEX "interview_hiring_triple_uidx"
|
|
131
|
+
ON "public"."Interview" ("interviewer_id", "candidate_id", "evaluation_plan_id")
|
|
132
|
+
WHERE "candidate_initiated" = false AND "evaluation_plan_id" IS NOT NULL;
|
|
133
|
+
|
|
134
|
+
-- List indexes
|
|
135
|
+
CREATE INDEX IF NOT EXISTS "Interview_candidate_id_candidate_initiated_created_at_idx"
|
|
136
|
+
ON "public"."Interview" ("candidate_id", "candidate_initiated", "created_at");
|
|
137
|
+
|
|
138
|
+
CREATE INDEX IF NOT EXISTS "Interview_candidate_initiated_interview_status_idx"
|
|
139
|
+
ON "public"."Interview" ("candidate_initiated", "interview_status");
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- BillingTransactionFailureCategory: rename Razorpay-specific values to provider-neutral ones.
|
|
2
|
+
-- RENAME VALUE keeps existing billing_transactions rows on the renamed label.
|
|
3
|
+
-- Guarded so it is a no-op where the enum was never created (migration-managed DBs
|
|
4
|
+
-- without billing tables) or was already renamed.
|
|
5
|
+
DO $$
|
|
6
|
+
BEGIN
|
|
7
|
+
IF EXISTS (
|
|
8
|
+
SELECT 1 FROM pg_enum e
|
|
9
|
+
JOIN pg_type t ON t.oid = e.enumtypid
|
|
10
|
+
JOIN pg_namespace n ON n.oid = t.typnamespace
|
|
11
|
+
WHERE n.nspname = 'public'
|
|
12
|
+
AND t.typname = 'BillingTransactionFailureCategory'
|
|
13
|
+
AND e.enumlabel = 'RAZORPAY_ORDER'
|
|
14
|
+
) THEN
|
|
15
|
+
ALTER TYPE "public"."BillingTransactionFailureCategory" RENAME VALUE 'RAZORPAY_ORDER' TO 'ORDER';
|
|
16
|
+
END IF;
|
|
17
|
+
|
|
18
|
+
IF EXISTS (
|
|
19
|
+
SELECT 1 FROM pg_enum e
|
|
20
|
+
JOIN pg_type t ON t.oid = e.enumtypid
|
|
21
|
+
JOIN pg_namespace n ON n.oid = t.typnamespace
|
|
22
|
+
WHERE n.nspname = 'public'
|
|
23
|
+
AND t.typname = 'BillingTransactionFailureCategory'
|
|
24
|
+
AND e.enumlabel = 'RAZORPAY_PAYMENT'
|
|
25
|
+
) THEN
|
|
26
|
+
ALTER TYPE "public"."BillingTransactionFailureCategory" RENAME VALUE 'RAZORPAY_PAYMENT' TO 'PAYMENT';
|
|
27
|
+
END IF;
|
|
28
|
+
END $$;
|
|
@@ -59,6 +59,11 @@ model Organisation {
|
|
|
59
59
|
timezone String @default("Asia/Kolkata")
|
|
60
60
|
/// ISO 3166-1 alpha-2 (e.g. IN).
|
|
61
61
|
country_code String @default("IN")
|
|
62
|
+
/// Customer GSTIN; first 2 digits give the state for the CGST/SGST vs IGST split.
|
|
63
|
+
/// Optional: an Indian org without one is still charged GST.
|
|
64
|
+
gstin String?
|
|
65
|
+
/// Currency the organisation is billed in (INR or USD). Catalogue and checkout use only packages in this currency.
|
|
66
|
+
billing_currency String @default("INR")
|
|
62
67
|
/// Who may consume unused hiring units. Does not rewrite unit rows when changed.
|
|
63
68
|
hiring_unit_assignment_scope HiringUnitAssignmentScope @default(DEPARTMENT)
|
|
64
69
|
organisation_configs OrganisationConfig[]
|
|
@@ -86,6 +91,9 @@ model Organisation {
|
|
|
86
91
|
license_package_organisations LicensePackageOrganisation[]
|
|
87
92
|
ai_cost_ledger_entries AiCostLedgerEntry[]
|
|
88
93
|
consent_documents ConsentDocument[]
|
|
94
|
+
billing_transactions BillingTransaction[]
|
|
95
|
+
payment_webhook_events PaymentWebhookEvent[]
|
|
96
|
+
invoices Invoice[]
|
|
89
97
|
|
|
90
98
|
@@index([name])
|
|
91
99
|
@@schema("public")
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// PAYMENT SERVICE boundary — portable payment microservice owns these enums/columns.
|
|
2
|
+
|
|
3
|
+
enum BillingTransactionStatus {
|
|
4
|
+
INITIATED
|
|
5
|
+
ORDER_CREATED
|
|
6
|
+
PAYMENT_PENDING
|
|
7
|
+
SUCCESS
|
|
8
|
+
FAILED
|
|
9
|
+
CANCELLED
|
|
10
|
+
REFUND_PENDING
|
|
11
|
+
REFUND_FAILED
|
|
12
|
+
REFUNDED
|
|
13
|
+
|
|
14
|
+
@@schema("public")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
enum BillingTransactionType {
|
|
18
|
+
PURCHASE
|
|
19
|
+
TOP_UP
|
|
20
|
+
REFUND
|
|
21
|
+
|
|
22
|
+
@@schema("public")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// Provider-neutral failure stage; provider detail goes in failure_reason.
|
|
26
|
+
enum BillingTransactionFailureCategory {
|
|
27
|
+
ORDER
|
|
28
|
+
PAYMENT
|
|
29
|
+
REFUND
|
|
30
|
+
INTERNAL
|
|
31
|
+
|
|
32
|
+
@@schema("public")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// Payment reconciliation state when Treadspace status is FAILED but Razorpay captured payment.
|
|
36
|
+
enum BillingPaymentMismatchStatus {
|
|
37
|
+
DETECTED
|
|
38
|
+
UNFULFILLED
|
|
39
|
+
|
|
40
|
+
@@schema("public")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// Financial transaction lifecycle for organisation billing purchases.
|
|
44
|
+
model BillingTransaction {
|
|
45
|
+
id String @id @default(uuid())
|
|
46
|
+
organisation_id String
|
|
47
|
+
/// Opaque plan/product identity supplied at checkout. Not a catalog FK.
|
|
48
|
+
purchase_reference String
|
|
49
|
+
/// Human-readable snapshot captured at checkout for invoices and receipts.
|
|
50
|
+
purchase_display_name String?
|
|
51
|
+
transaction_type BillingTransactionType
|
|
52
|
+
status BillingTransactionStatus @default(INITIATED)
|
|
53
|
+
failure_category BillingTransactionFailureCategory?
|
|
54
|
+
/// Human-readable or provider detail (e.g. Razorpay error_description).
|
|
55
|
+
failure_reason String?
|
|
56
|
+
amount Int
|
|
57
|
+
currency String @default("INR")
|
|
58
|
+
razorpay_order_id String?
|
|
59
|
+
razorpay_payment_id String? @unique
|
|
60
|
+
/// Razorpay payment method at capture (card, netbanking, upi, wallet, etc.).
|
|
61
|
+
payment_method String?
|
|
62
|
+
razorpay_subscription_id String?
|
|
63
|
+
razorpay_refund_id String?
|
|
64
|
+
refund_reason String?
|
|
65
|
+
refund_amount Int?
|
|
66
|
+
idempotency_key String @unique
|
|
67
|
+
/// Email of the org Admin who initiated checkout (bill-to).
|
|
68
|
+
purchaser_email String?
|
|
69
|
+
/// User id of the org Admin who started checkout; actor for fulfilment and the invoice.
|
|
70
|
+
created_by String?
|
|
71
|
+
/// Set when FAILED but Razorpay order/payment is captured (reconciliation path).
|
|
72
|
+
payment_mismatch_status BillingPaymentMismatchStatus?
|
|
73
|
+
/// Strict same-intent SUCCESS transaction that fulfilled the purchase (UNFULFILLED only).
|
|
74
|
+
payment_mismatch_fulfilled_by_id String?
|
|
75
|
+
created_at DateTime @default(now())
|
|
76
|
+
updated_at DateTime @updatedAt
|
|
77
|
+
|
|
78
|
+
organisation Organisation @relation(fields: [organisation_id], references: [id])
|
|
79
|
+
/// Tax invoice issued for this payment (set once fulfilled).
|
|
80
|
+
invoice Invoice?
|
|
81
|
+
|
|
82
|
+
@@index([organisation_id, status])
|
|
83
|
+
@@index([purchase_reference])
|
|
84
|
+
@@index([razorpay_order_id])
|
|
85
|
+
@@map("billing_transactions")
|
|
86
|
+
@@schema("public")
|
|
87
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Tax invoices issued by Treadspace. Shared by license package purchases and (later) platform subscriptions.
|
|
2
|
+
|
|
3
|
+
/// What the invoice was raised for.
|
|
4
|
+
enum InvoiceKind {
|
|
5
|
+
PACKAGE
|
|
6
|
+
|
|
7
|
+
@@schema("public")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/// Tax invoice. Raised only after money is received (or for a zero-amount purchase). Immutable once written.
|
|
11
|
+
/// All amounts are integer minor units (paise / cents); total = cost + tax + fee + fee_tax (not stored).
|
|
12
|
+
model Invoice {
|
|
13
|
+
id String @id @default(uuid())
|
|
14
|
+
/// Sequential number, e.g. TS/26-27/000001 (at most 16 chars). The financial year is part of the number.
|
|
15
|
+
invoice_number String @unique
|
|
16
|
+
kind InvoiceKind
|
|
17
|
+
organisation_id String
|
|
18
|
+
/// Payment that funded this invoice. Null for zero-amount purchases.
|
|
19
|
+
billing_transaction_id String? @unique
|
|
20
|
+
currency String
|
|
21
|
+
/// Optional line description snapshot, e.g. "Pro hiring pack (v2)".
|
|
22
|
+
description String?
|
|
23
|
+
quantity Int
|
|
24
|
+
/// Net cost of the goods/service (excludes GST and processing fee).
|
|
25
|
+
cost_amount Int
|
|
26
|
+
/// GST on cost. 0 for non-Indian organisations.
|
|
27
|
+
tax_amount Int
|
|
28
|
+
/// Payment processing fee.
|
|
29
|
+
fee_amount Int
|
|
30
|
+
/// GST on the processing fee. 0 for non-Indian organisations.
|
|
31
|
+
fee_tax_amount Int
|
|
32
|
+
/// GST rate in basis points (1800 = 18%) at issue time.
|
|
33
|
+
tax_rate_bps Int
|
|
34
|
+
/// Processing fee rate in basis points (200 = 2%) at issue time.
|
|
35
|
+
fee_rate_bps Int
|
|
36
|
+
/// Buyer snapshot from the organisation at issue time.
|
|
37
|
+
buyer_name String
|
|
38
|
+
buyer_address String
|
|
39
|
+
/// ISO 3166-1 alpha-2 (e.g. IN).
|
|
40
|
+
buyer_country_code String
|
|
41
|
+
buyer_gstin String?
|
|
42
|
+
/// Seller snapshot at issue time: { name, gstin, address, sac }.
|
|
43
|
+
seller_snapshot Json
|
|
44
|
+
issued_at DateTime @default(now())
|
|
45
|
+
created_at DateTime @default(now())
|
|
46
|
+
/// User id that triggered the issue (checkout admin), or "system".
|
|
47
|
+
created_by String
|
|
48
|
+
|
|
49
|
+
organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict)
|
|
50
|
+
billing_transaction BillingTransaction? @relation(fields: [billing_transaction_id], references: [id], onDelete: Restrict)
|
|
51
|
+
purchased_license_package PurchasedLicensePackage?
|
|
52
|
+
|
|
53
|
+
@@index([organisation_id, issued_at])
|
|
54
|
+
@@map("invoices")
|
|
55
|
+
@@schema("public")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// Invoice number counter: one row per financial year (e.g. "2026-27"); the key only lives here, not on Invoice.
|
|
59
|
+
/// Incremented inside the invoice-issuing transaction: concurrent issues wait on the row lock (no duplicate
|
|
60
|
+
/// numbers, no retries) and a rolled-back issue rolls the counter back too (no gaps).
|
|
61
|
+
model InvoiceSequence {
|
|
62
|
+
financial_year String @id
|
|
63
|
+
last_sequence Int @default(0)
|
|
64
|
+
updated_at DateTime @updatedAt
|
|
65
|
+
|
|
66
|
+
@@map("invoice_sequences")
|
|
67
|
+
@@schema("public")
|
|
68
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
enum PaymentWebhookEventStatus {
|
|
2
|
+
RECEIVED
|
|
3
|
+
PROCESSED
|
|
4
|
+
FAILED
|
|
5
|
+
|
|
6
|
+
@@schema("public")
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/// Idempotent record of payment provider webhook deliveries.
|
|
10
|
+
model PaymentWebhookEvent {
|
|
11
|
+
id String @id @default(uuid())
|
|
12
|
+
organisation_id String?
|
|
13
|
+
provider String
|
|
14
|
+
provider_event_id String
|
|
15
|
+
event_type String
|
|
16
|
+
status PaymentWebhookEventStatus @default(RECEIVED)
|
|
17
|
+
billing_transaction_id String?
|
|
18
|
+
error_message String?
|
|
19
|
+
processed_at DateTime?
|
|
20
|
+
created_at DateTime @default(now())
|
|
21
|
+
|
|
22
|
+
organisation Organisation? @relation(fields: [organisation_id], references: [id])
|
|
23
|
+
|
|
24
|
+
@@unique([provider, provider_event_id])
|
|
25
|
+
@@index([status, created_at])
|
|
26
|
+
@@map("payment_webhook_events")
|
|
27
|
+
@@schema("public")
|
|
28
|
+
}
|
package/prisma/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|