diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index 2c3dbb6..38f8c41 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -620,6 +620,7 @@ export type Database = { } billing_settings: { Row: { + auto_assess_penalties: boolean default_due_days: number early_dropoff_fee_cents: number id: boolean @@ -629,6 +630,7 @@ export type Database = { updated_at: string } Insert: { + auto_assess_penalties?: boolean default_due_days?: number early_dropoff_fee_cents?: number id?: boolean @@ -638,6 +640,7 @@ export type Database = { updated_at?: string } Update: { + auto_assess_penalties?: boolean default_due_days?: number early_dropoff_fee_cents?: number id?: boolean @@ -2398,56 +2401,156 @@ export type Database = { }, ] } + payment_allocations: { + Row: { + allocated_at: string + allocated_by: string | null + amount_cents: number + id: string + invoice_id: string + payment_id: string + } + Insert: { + allocated_at?: string + allocated_by?: string | null + amount_cents: number + id?: string + invoice_id: string + payment_id: string + } + Update: { + allocated_at?: string + allocated_by?: string | null + amount_cents?: number + id?: string + invoice_id?: string + payment_id?: string + } + Relationships: [ + { + foreignKeyName: "payment_allocations_invoice_id_fkey" + columns: ["invoice_id"] + isOneToOne: false + referencedRelation: "invoices" + referencedColumns: ["id"] + }, + { + foreignKeyName: "payment_allocations_invoice_id_fkey" + columns: ["invoice_id"] + isOneToOne: false + referencedRelation: "v_outstanding_invoices" + referencedColumns: ["invoice_id"] + }, + { + foreignKeyName: "payment_allocations_payment_id_fkey" + columns: ["payment_id"] + isOneToOne: false + referencedRelation: "payments" + referencedColumns: ["id"] + }, + ] + } payment_plans: { Row: { + autopay_authorized: boolean + campus_id: string | null created_at: string created_by: string | null day_of_period: number | null + down_payment_cents: number end_date: string | null frequency: string + grace_period_days: number household_id: string | null id: string installment_amount_cents: number + installment_count: number | null + late_fee_cents: number + missed_payment_action: string | null name: string notes: string | null + payment_method: string | null + scholarship_contribution_cents: number start_date: string status: string student_id: string | null + total_obligation_cents: number | null updated_at: string } Insert: { + autopay_authorized?: boolean + campus_id?: string | null created_at?: string created_by?: string | null day_of_period?: number | null + down_payment_cents?: number end_date?: string | null frequency?: string + grace_period_days?: number household_id?: string | null id?: string installment_amount_cents: number + installment_count?: number | null + late_fee_cents?: number + missed_payment_action?: string | null name: string notes?: string | null + payment_method?: string | null + scholarship_contribution_cents?: number start_date?: string status?: string student_id?: string | null + total_obligation_cents?: number | null updated_at?: string } Update: { + autopay_authorized?: boolean + campus_id?: string | null created_at?: string created_by?: string | null day_of_period?: number | null + down_payment_cents?: number end_date?: string | null frequency?: string + grace_period_days?: number household_id?: string | null id?: string installment_amount_cents?: number + installment_count?: number | null + late_fee_cents?: number + missed_payment_action?: string | null name?: string notes?: string | null + payment_method?: string | null + scholarship_contribution_cents?: number start_date?: string status?: string student_id?: string | null + total_obligation_cents?: number | null updated_at?: string } Relationships: [ + { + foreignKeyName: "payment_plans_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "campuses" + referencedColumns: ["id"] + }, + { + foreignKeyName: "payment_plans_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "v_campus_enrollment" + referencedColumns: ["campus_id"] + }, + { + foreignKeyName: "payment_plans_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "v_student_directory" + referencedColumns: ["primary_campus_id"] + }, { foreignKeyName: "payment_plans_household_id_fkey" columns: ["household_id"] @@ -2478,6 +2581,390 @@ export type Database = { }, ] } + payments: { + Row: { + amount_cents: number + campus_id: string | null + created_at: string + document_path: string | null + effective_date: string + household_id: string | null + id: string + kind: string + method: string + notes: string | null + payer_name: string | null + received_at: string + received_by: string | null + reference_number: string | null + reverses_payment_id: string | null + scholarship_id: string | null + status: string + student_id: string | null + third_party_name: string | null + updated_at: string + void_reason: string | null + } + Insert: { + amount_cents: number + campus_id?: string | null + created_at?: string + document_path?: string | null + effective_date?: string + household_id?: string | null + id?: string + kind?: string + method: string + notes?: string | null + payer_name?: string | null + received_at?: string + received_by?: string | null + reference_number?: string | null + reverses_payment_id?: string | null + scholarship_id?: string | null + status?: string + student_id?: string | null + third_party_name?: string | null + updated_at?: string + void_reason?: string | null + } + Update: { + amount_cents?: number + campus_id?: string | null + created_at?: string + document_path?: string | null + effective_date?: string + household_id?: string | null + id?: string + kind?: string + method?: string + notes?: string | null + payer_name?: string | null + received_at?: string + received_by?: string | null + reference_number?: string | null + reverses_payment_id?: string | null + scholarship_id?: string | null + status?: string + student_id?: string | null + third_party_name?: string | null + updated_at?: string + void_reason?: string | null + } + Relationships: [ + { + foreignKeyName: "payments_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "campuses" + referencedColumns: ["id"] + }, + { + foreignKeyName: "payments_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "v_campus_enrollment" + referencedColumns: ["campus_id"] + }, + { + foreignKeyName: "payments_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "v_student_directory" + referencedColumns: ["primary_campus_id"] + }, + { + foreignKeyName: "payments_household_id_fkey" + columns: ["household_id"] + isOneToOne: false + referencedRelation: "households" + referencedColumns: ["id"] + }, + { + foreignKeyName: "payments_household_id_fkey" + columns: ["household_id"] + isOneToOne: false + referencedRelation: "v_household_balances" + referencedColumns: ["household_id"] + }, + { + foreignKeyName: "payments_reverses_payment_id_fkey" + columns: ["reverses_payment_id"] + isOneToOne: false + referencedRelation: "payments" + referencedColumns: ["id"] + }, + { + foreignKeyName: "payments_scholarship_id_fkey" + columns: ["scholarship_id"] + isOneToOne: false + referencedRelation: "scholarships" + referencedColumns: ["id"] + }, + { + foreignKeyName: "payments_student_id_fkey" + columns: ["student_id"] + isOneToOne: false + referencedRelation: "students" + referencedColumns: ["id"] + }, + { + foreignKeyName: "payments_student_id_fkey" + columns: ["student_id"] + isOneToOne: false + referencedRelation: "v_student_directory" + referencedColumns: ["student_id"] + }, + ] + } + penalty_events: { + Row: { + approved_at: string | null + approved_by: string | null + attendance_id: string | null + campus_id: string | null + computed_fee_cents: number + created_at: string + event_type: string + final_fee_cents: number + id: string + invoice_id: string | null + is_waived: boolean + minutes_over: number + notes: string | null + notification_method: string | null + occurred_on: string + override_reason: string | null + parent_notified_at: string | null + recorded_by: string | null + rule_id: string | null + student_id: string + updated_at: string + waived_at: string | null + waived_by: string | null + waiver_reason: string | null + } + Insert: { + approved_at?: string | null + approved_by?: string | null + attendance_id?: string | null + campus_id?: string | null + computed_fee_cents?: number + created_at?: string + event_type: string + final_fee_cents?: number + id?: string + invoice_id?: string | null + is_waived?: boolean + minutes_over?: number + notes?: string | null + notification_method?: string | null + occurred_on?: string + override_reason?: string | null + parent_notified_at?: string | null + recorded_by?: string | null + rule_id?: string | null + student_id: string + updated_at?: string + waived_at?: string | null + waived_by?: string | null + waiver_reason?: string | null + } + Update: { + approved_at?: string | null + approved_by?: string | null + attendance_id?: string | null + campus_id?: string | null + computed_fee_cents?: number + created_at?: string + event_type?: string + final_fee_cents?: number + id?: string + invoice_id?: string | null + is_waived?: boolean + minutes_over?: number + notes?: string | null + notification_method?: string | null + occurred_on?: string + override_reason?: string | null + parent_notified_at?: string | null + recorded_by?: string | null + rule_id?: string | null + student_id?: string + updated_at?: string + waived_at?: string | null + waived_by?: string | null + waiver_reason?: string | null + } + Relationships: [ + { + foreignKeyName: "penalty_events_attendance_id_fkey" + columns: ["attendance_id"] + isOneToOne: false + referencedRelation: "attendance" + referencedColumns: ["id"] + }, + { + foreignKeyName: "penalty_events_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "campuses" + referencedColumns: ["id"] + }, + { + foreignKeyName: "penalty_events_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "v_campus_enrollment" + referencedColumns: ["campus_id"] + }, + { + foreignKeyName: "penalty_events_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "v_student_directory" + referencedColumns: ["primary_campus_id"] + }, + { + foreignKeyName: "penalty_events_invoice_id_fkey" + columns: ["invoice_id"] + isOneToOne: false + referencedRelation: "invoices" + referencedColumns: ["id"] + }, + { + foreignKeyName: "penalty_events_invoice_id_fkey" + columns: ["invoice_id"] + isOneToOne: false + referencedRelation: "v_outstanding_invoices" + referencedColumns: ["invoice_id"] + }, + { + foreignKeyName: "penalty_events_rule_id_fkey" + columns: ["rule_id"] + isOneToOne: false + referencedRelation: "penalty_rules" + referencedColumns: ["id"] + }, + { + foreignKeyName: "penalty_events_student_id_fkey" + columns: ["student_id"] + isOneToOne: false + referencedRelation: "students" + referencedColumns: ["id"] + }, + { + foreignKeyName: "penalty_events_student_id_fkey" + columns: ["student_id"] + isOneToOne: false + referencedRelation: "v_student_directory" + referencedColumns: ["student_id"] + }, + ] + } + penalty_rules: { + Row: { + allowed_time: string | null + amount_cents: number + campus_id: string | null + created_at: string + created_by: string | null + effective_end: string | null + effective_start: string + escalated_amount_cents: number | null + grace_period_minutes: number + id: string + increment_minutes: number | null + is_active: boolean + max_fee_cents: number | null + method: string + name: string + notes: string | null + notify_parent: boolean + priority: number + requires_approval: boolean + rule_type: string + threshold_count: number | null + threshold_window_days: number | null + updated_at: string + waiver_roles: Database["public"]["Enums"]["app_role"][] + } + Insert: { + allowed_time?: string | null + amount_cents?: number + campus_id?: string | null + created_at?: string + created_by?: string | null + effective_end?: string | null + effective_start?: string + escalated_amount_cents?: number | null + grace_period_minutes?: number + id?: string + increment_minutes?: number | null + is_active?: boolean + max_fee_cents?: number | null + method?: string + name: string + notes?: string | null + notify_parent?: boolean + priority?: number + requires_approval?: boolean + rule_type: string + threshold_count?: number | null + threshold_window_days?: number | null + updated_at?: string + waiver_roles?: Database["public"]["Enums"]["app_role"][] + } + Update: { + allowed_time?: string | null + amount_cents?: number + campus_id?: string | null + created_at?: string + created_by?: string | null + effective_end?: string | null + effective_start?: string + escalated_amount_cents?: number | null + grace_period_minutes?: number + id?: string + increment_minutes?: number | null + is_active?: boolean + max_fee_cents?: number | null + method?: string + name?: string + notes?: string | null + notify_parent?: boolean + priority?: number + requires_approval?: boolean + rule_type?: string + threshold_count?: number | null + threshold_window_days?: number | null + updated_at?: string + waiver_roles?: Database["public"]["Enums"]["app_role"][] + } + Relationships: [ + { + foreignKeyName: "penalty_rules_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "campuses" + referencedColumns: ["id"] + }, + { + foreignKeyName: "penalty_rules_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "v_campus_enrollment" + referencedColumns: ["campus_id"] + }, + { + foreignKeyName: "penalty_rules_campus_id_fkey" + columns: ["campus_id"] + isOneToOne: false + referencedRelation: "v_student_directory" + referencedColumns: ["primary_campus_id"] + }, + ] + } plan_accommodations: { Row: { category: string @@ -5401,6 +5888,25 @@ export type Database = { }, ] } + v_student_ledger: { + Row: { + amount_cents: number | null + campus_id: string | null + direction: string | null + effective_date: string | null + entered_by: string | null + method: string | null + ref_id: string | null + reference: string | null + running_balance_cents: number | null + sort_ts: string | null + source: string | null + student_id: string | null + student_name: string | null + txn_date: string | null + } + Relationships: [] + } } Functions: { active_student_alerts: { @@ -5430,6 +5936,14 @@ export type Database = { isSetofReturn: true } } + allocate_payment_oldest_first: { + Args: { _payment: string } + Returns: number + } + assess_attendance_penalties: { + Args: { _attendance: string } + Returns: number + } campus_ratio: { Args: { _campus: string; _date: string } Returns: { @@ -5483,6 +5997,23 @@ export type Database = { can_view_meeting: { Args: { _meeting: string }; Returns: boolean } can_view_plan_full: { Args: { _plan: string }; Returns: boolean } can_view_plan_impl: { Args: { _plan: string }; Returns: boolean } + compute_all_invoice_lines: { + Args: { _from: string; _student: string; _to: string } + Returns: { + adjustment_rule_id: string + amount_cents: number + campus_id: string + credit_id: string + description: string + detail: Json + line_kind: string + quantity: number + scholarship_id: string + sort_order: number + tuition_rate_id: string + unit_amount_cents: number + }[] + } compute_invoice_lines: { Args: { _from: string; _student: string; _to: string } Returns: { @@ -5500,6 +6031,31 @@ export type Database = { unit_amount_cents: number }[] } + compute_penalty_fee: { + Args: { + _escalated?: boolean + _minutes_over: number + _rule: Database["public"]["Tables"]["penalty_rules"]["Row"] + } + Returns: number + } + compute_penalty_lines: { + Args: { _from: string; _student: string; _to: string } + Returns: { + adjustment_rule_id: string + amount_cents: number + campus_id: string + credit_id: string + description: string + detail: Json + line_kind: string + quantity: number + scholarship_id: string + sort_order: number + tuition_rate_id: string + unit_amount_cents: number + }[] + } create_invoice: { Args: { _batch?: string @@ -5524,6 +6080,7 @@ export type Database = { student_id: string }[] } + family_responsibility_cents: { Args: { _plan: string }; Returns: number } generate_invoice_batch: { Args: { _batch: string }; Returns: number } has_campus_access: { Args: { _campus: string }; Returns: boolean } has_role: { @@ -5551,7 +6108,12 @@ export type Database = { is_student_account: { Args: { _student: string }; Returns: boolean } is_super_admin: { Args: never; Returns: boolean } is_thread_participant: { Args: { _thread: string }; Returns: boolean } + mark_penalties_invoiced: { + Args: { _from: string; _invoice: string; _student: string; _to: string } + Returns: number + } next_invoice_number: { Args: never; Returns: string } + payment_unallocated_cents: { Args: { _payment: string }; Returns: number } preview_invoice_batch: { Args: { _batch: string } Returns: { @@ -5567,6 +6129,46 @@ export type Database = { Args: { _student: string; _year: number } Returns: undefined } + refresh_invoice_paid: { Args: { _invoice: string }; Returns: undefined } + refund_payment: { + Args: { _amount_cents: number; _payment: string; _reason: string } + Returns: string + } + resolve_penalty_rule: { + Args: { _campus: string; _on: string; _type: string } + Returns: { + allowed_time: string | null + amount_cents: number + campus_id: string | null + created_at: string + created_by: string | null + effective_end: string | null + effective_start: string + escalated_amount_cents: number | null + grace_period_minutes: number + id: string + increment_minutes: number | null + is_active: boolean + max_fee_cents: number | null + method: string + name: string + notes: string | null + notify_parent: boolean + priority: number + requires_approval: boolean + rule_type: string + threshold_count: number | null + threshold_window_days: number | null + updated_at: string + waiver_roles: Database["public"]["Enums"]["app_role"][] + } + SetofOptions: { + from: "*" + to: "penalty_rules" + isOneToOne: true + isSetofReturn: false + } + } resolve_ratio_rule: { Args: { _age_months?: number @@ -5685,6 +6287,10 @@ export type Database = { isSetofReturn: false } } + reverse_payment: { + Args: { _payment: string; _reason: string } + Returns: string + } staff_compliance_gaps: { Args: { _user: string } Returns: {