@diy-accounting-uk/diya-gl 1.2.48 → 1.2.49
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.
|
@@ -1481,6 +1481,32 @@
|
|
|
1481
1481
|
"scorecard": "101608 passed, 0 warnings, 0 failed"
|
|
1482
1482
|
}
|
|
1483
1483
|
}
|
|
1484
|
+
},
|
|
1485
|
+
{
|
|
1486
|
+
"tag": "diya-gl-v1.2.48",
|
|
1487
|
+
"date": "2026-10-05",
|
|
1488
|
+
"formatVersion": "diya-gl/1",
|
|
1489
|
+
"engineVersion": "1.2.48+bf25fb49",
|
|
1490
|
+
"taxDataHash": "51bdff60e993",
|
|
1491
|
+
"reconciledCommit": "54e8731a91279975e61b1a232fbb67fda89515f0",
|
|
1492
|
+
"templates": {
|
|
1493
|
+
"bst": {
|
|
1494
|
+
"hash": "0d003e10e00c",
|
|
1495
|
+
"scorecard": "812 passed, 0 warnings, 0 failed"
|
|
1496
|
+
},
|
|
1497
|
+
"taxi": {
|
|
1498
|
+
"hash": "1ff69654d64d",
|
|
1499
|
+
"scorecard": "700 passed, 0 warnings, 0 failed"
|
|
1500
|
+
},
|
|
1501
|
+
"se": {
|
|
1502
|
+
"hash": "064605ae76ed",
|
|
1503
|
+
"scorecard": "8015 passed, 0 warnings, 0 failed"
|
|
1504
|
+
},
|
|
1505
|
+
"ltd": {
|
|
1506
|
+
"hash": "a65ab09cf35c",
|
|
1507
|
+
"scorecard": "101608 passed, 0 warnings, 0 failed"
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1484
1510
|
}
|
|
1485
1511
|
]
|
|
1486
1512
|
}
|
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
// this module never restates a box's API field name in code, so a mapping
|
|
13
13
|
// correction there reaches both derivations with no code change.
|
|
14
14
|
|
|
15
|
-
import
|
|
16
|
-
import { resolve, dirname } from "path";
|
|
17
|
-
import { fileURLToPath } from "url";
|
|
15
|
+
import mapping from "../../data/hmrc/sa103-mtd-mapping.json" with { type: "json" };
|
|
18
16
|
import { diyaGlToScenario } from "../diya-gl-loader.js";
|
|
19
17
|
import { calculateSeCells } from "./se.js";
|
|
20
18
|
import { SE_YEAR_END_MONTH, SBA_CLAIM_ROWS } from "../../products/se.js";
|
|
@@ -22,17 +20,8 @@ import { extractTaxYearStart, parseDate } from "../scenario-loader.js";
|
|
|
22
20
|
import { shiftMonths, periodShiftMonths } from "../period-shift.js";
|
|
23
21
|
import { splitVat } from "../tax/vat.js";
|
|
24
22
|
|
|
25
|
-
let cachedMapping = null;
|
|
26
|
-
|
|
27
|
-
// Resolved on first use, not at import: the engine bundle loads in the browser,
|
|
28
|
-
// where import.meta.url is an http URL and fileURLToPath throws.
|
|
29
23
|
export function loadMapping() {
|
|
30
|
-
|
|
31
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
32
|
-
const mappingPath = resolve(here, "..", "..", "data", "hmrc", "sa103-mtd-mapping.json");
|
|
33
|
-
cachedMapping = JSON.parse(readFileSync(mappingPath, "utf8"));
|
|
34
|
-
}
|
|
35
|
-
return cachedMapping;
|
|
24
|
+
return mapping;
|
|
36
25
|
}
|
|
37
26
|
|
|
38
27
|
function sa103fBoxes() {
|
|
@@ -49,8 +49,8 @@ function taxYearFileNameFor(label) {
|
|
|
49
49
|
return `se-${start}-${end}`;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
async function taxDataFor(book, taxYear) {
|
|
53
|
-
const options = taxYear ? { taxYearName: taxYearFileNameFor(taxYear) } : {};
|
|
52
|
+
async function taxDataFor(book, taxYear, resources) {
|
|
53
|
+
const options = taxYear ? { taxYearName: taxYearFileNameFor(taxYear), resources } : { resources };
|
|
54
54
|
const taxData = await loadTaxDataForBook(book, options);
|
|
55
55
|
const label = taxData?.tax_year?.label;
|
|
56
56
|
if (!label) throw new Error("the tax year file declares no tax_year.label");
|
|
@@ -153,13 +153,13 @@ function periodLabel(period) {
|
|
|
153
153
|
* @param {Object} book - parsed book.toml
|
|
154
154
|
* @param {Array} lines - parsed lines.jsonl entries
|
|
155
155
|
* @param {{periodEndDate?: string, quarterlyPeriodType?: "standard"|"calendar", taxYear?: string}} [params] -
|
|
156
|
-
* quarterlyPeriodType defaults to standard (6 April quarters); taxYear (as 2025-26) overrides the year the
|
|
156
|
+
* resources is the loader the tax data reads through (defaults to reading app/); quarterlyPeriodType defaults to standard (6 April quarters); taxYear (as 2025-26) overrides the year the
|
|
157
157
|
* book's dates imply
|
|
158
158
|
* @returns {Promise<Object>} { taxYear, shape, quarterlyPeriodType, fieldSlots, periods, warnings }
|
|
159
159
|
*/
|
|
160
|
-
export async function deriveItsaQuarterlyUpdate(book, lines, { periodEndDate, quarterlyPeriodType, taxYear } = {}) {
|
|
160
|
+
export async function deriveItsaQuarterlyUpdate(book, lines, { periodEndDate, quarterlyPeriodType, taxYear, resources } = {}) {
|
|
161
161
|
requireSelfEmployedBook(book, lines, "deriveItsaQuarterlyUpdate");
|
|
162
|
-
const taxData = await taxDataFor(book, taxYear);
|
|
162
|
+
const taxData = await taxDataFor(book, taxYear, resources);
|
|
163
163
|
const label = taxData.tax_year.label;
|
|
164
164
|
const shape = loadMapping().api.years[label].quarterly;
|
|
165
165
|
const periodType = quarterlyPeriodType || "standard";
|
|
@@ -217,9 +217,9 @@ export async function deriveItsaQuarterlyUpdate(book, lines, { periodEndDate, qu
|
|
|
217
217
|
* @param {{taxYear?: string}} [params] - taxYear (as 2025-26) overrides the year the book's dates imply
|
|
218
218
|
* @returns {Promise<Object>} { taxYear, fieldSlots, allowances, adjustments, omitted, warnings }
|
|
219
219
|
*/
|
|
220
|
-
export async function deriveItsaAnnualSubmission(book, lines, { taxYear } = {}) {
|
|
220
|
+
export async function deriveItsaAnnualSubmission(book, lines, { taxYear, resources } = {}) {
|
|
221
221
|
requireSelfEmployedBook(book, lines, "deriveItsaAnnualSubmission");
|
|
222
|
-
const taxData = await taxDataFor(book, taxYear);
|
|
222
|
+
const taxData = await taxDataFor(book, taxYear, resources);
|
|
223
223
|
const label = taxData.tax_year.label;
|
|
224
224
|
const slots = annualFieldSlotsForTaxYear(label);
|
|
225
225
|
|
|
@@ -141,12 +141,12 @@ function reconcile(label, attributed, engine) {
|
|
|
141
141
|
* @param {Object} book - parsed book.toml
|
|
142
142
|
* @param {Array} lines - parsed lines.jsonl entries
|
|
143
143
|
* @param {{periodEnd: string, periodStart?: string, periodKey?: string}} params - periodEnd is the
|
|
144
|
-
* obligation's period end (YYYY-MM-DD); periodStart, when given, must open that quarter; periodKey is
|
|
144
|
+
* obligation's period end (YYYY-MM-DD); resources is the loader the tax data reads through (defaults to reading app/); periodStart, when given, must open that quarter; periodKey is
|
|
145
145
|
* echoed back untouched
|
|
146
146
|
* @returns {Promise<Object>} { vatRegistrationNumber, periodKey, periodStart, periodEnd, dueDate, scheme,
|
|
147
147
|
* months, boxes, hmrc, lines, notes }
|
|
148
148
|
*/
|
|
149
|
-
export async function deriveVatReturn(book, lines, { periodEnd, periodStart, periodKey } = {}) {
|
|
149
|
+
export async function deriveVatReturn(book, lines, { periodEnd, periodStart, periodKey, resources } = {}) {
|
|
150
150
|
if (!book || !lines) throw new Error("deriveVatReturn requires a book and its lines");
|
|
151
151
|
if (!periodEnd) throw new Error("deriveVatReturn requires periodEnd (the obligation's period end, YYYY-MM-DD)");
|
|
152
152
|
const entity = book.entityInformation ?? {};
|
|
@@ -157,7 +157,7 @@ export async function deriveVatReturn(book, lines, { periodEnd, periodStart, per
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
const product = productOf(book);
|
|
160
|
-
const taxData = await loadTaxDataForBook(book);
|
|
160
|
+
const taxData = await loadTaxDataForBook(book, { resources });
|
|
161
161
|
const results = calculateFromDiyaGl(book, lines, product, taxData, diyaGlToScenario(book, lines, product));
|
|
162
162
|
const rows = interfaceRows(results);
|
|
163
163
|
const wantedEnd = isoDate(periodEnd);
|