@diy-accounting-uk/diya-gl 1.2.45 → 1.2.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/bin/diya-gl-new-book.js +8 -0
- package/bin/diya-gl-roll-forward.js +8 -0
- package/bin/diya-gl.js +3 -1
- package/dist/app/bin/export.js +15 -0
- package/dist/app/bin/new-book.js +64 -0
- package/dist/app/bin/roll-forward.js +79 -0
- package/dist/app/data/filing/ct-computation-v1.1.toml +2 -2
- package/dist/app/data/filing/ct600-v3.toml +2 -0
- package/dist/app/data/releases.json +56 -4
- package/dist/app/data/se-2027-2028.toml +57 -0
- package/dist/app/lib/book-checks/ltd.js +3 -5
- package/dist/app/lib/book-checks.js +10 -6
- package/dist/app/lib/calculators/bst.js +17 -1
- package/dist/app/lib/calculators/ltd.js +50 -19
- package/dist/app/lib/calculators/se.js +20 -1
- package/dist/app/lib/calculators/taxi.js +16 -0
- package/dist/app/lib/derivations/vat-return.js +5 -4
- package/dist/app/lib/diya-gl-loader.js +18 -0
- package/dist/app/lib/diya-gl-new-book.js +194 -0
- package/dist/app/lib/diya-gl-roll-forward.js +687 -0
- package/dist/app/lib/generator.js +7 -4
- package/dist/app/lib/ltd-layout.js +43 -0
- package/dist/app/lib/mcp/diya-gl-tools.js +92 -2
- package/dist/app/lib/mcp/server.js +4 -2
- package/dist/app/lib/provenance-data.js +5 -5
- package/dist/app/lib/scenario-extractor.js +37 -20
- package/dist/app/lib/scenario-loader.js +7 -1
- package/dist/app/lib/spreadsheet-runner.js +4 -3
- package/dist/app/lib/xlsx-exporter.js +34 -8
- package/dist/app/products/ltd.js +33 -17
- package/dist/app/products/se.js +1 -0
- package/dist/web/spreadsheets.diyaccounting.co.uk/public/schema/diya-gl-docs.md +78 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -38,12 +38,15 @@ diya-gl recalc --package bst --data my-book --years se-2025-2026 --output-dir ou
|
|
|
38
38
|
diya-gl read-workbook --file my-workbook.xlsx --output-dir out
|
|
39
39
|
diya-gl write-workbook --data my-book --output-dir out
|
|
40
40
|
diya-gl link my-book
|
|
41
|
+
diya-gl new-book --product se --name "Lark Lane" --year-end 2027-04-05 --output-dir lark-lane
|
|
42
|
+
diya-gl roll-forward --data my-book --output-dir next-year
|
|
41
43
|
diya-gl view my-book
|
|
42
44
|
diya-gl mcp
|
|
43
45
|
```
|
|
44
46
|
|
|
45
47
|
Each subcommand is also its own command, if you only want one on your `PATH`:
|
|
46
|
-
`diya-gl-recalc`, `diya-gl-read-workbook`, `diya-gl-write-workbook`, `diya-gl-link`, `diya-gl-
|
|
48
|
+
`diya-gl-recalc`, `diya-gl-read-workbook`, `diya-gl-write-workbook`, `diya-gl-link`, `diya-gl-new-book`,
|
|
49
|
+
`diya-gl-roll-forward`, `diya-gl-view`, `diya-gl-mcp`.
|
|
47
50
|
|
|
48
51
|
- **recalc** takes a diya-gl book (`--data`) or a populated workbook (`--source-dir`,
|
|
49
52
|
`--mode saved|recalculate`) and writes `report.json`: every figure, report section and
|
|
@@ -58,6 +61,22 @@ Each subcommand is also its own command, if you only want one on your `PATH`:
|
|
|
58
61
|
opens it, the whole book carried in the fragment so nothing is uploaded. `--base <url>`
|
|
59
62
|
replaces the origin. The fragment length goes to stderr, with a warning past 64 KB (about
|
|
60
63
|
2,000 lines), where chat, email and QR codes start to cut links off.
|
|
64
|
+
- **new-book** starts an empty book for a new business: `--product` (`bst`, `se`, `taxi` or
|
|
65
|
+
`ltd`), `--name` and `--year-end` (YYYY-MM-DD), plus `--vat` for a VAT-registered Self
|
|
66
|
+
Employed or Company book. It writes `book.toml` (the product's starting chart of accounts,
|
|
67
|
+
the twelve months to the year end and that tax year's rates), an empty `lines.jsonl`,
|
|
68
|
+
`report.json` and `bookchecks.json` into `--output-dir`, the current directory by default.
|
|
69
|
+
It answers: how do I start books for a new business, what accounts does a new sole trader
|
|
70
|
+
or company book start with, and which tax rates apply to the first year?
|
|
71
|
+
- **roll-forward** takes a book (`--data`, the same sources as **link**) and writes the next
|
|
72
|
+
year's into `--output-dir`: the year end a year on with that year's tax rates, the closing
|
|
73
|
+
balances as opening ones, and lines holding only the opening entries (a Company's opening
|
|
74
|
+
journal and one brought-forward line per bank account; a Self Employed book's bank lines).
|
|
75
|
+
Beside `book.toml`, `lines.jsonl`, `report.json` and `bookchecks.json` it writes
|
|
76
|
+
`rollchecks.json`, each opening figure the new year prints against the closing figure the old
|
|
77
|
+
year printed, and exits 1 when one disagrees. It answers: how do I start next year's books,
|
|
78
|
+
what do I bring forward from last year, and does my opening balance sheet agree with last
|
|
79
|
+
year's closing one?
|
|
61
80
|
- **view** takes the same book sources as **link**, serves the full diya-gl pages on
|
|
62
81
|
`127.0.0.1` (`--port <number>`, default a free port) and opens the book in your default
|
|
63
82
|
browser (`--no-open` prints the address only). The pages are not in this package: the local
|
|
@@ -67,8 +86,9 @@ Each subcommand is also its own command, if you only want one on your `PATH`:
|
|
|
67
86
|
another site. The book stays in the browser (the part of the address after `#` is never sent
|
|
68
87
|
anywhere). The server stays up until Ctrl-C. The workbook templates come from
|
|
69
88
|
spreadsheets.diyaccounting.co.uk the first time a page action needs one.
|
|
70
|
-
- **mcp** runs a stdio [MCP](https://modelcontextprotocol.io) server with
|
|
71
|
-
`extract_book`, `
|
|
89
|
+
- **mcp** runs a stdio [MCP](https://modelcontextprotocol.io) server with ten tools:
|
|
90
|
+
`extract_book`, `new_book` (the empty book **new-book** writes), `roll_forward` (the next
|
|
91
|
+
year **roll-forward** writes), `report`, `edit_lines`, `save_workbook`, and four that read every detail of
|
|
72
92
|
the loaded book: `lines` (filter and group every transaction, e.g. best customer or spend on
|
|
73
93
|
fuel in June), `chart` (the accounts and the report rows each feeds), `book` (the business,
|
|
74
94
|
period, tax settings and registers) and `checks` (every book check with the entryNumbers
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Copyright (C) 2006-2026 DIY Accounting Limited
|
|
4
|
+
//
|
|
5
|
+
// diya-gl-new-book.js — start an empty book for a new business.
|
|
6
|
+
|
|
7
|
+
import { runDistBin } from "./run-dist-bin.js";
|
|
8
|
+
runDistBin("app/bin/new-book.js", process.argv.slice(2));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Copyright (C) 2006-2026 DIY Accounting Limited
|
|
4
|
+
//
|
|
5
|
+
// diya-gl-roll-forward.js — start the next year of a book.
|
|
6
|
+
|
|
7
|
+
import { runDistBin } from "./run-dist-bin.js";
|
|
8
|
+
runDistBin("app/bin/roll-forward.js", process.argv.slice(2));
|
package/bin/diya-gl.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// Copyright (C) 2006-2026 DIY Accounting Limited
|
|
4
4
|
//
|
|
5
|
-
// diya-gl.js — the dispatcher: diya-gl <recalc|read-workbook|write-workbook|link|view|mcp> [args].
|
|
5
|
+
// diya-gl.js — the dispatcher: diya-gl <recalc|read-workbook|write-workbook|link|new-book|roll-forward|view|mcp> [args].
|
|
6
6
|
// Each subcommand is also its own bin (diya-gl-recalc, and so on), for a
|
|
7
7
|
// caller that wants one command on its PATH without the others.
|
|
8
8
|
|
|
@@ -17,6 +17,8 @@ const SUBCOMMANDS = {
|
|
|
17
17
|
"read-workbook": "app/bin/export.js",
|
|
18
18
|
"write-workbook": "app/bin/write-workbook.js",
|
|
19
19
|
"link": "app/bin/link.js",
|
|
20
|
+
"new-book": "app/bin/new-book.js",
|
|
21
|
+
"roll-forward": "app/bin/roll-forward.js",
|
|
20
22
|
"view": "app/bin/view.js",
|
|
21
23
|
"mcp": "app/bin/diya-gl-mcp.js",
|
|
22
24
|
};
|
package/dist/app/bin/export.js
CHANGED
|
@@ -253,6 +253,21 @@ function writeDiyaGlData(outputDir, book, lines) {
|
|
|
253
253
|
console.log(` book.toml: ${Object.keys(stamped).length} tables`);
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
/**
|
|
257
|
+
* A whole book directory from a (book, lines) pair already in hand: book.toml,
|
|
258
|
+
* lines.jsonl, report.json and bookchecks.json, written the way --file writes
|
|
259
|
+
* them. The new-book and roll-forward commands write their output through it.
|
|
260
|
+
* @param {string} outputDir
|
|
261
|
+
* @param {Object} book
|
|
262
|
+
* @param {Array} lines
|
|
263
|
+
*/
|
|
264
|
+
export async function writeBookDirectory(outputDir, book, lines) {
|
|
265
|
+
const product = productOf(book);
|
|
266
|
+
writeDiyaGlData(outputDir, book, lines);
|
|
267
|
+
writeReportJson(outputDir, buildFileReportDocument(book, lines, product, PRODUCTS[product]));
|
|
268
|
+
await writeBookChecksJson(outputDir, book, lines);
|
|
269
|
+
}
|
|
270
|
+
|
|
256
271
|
async function runFileMode(filePath, outputDirArg, packageName) {
|
|
257
272
|
const resolvedFile = resolve(filePath);
|
|
258
273
|
const resolvedOutput = resolve(outputDirArg || dirname(resolvedFile));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Copyright (C) 2006-2026 DIY Accounting Limited
|
|
4
|
+
//
|
|
5
|
+
// new-book.js — start an empty book for a new business: the product's
|
|
6
|
+
// starting chart of accounts, the twelve months to the year end and that tax
|
|
7
|
+
// year's rates, with no lines yet.
|
|
8
|
+
//
|
|
9
|
+
// Usage:
|
|
10
|
+
// node app/bin/new-book.js --product se --name "Lark Lane" --year-end 2027-04-05
|
|
11
|
+
// node app/bin/new-book.js --product ltd --name "Lark Lane Ltd" --year-end 2027-03-31 --vat --output-dir lark-lane
|
|
12
|
+
//
|
|
13
|
+
// Writes book.toml, lines.jsonl, report.json and bookchecks.json into
|
|
14
|
+
// --output-dir, the current directory when none is given. It runs the MCP
|
|
15
|
+
// server's new_book tool, so the command and the tool build the same book.
|
|
16
|
+
|
|
17
|
+
import { resolve } from "path";
|
|
18
|
+
import { fileURLToPath } from "url";
|
|
19
|
+
import { TOOLS, createSession } from "../lib/mcp/diya-gl-tools.js";
|
|
20
|
+
import { writeBookDirectory } from "./export.js";
|
|
21
|
+
|
|
22
|
+
const USAGE = [
|
|
23
|
+
"Usage: diya-gl new-book --product <bst|se|taxi|ltd> --name <business> --year-end <YYYY-MM-DD> [--vat] [--output-dir <dir>]",
|
|
24
|
+
"Answers: How do I start books for a new business? What accounts does a new sole trader or company book start with? Which tax rates apply to my first year?",
|
|
25
|
+
].join("\n");
|
|
26
|
+
|
|
27
|
+
function parseArgs(argv) {
|
|
28
|
+
const args = argv.slice(2);
|
|
29
|
+
const options = { vatRegistered: false, outputDir: "." };
|
|
30
|
+
const valueOf = (flag, index) => {
|
|
31
|
+
const value = args[index + 1];
|
|
32
|
+
if (value === undefined || value.startsWith("--")) throw new Error(`${flag} needs a value. ${USAGE}`);
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
for (let i = 0; i < args.length; i++) {
|
|
36
|
+
const flag = args[i];
|
|
37
|
+
if (flag === "--product") options.product = valueOf(flag, i++);
|
|
38
|
+
else if (flag === "--name") options.businessName = valueOf(flag, i++);
|
|
39
|
+
else if (flag === "--year-end") options.yearEnd = valueOf(flag, i++);
|
|
40
|
+
else if (flag === "--output-dir") options.outputDir = valueOf(flag, i++);
|
|
41
|
+
else if (flag === "--vat") options.vatRegistered = true;
|
|
42
|
+
else throw new Error(`Unknown argument ${flag}. ${USAGE}`);
|
|
43
|
+
}
|
|
44
|
+
if (!options.product || !options.businessName || !options.yearEnd) throw new Error(USAGE);
|
|
45
|
+
return options;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function main() {
|
|
49
|
+
const { outputDir, ...params } = parseArgs(process.argv);
|
|
50
|
+
const { book, lines, bookChecks } = await TOOLS.new_book.handler(createSession(), params);
|
|
51
|
+
const resolvedOutput = resolve(outputDir);
|
|
52
|
+
await writeBookDirectory(resolvedOutput, book, lines);
|
|
53
|
+
const { pass, warn, fail } = bookChecks.summary;
|
|
54
|
+
console.log(
|
|
55
|
+
`New ${params.product} book for ${book.entityInformation.organizationIdentifier}, ${book.documentInfo.periodCoveredStart} to ${book.documentInfo.periodCoveredEnd}, in ${resolvedOutput}: ${pass} checks pass, ${warn} warn, ${fail} fail`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
60
|
+
main().catch((error) => {
|
|
61
|
+
console.error(error.message);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Copyright (C) 2006-2026 DIY Accounting Limited
|
|
4
|
+
//
|
|
5
|
+
// roll-forward.js — start the next year of a book: the year end moves on a
|
|
6
|
+
// year, the closing balances become the opening ones, and the lines hold only
|
|
7
|
+
// the opening entries.
|
|
8
|
+
//
|
|
9
|
+
// Usage:
|
|
10
|
+
// node app/bin/roll-forward.js --data examples/brickwork-pro/ltd-nonvat --output-dir next-year
|
|
11
|
+
// node app/bin/roll-forward.js --data my-book-diya-gl.zip --output-dir next-year
|
|
12
|
+
//
|
|
13
|
+
// --data is a directory holding book.toml and lines.jsonl, or any diya-gl zip
|
|
14
|
+
// or JSON file diya-gl-interchange.js reads. Writes book.toml, lines.jsonl,
|
|
15
|
+
// report.json, bookchecks.json and rollchecks.json (each opening figure the
|
|
16
|
+
// new year prints against the closing figure the old year printed for it)
|
|
17
|
+
// into --output-dir. It runs the MCP server's roll_forward tool, so the
|
|
18
|
+
// command and the tool roll the same book. Exits 1 when a roll check fails.
|
|
19
|
+
|
|
20
|
+
import { existsSync, readFileSync, statSync, writeFileSync } from "fs";
|
|
21
|
+
import { join, resolve } from "path";
|
|
22
|
+
import { fileURLToPath } from "url";
|
|
23
|
+
import { parseDiyaGlData } from "../lib/diya-gl-loader.js";
|
|
24
|
+
import { readBookSource } from "../lib/diya-gl-interchange.js";
|
|
25
|
+
import { PRODUCTS } from "../lib/products.js";
|
|
26
|
+
import { TOOLS, createSession } from "../lib/mcp/diya-gl-tools.js";
|
|
27
|
+
import { writeBookDirectory } from "./export.js";
|
|
28
|
+
|
|
29
|
+
const USAGE = [
|
|
30
|
+
"Usage: diya-gl roll-forward --data <book directory | diya-gl zip | diya-gl JSON file> --output-dir <dir>",
|
|
31
|
+
"Answers: How do I start next year's books? What do I bring forward from last year? Does my opening balance sheet agree with last year's closing one?",
|
|
32
|
+
].join("\n");
|
|
33
|
+
|
|
34
|
+
function parseArgs(argv) {
|
|
35
|
+
const args = argv.slice(2);
|
|
36
|
+
const options = {};
|
|
37
|
+
for (let i = 0; i < args.length; i++) {
|
|
38
|
+
const flag = args[i];
|
|
39
|
+
const value = args[i + 1];
|
|
40
|
+
if (flag !== "--data" && flag !== "--output-dir") throw new Error(`Unknown argument ${flag}. ${USAGE}`);
|
|
41
|
+
if (value === undefined || value.startsWith("--")) throw new Error(`${flag} needs a value. ${USAGE}`);
|
|
42
|
+
options[flag === "--data" ? "data" : "outputDir"] = value;
|
|
43
|
+
i++;
|
|
44
|
+
}
|
|
45
|
+
if (!options.data || !options.outputDir) throw new Error(USAGE);
|
|
46
|
+
return options;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function readBook(source) {
|
|
50
|
+
const path = resolve(source);
|
|
51
|
+
if (!existsSync(path)) throw new Error(`${source} does not exist.`);
|
|
52
|
+
if (statSync(path).isDirectory()) {
|
|
53
|
+
return parseDiyaGlData(readFileSync(join(path, "book.toml"), "utf8"), readFileSync(join(path, "lines.jsonl"), "utf8"));
|
|
54
|
+
}
|
|
55
|
+
const { book, lines } = await readBookSource(readFileSync(path), source, { products: PRODUCTS });
|
|
56
|
+
return { book, lines };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function main() {
|
|
60
|
+
const { data, outputDir } = parseArgs(process.argv);
|
|
61
|
+
const prior = await readBook(data);
|
|
62
|
+
const { book, lines, bookChecks, rollChecks } = await TOOLS.roll_forward.handler(createSession(), prior);
|
|
63
|
+
const resolvedOutput = resolve(outputDir);
|
|
64
|
+
await writeBookDirectory(resolvedOutput, book, lines);
|
|
65
|
+
writeFileSync(join(resolvedOutput, "rollchecks.json"), `${JSON.stringify(rollChecks, null, 2)}\n`);
|
|
66
|
+
const failing = rollChecks.filter((check) => check.result === "fail");
|
|
67
|
+
console.log(
|
|
68
|
+
`Rolled forward to ${book.documentInfo.periodCoveredStart} to ${book.documentInfo.periodCoveredEnd} in ${resolvedOutput}: ${lines.length} opening lines, ${bookChecks.summary.fail} book checks failing, ${failing.length} of ${rollChecks.length} roll checks failing`,
|
|
69
|
+
);
|
|
70
|
+
for (const check of failing) console.error(` ${check.key}: expected ${check.expected}, the new year opens on ${check.actual}`);
|
|
71
|
+
if (failing.length > 0) process.exitCode = 1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
75
|
+
main().catch((error) => {
|
|
76
|
+
console.error(error.message);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -167,7 +167,7 @@ section = 1
|
|
|
167
167
|
part = 2
|
|
168
168
|
partName = "Section 1 Part 2: Accounting Non-Taxable Income Deducted"
|
|
169
169
|
label = "Non-trading loan relationship credit"
|
|
170
|
-
xbrl = "AdjustmentsNon-
|
|
170
|
+
xbrl = "AdjustmentsNon-tradingLoanRelationshipCreditsPerAccounts"
|
|
171
171
|
sheetCell = "Financialaccounts.xlsx!CorporationTax!K24"
|
|
172
172
|
note = "Bank interest: the plan's Ltd view moves this to CT600 box 170 rather than adding it back in the trading computation."
|
|
173
173
|
|
|
@@ -432,7 +432,7 @@ section = 1
|
|
|
432
432
|
part = 3
|
|
433
433
|
partName = "Section 1 Part 3: Accounting Disallowable Expenditure Addback"
|
|
434
434
|
label = "Non-trading loan relationship debit"
|
|
435
|
-
xbrl = "AdjustmentsNon-
|
|
435
|
+
xbrl = "AdjustmentsNon-tradingLoanRelationshipDebitsPerAccounts"
|
|
436
436
|
|
|
437
437
|
[[line]]
|
|
438
438
|
section = 1
|
|
@@ -1283,6 +1283,8 @@ label = "Tax already paid (and not already repaid)"
|
|
|
1283
1283
|
section = "Tax reconciliation"
|
|
1284
1284
|
format = "pounds-and-pence"
|
|
1285
1285
|
element = "TaxAlreadyPaid"
|
|
1286
|
+
status = "entry-on-this-template"
|
|
1287
|
+
statusNote = "CT600!AJ163 is an entry cell with no formula: the company types what it has paid, and no book figure feeds it"
|
|
1286
1288
|
xmlPath = "/IRenvelope/CompanyTaxReturn/TaxReconciliation/TaxAlreadyPaid"
|
|
1287
1289
|
sheetCell = "Financialaccounts.xlsx!CT600!AJ163"
|
|
1288
1290
|
|
|
@@ -1304,7 +1304,7 @@
|
|
|
1304
1304
|
"tag": "diya-gl-v1.2.41",
|
|
1305
1305
|
"date": "2026-10-01",
|
|
1306
1306
|
"formatVersion": "diya-gl/1",
|
|
1307
|
-
"engineVersion": "1.2.
|
|
1307
|
+
"engineVersion": "1.2.41+5b1fc93c5",
|
|
1308
1308
|
"taxDataHash": "89424bd36c0d",
|
|
1309
1309
|
"reconciledCommit": "54e8731a91279975e61b1a232fbb67fda89515f0",
|
|
1310
1310
|
"templates": {
|
|
@@ -1330,7 +1330,7 @@
|
|
|
1330
1330
|
"tag": "diya-gl-v1.2.42",
|
|
1331
1331
|
"date": "2026-10-03",
|
|
1332
1332
|
"formatVersion": "diya-gl/1",
|
|
1333
|
-
"engineVersion": "1.2.
|
|
1333
|
+
"engineVersion": "1.2.42+ed6c7809b",
|
|
1334
1334
|
"taxDataHash": "89424bd36c0d",
|
|
1335
1335
|
"reconciledCommit": "54e8731a91279975e61b1a232fbb67fda89515f0",
|
|
1336
1336
|
"templates": {
|
|
@@ -1356,7 +1356,7 @@
|
|
|
1356
1356
|
"tag": "diya-gl-v1.2.43",
|
|
1357
1357
|
"date": "2026-10-03",
|
|
1358
1358
|
"formatVersion": "diya-gl/1",
|
|
1359
|
-
"engineVersion": "1.2.
|
|
1359
|
+
"engineVersion": "1.2.43+971ca45ad",
|
|
1360
1360
|
"taxDataHash": "89424bd36c0d",
|
|
1361
1361
|
"reconciledCommit": "54e8731a91279975e61b1a232fbb67fda89515f0",
|
|
1362
1362
|
"templates": {
|
|
@@ -1382,7 +1382,7 @@
|
|
|
1382
1382
|
"tag": "diya-gl-v1.2.44",
|
|
1383
1383
|
"date": "2026-10-03",
|
|
1384
1384
|
"formatVersion": "diya-gl/1",
|
|
1385
|
-
"engineVersion": "1.2.
|
|
1385
|
+
"engineVersion": "1.2.44+4b8f90020",
|
|
1386
1386
|
"taxDataHash": "89424bd36c0d",
|
|
1387
1387
|
"reconciledCommit": "54e8731a91279975e61b1a232fbb67fda89515f0",
|
|
1388
1388
|
"templates": {
|
|
@@ -1403,6 +1403,58 @@
|
|
|
1403
1403
|
"scorecard": "101605 passed, 0 warnings, 0 failed"
|
|
1404
1404
|
}
|
|
1405
1405
|
}
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
"tag": "diya-gl-v1.2.45",
|
|
1409
|
+
"date": "2026-10-04",
|
|
1410
|
+
"formatVersion": "diya-gl/1",
|
|
1411
|
+
"engineVersion": "1.2.45+3801b0c2",
|
|
1412
|
+
"taxDataHash": "89424bd36c0d",
|
|
1413
|
+
"reconciledCommit": "54e8731a91279975e61b1a232fbb67fda89515f0",
|
|
1414
|
+
"templates": {
|
|
1415
|
+
"bst": {
|
|
1416
|
+
"hash": "0d003e10e00c",
|
|
1417
|
+
"scorecard": "812 passed, 0 warnings, 0 failed"
|
|
1418
|
+
},
|
|
1419
|
+
"taxi": {
|
|
1420
|
+
"hash": "1ff69654d64d",
|
|
1421
|
+
"scorecard": "700 passed, 0 warnings, 0 failed"
|
|
1422
|
+
},
|
|
1423
|
+
"se": {
|
|
1424
|
+
"hash": "064605ae76ed",
|
|
1425
|
+
"scorecard": "8014 passed, 0 warnings, 0 failed"
|
|
1426
|
+
},
|
|
1427
|
+
"ltd": {
|
|
1428
|
+
"hash": "5bb7be9b6d97",
|
|
1429
|
+
"scorecard": "101605 passed, 0 warnings, 0 failed"
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
},
|
|
1433
|
+
{
|
|
1434
|
+
"tag": "diya-gl-v1.2.46",
|
|
1435
|
+
"date": "2026-10-05",
|
|
1436
|
+
"formatVersion": "diya-gl/1",
|
|
1437
|
+
"engineVersion": "1.2.46+f38ebcb4",
|
|
1438
|
+
"taxDataHash": "89424bd36c0d",
|
|
1439
|
+
"reconciledCommit": "54e8731a91279975e61b1a232fbb67fda89515f0",
|
|
1440
|
+
"templates": {
|
|
1441
|
+
"bst": {
|
|
1442
|
+
"hash": "0d003e10e00c",
|
|
1443
|
+
"scorecard": "812 passed, 0 warnings, 0 failed"
|
|
1444
|
+
},
|
|
1445
|
+
"taxi": {
|
|
1446
|
+
"hash": "1ff69654d64d",
|
|
1447
|
+
"scorecard": "700 passed, 0 warnings, 0 failed"
|
|
1448
|
+
},
|
|
1449
|
+
"se": {
|
|
1450
|
+
"hash": "064605ae76ed",
|
|
1451
|
+
"scorecard": "8015 passed, 0 warnings, 0 failed"
|
|
1452
|
+
},
|
|
1453
|
+
"ltd": {
|
|
1454
|
+
"hash": "ab3dc062e15f",
|
|
1455
|
+
"scorecard": "101608 passed, 0 warnings, 0 failed"
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1406
1458
|
}
|
|
1407
1459
|
]
|
|
1408
1460
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (C) 2006-2026 DIY Accounting Limited
|
|
3
|
+
# UK self-employment tax rates and thresholds for the 2027-28 tax year
|
|
4
|
+
# Period: 6 April 2027 – 5 April 2028
|
|
5
|
+
# Source: HMRC. Class 2 weekly rate and small profits threshold carried forward from 2026-27 (not yet published)
|
|
6
|
+
|
|
7
|
+
[tax_year]
|
|
8
|
+
label = "2027-28"
|
|
9
|
+
next_label = "2028-29"
|
|
10
|
+
start = 2027-04-06
|
|
11
|
+
end = 2028-04-05
|
|
12
|
+
|
|
13
|
+
[income_tax]
|
|
14
|
+
personal_allowance = 12570
|
|
15
|
+
starting_rate = 0.00
|
|
16
|
+
basic_rate = 0.20
|
|
17
|
+
higher_rate = 0.40
|
|
18
|
+
starter_band_end = 0
|
|
19
|
+
basic_band_end = 37700
|
|
20
|
+
higher_band_start = 37701
|
|
21
|
+
higher_band_end = 125140
|
|
22
|
+
additional_rate = 0.45
|
|
23
|
+
personal_allowance_taper_threshold = 100000
|
|
24
|
+
|
|
25
|
+
[national_insurance]
|
|
26
|
+
class2_rate = 3.65
|
|
27
|
+
class4_lower_rate = 0.06
|
|
28
|
+
class4_lower_limit = 12570
|
|
29
|
+
class4_upper_rate = 0.02
|
|
30
|
+
class4_upper_limit = 50270
|
|
31
|
+
class2_weekly_rate = 3.65
|
|
32
|
+
class2_small_profits_threshold = 7105
|
|
33
|
+
|
|
34
|
+
[capital_allowances]
|
|
35
|
+
annual_investment_allowance = 1.00
|
|
36
|
+
writing_down_allowance = 0.14
|
|
37
|
+
writing_down_allowance_special = 0.06
|
|
38
|
+
structures_and_buildings_allowance = 0.03
|
|
39
|
+
structures_and_buildings_allowance_enhanced = 0.10
|
|
40
|
+
|
|
41
|
+
[depreciation]
|
|
42
|
+
land_and_property = 0.00
|
|
43
|
+
plant_and_machinery = 0.10
|
|
44
|
+
fixtures_and_fittings = 0.20
|
|
45
|
+
computer_equipment = 0.33
|
|
46
|
+
motor_vehicles = 0.25
|
|
47
|
+
|
|
48
|
+
# Approved mileage rates: gov.uk "Travel - mileage and fuel rates and allowances", cars and vans, tax year 2026 to 2027, unchanged for 2027-28: 55p first 10,000 miles, 25p after.
|
|
49
|
+
[mileage]
|
|
50
|
+
higher_rate_limit = 10000
|
|
51
|
+
higher_rate_pence = 0.55
|
|
52
|
+
lower_rate_start = 10001
|
|
53
|
+
lower_rate_pence = 0.25
|
|
54
|
+
|
|
55
|
+
[vat]
|
|
56
|
+
registration_threshold = 90000
|
|
57
|
+
standard_rate = 0.20
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import { changeLinePostingDate } from "../diya-gl-edits.js";
|
|
17
17
|
import { LTD_PURCHASE_CODE_MAP, LTD_SALES_CODE_MAP } from "../scenario-extractor.js";
|
|
18
|
-
import { BANK_ACCOUNT_FILES, BANK_TRANSFER_CODES,
|
|
18
|
+
import { BANK_ACCOUNT_FILES, BANK_TRANSFER_CODES, ltdBankPlacement } from "../ltd-layout.js";
|
|
19
19
|
|
|
20
20
|
// The bank account each transfer letter names: Currentaccount is BB, so a
|
|
21
21
|
// BB-coded line on any other workbook is a transfer to or from the current
|
|
@@ -161,13 +161,11 @@ export const LTD_CHECK_SPECS = [
|
|
|
161
161
|
const fileName = bankFileOf(line);
|
|
162
162
|
if (!fileName) return true;
|
|
163
163
|
if (line.debitCreditCode !== "D" && line.debitCreditCode !== "C") return false;
|
|
164
|
-
|
|
165
|
-
const analysed = line.debitCreditCode === "D" ? layout.receiptCodes : layout.paymentCodes;
|
|
166
|
-
return !analysed.includes(line["diya-gl:bankCode"]);
|
|
164
|
+
return !ltdBankPlacement(fileName, line.debitCreditCode === "D", line["diya-gl:bankCode"], line.amount).analysed;
|
|
167
165
|
});
|
|
168
166
|
},
|
|
169
167
|
consequence: function () {
|
|
170
|
-
return "Each bank workbook analyses its own list of codes, and the four workbooks do not share one list -- the cash book has no receipt column for RV, RC or X.
|
|
168
|
+
return "Each bank workbook analyses its own list of codes, and the four workbooks do not share one list -- the cash book has no receipt column for RV, RC or X. A refund coded DR on a payment or CR on a receipt lands in the opposite block as a negative entry under its own code. Any other entry coded outside its workbook's list has no column to land in, and the package cannot be written at all.";
|
|
171
169
|
},
|
|
172
170
|
buildHelper: null,
|
|
173
171
|
apply: null,
|
|
@@ -684,9 +684,13 @@ function bankEntries(lines, bankCode, side) {
|
|
|
684
684
|
// straddling invoice is returned on a VAT period outside that year and is
|
|
685
685
|
// banked in a book this one does not hold, so it neither needs a settlement
|
|
686
686
|
// of its own nor takes up a bank line another invoice is waiting for.
|
|
687
|
-
|
|
687
|
+
// A credit note runs the other way from an invoice: its money goes back out
|
|
688
|
+
// as a refund (DR on a payment, CR on a receipt), or it is offset or written
|
|
689
|
+
// off and never reaches the bank. It neither wants a receipt or a payment
|
|
690
|
+
// the way an invoice does nor takes up one an invoice is waiting for.
|
|
691
|
+
function invoiceEntries(lines, journal) {
|
|
688
692
|
return lines.filter(function (line) {
|
|
689
|
-
return line.sourceJournalID === journal && !isStraddlingLine(line);
|
|
693
|
+
return line.sourceJournalID === journal && line.documentType !== "credit-note" && !isStraddlingLine(line);
|
|
690
694
|
});
|
|
691
695
|
}
|
|
692
696
|
|
|
@@ -769,7 +773,7 @@ const SETTLEMENT_KINDS = [
|
|
|
769
773
|
actionLabel: "Add the sale",
|
|
770
774
|
what: "sale",
|
|
771
775
|
sources: function (ctx) {
|
|
772
|
-
return unpaired(bankEntries(ctx.lines, RECEIPT_BANK_CODE, "D"),
|
|
776
|
+
return unpaired(bankEntries(ctx.lines, RECEIPT_BANK_CODE, "D"), invoiceEntries(ctx.lines, "sales"));
|
|
773
777
|
},
|
|
774
778
|
account: function (ctx) {
|
|
775
779
|
return ctx.chart.sales[0] || null;
|
|
@@ -785,7 +789,7 @@ const SETTLEMENT_KINDS = [
|
|
|
785
789
|
actionLabel: "Add the purchase",
|
|
786
790
|
what: "purchase",
|
|
787
791
|
sources: function (ctx) {
|
|
788
|
-
return unpaired(bankEntries(ctx.lines, PAYMENT_BANK_CODE, "C"),
|
|
792
|
+
return unpaired(bankEntries(ctx.lines, PAYMENT_BANK_CODE, "C"), invoiceEntries(ctx.lines, "purchases"));
|
|
789
793
|
},
|
|
790
794
|
account: function (ctx) {
|
|
791
795
|
return repostAccount(ctx, "purchases");
|
|
@@ -801,7 +805,7 @@ const SETTLEMENT_KINDS = [
|
|
|
801
805
|
actionLabel: "Add the receipt",
|
|
802
806
|
what: "receipt",
|
|
803
807
|
sources: function (ctx) {
|
|
804
|
-
return unpaired(
|
|
808
|
+
return unpaired(invoiceEntries(ctx.lines, "sales"), bankEntries(ctx.lines, RECEIPT_BANK_CODE, "D"));
|
|
805
809
|
},
|
|
806
810
|
account: settlementBankAccount,
|
|
807
811
|
build: function (ctx, source, account, entryNumber) {
|
|
@@ -815,7 +819,7 @@ const SETTLEMENT_KINDS = [
|
|
|
815
819
|
actionLabel: "Add the payment",
|
|
816
820
|
what: "payment",
|
|
817
821
|
sources: function (ctx) {
|
|
818
|
-
return unpaired(
|
|
822
|
+
return unpaired(invoiceEntries(ctx.lines, "purchases"), bankEntries(ctx.lines, PAYMENT_BANK_CODE, "C"));
|
|
819
823
|
},
|
|
820
824
|
account: settlementBankAccount,
|
|
821
825
|
build: function (ctx, source, account, entryNumber) {
|
|
@@ -13,7 +13,7 @@ import { calculateIncomeTax } from "../tax/income-tax.js";
|
|
|
13
13
|
import { calculateNIClass4 } from "../tax/national-insurance.js";
|
|
14
14
|
import { calculateMileageAllowance, scenarioBusinessMiles } from "../tax/mileage.js";
|
|
15
15
|
import { aggregateByCode } from "./shared.js";
|
|
16
|
-
import { attributionWriter, entriesOf } from "../entry-attribution.js";
|
|
16
|
+
import { attributionWriter, entriesOf, entryOf } from "../entry-attribution.js";
|
|
17
17
|
|
|
18
18
|
const BST_MONTH_COLS = {
|
|
19
19
|
apr: "D",
|
|
@@ -87,6 +87,22 @@ function outstandingTotal(transactions) {
|
|
|
87
87
|
* @param {Object} [attribution] - filled in place with the entryNumbers behind each cell (entry-attribution.js)
|
|
88
88
|
* @returns {Object} { "SheetName": { "CellRef": value } }
|
|
89
89
|
*/
|
|
90
|
+
/**
|
|
91
|
+
* Each fixed asset bought in the year beside the tax written-down value the
|
|
92
|
+
* Fixed Assets sheet carries forward for it: the pool a book rolled forward
|
|
93
|
+
* brings into its next year.
|
|
94
|
+
* @param {Object} scenario - diyaGlToScenario's output
|
|
95
|
+
* @param {Object} taxData
|
|
96
|
+
* @returns {Array<{entryNumber: string, cost: number, writtenDownValue: number}>}
|
|
97
|
+
*/
|
|
98
|
+
export function bstAdditionsWrittenDown(scenario, taxData) {
|
|
99
|
+
return fixedAssetAdditions(scenario, "f").map((asset) => ({
|
|
100
|
+
entryNumber: entryOf(asset),
|
|
101
|
+
cost: asset.cost,
|
|
102
|
+
writtenDownValue: calculateFixedAssetSchedule([asset], taxData).M1,
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
|
|
90
106
|
export function calculateBstResults(book, lines, taxData, scenario, attribution) {
|
|
91
107
|
// A book's own declared chart can number its purchase accounts under a
|
|
92
108
|
// scheme other than the Basic Sole Trader master's own (see
|