All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 50s
Build and Push Docker Images / build-website (push) Successful in 22s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 21s
Build and Push Docker Images / build-frontend (push) Successful in 22s
115 lines
3.7 KiB
TypeScript
115 lines
3.7 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import test from "node:test"
|
|
import {
|
|
accountingTools,
|
|
prepareStatementAllocationInput,
|
|
} from "../src/mcp/tools/accounting"
|
|
|
|
const createTool = () => accountingTools.find((tool) => tool.name === "accounting.statement_allocations.create")
|
|
const deleteTool = () => accountingTools.find((tool) => tool.name === "accounting.statement_allocations.delete")
|
|
|
|
test("registers write tools for creating and deleting statement allocations", () => {
|
|
assert.deepEqual(createTool()?.requiredPermissions, ["accounting.statement_allocations.write"])
|
|
assert.deepEqual(deleteTool()?.requiredPermissions, ["accounting.statement_allocations.write"])
|
|
})
|
|
|
|
test("prepares a direct bank allocation to every target type exposed by the UI", () => {
|
|
const base = {
|
|
bankstatement: 42,
|
|
amount: -125.5,
|
|
description: "Teilzahlung",
|
|
}
|
|
|
|
const targets = [
|
|
["createddocument", 11],
|
|
["incominginvoice", 12],
|
|
["account", 13],
|
|
["ownaccount", "57d31d62-11a2-47c5-b074-69f9c5ab8bba"],
|
|
["customer", 14],
|
|
["vendor", 15],
|
|
] as const
|
|
|
|
for (const [field, value] of targets) {
|
|
assert.deepEqual(prepareStatementAllocationInput({ ...base, [field]: value }), {
|
|
bankstatement: 42,
|
|
amount: -125.5,
|
|
description: "Teilzahlung",
|
|
bookingMode: "expense",
|
|
[field]: value,
|
|
})
|
|
}
|
|
})
|
|
|
|
test("prepares depreciation metadata for direct account allocations", () => {
|
|
assert.deepEqual(prepareStatementAllocationInput({
|
|
bankstatement: 42,
|
|
amount: -1200,
|
|
account: 13,
|
|
bookingMode: "depreciation_bundle",
|
|
depreciationMonths: 60,
|
|
depreciationStartDate: "2026-08-01",
|
|
depreciationMethod: "degressive",
|
|
depreciationLabel: "Werkzeug",
|
|
depreciationGroup: "BGA 2026",
|
|
residualValue: 100,
|
|
}), {
|
|
bankstatement: 42,
|
|
amount: -1200,
|
|
account: 13,
|
|
bookingMode: "depreciation_bundle",
|
|
depreciationMonths: 60,
|
|
depreciationStartDate: "2026-08-01",
|
|
depreciationMethod: "degressive",
|
|
depreciationLabel: "Werkzeug",
|
|
depreciationGroup: "BGA 2026",
|
|
residualValue: 100,
|
|
})
|
|
})
|
|
|
|
test("prepares manual Soll/Haben bookings including incoming invoices", () => {
|
|
assert.deepEqual(prepareStatementAllocationInput({
|
|
manualBookingDate: "2026-08-31",
|
|
amount: 99.95,
|
|
incominginvoice: 7,
|
|
manualInvoiceSide: "debit",
|
|
contraOwnaccount: "57d31d62-11a2-47c5-b074-69f9c5ab8bba",
|
|
datevTaxKey: "9",
|
|
description: "Manuelle Buchung",
|
|
}), {
|
|
bankstatement: null,
|
|
manualBookingDate: "2026-08-31",
|
|
amount: 99.95,
|
|
incominginvoice: 7,
|
|
manualInvoiceSide: "debit",
|
|
contraOwnaccount: "57d31d62-11a2-47c5-b074-69f9c5ab8bba",
|
|
datevTaxKey: "9",
|
|
description: "Manuelle Buchung",
|
|
bookingMode: "expense",
|
|
})
|
|
})
|
|
|
|
test("rejects ambiguous bank targets and invalid manual booking sides", () => {
|
|
assert.throws(
|
|
() => prepareStatementAllocationInput({ bankstatement: 42, amount: 10, account: 1, vendor: 2 }),
|
|
/genau ein Ziel/,
|
|
)
|
|
assert.throws(
|
|
() => prepareStatementAllocationInput({ manualBookingDate: "2026-08-31", amount: 10, account: 1 }),
|
|
/Soll- und ein Haben-Konto/,
|
|
)
|
|
})
|
|
|
|
test("rejects incomplete depreciation settings", () => {
|
|
assert.throws(
|
|
() => prepareStatementAllocationInput({
|
|
bankstatement: 42,
|
|
amount: -1200,
|
|
account: 13,
|
|
bookingMode: "depreciation_bundle",
|
|
depreciationMonths: 0,
|
|
depreciationStartDate: "2026-08-01",
|
|
}),
|
|
/Abschreibungsdauer/,
|
|
)
|
|
})
|