chore: migrate to KT financial system

This commit is contained in:
woshiqp465
2025-11-04 16:06:44 +08:00
parent 2c0505b73d
commit f4cd0a5f22
289 changed files with 7362 additions and 41458 deletions

View File

@@ -2,9 +2,18 @@ import { getRouterParam, readBody } from 'h3';
import {
restoreTransaction,
updateTransaction,
type TransactionStatus,
} from '~/utils/finance-repository';
import { useResponseError, useResponseSuccess } from '~/utils/response';
const ALLOWED_STATUSES: TransactionStatus[] = [
'draft',
'pending',
'approved',
'rejected',
'paid',
];
export default defineEventHandler(async (event) => {
const id = Number(getRouterParam(event, 'id'));
if (Number.isNaN(id)) {
@@ -41,6 +50,31 @@ export default defineEventHandler(async (event) => {
if (body?.project !== undefined) payload.project = body.project ?? null;
if (body?.memo !== undefined) payload.memo = body.memo ?? null;
if (body?.isDeleted !== undefined) payload.isDeleted = body.isDeleted;
if (body?.status !== undefined) {
const status = body.status as TransactionStatus;
if (!ALLOWED_STATUSES.includes(status)) {
return useResponseError('状态值不合法', -1);
}
payload.status = status;
}
if (body?.statusUpdatedAt !== undefined) {
payload.statusUpdatedAt = body.statusUpdatedAt;
}
if (body?.reimbursementBatch !== undefined) {
payload.reimbursementBatch = body.reimbursementBatch ?? null;
}
if (body?.reviewNotes !== undefined) {
payload.reviewNotes = body.reviewNotes ?? null;
}
if (body?.submittedBy !== undefined) {
payload.submittedBy = body.submittedBy ?? null;
}
if (body?.approvedBy !== undefined) {
payload.approvedBy = body.approvedBy ?? null;
}
if (body?.approvedAt !== undefined) {
payload.approvedAt = body.approvedAt ?? null;
}
const updated = updateTransaction(id, payload);
if (!updated) {