refactor(web): unify bills as UIBill, remove BillRecord

This commit is contained in:
clz
2026-01-18 21:14:54 +08:00
parent c61691249f
commit 65ea2fa477
13 changed files with 484 additions and 613 deletions

View File

@@ -0,0 +1,45 @@
import type { CleanedBill, UpdateBillRequest } from '$lib/api';
export interface UIBill {
id?: string;
time: string;
category: string;
merchant: string;
description?: string;
incomeExpense: string;
amount: number;
paymentMethod?: string;
status?: string;
remark?: string;
reviewLevel?: string;
}
export function cleanedBillToUIBill(bill: CleanedBill): UIBill {
return {
id: bill.id,
time: bill.time,
category: bill.category,
merchant: bill.merchant,
description: bill.description || '',
incomeExpense: bill.income_expense,
amount: bill.amount,
paymentMethod: bill.pay_method || '',
status: bill.status || '',
remark: bill.remark || '',
reviewLevel: bill.review_level || '',
};
}
export function uiBillToUpdateBillRequest(bill: UIBill): UpdateBillRequest {
return {
time: bill.time,
category: bill.category,
merchant: bill.merchant,
description: bill.description,
income_expense: bill.incomeExpense,
amount: bill.amount,
pay_method: bill.paymentMethod,
status: bill.status,
remark: bill.remark,
};
}