All checks were successful
		
		
	
	Playwright Tests / test (pull_request) Has been skipped
				
			Check usage of free licenses / build-static-assets (pull_request) Successful in 1m12s
				
			Add copyright notice / copyright_notice (pull_request) Successful in 1m32s
				
			Build Nginx-based docker image / build-static-assets (push) Successful in 6m2s
				
			
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| /* 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<Expense>{
 | |
|   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';
 | |
|   }
 | |
| } |