founder-schema 0.34.0 → 0.36.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/dist/domains/billing/billing.d.ts +35 -2
- package/dist/domains/billing/billing.d.ts.map +1 -1
- package/dist/domains/billing/billing.js +5 -3
- package/dist/domains/billing/billing.js.map +1 -1
- package/dist/domains/billing/gst.d.ts +5 -0
- package/dist/domains/billing/gst.d.ts.map +1 -1
- package/dist/domains/billing/gst.js +7 -0
- package/dist/domains/billing/gst.js.map +1 -1
- package/dist/domains/membership/membership.d.ts +84 -12
- package/dist/domains/membership/membership.d.ts.map +1 -1
- package/dist/domains/membership/membership.js +106 -30
- package/dist/domains/membership/membership.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
* @module founder-schema/domains/billing
|
|
43
43
|
*/
|
|
44
44
|
import { z } from 'zod';
|
|
45
|
-
export { type BillingDetails, billingDetailsSchema, GST_RATE_PERCENT, GST_STATE_CODE_VALUES, GST_STATES, type GstStateCode, gstinChecksumValid, gstinSchema, gstStateCodeSchema, gstStateName, } from './gst.js';
|
|
45
|
+
export { type BillingDetails, billingDetailsSchema, GST_RATE_PERCENT, GST_STATE_CODE_VALUES, GST_STATES, type GstStateCode, gstinChecksumValid, gstinSchema, gstStateCodeOf, gstStateCodeSchema, gstStateName, } from './gst.js';
|
|
46
46
|
/** ⚠ Stored on every order: append only. */
|
|
47
47
|
export declare const PURCHASE_KIND_VALUES: readonly ["membership", "plan", "upgrade"];
|
|
48
48
|
export type PurchaseKind = (typeof PURCHASE_KIND_VALUES)[number];
|
|
@@ -64,6 +64,8 @@ export declare const purchaseItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
64
64
|
period: z.ZodEnum<{
|
|
65
65
|
month: "month";
|
|
66
66
|
year: "year";
|
|
67
|
+
quarter: "quarter";
|
|
68
|
+
half_year: "half_year";
|
|
67
69
|
}>;
|
|
68
70
|
}, z.core.$strip>, z.ZodObject<{
|
|
69
71
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -101,6 +103,8 @@ export declare const quoteBodySchema: z.ZodObject<{
|
|
|
101
103
|
period: z.ZodEnum<{
|
|
102
104
|
month: "month";
|
|
103
105
|
year: "year";
|
|
106
|
+
quarter: "quarter";
|
|
107
|
+
half_year: "half_year";
|
|
104
108
|
}>;
|
|
105
109
|
}, z.core.$strip>, z.ZodObject<{
|
|
106
110
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -219,6 +223,8 @@ export declare const autoRenewTermsSchema: z.ZodObject<{
|
|
|
219
223
|
period: z.ZodEnum<{
|
|
220
224
|
month: "month";
|
|
221
225
|
year: "year";
|
|
226
|
+
quarter: "quarter";
|
|
227
|
+
half_year: "half_year";
|
|
222
228
|
}>;
|
|
223
229
|
chargesNow: z.ZodBoolean;
|
|
224
230
|
firstChargeAt: z.ZodISODateTime;
|
|
@@ -237,6 +243,8 @@ export declare const quoteSchema: z.ZodObject<{
|
|
|
237
243
|
period: z.ZodEnum<{
|
|
238
244
|
month: "month";
|
|
239
245
|
year: "year";
|
|
246
|
+
quarter: "quarter";
|
|
247
|
+
half_year: "half_year";
|
|
240
248
|
}>;
|
|
241
249
|
}, z.core.$strip>, z.ZodObject<{
|
|
242
250
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -272,6 +280,8 @@ export declare const quoteSchema: z.ZodObject<{
|
|
|
272
280
|
period: z.ZodEnum<{
|
|
273
281
|
month: "month";
|
|
274
282
|
year: "year";
|
|
283
|
+
quarter: "quarter";
|
|
284
|
+
half_year: "half_year";
|
|
275
285
|
}>;
|
|
276
286
|
chargesNow: z.ZodBoolean;
|
|
277
287
|
firstChargeAt: z.ZodISODateTime;
|
|
@@ -319,6 +329,8 @@ export declare const createOrderBodySchema: z.ZodObject<{
|
|
|
319
329
|
period: z.ZodEnum<{
|
|
320
330
|
month: "month";
|
|
321
331
|
year: "year";
|
|
332
|
+
quarter: "quarter";
|
|
333
|
+
half_year: "half_year";
|
|
322
334
|
}>;
|
|
323
335
|
}, z.core.$strip>, z.ZodObject<{
|
|
324
336
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -405,6 +417,8 @@ export declare const createOrderResponseSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
405
417
|
period: z.ZodEnum<{
|
|
406
418
|
month: "month";
|
|
407
419
|
year: "year";
|
|
420
|
+
quarter: "quarter";
|
|
421
|
+
half_year: "half_year";
|
|
408
422
|
}>;
|
|
409
423
|
chargesNow: z.ZodBoolean;
|
|
410
424
|
firstChargeAt: z.ZodISODateTime;
|
|
@@ -451,7 +465,8 @@ export type AutoRenewalParams = z.infer<typeof autoRenewalParamsSchema>;
|
|
|
451
465
|
* Refused (`AUTO_RENEW_NOT_OFFERED`) with no plan time held (buy the plan with
|
|
452
466
|
* `autoRenew` instead), for Business while only Premium is held (that is an
|
|
453
467
|
* upgrade), while another auto-renewal holds the slot (one whose stop is
|
|
454
|
-
* already requested does not),
|
|
468
|
+
* already requested does not), for a term not in the catalog's
|
|
469
|
+
* `autoRenewPeriods`, or while auto-renew is off on this server.
|
|
455
470
|
*
|
|
456
471
|
* `billing`: the place of supply every renewal's invoice needs. Without it the
|
|
457
472
|
* member's saved details are used; with neither, `VALIDATION_ERROR` on
|
|
@@ -465,6 +480,8 @@ export declare const startAutoRenewalBodySchema: z.ZodObject<{
|
|
|
465
480
|
period: z.ZodEnum<{
|
|
466
481
|
month: "month";
|
|
467
482
|
year: "year";
|
|
483
|
+
quarter: "quarter";
|
|
484
|
+
half_year: "half_year";
|
|
468
485
|
}>;
|
|
469
486
|
billing: z.ZodOptional<z.ZodObject<{
|
|
470
487
|
stateCode: z.ZodEnum<{
|
|
@@ -544,6 +561,8 @@ export declare const autoRenewalStateSchema: z.ZodObject<{
|
|
|
544
561
|
period: z.ZodEnum<{
|
|
545
562
|
month: "month";
|
|
546
563
|
year: "year";
|
|
564
|
+
quarter: "quarter";
|
|
565
|
+
half_year: "half_year";
|
|
547
566
|
}>;
|
|
548
567
|
orderId: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
549
568
|
nextChargeAt: z.ZodNullable<z.ZodISODateTime>;
|
|
@@ -597,6 +616,8 @@ export declare const orderStateSchema: z.ZodObject<{
|
|
|
597
616
|
period: z.ZodEnum<{
|
|
598
617
|
month: "month";
|
|
599
618
|
year: "year";
|
|
619
|
+
quarter: "quarter";
|
|
620
|
+
half_year: "half_year";
|
|
600
621
|
}>;
|
|
601
622
|
}, z.core.$strip>, z.ZodObject<{
|
|
602
623
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -806,6 +827,8 @@ export declare const paymentSummarySchema: z.ZodObject<{
|
|
|
806
827
|
period: z.ZodEnum<{
|
|
807
828
|
month: "month";
|
|
808
829
|
year: "year";
|
|
830
|
+
quarter: "quarter";
|
|
831
|
+
half_year: "half_year";
|
|
809
832
|
}>;
|
|
810
833
|
}, z.core.$strip>, z.ZodObject<{
|
|
811
834
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -862,6 +885,8 @@ export declare const paymentPageSchema: z.ZodObject<{
|
|
|
862
885
|
period: z.ZodEnum<{
|
|
863
886
|
month: "month";
|
|
864
887
|
year: "year";
|
|
888
|
+
quarter: "quarter";
|
|
889
|
+
half_year: "half_year";
|
|
865
890
|
}>;
|
|
866
891
|
}, z.core.$strip>, z.ZodObject<{
|
|
867
892
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -919,6 +944,8 @@ export declare const paymentDetailSchema: z.ZodObject<{
|
|
|
919
944
|
period: z.ZodEnum<{
|
|
920
945
|
month: "month";
|
|
921
946
|
year: "year";
|
|
947
|
+
quarter: "quarter";
|
|
948
|
+
half_year: "half_year";
|
|
922
949
|
}>;
|
|
923
950
|
}, z.core.$strip>, z.ZodObject<{
|
|
924
951
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -1135,6 +1162,8 @@ export declare const staffPaymentSummarySchema: z.ZodObject<{
|
|
|
1135
1162
|
period: z.ZodEnum<{
|
|
1136
1163
|
month: "month";
|
|
1137
1164
|
year: "year";
|
|
1165
|
+
quarter: "quarter";
|
|
1166
|
+
half_year: "half_year";
|
|
1138
1167
|
}>;
|
|
1139
1168
|
}, z.core.$strip>, z.ZodObject<{
|
|
1140
1169
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -1205,6 +1234,8 @@ export declare const staffPaymentPageSchema: z.ZodObject<{
|
|
|
1205
1234
|
period: z.ZodEnum<{
|
|
1206
1235
|
month: "month";
|
|
1207
1236
|
year: "year";
|
|
1237
|
+
quarter: "quarter";
|
|
1238
|
+
half_year: "half_year";
|
|
1208
1239
|
}>;
|
|
1209
1240
|
}, z.core.$strip>, z.ZodObject<{
|
|
1210
1241
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -1276,6 +1307,8 @@ export declare const staffPaymentDetailSchema: z.ZodObject<{
|
|
|
1276
1307
|
period: z.ZodEnum<{
|
|
1277
1308
|
month: "month";
|
|
1278
1309
|
year: "year";
|
|
1310
|
+
quarter: "quarter";
|
|
1311
|
+
half_year: "half_year";
|
|
1279
1312
|
}>;
|
|
1280
1313
|
}, z.core.$strip>, z.ZodObject<{
|
|
1281
1314
|
kind: z.ZodLiteral<"upgrade">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../../src/domains/billing/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiCxB,OAAO,EACL,KAAK,cAAc,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,KAAK,YAAY,EACjB,kBAAkB,EAClB,W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C;AAC9E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,eAAO,MAAM,mBAAmB;;;;;;;;;;;2BAa9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;iBAavB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,kDAAkD;AAClD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;iBAA6C,CAAC;AAC3E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,kBAAkB;;iBAAyC,CAAC;AACzE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAK9D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;iBAS4D,CAAC;AAChG,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;iBAQ4D,CAAC;AAChG,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -50,7 +50,7 @@ import { autoRenewalStatusSchema, paiseSchema, planPeriodSchema, planTierSchema,
|
|
|
50
50
|
import { personSchema } from '../people/person.js';
|
|
51
51
|
import { billingDetailsSchema, gstStateCodeSchema } from './gst.js';
|
|
52
52
|
import { paymentMethodSnapshotSchema } from './payment-method.js';
|
|
53
|
-
export { billingDetailsSchema, GST_RATE_PERCENT, GST_STATE_CODE_VALUES, GST_STATES, gstinChecksumValid, gstinSchema, gstStateCodeSchema, gstStateName, } from './gst.js';
|
|
53
|
+
export { billingDetailsSchema, GST_RATE_PERCENT, GST_STATE_CODE_VALUES, GST_STATES, gstinChecksumValid, gstinSchema, gstStateCodeOf, gstStateCodeSchema, gstStateName, } from './gst.js';
|
|
54
54
|
// ─── What can be bought ──────────────────────────────────────────────────────
|
|
55
55
|
/** ⚠ Stored on every order: append only. */
|
|
56
56
|
export const PURCHASE_KIND_VALUES = ['membership', 'plan', 'upgrade'];
|
|
@@ -233,7 +233,8 @@ export const createOrderBodySchema = z.object({
|
|
|
233
233
|
* Buy the plan as an AUTO-RENEWAL (0.31.0): consent, said explicitly on the
|
|
234
234
|
* wire (the web's switch is on by default, the user's ruling; the request
|
|
235
235
|
* still says it). Only for `item.kind: 'plan'`, without a coupon, while the
|
|
236
|
-
* catalog's `autoRenewEnabled
|
|
236
|
+
* catalog's `autoRenewEnabled`, for a term in its `autoRenewPeriods`:
|
|
237
|
+
* otherwise `AUTO_RENEW_NOT_OFFERED`. The
|
|
237
238
|
* answer is then `status: 'subscription'`.
|
|
238
239
|
*/
|
|
239
240
|
autoRenew: z.boolean().optional(),
|
|
@@ -315,7 +316,8 @@ export const autoRenewalParamsSchema = z.object({ autoRenewalId: objectIdSchema
|
|
|
315
316
|
* Refused (`AUTO_RENEW_NOT_OFFERED`) with no plan time held (buy the plan with
|
|
316
317
|
* `autoRenew` instead), for Business while only Premium is held (that is an
|
|
317
318
|
* upgrade), while another auto-renewal holds the slot (one whose stop is
|
|
318
|
-
* already requested does not),
|
|
319
|
+
* already requested does not), for a term not in the catalog's
|
|
320
|
+
* `autoRenewPeriods`, or while auto-renew is off on this server.
|
|
319
321
|
*
|
|
320
322
|
* `billing`: the place of supply every renewal's invoice needs. Without it the
|
|
321
323
|
* member's saved details are used; with neither, `VALIDATION_ERROR` on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/domains/billing/billing.ts"],"names":[],"mappings":"AA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,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC3E,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACjD,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACnD,CAAC;KACD,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: buying, paying, invoices, refunds and coupons (0.12.0)\n *\n * POST /api/v1/billing/quote quoteBodySchema -> quoteSchema\n * POST /api/v1/billing/orders createOrderBodySchema -> createOrderResponseSchema\n * GET /api/v1/billing/orders/:orderId orderStateSchema (polled while \"processing\")\n * POST /api/v1/billing/orders/:orderId/confirm confirmOrderBodySchema -> orderStateSchema\n * GET /api/v1/billing/payments paymentPageSchema (mine)\n * GET /api/v1/billing/payments/:orderId paymentDetailSchema (mine, with the invoice)\n *\n * Staff (by the ability: support reads; managers refund and run coupons):\n * GET /api/v1/staff/payments staffPaymentsQuerySchema -> staffPaymentPageSchema\n * GET /api/v1/staff/payments/:orderId staffPaymentDetailSchema\n * POST /api/v1/staff/payments/:orderId/refund refundPaymentBodySchema -> staffPaymentDetailSchema\n * GET /api/v1/staff/coupons couponListSchema\n * POST /api/v1/staff/coupons createCouponBodySchema -> couponSchema\n * PATCH /api/v1/staff/coupons/:couponId updateCouponBodySchema -> couponSchema\n * PUT /api/v1/members/:memberId/membership setMembershipBodySchema -> memberDetailSchema\n *\n * Auto-renewal (0.31.0, payments v2; founder-circle-backend docs/payments-v2-plan.md 3a):\n * POST /api/v1/billing/auto-renewals startAutoRenewalBodySchema -> createOrderResponseSchema ('subscription')\n * GET /api/v1/billing/auto-renewals/:autoRenewalId autoRenewalStateSchema (polled after authorising)\n * POST /api/v1/billing/auto-renewals/:autoRenewalId/confirm confirmAutoRenewalBodySchema -> autoRenewalStateSchema\n * POST /api/v1/billing/auto-renewals/:autoRenewalId/cancel -> autoRenewalStateSchema (off at the period's end)\n * POST /api/v1/billing/auto-renewals/:autoRenewalId/payment-method -> paymentMethodUpdateSchema\n * (a plan bought with `autoRenew: true` on POST /billing/orders answers 'subscription' too)\n *\n * THE ONE RULE: THE SERVER PRICES, THE CLIENT CHOOSES. A request names what it\n * wants (an item) and maybe a coupon CODE; it never names an amount. Every\n * amount here is the server's, in integer paise, GST included.\n *\n * TWO PATHS IN, ONE GRANT. A payment reaches the server from the browser the\n * moment checkout returns (`confirm`) and from the gateway's webhook. Either\n * grants; the second is a no-op. So a member who closes the tab is still\n * granted, and `confirm` failing never means \"not paid\": the web says\n * \"processing\" and polls the order.\n *\n * GST: the company is registered, every captured payment gets a tax invoice,\n * every refund a credit note. Where the buyer is decides the tax: in the\n * supplier's state CGST + SGST, elsewhere IGST. So checkout asks for the state.\n *\n * @module founder-schema/domains/billing\n */\n\nimport { z } from 'zod';\nimport {\n eachOnce,\n emptyStringToUndefined,\n objectIdSchema,\n paginationQuerySchema,\n} from '../../core/common.js';\nimport {\n BILLING_REASON_MAX,\n BILLING_REASON_MIN,\n COUPON_CODE_MAX,\n COUPON_CODE_MIN,\n COUPON_LABEL_MAX,\n COUPON_LABEL_MIN,\n COUPON_PERCENT_MAX,\n COUPON_PERCENT_MIN,\n COUPON_USES_MAX,\n INVOICE_NUMBER_MAX,\n RAZORPAY_ID_MAX,\n RAZORPAY_SIGNATURE_MAX,\n} from '../../core/limits.js';\nimport { paginatedSchema } from '../../core/responses.js';\nimport { VALIDATION_MESSAGE } from '../../core/validation.js';\nimport {\n autoRenewalStatusSchema,\n paiseSchema,\n planPeriodSchema,\n planTierSchema,\n} from '../membership/membership.js';\nimport { personSchema } from '../people/person.js';\nimport { billingDetailsSchema, gstStateCodeSchema } from './gst.js';\nimport { paymentMethodSnapshotSchema } from './payment-method.js';\n\nexport {\n type BillingDetails,\n billingDetailsSchema,\n GST_RATE_PERCENT,\n GST_STATE_CODE_VALUES,\n GST_STATES,\n type GstStateCode,\n gstinChecksumValid,\n gstinSchema,\n gstStateCodeSchema,\n gstStateName,\n} from './gst.js';\n\n// ─── What can be bought ──────────────────────────────────────────────────────\n\n/** ⚠ Stored on every order: append only. */\nexport const PURCHASE_KIND_VALUES = ['membership', 'plan', 'upgrade'] as const;\nexport type PurchaseKind = (typeof PURCHASE_KIND_VALUES)[number];\n\n/**\n * The thing asked for.\n *\n * membership Rs 99, once\n * plan a month or a year of Premium or Business, appended\n * upgrade the Premium time left, turned into Business, for the difference\n */\nexport const purchaseItemSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('membership') }),\n z.object({ kind: z.literal('plan'), tier: planTierSchema, period: planPeriodSchema }),\n z.object({ kind: z.literal('upgrade') }),\n]);\nexport type PurchaseItem = z.infer<typeof purchaseItemSchema>;\n\n/** A coupon code as typed: letters, digits, hyphens; compared upper-case. */\nexport const couponCodeSchema = z\n .string()\n .trim()\n .min(COUPON_CODE_MIN)\n .max(COUPON_CODE_MAX)\n .regex(/^[A-Za-z0-9-]+$/, VALIDATION_MESSAGE.couponCodeInvalid)\n .transform((v) => v.toUpperCase());\n\n// ─── Quote ───────────────────────────────────────────────────────────────────\n\n/**\n * The tax inside a total. `taxable + cgst + sgst + igst = total`; either\n * CGST + SGST (buyer in the supplier's state) or IGST, never both.\n */\nexport const taxSplitSchema = z.object({\n ratePercent: z.number().int().positive(),\n taxable: paiseSchema,\n cgst: paiseSchema,\n sgst: paiseSchema,\n igst: paiseSchema,\n total: paiseSchema,\n});\nexport type TaxSplit = z.infer<typeof taxSplitSchema>;\n\n/**\n * `POST /billing/quote`. The state is optional: without it, no tax split.\n * `autoRenew` (0.31.0): price it as an auto-renewing plan, so the quote carries\n * the terms the member must see before authorising (`quote.autoRenew`).\n */\nexport const quoteBodySchema = z.object({\n item: purchaseItemSchema,\n couponCode: couponCodeSchema.optional(),\n stateCode: gstStateCodeSchema.optional(),\n autoRenew: z.boolean().optional(),\n});\nexport type QuoteBody = z.infer<typeof quoteBodySchema>;\n\n/** What a plan or an upgrade would do to the plan, priced now. */\nexport const planEffectSchema = z.object({\n tier: planTierSchema,\n /** When this purchase's time starts (later than now when it waits its turn). */\n startsAt: z.iso.datetime(),\n endsAt: z.iso.datetime(),\n /** For an upgrade: the days of Premium turned into Business. */\n upgradedDays: z.number().int().positive().nullable(),\n});\nexport type PlanEffect = z.infer<typeof planEffectSchema>;\n\n/** A coupon as a purchase carries it: its code and staff's name for it. */\nexport const appliedCouponSchema = z.object({ code: z.string(), label: z.string() });\nexport type AppliedCoupon = z.infer<typeof appliedCouponSchema>;\n\n/**\n * Why a captured payment was NOT applied (`grantFailed`), and so refunded\n * (0.18.0: the one list; the backend wrote two of these as loose strings and\n * the contract said `string`). Stored on the order: append only.\n *\n * AMOUNT_MISMATCH the gateway captured another amount than the price\n * ACCOUNT_DELETED paid after the account was deleted\n * COUPON_ALREADY_USED the code went to another of their orders, paid first\n * MEMBERSHIP_REQUIRED a plan, but the membership is gone (refunded, withdrawn)\n * ALREADY_MEMBER a membership, but they are a member already\n * PLAN_CHANGED an upgrade priced on a plan that has since changed\n * PLAN_NOTHING_TO_UPGRADE an upgrade with no Premium time left\n * PLAN_TERM_LIMIT past `PLAN_AHEAD_MAX_YEARS` of plan time\n * PLAN_UPGRADE_INSTEAD Business bought while on Premium (that is an upgrade)\n * AUTO_RENEW_STOPPED an auto-renewal's charge that landed after the\n * auto-renewal was stopped at once (a refund, the\n * membership ended, the account deleted) and the\n * gateway's cancel had not taken yet (0.31.0)\n * GRANT_REFUSED any other refusal of the grant: still recorded and\n * refunded, never left captured for nothing (the\n * server logs which one, to add it here)\n */\nexport const GRANT_FAILURE_VALUES = [\n 'AMOUNT_MISMATCH',\n 'ACCOUNT_DELETED',\n 'COUPON_ALREADY_USED',\n 'MEMBERSHIP_REQUIRED',\n 'ALREADY_MEMBER',\n 'PLAN_CHANGED',\n 'PLAN_NOTHING_TO_UPGRADE',\n 'PLAN_TERM_LIMIT',\n 'PLAN_UPGRADE_INSTEAD',\n 'GRANT_REFUSED',\n 'AUTO_RENEW_STOPPED',\n] as const;\nexport const grantFailureSchema = z.enum(GRANT_FAILURE_VALUES);\nexport type GrantFailure = z.infer<typeof grantFailureSchema>;\n\n/**\n * What an auto-renewing plan will charge (0.31.0), for the disclosure next to\n * Pay. India's 2023 dark-pattern guidelines: the member is told, before\n * authorising, that it renews, how much, how often and from when, and that it\n * can be turned off.\n *\n * chargesNow true: `amount` is taken now and buys the first period.\n * false: time of this tier is already held, so nothing is\n * taken now; the mandate is authorised and the first charge is\n * on `firstChargeAt`, when that time ends.\n * firstChargeAt now (chargesNow) or the end of the time held\n * nextChargeAt the charge after the first: one `period` later, India's calendar\n */\nexport const autoRenewTermsSchema = z.object({\n amount: paiseSchema,\n period: planPeriodSchema,\n chargesNow: z.boolean(),\n firstChargeAt: z.iso.datetime(),\n nextChargeAt: z.iso.datetime(),\n});\nexport type AutoRenewTerms = z.infer<typeof autoRenewTermsSchema>;\n\nexport const quoteSchema = z.object({\n item: purchaseItemSchema,\n /** \"Membership\", \"Premium, 1 month\", \"Upgrade to Business\": the server's words. */\n title: z.string(),\n listPrice: paiseSchema,\n discount: paiseSchema,\n /** What would be charged. Zero for a free-membership coupon: no checkout at all. */\n total: paiseSchema,\n coupon: appliedCouponSchema.nullable(),\n /** Null for a membership. */\n plan: planEffectSchema.nullable(),\n /** Null without a state. */\n tax: taxSplitSchema.nullable(),\n refundWindowDays: z.number().int().positive(),\n /**\n * The auto-renewing terms, when asked with `autoRenew: true` (0.31.0):\n *\n * a plan its own terms\n * an upgrade the BUSINESS terms it would continue as, only while a\n * Premium auto-renewal runs (not being turned off): its\n * period, first charge at the Business end (corrected\n * 2026-11-28; this said \"null for an upgrade\", and the web's\n * \"Keep auto-renew on, as Business\" needs these terms)\n *\n * Null otherwise: a coupon, the membership, auto-renew off on this server,\n * an upgrade with no Premium auto-renewal running. A PREVIEW: it ignores\n * whether another auto-renewal holds the slot, so \"Switch to Premium at\n * renewal\" can show its terms while Business still renews; only\n * `POST /billing/auto-renewals` (or the order) refuses on the slot.\n */\n autoRenew: autoRenewTermsSchema.nullable().default(null),\n});\nexport type Quote = z.infer<typeof quoteSchema>;\n\n// ─── Orders ──────────────────────────────────────────────────────────────────\n\n/**\n * Where an order stands. ⚠ Stored: append only.\n *\n * created checkout open, nothing paid yet\n * paid captured and granted; has an invoice\n * granted_free a free coupon: granted with no payment and no invoice\n * expired not paid within `ORDER_TTL_MINUTES`\n * refund_pending staff refunded it; the gateway is returning the money\n * refunded the money is back; has a credit note\n * refund_failed the gateway could not return it; staff act from its dashboard\n */\nexport const ORDER_STATUS_VALUES = [\n 'created',\n 'paid',\n 'granted_free',\n 'expired',\n 'refund_pending',\n 'refunded',\n 'refund_failed',\n] as const;\nexport const orderStatusSchema = z.enum(ORDER_STATUS_VALUES);\nexport type OrderStatus = z.infer<typeof orderStatusSchema>;\n\n/**\n * `POST /billing/orders`. Billing details are required for anything paid (the\n * invoice needs a place of supply): the server refuses a paid order without\n * them (`billing.stateCode`, VALIDATION_ERROR). A free coupon issues no\n * invoice, so it needs none (0.12.0).\n */\nexport const createOrderBodySchema = z.object({\n item: purchaseItemSchema,\n couponCode: couponCodeSchema.optional(),\n billing: billingDetailsSchema.optional(),\n /**\n * Buy the plan as an AUTO-RENEWAL (0.31.0): consent, said explicitly on the\n * wire (the web's switch is on by default, the user's ruling; the request\n * still says it). Only for `item.kind: 'plan'`, without a coupon, while the\n * catalog's `autoRenewEnabled`: otherwise `AUTO_RENEW_NOT_OFFERED`. The\n * answer is then `status: 'subscription'`.\n */\n autoRenew: z.boolean().optional(),\n});\nexport type CreateOrderBody = z.infer<typeof createOrderBodySchema>;\n\n/**\n * Either done (a free coupon granted at once) or a checkout to open. The\n * checkout fields are Razorpay Checkout's own options; identity (name, email,\n * phone) is the server's, never typed by the caller.\n */\nexport const createOrderResponseSchema = z.discriminatedUnion('status', [\n z.object({ status: z.literal('granted'), orderId: objectIdSchema }),\n z.object({\n status: z.literal('checkout'),\n orderId: objectIdSchema,\n expiresAt: z.iso.datetime(),\n checkout: z.object({\n keyId: z.string().min(1),\n razorpayOrderId: z.string().min(1),\n amount: paiseSchema,\n currency: z.literal('INR'),\n /** The merchant name on the dialog. */\n name: z.string(),\n /** What is being bought, under the name. */\n description: z.string(),\n prefill: z.object({\n name: z.string(),\n email: z.string(),\n contact: z.string().optional(),\n }),\n }),\n }),\n /**\n * An auto-renewal to authorise at Checkout (0.31.0): Razorpay Checkout is\n * opened with `subscription_id`, never `order_id` or an amount. `orderId` is\n * the first charge's order when one is taken now (`terms.chargesNow`): poll\n * it as any order. With nothing taken now it is null: poll the\n * auto-renewal instead. Its handler's answer goes to\n * `POST /billing/auto-renewals/:autoRenewalId/confirm`.\n */\n z.object({\n status: z.literal('subscription'),\n autoRenewalId: objectIdSchema,\n orderId: objectIdSchema.nullable(),\n /** Authorise before this, or it lapses (`expired`). */\n expiresAt: z.iso.datetime(),\n terms: autoRenewTermsSchema,\n checkout: z.object({\n keyId: z.string().min(1),\n razorpaySubscriptionId: z.string().min(1),\n name: z.string(),\n description: z.string(),\n prefill: z.object({\n name: z.string(),\n email: z.string(),\n contact: z.string().optional(),\n }),\n }),\n }),\n]);\nexport type CreateOrderResponse = z.infer<typeof createOrderResponseSchema>;\n\nexport const orderParamsSchema = z.object({ orderId: objectIdSchema });\nexport type OrderParams = z.infer<typeof orderParamsSchema>;\n\n/** What Razorpay Checkout's `handler` hands back, as it names it. */\nexport const confirmOrderBodySchema = z.object({\n razorpayOrderId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpayPaymentId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpaySignature: z.string().min(1).max(RAZORPAY_SIGNATURE_MAX),\n});\nexport type ConfirmOrderBody = z.infer<typeof confirmOrderBodySchema>;\n\n// ─── Auto-renewals (0.31.0) ──────────────────────────────────────────────────\n\nexport const autoRenewalParamsSchema = z.object({ autoRenewalId: objectIdSchema });\nexport type AutoRenewalParams = z.infer<typeof autoRenewalParamsSchema>;\n\n/**\n * `POST /billing/auto-renewals`: turn auto-renew ON for the plan time already\n * held (Me > Plans, after turning it off, after an upgrade). Nothing is taken\n * now; the first charge is when the time it follows ends (`terms.chargesNow`\n * false):\n *\n * the tier's own time held it starts when that tier's time ends\n * Premium while only Business is held (a DOWNGRADE, \"switch to Premium at\n * renewal\") it starts when the Business time ends\n *\n * Refused (`AUTO_RENEW_NOT_OFFERED`) with no plan time held (buy the plan with\n * `autoRenew` instead), for Business while only Premium is held (that is an\n * upgrade), while another auto-renewal holds the slot (one whose stop is\n * already requested does not), or while auto-renew is off on this server.\n *\n * `billing`: the place of supply every renewal's invoice needs. Without it the\n * member's saved details are used; with neither, `VALIDATION_ERROR` on\n * `billing.stateCode`, as for an order.\n */\nexport const startAutoRenewalBodySchema = z.object({\n tier: planTierSchema,\n period: planPeriodSchema,\n billing: billingDetailsSchema.optional(),\n});\nexport type StartAutoRenewalBody = z.infer<typeof startAutoRenewalBodySchema>;\n\n/**\n * What Razorpay Checkout's `handler` hands back for a subscription, as it\n * names it. The server checks the signature over its OWN stored subscription\n * id, never the one sent here: HMAC_SHA256(razorpay_payment_id + \"|\" +\n * subscription_id, key secret).\n */\nexport const confirmAutoRenewalBodySchema = z.object({\n razorpaySubscriptionId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpayPaymentId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpaySignature: z.string().min(1).max(RAZORPAY_SIGNATURE_MAX),\n});\nexport type ConfirmAutoRenewalBody = z.infer<typeof confirmAutoRenewalBodySchema>;\n\n/** An auto-renewal as its member polls or changes it. */\nexport const autoRenewalStateSchema = z.object({\n autoRenewalId: objectIdSchema,\n status: autoRenewalStatusSchema,\n tier: planTierSchema,\n period: planPeriodSchema,\n /** The first charge's order, when one was taken at authorisation: poll it for the grant. */\n orderId: objectIdSchema.nullable(),\n nextChargeAt: z.iso.datetime().nullable(),\n cancelAtCycleEnd: z.boolean(),\n});\nexport type AutoRenewalState = z.infer<typeof autoRenewalStateSchema>;\n\n/**\n * `POST /billing/auto-renewals/:id/payment-method`: how the member updates the\n * method a failed charge used. A card mandate opens Checkout to change the\n * card (`subscription_card_change`); any other opens Razorpay's own page,\n * where a UPI or eMandate can move to a card only (Razorpay's rule).\n */\nexport const paymentMethodUpdateSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('checkout'),\n keyId: z.string().min(1),\n razorpaySubscriptionId: z.string().min(1),\n name: z.string(),\n prefill: z.object({\n name: z.string(),\n email: z.string(),\n contact: z.string().optional(),\n }),\n }),\n z.object({ kind: z.literal('link'), url: z.url() }),\n]);\nexport type PaymentMethodUpdate = z.infer<typeof paymentMethodUpdateSchema>;\n\n/**\n * Where an order came from (0.31.0). ⚠ Stored: append only.\n *\n * checkout the member bought it (or a free code granted it)\n * renewal an auto-renewal's charge\n */\nexport const ORDER_SOURCE_VALUES = ['checkout', 'renewal'] as const;\nexport const orderSourceSchema = z.enum(ORDER_SOURCE_VALUES);\nexport type OrderSource = z.infer<typeof orderSourceSchema>;\n\n/** An order as its buyer polls it. */\nexport const orderStateSchema = z.object({\n orderId: objectIdSchema,\n item: purchaseItemSchema,\n status: orderStatusSchema,\n /**\n * The money was taken but what it bought could not be applied (bought\n * twice in two tabs, the plan changed while paying): it is refunded in\n * full, by itself. The client says so instead of \"done\".\n */\n notApplied: z.boolean(),\n});\nexport type OrderState = z.infer<typeof orderStateSchema>;\n\n// ─── Payments, invoices, credit notes ────────────────────────────────────────\n\n/** A party on an invoice. The supplier always has a GSTIN on a real invoice; a buyer, only on B2B. */\nexport const invoicePartySchema = z.object({\n name: z.string(),\n address: z.string().nullable(),\n gstin: z.string().nullable(),\n stateCode: gstStateCodeSchema,\n stateName: z.string(),\n});\nexport type InvoiceParty = z.infer<typeof invoicePartySchema>;\n\n/** B2B with the buyer's GSTIN, B2C without (0.18.0: the values, for the backend's model). */\nexport const INVOICE_KIND_VALUES = ['b2b', 'b2c'] as const;\nexport const invoiceKindSchema = z.enum(INVOICE_KIND_VALUES);\nexport type InvoiceKind = z.infer<typeof invoiceKindSchema>;\n\n/** A tax invoice, frozen when the payment was captured. */\nexport const invoiceSchema = z.object({\n /** e.g. `FC/26-27/000123`: sequential within a financial year, at most `INVOICE_NUMBER_MAX`. */\n number: z.string().max(INVOICE_NUMBER_MAX),\n issuedAt: z.iso.datetime(),\n /**\n * Issued where the supplier's GSTIN is not configured (dev, Razorpay test\n * mode): marked \"TEST: not a tax invoice\". Never true in production.\n */\n test: z.boolean(),\n supplier: invoicePartySchema,\n buyer: invoicePartySchema,\n kind: invoiceKindSchema,\n /** The service's accounting code (SAC). */\n sac: z.string(),\n description: z.string(),\n tax: taxSplitSchema,\n /** Always false: these services are never under reverse charge. */\n reverseCharge: z.literal(false),\n razorpayPaymentId: z.string(),\n});\nexport type Invoice = z.infer<typeof invoiceSchema>;\n\n/** A refund's credit note, against its invoice. */\nexport const creditNoteSchema = z.object({\n /** e.g. `FCCN/26-27/00012`: the invoice series + `CN`, sequential within a financial year. */\n number: z.string().max(INVOICE_NUMBER_MAX),\n issuedAt: z.iso.datetime(),\n invoiceNumber: z.string().max(INVOICE_NUMBER_MAX),\n tax: taxSplitSchema,\n});\nexport type CreditNote = z.infer<typeof creditNoteSchema>;\n\n/** One purchase in a member's history. Only settled orders are listed, never an abandoned checkout. */\nexport const paymentSummarySchema = z.object({\n id: objectIdSchema,\n item: purchaseItemSchema,\n title: z.string(),\n total: paiseSchema,\n status: orderStatusSchema,\n /** When it was captured, or granted for a free coupon. */\n paidAt: z.iso.datetime(),\n invoiceNumber: z.string().nullable(),\n /** Until when a refund may be asked for; null once refunded or for a free coupon. */\n refundableUntil: z.iso.datetime().nullable(),\n /** A purchase or an auto-renewal's charge (0.31.0): the history says \"Renewal\". */\n source: orderSourceSchema.default('checkout'),\n /** How it was paid (0.31.0); null for a free coupon and for payments from before 0.31.0. */\n method: paymentMethodSnapshotSchema.nullable().default(null),\n});\nexport type PaymentSummary = z.infer<typeof paymentSummarySchema>;\n\nexport const paymentPageSchema = paginatedSchema(paymentSummarySchema);\nexport type PaymentPage = z.infer<typeof paymentPageSchema>;\n\nexport const paymentDetailSchema = paymentSummarySchema.extend({\n listPrice: paiseSchema,\n discount: paiseSchema,\n coupon: appliedCouponSchema.nullable(),\n invoice: invoiceSchema.nullable(),\n creditNote: creditNoteSchema.nullable(),\n refundedAt: z.iso.datetime().nullable(),\n});\nexport type PaymentDetail = z.infer<typeof paymentDetailSchema>;\n\n// ─── Staff: payments and refunds ─────────────────────────────────────────────\n\n/** Who paid, as they are now, so staff can find them. Email only for a role that may read it. */\nexport const payerSchema = personSchema.extend({\n email: z.string().nullable(),\n});\nexport type Payer = z.infer<typeof payerSchema>;\n\nexport const staffPaymentsQuerySchema = paginationQuerySchema.extend({\n status: orderStatusSchema.optional(),\n memberId: objectIdSchema.optional(),\n /** Only the ones a person must act on (`needsAction` below). */\n needsAction: z.preprocess(emptyStringToUndefined, z.stringbool().default(false)),\n});\nexport type StaffPaymentsQuery = z.infer<typeof staffPaymentsQuerySchema>;\nexport type StaffPaymentsQueryInput = z.input<typeof staffPaymentsQuerySchema>;\n\nexport const staffPaymentSummarySchema = paymentSummarySchema.extend({\n payer: payerSchema,\n /**\n * A person must act (0.12.0): taken but not applied and not yet refunded\n * (the automatic refund did not go through), a refund that failed at the\n * gateway, or an open chargeback.\n */\n needsAction: z.boolean(),\n});\nexport type StaffPaymentSummary = z.infer<typeof staffPaymentSummarySchema>;\nexport const staffPaymentPageSchema = paginatedSchema(staffPaymentSummarySchema);\nexport type StaffPaymentPage = z.infer<typeof staffPaymentPageSchema>;\n\nexport const staffPaymentDetailSchema = paymentDetailSchema.extend({\n payer: payerSchema,\n razorpay: z.object({\n orderId: z.string().nullable(),\n paymentId: z.string().nullable(),\n refundId: z.string().nullable(),\n /** The auto-renewal's subscription, for a renewal charge (0.31.0). */\n subscriptionId: z.string().nullable().default(null),\n }),\n /** Why staff refunded it, on record. */\n refundReason: z.string().nullable(),\n /**\n * The money was taken but what it bought could not be applied when it was\n * captured (they were a member already, the Premium time to upgrade had\n * run out, past the 3-year cap): refund it. Null when it applied. One of\n * `GRANT_FAILURE_VALUES` (0.18.0; a plain string before).\n */\n grantFailed: grantFailureSchema.nullable(),\n /** A chargeback was opened on it (cleared when it is won or closed). */\n disputedAt: z.iso.datetime().nullable(),\n /**\n * What refunds made outside Founder Circle (the Razorpay dashboard) have\n * already given back of this payment. A Refund here gives back the rest:\n * `total` less this. 0 when there were none.\n */\n refundedOutside: paiseSchema,\n /**\n * Payments captured on this order other than the one that settled it (a\n * late authorisation, a second Checkout attempt): each is refunded by\n * itself; `refunded: false` means that refund has not gone through yet and\n * the payment needs a person.\n */\n strayPayments: z.array(\n z.object({\n paymentId: z.string(),\n amount: paiseSchema,\n refunded: z.boolean(),\n at: z.iso.datetime(),\n }),\n ),\n /**\n * When the payer asked for a refund (0.13.0): their first \"Payments and\n * refunds\" ticket opened inside the refund window. An ask in time keeps the\n * payment refundable after the window ends. Null when they did not ask in\n * time, or it is not a paid payment.\n */\n refundAskedAt: z.iso.datetime().nullable(),\n viewer: z.object({\n /**\n * Paid, within the window (or asked for within it), not their own, and\n * the asker may refund.\n */\n canRefund: z.boolean(),\n }),\n});\nexport type StaffPaymentDetail = z.infer<typeof staffPaymentDetailSchema>;\n\nconst reasonSchema = z.string().trim().min(BILLING_REASON_MIN).max(BILLING_REASON_MAX);\n\n/** `POST /staff/payments/:orderId/refund`. The reason is on the audit record. */\nexport const refundPaymentBodySchema = z.object({ reason: reasonSchema });\nexport type RefundPaymentBody = z.infer<typeof refundPaymentBodySchema>;\n\n/**\n * `PUT /members/:memberId/membership`: grant (a partner, a press account) or\n * revoke (a fake or duplicate account holding a founding place). A paid one\n * is never revoked: refund its payment.\n */\nexport const setMembershipBodySchema = z.object({\n granted: z.boolean(),\n reason: reasonSchema,\n});\nexport type SetMembershipBody = z.infer<typeof setMembershipBodySchema>;\n\n// ─── Staff: coupons ──────────────────────────────────────────────────────────\n\n/** What a coupon is good for. A percent coupon names what it applies to. */\nexport const COUPON_TARGET_VALUES = ['membership', 'premium', 'business'] as const;\nexport const couponTargetSchema = z.enum(COUPON_TARGET_VALUES);\nexport type CouponTarget = z.infer<typeof couponTargetSchema>;\n\n/**\n * ⚠ Stored: append only.\n *\n * free_membership the membership at Rs 0; `founding` numbers its holders\n * (\"Founding member #N\"). ⚠ A NEW founding coupon is refused\n * (0.14.0, COUPON_FOUNDING_RETIRED): founding places come\n * from the launch waitlist alone. The field stays, because\n * stored coupons carry it.\n * percent_off a share off the listed price of what it applies to\n */\nexport const COUPON_KIND_VALUES = ['free_membership', 'percent_off'] as const;\nexport type CouponKind = (typeof COUPON_KIND_VALUES)[number];\n\nexport const couponBenefitSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('free_membership'), founding: z.boolean() }),\n z.object({\n kind: z.literal('percent_off'),\n percent: z.number().int().min(COUPON_PERCENT_MIN).max(COUPON_PERCENT_MAX),\n appliesTo: z\n .array(couponTargetSchema)\n .min(1)\n .max(COUPON_TARGET_VALUES.length)\n .refine(eachOnce, {\n error: VALIDATION_MESSAGE.couponTargetsDuplicate,\n }),\n }),\n]);\nexport type CouponBenefit = z.infer<typeof couponBenefitSchema>;\n\nexport const couponSchema = z.object({\n id: objectIdSchema,\n code: z.string(),\n label: z.string(),\n benefit: couponBenefitSchema,\n /** Redemptions allowed in all; null is no cap. */\n max: z.number().int().positive().nullable(),\n /** Redemptions in force (a revoked founding place frees one). */\n used: z.number().int().nonnegative(),\n active: z.boolean(),\n validFrom: z.iso.datetime().nullable(),\n validUntil: z.iso.datetime().nullable(),\n createdAt: z.iso.datetime(),\n});\nexport type Coupon = z.infer<typeof couponSchema>;\n\n/** Never paged: coupons are few. Newest first. */\nexport const couponListSchema = z.object({ items: z.array(couponSchema) });\nexport type CouponList = z.infer<typeof couponListSchema>;\n\nexport const couponParamsSchema = z.object({ couponId: objectIdSchema });\nexport type CouponParams = z.infer<typeof couponParamsSchema>;\n\nconst windowValid = (body: { validFrom?: string | null; validUntil?: string | null }) =>\n !body.validFrom || !body.validUntil || Date.parse(body.validFrom) < Date.parse(body.validUntil);\n\nexport const createCouponBodySchema = z\n .object({\n code: couponCodeSchema,\n label: z.string().trim().min(COUPON_LABEL_MIN).max(COUPON_LABEL_MAX),\n benefit: couponBenefitSchema,\n max: z.number().int().positive().max(COUPON_USES_MAX).nullable(),\n validFrom: z.iso.datetime().nullable().optional(),\n validUntil: z.iso.datetime().nullable().optional(),\n })\n .refine(windowValid, { path: ['validUntil'], error: VALIDATION_MESSAGE.couponWindowInvalid });\nexport type CreateCouponBody = z.infer<typeof createCouponBodySchema>;\n\n/**\n * What may change on a live coupon. The code and the benefit never change: a\n * redemption is a record of what a code gave when it was used.\n */\nexport const updateCouponBodySchema = z\n .object({\n label: z.string().trim().min(COUPON_LABEL_MIN).max(COUPON_LABEL_MAX).optional(),\n active: z.boolean().optional(),\n max: z.number().int().positive().max(COUPON_USES_MAX).nullable().optional(),\n validFrom: z.iso.datetime().nullable().optional(),\n validUntil: z.iso.datetime().nullable().optional(),\n })\n .refine(windowValid, { path: ['validUntil'], error: VALIDATION_MESSAGE.couponWindowInvalid });\nexport type UpdateCouponBody = z.infer<typeof updateCouponBodySchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/domains/billing/billing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,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M,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: buying, paying, invoices, refunds and coupons (0.12.0)\n *\n * POST /api/v1/billing/quote quoteBodySchema -> quoteSchema\n * POST /api/v1/billing/orders createOrderBodySchema -> createOrderResponseSchema\n * GET /api/v1/billing/orders/:orderId orderStateSchema (polled while \"processing\")\n * POST /api/v1/billing/orders/:orderId/confirm confirmOrderBodySchema -> orderStateSchema\n * GET /api/v1/billing/payments paymentPageSchema (mine)\n * GET /api/v1/billing/payments/:orderId paymentDetailSchema (mine, with the invoice)\n *\n * Staff (by the ability: support reads; managers refund and run coupons):\n * GET /api/v1/staff/payments staffPaymentsQuerySchema -> staffPaymentPageSchema\n * GET /api/v1/staff/payments/:orderId staffPaymentDetailSchema\n * POST /api/v1/staff/payments/:orderId/refund refundPaymentBodySchema -> staffPaymentDetailSchema\n * GET /api/v1/staff/coupons couponListSchema\n * POST /api/v1/staff/coupons createCouponBodySchema -> couponSchema\n * PATCH /api/v1/staff/coupons/:couponId updateCouponBodySchema -> couponSchema\n * PUT /api/v1/members/:memberId/membership setMembershipBodySchema -> memberDetailSchema\n *\n * Auto-renewal (0.31.0, payments v2; founder-circle-backend docs/payments-v2-plan.md 3a):\n * POST /api/v1/billing/auto-renewals startAutoRenewalBodySchema -> createOrderResponseSchema ('subscription')\n * GET /api/v1/billing/auto-renewals/:autoRenewalId autoRenewalStateSchema (polled after authorising)\n * POST /api/v1/billing/auto-renewals/:autoRenewalId/confirm confirmAutoRenewalBodySchema -> autoRenewalStateSchema\n * POST /api/v1/billing/auto-renewals/:autoRenewalId/cancel -> autoRenewalStateSchema (off at the period's end)\n * POST /api/v1/billing/auto-renewals/:autoRenewalId/payment-method -> paymentMethodUpdateSchema\n * (a plan bought with `autoRenew: true` on POST /billing/orders answers 'subscription' too)\n *\n * THE ONE RULE: THE SERVER PRICES, THE CLIENT CHOOSES. A request names what it\n * wants (an item) and maybe a coupon CODE; it never names an amount. Every\n * amount here is the server's, in integer paise, GST included.\n *\n * TWO PATHS IN, ONE GRANT. A payment reaches the server from the browser the\n * moment checkout returns (`confirm`) and from the gateway's webhook. Either\n * grants; the second is a no-op. So a member who closes the tab is still\n * granted, and `confirm` failing never means \"not paid\": the web says\n * \"processing\" and polls the order.\n *\n * GST: the company is registered, every captured payment gets a tax invoice,\n * every refund a credit note. Where the buyer is decides the tax: in the\n * supplier's state CGST + SGST, elsewhere IGST. So checkout asks for the state.\n *\n * @module founder-schema/domains/billing\n */\n\nimport { z } from 'zod';\nimport {\n eachOnce,\n emptyStringToUndefined,\n objectIdSchema,\n paginationQuerySchema,\n} from '../../core/common.js';\nimport {\n BILLING_REASON_MAX,\n BILLING_REASON_MIN,\n COUPON_CODE_MAX,\n COUPON_CODE_MIN,\n COUPON_LABEL_MAX,\n COUPON_LABEL_MIN,\n COUPON_PERCENT_MAX,\n COUPON_PERCENT_MIN,\n COUPON_USES_MAX,\n INVOICE_NUMBER_MAX,\n RAZORPAY_ID_MAX,\n RAZORPAY_SIGNATURE_MAX,\n} from '../../core/limits.js';\nimport { paginatedSchema } from '../../core/responses.js';\nimport { VALIDATION_MESSAGE } from '../../core/validation.js';\nimport {\n autoRenewalStatusSchema,\n paiseSchema,\n planPeriodSchema,\n planTierSchema,\n} from '../membership/membership.js';\nimport { personSchema } from '../people/person.js';\nimport { billingDetailsSchema, gstStateCodeSchema } from './gst.js';\nimport { paymentMethodSnapshotSchema } from './payment-method.js';\n\nexport {\n type BillingDetails,\n billingDetailsSchema,\n GST_RATE_PERCENT,\n GST_STATE_CODE_VALUES,\n GST_STATES,\n type GstStateCode,\n gstinChecksumValid,\n gstinSchema,\n gstStateCodeOf,\n gstStateCodeSchema,\n gstStateName,\n} from './gst.js';\n\n// ─── What can be bought ──────────────────────────────────────────────────────\n\n/** ⚠ Stored on every order: append only. */\nexport const PURCHASE_KIND_VALUES = ['membership', 'plan', 'upgrade'] as const;\nexport type PurchaseKind = (typeof PURCHASE_KIND_VALUES)[number];\n\n/**\n * The thing asked for.\n *\n * membership Rs 99, once\n * plan a month or a year of Premium or Business, appended\n * upgrade the Premium time left, turned into Business, for the difference\n */\nexport const purchaseItemSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('membership') }),\n z.object({ kind: z.literal('plan'), tier: planTierSchema, period: planPeriodSchema }),\n z.object({ kind: z.literal('upgrade') }),\n]);\nexport type PurchaseItem = z.infer<typeof purchaseItemSchema>;\n\n/** A coupon code as typed: letters, digits, hyphens; compared upper-case. */\nexport const couponCodeSchema = z\n .string()\n .trim()\n .min(COUPON_CODE_MIN)\n .max(COUPON_CODE_MAX)\n .regex(/^[A-Za-z0-9-]+$/, VALIDATION_MESSAGE.couponCodeInvalid)\n .transform((v) => v.toUpperCase());\n\n// ─── Quote ───────────────────────────────────────────────────────────────────\n\n/**\n * The tax inside a total. `taxable + cgst + sgst + igst = total`; either\n * CGST + SGST (buyer in the supplier's state) or IGST, never both.\n */\nexport const taxSplitSchema = z.object({\n ratePercent: z.number().int().positive(),\n taxable: paiseSchema,\n cgst: paiseSchema,\n sgst: paiseSchema,\n igst: paiseSchema,\n total: paiseSchema,\n});\nexport type TaxSplit = z.infer<typeof taxSplitSchema>;\n\n/**\n * `POST /billing/quote`. The state is optional: without it, no tax split.\n * `autoRenew` (0.31.0): price it as an auto-renewing plan, so the quote carries\n * the terms the member must see before authorising (`quote.autoRenew`).\n */\nexport const quoteBodySchema = z.object({\n item: purchaseItemSchema,\n couponCode: couponCodeSchema.optional(),\n stateCode: gstStateCodeSchema.optional(),\n autoRenew: z.boolean().optional(),\n});\nexport type QuoteBody = z.infer<typeof quoteBodySchema>;\n\n/** What a plan or an upgrade would do to the plan, priced now. */\nexport const planEffectSchema = z.object({\n tier: planTierSchema,\n /** When this purchase's time starts (later than now when it waits its turn). */\n startsAt: z.iso.datetime(),\n endsAt: z.iso.datetime(),\n /** For an upgrade: the days of Premium turned into Business. */\n upgradedDays: z.number().int().positive().nullable(),\n});\nexport type PlanEffect = z.infer<typeof planEffectSchema>;\n\n/** A coupon as a purchase carries it: its code and staff's name for it. */\nexport const appliedCouponSchema = z.object({ code: z.string(), label: z.string() });\nexport type AppliedCoupon = z.infer<typeof appliedCouponSchema>;\n\n/**\n * Why a captured payment was NOT applied (`grantFailed`), and so refunded\n * (0.18.0: the one list; the backend wrote two of these as loose strings and\n * the contract said `string`). Stored on the order: append only.\n *\n * AMOUNT_MISMATCH the gateway captured another amount than the price\n * ACCOUNT_DELETED paid after the account was deleted\n * COUPON_ALREADY_USED the code went to another of their orders, paid first\n * MEMBERSHIP_REQUIRED a plan, but the membership is gone (refunded, withdrawn)\n * ALREADY_MEMBER a membership, but they are a member already\n * PLAN_CHANGED an upgrade priced on a plan that has since changed\n * PLAN_NOTHING_TO_UPGRADE an upgrade with no Premium time left\n * PLAN_TERM_LIMIT past `PLAN_AHEAD_MAX_YEARS` of plan time\n * PLAN_UPGRADE_INSTEAD Business bought while on Premium (that is an upgrade)\n * AUTO_RENEW_STOPPED an auto-renewal's charge that landed after the\n * auto-renewal was stopped at once (a refund, the\n * membership ended, the account deleted) and the\n * gateway's cancel had not taken yet (0.31.0)\n * GRANT_REFUSED any other refusal of the grant: still recorded and\n * refunded, never left captured for nothing (the\n * server logs which one, to add it here)\n */\nexport const GRANT_FAILURE_VALUES = [\n 'AMOUNT_MISMATCH',\n 'ACCOUNT_DELETED',\n 'COUPON_ALREADY_USED',\n 'MEMBERSHIP_REQUIRED',\n 'ALREADY_MEMBER',\n 'PLAN_CHANGED',\n 'PLAN_NOTHING_TO_UPGRADE',\n 'PLAN_TERM_LIMIT',\n 'PLAN_UPGRADE_INSTEAD',\n 'GRANT_REFUSED',\n 'AUTO_RENEW_STOPPED',\n] as const;\nexport const grantFailureSchema = z.enum(GRANT_FAILURE_VALUES);\nexport type GrantFailure = z.infer<typeof grantFailureSchema>;\n\n/**\n * What an auto-renewing plan will charge (0.31.0), for the disclosure next to\n * Pay. India's 2023 dark-pattern guidelines: the member is told, before\n * authorising, that it renews, how much, how often and from when, and that it\n * can be turned off.\n *\n * chargesNow true: `amount` is taken now and buys the first period.\n * false: time of this tier is already held, so nothing is\n * taken now; the mandate is authorised and the first charge is\n * on `firstChargeAt`, when that time ends.\n * firstChargeAt now (chargesNow) or the end of the time held\n * nextChargeAt the charge after the first: one `period` later, India's calendar\n */\nexport const autoRenewTermsSchema = z.object({\n amount: paiseSchema,\n period: planPeriodSchema,\n chargesNow: z.boolean(),\n firstChargeAt: z.iso.datetime(),\n nextChargeAt: z.iso.datetime(),\n});\nexport type AutoRenewTerms = z.infer<typeof autoRenewTermsSchema>;\n\nexport const quoteSchema = z.object({\n item: purchaseItemSchema,\n /** \"Membership\", \"Premium, 1 month\", \"Upgrade to Business\": the server's words. */\n title: z.string(),\n listPrice: paiseSchema,\n discount: paiseSchema,\n /** What would be charged. Zero for a free-membership coupon: no checkout at all. */\n total: paiseSchema,\n coupon: appliedCouponSchema.nullable(),\n /** Null for a membership. */\n plan: planEffectSchema.nullable(),\n /** Null without a state. */\n tax: taxSplitSchema.nullable(),\n refundWindowDays: z.number().int().positive(),\n /**\n * The auto-renewing terms, when asked with `autoRenew: true` (0.31.0):\n *\n * a plan its own terms\n * an upgrade the BUSINESS terms it would continue as, only while a\n * Premium auto-renewal runs (not being turned off): its\n * period, first charge at the Business end (corrected\n * 2026-11-28; this said \"null for an upgrade\", and the web's\n * \"Keep auto-renew on, as Business\" needs these terms)\n *\n * Null otherwise: a coupon, the membership, auto-renew off on this server,\n * an upgrade with no Premium auto-renewal running. A PREVIEW: it ignores\n * whether another auto-renewal holds the slot, so \"Switch to Premium at\n * renewal\" can show its terms while Business still renews; only\n * `POST /billing/auto-renewals` (or the order) refuses on the slot.\n */\n autoRenew: autoRenewTermsSchema.nullable().default(null),\n});\nexport type Quote = z.infer<typeof quoteSchema>;\n\n// ─── Orders ──────────────────────────────────────────────────────────────────\n\n/**\n * Where an order stands. ⚠ Stored: append only.\n *\n * created checkout open, nothing paid yet\n * paid captured and granted; has an invoice\n * granted_free a free coupon: granted with no payment and no invoice\n * expired not paid within `ORDER_TTL_MINUTES`\n * refund_pending staff refunded it; the gateway is returning the money\n * refunded the money is back; has a credit note\n * refund_failed the gateway could not return it; staff act from its dashboard\n */\nexport const ORDER_STATUS_VALUES = [\n 'created',\n 'paid',\n 'granted_free',\n 'expired',\n 'refund_pending',\n 'refunded',\n 'refund_failed',\n] as const;\nexport const orderStatusSchema = z.enum(ORDER_STATUS_VALUES);\nexport type OrderStatus = z.infer<typeof orderStatusSchema>;\n\n/**\n * `POST /billing/orders`. Billing details are required for anything paid (the\n * invoice needs a place of supply): the server refuses a paid order without\n * them (`billing.stateCode`, VALIDATION_ERROR). A free coupon issues no\n * invoice, so it needs none (0.12.0).\n */\nexport const createOrderBodySchema = z.object({\n item: purchaseItemSchema,\n couponCode: couponCodeSchema.optional(),\n billing: billingDetailsSchema.optional(),\n /**\n * Buy the plan as an AUTO-RENEWAL (0.31.0): consent, said explicitly on the\n * wire (the web's switch is on by default, the user's ruling; the request\n * still says it). Only for `item.kind: 'plan'`, without a coupon, while the\n * catalog's `autoRenewEnabled`, for a term in its `autoRenewPeriods`:\n * otherwise `AUTO_RENEW_NOT_OFFERED`. The\n * answer is then `status: 'subscription'`.\n */\n autoRenew: z.boolean().optional(),\n});\nexport type CreateOrderBody = z.infer<typeof createOrderBodySchema>;\n\n/**\n * Either done (a free coupon granted at once) or a checkout to open. The\n * checkout fields are Razorpay Checkout's own options; identity (name, email,\n * phone) is the server's, never typed by the caller.\n */\nexport const createOrderResponseSchema = z.discriminatedUnion('status', [\n z.object({ status: z.literal('granted'), orderId: objectIdSchema }),\n z.object({\n status: z.literal('checkout'),\n orderId: objectIdSchema,\n expiresAt: z.iso.datetime(),\n checkout: z.object({\n keyId: z.string().min(1),\n razorpayOrderId: z.string().min(1),\n amount: paiseSchema,\n currency: z.literal('INR'),\n /** The merchant name on the dialog. */\n name: z.string(),\n /** What is being bought, under the name. */\n description: z.string(),\n prefill: z.object({\n name: z.string(),\n email: z.string(),\n contact: z.string().optional(),\n }),\n }),\n }),\n /**\n * An auto-renewal to authorise at Checkout (0.31.0): Razorpay Checkout is\n * opened with `subscription_id`, never `order_id` or an amount. `orderId` is\n * the first charge's order when one is taken now (`terms.chargesNow`): poll\n * it as any order. With nothing taken now it is null: poll the\n * auto-renewal instead. Its handler's answer goes to\n * `POST /billing/auto-renewals/:autoRenewalId/confirm`.\n */\n z.object({\n status: z.literal('subscription'),\n autoRenewalId: objectIdSchema,\n orderId: objectIdSchema.nullable(),\n /** Authorise before this, or it lapses (`expired`). */\n expiresAt: z.iso.datetime(),\n terms: autoRenewTermsSchema,\n checkout: z.object({\n keyId: z.string().min(1),\n razorpaySubscriptionId: z.string().min(1),\n name: z.string(),\n description: z.string(),\n prefill: z.object({\n name: z.string(),\n email: z.string(),\n contact: z.string().optional(),\n }),\n }),\n }),\n]);\nexport type CreateOrderResponse = z.infer<typeof createOrderResponseSchema>;\n\nexport const orderParamsSchema = z.object({ orderId: objectIdSchema });\nexport type OrderParams = z.infer<typeof orderParamsSchema>;\n\n/** What Razorpay Checkout's `handler` hands back, as it names it. */\nexport const confirmOrderBodySchema = z.object({\n razorpayOrderId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpayPaymentId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpaySignature: z.string().min(1).max(RAZORPAY_SIGNATURE_MAX),\n});\nexport type ConfirmOrderBody = z.infer<typeof confirmOrderBodySchema>;\n\n// ─── Auto-renewals (0.31.0) ──────────────────────────────────────────────────\n\nexport const autoRenewalParamsSchema = z.object({ autoRenewalId: objectIdSchema });\nexport type AutoRenewalParams = z.infer<typeof autoRenewalParamsSchema>;\n\n/**\n * `POST /billing/auto-renewals`: turn auto-renew ON for the plan time already\n * held (Me > Plans, after turning it off, after an upgrade). Nothing is taken\n * now; the first charge is when the time it follows ends (`terms.chargesNow`\n * false):\n *\n * the tier's own time held it starts when that tier's time ends\n * Premium while only Business is held (a DOWNGRADE, \"switch to Premium at\n * renewal\") it starts when the Business time ends\n *\n * Refused (`AUTO_RENEW_NOT_OFFERED`) with no plan time held (buy the plan with\n * `autoRenew` instead), for Business while only Premium is held (that is an\n * upgrade), while another auto-renewal holds the slot (one whose stop is\n * already requested does not), for a term not in the catalog's\n * `autoRenewPeriods`, or while auto-renew is off on this server.\n *\n * `billing`: the place of supply every renewal's invoice needs. Without it the\n * member's saved details are used; with neither, `VALIDATION_ERROR` on\n * `billing.stateCode`, as for an order.\n */\nexport const startAutoRenewalBodySchema = z.object({\n tier: planTierSchema,\n period: planPeriodSchema,\n billing: billingDetailsSchema.optional(),\n});\nexport type StartAutoRenewalBody = z.infer<typeof startAutoRenewalBodySchema>;\n\n/**\n * What Razorpay Checkout's `handler` hands back for a subscription, as it\n * names it. The server checks the signature over its OWN stored subscription\n * id, never the one sent here: HMAC_SHA256(razorpay_payment_id + \"|\" +\n * subscription_id, key secret).\n */\nexport const confirmAutoRenewalBodySchema = z.object({\n razorpaySubscriptionId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpayPaymentId: z.string().min(1).max(RAZORPAY_ID_MAX),\n razorpaySignature: z.string().min(1).max(RAZORPAY_SIGNATURE_MAX),\n});\nexport type ConfirmAutoRenewalBody = z.infer<typeof confirmAutoRenewalBodySchema>;\n\n/** An auto-renewal as its member polls or changes it. */\nexport const autoRenewalStateSchema = z.object({\n autoRenewalId: objectIdSchema,\n status: autoRenewalStatusSchema,\n tier: planTierSchema,\n period: planPeriodSchema,\n /** The first charge's order, when one was taken at authorisation: poll it for the grant. */\n orderId: objectIdSchema.nullable(),\n nextChargeAt: z.iso.datetime().nullable(),\n cancelAtCycleEnd: z.boolean(),\n});\nexport type AutoRenewalState = z.infer<typeof autoRenewalStateSchema>;\n\n/**\n * `POST /billing/auto-renewals/:id/payment-method`: how the member updates the\n * method a failed charge used. A card mandate opens Checkout to change the\n * card (`subscription_card_change`); any other opens Razorpay's own page,\n * where a UPI or eMandate can move to a card only (Razorpay's rule).\n */\nexport const paymentMethodUpdateSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('checkout'),\n keyId: z.string().min(1),\n razorpaySubscriptionId: z.string().min(1),\n name: z.string(),\n prefill: z.object({\n name: z.string(),\n email: z.string(),\n contact: z.string().optional(),\n }),\n }),\n z.object({ kind: z.literal('link'), url: z.url() }),\n]);\nexport type PaymentMethodUpdate = z.infer<typeof paymentMethodUpdateSchema>;\n\n/**\n * Where an order came from (0.31.0). ⚠ Stored: append only.\n *\n * checkout the member bought it (or a free code granted it)\n * renewal an auto-renewal's charge\n */\nexport const ORDER_SOURCE_VALUES = ['checkout', 'renewal'] as const;\nexport const orderSourceSchema = z.enum(ORDER_SOURCE_VALUES);\nexport type OrderSource = z.infer<typeof orderSourceSchema>;\n\n/** An order as its buyer polls it. */\nexport const orderStateSchema = z.object({\n orderId: objectIdSchema,\n item: purchaseItemSchema,\n status: orderStatusSchema,\n /**\n * The money was taken but what it bought could not be applied (bought\n * twice in two tabs, the plan changed while paying): it is refunded in\n * full, by itself. The client says so instead of \"done\".\n */\n notApplied: z.boolean(),\n});\nexport type OrderState = z.infer<typeof orderStateSchema>;\n\n// ─── Payments, invoices, credit notes ────────────────────────────────────────\n\n/** A party on an invoice. The supplier always has a GSTIN on a real invoice; a buyer, only on B2B. */\nexport const invoicePartySchema = z.object({\n name: z.string(),\n address: z.string().nullable(),\n gstin: z.string().nullable(),\n stateCode: gstStateCodeSchema,\n stateName: z.string(),\n});\nexport type InvoiceParty = z.infer<typeof invoicePartySchema>;\n\n/** B2B with the buyer's GSTIN, B2C without (0.18.0: the values, for the backend's model). */\nexport const INVOICE_KIND_VALUES = ['b2b', 'b2c'] as const;\nexport const invoiceKindSchema = z.enum(INVOICE_KIND_VALUES);\nexport type InvoiceKind = z.infer<typeof invoiceKindSchema>;\n\n/** A tax invoice, frozen when the payment was captured. */\nexport const invoiceSchema = z.object({\n /** e.g. `FC/26-27/000123`: sequential within a financial year, at most `INVOICE_NUMBER_MAX`. */\n number: z.string().max(INVOICE_NUMBER_MAX),\n issuedAt: z.iso.datetime(),\n /**\n * Issued where the supplier's GSTIN is not configured (dev, Razorpay test\n * mode): marked \"TEST: not a tax invoice\". Never true in production.\n */\n test: z.boolean(),\n supplier: invoicePartySchema,\n buyer: invoicePartySchema,\n kind: invoiceKindSchema,\n /** The service's accounting code (SAC). */\n sac: z.string(),\n description: z.string(),\n tax: taxSplitSchema,\n /** Always false: these services are never under reverse charge. */\n reverseCharge: z.literal(false),\n razorpayPaymentId: z.string(),\n});\nexport type Invoice = z.infer<typeof invoiceSchema>;\n\n/** A refund's credit note, against its invoice. */\nexport const creditNoteSchema = z.object({\n /** e.g. `FCCN/26-27/00012`: the invoice series + `CN`, sequential within a financial year. */\n number: z.string().max(INVOICE_NUMBER_MAX),\n issuedAt: z.iso.datetime(),\n invoiceNumber: z.string().max(INVOICE_NUMBER_MAX),\n tax: taxSplitSchema,\n});\nexport type CreditNote = z.infer<typeof creditNoteSchema>;\n\n/** One purchase in a member's history. Only settled orders are listed, never an abandoned checkout. */\nexport const paymentSummarySchema = z.object({\n id: objectIdSchema,\n item: purchaseItemSchema,\n title: z.string(),\n total: paiseSchema,\n status: orderStatusSchema,\n /** When it was captured, or granted for a free coupon. */\n paidAt: z.iso.datetime(),\n invoiceNumber: z.string().nullable(),\n /** Until when a refund may be asked for; null once refunded or for a free coupon. */\n refundableUntil: z.iso.datetime().nullable(),\n /** A purchase or an auto-renewal's charge (0.31.0): the history says \"Renewal\". */\n source: orderSourceSchema.default('checkout'),\n /** How it was paid (0.31.0); null for a free coupon and for payments from before 0.31.0. */\n method: paymentMethodSnapshotSchema.nullable().default(null),\n});\nexport type PaymentSummary = z.infer<typeof paymentSummarySchema>;\n\nexport const paymentPageSchema = paginatedSchema(paymentSummarySchema);\nexport type PaymentPage = z.infer<typeof paymentPageSchema>;\n\nexport const paymentDetailSchema = paymentSummarySchema.extend({\n listPrice: paiseSchema,\n discount: paiseSchema,\n coupon: appliedCouponSchema.nullable(),\n invoice: invoiceSchema.nullable(),\n creditNote: creditNoteSchema.nullable(),\n refundedAt: z.iso.datetime().nullable(),\n});\nexport type PaymentDetail = z.infer<typeof paymentDetailSchema>;\n\n// ─── Staff: payments and refunds ─────────────────────────────────────────────\n\n/** Who paid, as they are now, so staff can find them. Email only for a role that may read it. */\nexport const payerSchema = personSchema.extend({\n email: z.string().nullable(),\n});\nexport type Payer = z.infer<typeof payerSchema>;\n\nexport const staffPaymentsQuerySchema = paginationQuerySchema.extend({\n status: orderStatusSchema.optional(),\n memberId: objectIdSchema.optional(),\n /** Only the ones a person must act on (`needsAction` below). */\n needsAction: z.preprocess(emptyStringToUndefined, z.stringbool().default(false)),\n});\nexport type StaffPaymentsQuery = z.infer<typeof staffPaymentsQuerySchema>;\nexport type StaffPaymentsQueryInput = z.input<typeof staffPaymentsQuerySchema>;\n\nexport const staffPaymentSummarySchema = paymentSummarySchema.extend({\n payer: payerSchema,\n /**\n * A person must act (0.12.0): taken but not applied and not yet refunded\n * (the automatic refund did not go through), a refund that failed at the\n * gateway, or an open chargeback.\n */\n needsAction: z.boolean(),\n});\nexport type StaffPaymentSummary = z.infer<typeof staffPaymentSummarySchema>;\nexport const staffPaymentPageSchema = paginatedSchema(staffPaymentSummarySchema);\nexport type StaffPaymentPage = z.infer<typeof staffPaymentPageSchema>;\n\nexport const staffPaymentDetailSchema = paymentDetailSchema.extend({\n payer: payerSchema,\n razorpay: z.object({\n orderId: z.string().nullable(),\n paymentId: z.string().nullable(),\n refundId: z.string().nullable(),\n /** The auto-renewal's subscription, for a renewal charge (0.31.0). */\n subscriptionId: z.string().nullable().default(null),\n }),\n /** Why staff refunded it, on record. */\n refundReason: z.string().nullable(),\n /**\n * The money was taken but what it bought could not be applied when it was\n * captured (they were a member already, the Premium time to upgrade had\n * run out, past the 3-year cap): refund it. Null when it applied. One of\n * `GRANT_FAILURE_VALUES` (0.18.0; a plain string before).\n */\n grantFailed: grantFailureSchema.nullable(),\n /** A chargeback was opened on it (cleared when it is won or closed). */\n disputedAt: z.iso.datetime().nullable(),\n /**\n * What refunds made outside Founder Circle (the Razorpay dashboard) have\n * already given back of this payment. A Refund here gives back the rest:\n * `total` less this. 0 when there were none.\n */\n refundedOutside: paiseSchema,\n /**\n * Payments captured on this order other than the one that settled it (a\n * late authorisation, a second Checkout attempt): each is refunded by\n * itself; `refunded: false` means that refund has not gone through yet and\n * the payment needs a person.\n */\n strayPayments: z.array(\n z.object({\n paymentId: z.string(),\n amount: paiseSchema,\n refunded: z.boolean(),\n at: z.iso.datetime(),\n }),\n ),\n /**\n * When the payer asked for a refund (0.13.0): their first \"Payments and\n * refunds\" ticket opened inside the refund window. An ask in time keeps the\n * payment refundable after the window ends. Null when they did not ask in\n * time, or it is not a paid payment.\n */\n refundAskedAt: z.iso.datetime().nullable(),\n viewer: z.object({\n /**\n * Paid, within the window (or asked for within it), not their own, and\n * the asker may refund.\n */\n canRefund: z.boolean(),\n }),\n});\nexport type StaffPaymentDetail = z.infer<typeof staffPaymentDetailSchema>;\n\nconst reasonSchema = z.string().trim().min(BILLING_REASON_MIN).max(BILLING_REASON_MAX);\n\n/** `POST /staff/payments/:orderId/refund`. The reason is on the audit record. */\nexport const refundPaymentBodySchema = z.object({ reason: reasonSchema });\nexport type RefundPaymentBody = z.infer<typeof refundPaymentBodySchema>;\n\n/**\n * `PUT /members/:memberId/membership`: grant (a partner, a press account) or\n * revoke (a fake or duplicate account holding a founding place). A paid one\n * is never revoked: refund its payment.\n */\nexport const setMembershipBodySchema = z.object({\n granted: z.boolean(),\n reason: reasonSchema,\n});\nexport type SetMembershipBody = z.infer<typeof setMembershipBodySchema>;\n\n// ─── Staff: coupons ──────────────────────────────────────────────────────────\n\n/** What a coupon is good for. A percent coupon names what it applies to. */\nexport const COUPON_TARGET_VALUES = ['membership', 'premium', 'business'] as const;\nexport const couponTargetSchema = z.enum(COUPON_TARGET_VALUES);\nexport type CouponTarget = z.infer<typeof couponTargetSchema>;\n\n/**\n * ⚠ Stored: append only.\n *\n * free_membership the membership at Rs 0; `founding` numbers its holders\n * (\"Founding member #N\"). ⚠ A NEW founding coupon is refused\n * (0.14.0, COUPON_FOUNDING_RETIRED): founding places come\n * from the launch waitlist alone. The field stays, because\n * stored coupons carry it.\n * percent_off a share off the listed price of what it applies to\n */\nexport const COUPON_KIND_VALUES = ['free_membership', 'percent_off'] as const;\nexport type CouponKind = (typeof COUPON_KIND_VALUES)[number];\n\nexport const couponBenefitSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('free_membership'), founding: z.boolean() }),\n z.object({\n kind: z.literal('percent_off'),\n percent: z.number().int().min(COUPON_PERCENT_MIN).max(COUPON_PERCENT_MAX),\n appliesTo: z\n .array(couponTargetSchema)\n .min(1)\n .max(COUPON_TARGET_VALUES.length)\n .refine(eachOnce, {\n error: VALIDATION_MESSAGE.couponTargetsDuplicate,\n }),\n }),\n]);\nexport type CouponBenefit = z.infer<typeof couponBenefitSchema>;\n\nexport const couponSchema = z.object({\n id: objectIdSchema,\n code: z.string(),\n label: z.string(),\n benefit: couponBenefitSchema,\n /** Redemptions allowed in all; null is no cap. */\n max: z.number().int().positive().nullable(),\n /** Redemptions in force (a revoked founding place frees one). */\n used: z.number().int().nonnegative(),\n active: z.boolean(),\n validFrom: z.iso.datetime().nullable(),\n validUntil: z.iso.datetime().nullable(),\n createdAt: z.iso.datetime(),\n});\nexport type Coupon = z.infer<typeof couponSchema>;\n\n/** Never paged: coupons are few. Newest first. */\nexport const couponListSchema = z.object({ items: z.array(couponSchema) });\nexport type CouponList = z.infer<typeof couponListSchema>;\n\nexport const couponParamsSchema = z.object({ couponId: objectIdSchema });\nexport type CouponParams = z.infer<typeof couponParamsSchema>;\n\nconst windowValid = (body: { validFrom?: string | null; validUntil?: string | null }) =>\n !body.validFrom || !body.validUntil || Date.parse(body.validFrom) < Date.parse(body.validUntil);\n\nexport const createCouponBodySchema = z\n .object({\n code: couponCodeSchema,\n label: z.string().trim().min(COUPON_LABEL_MIN).max(COUPON_LABEL_MAX),\n benefit: couponBenefitSchema,\n max: z.number().int().positive().max(COUPON_USES_MAX).nullable(),\n validFrom: z.iso.datetime().nullable().optional(),\n validUntil: z.iso.datetime().nullable().optional(),\n })\n .refine(windowValid, { path: ['validUntil'], error: VALIDATION_MESSAGE.couponWindowInvalid });\nexport type CreateCouponBody = z.infer<typeof createCouponBodySchema>;\n\n/**\n * What may change on a live coupon. The code and the benefit never change: a\n * redemption is a record of what a code gave when it was used.\n */\nexport const updateCouponBodySchema = z\n .object({\n label: z.string().trim().min(COUPON_LABEL_MIN).max(COUPON_LABEL_MAX).optional(),\n active: z.boolean().optional(),\n max: z.number().int().positive().max(COUPON_USES_MAX).nullable().optional(),\n validFrom: z.iso.datetime().nullable().optional(),\n validUntil: z.iso.datetime().nullable().optional(),\n })\n .refine(windowValid, { path: ['validUntil'], error: VALIDATION_MESSAGE.couponWindowInvalid });\nexport type UpdateCouponBody = z.infer<typeof updateCouponBodySchema>;\n"]}
|
|
@@ -124,6 +124,11 @@ export declare const GST_STATES: readonly [{
|
|
|
124
124
|
readonly name: "Ladakh";
|
|
125
125
|
}];
|
|
126
126
|
export type GstStateCode = (typeof GST_STATES)[number]['code'];
|
|
127
|
+
/**
|
|
128
|
+
* The GST code of a state by its NAME (the one the state picker writes,
|
|
129
|
+
* `findIndiaState`), or null: a foreign or misspelt one has none.
|
|
130
|
+
*/
|
|
131
|
+
export declare function gstStateCodeOf(name: string | null | undefined): GstStateCode | null;
|
|
127
132
|
export declare const GST_STATE_CODE_VALUES: [GstStateCode, ...GstStateCode[]];
|
|
128
133
|
export declare const gstStateCodeSchema: z.ZodEnum<{
|
|
129
134
|
"01": "01";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gst.d.ts","sourceRoot":"","sources":["../../../src/domains/billing/gst.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,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;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCb,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAEnF;AAED,eAAO,MAAM,qBAAqB,EAAoC,CACpE,YAAY,EACZ,GAAG,YAAY,EAAE,CAClB,CAAC;AACF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAgC,CAAC;AAEhE,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEvD;AAED,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAKnC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAUzD;AAED,yDAAyD;AACzD,eAAO,MAAM,WAAW,wDAKiD,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkB7B,CAAC;AACL,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -55,6 +55,13 @@ export const GST_STATES = [
|
|
|
55
55
|
{ code: '37', name: 'Andhra Pradesh' },
|
|
56
56
|
{ code: '38', name: 'Ladakh' },
|
|
57
57
|
];
|
|
58
|
+
/**
|
|
59
|
+
* The GST code of a state by its NAME (the one the state picker writes,
|
|
60
|
+
* `findIndiaState`), or null: a foreign or misspelt one has none.
|
|
61
|
+
*/
|
|
62
|
+
export function gstStateCodeOf(name) {
|
|
63
|
+
return GST_STATES.find((s) => s.name === name)?.code ?? null;
|
|
64
|
+
}
|
|
58
65
|
export const GST_STATE_CODE_VALUES = GST_STATES.map((s) => s.code);
|
|
59
66
|
export const gstStateCodeSchema = z.enum(GST_STATE_CODE_VALUES);
|
|
60
67
|
/** The state's name for its code, as an invoice prints it. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gst.js","sourceRoot":"","sources":["../../../src/domains/billing/gst.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,mBAAmB,EAAE;IACzC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,kBAAkB,EAAE;IACxC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE;IAClC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE;IACnC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;IAC/B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE;IACjC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE;IACrC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,IAAI,EAAE,IAAI,EA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I,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE;IAC1E,IAAI,EAAE,CAAC,WAAW,CAAC;IACnB,KAAK,EAAE,kBAAkB,CAAC,kBAAkB;CAC7C,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE;IAC7D,IAAI,EAAE,CAAC,WAAW,CAAC;IACnB,KAAK,EAAE,kBAAkB,CAAC,wBAAwB;CACnD,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;IAC3D,IAAI,EAAE,CAAC,SAAS,CAAC;IACjB,KAAK,EAAE,kBAAkB,CAAC,wBAAwB;CACnD,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: GST, the states and the GSTIN (0.12.0)\n *\n * Its own module so both the billing contract and a member's membership\n * (the billing details they last used, to prefill a checkout) can use it\n * without importing each other.\n *\n * @module founder-schema/domains/billing/gst\n */\n\nimport { z } from 'zod';\nimport {\n BILLING_ADDRESS_MAX,\n BILLING_ADDRESS_MIN,\n BILLING_NAME_MAX,\n BILLING_NAME_MIN,\n GSTIN_LENGTH,\n} from '../../core/limits.js';\nimport { VALIDATION_MESSAGE } from '../../core/validation.js';\n\n// ─── GST: states and the GSTIN ───────────────────────────────────────────────\n\n/**\n * India's states and union territories by their GST state code, the first\n * two digits of every GSTIN registered there. The current codes only: 25\n * (Daman and Diu) merged into 26 in 2020, and 28 (undivided Andhra Pradesh)\n * gave way to 37.\n */\nexport const GST_STATES = [\n { code: '01', name: 'Jammu and Kashmir' },\n { code: '02', name: 'Himachal Pradesh' },\n { code: '03', name: 'Punjab' },\n { code: '04', name: 'Chandigarh' },\n { code: '05', name: 'Uttarakhand' },\n { code: '06', name: 'Haryana' },\n { code: '07', name: 'Delhi' },\n { code: '08', name: 'Rajasthan' },\n { code: '09', name: 'Uttar Pradesh' },\n { code: '10', name: 'Bihar' },\n { code: '11', name: 'Sikkim' },\n { code: '12', name: 'Arunachal Pradesh' },\n { code: '13', name: 'Nagaland' },\n { code: '14', name: 'Manipur' },\n { code: '15', name: 'Mizoram' },\n { code: '16', name: 'Tripura' },\n { code: '17', name: 'Meghalaya' },\n { code: '18', name: 'Assam' },\n { code: '19', name: 'West Bengal' },\n { code: '20', name: 'Jharkhand' },\n { code: '21', name: 'Odisha' },\n { code: '22', name: 'Chhattisgarh' },\n { code: '23', name: 'Madhya Pradesh' },\n { code: '24', name: 'Gujarat' },\n { code: '26', name: 'Dadra and Nagar Haveli and Daman and Diu' },\n { code: '27', name: 'Maharashtra' },\n { code: '29', name: 'Karnataka' },\n { code: '30', name: 'Goa' },\n { code: '31', name: 'Lakshadweep' },\n { code: '32', name: 'Kerala' },\n { code: '33', name: 'Tamil Nadu' },\n { code: '34', name: 'Puducherry' },\n { code: '35', name: 'Andaman and Nicobar Islands' },\n { code: '36', name: 'Telangana' },\n { code: '37', name: 'Andhra Pradesh' },\n { code: '38', name: 'Ladakh' },\n] as const;\nexport type GstStateCode = (typeof GST_STATES)[number]['code'];\nexport const GST_STATE_CODE_VALUES = GST_STATES.map((s) => s.code) as [\n GstStateCode,\n ...GstStateCode[],\n];\nexport const gstStateCodeSchema = z.enum(GST_STATE_CODE_VALUES);\n\n/** The state's name for its code, as an invoice prints it. */\nexport function gstStateName(code: GstStateCode): string {\n return GST_STATES.find((s) => s.code === code)?.name ?? code;\n}\n\n/** GST is 18% on these services, inside every price. */\nexport const GST_RATE_PERCENT = 18;\n\nconst GSTIN_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst GSTIN_PATTERN = /^\\d{2}[A-Z]{5}\\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$/;\n\n/**\n * Whether a GSTIN's 15th character is the check character of the first 14\n * (the GSTN's base-36 Luhn variant). Catches a mistyped digit, which the\n * pattern alone does not: a B2B invoice with a wrong GSTIN costs the buyer\n * their input credit.\n */\nexport function gstinChecksumValid(gstin: string): boolean {\n if (!GSTIN_PATTERN.test(gstin)) return false;\n let sum = 0;\n for (let i = 0; i < 14; i++) {\n const value = GSTIN_CHARS.indexOf(gstin.charAt(i));\n const product = value * (i % 2 === 0 ? 1 : 2);\n sum += Math.floor(product / 36) + (product % 36);\n }\n const check = (36 - (sum % 36)) % 36;\n return gstin.charAt(14) === GSTIN_CHARS.charAt(check);\n}\n\n/** A GSTIN, upper-cased, pattern AND check character. */\nexport const gstinSchema = z\n .string()\n .trim()\n .max(GSTIN_LENGTH, VALIDATION_MESSAGE.gstinInvalid)\n .transform((v) => v.toUpperCase())\n .refine(gstinChecksumValid, { error: VALIDATION_MESSAGE.gstinInvalid });\n\n/**\n * Who is buying, for the invoice. The state is the place of supply and\n * decides the tax. With a GSTIN (a business claiming input credit) the\n * invoice is B2B: it must carry the buyer's legal name and address, and the\n * state is the GSTIN's own.\n */\nexport const billingDetailsSchema = z\n .object({\n stateCode: gstStateCodeSchema,\n gstin: gstinSchema.optional(),\n legalName: z.string().trim().min(BILLING_NAME_MIN).max(BILLING_NAME_MAX).optional(),\n address: z.string().trim().min(BILLING_ADDRESS_MIN).max(BILLING_ADDRESS_MAX).optional(),\n })\n .refine((body) => !body.gstin || body.gstin.slice(0, 2) === body.stateCode, {\n path: ['stateCode'],\n error: VALIDATION_MESSAGE.gstinStateMismatch,\n })\n .refine((body) => !body.gstin || body.legalName !== undefined, {\n path: ['legalName'],\n error: VALIDATION_MESSAGE.gstinNeedsNameAndAddress,\n })\n .refine((body) => !body.gstin || body.address !== undefined, {\n path: ['address'],\n error: VALIDATION_MESSAGE.gstinNeedsNameAndAddress,\n });\nexport type BillingDetails = z.infer<typeof billingDetailsSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"gst.js","sourceRoot":"","sources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C,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE;IAC1E,IAAI,EAAE,CAAC,WAAW,CAAC;IACnB,KAAK,EAAE,kBAAkB,CAAC,kBAAkB;CAC7C,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE;IAC7D,IAAI,EAAE,CAAC,WAAW,CAAC;IACnB,KAAK,EAAE,kBAAkB,CAAC,wBAAwB;CACnD,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;IAC3D,IAAI,EAAE,CAAC,SAAS,CAAC;IACjB,KAAK,EAAE,kBAAkB,CAAC,wBAAwB;CACnD,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: GST, the states and the GSTIN (0.12.0)\n *\n * Its own module so both the billing contract and a member's membership\n * (the billing details they last used, to prefill a checkout) can use it\n * without importing each other.\n *\n * @module founder-schema/domains/billing/gst\n */\n\nimport { z } from 'zod';\nimport {\n BILLING_ADDRESS_MAX,\n BILLING_ADDRESS_MIN,\n BILLING_NAME_MAX,\n BILLING_NAME_MIN,\n GSTIN_LENGTH,\n} from '../../core/limits.js';\nimport { VALIDATION_MESSAGE } from '../../core/validation.js';\n\n// ─── GST: states and the GSTIN ───────────────────────────────────────────────\n\n/**\n * India's states and union territories by their GST state code, the first\n * two digits of every GSTIN registered there. The current codes only: 25\n * (Daman and Diu) merged into 26 in 2020, and 28 (undivided Andhra Pradesh)\n * gave way to 37.\n */\nexport const GST_STATES = [\n { code: '01', name: 'Jammu and Kashmir' },\n { code: '02', name: 'Himachal Pradesh' },\n { code: '03', name: 'Punjab' },\n { code: '04', name: 'Chandigarh' },\n { code: '05', name: 'Uttarakhand' },\n { code: '06', name: 'Haryana' },\n { code: '07', name: 'Delhi' },\n { code: '08', name: 'Rajasthan' },\n { code: '09', name: 'Uttar Pradesh' },\n { code: '10', name: 'Bihar' },\n { code: '11', name: 'Sikkim' },\n { code: '12', name: 'Arunachal Pradesh' },\n { code: '13', name: 'Nagaland' },\n { code: '14', name: 'Manipur' },\n { code: '15', name: 'Mizoram' },\n { code: '16', name: 'Tripura' },\n { code: '17', name: 'Meghalaya' },\n { code: '18', name: 'Assam' },\n { code: '19', name: 'West Bengal' },\n { code: '20', name: 'Jharkhand' },\n { code: '21', name: 'Odisha' },\n { code: '22', name: 'Chhattisgarh' },\n { code: '23', name: 'Madhya Pradesh' },\n { code: '24', name: 'Gujarat' },\n { code: '26', name: 'Dadra and Nagar Haveli and Daman and Diu' },\n { code: '27', name: 'Maharashtra' },\n { code: '29', name: 'Karnataka' },\n { code: '30', name: 'Goa' },\n { code: '31', name: 'Lakshadweep' },\n { code: '32', name: 'Kerala' },\n { code: '33', name: 'Tamil Nadu' },\n { code: '34', name: 'Puducherry' },\n { code: '35', name: 'Andaman and Nicobar Islands' },\n { code: '36', name: 'Telangana' },\n { code: '37', name: 'Andhra Pradesh' },\n { code: '38', name: 'Ladakh' },\n] as const;\nexport type GstStateCode = (typeof GST_STATES)[number]['code'];\n/**\n * The GST code of a state by its NAME (the one the state picker writes,\n * `findIndiaState`), or null: a foreign or misspelt one has none.\n */\nexport function gstStateCodeOf(name: string | null | undefined): GstStateCode | null {\n return GST_STATES.find((s) => s.name === name)?.code ?? null;\n}\n\nexport const GST_STATE_CODE_VALUES = GST_STATES.map((s) => s.code) as [\n GstStateCode,\n ...GstStateCode[],\n];\nexport const gstStateCodeSchema = z.enum(GST_STATE_CODE_VALUES);\n\n/** The state's name for its code, as an invoice prints it. */\nexport function gstStateName(code: GstStateCode): string {\n return GST_STATES.find((s) => s.code === code)?.name ?? code;\n}\n\n/** GST is 18% on these services, inside every price. */\nexport const GST_RATE_PERCENT = 18;\n\nconst GSTIN_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst GSTIN_PATTERN = /^\\d{2}[A-Z]{5}\\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$/;\n\n/**\n * Whether a GSTIN's 15th character is the check character of the first 14\n * (the GSTN's base-36 Luhn variant). Catches a mistyped digit, which the\n * pattern alone does not: a B2B invoice with a wrong GSTIN costs the buyer\n * their input credit.\n */\nexport function gstinChecksumValid(gstin: string): boolean {\n if (!GSTIN_PATTERN.test(gstin)) return false;\n let sum = 0;\n for (let i = 0; i < 14; i++) {\n const value = GSTIN_CHARS.indexOf(gstin.charAt(i));\n const product = value * (i % 2 === 0 ? 1 : 2);\n sum += Math.floor(product / 36) + (product % 36);\n }\n const check = (36 - (sum % 36)) % 36;\n return gstin.charAt(14) === GSTIN_CHARS.charAt(check);\n}\n\n/** A GSTIN, upper-cased, pattern AND check character. */\nexport const gstinSchema = z\n .string()\n .trim()\n .max(GSTIN_LENGTH, VALIDATION_MESSAGE.gstinInvalid)\n .transform((v) => v.toUpperCase())\n .refine(gstinChecksumValid, { error: VALIDATION_MESSAGE.gstinInvalid });\n\n/**\n * Who is buying, for the invoice. The state is the place of supply and\n * decides the tax. With a GSTIN (a business claiming input credit) the\n * invoice is B2B: it must carry the buyer's legal name and address, and the\n * state is the GSTIN's own.\n */\nexport const billingDetailsSchema = z\n .object({\n stateCode: gstStateCodeSchema,\n gstin: gstinSchema.optional(),\n legalName: z.string().trim().min(BILLING_NAME_MIN).max(BILLING_NAME_MAX).optional(),\n address: z.string().trim().min(BILLING_ADDRESS_MIN).max(BILLING_ADDRESS_MAX).optional(),\n })\n .refine((body) => !body.gstin || body.gstin.slice(0, 2) === body.stateCode, {\n path: ['stateCode'],\n error: VALIDATION_MESSAGE.gstinStateMismatch,\n })\n .refine((body) => !body.gstin || body.legalName !== undefined, {\n path: ['legalName'],\n error: VALIDATION_MESSAGE.gstinNeedsNameAndAddress,\n })\n .refine((body) => !body.gstin || body.address !== undefined, {\n path: ['address'],\n error: VALIDATION_MESSAGE.gstinNeedsNameAndAddress,\n });\nexport type BillingDetails = z.infer<typeof billingDetailsSchema>;\n"]}
|