Introduces a new module to manage and track extraordinary expenses within condominiums. This includes defining expense items, sharing arrangements, and attaching relevant documents. The module adds new types for `ExpenseItem`, `ExpenseShare`, and `ExtraordinaryExpense`. Mock database functions are updated to support fetching, creating, and managing these expenses. UI components in `Layout.tsx` and `Settings.tsx` are modified to include navigation and feature toggling for extraordinary expenses. Additionally, new routes are added in `App.tsx` for both administrative and user-facing views of these expenses.
216 lines
4.6 KiB
TypeScript
216 lines
4.6 KiB
TypeScript
|
|
export interface Condo {
|
|
id: string;
|
|
name: string;
|
|
address?: string;
|
|
streetNumber?: string; // Civico
|
|
city?: string; // Città
|
|
province?: string; // Provincia
|
|
zipCode?: string; // CAP
|
|
notes?: string; // Note
|
|
iban?: string;
|
|
paypalClientId?: string; // PayPal Client ID for receiving payments
|
|
defaultMonthlyQuota: number;
|
|
image?: string; // Optional placeholder for logo
|
|
}
|
|
|
|
export interface Family {
|
|
id: string;
|
|
condoId: string; // Link to specific condo
|
|
name: string;
|
|
unitNumber: string; // Internal apartment number (Interno)
|
|
stair?: string; // Scala
|
|
floor?: string; // Piano
|
|
notes?: string; // Note
|
|
contactEmail?: string;
|
|
balance: number; // Calculated balance (positive = credit, negative = debt)
|
|
customMonthlyQuota?: number; // Optional override for default quota
|
|
}
|
|
|
|
export interface Payment {
|
|
id: string;
|
|
familyId: string;
|
|
amount: number;
|
|
datePaid: string; // ISO Date string
|
|
forMonth: number; // 1-12
|
|
forYear: number;
|
|
notes?: string;
|
|
}
|
|
|
|
export interface SmtpConfig {
|
|
host: string;
|
|
port: number;
|
|
user: string;
|
|
pass: string;
|
|
secure: boolean;
|
|
fromEmail: string;
|
|
}
|
|
|
|
export interface AppFeatures {
|
|
multiCondo: boolean;
|
|
tickets: boolean;
|
|
payPal: boolean;
|
|
notices: boolean;
|
|
reports: boolean;
|
|
extraordinaryExpenses: boolean;
|
|
}
|
|
|
|
export interface AlertDefinition {
|
|
id: string;
|
|
subject: string;
|
|
body: string;
|
|
daysOffset: number; // Number of days
|
|
offsetType: 'before_next_month' | 'after_current_month';
|
|
sendHour: number; // 0-23
|
|
active: boolean;
|
|
lastSent?: string; // ISO Date of last execution
|
|
}
|
|
|
|
export type NoticeIconType = 'info' | 'warning' | 'maintenance' | 'event';
|
|
|
|
export interface Notice {
|
|
id: string;
|
|
condoId: string;
|
|
title: string;
|
|
content: string;
|
|
type: NoticeIconType;
|
|
link?: string;
|
|
date: string; // ISO Date
|
|
active: boolean;
|
|
targetFamilyIds?: string[]; // Array of family IDs. If empty/null, it means "ALL"
|
|
}
|
|
|
|
export interface NoticeRead {
|
|
userId: string;
|
|
noticeId: string;
|
|
readAt: string;
|
|
}
|
|
|
|
export interface AppSettings {
|
|
// Global settings only
|
|
currentYear: number; // The active fiscal year (could be per-condo, but global for simplicity now)
|
|
smtpConfig?: SmtpConfig;
|
|
features: AppFeatures;
|
|
}
|
|
|
|
export enum PaymentStatus {
|
|
PAID = 'PAID',
|
|
UNPAID = 'UNPAID', // Past due
|
|
UPCOMING = 'UPCOMING', // Future
|
|
PENDING = 'PENDING'
|
|
}
|
|
|
|
export interface MonthStatus {
|
|
monthIndex: number; // 0-11
|
|
status: PaymentStatus;
|
|
payment?: Payment;
|
|
}
|
|
|
|
export interface User {
|
|
id: string;
|
|
email: string;
|
|
name?: string;
|
|
role?: 'admin' | 'poweruser' | 'user';
|
|
phone?: string;
|
|
familyId?: string | null;
|
|
receiveAlerts?: boolean;
|
|
}
|
|
|
|
export interface AuthResponse {
|
|
token: string;
|
|
user: User;
|
|
}
|
|
|
|
// --- TICKETS ---
|
|
|
|
export enum TicketStatus {
|
|
OPEN = 'OPEN',
|
|
IN_PROGRESS = 'IN_PROGRESS',
|
|
SUSPENDED = 'SUSPENDED', // New State
|
|
RESOLVED = 'RESOLVED',
|
|
CLOSED = 'CLOSED' // Closed without resolution (Archived/WontFix)
|
|
}
|
|
|
|
export enum TicketPriority {
|
|
LOW = 'LOW',
|
|
MEDIUM = 'MEDIUM',
|
|
HIGH = 'HIGH',
|
|
URGENT = 'URGENT'
|
|
}
|
|
|
|
export enum TicketCategory {
|
|
MAINTENANCE = 'MAINTENANCE', // Manutenzione
|
|
ADMINISTRATIVE = 'ADMINISTRATIVE', // Amministrativa
|
|
NOISE = 'NOISE', // Disturbo/Rumori
|
|
CLEANING = 'CLEANING', // Pulizie
|
|
OTHER = 'OTHER' // Altro
|
|
}
|
|
|
|
export interface TicketAttachment {
|
|
id: string;
|
|
ticketId: string;
|
|
fileName: string;
|
|
fileType: string; // MIME type
|
|
data: string; // Base64 Data URI
|
|
}
|
|
|
|
export interface TicketComment {
|
|
id: string;
|
|
ticketId: string;
|
|
userId: string;
|
|
userName: string;
|
|
text: string;
|
|
createdAt: string;
|
|
isAdminResponse: boolean;
|
|
}
|
|
|
|
export interface Ticket {
|
|
id: string;
|
|
condoId: string;
|
|
userId: string;
|
|
title: string;
|
|
description: string;
|
|
status: TicketStatus;
|
|
priority: TicketPriority;
|
|
category: TicketCategory;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
attachments?: TicketAttachment[];
|
|
comments?: TicketComment[];
|
|
userName?: string; // Joined field
|
|
userEmail?: string; // Joined field
|
|
}
|
|
|
|
// --- EXTRAORDINARY EXPENSES ---
|
|
|
|
export interface ExpenseItem {
|
|
id?: string;
|
|
description: string;
|
|
amount: number;
|
|
}
|
|
|
|
export interface ExpenseShare {
|
|
id?: string;
|
|
familyId: string;
|
|
percentage: number;
|
|
amountDue: number;
|
|
amountPaid: number;
|
|
status: 'PAID' | 'PARTIAL' | 'UNPAID';
|
|
familyName?: string; // Joined
|
|
}
|
|
|
|
export interface ExtraordinaryExpense {
|
|
id: string;
|
|
condoId: string;
|
|
title: string;
|
|
description: string;
|
|
startDate: string;
|
|
endDate?: string;
|
|
contractorName: string;
|
|
totalAmount: number;
|
|
items: ExpenseItem[];
|
|
shares?: ExpenseShare[]; // For detail view
|
|
attachments?: { id: string, fileName: string, fileType: string, data: string }[];
|
|
createdAt: string;
|
|
}
|