Files
2026-11-14 09:56:45 +00:00

31 lines
1.6 KiB
TypeScript

// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
import type { TransportCaller } from "@conusai-kit/core"
import type { IsolationFixture, IsolationTenant } from "@conusai-kit/testing"
import { businessModulesOn } from "../../index.js"
import { id, invoiceId, seriesId, terms } from "./fixture.js"
const org = (t: IsolationTenant) => ({ org: t.orgSlug })
const get = (t: IsolationTenant) => ({ ...org(t), invoiceId })
const action = (t: IsolationTenant) => ({ ...get(t), expectedVersion: "1", requestId: id, confirmed: true })
export const invoicingIsolationFixtures: Record<string, IsolationFixture> = {
"invoicing.invoice.list": { input: org },
"invoicing.series.list": { input: org },
"invoicing.invoice.get": { input: get },
"invoicing.invoice.ubl": { input: get },
"invoicing.invoice.draft": { input: (t) => ({ ...org(t), data: terms, requestId: id }) },
"invoicing.invoice.update": { input: (t) => ({ ...action(t), data: terms }) },
"invoicing.invoice.issue": { input: action },
"invoicing.invoice.credit": { input: (t) => ({ ...action(t), seriesId, reason: "Synthetic correction" }) },
"invoicing.invoice.void": { input: (t) => ({ ...action(t), reason: "Synthetic correction" }) },
"invoicing.series.create": {
input: (t) => ({ ...org(t), code: "SYNTH", prefix: "SYNTH-", kind: "invoice", requestId: id }),
},
}
export const isolation: {
seed(
call: TransportCaller,
inProject: { org: string; workspace: string; project: string },
): Promise<Record<string, string>>
fixtures: Record<string, IsolationFixture>
} = { seed: async () => ({}), fixtures: businessModulesOn.includes("invoicing") ? invoicingIsolationFixtures : {} }