/* Copyright (C) 2024-2025 LibreWeddingPlanner contributors*/ import { Serializable } from "../api/abstract-api"; import { Entity } from "./definitions"; export const pricingTypes = ['fixed', 'per_person'] as const; export type PricingType = typeof pricingTypes[number]; export class Expense implements Entity { id?: string; name?: string; amount?: number; pricingType?: PricingType; constructor(id?: string, name?: string, amount?: number, pricingType?: PricingType) { this.id = id; this.name = name || ''; this.amount = amount || 0; this.pricingType = pricingType || 'fixed'; } } export class ExpenseSerializer implements Serializable{ fromJson(data: any): Expense { return new Expense(data.id, data.name, data.amount, data.pricing_type); } toJson(expense: Expense): string { return JSON.stringify({ expense: { name: expense.name, amount: expense.amount, pricing_type: expense.pricingType } }); } apiPath(): string { return 'expenses'; } }