Added ability to select the language for automatic notification emails sent to tenants. Users can choose between Croatian (hr) and English (en). If not set, defaults to the current UI language. Changes: - Add tenantEmailLanguage field to BillingLocation type (shared-code) - Add language selector fieldset in LocationEditForm below email settings - Add Zod validation for tenantEmailLanguage in locationActions - Include field in all database insert and update operations - Default to current locale if not explicitly set - Add translation labels for language selector (EN/HR) This allows tenants to receive bills and notifications in their preferred language regardless of the landlord's UI language preference. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
146 lines
4.9 KiB
TypeScript
146 lines
4.9 KiB
TypeScript
import { unsubscribe } from "diagnostics_channel";
|
|
|
|
export interface FileAttachment {
|
|
fileName: string;
|
|
fileSize: number;
|
|
fileType: string;
|
|
fileLastModified: number;
|
|
fileContentsBase64: string;
|
|
uploadedAt: Date;
|
|
};
|
|
|
|
export interface YearMonth {
|
|
year: number;
|
|
month: number;
|
|
};
|
|
|
|
/** User settings data */
|
|
export interface UserSettings {
|
|
/** user's ID */
|
|
userId: string;
|
|
/** whether enableshow IBAN payment instructions in monthly statement */
|
|
enableIbanPayment?: boolean | null;
|
|
/** owner name */
|
|
ownerName?: string | null;
|
|
/** owner street */
|
|
ownerStreet?: string | null;
|
|
/** owner town */
|
|
ownerTown?: string | null;
|
|
/** owner IBAN */
|
|
ownerIBAN?: string | null;
|
|
/** currency (ISO 4217) */
|
|
currency?: string | null;
|
|
/** whether to enable Revolut payment instructions in monthly statement */
|
|
enableRevolutPayment?: boolean | null;
|
|
/** owner Revolut payment link */
|
|
ownerRevolutProfileName?: string | null;
|
|
};
|
|
|
|
export enum EmailStatus {
|
|
/** Email is not yet verified - recipient has not yet confirmed their email address */
|
|
Unverified = "unverified",
|
|
/** Email is not yet verified - a verification request has been sent */
|
|
VerificationPending = "verification-pending",
|
|
/** sending of verification email failed */
|
|
VerificationFailed = "verification-failed",
|
|
/** Email is verified and is in good standing: emails are being successfully delivered */
|
|
Verified = "verified",
|
|
/** Recepient has unsubscribed from receiving emails via link - no further emails will be sent */
|
|
Unsubscribed = "unsubscribed"
|
|
}
|
|
|
|
/** bill object in the form returned by MongoDB */
|
|
export interface BillingLocation {
|
|
_id: string;
|
|
/** user's ID */
|
|
userId: string;
|
|
/** user's email */
|
|
userEmail?: string | null;
|
|
/** name of the location */
|
|
name: string;
|
|
/** billing period year and month */
|
|
yearMonth: YearMonth;
|
|
/** array of bills */
|
|
bills: Bill[];
|
|
/** (optional) notes */
|
|
notes: string|null;
|
|
|
|
/** (optional) method for showing payment instructions to tenant */
|
|
tenantPaymentMethod?: "none" | "iban" | "revolut" | null;
|
|
|
|
/** (optional) type of proof of payment attachment */
|
|
proofOfPaymentType: "none" | "combined" | "per-bill";
|
|
|
|
/** (optional) tenant name */
|
|
tenantName?: string | null;
|
|
/** (optional) tenant street */
|
|
tenantStreet?: string | null;
|
|
/** (optional) tenant town */
|
|
tenantTown?: string | null;
|
|
/** (optional) tenant email */
|
|
tenantEmail?: string | null;
|
|
/** (optional) tenant email status */
|
|
tenantEmailStatus?: EmailStatus | null;
|
|
/** (optional) language for tenant notification emails */
|
|
tenantEmailLanguage?: "hr" | "en" | null;
|
|
/** (optional) whether to automatically notify tenant */
|
|
billFwdEnabled?: boolean | null;
|
|
/** (optional) bill forwarding strategy */
|
|
billFwdStrategy?: "when-payed" | "when-attached" | null;
|
|
/** (optional) bill forwarding status */
|
|
billFwdStatus?: "pending" | "sent" | "failed" | null;
|
|
/** (optional) whether to automatically send rent notification */
|
|
rentDueNotificationEnabled?: boolean | null;
|
|
/** (optional) day of month when rent is due (1-31) */
|
|
rentDueDay?: number | null;
|
|
/** (optional) when was the rent due notification sent */
|
|
rentDueNotificationStatus?: "sent" | "failed" | null;
|
|
/** (optional) monthly rent amount in cents */
|
|
rentAmount?: number | null;
|
|
/** (optional) whether the location has been seen by tenant */
|
|
seenByTenantAt?: Date | null;
|
|
/** (optional) utility bills proof of payment attachment */
|
|
utilBillsProofOfPayment?: FileAttachment|null;
|
|
/** (optional) rent proof of payment attachment */
|
|
rentProofOfPayment?: FileAttachment|null;
|
|
/** (optional) share link expiry timestamp */
|
|
shareTTL?: Date;
|
|
/** (optional) when tenant first visited the share link */
|
|
shareFirstVisitedAt?: Date | null;
|
|
};
|
|
|
|
export enum BilledTo {
|
|
Tenant = "tenant",
|
|
Landlord = "landlord"
|
|
}
|
|
|
|
/** Bill basic data */
|
|
export interface Bill {
|
|
_id: string;
|
|
/** bill name */
|
|
name: string;
|
|
/** is the bill paid */
|
|
paid: boolean;
|
|
/** who is billed for the bill */
|
|
billedTo?: BilledTo;
|
|
/** payed amount amount in cents */
|
|
payedAmount?: number | null;
|
|
/** attached document (optional) */
|
|
attachment?: FileAttachment|null;
|
|
/**
|
|
* true if there an attachment
|
|
* @description this field enables us to send this info to the client without sending large attachment - it's an optimization
|
|
*/
|
|
hasAttachment?: boolean;
|
|
/** (optional) notes */
|
|
notes?: string|null;
|
|
/**
|
|
* (optional) image data containing PDF471 bar code
|
|
* @deprecated LEGACY FIELD - use hub3aText instead
|
|
* */
|
|
barcodeImage?:string;
|
|
/** (optional) HUB-3A text for generating PDF417 bar code */
|
|
hub3aText?:string;
|
|
/** (optional) proof of payment attachment */
|
|
proofOfPayment?: FileAttachment|null;
|
|
}; |