feat: harden portal security and auditability
This commit is contained in:
1 parent
7f1ecd9322
commit
21871bb9ff
26 files changed
+2664
-4
No files matched your search
@@ -15,6 +15,7 @@ import {
|
||||
usages,
|
||||
} from "@/db/schema";
|
||||
import type * as schema from "@/db/schema";
|
||||
import { writeAudit } from "@/modules/audit/write";
|
||||
import { renderBillingPdf } from "@/modules/pdf/render";
|
||||
import type { BillingReportSnapshot } from "@/modules/billing/types";
|
||||
|
||||
@@ -304,6 +305,25 @@ export function createReportService({
|
||||
legalSeparationNotice: LEGAL_SEPARATION_NOTICE,
|
||||
});
|
||||
|
||||
try {
|
||||
await writeAudit({
|
||||
type: "billing_report_finalized",
|
||||
actorUserId: input.adminUserId,
|
||||
actorType: "admin",
|
||||
entityType: "billing_report",
|
||||
entityId: result.reportId,
|
||||
metadata: {
|
||||
editorialId: input.editorialId,
|
||||
reportNumber: result.reportNumber,
|
||||
invoiceNumber: result.invoiceNumber,
|
||||
netTotalCents,
|
||||
usageCount: selectedUsages.length,
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
// Audit is observability, not a transaction participant.
|
||||
}
|
||||
|
||||
return {
|
||||
reportId: result.reportId,
|
||||
reportNumber: String(result.reportNumber),
|
||||
@@ -335,6 +355,19 @@ export function createReportService({
|
||||
input.adminUserId,
|
||||
report.usageIds,
|
||||
);
|
||||
|
||||
try {
|
||||
await writeAudit({
|
||||
type: "billing_report_cancelled",
|
||||
actorUserId: input.adminUserId,
|
||||
actorType: "admin",
|
||||
entityType: "billing_report",
|
||||
entityId: input.reportId,
|
||||
metadata: { reason, usageCount: report.usageIds.length },
|
||||
});
|
||||
} catch {
|
||||
// Audit is observability, not a transaction participant.
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user