@diy-accounting-uk/diya-gl 1.0.0
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 +63 -0
- package/bin/diya-gl-mcp.js +10 -0
- package/bin/diya-gl-read-workbook.js +11 -0
- package/bin/diya-gl-recalc.js +10 -0
- package/bin/diya-gl-write-workbook.js +12 -0
- package/bin/diya-gl.js +24 -0
- package/bin/run-dist-bin.js +23 -0
- package/dist/app/bin/build-diya-gl-spec.js +680 -0
- package/dist/app/bin/build-packages.js +149 -0
- package/dist/app/bin/build-reconciliation-pages.js +1052 -0
- package/dist/app/bin/build-sitemaps.js +51 -0
- package/dist/app/bin/compliance-report.js +125 -0
- package/dist/app/bin/cross-package-reconciliation.js +92 -0
- package/dist/app/bin/diya-gl-mcp.js +27 -0
- package/dist/app/bin/export.js +318 -0
- package/dist/app/bin/extract-scenarios.js +1348 -0
- package/dist/app/bin/generate.js +353 -0
- package/dist/app/bin/judge-reconciliation.js +649 -0
- package/dist/app/bin/reconcile.js +247 -0
- package/dist/app/bin/report.js +291 -0
- package/dist/app/bin/verify-roundtrip.js +941 -0
- package/dist/app/bin/verify-stability.js +429 -0
- package/dist/app/bin/write-workbook.js +106 -0
- package/dist/app/data/filing/ct-computation-v1.1.toml +1033 -0
- package/dist/app/data/filing/ct600-v3.toml +2329 -0
- package/dist/app/data/filing/frs105-formats.toml +244 -0
- package/dist/app/data/fixture-master-gaps.json +247 -0
- package/dist/app/data/hmrc/SOURCE.md +14 -0
- package/dist/app/data/hmrc/form-layouts/bst.json +116 -0
- package/dist/app/data/hmrc/form-layouts/ltd.json +452 -0
- package/dist/app/data/hmrc/form-layouts/se.json +485 -0
- package/dist/app/data/hmrc/form-layouts/taxi.json +117 -0
- package/dist/app/data/hmrc/sa103-mtd-mapping.json +1078 -0
- package/dist/app/data/hmrc/sa103f_mapping_v3.csv +111 -0
- package/dist/app/data/judge-rubric.md +52 -0
- package/dist/app/data/ltd-2020.toml +49 -0
- package/dist/app/data/ltd-2021.toml +49 -0
- package/dist/app/data/ltd-2022.toml +49 -0
- package/dist/app/data/ltd-2023.toml +49 -0
- package/dist/app/data/ltd-2024.toml +49 -0
- package/dist/app/data/ltd-2025.toml +49 -0
- package/dist/app/data/ltd-2026.toml +53 -0
- package/dist/app/data/ltd-2027.toml +51 -0
- package/dist/app/data/render-unrepresentable/bst.json +24 -0
- package/dist/app/data/render-unrepresentable/ltd.json +863 -0
- package/dist/app/data/render-unrepresentable/se.json +455 -0
- package/dist/app/data/render-unrepresentable/taxi.json +16 -0
- package/dist/app/data/roundtrip-budget.json +38 -0
- package/dist/app/data/roundtrip-matrix-budget.json +26 -0
- package/dist/app/data/roundtrip-unrepresentable.json +401 -0
- package/dist/app/data/se-2020-2021.toml +52 -0
- package/dist/app/data/se-2021-2022.toml +52 -0
- package/dist/app/data/se-2022-2023.toml +55 -0
- package/dist/app/data/se-2023-2024.toml +54 -0
- package/dist/app/data/se-2024-2025.toml +51 -0
- package/dist/app/data/se-2025-2026.toml +51 -0
- package/dist/app/data/se-2026-2027.toml +51 -0
- package/dist/app/data/volatile-cells.json +16 -0
- package/dist/app/lib/anchors/bst.js +79 -0
- package/dist/app/lib/anchors/ltd.js +626 -0
- package/dist/app/lib/anchors/run.js +100 -0
- package/dist/app/lib/anchors/se.js +456 -0
- package/dist/app/lib/anchors/taxi.js +164 -0
- package/dist/app/lib/app-resources.js +80 -0
- package/dist/app/lib/book-checks/ltd.js +408 -0
- package/dist/app/lib/book-checks/se.js +687 -0
- package/dist/app/lib/book-checks/taxi.js +215 -0
- package/dist/app/lib/book-checks.js +872 -0
- package/dist/app/lib/books-engine.js +197 -0
- package/dist/app/lib/books-interchange.js +533 -0
- package/dist/app/lib/calculators/bst.js +381 -0
- package/dist/app/lib/calculators/ltd.js +1938 -0
- package/dist/app/lib/calculators/se.js +1239 -0
- package/dist/app/lib/calculators/shared.js +131 -0
- package/dist/app/lib/calculators/taxi.js +461 -0
- package/dist/app/lib/canonical-report-value.js +77 -0
- package/dist/app/lib/compliance-report.js +341 -0
- package/dist/app/lib/diya-gl-calculator.js +52 -0
- package/dist/app/lib/diya-gl-canonical.js +355 -0
- package/dist/app/lib/diya-gl-edits-ltd.js +144 -0
- package/dist/app/lib/diya-gl-edits.js +361 -0
- package/dist/app/lib/diya-gl-loader.js +774 -0
- package/dist/app/lib/diya-gl-schema.js +212 -0
- package/dist/app/lib/generator.js +1912 -0
- package/dist/app/lib/guide.js +33 -0
- package/dist/app/lib/headlines.js +293 -0
- package/dist/app/lib/link-caches.js +421 -0
- package/dist/app/lib/ltd-layout.js +139 -0
- package/dist/app/lib/mcp/diya-gl-tools.js +330 -0
- package/dist/app/lib/mcp/jsonrpc-stdio.js +66 -0
- package/dist/app/lib/mcp/server.js +65 -0
- package/dist/app/lib/overtype-sidecar.js +180 -0
- package/dist/app/lib/package-builder.js +202 -0
- package/dist/app/lib/payslips-date-chain.js +481 -0
- package/dist/app/lib/payslips-layout.js +235 -0
- package/dist/app/lib/period-shift.js +111 -0
- package/dist/app/lib/product-workbook.js +317 -0
- package/dist/app/lib/products.js +27 -0
- package/dist/app/lib/provenance-data.js +36 -0
- package/dist/app/lib/provenance.js +92 -0
- package/dist/app/lib/report-generator.js +374 -0
- package/dist/app/lib/report-indicators.js +468 -0
- package/dist/app/lib/report-serializer.js +392 -0
- package/dist/app/lib/scenario-extractor.js +1403 -0
- package/dist/app/lib/scenario-loader.js +84 -0
- package/dist/app/lib/sitemap-builder.js +59 -0
- package/dist/app/lib/spreadsheet-runner.js +566 -0
- package/dist/app/lib/tax/capital-allowances.js +77 -0
- package/dist/app/lib/tax/corporation-tax.js +144 -0
- package/dist/app/lib/tax/income-tax.js +122 -0
- package/dist/app/lib/tax/mileage.js +69 -0
- package/dist/app/lib/tax/national-insurance.js +31 -0
- package/dist/app/lib/tax/vat.js +188 -0
- package/dist/app/lib/tax-year.js +31 -0
- package/dist/app/lib/template-formula-map.js +253 -0
- package/dist/app/lib/workbook-set.js +153 -0
- package/dist/app/lib/xlsx-exporter.js +2815 -0
- package/dist/app/lib/xlsx-parts.js +111 -0
- package/dist/app/lib/xlsx-reader.js +84 -0
- package/dist/app/products/bst.js +727 -0
- package/dist/app/products/ltd.js +4270 -0
- package/dist/app/products/se.js +3403 -0
- package/dist/app/products/taxi.js +912 -0
- package/dist/app/templates/bst/bst-excel.xlsx +0 -0
- package/dist/app/templates/bst/meta.toml +27 -0
- package/dist/app/templates/ltd/Cashaccount.xlsx +0 -0
- package/dist/app/templates/ltd/Companysecretary.xlsx +0 -0
- package/dist/app/templates/ltd/Creditcardaccount.xlsx +0 -0
- package/dist/app/templates/ltd/Currentaccount.xlsx +0 -0
- package/dist/app/templates/ltd/Dividend Voucher.docx +0 -0
- package/dist/app/templates/ltd/Financialaccounts.xlsx +0 -0
- package/dist/app/templates/ltd/Fixedassets.xlsx +0 -0
- package/dist/app/templates/ltd/Payslips.xlsx +0 -0
- package/dist/app/templates/ltd/Purchases.xlsx +0 -0
- package/dist/app/templates/ltd/Sales.xlsx +0 -0
- package/dist/app/templates/ltd/Salesinvoice.xlsx +0 -0
- package/dist/app/templates/ltd/Savingaccount.xlsx +0 -0
- package/dist/app/templates/ltd/Vatreturns.xlsx +0 -0
- package/dist/app/templates/ltd/expensesform.xlsx +0 -0
- package/dist/app/templates/ltd/meta.toml +54 -0
- package/dist/app/templates/meta.toml +12 -0
- package/dist/app/templates/se/Bank.xlsx +0 -0
- package/dist/app/templates/se/Cash.xlsx +0 -0
- package/dist/app/templates/se/Financialaccounts.xlsx +0 -0
- package/dist/app/templates/se/Fixedassets.xlsx +0 -0
- package/dist/app/templates/se/Payslips.xlsx +0 -0
- package/dist/app/templates/se/Purchases.xlsx +0 -0
- package/dist/app/templates/se/Sales.xlsx +0 -0
- package/dist/app/templates/se/Salesinvoice.xlsx +0 -0
- package/dist/app/templates/se/Vat.xlsx +0 -0
- package/dist/app/templates/se/meta.toml +43 -0
- package/dist/app/templates/taxi/meta.toml +43 -0
- package/dist/app/templates/taxi/taxi-excel.xlsx +0 -0
- package/dist/web/spreadsheets.diyaccounting.co.uk/public/schema/diya-gl-book-v2.schema.json +713 -0
- package/dist/web/spreadsheets.diyaccounting.co.uk/public/schema/diya-gl-docs.md +930 -0
- package/dist/web/spreadsheets.diyaccounting.co.uk/public/schema/diya-gl-lines-v2.schema.json +220 -0
- package/package.json +37 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (C) 2026 DIY Accounting Ltd
|
|
3
|
+
//
|
|
4
|
+
// compliance-report.js — Pure parsers and report generator for compliance reports.
|
|
5
|
+
|
|
6
|
+
export function parseNpmAudit(auditJson) {
|
|
7
|
+
if (!auditJson) return { critical: 0, high: 0, moderate: 0, low: 0, info: 0, total: 0, found: false };
|
|
8
|
+
const vuln = auditJson.metadata?.vulnerabilities || {};
|
|
9
|
+
return {
|
|
10
|
+
critical: vuln.critical || 0,
|
|
11
|
+
high: vuln.high || 0,
|
|
12
|
+
moderate: vuln.moderate || 0,
|
|
13
|
+
low: vuln.low || 0,
|
|
14
|
+
info: vuln.info || 0,
|
|
15
|
+
total: vuln.total || 0,
|
|
16
|
+
found: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function parseEslintSecurity(eslintText) {
|
|
21
|
+
if (eslintText === null || eslintText === undefined) return { errors: 0, warnings: 0, found: false };
|
|
22
|
+
const summaryMatch = eslintText.match(/(\d+)\s+problems?\s+\((\d+)\s+errors?,\s*(\d+)\s+warnings?\)/);
|
|
23
|
+
if (summaryMatch) return { errors: parseInt(summaryMatch[2], 10), warnings: parseInt(summaryMatch[3], 10), found: true };
|
|
24
|
+
return { errors: 0, warnings: 0, found: true };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function parsePa11yReport(pa11yText) {
|
|
28
|
+
if (!pa11yText) return { passed: 0, failed: 0, total: 0, results: [], found: false };
|
|
29
|
+
const results = [];
|
|
30
|
+
const urlPattern = />\s+(https?:\/\/[^\s]+)\s+-\s+(\d+)\s+errors?/g;
|
|
31
|
+
let match;
|
|
32
|
+
while ((match = urlPattern.exec(pa11yText)) !== null) {
|
|
33
|
+
results.push({ url: match[1], errorCount: parseInt(match[2], 10) });
|
|
34
|
+
}
|
|
35
|
+
const summaryMatch = pa11yText.match(/(\d+)\s+of\s+(\d+)\s+URLs?\s+passed/);
|
|
36
|
+
const passed = summaryMatch ? parseInt(summaryMatch[1], 10) : results.filter((r) => r.errorCount === 0).length;
|
|
37
|
+
const total = summaryMatch ? parseInt(summaryMatch[2], 10) : results.length;
|
|
38
|
+
return { passed, failed: total - passed, total, results, found: true };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function parseAxeResults(axeJson) {
|
|
42
|
+
if (!axeJson || !Array.isArray(axeJson)) return { violations: 0, passes: 0, incomplete: 0, found: false };
|
|
43
|
+
let totalViolations = 0,
|
|
44
|
+
totalPasses = 0,
|
|
45
|
+
totalIncomplete = 0;
|
|
46
|
+
const violationDetails = [];
|
|
47
|
+
for (const result of axeJson) {
|
|
48
|
+
totalViolations += (result.violations || []).length;
|
|
49
|
+
totalPasses += (result.passes || []).length;
|
|
50
|
+
totalIncomplete += (result.incomplete || []).length;
|
|
51
|
+
for (const v of result.violations || []) {
|
|
52
|
+
violationDetails.push({ id: v.id, impact: v.impact, description: v.description, nodes: v.nodes?.length || 0 });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { violations: totalViolations, passes: totalPasses, incomplete: totalIncomplete, violationDetails, found: true };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function parseLighthouseResults(lighthouseJson) {
|
|
59
|
+
if (!lighthouseJson || !lighthouseJson.categories) return { performance: 0, accessibility: 0, bestPractices: 0, seo: 0, found: false };
|
|
60
|
+
const categories = lighthouseJson.categories;
|
|
61
|
+
return {
|
|
62
|
+
performance: Math.round((categories.performance?.score || 0) * 100),
|
|
63
|
+
accessibility: Math.round((categories.accessibility?.score || 0) * 100),
|
|
64
|
+
bestPractices: Math.round((categories["best-practices"]?.score || 0) * 100),
|
|
65
|
+
seo: Math.round((categories.seo?.score || 0) * 100),
|
|
66
|
+
found: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function parseTextSpacingResults(textSpacingJson) {
|
|
71
|
+
if (!textSpacingJson || !textSpacingJson.pages) return { passed: 0, failed: 0, total: 0, errors: 0, failedPages: [], found: false };
|
|
72
|
+
const summary = textSpacingJson.summary || {};
|
|
73
|
+
const failedPages = textSpacingJson.pages
|
|
74
|
+
.filter((p) => !p.passed && !p.error)
|
|
75
|
+
.map((p) => ({ url: p.url, clippedCount: p.clippedElements?.length || 0 }));
|
|
76
|
+
return {
|
|
77
|
+
passed: summary.passed || 0,
|
|
78
|
+
failed: summary.failed || 0,
|
|
79
|
+
total: summary.total || 0,
|
|
80
|
+
errors: summary.errors || 0,
|
|
81
|
+
failedPages,
|
|
82
|
+
found: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function parseRetireResults(retireJson) {
|
|
87
|
+
if (!retireJson) return { total: 0, high: 0, medium: 0, low: 0, found: false };
|
|
88
|
+
let high = 0,
|
|
89
|
+
medium = 0,
|
|
90
|
+
low = 0;
|
|
91
|
+
const results = Array.isArray(retireJson) ? retireJson : retireJson.data || [];
|
|
92
|
+
for (const result of results) {
|
|
93
|
+
for (const vuln of result.results || []) {
|
|
94
|
+
for (const v of vuln.vulnerabilities || []) {
|
|
95
|
+
const severity = (v.severity || "").toLowerCase();
|
|
96
|
+
if (severity === "high" || severity === "critical") high++;
|
|
97
|
+
else if (severity === "medium" || severity === "moderate") medium++;
|
|
98
|
+
else low++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { total: high + medium + low, high, medium, low, found: true };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function generateReport({
|
|
106
|
+
targetUrl,
|
|
107
|
+
version,
|
|
108
|
+
sourceFiles,
|
|
109
|
+
npmAudit,
|
|
110
|
+
eslint,
|
|
111
|
+
pa11y,
|
|
112
|
+
axe,
|
|
113
|
+
axeWcag22,
|
|
114
|
+
lighthouse,
|
|
115
|
+
textSpacing,
|
|
116
|
+
retire,
|
|
117
|
+
}) {
|
|
118
|
+
const sourceFilesSection = sourceFiles.map((sf) => ` ${sf.exists ? "+" : "-"} ${sf.path}`).join("\n");
|
|
119
|
+
const securityPass = npmAudit.critical === 0 && npmAudit.high === 0 && eslint.errors === 0;
|
|
120
|
+
const accessibilityPass = pa11y.failed === 0 && axe.violations === 0 && textSpacing.failed === 0;
|
|
121
|
+
const overallPass = securityPass && accessibilityPass;
|
|
122
|
+
const statusIcon = (pass) => (pass ? "PASS" : "FAIL");
|
|
123
|
+
|
|
124
|
+
return `# Compliance Report
|
|
125
|
+
|
|
126
|
+
**Application**: DIY Accounting Spreadsheets
|
|
127
|
+
**Version**: ${version}
|
|
128
|
+
**Target URL**: ${targetUrl}
|
|
129
|
+
**Overall Status**: ${statusIcon(overallPass)}
|
|
130
|
+
|
|
131
|
+
**Source Files**:
|
|
132
|
+
\`\`\`
|
|
133
|
+
${sourceFilesSection}
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Summary
|
|
139
|
+
|
|
140
|
+
| Check | Status | Summary |
|
|
141
|
+
|-------|--------|---------|
|
|
142
|
+
| npm audit (prod) | ${statusIcon(npmAudit.critical === 0 && npmAudit.high === 0)} | ${npmAudit.found ? `${npmAudit.critical} critical, ${npmAudit.high} high, ${npmAudit.moderate} moderate` : "Report not found"} |
|
|
143
|
+
| ESLint Security | ${statusIcon(eslint.errors === 0)} | ${eslint.found ? `${eslint.errors} errors, ${eslint.warnings} warnings` : "Report not found"} |
|
|
144
|
+
| retire.js | ${statusIcon(retire.high === 0)} | ${retire.found ? `${retire.high} high, ${retire.medium} medium, ${retire.low} low` : "Report not found"} |
|
|
145
|
+
| Pa11y (WCAG AA) | ${statusIcon(pa11y.failed === 0)} | ${pa11y.found ? `${pa11y.passed}/${pa11y.total} pages passed` : "Report not found"} |
|
|
146
|
+
| axe-core | ${statusIcon(axe.violations === 0)} | ${axe.found ? `${axe.violations} violations, ${axe.passes} passes` : "Report not found"} |
|
|
147
|
+
| axe-core (WCAG 2.2) | ${statusIcon(axeWcag22.violations === 0)} | ${axeWcag22.found ? `${axeWcag22.violations} violations, ${axeWcag22.passes} passes` : "Report not found"} |
|
|
148
|
+
| Lighthouse | ${statusIcon(lighthouse.accessibility >= 90)} | ${lighthouse.found ? `A11y: ${lighthouse.accessibility}%, Perf: ${lighthouse.performance}%, BP: ${lighthouse.bestPractices}%` : "Report not found"} |
|
|
149
|
+
| Text Spacing (1.4.12) | ${statusIcon(textSpacing.failed === 0)} | ${textSpacing.found ? `${textSpacing.passed}/${textSpacing.total} pages passed` : "Report not found"} |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 1. Security Checks
|
|
154
|
+
|
|
155
|
+
### 1.1 npm audit (Production Dependency Vulnerabilities)
|
|
156
|
+
|
|
157
|
+
Scanned with \`--omit=dev\` — only production dependencies affect compliance status.
|
|
158
|
+
|
|
159
|
+
${
|
|
160
|
+
npmAudit.found
|
|
161
|
+
? `| Severity | Count |
|
|
162
|
+
|----------|-------|
|
|
163
|
+
| Critical | ${npmAudit.critical} |
|
|
164
|
+
| High | ${npmAudit.high} |
|
|
165
|
+
| Moderate | ${npmAudit.moderate} |
|
|
166
|
+
| Low | ${npmAudit.low} |
|
|
167
|
+
| **Total** | **${npmAudit.total}** |
|
|
168
|
+
|
|
169
|
+
**Status**: ${statusIcon(npmAudit.critical === 0 && npmAudit.high === 0)} ${npmAudit.critical === 0 && npmAudit.high === 0 ? "No critical/high vulnerabilities in production dependencies" : "Critical/high vulnerabilities in production dependencies require attention"}`
|
|
170
|
+
: "Report not found: `web/spreadsheets.diyaccounting.co.uk/public/tests/penetration/npm-audit.json`"
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
### 1.2 ESLint Security Analysis
|
|
174
|
+
|
|
175
|
+
${
|
|
176
|
+
eslint.found
|
|
177
|
+
? `| Metric | Count |
|
|
178
|
+
|--------|-------|
|
|
179
|
+
| Errors | ${eslint.errors} |
|
|
180
|
+
| Warnings | ${eslint.warnings} |
|
|
181
|
+
|
|
182
|
+
**Status**: ${statusIcon(eslint.errors === 0)} ${eslint.errors === 0 ? "No security errors" : "Security errors require attention"}`
|
|
183
|
+
: "Report not found: `web/spreadsheets.diyaccounting.co.uk/public/tests/penetration/eslint-security.txt`"
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
### 1.3 retire.js (Known Vulnerabilities)
|
|
187
|
+
|
|
188
|
+
${
|
|
189
|
+
retire.found
|
|
190
|
+
? `| Severity | Count |
|
|
191
|
+
|----------|-------|
|
|
192
|
+
| High | ${retire.high} |
|
|
193
|
+
| Medium | ${retire.medium} |
|
|
194
|
+
| Low | ${retire.low} |
|
|
195
|
+
|
|
196
|
+
**Status**: ${statusIcon(retire.high === 0)} ${retire.high === 0 ? "No high severity vulnerabilities" : "High severity vulnerabilities require attention"}`
|
|
197
|
+
: "Report not found: `web/spreadsheets.diyaccounting.co.uk/public/tests/penetration/retire.json`"
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 2. Accessibility Checks
|
|
203
|
+
|
|
204
|
+
### 2.1 Pa11y (WCAG 2.1 Level AA)
|
|
205
|
+
|
|
206
|
+
${
|
|
207
|
+
pa11y.found
|
|
208
|
+
? `| Metric | Value |
|
|
209
|
+
|--------|-------|
|
|
210
|
+
| Pages Tested | ${pa11y.total} |
|
|
211
|
+
| Pages Passed | ${pa11y.passed} |
|
|
212
|
+
| Pages Failed | ${pa11y.failed} |
|
|
213
|
+
|
|
214
|
+
**Status**: ${statusIcon(pa11y.failed === 0)} ${pa11y.failed === 0 ? "All pages comply with WCAG AA" : "Some pages have accessibility issues"}
|
|
215
|
+
${
|
|
216
|
+
pa11y.results.length > 0
|
|
217
|
+
? `
|
|
218
|
+
#### Page Results
|
|
219
|
+
|
|
220
|
+
| Page | Errors |
|
|
221
|
+
|------|--------|
|
|
222
|
+
${pa11y.results.map((r) => `| ${r.url.replace(targetUrl, "") || "/"} | ${r.errorCount} |`).join("\n")}`
|
|
223
|
+
: ""
|
|
224
|
+
}`
|
|
225
|
+
: "Report not found: `web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/pa11y-report.txt`"
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
### 2.2 axe-core (Automated Accessibility)
|
|
229
|
+
|
|
230
|
+
${
|
|
231
|
+
axe.found
|
|
232
|
+
? `| Metric | Count |
|
|
233
|
+
|--------|-------|
|
|
234
|
+
| Violations | ${axe.violations} |
|
|
235
|
+
| Passes | ${axe.passes} |
|
|
236
|
+
| Incomplete | ${axe.incomplete} |
|
|
237
|
+
|
|
238
|
+
**Status**: ${statusIcon(axe.violations === 0)} ${axe.violations === 0 ? "No accessibility violations" : "Accessibility violations require attention"}
|
|
239
|
+
${
|
|
240
|
+
axe.violationDetails.length > 0
|
|
241
|
+
? `
|
|
242
|
+
#### Violations
|
|
243
|
+
|
|
244
|
+
| Rule | Impact | Description | Nodes |
|
|
245
|
+
|------|--------|-------------|-------|
|
|
246
|
+
${axe.violationDetails.map((v) => `| ${v.id} | ${v.impact} | ${v.description} | ${v.nodes} |`).join("\n")}`
|
|
247
|
+
: ""
|
|
248
|
+
}`
|
|
249
|
+
: "Report not found: `web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/axe-results.json`"
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
### 2.3 axe-core (WCAG 2.2 Level AA)
|
|
253
|
+
|
|
254
|
+
${
|
|
255
|
+
axeWcag22.found
|
|
256
|
+
? `| Metric | Count |
|
|
257
|
+
|--------|-------|
|
|
258
|
+
| Violations | ${axeWcag22.violations} |
|
|
259
|
+
| Passes | ${axeWcag22.passes} |
|
|
260
|
+
| Incomplete | ${axeWcag22.incomplete} |
|
|
261
|
+
|
|
262
|
+
**Status**: ${statusIcon(axeWcag22.violations === 0)} ${axeWcag22.violations === 0 ? "No WCAG 2.2 violations" : "WCAG 2.2 violations detected"}
|
|
263
|
+
${
|
|
264
|
+
axeWcag22.violationDetails.length > 0
|
|
265
|
+
? `
|
|
266
|
+
#### Violations
|
|
267
|
+
|
|
268
|
+
| Rule | Impact | Description | Nodes |
|
|
269
|
+
|------|--------|-------------|-------|
|
|
270
|
+
${axeWcag22.violationDetails.map((v) => `| ${v.id} | ${v.impact} | ${v.description} | ${v.nodes} |`).join("\n")}`
|
|
271
|
+
: ""
|
|
272
|
+
}`
|
|
273
|
+
: "Report not found: `web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/axe-wcag22-results.json`"
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
### 2.4 Lighthouse
|
|
277
|
+
|
|
278
|
+
${
|
|
279
|
+
lighthouse.found
|
|
280
|
+
? `| Category | Score |
|
|
281
|
+
|----------|-------|
|
|
282
|
+
| Accessibility | ${lighthouse.accessibility}% |
|
|
283
|
+
| Performance | ${lighthouse.performance}% |
|
|
284
|
+
| Best Practices | ${lighthouse.bestPractices}% |
|
|
285
|
+
| SEO | ${lighthouse.seo}% |
|
|
286
|
+
|
|
287
|
+
**Status**: ${statusIcon(lighthouse.accessibility >= 90)} ${lighthouse.accessibility >= 90 ? "Accessibility score meets threshold (90%+)" : "Accessibility score below 90% threshold"}`
|
|
288
|
+
: "Report not found: `web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/lighthouse-results.json`"
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
### 2.5 Text Spacing (WCAG 1.4.12)
|
|
292
|
+
|
|
293
|
+
${
|
|
294
|
+
textSpacing.found
|
|
295
|
+
? `| Metric | Value |
|
|
296
|
+
|--------|-------|
|
|
297
|
+
| Pages Tested | ${textSpacing.total} |
|
|
298
|
+
| Pages Passed | ${textSpacing.passed} |
|
|
299
|
+
| Pages Failed | ${textSpacing.failed} |
|
|
300
|
+
| Errors | ${textSpacing.errors} |
|
|
301
|
+
|
|
302
|
+
**Status**: ${statusIcon(textSpacing.failed === 0)} ${textSpacing.failed === 0 ? "All pages pass text spacing test" : "Some pages have text spacing issues"}
|
|
303
|
+
|
|
304
|
+
**Test Parameters** (WCAG 1.4.12 minimum values):
|
|
305
|
+
- Line height: 1.5 times font size
|
|
306
|
+
- Letter spacing: 0.12 times font size
|
|
307
|
+
- Word spacing: 0.16 times font size
|
|
308
|
+
- Paragraph spacing: 2 times font size
|
|
309
|
+
${
|
|
310
|
+
textSpacing.failedPages.length > 0
|
|
311
|
+
? `
|
|
312
|
+
#### Pages with Clipped Content
|
|
313
|
+
|
|
314
|
+
| Page | Clipped Elements |
|
|
315
|
+
|------|------------------|
|
|
316
|
+
${textSpacing.failedPages.map((p) => `| ${p.url.replace(targetUrl, "") || "/"} | ${p.clippedCount} |`).join("\n")}`
|
|
317
|
+
: ""
|
|
318
|
+
}`
|
|
319
|
+
: "Report not found: `web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/text-spacing-results.json`"
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 3. Report Files
|
|
325
|
+
|
|
326
|
+
| Report | Path | Status |
|
|
327
|
+
|--------|------|--------|
|
|
328
|
+
| npm audit | web/spreadsheets.diyaccounting.co.uk/public/tests/penetration/npm-audit.json | ${npmAudit.found ? "Found" : "Missing"} |
|
|
329
|
+
| ESLint Security | web/spreadsheets.diyaccounting.co.uk/public/tests/penetration/eslint-security.txt | ${eslint.found ? "Found" : "Missing"} |
|
|
330
|
+
| retire.js | web/spreadsheets.diyaccounting.co.uk/public/tests/penetration/retire.json | ${retire.found ? "Found" : "Missing"} |
|
|
331
|
+
| Pa11y | web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/pa11y-report.txt | ${pa11y.found ? "Found" : "Missing"} |
|
|
332
|
+
| axe-core | web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/axe-results.json | ${axe.found ? "Found" : "Missing"} |
|
|
333
|
+
| axe-core (WCAG 2.2) | web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/axe-wcag22-results.json | ${axeWcag22.found ? "Found" : "Missing"} |
|
|
334
|
+
| Lighthouse | web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/lighthouse-results.json | ${lighthouse.found ? "Found" : "Missing"} |
|
|
335
|
+
| Text Spacing | web/spreadsheets.diyaccounting.co.uk/public/tests/accessibility/text-spacing-results.json | ${textSpacing.found ? "Found" : "Missing"} |
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
*Generated by \`node app/bin/compliance-report.js --target ${targetUrl}\`*
|
|
340
|
+
`;
|
|
341
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (C) 2026 DIY Accounting Ltd
|
|
3
|
+
//
|
|
4
|
+
// diya-gl-calculator.js — Pure JS calculation engine that computes financial
|
|
5
|
+
// reports from diya-gl data, producing output identical to what Excel formulas compute.
|
|
6
|
+
//
|
|
7
|
+
// The output shape matches runSpreadsheet results: { "SheetName": { "CellRef": value } }
|
|
8
|
+
// so product modules' reportSections() and checkCompliance() work unchanged.
|
|
9
|
+
//
|
|
10
|
+
// Each product's calculation lives in its own module under app/lib/calculators/,
|
|
11
|
+
// so a track working on one product's arithmetic touches only its own file.
|
|
12
|
+
|
|
13
|
+
import { calculateBstResults } from "./calculators/bst.js";
|
|
14
|
+
import { calculateTaxiResults } from "./calculators/taxi.js";
|
|
15
|
+
import { calculateSeCells, calculateSeResults } from "./calculators/se.js";
|
|
16
|
+
import { calculateLtdCells, calculateLtdResults } from "./calculators/ltd.js";
|
|
17
|
+
|
|
18
|
+
export { aggregateByAccountAndMonth, annualTotal, sumValues, aggregateByCode } from "./calculators/shared.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Main entry point. Calculate financial reports from diya-gl data.
|
|
22
|
+
* @param {Object} book - parsed book.toml
|
|
23
|
+
* @param {Array} lines - parsed lines.jsonl entries
|
|
24
|
+
* @param {string} product - 'bst' | 'taxi' | 'se' | 'ltd'
|
|
25
|
+
* @param {Object} taxData - tax rates from app/data/*.toml format
|
|
26
|
+
* @param {Object} [scenario] - optional scenario with stock/debtors/creditors
|
|
27
|
+
* @returns {Object} { "SheetName": { "CellRef": value, ... }, ... }
|
|
28
|
+
*/
|
|
29
|
+
export function calculateFromDiyaGl(book, lines, product, taxData, scenario = {}) {
|
|
30
|
+
if (product === "bst") return calculateBstResults(book, lines, taxData, scenario);
|
|
31
|
+
if (product === "taxi") return calculateTaxiResults(book, lines, taxData, scenario);
|
|
32
|
+
if (product === "se") return calculateSeResults(book, lines, taxData, scenario);
|
|
33
|
+
if (product === "ltd") return calculateLtdResults(book, lines, taxData, scenario);
|
|
34
|
+
throw new Error(`Product "${product}" not yet supported by JS calculator`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Every cell a sibling workbook's external link addresses, for the products
|
|
39
|
+
* whose packages are more than one file. A single-file product has no links,
|
|
40
|
+
* so asking for its link cells is a bug rather than an empty answer.
|
|
41
|
+
* @param {Object} book - parsed book.toml
|
|
42
|
+
* @param {Array} lines - parsed lines.jsonl entries
|
|
43
|
+
* @param {string} product - 'se' | 'ltd'
|
|
44
|
+
* @param {Object} taxData - tax rates from app/data/*.toml format
|
|
45
|
+
* @param {Object} [scenario] - optional scenario with stock/debtors/creditors
|
|
46
|
+
* @returns {Object} { "SheetName": { "CellRef": value, ... }, ... }
|
|
47
|
+
*/
|
|
48
|
+
export function calculateLinkCells(book, lines, product, taxData, scenario = {}) {
|
|
49
|
+
if (product === "se") return calculateSeCells(book, lines, taxData, scenario);
|
|
50
|
+
if (product === "ltd") return calculateLtdCells(book, lines, taxData, scenario);
|
|
51
|
+
throw new Error(`Product "${product}" has no external link cells`);
|
|
52
|
+
}
|