💳 school fees / payments module — collection UI, plans, ledger
Browse files at this commitf30ea30538323de79ebf66740d0c29f05f9d271cParent: 789e256- feat
- 💳 school fees / payments module — collection UI, plans, ledger
25 changed files +1417 -0
- src/api/__tests__/payments/payments.test.ts +121 -0
- src/api/client/types.ts +7 -0
- src/api/payments/deletePaymentPlanById.ts +5 -0
- src/api/payments/getMyPaymentBalance.ts +6 -0
- src/api/payments/getMyPaymentStatement.ts +10 -0
- src/api/payments/getPaymentBalanceByUserId.ts +9 -0
- src/api/payments/getPaymentLedgerByUserId.ts +14 -0
- src/api/payments/getPaymentPlanById.ts +6 -0
- src/api/payments/getPaymentPlans.ts +10 -0
- src/api/payments/getPaymentStatementByUserId.ts +13 -0
- src/api/payments/getPlanAssignments.ts +14 -0
- src/api/payments/index.ts +16 -0
- src/api/payments/patchPaymentPlanById.ts +6 -0
- src/api/payments/postPaymentCredit.ts +7 -0
- src/api/payments/postPaymentPlan.ts +6 -0
- src/api/payments/postPaymentRefund.ts +7 -0
- src/api/payments/postPaymentReversal.ts +7 -0
- src/api/payments/postPlanAssignment.ts +12 -0
- src/api/payments/types.ts +103 -0
- src/components/layout/nav-items.ts +2 -0
- src/i18n/messages.ts +204 -0
- src/lib/payments.ts +44 -0
- src/pages/payment-statement-page.tsx +140 -0
- src/pages/payments-page.tsx +632 -0
- src/routes/router.tsx +16 -0
src/api/__tests__/payments/payments.test.tsadded+121 -0
| @@ -0,0 +1,121 @@ | |||
| 1 | +import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| 2 | +import { | ||
| 3 | + deletePaymentPlanById, | ||
| 4 | + getMyPaymentBalance, | ||
| 5 | + getMyPaymentStatement, | ||
| 6 | + getPaymentBalanceByUserId, | ||
| 7 | + getPaymentLedgerByUserId, | ||
| 8 | + getPaymentPlanById, | ||
| 9 | + getPaymentPlans, | ||
| 10 | + getPaymentStatementByUserId, | ||
| 11 | + getPlanAssignments, | ||
| 12 | + patchPaymentPlanById, | ||
| 13 | + postPaymentCredit, | ||
| 14 | + postPaymentPlan, | ||
| 15 | + postPaymentRefund, | ||
| 16 | + postPaymentReversal, | ||
| 17 | + postPlanAssignment, | ||
| 18 | +} from "../../payments"; | ||
| 19 | +import { lastFetchCall, mockFetch204, mockFetchSuccess } from "../helpers/mock-fetch"; | ||
| 20 | + | ||
| 21 | +describe("payments API", () => { | ||
| 22 | + afterEach(() => vi.restoreAllMocks()); | ||
| 23 | + const json = () => mockFetchSuccess({}); | ||
| 24 | + const page = () => mockFetchSuccess({ items: [], total: 0 }); | ||
| 25 | + | ||
| 26 | + it("creates a fee plan", async () => { | ||
| 27 | + json(); | ||
| 28 | + const body = { name: "2026-2027", installments: [{ amount_minor: 150000, due_at: 1_760_000_000_000 }] }; | ||
| 29 | + await postPaymentPlan(body); | ||
| 30 | + expect(lastFetchCall()).toMatchObject(["/api/payments/plans", { method: "POST", body: JSON.stringify(body) }]); | ||
| 31 | + }); | ||
| 32 | + | ||
| 33 | + it("lists plans with pagination", async () => { | ||
| 34 | + page(); | ||
| 35 | + await getPaymentPlans({ limit: 12, offset: 24 }); | ||
| 36 | + expect(lastFetchCall()[0]).toBe("/api/payments/plans?limit=12&offset=24"); | ||
| 37 | + }); | ||
| 38 | + | ||
| 39 | + it("gets a plan by id", async () => { | ||
| 40 | + json(); | ||
| 41 | + await getPaymentPlanById("p/1"); | ||
| 42 | + expect(lastFetchCall()[0]).toBe("/api/payments/plans/p%2F1"); | ||
| 43 | + }); | ||
| 44 | + | ||
| 45 | + it("updates a plan", async () => { | ||
| 46 | + json(); | ||
| 47 | + const body = { name: "renamed" }; | ||
| 48 | + await patchPaymentPlanById("p1", body); | ||
| 49 | + expect(lastFetchCall()).toMatchObject(["/api/payments/plans/p1", { method: "PATCH", body: JSON.stringify(body) }]); | ||
| 50 | + }); | ||
| 51 | + | ||
| 52 | + it("deletes a plan", async () => { | ||
| 53 | + mockFetch204(); | ||
| 54 | + await deletePaymentPlanById("p1"); | ||
| 55 | + expect(lastFetchCall()).toMatchObject(["/api/payments/plans/p1", { method: "DELETE" }]); | ||
| 56 | + }); | ||
| 57 | + | ||
| 58 | + it("assigns a plan to students", async () => { | ||
| 59 | + mockFetchSuccess([]); | ||
| 60 | + const body = { student_ids: ["s1", "s2"] }; | ||
| 61 | + await postPlanAssignment("p1", body); | ||
| 62 | + expect(lastFetchCall()).toMatchObject(["/api/payments/plans/p1/assignments", { method: "POST", body: JSON.stringify(body) }]); | ||
| 63 | + }); | ||
| 64 | + | ||
| 65 | + it("lists plan assignments with pagination", async () => { | ||
| 66 | + page(); | ||
| 67 | + await getPlanAssignments("p1", { limit: 5 }); | ||
| 68 | + expect(lastFetchCall()[0]).toBe("/api/payments/plans/p1/assignments?limit=5"); | ||
| 69 | + }); | ||
| 70 | + | ||
| 71 | + it("records a payment with an idempotence key", async () => { | ||
| 72 | + json(); | ||
| 73 | + const body = { charge_id: "c1", amount_minor: 50000, method: "havale", request_key: "receipt-2026-114" }; | ||
| 74 | + await postPaymentCredit(body); | ||
| 75 | + expect(lastFetchCall()).toMatchObject(["/api/payments/credits", { method: "POST", body: JSON.stringify(body) }]); | ||
| 76 | + }); | ||
| 77 | + | ||
| 78 | + it("records a refund with an idempotence key", async () => { | ||
| 79 | + json(); | ||
| 80 | + const body = { credit_id: "cr1", amount_minor: 50000, request_key: "refund-2026-114" }; | ||
| 81 | + await postPaymentRefund(body); | ||
| 82 | + expect(lastFetchCall()).toMatchObject(["/api/payments/refunds", { method: "POST", body: JSON.stringify(body) }]); | ||
| 83 | + }); | ||
| 84 | + | ||
| 85 | + it("records a reversal", async () => { | ||
| 86 | + json(); | ||
| 87 | + const body = { line_id: "l1", note: "billed in error" }; | ||
| 88 | + await postPaymentReversal(body); | ||
| 89 | + expect(lastFetchCall()).toMatchObject(["/api/payments/reversals", { method: "POST", body: JSON.stringify(body) }]); | ||
| 90 | + }); | ||
| 91 | + | ||
| 92 | + it("reads a student ledger with pagination", async () => { | ||
| 93 | + page(); | ||
| 94 | + await getPaymentLedgerByUserId("u/1", { limit: 20, offset: 20 }); | ||
| 95 | + expect(lastFetchCall()[0]).toBe("/api/payments/ledger/u%2F1?limit=20&offset=20"); | ||
| 96 | + }); | ||
| 97 | + | ||
| 98 | + it("reads my statement", async () => { | ||
| 99 | + mockFetchSuccess({ student: {}, entries: { items: [], total: 0 }, balance_minor: 0 }); | ||
| 100 | + await getMyPaymentStatement({ limit: 10 }); | ||
| 101 | + expect(lastFetchCall()[0]).toBe("/api/payments/statement/me?limit=10"); | ||
| 102 | + }); | ||
| 103 | + | ||
| 104 | + it("reads a student statement", async () => { | ||
| 105 | + mockFetchSuccess({ student: {}, entries: { items: [], total: 0 }, balance_minor: 0 }); | ||
| 106 | + await getPaymentStatementByUserId("u1"); | ||
| 107 | + expect(lastFetchCall()[0]).toBe("/api/payments/statement/u1"); | ||
| 108 | + }); | ||
| 109 | + | ||
| 110 | + it("reads my balance", async () => { | ||
| 111 | + mockFetchSuccess({ student: {}, balance_minor: 0 }); | ||
| 112 | + await getMyPaymentBalance(); | ||
| 113 | + expect(lastFetchCall()[0]).toBe("/api/payments/balance/me"); | ||
| 114 | + }); | ||
| 115 | + | ||
| 116 | + it("reads a student balance", async () => { | ||
| 117 | + mockFetchSuccess({ student: {}, balance_minor: 0 }); | ||
| 118 | + await getPaymentBalanceByUserId("u1"); | ||
| 119 | + expect(lastFetchCall()[0]).toBe("/api/payments/balance/u1"); | ||
| 120 | + }); | ||
| 121 | +}); | ||
src/api/client/types.tsmodified+7 -0
| @@ -541,6 +541,13 @@ export type Limits = { | |||
| 541 | attendance_statuses: string[]; | 541 | attendance_statuses: string[]; |
| 542 | ledger_kinds: string[]; | 542 | ledger_kinds: string[]; |
| 543 | }; | 543 | }; |
| 544 | + payment: { | ||
| 545 | + max_plan_name_len: number; | ||
| 546 | + max_plan_installments: number; | ||
| 547 | + max_assign_students: number; | ||
| 548 | + max_request_key_len: number; | ||
| 549 | + ledger_kinds: string[]; | ||
| 550 | + }; | ||
| 544 | chatbot: { | 551 | chatbot: { |
| 545 | max_message_len: number; | 552 | max_message_len: number; |
| 546 | max_thread_title_len: number; | 553 | max_thread_title_len: number; |
src/api/payments/deletePaymentPlanById.tsadded+5 -0
| @@ -0,0 +1,5 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | + | ||
| 3 | +export function deletePaymentPlanById(id: string): Promise<void> { | ||
| 4 | + return client<void>(`/payments/plans/${encodeURIComponent(id)}`, { method: "DELETE" }); | ||
| 5 | +} | ||
src/api/payments/getMyPaymentBalance.tsadded+6 -0
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { PaymentBalance } from "./types"; | ||
| 3 | + | ||
| 4 | +export function getMyPaymentBalance(signal?: AbortSignal): Promise<PaymentBalance> { | ||
| 5 | + return client<PaymentBalance>("/payments/balance/me", { signal }); | ||
| 6 | +} | ||
src/api/payments/getMyPaymentStatement.tsadded+10 -0
| @@ -0,0 +1,10 @@ | |||
| 1 | +import { client, pageQuery, type PageParams } from "../client"; | ||
| 2 | +import type { PaymentStatement } from "./types"; | ||
| 3 | + | ||
| 4 | +// Statement is not itself a Page envelope: { student, entries: Page, balance_minor }. | ||
| 5 | +export function getMyPaymentStatement( | ||
| 6 | + params?: PageParams, | ||
| 7 | + signal?: AbortSignal, | ||
| 8 | +): Promise<PaymentStatement> { | ||
| 9 | + return client<PaymentStatement>(`/payments/statement/me${pageQuery(params)}`, { signal }); | ||
| 10 | +} | ||
src/api/payments/getPaymentBalanceByUserId.tsadded+9 -0
| @@ -0,0 +1,9 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { PaymentBalance } from "./types"; | ||
| 3 | + | ||
| 4 | +export function getPaymentBalanceByUserId( | ||
| 5 | + userId: string, | ||
| 6 | + signal?: AbortSignal, | ||
| 7 | +): Promise<PaymentBalance> { | ||
| 8 | + return client<PaymentBalance>(`/payments/balance/${encodeURIComponent(userId)}`, { signal }); | ||
| 9 | +} | ||
src/api/payments/getPaymentLedgerByUserId.tsadded+14 -0
| @@ -0,0 +1,14 @@ | |||
| 1 | +import { client, normalizePage, pageQuery, type Page, type PageParams } from "../client"; | ||
| 2 | +import type { PaymentLine } from "./types"; | ||
| 3 | + | ||
| 4 | +export async function getPaymentLedgerByUserId( | ||
| 5 | + userId: string, | ||
| 6 | + params?: PageParams, | ||
| 7 | + signal?: AbortSignal, | ||
| 8 | +): Promise<Page<PaymentLine>> { | ||
| 9 | + const data = await client<unknown>( | ||
| 10 | + `/payments/ledger/${encodeURIComponent(userId)}${pageQuery(params)}`, | ||
| 11 | + { signal }, | ||
| 12 | + ); | ||
| 13 | + return normalizePage<PaymentLine>(data); | ||
| 14 | +} | ||
src/api/payments/getPaymentPlanById.tsadded+6 -0
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { FeePlan } from "./types"; | ||
| 3 | + | ||
| 4 | +export function getPaymentPlanById(id: string, signal?: AbortSignal): Promise<FeePlan> { | ||
| 5 | + return client<FeePlan>(`/payments/plans/${encodeURIComponent(id)}`, { signal }); | ||
| 6 | +} | ||
src/api/payments/getPaymentPlans.tsadded+10 -0
| @@ -0,0 +1,10 @@ | |||
| 1 | +import { client, normalizePage, pageQuery, type Page, type PageParams } from "../client"; | ||
| 2 | +import type { FeePlan } from "./types"; | ||
| 3 | + | ||
| 4 | +export async function getPaymentPlans( | ||
| 5 | + params?: PageParams, | ||
| 6 | + signal?: AbortSignal, | ||
| 7 | +): Promise<Page<FeePlan>> { | ||
| 8 | + const data = await client<unknown>(`/payments/plans${pageQuery(params)}`, { signal }); | ||
| 9 | + return normalizePage<FeePlan>(data); | ||
| 10 | +} | ||
src/api/payments/getPaymentStatementByUserId.tsadded+13 -0
| @@ -0,0 +1,13 @@ | |||
| 1 | +import { client, pageQuery, type PageParams } from "../client"; | ||
| 2 | +import type { PaymentStatement } from "./types"; | ||
| 3 | + | ||
| 4 | +export function getPaymentStatementByUserId( | ||
| 5 | + userId: string, | ||
| 6 | + params?: PageParams, | ||
| 7 | + signal?: AbortSignal, | ||
| 8 | +): Promise<PaymentStatement> { | ||
| 9 | + return client<PaymentStatement>( | ||
| 10 | + `/payments/statement/${encodeURIComponent(userId)}${pageQuery(params)}`, | ||
| 11 | + { signal }, | ||
| 12 | + ); | ||
| 13 | +} | ||
src/api/payments/getPlanAssignments.tsadded+14 -0
| @@ -0,0 +1,14 @@ | |||
| 1 | +import { client, normalizePage, pageQuery, type Page, type PageParams } from "../client"; | ||
| 2 | +import type { FeePlanAssignment } from "./types"; | ||
| 3 | + | ||
| 4 | +export async function getPlanAssignments( | ||
| 5 | + planId: string, | ||
| 6 | + params?: PageParams, | ||
| 7 | + signal?: AbortSignal, | ||
| 8 | +): Promise<Page<FeePlanAssignment>> { | ||
| 9 | + const data = await client<unknown>( | ||
| 10 | + `/payments/plans/${encodeURIComponent(planId)}/assignments${pageQuery(params)}`, | ||
| 11 | + { signal }, | ||
| 12 | + ); | ||
| 13 | + return normalizePage<FeePlanAssignment>(data); | ||
| 14 | +} | ||
src/api/payments/index.tsadded+16 -0
| @@ -0,0 +1,16 @@ | |||
| 1 | +export * from "./types"; | ||
| 2 | +export * from "./postPaymentPlan"; | ||
| 3 | +export * from "./getPaymentPlans"; | ||
| 4 | +export * from "./getPaymentPlanById"; | ||
| 5 | +export * from "./patchPaymentPlanById"; | ||
| 6 | +export * from "./deletePaymentPlanById"; | ||
| 7 | +export * from "./postPlanAssignment"; | ||
| 8 | +export * from "./getPlanAssignments"; | ||
| 9 | +export * from "./postPaymentCredit"; | ||
| 10 | +export * from "./postPaymentRefund"; | ||
| 11 | +export * from "./postPaymentReversal"; | ||
| 12 | +export * from "./getPaymentLedgerByUserId"; | ||
| 13 | +export * from "./getMyPaymentStatement"; | ||
| 14 | +export * from "./getPaymentStatementByUserId"; | ||
| 15 | +export * from "./getMyPaymentBalance"; | ||
| 16 | +export * from "./getPaymentBalanceByUserId"; | ||
src/api/payments/patchPaymentPlanById.tsadded+6 -0
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { FeePlan, UpdateFeePlanBody } from "./types"; | ||
| 3 | + | ||
| 4 | +export function patchPaymentPlanById(id: string, body: UpdateFeePlanBody): Promise<FeePlan> { | ||
| 5 | + return client<FeePlan>(`/payments/plans/${encodeURIComponent(id)}`, { method: "PATCH", body }); | ||
| 6 | +} | ||
src/api/payments/postPaymentCredit.tsadded+7 -0
| @@ -0,0 +1,7 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { PaymentLine, RecordPaymentBody } from "./types"; | ||
| 3 | + | ||
| 4 | +// Record a payment against a charge line. | ||
| 5 | +export function postPaymentCredit(body: RecordPaymentBody): Promise<PaymentLine> { | ||
| 6 | + return client<PaymentLine>("/payments/credits", { method: "POST", body }); | ||
| 7 | +} | ||
src/api/payments/postPaymentPlan.tsadded+6 -0
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { CreateFeePlanBody, FeePlan } from "./types"; | ||
| 3 | + | ||
| 4 | +export function postPaymentPlan(body: CreateFeePlanBody): Promise<FeePlan> { | ||
| 5 | + return client<FeePlan>("/payments/plans", { method: "POST", body }); | ||
| 6 | +} | ||
src/api/payments/postPaymentRefund.tsadded+7 -0
| @@ -0,0 +1,7 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { PaymentLine, RecordRefundBody } from "./types"; | ||
| 3 | + | ||
| 4 | +// Hand back a recorded payment (credit line). | ||
| 5 | +export function postPaymentRefund(body: RecordRefundBody): Promise<PaymentLine> { | ||
| 6 | + return client<PaymentLine>("/payments/refunds", { method: "POST", body }); | ||
| 7 | +} | ||
src/api/payments/postPaymentReversal.tsadded+7 -0
| @@ -0,0 +1,7 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { PaymentLine, RecordReversalBody } from "./types"; | ||
| 3 | + | ||
| 4 | +// Undo a charge or refund line for its exact amount. | ||
| 5 | +export function postPaymentReversal(body: RecordReversalBody): Promise<PaymentLine> { | ||
| 6 | + return client<PaymentLine>("/payments/reversals", { method: "POST", body }); | ||
| 7 | +} | ||
src/api/payments/postPlanAssignment.tsadded+12 -0
| @@ -0,0 +1,12 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { AssignmentOutcome } from "./types"; | ||
| 3 | + | ||
| 4 | +export function postPlanAssignment( | ||
| 5 | + planId: string, | ||
| 6 | + body: { student_ids: string[] }, | ||
| 7 | +): Promise<AssignmentOutcome[]> { | ||
| 8 | + return client<AssignmentOutcome[]>( | ||
| 9 | + `/payments/plans/${encodeURIComponent(planId)}/assignments`, | ||
| 10 | + { method: "POST", body }, | ||
| 11 | + ); | ||
| 12 | +} | ||
src/api/payments/types.tsadded+103 -0
| @@ -0,0 +1,103 @@ | |||
| 1 | +import type { Page, PersonRef } from "../client"; | ||
| 2 | + | ||
| 3 | +export type PaymentLedgerKind = "charge" | "credit" | "reversal" | "refund"; | ||
| 4 | + | ||
| 5 | +export type FeePlanInstallment = { | ||
| 6 | + amount_minor: number; | ||
| 7 | + due_at: number; | ||
| 8 | +}; | ||
| 9 | + | ||
| 10 | +export type FeePlan = { | ||
| 11 | + id: string; | ||
| 12 | + name: string; | ||
| 13 | + installments: FeePlanInstallment[]; | ||
| 14 | + created_by: PersonRef; | ||
| 15 | + created_at: number; | ||
| 16 | +}; | ||
| 17 | + | ||
| 18 | +export type CreateFeePlanBody = { | ||
| 19 | + name: string; | ||
| 20 | + installments: FeePlanInstallment[]; | ||
| 21 | +}; | ||
| 22 | + | ||
| 23 | +// Backend replaces the whole schedule; refused (409) once anyone is assigned. | ||
| 24 | +export type UpdateFeePlanBody = { | ||
| 25 | + name?: string; | ||
| 26 | + installments?: FeePlanInstallment[]; | ||
| 27 | +}; | ||
| 28 | + | ||
| 29 | +export type FeePlanAssignment = { | ||
| 30 | + id: string; | ||
| 31 | + plan: string; | ||
| 32 | + student: PersonRef; | ||
| 33 | + assigned_by: PersonRef; | ||
| 34 | + created_at: number; | ||
| 35 | +}; | ||
| 36 | + | ||
| 37 | +export type AssignmentOutcome = { | ||
| 38 | + student_id: string; | ||
| 39 | + status: "assigned" | "already_assigned" | "rejected"; | ||
| 40 | + reason: string | null; | ||
| 41 | +}; | ||
| 42 | + | ||
| 43 | +export type PaymentLine = { | ||
| 44 | + id: string; | ||
| 45 | + student: PersonRef; | ||
| 46 | + kind: PaymentLedgerKind; | ||
| 47 | + amount_minor: number; | ||
| 48 | + source: string | null; | ||
| 49 | + due_at: number | null; | ||
| 50 | + method: string | null; | ||
| 51 | + note: string | null; | ||
| 52 | + recorded_by: PersonRef; | ||
| 53 | + created_at: number; | ||
| 54 | +}; | ||
| 55 | + | ||
| 56 | +// request_key: optional idempotence key, charset [A-Za-z0-9-]. Same key with a | ||
| 57 | +// different amount_minor/charge_id → 409. | ||
| 58 | +export type RecordPaymentBody = { | ||
| 59 | + charge_id: string; | ||
| 60 | + amount_minor: number; | ||
| 61 | + method?: string; | ||
| 62 | + note?: string; | ||
| 63 | + request_key?: string; | ||
| 64 | +}; | ||
| 65 | + | ||
| 66 | +export type RecordRefundBody = { | ||
| 67 | + credit_id: string; | ||
| 68 | + amount_minor: number; | ||
| 69 | + method?: string; | ||
| 70 | + note?: string; | ||
| 71 | + request_key?: string; | ||
| 72 | +}; | ||
| 73 | + | ||
| 74 | +export type RecordReversalBody = { | ||
| 75 | + line_id: string; | ||
| 76 | + note?: string; | ||
| 77 | +}; | ||
| 78 | + | ||
| 79 | +export type StatementEntry = { | ||
| 80 | + charge_id: string; | ||
| 81 | + plan: string | null; | ||
| 82 | + plan_name: string | null; | ||
| 83 | + amount_minor: number; | ||
| 84 | + due_at: number | null; | ||
| 85 | + credited_minor: number; | ||
| 86 | + refunded_minor: number; | ||
| 87 | + outstanding_minor: number; | ||
| 88 | + reversed: boolean; | ||
| 89 | + overdue: boolean; | ||
| 90 | +}; | ||
| 91 | + | ||
| 92 | +// entries is a Page envelope; balance_minor is folded from the full ledger | ||
| 93 | +// regardless of paging. Negative balance means the family owes the school. | ||
| 94 | +export type PaymentStatement = { | ||
| 95 | + student: PersonRef; | ||
| 96 | + entries: Page<StatementEntry>; | ||
| 97 | + balance_minor: number; | ||
| 98 | +}; | ||
| 99 | + | ||
| 100 | +export type PaymentBalance = { | ||
| 101 | + student: PersonRef; | ||
| 102 | + balance_minor: number; | ||
| 103 | +}; | ||
src/components/layout/nav-items.tsmodified+2 -0
| @@ -151,6 +151,7 @@ const NAV_GROUPS: NavGroup[] = [ | |||
| 151 | Icon: IconGlobe, | 151 | Icon: IconGlobe, |
| 152 | items: [ | 152 | items: [ |
| 153 | MEALS_ITEM, | 153 | MEALS_ITEM, |
| 154 | + { id: "payment-statement", to: "/payments", labelKey: "nav.paymentStatement", Icon: IconChart, maxRole: "student" }, | ||
| 154 | { id: "messages", to: "/messages", labelKey: "nav.messages", Icon: IconMessage }, | 155 | { id: "messages", to: "/messages", labelKey: "nav.messages", Icon: IconMessage }, |
| 155 | { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle }, | 156 | { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle }, |
| 156 | { id: "work", to: "/work", labelKey: "nav.work", Icon: IconBriefcase, minRole: "teacher", maxRole: "manager" }, | 157 | { id: "work", to: "/work", labelKey: "nav.work", Icon: IconBriefcase, minRole: "teacher", maxRole: "manager" }, |
| @@ -165,6 +166,7 @@ const NAV_GROUPS: NavGroup[] = [ | |||
| 165 | { id: "staff-work", to: "/management/staff-work", labelKey: "nav.staffWork", Icon: IconBriefcase, minRole: "manager" }, | 166 | { id: "staff-work", to: "/management/staff-work", labelKey: "nav.staffWork", Icon: IconBriefcase, minRole: "manager" }, |
| 166 | { id: "settings", to: "/management/settings", labelKey: "nav.settings", Icon: IconSettings, minRole: "manager" }, | 167 | { id: "settings", to: "/management/settings", labelKey: "nav.settings", Icon: IconSettings, minRole: "manager" }, |
| 167 | { id: "terms", to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendarDays, minRole: "manager" }, | 168 | { id: "terms", to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendarDays, minRole: "manager" }, |
| 169 | + { id: "payments", to: "/management/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, minRole: "manager" }, | ||
| 168 | { id: "users", to: "/admin/users", labelKey: "nav.users", Icon: IconUserCog, minRole: "admin" }, | 170 | { id: "users", to: "/admin/users", labelKey: "nav.users", Icon: IconUserCog, minRole: "admin" }, |
| 169 | ], | 171 | ], |
| 170 | }, | 172 | }, |
src/i18n/messages.tsmodified+204 -0
| @@ -937,6 +937,74 @@ export type MessageKey = | |||
| 937 | | "meals.editDish" | 937 | | "meals.editDish" |
| 938 | | "meals.dishName" | 938 | | "meals.dishName" |
| 939 | | "meals.priceTry" | 939 | | "meals.priceTry" |
| 940 | + | "nav.payments" | ||
| 941 | + | "nav.paymentStatement" | ||
| 942 | + | "payments.title" | ||
| 943 | + | "payments.subtitle" | ||
| 944 | + | "payments.empty" | ||
| 945 | + | "payments.createPlan" | ||
| 946 | + | "payments.editPlan" | ||
| 947 | + | "payments.deletePlan" | ||
| 948 | + | "payments.planName" | ||
| 949 | + | "payments.installments" | ||
| 950 | + | "payments.addInstallment" | ||
| 951 | + | "payments.amountTry" | ||
| 952 | + | "payments.dueDate" | ||
| 953 | + | "payments.total" | ||
| 954 | + | "payments.assign" | ||
| 955 | + | "payments.assignHelp" | ||
| 956 | + | "payments.selectStudent" | ||
| 957 | + | "payments.assignments" | ||
| 958 | + | "payments.noAssignments" | ||
| 959 | + | "payments.outcomeAssigned" | ||
| 960 | + | "payments.outcomeAlready" | ||
| 961 | + | "payments.outcomeRejected" | ||
| 962 | + | "payments.studentLedger" | ||
| 963 | + | "payments.balance" | ||
| 964 | + | "payments.ledger" | ||
| 965 | + | "payments.noLedger" | ||
| 966 | + | "payments.recordPayment" | ||
| 967 | + | "payments.recordRefund" | ||
| 968 | + | "payments.reverse" | ||
| 969 | + | "payments.method" | ||
| 970 | + | "payments.note" | ||
| 971 | + | "payments.reason" | ||
| 972 | + | "payments.kindCharge" | ||
| 973 | + | "payments.kindCredit" | ||
| 974 | + | "payments.kindRefund" | ||
| 975 | + | "payments.kindReversal" | ||
| 976 | + | "payments.statementTitle" | ||
| 977 | + | "payments.statementSubtitle" | ||
| 978 | + | "payments.noStatement" | ||
| 979 | + | "payments.due" | ||
| 980 | + | "payments.credited" | ||
| 981 | + | "payments.refunded" | ||
| 982 | + | "payments.outstanding" | ||
| 983 | + | "payments.status" | ||
| 984 | + | "payments.overdue" | ||
| 985 | + | "payments.reversed" | ||
| 986 | + | "payments.paid" | ||
| 987 | + | "payments.appendOnly" | ||
| 988 | + | "payments.tabCollect" | ||
| 989 | + | "payments.tabPlans" | ||
| 990 | + | "payments.collect" | ||
| 991 | + | "payments.collectFrom" | ||
| 992 | + | "payments.totalDebt" | ||
| 993 | + | "payments.collected" | ||
| 994 | + | "payments.overdueCount" | ||
| 995 | + | "payments.statusPending" | ||
| 996 | + | "payments.statusPartial" | ||
| 997 | + | "payments.statusCancelled" | ||
| 998 | + | "payments.noDebt" | ||
| 999 | + | "payments.noDebtHint" | ||
| 1000 | + | "payments.methodCash" | ||
| 1001 | + | "payments.methodTransfer" | ||
| 1002 | + | "payments.methodCard" | ||
| 1003 | + | "payments.methodCheck" | ||
| 1004 | + | "payments.ledgerAudit" | ||
| 1005 | + | "payments.showLedger" | ||
| 1006 | + | "payments.hideLedger" | ||
| 1007 | + | "payments.plan" | ||
| 940 | | "terms.title" | 1008 | | "terms.title" |
| 941 | | "terms.subtitle" | 1009 | | "terms.subtitle" |
| 942 | | "terms.create" | 1010 | | "terms.create" |
| @@ -2118,6 +2186,74 @@ const en: Dict = { | |||
| 2118 | "meals.editDish": "Edit dish", | 2186 | "meals.editDish": "Edit dish", |
| 2119 | "meals.dishName": "Dish name", | 2187 | "meals.dishName": "Dish name", |
| 2120 | "meals.priceTry": "Price (TRY)", | 2188 | "meals.priceTry": "Price (TRY)", |
| 2189 | + "nav.payments": "Fees", | ||
| 2190 | + "nav.paymentStatement": "My Fees", | ||
| 2191 | + "payments.title": "School fees", | ||
| 2192 | + "payments.subtitle": "Fee plans, assignments, and the payment ledger.", | ||
| 2193 | + "payments.empty": "No fee plans yet.", | ||
| 2194 | + "payments.createPlan": "New plan", | ||
| 2195 | + "payments.editPlan": "Edit plan", | ||
| 2196 | + "payments.deletePlan": "Delete plan", | ||
| 2197 | + "payments.planName": "Plan name", | ||
| 2198 | + "payments.installments": "Installments", | ||
| 2199 | + "payments.addInstallment": "Add installment", | ||
| 2200 | + "payments.amountTry": "Amount (TRY)", | ||
| 2201 | + "payments.dueDate": "Due date", | ||
| 2202 | + "payments.total": "Total", | ||
| 2203 | + "payments.assign": "Assign", | ||
| 2204 | + "payments.assignHelp": "Assigning bills every installment as a charge at once. Students already on the plan are not billed again.", | ||
| 2205 | + "payments.selectStudent": "Select student", | ||
| 2206 | + "payments.assignments": "Assigned students", | ||
| 2207 | + "payments.noAssignments": "No students assigned yet.", | ||
| 2208 | + "payments.outcomeAssigned": "Assigned", | ||
| 2209 | + "payments.outcomeAlready": "Already assigned", | ||
| 2210 | + "payments.outcomeRejected": "Rejected", | ||
| 2211 | + "payments.studentLedger": "Student ledger", | ||
| 2212 | + "payments.balance": "Balance", | ||
| 2213 | + "payments.ledger": "Ledger", | ||
| 2214 | + "payments.noLedger": "No ledger entries.", | ||
| 2215 | + "payments.recordPayment": "Record payment", | ||
| 2216 | + "payments.recordRefund": "Refund", | ||
| 2217 | + "payments.reverse": "Reverse", | ||
| 2218 | + "payments.method": "Method", | ||
| 2219 | + "payments.note": "Note", | ||
| 2220 | + "payments.reason": "Reason", | ||
| 2221 | + "payments.kindCharge": "Charge", | ||
| 2222 | + "payments.kindCredit": "Payment", | ||
| 2223 | + "payments.kindRefund": "Refund", | ||
| 2224 | + "payments.kindReversal": "Reversal", | ||
| 2225 | + "payments.statementTitle": "My fees", | ||
| 2226 | + "payments.statementSubtitle": "What you owe the school and every charge behind it.", | ||
| 2227 | + "payments.noStatement": "No charges yet.", | ||
| 2228 | + "payments.due": "Due", | ||
| 2229 | + "payments.credited": "Paid", | ||
| 2230 | + "payments.refunded": "Refunded", | ||
| 2231 | + "payments.outstanding": "Outstanding", | ||
| 2232 | + "payments.status": "Status", | ||
| 2233 | + "payments.overdue": "Overdue", | ||
| 2234 | + "payments.reversed": "Reversed", | ||
| 2235 | + "payments.paid": "Paid", | ||
| 2236 | + "payments.appendOnly": "The ledger is append-only. A correction needs a balancing entry, never an edit.", | ||
| 2237 | + "payments.tabCollect": "Collection", | ||
| 2238 | + "payments.tabPlans": "Fee plans", | ||
| 2239 | + "payments.collect": "Collect", | ||
| 2240 | + "payments.collectFrom": "Collect payment", | ||
| 2241 | + "payments.totalDebt": "Total billed", | ||
| 2242 | + "payments.collected": "Collected", | ||
| 2243 | + "payments.overdueCount": "Overdue", | ||
| 2244 | + "payments.statusPending": "Pending", | ||
| 2245 | + "payments.statusPartial": "Partial", | ||
| 2246 | + "payments.statusCancelled": "Cancelled", | ||
| 2247 | + "payments.noDebt": "No charges for this student yet.", | ||
| 2248 | + "payments.noDebtHint": "Assign a fee plan from the Fee plans tab to bill this student.", | ||
| 2249 | + "payments.methodCash": "Cash", | ||
| 2250 | + "payments.methodTransfer": "Transfer / EFT", | ||
| 2251 | + "payments.methodCard": "Card", | ||
| 2252 | + "payments.methodCheck": "Cheque", | ||
| 2253 | + "payments.ledgerAudit": "Account activity", | ||
| 2254 | + "payments.showLedger": "Show account activity", | ||
| 2255 | + "payments.hideLedger": "Hide account activity", | ||
| 2256 | + "payments.plan": "Plan", | ||
| 2121 | "terms.title": "Academic terms", | 2257 | "terms.title": "Academic terms", |
| 2122 | "terms.subtitle": "Manage academic terms and assign courses to each one.", | 2258 | "terms.subtitle": "Manage academic terms and assign courses to each one.", |
| 2123 | "terms.create": "Create term", | 2259 | "terms.create": "Create term", |
| @@ -3225,6 +3361,74 @@ const tr: Dict = { | |||
| 3225 | "meals.editDish": "Yemeği düzenle", | 3361 | "meals.editDish": "Yemeği düzenle", |
| 3226 | "meals.dishName": "Yemek adı", | 3362 | "meals.dishName": "Yemek adı", |
| 3227 | "meals.priceTry": "Fiyat (TRY)", | 3363 | "meals.priceTry": "Fiyat (TRY)", |
| 3364 | + "nav.payments": "Ücretler", | ||
| 3365 | + "nav.paymentStatement": "Ücretlerim", | ||
| 3366 | + "payments.title": "Okul ücretleri", | ||
| 3367 | + "payments.subtitle": "Ücret planları, atamalar ve ödeme hareketleri.", | ||
| 3368 | + "payments.empty": "Henüz ücret planı yok.", | ||
| 3369 | + "payments.createPlan": "Yeni plan", | ||
| 3370 | + "payments.editPlan": "Planı düzenle", | ||
| 3371 | + "payments.deletePlan": "Planı sil", | ||
| 3372 | + "payments.planName": "Plan adı", | ||
| 3373 | + "payments.installments": "Taksitler", | ||
| 3374 | + "payments.addInstallment": "Taksit ekle", | ||
| 3375 | + "payments.amountTry": "Tutar (TRY)", | ||
| 3376 | + "payments.dueDate": "Vade tarihi", | ||
| 3377 | + "payments.total": "Toplam", | ||
| 3378 | + "payments.assign": "Ata", | ||
| 3379 | + "payments.assignHelp": "Atama, tüm taksitleri anında ücret olarak yansıtır. Planda olan öğrenciye tekrar ücret çıkmaz.", | ||
| 3380 | + "payments.selectStudent": "Öğrenci seç", | ||
| 3381 | + "payments.assignments": "Atanan öğrenciler", | ||
| 3382 | + "payments.noAssignments": "Henüz öğrenci atanmadı.", | ||
| 3383 | + "payments.outcomeAssigned": "Atandı", | ||
| 3384 | + "payments.outcomeAlready": "Zaten atanmış", | ||
| 3385 | + "payments.outcomeRejected": "Reddedildi", | ||
| 3386 | + "payments.studentLedger": "Öğrenci hesabı", | ||
| 3387 | + "payments.balance": "Bakiye", | ||
| 3388 | + "payments.ledger": "Hesap hareketleri", | ||
| 3389 | + "payments.noLedger": "Hesap hareketi yok.", | ||
| 3390 | + "payments.recordPayment": "Ödeme kaydet", | ||
| 3391 | + "payments.recordRefund": "İade et", | ||
| 3392 | + "payments.reverse": "Ters kaydet", | ||
| 3393 | + "payments.method": "Yöntem", | ||
| 3394 | + "payments.note": "Not", | ||
| 3395 | + "payments.reason": "Gerekçe", | ||
| 3396 | + "payments.kindCharge": "Ücret", | ||
| 3397 | + "payments.kindCredit": "Ödeme", | ||
| 3398 | + "payments.kindRefund": "İade", | ||
| 3399 | + "payments.kindReversal": "Ters kayıt", | ||
| 3400 | + "payments.statementTitle": "Ücretlerim", | ||
| 3401 | + "payments.statementSubtitle": "Okula borcunuz ve arkasındaki tüm ücretler.", | ||
| 3402 | + "payments.noStatement": "Henüz ücret yok.", | ||
| 3403 | + "payments.due": "Vade", | ||
| 3404 | + "payments.credited": "Ödenen", | ||
| 3405 | + "payments.refunded": "İade", | ||
| 3406 | + "payments.outstanding": "Kalan", | ||
| 3407 | + "payments.status": "Durum", | ||
| 3408 | + "payments.overdue": "Gecikmiş", | ||
| 3409 | + "payments.reversed": "Ters kaydedildi", | ||
| 3410 | + "payments.paid": "Ödendi", | ||
| 3411 | + "payments.appendOnly": "Hesap yalnızca eklenir. Düzeltme, düzenleme değil dengeleyici kayıt gerektirir.", | ||
| 3412 | + "payments.tabCollect": "Tahsilat", | ||
| 3413 | + "payments.tabPlans": "Ücret planları", | ||
| 3414 | + "payments.collect": "Tahsilat Al", | ||
| 3415 | + "payments.collectFrom": "Tahsilat al", | ||
| 3416 | + "payments.totalDebt": "Toplam borç", | ||
| 3417 | + "payments.collected": "Tahsil edilen", | ||
| 3418 | + "payments.overdueCount": "Gecikmiş", | ||
| 3419 | + "payments.statusPending": "Bekliyor", | ||
| 3420 | + "payments.statusPartial": "Kısmi", | ||
| 3421 | + "payments.statusCancelled": "İptal edildi", | ||
| 3422 | + "payments.noDebt": "Bu öğrenci için henüz borç yok.", | ||
| 3423 | + "payments.noDebtHint": "Bu öğrenciye borç çıkmak için Ücret planları sekmesinden bir plan atayın.", | ||
| 3424 | + "payments.methodCash": "Nakit", | ||
| 3425 | + "payments.methodTransfer": "Havale / EFT", | ||
| 3426 | + "payments.methodCard": "Kredi kartı", | ||
| 3427 | + "payments.methodCheck": "Çek", | ||
| 3428 | + "payments.ledgerAudit": "Hesap hareketleri", | ||
| 3429 | + "payments.showLedger": "Hesap hareketlerini göster", | ||
| 3430 | + "payments.hideLedger": "Hesap hareketlerini gizle", | ||
| 3431 | + "payments.plan": "Plan", | ||
| 3228 | "terms.title": "Akademik dönemler", | 3432 | "terms.title": "Akademik dönemler", |
| 3229 | "terms.subtitle": "Akademik dönemleri yönetin ve dersleri ilgili dönemlere atayın.", | 3433 | "terms.subtitle": "Akademik dönemleri yönetin ve dersleri ilgili dönemlere atayın.", |
| 3230 | "terms.create": "Dönem oluştur", | 3434 | "terms.create": "Dönem oluştur", |
src/lib/payments.tsadded+44 -0
| @@ -0,0 +1,44 @@ | |||
| 1 | +import type { StatementEntry } from "@/api/payments"; | ||
| 2 | +import type { MessageKey } from "@/i18n/messages"; | ||
| 3 | + | ||
| 4 | +export type StatementStatus = { | ||
| 5 | + key: MessageKey; | ||
| 6 | + // Badge color classes (used with Badge variant="outline") and a matching dot. | ||
| 7 | + class: string; | ||
| 8 | + dot: string; | ||
| 9 | +}; | ||
| 10 | + | ||
| 11 | +// A charge's status, mirrored from the backend rollup fields, in the finance | ||
| 12 | +// operator's vocabulary (paid / partial / overdue / pending / cancelled), with | ||
| 13 | +// receivables-aging colors: green current/paid, amber partial, red overdue. | ||
| 14 | +export function statementStatus(entry: StatementEntry): StatementStatus { | ||
| 15 | + if (entry.reversed) return { key: "payments.statusCancelled", class: "border-border bg-muted/40 text-muted-foreground", dot: "bg-muted-foreground/50" }; | ||
| 16 | + if (entry.outstanding_minor <= 0) return { key: "payments.paid", class: "border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300", dot: "bg-emerald-500" }; | ||
| 17 | + if (entry.overdue) return { key: "payments.overdue", class: "border-red-500/40 bg-red-500/10 text-red-700 dark:text-red-300", dot: "bg-red-500" }; | ||
| 18 | + if (entry.credited_minor > 0) return { key: "payments.statusPartial", class: "border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-200", dot: "bg-amber-500" }; | ||
| 19 | + return { key: "payments.statusPending", class: "border-border bg-background/50 text-muted-foreground", dot: "bg-muted-foreground/40" }; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +// Sort rank for a receivables list: overdue first, then unpaid by due date, | ||
| 23 | +// then settled, then cancelled last. | ||
| 24 | +export function statementSortRank(entry: StatementEntry): number { | ||
| 25 | + if (entry.reversed) return 3; | ||
| 26 | + if (entry.outstanding_minor <= 0) return 2; | ||
| 27 | + if (entry.overdue) return 0; | ||
| 28 | + return 1; | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +export function sortStatementEntries(entries: StatementEntry[]): StatementEntry[] { | ||
| 32 | + return [...entries].sort( | ||
| 33 | + (a, b) => statementSortRank(a) - statementSortRank(b) || (a.due_at ?? Infinity) - (b.due_at ?? Infinity), | ||
| 34 | + ); | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// Common collection methods. Values are stored as free text on the ledger line, | ||
| 38 | +// so the localized label is what a receipt shows. | ||
| 39 | +export const PAYMENT_METHOD_KEYS: MessageKey[] = [ | ||
| 40 | + "payments.methodCash", | ||
| 41 | + "payments.methodTransfer", | ||
| 42 | + "payments.methodCard", | ||
| 43 | + "payments.methodCheck", | ||
| 44 | +]; | ||
src/pages/payment-statement-page.tsxadded+140 -0
| @@ -0,0 +1,140 @@ | |||
| 1 | +import { Show, Suspense, createEffect, createMemo, createResource, createSignal } from "solid-js"; | ||
| 2 | +import type { ColumnDef } from "@tanstack/solid-table"; | ||
| 3 | +import { | ||
| 4 | + getMyPaymentBalance, | ||
| 5 | + getMyPaymentStatement, | ||
| 6 | + getPaymentBalanceByUserId, | ||
| 7 | + getPaymentStatementByUserId, | ||
| 8 | + type StatementEntry, | ||
| 9 | +} from "@/api/payments"; | ||
| 10 | +import { getMyStudents } from "@/api/parents"; | ||
| 11 | +import { formatApiError } from "@/api/client"; | ||
| 12 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 13 | +import { PageHeader } from "@/components/layout/page-header"; | ||
| 14 | +import { Badge } from "@/components/ui/badge"; | ||
| 15 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | ||
| 16 | +import { EmptyState } from "@/components/ui/empty-state"; | ||
| 17 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 18 | +import { Label } from "@/components/ui/label"; | ||
| 19 | +import { SearchableSelect } from "@/components/ui/searchable-select"; | ||
| 20 | +import { formatDate } from "@/lib/format"; | ||
| 21 | +import { formatTry } from "@/lib/meals"; | ||
| 22 | +import { sortStatementEntries, statementStatus } from "@/lib/payments"; | ||
| 23 | +import { personLabel } from "@/lib/person"; | ||
| 24 | +import { useAuth } from "@/stores/auth-context"; | ||
| 25 | +import { usePreferences, useT } from "@/stores/preferences-context"; | ||
| 26 | + | ||
| 27 | +const STATEMENT_PAGE_SIZE = 12; | ||
| 28 | + | ||
| 29 | +export default function PaymentStatementPage() { | ||
| 30 | + return ( | ||
| 31 | + <RouteGuard> | ||
| 32 | + <StatementContent /> | ||
| 33 | + </RouteGuard> | ||
| 34 | + ); | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +function StatementContent() { | ||
| 38 | + const auth = useAuth(); | ||
| 39 | + const t = useT(); | ||
| 40 | + const { locale } = usePreferences(); | ||
| 41 | + const moneyLocale = () => (locale() === "tr" ? "tr-TR" : "en-US"); | ||
| 42 | + const isParent = () => auth.user()!.role === "parent"; | ||
| 43 | + | ||
| 44 | + const [children] = createResource(() => (isParent() ? getMyStudents({ limit: 100 }) : null)); | ||
| 45 | + const [selectedChild, setSelectedChild] = createSignal(""); | ||
| 46 | + createEffect(() => { | ||
| 47 | + if (isParent() && !selectedChild() && children()?.items[0]) setSelectedChild(children()!.items[0].id); | ||
| 48 | + }); | ||
| 49 | + // Parent reads a child by id; everyone else reads their own record. | ||
| 50 | + const targetId = () => (isParent() ? selectedChild() : ""); | ||
| 51 | + | ||
| 52 | + const [statement, { refetch }] = createResource( | ||
| 53 | + () => (isParent() ? targetId() || null : "me"), | ||
| 54 | + (key) => (key === "me" ? getMyPaymentStatement({ limit: 100 }) : getPaymentStatementByUserId(key, { limit: 100 })), | ||
| 55 | + ); | ||
| 56 | + const [balance] = createResource( | ||
| 57 | + () => (isParent() ? targetId() || null : "me"), | ||
| 58 | + (key) => (key === "me" ? getMyPaymentBalance() : getPaymentBalanceByUserId(key)), | ||
| 59 | + ); | ||
| 60 | + const entries = () => statement()?.entries.items ?? []; | ||
| 61 | + const summary = createMemo(() => { | ||
| 62 | + const rows = entries(); | ||
| 63 | + return { | ||
| 64 | + billed: rows.filter((row) => !row.reversed).reduce((sum, row) => sum + row.amount_minor, 0), | ||
| 65 | + collected: rows.reduce((sum, row) => sum + row.credited_minor, 0), | ||
| 66 | + balance: statement()?.balance_minor ?? balance()?.balance_minor ?? 0, | ||
| 67 | + }; | ||
| 68 | + }); | ||
| 69 | + | ||
| 70 | + const columns = createMemo<ColumnDef<StatementEntry>[]>(() => [ | ||
| 71 | + { | ||
| 72 | + id: "plan", | ||
| 73 | + header: t("payments.planName"), | ||
| 74 | + cell: (cell) => <span class="font-medium">{cell.row.original.plan_name ?? "—"}</span>, | ||
| 75 | + }, | ||
| 76 | + { | ||
| 77 | + accessorKey: "amount_minor", | ||
| 78 | + header: t("payments.amountTry"), | ||
| 79 | + cell: (cell) => <span class="tabular-nums">{formatTry(cell.row.original.amount_minor, moneyLocale())}</span>, | ||
| 80 | + }, | ||
| 81 | + { | ||
| 82 | + accessorKey: "due_at", | ||
| 83 | + header: t("payments.due"), | ||
| 84 | + cell: (cell) => <span class="mono text-sm" classList={{ "font-semibold text-destructive": cell.row.original.overdue }}>{cell.row.original.due_at == null ? "—" : formatDate(cell.row.original.due_at, locale())}</span>, | ||
| 85 | + }, | ||
| 86 | + { | ||
| 87 | + accessorKey: "credited_minor", | ||
| 88 | + header: t("payments.credited"), | ||
| 89 | + cell: (cell) => <span class="tabular-nums">{formatTry(cell.row.original.credited_minor, moneyLocale())}</span>, | ||
| 90 | + }, | ||
| 91 | + { | ||
| 92 | + accessorKey: "outstanding_minor", | ||
| 93 | + header: t("payments.outstanding"), | ||
| 94 | + cell: (cell) => <span class="tabular-nums">{formatTry(cell.row.original.outstanding_minor, moneyLocale())}</span>, | ||
| 95 | + }, | ||
| 96 | + { | ||
| 97 | + id: "status", | ||
| 98 | + header: t("payments.status"), | ||
| 99 | + cell: (cell) => { | ||
| 100 | + const status = statementStatus(cell.row.original); | ||
| 101 | + return <Badge variant="outline" class={status.class}><span class={`mr-1.5 inline-block h-1.5 w-1.5 rounded-full ${status.dot}`} />{t(status.key)}</Badge>; | ||
| 102 | + }, | ||
| 103 | + }, | ||
| 104 | + ]); | ||
| 105 | + | ||
| 106 | + return ( | ||
| 107 | + <div class="space-y-6"> | ||
| 108 | + <PageHeader | ||
| 109 | + accent="violet" | ||
| 110 | + eyebrow={t("nav.paymentStatement")} | ||
| 111 | + title={t("payments.statementTitle")} | ||
| 112 | + description={t("payments.statementSubtitle")} | ||
| 113 | + /> | ||
| 114 | + | ||
| 115 | + <Show when={isParent()}> | ||
| 116 | + <div class="data-shell max-w-md p-4"> | ||
| 117 | + <Label for="statement-child">{t("meals.child")}</Label> | ||
| 118 | + <SearchableSelect id="statement-child" value={selectedChild()} onChange={setSelectedChild} options={(children()?.items ?? []).map((child) => ({ value: child.id, label: personLabel(child) }))} /> | ||
| 119 | + </div> | ||
| 120 | + </Show> | ||
| 121 | + | ||
| 122 | + <div class="grid gap-3 sm:grid-cols-3"> | ||
| 123 | + <div class="detail-metric-card"><p class="text-xs uppercase text-muted-foreground">{t("payments.totalDebt")}</p><p class="mt-1 font-semibold tabular-nums">{formatTry(summary().billed, moneyLocale())}</p></div> | ||
| 124 | + <div class="detail-metric-card"><p class="text-xs uppercase text-muted-foreground">{t("payments.collected")}</p><p class="mt-1 font-semibold tabular-nums">{formatTry(summary().collected, moneyLocale())}</p></div> | ||
| 125 | + <div class="detail-metric-card"><p class="text-xs uppercase text-muted-foreground">{t("payments.balance")}</p><p class="mt-1 text-2xl font-semibold tabular-nums" classList={{ "text-destructive": summary().balance < 0 }}>{formatTry(summary().balance, moneyLocale())}</p></div> | ||
| 126 | + </div> | ||
| 127 | + | ||
| 128 | + <section class="data-shell space-y-4 border-violet-500/15 bg-violet-500/2.5 p-4"> | ||
| 129 | + <Suspense fallback={<DataTableSkeleton columns={6} rows={6} />}> | ||
| 130 | + <Show when={statement.error}> | ||
| 131 | + <ErrorAlert message={formatApiError(statement.error)} onRetry={() => void refetch()} /> | ||
| 132 | + </Show> | ||
| 133 | + <Show when={entries().length > 0} fallback={<EmptyState title={t("payments.noStatement")} />}> | ||
| 134 | + <DataTable columns={columns()} data={sortStatementEntries(entries())} tableClass="min-w-160" enablePagination pageSize={STATEMENT_PAGE_SIZE} /> | ||
| 135 | + </Show> | ||
| 136 | + </Suspense> | ||
| 137 | + </section> | ||
| 138 | + </div> | ||
| 139 | + ); | ||
| 140 | +} | ||
src/pages/payments-page.tsxadded+632 -0
| @@ -0,0 +1,632 @@ | |||
| 1 | +import { For, Index, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; | ||
| 2 | +import type { ColumnDef } from "@tanstack/solid-table"; | ||
| 3 | +import { | ||
| 4 | + deletePaymentPlanById, | ||
| 5 | + getPaymentLedgerByUserId, | ||
| 6 | + getPaymentPlans, | ||
| 7 | + getPaymentStatementByUserId, | ||
| 8 | + getPlanAssignments, | ||
| 9 | + patchPaymentPlanById, | ||
| 10 | + postPaymentCredit, | ||
| 11 | + postPaymentPlan, | ||
| 12 | + postPaymentRefund, | ||
| 13 | + postPaymentReversal, | ||
| 14 | + postPlanAssignment, | ||
| 15 | + type FeePlan, | ||
| 16 | + type FeePlanInstallment, | ||
| 17 | + type PaymentLine, | ||
| 18 | + type StatementEntry, | ||
| 19 | +} from "@/api/payments"; | ||
| 20 | +import { formatApiError } from "@/api/client"; | ||
| 21 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 22 | +import { PageHeader } from "@/components/layout/page-header"; | ||
| 23 | +import { Alert } from "@/components/ui/alert"; | ||
| 24 | +import { Badge } from "@/components/ui/badge"; | ||
| 25 | +import { Button } from "@/components/ui/button"; | ||
| 26 | +import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | ||
| 27 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | ||
| 28 | +import { DatePicker } from "@/components/ui/date-picker"; | ||
| 29 | +import { EmptyState } from "@/components/ui/empty-state"; | ||
| 30 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 31 | +import { IconEdit, IconPlus, IconTrash } from "@/components/ui/icons"; | ||
| 32 | +import { Input } from "@/components/ui/input"; | ||
| 33 | +import { Label } from "@/components/ui/label"; | ||
| 34 | +import { Select } from "@/components/ui/select"; | ||
| 35 | +import { SidePanel } from "@/components/ui/side-panel"; | ||
| 36 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | ||
| 37 | +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 38 | +import { Textarea } from "@/components/ui/textarea"; | ||
| 39 | +import { UserSearchSelect } from "@/components/users/user-search-select"; | ||
| 40 | +import { createFlash } from "@/lib/flash"; | ||
| 41 | +import { formatDate, formatDateTime } from "@/lib/format"; | ||
| 42 | +import { formatTry } from "@/lib/meals"; | ||
| 43 | +import { PAYMENT_METHOD_KEYS, sortStatementEntries, statementStatus } from "@/lib/payments"; | ||
| 44 | +import { personLabel } from "@/lib/person"; | ||
| 45 | +import { usePreferences, useT } from "@/stores/preferences-context"; | ||
| 46 | + | ||
| 47 | +const PLAN_PAGE_SIZE = 12; | ||
| 48 | +const STATEMENT_PAGE_SIZE = 15; | ||
| 49 | + | ||
| 50 | +function dateInputFromMs(ms: number): string { | ||
| 51 | + const date = new Date(ms); | ||
| 52 | + const pad = (n: number) => String(n).padStart(2, "0"); | ||
| 53 | + return `${pad(date.getDate())}/${pad(date.getMonth() + 1)}/${date.getFullYear()}`; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +function dateInputToMs(value: string): number | null { | ||
| 57 | + const match = value.trim().match(/^(\d{2})\/(\d{2})\/(\d{4})$/); | ||
| 58 | + if (!match) return null; | ||
| 59 | + const [, dayRaw, monthRaw, yearRaw] = match; | ||
| 60 | + const day = Number(dayRaw); | ||
| 61 | + const month = Number(monthRaw); | ||
| 62 | + const year = Number(yearRaw); | ||
| 63 | + const date = new Date(year, month - 1, day, 0, 0, 0, 0); | ||
| 64 | + if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) return null; | ||
| 65 | + return date.getTime(); | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +type LineAction = { line: PaymentLine; kind: "refund" | "reverse" }; | ||
| 69 | + | ||
| 70 | +export default function PaymentsPage() { | ||
| 71 | + return ( | ||
| 72 | + <RouteGuard minRole="manager"> | ||
| 73 | + <PaymentsContent /> | ||
| 74 | + </RouteGuard> | ||
| 75 | + ); | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +function PaymentsContent() { | ||
| 79 | + const t = useT(); | ||
| 80 | + const { locale } = usePreferences(); | ||
| 81 | + const moneyLocale = () => (locale() === "tr" ? "tr-TR" : "en-US"); | ||
| 82 | + const [tab, setTab] = createSignal("collect"); | ||
| 83 | + const [error, setError] = createSignal(""); | ||
| 84 | + const [flash, setFlash] = createFlash(); | ||
| 85 | + const [pending, setPending] = createSignal(false); | ||
| 86 | + | ||
| 87 | + // ============================ Collection ============================ | ||
| 88 | + const [student, setStudent] = createSignal(""); | ||
| 89 | + const [statement, { refetch: refetchStatement }] = createResource( | ||
| 90 | + () => student() || null, | ||
| 91 | + (userId) => getPaymentStatementByUserId(userId, { limit: 500 }), | ||
| 92 | + ); | ||
| 93 | + const [ledger, { refetch: refetchLedger }] = createResource( | ||
| 94 | + () => student() || null, | ||
| 95 | + (userId) => getPaymentLedgerByUserId(userId, { limit: 200 }), | ||
| 96 | + ); | ||
| 97 | + const entries = () => statement()?.entries.items ?? []; | ||
| 98 | + const sortedEntries = () => sortStatementEntries(entries()); | ||
| 99 | + const summary = createMemo(() => { | ||
| 100 | + const rows = entries(); | ||
| 101 | + return { | ||
| 102 | + billed: rows.filter((row) => !row.reversed).reduce((sum, row) => sum + row.amount_minor, 0), | ||
| 103 | + collected: rows.reduce((sum, row) => sum + row.credited_minor, 0), | ||
| 104 | + overdue: rows.filter((row) => row.overdue).length, | ||
| 105 | + balance: statement()?.balance_minor ?? 0, | ||
| 106 | + }; | ||
| 107 | + }); | ||
| 108 | + | ||
| 109 | + const [collectEntry, setCollectEntry] = createSignal<StatementEntry | null>(null); | ||
| 110 | + const [collectAmount, setCollectAmount] = createSignal(""); | ||
| 111 | + const [collectMethod, setCollectMethod] = createSignal(""); | ||
| 112 | + const [collectNote, setCollectNote] = createSignal(""); | ||
| 113 | + | ||
| 114 | + const openCollect = (entry: StatementEntry) => { | ||
| 115 | + setCollectEntry(entry); | ||
| 116 | + setCollectAmount(entry.outstanding_minor > 0 ? String(entry.outstanding_minor / 100) : ""); | ||
| 117 | + setCollectMethod(t("payments.methodCash")); | ||
| 118 | + setCollectNote(""); | ||
| 119 | + setError(""); | ||
| 120 | + }; | ||
| 121 | + const submitCollect = async (e: SubmitEvent) => { | ||
| 122 | + e.preventDefault(); | ||
| 123 | + const entry = collectEntry(); | ||
| 124 | + if (!entry) return; | ||
| 125 | + const amount_minor = Math.round(Number(collectAmount()) * 100); | ||
| 126 | + if (!(amount_minor > 0)) { | ||
| 127 | + setError(t("payments.amountTry")); | ||
| 128 | + return; | ||
| 129 | + } | ||
| 130 | + setPending(true); | ||
| 131 | + setError(""); | ||
| 132 | + try { | ||
| 133 | + await postPaymentCredit({ | ||
| 134 | + charge_id: entry.charge_id, | ||
| 135 | + amount_minor, | ||
| 136 | + method: collectMethod().trim() || undefined, | ||
| 137 | + note: collectNote().trim() || undefined, | ||
| 138 | + request_key: crypto.randomUUID(), | ||
| 139 | + }); | ||
| 140 | + setCollectEntry(null); | ||
| 141 | + setFlash(t("common.saved")); | ||
| 142 | + await Promise.all([refetchStatement(), refetchLedger()]); | ||
| 143 | + } catch (err) { | ||
| 144 | + setError(formatApiError(err)); | ||
| 145 | + } finally { | ||
| 146 | + setPending(false); | ||
| 147 | + } | ||
| 148 | + }; | ||
| 149 | + | ||
| 150 | + const statementColumns = createMemo<ColumnDef<StatementEntry>[]>(() => [ | ||
| 151 | + { | ||
| 152 | + id: "plan", | ||
| 153 | + header: t("payments.plan"), | ||
| 154 | + cell: (cell) => <span class="font-medium">{cell.row.original.plan_name ?? "—"}</span>, | ||
| 155 | + }, | ||
| 156 | + { | ||
| 157 | + accessorKey: "due_at", | ||
| 158 | + header: t("payments.due"), | ||
| 159 | + cell: (cell) => <span class="mono text-sm" classList={{ "font-semibold text-destructive": cell.row.original.overdue }}>{cell.row.original.due_at == null ? "—" : formatDate(cell.row.original.due_at, locale())}</span>, | ||
| 160 | + }, | ||
| 161 | + { | ||
| 162 | + accessorKey: "amount_minor", | ||
| 163 | + header: t("payments.amountTry"), | ||
| 164 | + cell: (cell) => <span class="tabular-nums">{formatTry(cell.row.original.amount_minor, moneyLocale())}</span>, | ||
| 165 | + }, | ||
| 166 | + { | ||
| 167 | + accessorKey: "credited_minor", | ||
| 168 | + header: t("payments.collected"), | ||
| 169 | + cell: (cell) => <span class="tabular-nums text-muted-foreground">{formatTry(cell.row.original.credited_minor, moneyLocale())}</span>, | ||
| 170 | + }, | ||
| 171 | + { | ||
| 172 | + accessorKey: "outstanding_minor", | ||
| 173 | + header: t("payments.outstanding"), | ||
| 174 | + cell: (cell) => <span class="font-semibold tabular-nums">{formatTry(cell.row.original.outstanding_minor, moneyLocale())}</span>, | ||
| 175 | + }, | ||
| 176 | + { | ||
| 177 | + id: "status", | ||
| 178 | + header: t("payments.status"), | ||
| 179 | + cell: (cell) => { | ||
| 180 | + const status = statementStatus(cell.row.original); | ||
| 181 | + return <Badge variant="outline" class={status.class}><span class={`mr-1.5 inline-block h-1.5 w-1.5 rounded-full ${status.dot}`} />{t(status.key)}</Badge>; | ||
| 182 | + }, | ||
| 183 | + }, | ||
| 184 | + { | ||
| 185 | + id: "actions", | ||
| 186 | + header: "", | ||
| 187 | + meta: { headerClass: "w-32 min-w-32 text-right", cellClass: "text-right" }, | ||
| 188 | + cell: (cell) => ( | ||
| 189 | + <Show when={!cell.row.original.reversed && cell.row.original.outstanding_minor > 0}> | ||
| 190 | + <Button size="sm" class="rounded-lg" onClick={() => openCollect(cell.row.original)}>{t("payments.collect")}</Button> | ||
| 191 | + </Show> | ||
| 192 | + ), | ||
| 193 | + }, | ||
| 194 | + ]); | ||
| 195 | + | ||
| 196 | + // ---- account activity (advanced corrections) ---- | ||
| 197 | + const [showLedger, setShowLedger] = createSignal(false); | ||
| 198 | + const [lineAction, setLineAction] = createSignal<LineAction | null>(null); | ||
| 199 | + const [actionAmount, setActionAmount] = createSignal(""); | ||
| 200 | + const [actionNote, setActionNote] = createSignal(""); | ||
| 201 | + const kindLabel = (kind: PaymentLine["kind"]) => t(`payments.kind${kind.charAt(0).toUpperCase()}${kind.slice(1)}` as never); | ||
| 202 | + const openLineAction = (line: PaymentLine, kind: LineAction["kind"]) => { | ||
| 203 | + setLineAction({ line, kind }); | ||
| 204 | + setActionAmount(kind === "refund" ? String(line.amount_minor / 100) : ""); | ||
| 205 | + setActionNote(""); | ||
| 206 | + setError(""); | ||
| 207 | + }; | ||
| 208 | + const submitLineAction = async (e: SubmitEvent) => { | ||
| 209 | + e.preventDefault(); | ||
| 210 | + const action = lineAction(); | ||
| 211 | + if (!action) return; | ||
| 212 | + const note = actionNote().trim() || undefined; | ||
| 213 | + setPending(true); | ||
| 214 | + setError(""); | ||
| 215 | + try { | ||
| 216 | + if (action.kind === "reverse") { | ||
| 217 | + await postPaymentReversal({ line_id: action.line.id, note }); | ||
| 218 | + } else { | ||
| 219 | + const amount_minor = Math.round(Number(actionAmount()) * 100); | ||
| 220 | + if (!(amount_minor > 0)) { | ||
| 221 | + setError(t("payments.amountTry")); | ||
| 222 | + setPending(false); | ||
| 223 | + return; | ||
| 224 | + } | ||
| 225 | + await postPaymentRefund({ credit_id: action.line.id, amount_minor, note, request_key: crypto.randomUUID() }); | ||
| 226 | + } | ||
| 227 | + setLineAction(null); | ||
| 228 | + setFlash(t("common.saved")); | ||
| 229 | + await Promise.all([refetchStatement(), refetchLedger()]); | ||
| 230 | + } catch (err) { | ||
| 231 | + setError(formatApiError(err)); | ||
| 232 | + } finally { | ||
| 233 | + setPending(false); | ||
| 234 | + } | ||
| 235 | + }; | ||
| 236 | + | ||
| 237 | + // ============================ Fee plans ============================ | ||
| 238 | + const [plans, { refetch: refetchPlans }] = createResource(async () => (await getPaymentPlans({ limit: 100 })).items); | ||
| 239 | + const planList = () => plans() ?? []; | ||
| 240 | + const [panelOpen, setPanelOpen] = createSignal(false); | ||
| 241 | + const [editing, setEditing] = createSignal<FeePlan | null>(null); | ||
| 242 | + const [planName, setPlanName] = createSignal(""); | ||
| 243 | + const [rows, setRows] = createSignal<{ amount: string; due: string }[]>([{ amount: "", due: "" }]); | ||
| 244 | + const [deleteTarget, setDeleteTarget] = createSignal<FeePlan | null>(null); | ||
| 245 | + const [assignPlan, setAssignPlan] = createSignal<FeePlan | null>(null); | ||
| 246 | + const [assignStudent, setAssignStudent] = createSignal(""); | ||
| 247 | + const [assignments, { refetch: refetchAssignments }] = createResource( | ||
| 248 | + () => assignPlan()?.id ?? null, | ||
| 249 | + (planId) => getPlanAssignments(planId, { limit: 200 }), | ||
| 250 | + ); | ||
| 251 | + | ||
| 252 | + const planTotal = (plan: FeePlan) => plan.installments.reduce((sum, item) => sum + item.amount_minor, 0); | ||
| 253 | + const planColumns = createMemo<ColumnDef<FeePlan>[]>(() => [ | ||
| 254 | + { accessorKey: "name", header: t("payments.planName"), cell: (cell) => <span class="font-medium">{cell.row.original.name}</span> }, | ||
| 255 | + { id: "installments", header: t("payments.installments"), cell: (cell) => <span class="mono text-sm">{cell.row.original.installments.length}</span> }, | ||
| 256 | + { id: "total", header: t("payments.total"), cell: (cell) => <span class="tabular-nums">{formatTry(planTotal(cell.row.original), moneyLocale())}</span> }, | ||
| 257 | + { | ||
| 258 | + id: "actions", | ||
| 259 | + header: t("common.actions"), | ||
| 260 | + meta: { headerClass: "w-40 min-w-40 text-right whitespace-nowrap", cellClass: "text-right" }, | ||
| 261 | + cell: (cell) => ( | ||
| 262 | + <div class="flex items-center justify-end gap-1"> | ||
| 263 | + <Button size="sm" variant="outline" class="rounded-lg" onClick={() => openAssign(cell.row.original)}> | ||
| 264 | + <IconPlus class="h-4 w-4" /> | ||
| 265 | + {t("payments.assign")} | ||
| 266 | + </Button> | ||
| 267 | + <TableRowActions | ||
| 268 | + label={t("common.actions")} | ||
| 269 | + actions={[ | ||
| 270 | + { label: t("common.edit"), icon: <IconEdit class="h-4 w-4" />, onSelect: () => startEdit(cell.row.original) }, | ||
| 271 | + { label: t("common.delete"), icon: <IconTrash class="h-4 w-4" />, destructive: true, onSelect: () => setDeleteTarget(cell.row.original) }, | ||
| 272 | + ]} | ||
| 273 | + /> | ||
| 274 | + </div> | ||
| 275 | + ), | ||
| 276 | + }, | ||
| 277 | + ]); | ||
| 278 | + | ||
| 279 | + const resetPlanForm = () => { | ||
| 280 | + setPlanName(""); | ||
| 281 | + setRows([{ amount: "", due: "" }]); | ||
| 282 | + setEditing(null); | ||
| 283 | + setError(""); | ||
| 284 | + }; | ||
| 285 | + const openCreate = () => { | ||
| 286 | + resetPlanForm(); | ||
| 287 | + setPanelOpen(true); | ||
| 288 | + }; | ||
| 289 | + const startEdit = (plan: FeePlan) => { | ||
| 290 | + setEditing(plan); | ||
| 291 | + setPlanName(plan.name); | ||
| 292 | + setRows(plan.installments.map((item) => ({ amount: String(item.amount_minor / 100), due: dateInputFromMs(item.due_at) }))); | ||
| 293 | + setError(""); | ||
| 294 | + setPanelOpen(true); | ||
| 295 | + }; | ||
| 296 | + const addRow = () => setRows([...rows(), { amount: "", due: "" }]); | ||
| 297 | + const removeRow = (idx: number) => setRows(rows().filter((_, i) => i !== idx)); | ||
| 298 | + const setRowAmount = (idx: number, value: string) => setRows(rows().map((r, i) => (i === idx ? { ...r, amount: value } : r))); | ||
| 299 | + const setRowDue = (idx: number, value: string) => setRows(rows().map((r, i) => (i === idx ? { ...r, due: value } : r))); | ||
| 300 | + | ||
| 301 | + const savePlan = async (e: SubmitEvent) => { | ||
| 302 | + e.preventDefault(); | ||
| 303 | + setError(""); | ||
| 304 | + const installments: FeePlanInstallment[] = []; | ||
| 305 | + for (const row of rows()) { | ||
| 306 | + const amount_minor = Math.round(Number(row.amount) * 100); | ||
| 307 | + const due_at = dateInputToMs(row.due); | ||
| 308 | + if (!(amount_minor > 0) || due_at == null) { | ||
| 309 | + setError(t("terms.dateRequired")); | ||
| 310 | + return; | ||
| 311 | + } | ||
| 312 | + installments.push({ amount_minor, due_at }); | ||
| 313 | + } | ||
| 314 | + setPending(true); | ||
| 315 | + try { | ||
| 316 | + const current = editing(); | ||
| 317 | + if (current) { | ||
| 318 | + await patchPaymentPlanById(current.id, { name: planName().trim(), installments }); | ||
| 319 | + setFlash(t("common.saved")); | ||
| 320 | + } else { | ||
| 321 | + await postPaymentPlan({ name: planName().trim(), installments }); | ||
| 322 | + setFlash(t("common.created")); | ||
| 323 | + } | ||
| 324 | + resetPlanForm(); | ||
| 325 | + setPanelOpen(false); | ||
| 326 | + await refetchPlans(); | ||
| 327 | + } catch (err) { | ||
| 328 | + setError(formatApiError(err)); | ||
| 329 | + } finally { | ||
| 330 | + setPending(false); | ||
| 331 | + } | ||
| 332 | + }; | ||
| 333 | + | ||
| 334 | + const openAssign = (plan: FeePlan) => { | ||
| 335 | + setAssignPlan(plan); | ||
| 336 | + setAssignStudent(""); | ||
| 337 | + setError(""); | ||
| 338 | + }; | ||
| 339 | + const submitAssign = async () => { | ||
| 340 | + const plan = assignPlan(); | ||
| 341 | + const target = assignStudent(); | ||
| 342 | + if (!plan || !target) return; | ||
| 343 | + setPending(true); | ||
| 344 | + setError(""); | ||
| 345 | + try { | ||
| 346 | + const outcomes = await postPlanAssignment(plan.id, { student_ids: [target] }); | ||
| 347 | + const outcome = outcomes[0]; | ||
| 348 | + const key = outcome?.status === "assigned" ? "payments.outcomeAssigned" : outcome?.status === "already_assigned" ? "payments.outcomeAlready" : "payments.outcomeRejected"; | ||
| 349 | + setFlash(t(key as never)); | ||
| 350 | + setAssignStudent(""); | ||
| 351 | + await refetchAssignments(); | ||
| 352 | + } catch (err) { | ||
| 353 | + setError(formatApiError(err)); | ||
| 354 | + } finally { | ||
| 355 | + setPending(false); | ||
| 356 | + } | ||
| 357 | + }; | ||
| 358 | + | ||
| 359 | + const globalError = () => error() && !panelOpen() && !assignPlan() && !collectEntry() && !lineAction(); | ||
| 360 | + | ||
| 361 | + return ( | ||
| 362 | + <div class="space-y-6"> | ||
| 363 | + <PageHeader accent="violet" eyebrow={t("nav.school")} title={t("payments.title")} description={t("payments.subtitle")} /> | ||
| 364 | + | ||
| 365 | + <Show when={flash()}> | ||
| 366 | + <Alert variant="success">{flash()}</Alert> | ||
| 367 | + </Show> | ||
| 368 | + <Show when={globalError()}> | ||
| 369 | + <Alert variant="destructive">{error()}</Alert> | ||
| 370 | + </Show> | ||
| 371 | + | ||
| 372 | + <Tabs value={tab()} onChange={setTab}> | ||
| 373 | + <TabsList> | ||
| 374 | + <TabsTrigger value="collect">{t("payments.tabCollect")}</TabsTrigger> | ||
| 375 | + <TabsTrigger value="plans">{t("payments.tabPlans")}</TabsTrigger> | ||
| 376 | + </TabsList> | ||
| 377 | + | ||
| 378 | + {/* ---------------- Collection ---------------- */} | ||
| 379 | + <TabsContent value="collect" class="space-y-5"> | ||
| 380 | + <div class="data-shell max-w-md p-4"> | ||
| 381 | + <UserSearchSelect id="collect-student" role="student" value={student()} onChange={setStudent} label={t("payments.selectStudent")} placeholder={t("payments.selectStudent")} /> | ||
| 382 | + </div> | ||
| 383 | + | ||
| 384 | + <Show when={student()}> | ||
| 385 | + <div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-4"> | ||
| 386 | + <div class="detail-metric-card"><p class="text-xs uppercase text-muted-foreground">{t("payments.totalDebt")}</p><p class="mt-1 font-semibold tabular-nums">{formatTry(summary().billed, moneyLocale())}</p></div> | ||
| 387 | + <div class="detail-metric-card"><p class="text-xs uppercase text-muted-foreground">{t("payments.collected")}</p><p class="mt-1 font-semibold tabular-nums">{formatTry(summary().collected, moneyLocale())}</p></div> | ||
| 388 | + <div class="detail-metric-card"><p class="text-xs uppercase text-muted-foreground">{t("payments.balance")}</p><p class="mt-1 font-semibold tabular-nums" classList={{ "text-destructive": summary().balance < 0 }}>{formatTry(summary().balance, moneyLocale())}</p></div> | ||
| 389 | + <div class="detail-metric-card"><p class="text-xs uppercase text-muted-foreground">{t("payments.overdueCount")}</p><p class="mt-1 font-semibold tabular-nums" classList={{ "text-destructive": summary().overdue > 0 }}>{summary().overdue}</p></div> | ||
| 390 | + </div> | ||
| 391 | + | ||
| 392 | + <section class="data-shell space-y-4 border-violet-500/15 bg-violet-500/2.5 p-4"> | ||
| 393 | + <Suspense fallback={<DataTableSkeleton columns={7} rows={5} />}> | ||
| 394 | + <Show when={statement.error}> | ||
| 395 | + <ErrorAlert message={formatApiError(statement.error)} onRetry={() => void refetchStatement()} /> | ||
| 396 | + </Show> | ||
| 397 | + <Show | ||
| 398 | + when={entries().length > 0} | ||
| 399 | + fallback={ | ||
| 400 | + <div class="space-y-3"> | ||
| 401 | + <EmptyState title={t("payments.noDebt")} description={t("payments.noDebtHint")} /> | ||
| 402 | + <div class="flex justify-center"> | ||
| 403 | + <Button variant="outline" size="sm" class="rounded-lg" onClick={() => setTab("plans")}>{t("payments.tabPlans")}</Button> | ||
| 404 | + </div> | ||
| 405 | + </div> | ||
| 406 | + } | ||
| 407 | + > | ||
| 408 | + <DataTable columns={statementColumns()} data={sortedEntries()} tableClass="min-w-180" enablePagination pageSize={STATEMENT_PAGE_SIZE} /> | ||
| 409 | + </Show> | ||
| 410 | + </Suspense> | ||
| 411 | + </section> | ||
| 412 | + | ||
| 413 | + {/* advanced corrections, folded away */} | ||
| 414 | + <div> | ||
| 415 | + <Button variant="ghost" size="sm" onClick={() => setShowLedger(!showLedger())}>{showLedger() ? t("payments.hideLedger") : t("payments.showLedger")}</Button> | ||
| 416 | + <Show when={showLedger()}> | ||
| 417 | + <section class="data-shell mt-3 space-y-1 p-4"> | ||
| 418 | + <div class="mb-2"> | ||
| 419 | + <h2 class="font-semibold">{t("payments.ledgerAudit")}</h2> | ||
| 420 | + <p class="text-xs text-muted-foreground">{t("payments.appendOnly")}</p> | ||
| 421 | + </div> | ||
| 422 | + <div class="divide-y divide-border/60"> | ||
| 423 | + <For each={ledger()?.items ?? []}> | ||
| 424 | + {(line) => ( | ||
| 425 | + <div class="flex flex-wrap items-center justify-between gap-3 py-2.5 text-sm"> | ||
| 426 | + <div> | ||
| 427 | + <p class="font-medium">{kindLabel(line.kind)}</p> | ||
| 428 | + <p class="text-xs text-muted-foreground">{line.note || line.method || "—"} · {formatDateTime(line.created_at, locale())}</p> | ||
| 429 | + </div> | ||
| 430 | + <div class="flex items-center gap-3"> | ||
| 431 | + <span class="font-semibold tabular-nums">{line.kind === "charge" || line.kind === "refund" ? "−" : "+"}{formatTry(line.amount_minor, moneyLocale())}</span> | ||
| 432 | + <Show when={line.kind === "credit"}> | ||
| 433 | + <Button size="sm" variant="outline" onClick={() => openLineAction(line, "refund")}>{t("payments.recordRefund")}</Button> | ||
| 434 | + </Show> | ||
| 435 | + <Show when={line.kind === "charge" || line.kind === "refund"}> | ||
| 436 | + <Button size="sm" variant="ghost" class="text-destructive" onClick={() => openLineAction(line, "reverse")}>{t("payments.reverse")}</Button> | ||
| 437 | + </Show> | ||
| 438 | + </div> | ||
| 439 | + </div> | ||
| 440 | + )} | ||
| 441 | + </For> | ||
| 442 | + <Show when={(ledger()?.items.length ?? 0) === 0}> | ||
| 443 | + <p class="py-2 text-sm text-muted-foreground">{t("payments.noLedger")}</p> | ||
| 444 | + </Show> | ||
| 445 | + </div> | ||
| 446 | + </section> | ||
| 447 | + </Show> | ||
| 448 | + </div> | ||
| 449 | + </Show> | ||
| 450 | + </TabsContent> | ||
| 451 | + | ||
| 452 | + {/* ---------------- Fee plans ---------------- */} | ||
| 453 | + <TabsContent value="plans" class="space-y-4"> | ||
| 454 | + <div class="flex justify-end"> | ||
| 455 | + <Button type="button" size="sm" class="min-w-30 rounded-lg" onClick={openCreate}> | ||
| 456 | + <IconPlus class="h-4 w-4" /> | ||
| 457 | + {t("payments.createPlan")} | ||
| 458 | + </Button> | ||
| 459 | + </div> | ||
| 460 | + <section class="data-shell space-y-4 border-violet-500/15 bg-violet-500/2.5 p-4"> | ||
| 461 | + <Suspense fallback={<DataTableSkeleton columns={4} rows={6} />}> | ||
| 462 | + <Show when={plans.error}> | ||
| 463 | + <ErrorAlert message={formatApiError(plans.error)} onRetry={() => void refetchPlans()} /> | ||
| 464 | + </Show> | ||
| 465 | + <Show when={planList().length > 0} fallback={<EmptyState title={t("payments.empty")} />}> | ||
| 466 | + <DataTable columns={planColumns()} data={planList()} tableClass="min-w-160" filterColumn="name" enablePagination pageSize={PLAN_PAGE_SIZE} /> | ||
| 467 | + </Show> | ||
| 468 | + </Suspense> | ||
| 469 | + </section> | ||
| 470 | + </TabsContent> | ||
| 471 | + </Tabs> | ||
| 472 | + | ||
| 473 | + {/* ---------------- Collect payment panel ---------------- */} | ||
| 474 | + <SidePanel | ||
| 475 | + open={collectEntry() != null} | ||
| 476 | + onOpenChange={(open) => { if (!open) setCollectEntry(null); }} | ||
| 477 | + title={t("payments.collectFrom")} | ||
| 478 | + description={collectEntry() ? `${collectEntry()!.plan_name ?? "—"} · ${t("payments.outstanding")}: ${formatTry(collectEntry()!.outstanding_minor, moneyLocale())}` : ""} | ||
| 479 | + > | ||
| 480 | + <form class="space-y-4" onSubmit={submitCollect}> | ||
| 481 | + <Show when={error()}> | ||
| 482 | + <Alert variant="destructive">{error()}</Alert> | ||
| 483 | + </Show> | ||
| 484 | + <div class="space-y-1.5"> | ||
| 485 | + <Label for="collect-amount">{t("payments.amountTry")}</Label> | ||
| 486 | + <Input id="collect-amount" type="number" min={0.01} step={0.01} required value={collectAmount()} onInput={(e) => setCollectAmount(e.currentTarget.value)} /> | ||
| 487 | + </div> | ||
| 488 | + <div class="space-y-1.5"> | ||
| 489 | + <Label for="collect-method">{t("payments.method")}</Label> | ||
| 490 | + <Select id="collect-method" value={collectMethod()} onChange={(e) => setCollectMethod(e.currentTarget.value)}> | ||
| 491 | + <For each={PAYMENT_METHOD_KEYS}>{(key) => <option value={t(key)}>{t(key)}</option>}</For> | ||
| 492 | + </Select> | ||
| 493 | + </div> | ||
| 494 | + <div class="space-y-1.5"> | ||
| 495 | + <Label for="collect-note">{t("payments.note")}</Label> | ||
| 496 | + <Textarea id="collect-note" maxlength={500} value={collectNote()} onInput={(e) => setCollectNote(e.currentTarget.value)} /> | ||
| 497 | + </div> | ||
| 498 | + <div class="flex flex-wrap items-center gap-2"> | ||
| 499 | + <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={() => setCollectEntry(null)}>{t("common.cancel")}</Button> | ||
| 500 | + <Button type="submit" class="h-10 rounded-lg" disabled={pending()}>{t("payments.collect")}</Button> | ||
| 501 | + </div> | ||
| 502 | + </form> | ||
| 503 | + </SidePanel> | ||
| 504 | + | ||
| 505 | + {/* ---------------- Correction panel (refund / reverse) ---------------- */} | ||
| 506 | + <SidePanel | ||
| 507 | + open={lineAction() != null} | ||
| 508 | + onOpenChange={(open) => { if (!open) setLineAction(null); }} | ||
| 509 | + title={lineAction()?.kind === "refund" ? t("payments.recordRefund") : t("payments.reverse")} | ||
| 510 | + description={lineAction() ? `${kindLabel(lineAction()!.line.kind)} · ${formatTry(lineAction()!.line.amount_minor, moneyLocale())}` : ""} | ||
| 511 | + > | ||
| 512 | + <form class="space-y-4" onSubmit={submitLineAction}> | ||
| 513 | + <Show when={error()}> | ||
| 514 | + <Alert variant="destructive">{error()}</Alert> | ||
| 515 | + </Show> | ||
| 516 | + <Show when={lineAction()?.kind === "refund"}> | ||
| 517 | + <div class="space-y-1.5"> | ||
| 518 | + <Label for="correction-amount">{t("payments.amountTry")}</Label> | ||
| 519 | + <Input id="correction-amount" type="number" min={0.01} step={0.01} required value={actionAmount()} onInput={(e) => setActionAmount(e.currentTarget.value)} /> | ||
| 520 | + </div> | ||
| 521 | + </Show> | ||
| 522 | + <div class="space-y-1.5"> | ||
| 523 | + <Label for="correction-note">{lineAction()?.kind === "reverse" ? t("payments.reason") : t("payments.note")}</Label> | ||
| 524 | + <Textarea id="correction-note" maxlength={500} value={actionNote()} onInput={(e) => setActionNote(e.currentTarget.value)} /> | ||
| 525 | + </div> | ||
| 526 | + <div class="flex flex-wrap items-center gap-2"> | ||
| 527 | + <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={() => setLineAction(null)}>{t("common.cancel")}</Button> | ||
| 528 | + <Button type="submit" class="h-10 rounded-lg" disabled={pending()}>{t("common.save")}</Button> | ||
| 529 | + </div> | ||
| 530 | + </form> | ||
| 531 | + </SidePanel> | ||
| 532 | + | ||
| 533 | + {/* ---------------- Plan create / edit ---------------- */} | ||
| 534 | + <SidePanel open={panelOpen()} onOpenChange={(open) => { setPanelOpen(open); if (!open) resetPlanForm(); }} title={editing() ? t("payments.editPlan") : t("payments.createPlan")} description={t("payments.subtitle")}> | ||
| 535 | + <form class="space-y-4" onSubmit={savePlan}> | ||
| 536 | + <Show when={error()}> | ||
| 537 | + <Alert variant="destructive">{error()}</Alert> | ||
| 538 | + </Show> | ||
| 539 | + <div class="space-y-1.5"> | ||
| 540 | + <Label for="plan-name">{t("payments.planName")}</Label> | ||
| 541 | + <Input id="plan-name" class="rounded-lg" required maxlength={120} value={planName()} onInput={(e) => setPlanName(e.currentTarget.value)} /> | ||
| 542 | + </div> | ||
| 543 | + <div class="space-y-3"> | ||
| 544 | + <div class="flex items-center justify-between"> | ||
| 545 | + <Label>{t("payments.installments")}</Label> | ||
| 546 | + <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={addRow}> | ||
| 547 | + <IconPlus class="h-4 w-4" /> | ||
| 548 | + {t("payments.addInstallment")} | ||
| 549 | + </Button> | ||
| 550 | + </div> | ||
| 551 | + <Index each={rows()}> | ||
| 552 | + {(row, idx) => ( | ||
| 553 | + <div class="flex flex-wrap items-end gap-2"> | ||
| 554 | + <div class="min-w-32 flex-1 space-y-1.5"> | ||
| 555 | + <Label for={`inst-amount-${idx}`}>{t("payments.amountTry")}</Label> | ||
| 556 | + <Input id={`inst-amount-${idx}`} type="number" min={0.01} step={0.01} required value={row().amount} onInput={(e) => setRowAmount(idx, e.currentTarget.value)} /> | ||
| 557 | + </div> | ||
| 558 | + <div class="min-w-40 flex-1 space-y-1.5"> | ||
| 559 | + <Label for={`inst-due-${idx}`}>{t("payments.dueDate")}</Label> | ||
| 560 | + <DatePicker id={`inst-due-${idx}`} placeholder={t("form.datePlaceholder")} required value={row().due} onChange={(value) => setRowDue(idx, value)} /> | ||
| 561 | + </div> | ||
| 562 | + <Show when={rows().length > 1}> | ||
| 563 | + <Button type="button" variant="ghost" size="sm" class="text-destructive" onClick={() => removeRow(idx)}> | ||
| 564 | + <IconTrash class="h-4 w-4" /> | ||
| 565 | + </Button> | ||
| 566 | + </Show> | ||
| 567 | + </div> | ||
| 568 | + )} | ||
| 569 | + </Index> | ||
| 570 | + </div> | ||
| 571 | + <div class="flex flex-wrap items-center gap-2"> | ||
| 572 | + <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={() => setPanelOpen(false)}>{t("common.cancel")}</Button> | ||
| 573 | + <Button type="submit" class="h-10 rounded-lg" disabled={pending()}>{editing() ? t("common.update") : t("common.create")}</Button> | ||
| 574 | + </div> | ||
| 575 | + </form> | ||
| 576 | + </SidePanel> | ||
| 577 | + | ||
| 578 | + {/* ---------------- Assign ---------------- */} | ||
| 579 | + <SidePanel open={assignPlan() != null} onOpenChange={(open) => { if (!open) setAssignPlan(null); }} title={t("payments.assign")} description={assignPlan()?.name ?? ""}> | ||
| 580 | + <div class="space-y-4"> | ||
| 581 | + <Show when={error()}> | ||
| 582 | + <Alert variant="destructive">{error()}</Alert> | ||
| 583 | + </Show> | ||
| 584 | + <p class="text-sm text-muted-foreground">{t("payments.assignHelp")}</p> | ||
| 585 | + <div class="flex flex-col gap-2 sm:flex-row sm:items-end"> | ||
| 586 | + <div class="min-w-0 flex-1"> | ||
| 587 | + <UserSearchSelect id="assign-student" role="student" value={assignStudent()} onChange={setAssignStudent} label={t("payments.selectStudent")} placeholder={t("payments.selectStudent")} /> | ||
| 588 | + </div> | ||
| 589 | + <Button disabled={!assignStudent() || pending()} onClick={() => void submitAssign()}>{t("payments.assign")}</Button> | ||
| 590 | + </div> | ||
| 591 | + <div class="space-y-2"> | ||
| 592 | + <Label>{t("payments.assignments")}</Label> | ||
| 593 | + <div class="divide-y divide-border/60"> | ||
| 594 | + <For each={assignments()?.items ?? []}> | ||
| 595 | + {(row) => ( | ||
| 596 | + <div class="flex items-center justify-between gap-3 py-2 text-sm"> | ||
| 597 | + <span>{personLabel(row.student)}</span> | ||
| 598 | + <span class="text-xs text-muted-foreground">{formatDateTime(row.created_at, locale())}</span> | ||
| 599 | + </div> | ||
| 600 | + )} | ||
| 601 | + </For> | ||
| 602 | + <Show when={(assignments()?.items.length ?? 0) === 0}> | ||
| 603 | + <p class="py-2 text-sm text-muted-foreground">{t("payments.noAssignments")}</p> | ||
| 604 | + </Show> | ||
| 605 | + </div> | ||
| 606 | + </div> | ||
| 607 | + </div> | ||
| 608 | + </SidePanel> | ||
| 609 | + | ||
| 610 | + <ConfirmDialog | ||
| 611 | + open={deleteTarget() != null} | ||
| 612 | + onOpenChange={(open) => !open && setDeleteTarget(null)} | ||
| 613 | + title={t("payments.deletePlan")} | ||
| 614 | + variant="destructive" | ||
| 615 | + summary={deleteTarget()?.name ?? ""} | ||
| 616 | + onConfirm={async () => { | ||
| 617 | + const plan = deleteTarget(); | ||
| 618 | + if (!plan) return; | ||
| 619 | + try { | ||
| 620 | + await deletePaymentPlanById(plan.id); | ||
| 621 | + await refetchPlans(); | ||
| 622 | + setFlash(t("common.deleted")); | ||
| 623 | + } catch (err) { | ||
| 624 | + setError(formatApiError(err)); | ||
| 625 | + } finally { | ||
| 626 | + setDeleteTarget(null); | ||
| 627 | + } | ||
| 628 | + }} | ||
| 629 | + /> | ||
| 630 | + </div> | ||
| 631 | + ); | ||
| 632 | +} | ||
src/routes/router.tsxmodified+16 -0
| @@ -57,6 +57,8 @@ const CalendarPage = lazyRoute(() => import("@/pages/calendar-page")); | |||
| 57 | const AppointmentsPage = lazyRoute(() => import("@/pages/appointments-page")); | 57 | const AppointmentsPage = lazyRoute(() => import("@/pages/appointments-page")); |
| 58 | const MealsPage = lazyRoute(() => import("@/pages/meals-page")); | 58 | const MealsPage = lazyRoute(() => import("@/pages/meals-page")); |
| 59 | const MealDetailPage = lazyRoute(() => import("@/pages/meal-detail-page")); | 59 | const MealDetailPage = lazyRoute(() => import("@/pages/meal-detail-page")); |
| 60 | +const PaymentsPage = lazyRoute(() => import("@/pages/payments-page")); | ||
| 61 | +const PaymentStatementPage = lazyRoute(() => import("@/pages/payment-statement-page")); | ||
| 60 | 62 | ||
| 61 | function RootComponent() { | 63 | function RootComponent() { |
| 62 | return ( | 64 | return ( |
| @@ -323,6 +325,18 @@ const mealDetailRoute = createRoute({ | |||
| 323 | component: MealDetailPage, | 325 | component: MealDetailPage, |
| 324 | }); | 326 | }); |
| 325 | 327 | ||
| 328 | +const paymentsRoute = createRoute({ | ||
| 329 | + getParentRoute: () => rootRoute, | ||
| 330 | + path: "/management/payments", | ||
| 331 | + component: PaymentsPage, | ||
| 332 | +}); | ||
| 333 | + | ||
| 334 | +const paymentStatementRoute = createRoute({ | ||
| 335 | + getParentRoute: () => rootRoute, | ||
| 336 | + path: "/payments", | ||
| 337 | + component: PaymentStatementPage, | ||
| 338 | +}); | ||
| 339 | + | ||
| 326 | const routeTree = rootRoute.addChildren([ | 340 | const routeTree = rootRoute.addChildren([ |
| 327 | indexRoute, | 341 | indexRoute, |
| 328 | loginRoute, | 342 | loginRoute, |
| @@ -362,6 +376,8 @@ const routeTree = rootRoute.addChildren([ | |||
| 362 | appointmentsRoute, | 376 | appointmentsRoute, |
| 363 | mealsRoute, | 377 | mealsRoute, |
| 364 | mealDetailRoute, | 378 | mealDetailRoute, |
| 379 | + paymentsRoute, | ||
| 380 | + paymentStatementRoute, | ||
| 365 | ]); | 381 | ]); |
| 366 | 382 | ||
| 367 | function RouterPending() { | 383 | function RouterPending() { |