mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 09:07:46 +02:00
test: preserve exact report totals in Costs Storybook fixtures
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
6e90f5d107
commit
5280ad2615
2 files changed
+3
-3
No files matched your search
@@ -28,6 +28,6 @@ describe("Costs story finance actions", () => {
|
||||
const provider = { provider: "openai", accountId: "preview-account", scopeIds: ["preview-project"], secretId: secrets[0].id, from: "2026-01-01", to: "2026-01-02" };
|
||||
await fixture("accounting/provider-costs/import", request("accounting/provider-costs/import", provider));
|
||||
const summary = await (await fixture("costs/finance-summary", request("costs/finance-summary")))!.json();
|
||||
expect(summary).toMatchObject({ debitCents: 50, providerReportedCents: 250, eventCount: 2 });
|
||||
expect(summary).toMatchObject({ debitCents: 50, debitCentsExact: "50.0000000", providerReportedCents: 250, providerReportedCentsExact: "250.0000000", eventCount: 2 });
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createFinanceEventSchema, importBillingInvoiceSchema, importProviderCostsSchema, type BillingReconciliation, type FinanceEvent } from "@paperclipai/shared";
|
||||
import { normalizeCents, createFinanceEventSchema, importBillingInvoiceSchema, importProviderCostsSchema, type BillingReconciliation, type FinanceEvent } from "@paperclipai/shared";
|
||||
|
||||
/** In-memory, per-mount data. Preview actions never contact billing providers. */
|
||||
export function createCostsFinanceFixtures(companyId: string) {
|
||||
@@ -13,7 +13,7 @@ export function createCostsFinanceFixtures(companyId: string) {
|
||||
const rows = matching.filter(row => row.metadataJson?.source !== "provider_cost_report");
|
||||
const debitCents = rows.filter(row => row.direction === "debit").reduce((sum, row) => sum + row.amountCents, 0);
|
||||
const creditCents = rows.filter(row => row.direction === "credit").reduce((sum, row) => sum + row.amountCents, 0);
|
||||
return { currency, providerReportedCents, debitCents, creditCents, netCents: debitCents - creditCents, estimatedDebitCents: 0, eventCount: matching.length };
|
||||
return { currency, providerReportedCents, providerReportedCentsExact: normalizeCents(providerReportedCents), debitCents, debitCentsExact: normalizeCents(debitCents), creditCents, creditCentsExact: normalizeCents(creditCents), netCents: debitCents - creditCents, netCentsExact: normalizeCents(debitCents - creditCents), estimatedDebitCents: 0, estimatedDebitCentsExact: "0.0000000", eventCount: matching.length };
|
||||
};
|
||||
function record(raw: unknown) {
|
||||
const input = createFinanceEventSchema.parse(raw);
|
||||
|
||||
Reference in new issue
Block a user