Add accounts, members, and processor-agnostic payment linking
- account table (billing entity, soft-delete, company-scoped) - member table (people on an account, is_minor from DOB) - account_processor_link table (maps accounts to any payment processor — stripe, global_payments — instead of stripe_customer_id directly on account) - Full CRUD routes + search (name, email, phone, account_number) - Member routes nested under accounts with isMinor auto-calculation - Zod validation schemas in @forte/shared - 19 tests passing
This commit is contained in:
42
packages/shared/src/schemas/account.schema.ts
Normal file
42
packages/shared/src/schemas/account.schema.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const BillingMode = z.enum(['consolidated', 'split'])
|
||||
export type BillingMode = z.infer<typeof BillingMode>
|
||||
|
||||
export const AccountCreateSchema = z.object({
|
||||
name: z.string().min(1).max(255),
|
||||
email: z.string().email().optional(),
|
||||
phone: z.string().max(50).optional(),
|
||||
address: z
|
||||
.object({
|
||||
street: z.string().optional(),
|
||||
city: z.string().optional(),
|
||||
state: z.string().optional(),
|
||||
zip: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
billingMode: BillingMode.default('consolidated'),
|
||||
notes: z.string().optional(),
|
||||
})
|
||||
export type AccountCreateInput = z.infer<typeof AccountCreateSchema>
|
||||
|
||||
export const AccountUpdateSchema = AccountCreateSchema.partial()
|
||||
export type AccountUpdateInput = z.infer<typeof AccountUpdateSchema>
|
||||
|
||||
export const MemberCreateSchema = z.object({
|
||||
accountId: z.string().uuid(),
|
||||
firstName: z.string().min(1).max(100),
|
||||
lastName: z.string().min(1).max(100),
|
||||
dateOfBirth: z.string().date().optional(),
|
||||
email: z.string().email().optional(),
|
||||
phone: z.string().max(50).optional(),
|
||||
notes: z.string().optional(),
|
||||
})
|
||||
export type MemberCreateInput = z.infer<typeof MemberCreateSchema>
|
||||
|
||||
export const MemberUpdateSchema = MemberCreateSchema.omit({ accountId: true }).partial()
|
||||
export type MemberUpdateInput = z.infer<typeof MemberUpdateSchema>
|
||||
|
||||
export const AccountSearchSchema = z.object({
|
||||
q: z.string().min(1).max(255),
|
||||
})
|
||||
@@ -1,2 +1,17 @@
|
||||
export { UserRole, RegisterSchema, LoginSchema } from './auth.schema.js'
|
||||
export type { RegisterInput, LoginInput } from './auth.schema.js'
|
||||
|
||||
export {
|
||||
BillingMode,
|
||||
AccountCreateSchema,
|
||||
AccountUpdateSchema,
|
||||
MemberCreateSchema,
|
||||
MemberUpdateSchema,
|
||||
AccountSearchSchema,
|
||||
} from './account.schema.js'
|
||||
export type {
|
||||
AccountCreateInput,
|
||||
AccountUpdateInput,
|
||||
MemberCreateInput,
|
||||
MemberUpdateInput,
|
||||
} from './account.schema.js'
|
||||
|
||||
Reference in New Issue
Block a user