feat(accounting): edit finalized document cost centres
This commit is contained in:
33
backend/tests/outgoingDocumentCostCentres.test.ts
Normal file
33
backend/tests/outgoingDocumentCostCentres.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import assert from "node:assert/strict"
|
||||
import test from "node:test"
|
||||
import { applyRowCostCentreAssignments } from "../src/modules/outgoing-document-cost-centres.service"
|
||||
import { mcpToolMap } from "../src/mcp/registry"
|
||||
|
||||
test("changes only requested position cost centres", () => {
|
||||
const rows = [
|
||||
{ id: "row-1", description: "Montage", price: 100, costCentre: "old-1" },
|
||||
{ id: "row-2", description: "Material", price: 50, costCentre: "old-2" },
|
||||
]
|
||||
|
||||
assert.deepEqual(applyRowCostCentreAssignments(rows, [
|
||||
{ rowId: "row-1", costcentre: "new-1" },
|
||||
]), [
|
||||
{ id: "row-1", description: "Montage", price: 100, costCentre: "new-1" },
|
||||
rows[1],
|
||||
])
|
||||
})
|
||||
|
||||
test("rejects assignments for unknown document positions", () => {
|
||||
assert.throws(
|
||||
() => applyRowCostCentreAssignments([{ id: "row-1" }], [{ rowId: "missing", costcentre: null }]),
|
||||
/Position missing.*nicht gefunden/,
|
||||
)
|
||||
})
|
||||
|
||||
test("registers a dedicated finalized-document cost centre tool", () => {
|
||||
const tool = mcpToolMap.get("accounting.outgoing_documents.cost_centres.update")
|
||||
|
||||
assert.deepEqual(tool?.requiredPermissions, ["accounting.outgoing_documents.write"])
|
||||
assert.deepEqual(tool?.inputSchema.required, ["id"])
|
||||
assert.ok(tool?.inputSchema.anyOf)
|
||||
})
|
||||
Reference in New Issue
Block a user