@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.
Files changed (157) hide show
  1. package/README.md +63 -0
  2. package/bin/diya-gl-mcp.js +10 -0
  3. package/bin/diya-gl-read-workbook.js +11 -0
  4. package/bin/diya-gl-recalc.js +10 -0
  5. package/bin/diya-gl-write-workbook.js +12 -0
  6. package/bin/diya-gl.js +24 -0
  7. package/bin/run-dist-bin.js +23 -0
  8. package/dist/app/bin/build-diya-gl-spec.js +680 -0
  9. package/dist/app/bin/build-packages.js +149 -0
  10. package/dist/app/bin/build-reconciliation-pages.js +1052 -0
  11. package/dist/app/bin/build-sitemaps.js +51 -0
  12. package/dist/app/bin/compliance-report.js +125 -0
  13. package/dist/app/bin/cross-package-reconciliation.js +92 -0
  14. package/dist/app/bin/diya-gl-mcp.js +27 -0
  15. package/dist/app/bin/export.js +318 -0
  16. package/dist/app/bin/extract-scenarios.js +1348 -0
  17. package/dist/app/bin/generate.js +353 -0
  18. package/dist/app/bin/judge-reconciliation.js +649 -0
  19. package/dist/app/bin/reconcile.js +247 -0
  20. package/dist/app/bin/report.js +291 -0
  21. package/dist/app/bin/verify-roundtrip.js +941 -0
  22. package/dist/app/bin/verify-stability.js +429 -0
  23. package/dist/app/bin/write-workbook.js +106 -0
  24. package/dist/app/data/filing/ct-computation-v1.1.toml +1033 -0
  25. package/dist/app/data/filing/ct600-v3.toml +2329 -0
  26. package/dist/app/data/filing/frs105-formats.toml +244 -0
  27. package/dist/app/data/fixture-master-gaps.json +247 -0
  28. package/dist/app/data/hmrc/SOURCE.md +14 -0
  29. package/dist/app/data/hmrc/form-layouts/bst.json +116 -0
  30. package/dist/app/data/hmrc/form-layouts/ltd.json +452 -0
  31. package/dist/app/data/hmrc/form-layouts/se.json +485 -0
  32. package/dist/app/data/hmrc/form-layouts/taxi.json +117 -0
  33. package/dist/app/data/hmrc/sa103-mtd-mapping.json +1078 -0
  34. package/dist/app/data/hmrc/sa103f_mapping_v3.csv +111 -0
  35. package/dist/app/data/judge-rubric.md +52 -0
  36. package/dist/app/data/ltd-2020.toml +49 -0
  37. package/dist/app/data/ltd-2021.toml +49 -0
  38. package/dist/app/data/ltd-2022.toml +49 -0
  39. package/dist/app/data/ltd-2023.toml +49 -0
  40. package/dist/app/data/ltd-2024.toml +49 -0
  41. package/dist/app/data/ltd-2025.toml +49 -0
  42. package/dist/app/data/ltd-2026.toml +53 -0
  43. package/dist/app/data/ltd-2027.toml +51 -0
  44. package/dist/app/data/render-unrepresentable/bst.json +24 -0
  45. package/dist/app/data/render-unrepresentable/ltd.json +863 -0
  46. package/dist/app/data/render-unrepresentable/se.json +455 -0
  47. package/dist/app/data/render-unrepresentable/taxi.json +16 -0
  48. package/dist/app/data/roundtrip-budget.json +38 -0
  49. package/dist/app/data/roundtrip-matrix-budget.json +26 -0
  50. package/dist/app/data/roundtrip-unrepresentable.json +401 -0
  51. package/dist/app/data/se-2020-2021.toml +52 -0
  52. package/dist/app/data/se-2021-2022.toml +52 -0
  53. package/dist/app/data/se-2022-2023.toml +55 -0
  54. package/dist/app/data/se-2023-2024.toml +54 -0
  55. package/dist/app/data/se-2024-2025.toml +51 -0
  56. package/dist/app/data/se-2025-2026.toml +51 -0
  57. package/dist/app/data/se-2026-2027.toml +51 -0
  58. package/dist/app/data/volatile-cells.json +16 -0
  59. package/dist/app/lib/anchors/bst.js +79 -0
  60. package/dist/app/lib/anchors/ltd.js +626 -0
  61. package/dist/app/lib/anchors/run.js +100 -0
  62. package/dist/app/lib/anchors/se.js +456 -0
  63. package/dist/app/lib/anchors/taxi.js +164 -0
  64. package/dist/app/lib/app-resources.js +80 -0
  65. package/dist/app/lib/book-checks/ltd.js +408 -0
  66. package/dist/app/lib/book-checks/se.js +687 -0
  67. package/dist/app/lib/book-checks/taxi.js +215 -0
  68. package/dist/app/lib/book-checks.js +872 -0
  69. package/dist/app/lib/books-engine.js +197 -0
  70. package/dist/app/lib/books-interchange.js +533 -0
  71. package/dist/app/lib/calculators/bst.js +381 -0
  72. package/dist/app/lib/calculators/ltd.js +1938 -0
  73. package/dist/app/lib/calculators/se.js +1239 -0
  74. package/dist/app/lib/calculators/shared.js +131 -0
  75. package/dist/app/lib/calculators/taxi.js +461 -0
  76. package/dist/app/lib/canonical-report-value.js +77 -0
  77. package/dist/app/lib/compliance-report.js +341 -0
  78. package/dist/app/lib/diya-gl-calculator.js +52 -0
  79. package/dist/app/lib/diya-gl-canonical.js +355 -0
  80. package/dist/app/lib/diya-gl-edits-ltd.js +144 -0
  81. package/dist/app/lib/diya-gl-edits.js +361 -0
  82. package/dist/app/lib/diya-gl-loader.js +774 -0
  83. package/dist/app/lib/diya-gl-schema.js +212 -0
  84. package/dist/app/lib/generator.js +1912 -0
  85. package/dist/app/lib/guide.js +33 -0
  86. package/dist/app/lib/headlines.js +293 -0
  87. package/dist/app/lib/link-caches.js +421 -0
  88. package/dist/app/lib/ltd-layout.js +139 -0
  89. package/dist/app/lib/mcp/diya-gl-tools.js +330 -0
  90. package/dist/app/lib/mcp/jsonrpc-stdio.js +66 -0
  91. package/dist/app/lib/mcp/server.js +65 -0
  92. package/dist/app/lib/overtype-sidecar.js +180 -0
  93. package/dist/app/lib/package-builder.js +202 -0
  94. package/dist/app/lib/payslips-date-chain.js +481 -0
  95. package/dist/app/lib/payslips-layout.js +235 -0
  96. package/dist/app/lib/period-shift.js +111 -0
  97. package/dist/app/lib/product-workbook.js +317 -0
  98. package/dist/app/lib/products.js +27 -0
  99. package/dist/app/lib/provenance-data.js +36 -0
  100. package/dist/app/lib/provenance.js +92 -0
  101. package/dist/app/lib/report-generator.js +374 -0
  102. package/dist/app/lib/report-indicators.js +468 -0
  103. package/dist/app/lib/report-serializer.js +392 -0
  104. package/dist/app/lib/scenario-extractor.js +1403 -0
  105. package/dist/app/lib/scenario-loader.js +84 -0
  106. package/dist/app/lib/sitemap-builder.js +59 -0
  107. package/dist/app/lib/spreadsheet-runner.js +566 -0
  108. package/dist/app/lib/tax/capital-allowances.js +77 -0
  109. package/dist/app/lib/tax/corporation-tax.js +144 -0
  110. package/dist/app/lib/tax/income-tax.js +122 -0
  111. package/dist/app/lib/tax/mileage.js +69 -0
  112. package/dist/app/lib/tax/national-insurance.js +31 -0
  113. package/dist/app/lib/tax/vat.js +188 -0
  114. package/dist/app/lib/tax-year.js +31 -0
  115. package/dist/app/lib/template-formula-map.js +253 -0
  116. package/dist/app/lib/workbook-set.js +153 -0
  117. package/dist/app/lib/xlsx-exporter.js +2815 -0
  118. package/dist/app/lib/xlsx-parts.js +111 -0
  119. package/dist/app/lib/xlsx-reader.js +84 -0
  120. package/dist/app/products/bst.js +727 -0
  121. package/dist/app/products/ltd.js +4270 -0
  122. package/dist/app/products/se.js +3403 -0
  123. package/dist/app/products/taxi.js +912 -0
  124. package/dist/app/templates/bst/bst-excel.xlsx +0 -0
  125. package/dist/app/templates/bst/meta.toml +27 -0
  126. package/dist/app/templates/ltd/Cashaccount.xlsx +0 -0
  127. package/dist/app/templates/ltd/Companysecretary.xlsx +0 -0
  128. package/dist/app/templates/ltd/Creditcardaccount.xlsx +0 -0
  129. package/dist/app/templates/ltd/Currentaccount.xlsx +0 -0
  130. package/dist/app/templates/ltd/Dividend Voucher.docx +0 -0
  131. package/dist/app/templates/ltd/Financialaccounts.xlsx +0 -0
  132. package/dist/app/templates/ltd/Fixedassets.xlsx +0 -0
  133. package/dist/app/templates/ltd/Payslips.xlsx +0 -0
  134. package/dist/app/templates/ltd/Purchases.xlsx +0 -0
  135. package/dist/app/templates/ltd/Sales.xlsx +0 -0
  136. package/dist/app/templates/ltd/Salesinvoice.xlsx +0 -0
  137. package/dist/app/templates/ltd/Savingaccount.xlsx +0 -0
  138. package/dist/app/templates/ltd/Vatreturns.xlsx +0 -0
  139. package/dist/app/templates/ltd/expensesform.xlsx +0 -0
  140. package/dist/app/templates/ltd/meta.toml +54 -0
  141. package/dist/app/templates/meta.toml +12 -0
  142. package/dist/app/templates/se/Bank.xlsx +0 -0
  143. package/dist/app/templates/se/Cash.xlsx +0 -0
  144. package/dist/app/templates/se/Financialaccounts.xlsx +0 -0
  145. package/dist/app/templates/se/Fixedassets.xlsx +0 -0
  146. package/dist/app/templates/se/Payslips.xlsx +0 -0
  147. package/dist/app/templates/se/Purchases.xlsx +0 -0
  148. package/dist/app/templates/se/Sales.xlsx +0 -0
  149. package/dist/app/templates/se/Salesinvoice.xlsx +0 -0
  150. package/dist/app/templates/se/Vat.xlsx +0 -0
  151. package/dist/app/templates/se/meta.toml +43 -0
  152. package/dist/app/templates/taxi/meta.toml +43 -0
  153. package/dist/app/templates/taxi/taxi-excel.xlsx +0 -0
  154. package/dist/web/spreadsheets.diyaccounting.co.uk/public/schema/diya-gl-book-v2.schema.json +713 -0
  155. package/dist/web/spreadsheets.diyaccounting.co.uk/public/schema/diya-gl-docs.md +930 -0
  156. package/dist/web/spreadsheets.diyaccounting.co.uk/public/schema/diya-gl-lines-v2.schema.json +220 -0
  157. package/package.json +37 -0
@@ -0,0 +1,220 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://spreadsheets.diyaccounting.co.uk/schema/diya-gl-lines-v2.schema.json",
4
+ "title": "DIY Accounting GL-aligned Transaction Lines (v2)",
5
+ "description": "A single financial transaction record. Field names adapted from XBRL Global Ledger Taxonomy Framework 2015 (gl-cor, gl-bus, gl-muc, gl-taf modules). Reference: http://www.xbrl.org/int/gl/2015-03-25/gl-framework-REC-2015-03-25.html. v2 makes debitCreditCode required on journal lines and adds the fields that link a line to the book's asset, hire purchase and member registers.",
6
+ "type": "object",
7
+ "required": ["postingDate", "amount", "accountMainID", "sourceJournalID"],
8
+ "additionalProperties": false,
9
+ "allOf": [
10
+ {
11
+ "if": {
12
+ "required": ["sourceJournalID"],
13
+ "properties": { "sourceJournalID": { "const": "journal" } }
14
+ },
15
+ "then": { "required": ["debitCreditCode"] }
16
+ }
17
+ ],
18
+ "properties": {
19
+ "entryNumber": {
20
+ "type": "string",
21
+ "description": "gl-cor:entryNumber — Unique transaction identifier within this book"
22
+ },
23
+ "lineNumber": {
24
+ "type": "integer",
25
+ "minimum": 1,
26
+ "description": "gl-cor:lineNumber — Line within a multi-line journal entry (Company Accounts only)"
27
+ },
28
+ "sourceJournalID": {
29
+ "type": "string",
30
+ "enum": ["sales", "purchases", "bank", "journal", "payroll", "petty-cash"],
31
+ "description": "gl-cor:sourceJournalID — Which journal/daybook this belongs to"
32
+ },
33
+ "enteredDate": {
34
+ "type": "string",
35
+ "format": "date",
36
+ "description": "gl-cor:enteredDate — Date keyed (ISO 8601)"
37
+ },
38
+ "enteredBy": {
39
+ "type": "string",
40
+ "description": "gl-cor:enteredBy — User or system that entered the transaction"
41
+ },
42
+ "postingDate": {
43
+ "type": "string",
44
+ "format": "date",
45
+ "description": "gl-cor:postingDate — Tax-relevant date (ISO 8601)"
46
+ },
47
+ "accountMainID": {
48
+ "type": "string",
49
+ "description": "gl-cor:accountMainID — Nominal code from the chart of accounts in book.toml. Must name an account the book declares; enforced by the validator, not this schema."
50
+ },
51
+ "accountMainDescription": {
52
+ "type": "string",
53
+ "description": "gl-cor:accountMainDescription — Human-readable account name"
54
+ },
55
+ "accountSubID": {
56
+ "type": "string",
57
+ "description": "gl-cor:accountSubID — Sub-account or department code"
58
+ },
59
+ "accountSubDescription": {
60
+ "type": "string",
61
+ "description": "gl-cor:accountSubDescription — Sub-account description"
62
+ },
63
+ "debitCreditCode": {
64
+ "type": "string",
65
+ "enum": ["D", "C"],
66
+ "description": "gl-cor:debitCreditCode — D=Debit, C=Credit. Required on journal lines, because a journal line's sign is otherwise ambiguous."
67
+ },
68
+ "amount": {
69
+ "type": "number",
70
+ "minimum": 0,
71
+ "description": "gl-cor:amount — Always positive, penny precision"
72
+ },
73
+ "amountCurrency": {
74
+ "type": "string",
75
+ "pattern": "^[A-Z]{3}$",
76
+ "default": "GBP",
77
+ "description": "gl-muc:amountCurrency — ISO 4217 currency code"
78
+ },
79
+ "documentType": {
80
+ "type": "string",
81
+ "enum": ["invoice", "credit-note", "receipt", "bank-statement", "journal", "payslip", "mileage-log", "other"],
82
+ "description": "gl-cor:documentType — Type of source document"
83
+ },
84
+ "documentReference": {
85
+ "type": "string",
86
+ "description": "gl-cor:documentReference — Invoice/receipt number"
87
+ },
88
+ "documentNumber": {
89
+ "type": "string",
90
+ "description": "gl-cor:documentNumber — Internal document number"
91
+ },
92
+ "documentDate": {
93
+ "type": "string",
94
+ "format": "date",
95
+ "description": "gl-cor:documentDate — Date on source document (ISO 8601)"
96
+ },
97
+ "detailComment": {
98
+ "type": "string",
99
+ "description": "gl-cor:detailComment — Customer/supplier name or narrative"
100
+ },
101
+ "lineItemComment": {
102
+ "type": "string",
103
+ "description": "Adapted from gl-cor:detailComment — Description of goods/services"
104
+ },
105
+ "postingStatus": {
106
+ "type": "string",
107
+ "enum": ["posted", "draft", "voided"],
108
+ "description": "gl-cor:postingStatus — Entry status"
109
+ },
110
+ "taxCode": {
111
+ "type": "string",
112
+ "enum": ["S", "R", "Z", "E", "OS", "RC", "NA"],
113
+ "description": "gl-taf — UK VAT code: S=Standard, R=Reduced, Z=Zero, E=Exempt, OS=Outside Scope, RC=Reverse Charge, NA=Not Applicable"
114
+ },
115
+ "taxAmount": {
116
+ "type": "number",
117
+ "minimum": 0,
118
+ "description": "gl-cor:taxAmount — VAT amount, always positive"
119
+ },
120
+ "taxRate": {
121
+ "type": "number",
122
+ "minimum": 0,
123
+ "maximum": 1,
124
+ "description": "gl-taf:taxRate — VAT rate as decimal (0.20 = 20%)"
125
+ },
126
+ "taxPointDate": {
127
+ "type": "string",
128
+ "format": "date",
129
+ "description": "gl-taf:taxPointDate — VAT tax point if different from postingDate"
130
+ },
131
+ "taxDescription": {
132
+ "type": "string",
133
+ "description": "gl-cor:taxDescription — Human-readable tax description"
134
+ },
135
+ "paymentMethod": {
136
+ "type": "string",
137
+ "enum": ["bank-transfer", "cash", "cheque", "debit-card", "credit-card", "direct-debit", "standing-order", "online-payment", "other"],
138
+ "description": "gl-bus:paymentMethod — How payment was made/received"
139
+ },
140
+ "measurableQuantity": {
141
+ "type": "number",
142
+ "description": "gl-bus:measurableQuantity — Non-monetary quantity (miles, hours, units)"
143
+ },
144
+ "measurableUnitOfMeasure": {
145
+ "type": "string",
146
+ "enum": ["miles", "km", "hours", "units", "litres", "other"],
147
+ "description": "gl-bus:measurableUnitOfMeasure — Unit for measurableQuantity"
148
+ },
149
+ "measurableDescription": {
150
+ "type": "string",
151
+ "description": "gl-bus:measurableQualifier — What is being measured"
152
+ },
153
+ "diya-gl:bankCode": {
154
+ "type": "string",
155
+ "enum": ["BB", "BS", "BC", "BD", "DR", "CR", "K", "LDR", "LCR", "RV", "RC", "RT", "RP", "W", "B", "J", "DV", "DL", "X"],
156
+ "description": "diya-gl: extension — Bank receipt/payment code, matching the analysis columns of the bank account workbooks. Transfers between accounts carry the letter of the account on the other side: BB=current, BS=savings, BC=cash, BD=credit card. Receipt only: K=interest received. Payment only: W=net wages, B=bank charges, J=interest paid, DV=dividend, RP=HMRC PAYE, RT=HMRC corporation tax. Either side: DR=trade debtor, CR=trade creditor, LDR=long term debtor, LCR=long term creditor, RV=HMRC VAT, RC=HMRC CIS, DL=directors loan, X=bank contra item. BC on a bank line with no other account on the other side is the workbook's own opening balance."
157
+ },
158
+ "diya-gl:bankAccountID": {
159
+ "type": "string",
160
+ "description": "diya-gl: extension — Bank account code from book.toml accounts.bank (e.g. 1200=current, 1210=savings). Identifies which bank workbook this transaction belongs to."
161
+ },
162
+ "diya-gl:employeeID": {
163
+ "type": "string",
164
+ "description": "diya-gl: extension — Employee identifier matching employees[] in book.toml. Used for payroll lines (sourceJournalID=payroll)."
165
+ },
166
+ "diya-gl:grossPay": {
167
+ "type": "number",
168
+ "minimum": 0,
169
+ "description": "diya-gl: extension — Gross pay for this payroll period. Payroll lines only."
170
+ },
171
+ "diya-gl:incomeTax": {
172
+ "type": "number",
173
+ "minimum": 0,
174
+ "description": "diya-gl: extension — PAYE income tax deducted. Payroll lines only."
175
+ },
176
+ "diya-gl:employeeNI": {
177
+ "type": "number",
178
+ "minimum": 0,
179
+ "description": "diya-gl: extension — Employee National Insurance deducted. Payroll lines only."
180
+ },
181
+ "diya-gl:employerNI": {
182
+ "type": "number",
183
+ "minimum": 0,
184
+ "description": "diya-gl: extension — Employer National Insurance contribution. Payroll lines only."
185
+ },
186
+ "diya-gl:netPay": {
187
+ "type": "number",
188
+ "minimum": 0,
189
+ "description": "diya-gl: extension — Net pay (gross - tax - employee NI). Payroll lines only."
190
+ },
191
+ "diya-gl:cisDeduction": {
192
+ "type": "number",
193
+ "minimum": 0,
194
+ "description": "diya-gl: extension — CIS deduction amount withheld from sub-contractor payment. Purchases lines with CIS sub-contractors only."
195
+ },
196
+ "diya-gl:hpAgreement": {
197
+ "type": "string",
198
+ "description": "diya-gl: extension — Reference of the hire purchase agreement that finances this purchase, matching an id on book.toml hpAgreements[]. A purchase carrying one reaches the books as an ordinary trade creditor; the year-end journal then moves the amount financed onto creditors falling due after more than one year."
199
+ },
200
+ "diya-gl:cisRate": {
201
+ "type": "number",
202
+ "minimum": 0,
203
+ "maximum": 1,
204
+ "description": "diya-gl: extension — CIS deduction rate (0.20=20% standard, 0.30=30% higher, 0=gross payment). CIS lines only."
205
+ },
206
+ "diya-gl:vatPeriodEnd": {
207
+ "type": "string",
208
+ "format": "date",
209
+ "description": "diya-gl: extension — The VAT return period this line is declared on, when that period falls outside the accounting year the book covers. This is what makes a straddling entry representable: the line's postingDate sits in one accounting year, but its VAT is due on the return ending vatPeriodEnd."
210
+ },
211
+ "diya-gl:assetID": {
212
+ "type": "string",
213
+ "description": "diya-gl: extension — The book.toml fixedAssets[] id this line moves: a capital purchase that registers the asset, or a disposal (an 'fs'-coded sale) that removes it."
214
+ },
215
+ "diya-gl:memberID": {
216
+ "type": "string",
217
+ "description": "diya-gl: extension — The book.toml members[] id a dividend payment line settles."
218
+ }
219
+ }
220
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@diy-accounting-uk/diya-gl",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Recalculate, read and write diya-gl books: a UK sole trader or company's accounts, reconciled the same way in a browser, a CLI and an MCP server.",
6
+ "license": "AGPL-3.0-only",
7
+ "homepage": "https://spreadsheets.diyaccounting.co.uk/diya-gl.html",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/diy-accounting-uk/spreadsheets.diyaccounting.co.uk.git",
11
+ "directory": "diya-gl"
12
+ },
13
+ "keywords": ["accounting", "bookkeeping", "uk-tax", "mtd", "diya-gl", "self-assessment"],
14
+ "bin": {
15
+ "diya-gl": "bin/diya-gl.js",
16
+ "diya-gl-recalc": "bin/diya-gl-recalc.js",
17
+ "diya-gl-read-workbook": "bin/diya-gl-read-workbook.js",
18
+ "diya-gl-write-workbook": "bin/diya-gl-write-workbook.js",
19
+ "diya-gl-mcp": "bin/diya-gl-mcp.js"
20
+ },
21
+ "files": ["bin/", "dist/", "README.md"],
22
+ "scripts": {
23
+ "prepack": "node scripts/prepack.mjs"
24
+ },
25
+ "dependencies": {
26
+ "ajv": "^8.20.0",
27
+ "ajv-formats": "^3.0.1",
28
+ "jszip": "^3.10.1",
29
+ "smol-toml": "^1.8.0"
30
+ },
31
+ "engines": {
32
+ "node": ">=24.0.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }