shutro-erp 0.2.0 → 0.3.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 (232) hide show
  1. package/README.md +17 -10
  2. package/dist/account_portal/.kosh/bindings.d.ts +22 -0
  3. package/dist/account_portal/.kosh/bindings.js +15 -0
  4. package/dist/account_portal/.kosh/schema.d.ts +1350 -0
  5. package/dist/account_portal/index.d.ts +3 -0
  6. package/dist/account_portal/index.js +73 -0
  7. package/dist/account_portal/module.d.ts +5983 -0
  8. package/dist/account_portal/module.js +18 -0
  9. package/dist/accounting/.kosh/bindings.js +1 -1
  10. package/dist/accounting/.kosh/schema.d.ts +142 -9
  11. package/dist/accounting/chart.d.ts +40 -8
  12. package/dist/accounting/chart.js +124 -30
  13. package/dist/accounting/closing.d.ts +6 -1
  14. package/dist/accounting/closing.js +5 -1
  15. package/dist/accounting/demo.js +6 -5
  16. package/dist/accounting/index.d.ts +3 -3
  17. package/dist/accounting/index.js +200 -23
  18. package/dist/accounting/module.d.ts +3326 -1086
  19. package/dist/accounting/module.js +408 -66
  20. package/dist/accounting/payments.d.ts +25 -0
  21. package/dist/accounting/payments.js +96 -4
  22. package/dist/accounting/web/RegisterPayment.d.ts +3 -2
  23. package/dist/accounting/web/RegisterPayment.js +39 -6
  24. package/dist/accounting/web/SettingsPage.js +5 -1
  25. package/dist/accounting/web/messages.js +10 -0
  26. package/dist/cli/index.d.ts +1 -1
  27. package/dist/cli/index.js +1 -1
  28. package/dist/cli/init.d.ts +5 -0
  29. package/dist/cli/init.js +195 -53
  30. package/dist/cli/launch.d.ts +16 -0
  31. package/dist/cli/launch.js +138 -0
  32. package/dist/cli/prompt.d.ts +35 -0
  33. package/dist/cli/prompt.js +46 -0
  34. package/dist/cli/templates.d.ts +11 -3
  35. package/dist/cli/templates.js +32 -7
  36. package/dist/cli/tui.d.ts +7 -0
  37. package/dist/cli/tui.js +254 -0
  38. package/dist/cli/ui.d.ts +25 -5
  39. package/dist/cli/ui.js +49 -9
  40. package/dist/contacts/.kosh/bindings.js +1 -1
  41. package/dist/contacts/.kosh/schema.d.ts +3 -1
  42. package/dist/contacts/index.js +24 -1
  43. package/dist/contacts/module.d.ts +42 -0
  44. package/dist/contacts/module.js +3 -1
  45. package/dist/import/convert.d.ts +55 -0
  46. package/dist/import/convert.js +224 -0
  47. package/dist/import/csv.d.ts +28 -0
  48. package/dist/import/csv.js +115 -0
  49. package/dist/import/index.d.ts +33 -0
  50. package/dist/import/index.js +60 -0
  51. package/dist/import/mapping.d.ts +15 -0
  52. package/dist/import/mapping.js +33 -0
  53. package/dist/import/match.d.ts +24 -0
  54. package/dist/import/match.js +60 -0
  55. package/dist/import/models.d.ts +2 -0
  56. package/dist/import/models.js +102 -0
  57. package/dist/import/routes.d.ts +13 -0
  58. package/dist/import/routes.js +392 -0
  59. package/dist/import/run.d.ts +131 -0
  60. package/dist/import/run.js +568 -0
  61. package/dist/import/service.d.ts +153 -0
  62. package/dist/import/service.js +367 -0
  63. package/dist/import/web/ImportButton.d.ts +7 -0
  64. package/dist/import/web/ImportButton.js +31 -0
  65. package/dist/import/web/ImportWizard.d.ts +75 -0
  66. package/dist/import/web/ImportWizard.js +217 -0
  67. package/dist/import/web/index.d.ts +13 -0
  68. package/dist/import/web/index.js +18 -0
  69. package/dist/import/web/messages.d.ts +2 -0
  70. package/dist/import/web/messages.js +139 -0
  71. package/dist/import/worker.d.ts +3 -0
  72. package/dist/import/worker.js +52 -0
  73. package/dist/import/xlsx.d.ts +20 -0
  74. package/dist/import/xlsx.js +192 -0
  75. package/dist/l10n_bd/.kosh/bindings.d.ts +22 -0
  76. package/dist/l10n_bd/.kosh/bindings.js +15 -0
  77. package/dist/l10n_bd/.kosh/schema.d.ts +1281 -0
  78. package/dist/l10n_bd/documents.d.ts +8 -0
  79. package/dist/l10n_bd/documents.js +183 -0
  80. package/dist/l10n_bd/index.d.ts +8 -0
  81. package/dist/l10n_bd/index.js +156 -0
  82. package/dist/l10n_bd/module.d.ts +5705 -0
  83. package/dist/l10n_bd/module.js +163 -0
  84. package/dist/l10n_bd/mushak.d.ts +67 -0
  85. package/dist/l10n_bd/mushak.js +139 -0
  86. package/dist/l10n_bd/routes.d.ts +3 -0
  87. package/dist/l10n_bd/routes.js +205 -0
  88. package/dist/l10n_bd/web/MushakPage.d.ts +7 -0
  89. package/dist/l10n_bd/web/MushakPage.js +53 -0
  90. package/dist/l10n_bd/web/index.d.ts +13 -0
  91. package/dist/l10n_bd/web/index.js +18 -0
  92. package/dist/l10n_bd/web/messages.d.ts +2 -0
  93. package/dist/l10n_bd/web/messages.js +101 -0
  94. package/dist/l10n_in/.kosh/bindings.d.ts +22 -0
  95. package/dist/l10n_in/.kosh/bindings.js +15 -0
  96. package/dist/l10n_in/.kosh/schema.d.ts +1343 -0
  97. package/dist/l10n_in/documents.d.ts +8 -0
  98. package/dist/l10n_in/documents.js +114 -0
  99. package/dist/l10n_in/einvoice.d.ts +253 -0
  100. package/dist/l10n_in/einvoice.js +485 -0
  101. package/dist/l10n_in/gstr.d.ts +109 -0
  102. package/dist/l10n_in/gstr.js +430 -0
  103. package/dist/l10n_in/index.d.ts +20 -0
  104. package/dist/l10n_in/index.js +232 -0
  105. package/dist/l10n_in/module.d.ts +7823 -0
  106. package/dist/l10n_in/module.js +427 -0
  107. package/dist/l10n_in/routes-einvoice.d.ts +15 -0
  108. package/dist/l10n_in/routes-einvoice.js +124 -0
  109. package/dist/l10n_in/routes.d.ts +17 -0
  110. package/dist/l10n_in/routes.js +282 -0
  111. package/dist/l10n_in/web/EInvoicePanel.d.ts +8 -0
  112. package/dist/l10n_in/web/EInvoicePanel.js +63 -0
  113. package/dist/l10n_in/web/GstPage.d.ts +7 -0
  114. package/dist/l10n_in/web/GstPage.js +57 -0
  115. package/dist/l10n_in/web/GstSettings.d.ts +10 -0
  116. package/dist/l10n_in/web/GstSettings.js +36 -0
  117. package/dist/l10n_in/web/index.d.ts +15 -0
  118. package/dist/l10n_in/web/index.js +22 -0
  119. package/dist/l10n_in/web/messages.d.ts +2 -0
  120. package/dist/l10n_in/web/messages.js +166 -0
  121. package/dist/modules-sdk/demo.d.ts +2 -0
  122. package/dist/modules-sdk/demo.js +7 -3
  123. package/dist/modules-sdk/index.d.ts +2 -2
  124. package/dist/modules-sdk/index.js +1 -1
  125. package/dist/modules-sdk/manifest.d.ts +132 -0
  126. package/dist/modules-sdk/manifest.js +22 -0
  127. package/dist/notify/inbox.js +21 -0
  128. package/dist/notify/messages.js +4 -0
  129. package/dist/notify/models.d.ts +1 -1
  130. package/dist/notify/models.js +2 -0
  131. package/dist/notify/web/messages.js +4 -0
  132. package/dist/portal/.kosh/bindings.d.ts +22 -0
  133. package/dist/portal/.kosh/bindings.js +15 -0
  134. package/dist/portal/.kosh/schema.d.ts +346 -0
  135. package/dist/portal/announce.d.ts +16 -0
  136. package/dist/portal/announce.js +117 -0
  137. package/dist/portal/documents.d.ts +17 -0
  138. package/dist/portal/documents.js +61 -0
  139. package/dist/portal/index.d.ts +20 -0
  140. package/dist/portal/index.js +65 -0
  141. package/dist/portal/module.d.ts +1405 -0
  142. package/dist/portal/module.js +84 -0
  143. package/dist/portal/routes-documents.d.ts +2 -0
  144. package/dist/portal/routes-documents.js +391 -0
  145. package/dist/portal/routes.d.ts +13 -0
  146. package/dist/portal/routes.js +313 -0
  147. package/dist/portal/rules.d.ts +11 -0
  148. package/dist/portal/rules.js +25 -0
  149. package/dist/portal/web/PortalAccess.d.ts +8 -0
  150. package/dist/portal/web/PortalAccess.js +66 -0
  151. package/dist/portal/web/index.d.ts +12 -0
  152. package/dist/portal/web/index.js +17 -0
  153. package/dist/portal/web/messages.d.ts +2 -0
  154. package/dist/portal/web/messages.js +33 -0
  155. package/dist/product/.kosh/bindings.js +1 -1
  156. package/dist/product/.kosh/schema.d.ts +12 -3
  157. package/dist/product/demo.js +6 -5
  158. package/dist/product/index.d.ts +1 -0
  159. package/dist/product/index.js +17 -4
  160. package/dist/product/module.d.ts +346 -14
  161. package/dist/product/module.js +48 -18
  162. package/dist/product/taxes.d.ts +59 -0
  163. package/dist/product/taxes.js +61 -0
  164. package/dist/project/.kosh/bindings.js +1 -1
  165. package/dist/project/.kosh/schema.d.ts +3 -1
  166. package/dist/project/module.d.ts +20 -0
  167. package/dist/project_portal/.kosh/bindings.d.ts +22 -0
  168. package/dist/project_portal/.kosh/bindings.js +15 -0
  169. package/dist/project_portal/.kosh/schema.d.ts +671 -0
  170. package/dist/project_portal/index.d.ts +9 -0
  171. package/dist/project_portal/index.js +42 -0
  172. package/dist/project_portal/module.d.ts +2142 -0
  173. package/dist/project_portal/module.js +22 -0
  174. package/dist/purchase/.kosh/bindings.js +1 -1
  175. package/dist/purchase/.kosh/schema.d.ts +15 -4
  176. package/dist/purchase/demo.js +3 -3
  177. package/dist/purchase/index.js +1 -1
  178. package/dist/purchase/module.d.ts +232 -8
  179. package/dist/purchase/module.js +51 -9
  180. package/dist/purchase_account/.kosh/bindings.js +1 -1
  181. package/dist/purchase_account/.kosh/schema.d.ts +144 -10
  182. package/dist/purchase_account/module.d.ts +2008 -641
  183. package/dist/purchase_account/module.js +2 -2
  184. package/dist/purchase_portal/.kosh/bindings.d.ts +22 -0
  185. package/dist/purchase_portal/.kosh/bindings.js +15 -0
  186. package/dist/purchase_portal/.kosh/schema.d.ts +822 -0
  187. package/dist/purchase_portal/index.d.ts +9 -0
  188. package/dist/purchase_portal/index.js +53 -0
  189. package/dist/purchase_portal/module.d.ts +2758 -0
  190. package/dist/purchase_portal/module.js +18 -0
  191. package/dist/reporting/documents.js +20 -3
  192. package/dist/reporting/index.d.ts +1 -0
  193. package/dist/reporting/index.js +1 -0
  194. package/dist/reporting/routes-documents.js +9 -2
  195. package/dist/reporting/words.d.ts +11 -0
  196. package/dist/reporting/words.js +229 -0
  197. package/dist/sale_account/.kosh/bindings.js +1 -1
  198. package/dist/sale_account/.kosh/schema.d.ts +144 -10
  199. package/dist/sale_account/module.d.ts +2008 -641
  200. package/dist/sale_account/module.js +3 -3
  201. package/dist/sale_portal/.kosh/bindings.d.ts +22 -0
  202. package/dist/sale_portal/.kosh/bindings.js +15 -0
  203. package/dist/sale_portal/.kosh/schema.d.ts +736 -0
  204. package/dist/sale_portal/index.d.ts +9 -0
  205. package/dist/sale_portal/index.js +71 -0
  206. package/dist/sale_portal/module.d.ts +2718 -0
  207. package/dist/sale_portal/module.js +19 -0
  208. package/dist/sale_project/.kosh/bindings.js +1 -1
  209. package/dist/sale_project/.kosh/schema.d.ts +15 -4
  210. package/dist/sale_project/module.d.ts +390 -10
  211. package/dist/sales/.kosh/bindings.js +1 -1
  212. package/dist/sales/.kosh/schema.d.ts +15 -4
  213. package/dist/sales/demo.js +3 -3
  214. package/dist/sales/index.js +67 -1
  215. package/dist/sales/module.d.ts +232 -8
  216. package/dist/sales/module.js +51 -12
  217. package/dist/server/auth/base.js +2 -0
  218. package/dist/server/auth/service.d.ts +2 -0
  219. package/dist/server/auth/service.js +7 -1
  220. package/dist/server/index.d.ts +1 -1
  221. package/dist/server/index.js +1 -1
  222. package/dist/server/server.js +26 -1
  223. package/dist/ui/api.d.ts +2 -0
  224. package/dist/ui/app.js +1 -1
  225. package/dist/ui/context.d.ts +3 -1
  226. package/dist/ui/context.js +2 -2
  227. package/dist/ui/index.d.ts +1 -1
  228. package/dist/ui/index.js +1 -1
  229. package/dist/ui/lib/format.d.ts +2 -0
  230. package/dist/ui/lib/format.js +3 -1
  231. package/dist/ui/views/FormView.js +19 -6
  232. package/package.json +50 -2
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The data layer of Accounting in the portal (RFC 0015 §5.4): portal users read the posted invoices, credit notes
3
+ * and bills of their contact and company (the portal's record rule) and nothing else of the ledger.
4
+ */
5
+ import { accountingShutro } from '../accounting/index.js';
6
+ import { portalRule, portalShutro } from '../portal/index.js';
7
+ import { defineModule, extendModel } from './.kosh/bindings.js';
8
+ export const MovePortal = extendModel('account.move', {
9
+ access: { 'portal.user': ['read'] },
10
+ rules: { portal: portalRule('partner') },
11
+ });
12
+ export const accountPortalShutro = defineModule({
13
+ name: 'account_portal',
14
+ version: '0.1.0',
15
+ depends: [accountingShutro, portalShutro],
16
+ models: [],
17
+ extensions: [MovePortal],
18
+ });
@@ -1,4 +1,4 @@
1
- // GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash: 5dbc1f9f7f888acd
1
+ // GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash: 5c7f5b1c2e181d35
2
2
  // Bindings of module `accounting`: import the definition API from here to get types scoped to what it can see.
3
3
  export { defineModel, defineModule, extendModel, f, replace } from '../../server/orm.js';
4
4
  import { definitions } from '../../server/orm.js';
@@ -1,4 +1,4 @@
1
- // GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash: 5dbc1f9f7f888acd
1
+ // GENERATED by `pnpm generate:models` (Shutro’s generator). Do not edit. definitions-hash: 5c7f5b1c2e181d35
2
2
  // Schema view of module `accounting` (RFC 0002 §7.7): the models it owns or depends on, with the extensions it can see.
3
3
  import type { F } from '../../server/orm.js';
4
4
 
@@ -14,7 +14,10 @@ export interface SchemaView {
14
14
  readonly 'account.payment': AccountPayment;
15
15
  readonly 'account.payment.term': AccountPaymentTerm;
16
16
  readonly 'account.payment.term.line': AccountPaymentTermLine;
17
+ readonly 'account.payment.withholding': AccountPaymentWithholding;
17
18
  readonly 'account.tax': AccountTax;
19
+ readonly 'account.tax.component': AccountTaxComponent;
20
+ readonly 'account.withholding': AccountWithholding;
18
21
  readonly 'approval.level': ApprovalLevel;
19
22
  readonly 'approval.policy': ApprovalPolicy;
20
23
  readonly 'approval.request': ApprovalRequest;
@@ -38,6 +41,7 @@ export interface SchemaView {
38
41
  readonly 'report.schedule': ReportSchedule;
39
42
  readonly 'report.spreadsheet': ReportSpreadsheet;
40
43
  readonly 'report.template': ReportTemplate;
44
+ readonly 'res.bank.account': ResBankAccount;
41
45
  readonly 'res.company': ResCompany;
42
46
  readonly 'res.currency': ResCurrency;
43
47
  readonly 'res.currency.rate': ResCurrencyRate;
@@ -163,7 +167,7 @@ export interface AccountMove {
163
167
  readonly numberGeneral: F.Char<{ readonly readonly: true; readonly sequence: true }>;
164
168
  readonly journal: F.Many2one<'account.journal', { readonly required: true }>;
165
169
  readonly date: F.DateOnly<{ readonly required: true; readonly default: true }>;
166
- readonly kind: F.Selection<'entry' | 'out_invoice' | 'out_refund' | 'in_invoice' | 'in_refund', { readonly required: true; readonly default: true }>;
170
+ readonly kind: F.Selection<'entry' | 'out_invoice' | 'out_refund' | 'in_invoice' | 'in_refund' | 'out_debit' | 'in_debit', { readonly required: true; readonly default: true }>;
167
171
  readonly partner: F.Many2one<'res.partner'>;
168
172
  readonly ref: F.Char;
169
173
  readonly currency: F.Many2one<'res.currency', { readonly required: true }>;
@@ -175,6 +179,7 @@ export interface AccountMove {
175
179
  readonly amountDebit: F.Monetary<'companyCurrency', { readonly readonly: true; readonly compute: true; readonly store: true }>;
176
180
  readonly amountCredit: F.Monetary<'companyCurrency', { readonly readonly: true; readonly compute: true; readonly store: true }>;
177
181
  readonly dateDue: F.DateOnly;
182
+ readonly paymentDetails: F.Text<{ readonly readonly: true; readonly compute: true }>;
178
183
  readonly paymentTerm: F.Many2one<'account.payment.term'>;
179
184
  readonly invoiceOrigin: F.Char;
180
185
  readonly amountUntaxed: F.Monetary<'currency', { readonly readonly: true; readonly compute: true; readonly store: true }>;
@@ -187,6 +192,8 @@ export interface AccountMove {
187
192
  readonly postedAt: F.Datetime;
188
193
  readonly postedTx: F.Char;
189
194
  readonly reversalOf: F.Many2one<'account.move'>;
195
+ readonly debitOf: F.Many2one<'account.move'>;
196
+ readonly placeOfSupply: F.Char;
190
197
  readonly reversedBy: F.Many2one<'account.move'>;
191
198
  };
192
199
  readonly methods: AccountMoveMethods;
@@ -228,10 +235,14 @@ export interface AccountMoveLine {
228
235
  readonly quantity: F.Decimal<{ readonly default: true }>;
229
236
  readonly priceUnit: F.Decimal<{ readonly default: true }>;
230
237
  readonly discount: F.Decimal<{ readonly default: true }>;
231
- readonly tax: F.Many2one<'account.tax'>;
238
+ readonly taxes: F.Many2many<'account.tax', { readonly required: true }>;
239
+ readonly tax: F.Many2one<'account.tax', { readonly readonly: true }>;
232
240
  readonly subtotal: F.Monetary<'currency', { readonly readonly: true; readonly compute: true; readonly store: true }>;
233
241
  readonly taxAmount: F.Monetary<'currency', { readonly readonly: true; readonly compute: true; readonly store: true }>;
234
242
  readonly taxLineOf: F.Many2one<'account.tax'>;
243
+ readonly taxComponent: F.Many2one<'account.tax.component'>;
244
+ readonly taxReverseCharge: F.Bool<{ readonly required: true; readonly default: true }>;
245
+ readonly taxBase: F.Monetary<'currency'>;
235
246
  readonly balance: F.Monetary<'companyCurrency', { readonly readonly: true; readonly compute: true; readonly store: true }>;
236
247
  readonly posted: F.Bool<{ readonly required: true; readonly readonly: true; readonly default: true; readonly compute: true; readonly store: true }>;
237
248
  readonly accountType: F.Selection<'asset_receivable' | 'asset_cash' | 'asset_current' | 'asset_prepayments' | 'asset_fixed' | 'asset_non_current' | 'liability_payable' | 'liability_current' | 'liability_non_current' | 'equity' | 'equity_unaffected' | 'income' | 'income_other' | 'expense' | 'expense_direct_cost' | 'expense_depreciation' | 'off_balance', { readonly readonly: true; readonly compute: true; readonly store: true }>;
@@ -295,6 +306,8 @@ export interface AccountPayment {
295
306
  readonly amount: F.Monetary<'currency', { readonly required: true }>;
296
307
  readonly memo: F.Char;
297
308
  readonly documents: F.Many2many<'account.move', { readonly required: true }>;
309
+ readonly withholdings: F.One2many<'account.payment.withholding', { readonly required: true }>;
310
+ readonly amountWithheld: F.Monetary<'currency', { readonly readonly: true; readonly compute: true; readonly store: true }>;
298
311
  readonly move: F.Many2one<'account.move'>;
299
312
  readonly state: F.State<'draft' | 'posted' | 'cancel', { readonly required: true; readonly readonly: true; readonly default: true }>;
300
313
  };
@@ -351,6 +364,29 @@ export interface AccountPaymentTermLine {
351
364
  export interface AccountPaymentTermLineMethods extends F.Methods<typeof import('../module.js').accountingShutro, 'account.payment.term.line'> {
352
365
  }
353
366
 
367
+ /** `account.payment.withholding` (owner: accounting). */
368
+ export interface AccountPaymentWithholding {
369
+ readonly name: 'account.payment.withholding';
370
+ readonly fields: {
371
+ readonly id: F.Id<'account.payment.withholding'>;
372
+ readonly createdAt: F.Datetime<{ readonly required: true; readonly readonly: true }>;
373
+ readonly updatedAt: F.Datetime<{ readonly required: true; readonly readonly: true }>;
374
+ readonly createdBy: F.Many2one<'res.users', { readonly readonly: true }>;
375
+ readonly updatedBy: F.Many2one<'res.users', { readonly readonly: true }>;
376
+ readonly displayName: F.Char<{ readonly required: true; readonly readonly: true; readonly compute: true }>;
377
+ readonly payment: F.Many2one<'account.payment', { readonly required: true }>;
378
+ readonly withholding: F.Many2one<'account.withholding', { readonly required: true }>;
379
+ readonly currency: F.Many2one<'res.currency', { readonly readonly: true; readonly compute: true; readonly store: true }>;
380
+ readonly base: F.Monetary<'currency'>;
381
+ readonly amount: F.Monetary<'currency', { readonly required: true }>;
382
+ };
383
+ readonly methods: AccountPaymentWithholdingMethods;
384
+ }
385
+
386
+ /** Methods of `account.payment.withholding`: declared ones and transitions. */
387
+ export interface AccountPaymentWithholdingMethods extends F.Methods<typeof import('../module.js').accountingShutro, 'account.payment.withholding'> {
388
+ }
389
+
354
390
  /** `account.tax` (owner: product; extended by: accounting). */
355
391
  export interface AccountTax {
356
392
  readonly name: 'account.tax';
@@ -364,10 +400,17 @@ export interface AccountTax {
364
400
  readonly active: F.Bool<{ readonly required: true; readonly default: true }>;
365
401
  readonly name: F.Char<{ readonly required: true; readonly translate: true }>;
366
402
  readonly use: F.Selection<'sale' | 'purchase', { readonly required: true; readonly default: true }>;
403
+ readonly sequence: F.Integer<{ readonly required: true; readonly default: true }>;
404
+ readonly amountType: F.Selection<'percent' | 'fixed', { readonly required: true; readonly default: true }>;
367
405
  readonly rate: F.Decimal<{ readonly required: true; readonly default: true }>;
406
+ readonly fixedAmount: F.Decimal<{ readonly required: true; readonly default: true }>;
407
+ readonly affectsBase: F.Bool<{ readonly required: true; readonly default: true }>;
408
+ readonly priceIncluded: F.Bool<{ readonly required: true; readonly default: true }>;
409
+ readonly reverseCharge: F.Bool<{ readonly required: true; readonly default: true }>;
368
410
  readonly account: F.Many2one<'account.account'>; // accounting
369
411
  readonly refundAccount: F.Many2one<'account.account'>; // accounting
370
- readonly priceIncluded: F.Bool<{ readonly required: true; readonly default: true }>; // accounting
412
+ readonly reverseChargeAccount: F.Many2one<'account.account'>; // accounting
413
+ readonly components: F.One2many<'account.tax.component', { readonly required: true }>; // accounting
371
414
  };
372
415
  readonly methods: AccountTaxMethods;
373
416
  }
@@ -376,6 +419,60 @@ export interface AccountTax {
376
419
  export interface AccountTaxMethods extends F.Methods<typeof import('../../product/index.js').productShutro, 'account.tax'>, F.Methods<typeof import('../module.js').accountingShutro, 'account.tax'> {
377
420
  }
378
421
 
422
+ /** `account.tax.component` (owner: accounting). */
423
+ export interface AccountTaxComponent {
424
+ readonly name: 'account.tax.component';
425
+ readonly fields: {
426
+ readonly id: F.Id<'account.tax.component'>;
427
+ readonly createdAt: F.Datetime<{ readonly required: true; readonly readonly: true }>;
428
+ readonly updatedAt: F.Datetime<{ readonly required: true; readonly readonly: true }>;
429
+ readonly createdBy: F.Many2one<'res.users', { readonly readonly: true }>;
430
+ readonly updatedBy: F.Many2one<'res.users', { readonly readonly: true }>;
431
+ readonly displayName: F.Char<{ readonly required: true; readonly readonly: true; readonly compute: true }>;
432
+ readonly tax: F.Many2one<'account.tax', { readonly required: true }>;
433
+ readonly sequence: F.Integer<{ readonly required: true; readonly default: true }>;
434
+ readonly name: F.Char<{ readonly required: true; readonly translate: true }>;
435
+ readonly share: F.Decimal<{ readonly required: true; readonly default: true }>;
436
+ readonly scope: F.Selection<'always' | 'intra' | 'inter', { readonly required: true; readonly default: true }>;
437
+ readonly code: F.Char;
438
+ readonly account: F.Many2one<'account.account'>;
439
+ readonly refundAccount: F.Many2one<'account.account'>;
440
+ readonly reverseChargeAccount: F.Many2one<'account.account'>;
441
+ };
442
+ readonly methods: AccountTaxComponentMethods;
443
+ }
444
+
445
+ /** Methods of `account.tax.component`: declared ones and transitions. */
446
+ export interface AccountTaxComponentMethods extends F.Methods<typeof import('../module.js').accountingShutro, 'account.tax.component'> {
447
+ }
448
+
449
+ /** `account.withholding` (owner: accounting). */
450
+ export interface AccountWithholding {
451
+ readonly name: 'account.withholding';
452
+ readonly fields: {
453
+ readonly id: F.Id<'account.withholding'>;
454
+ readonly createdAt: F.Datetime<{ readonly required: true; readonly readonly: true }>;
455
+ readonly updatedAt: F.Datetime<{ readonly required: true; readonly readonly: true }>;
456
+ readonly createdBy: F.Many2one<'res.users', { readonly readonly: true }>;
457
+ readonly updatedBy: F.Many2one<'res.users', { readonly readonly: true }>;
458
+ readonly displayName: F.Char<{ readonly required: true; readonly readonly: true; readonly compute: true }>;
459
+ readonly active: F.Bool<{ readonly required: true; readonly default: true }>;
460
+ readonly company: F.Many2one<'res.company', { readonly required: true; readonly default: true }>;
461
+ readonly name: F.Char<{ readonly required: true; readonly translate: true }>;
462
+ readonly sequence: F.Integer<{ readonly required: true; readonly default: true }>;
463
+ readonly direction: F.Selection<'vendor' | 'customer', { readonly required: true; readonly default: true }>;
464
+ readonly base: F.Selection<'untaxed' | 'tax' | 'total', { readonly required: true; readonly default: true }>;
465
+ readonly rate: F.Decimal<{ readonly required: true; readonly default: true }>;
466
+ readonly threshold: F.Decimal<{ readonly required: true; readonly default: true }>;
467
+ readonly account: F.Many2one<'account.account', { readonly required: true }>;
468
+ };
469
+ readonly methods: AccountWithholdingMethods;
470
+ }
471
+
472
+ /** Methods of `account.withholding`: declared ones and transitions. */
473
+ export interface AccountWithholdingMethods extends F.Methods<typeof import('../module.js').accountingShutro, 'account.withholding'> {
474
+ }
475
+
379
476
  /** `approval.level` (owner: permissions). */
380
477
  export interface ApprovalLevel {
381
478
  readonly name: 'approval.level';
@@ -820,8 +917,10 @@ export interface ProductProduct {
820
917
  readonly standardPrice: F.Decimal<{ readonly required: true; readonly default: true }>;
821
918
  readonly saleOk: F.Bool<{ readonly required: true; readonly default: true }>;
822
919
  readonly purchaseOk: F.Bool<{ readonly required: true; readonly default: true }>;
823
- readonly tax: F.Many2one<'account.tax'>;
824
- readonly purchaseTax: F.Many2one<'account.tax'>;
920
+ readonly taxes: F.Many2many<'account.tax', { readonly required: true }>;
921
+ readonly purchaseTaxes: F.Many2many<'account.tax', { readonly required: true }>;
922
+ readonly tax: F.Many2one<'account.tax', { readonly readonly: true }>;
923
+ readonly purchaseTax: F.Many2one<'account.tax', { readonly readonly: true }>;
825
924
  readonly description: F.Text<{ readonly translate: true }>;
826
925
  };
827
926
  readonly methods: ProductProductMethods;
@@ -956,6 +1055,34 @@ export interface ReportTemplate {
956
1055
  export interface ReportTemplateMethods extends F.Methods<typeof import('../../reporting/index.js').reportingShutro, 'report.template'> {
957
1056
  }
958
1057
 
1058
+ /** `res.bank.account` (owner: accounting). */
1059
+ export interface ResBankAccount {
1060
+ readonly name: 'res.bank.account';
1061
+ readonly fields: {
1062
+ readonly id: F.Id<'res.bank.account'>;
1063
+ readonly createdAt: F.Datetime<{ readonly required: true; readonly readonly: true }>;
1064
+ readonly updatedAt: F.Datetime<{ readonly required: true; readonly readonly: true }>;
1065
+ readonly createdBy: F.Many2one<'res.users', { readonly readonly: true }>;
1066
+ readonly updatedBy: F.Many2one<'res.users', { readonly readonly: true }>;
1067
+ readonly displayName: F.Char<{ readonly required: true; readonly readonly: true; readonly compute: true }>;
1068
+ readonly active: F.Bool<{ readonly required: true; readonly default: true }>;
1069
+ readonly company: F.Many2one<'res.company', { readonly required: true; readonly default: true }>;
1070
+ readonly sequence: F.Integer<{ readonly required: true; readonly default: true }>;
1071
+ readonly bank: F.Char<{ readonly required: true }>;
1072
+ readonly branch: F.Char;
1073
+ readonly number: F.Char<{ readonly required: true }>;
1074
+ readonly holder: F.Char;
1075
+ readonly routing: F.Char;
1076
+ readonly swift: F.Char;
1077
+ readonly currency: F.Many2one<'res.currency'>;
1078
+ };
1079
+ readonly methods: ResBankAccountMethods;
1080
+ }
1081
+
1082
+ /** Methods of `res.bank.account`: declared ones and transitions. */
1083
+ export interface ResBankAccountMethods extends F.Methods<typeof import('../module.js').accountingShutro, 'res.bank.account'> {
1084
+ }
1085
+
959
1086
  /** `res.company` (owner: base; extended by: accounting). */
960
1087
  export interface ResCompany {
961
1088
  readonly name: 'res.company';
@@ -968,7 +1095,11 @@ export interface ResCompany {
968
1095
  readonly displayName: F.Char<{ readonly required: true; readonly readonly: true; readonly compute: true }>;
969
1096
  readonly name: F.Char<{ readonly required: true }>;
970
1097
  readonly currency: F.Many2one<'res.currency', { readonly required: true }>;
971
- readonly chartTemplate: F.Selection<'generic' | 'bd'>; // accounting
1098
+ readonly numberGrouping: F.Selection<'international' | 'lakh', { readonly required: true; readonly default: true }>;
1099
+ readonly fiscalYearStart: F.Integer<{ readonly required: true; readonly default: true }>; // accounting
1100
+ readonly chartTemplate: F.Char; // accounting
1101
+ readonly country: F.Char; // accounting
1102
+ readonly state: F.Char; // accounting
972
1103
  readonly lockDate: F.DateOnly; // accounting
973
1104
  readonly taxLockDate: F.DateOnly; // accounting
974
1105
  readonly accountReceivable: F.Many2one<'account.account'>; // accounting
@@ -1027,7 +1158,7 @@ export interface ResCurrencyRate {
1027
1158
  export interface ResCurrencyRateMethods extends F.Methods<typeof import('../module.js').accountingShutro, 'res.currency.rate'> {
1028
1159
  }
1029
1160
 
1030
- /** `res.partner` (owner: contacts). */
1161
+ /** `res.partner` (owner: contacts; extended by: accounting). */
1031
1162
  export interface ResPartner {
1032
1163
  readonly name: 'res.partner';
1033
1164
  readonly fields: {
@@ -1051,17 +1182,19 @@ export interface ResPartner {
1051
1182
  readonly city: F.Char;
1052
1183
  readonly zip: F.Char;
1053
1184
  readonly country: F.Char;
1185
+ readonly state: F.Char;
1054
1186
  readonly taxId: F.Char;
1055
1187
  readonly isCustomer: F.Bool<{ readonly required: true; readonly default: true }>;
1056
1188
  readonly isVendor: F.Bool<{ readonly required: true; readonly default: true }>;
1057
1189
  readonly currency: F.Many2one<'res.currency'>;
1058
1190
  readonly notes: F.Text;
1191
+ readonly withholdings: F.Many2many<'account.withholding', { readonly required: true }>; // accounting
1059
1192
  };
1060
1193
  readonly methods: ResPartnerMethods;
1061
1194
  }
1062
1195
 
1063
1196
  /** Methods of `res.partner`: declared ones and transitions. */
1064
- export interface ResPartnerMethods extends F.Methods<typeof import('../../contacts/index.js').contactsShutro, 'res.partner'> {
1197
+ export interface ResPartnerMethods extends F.Methods<typeof import('../../contacts/index.js').contactsShutro, 'res.partner'>, F.Methods<typeof import('../module.js').accountingShutro, 'res.partner'> {
1065
1198
  }
1066
1199
 
1067
1200
  /** `res.users` (owner: base). */
@@ -1,14 +1,24 @@
1
+ /**
2
+ * Charts of accounts (RFC 0009 §5.6) and localizations (RFC 0016 §5.2): the generic template lives here; a country's
3
+ * comes with its localization module (`l10n_bd`). Installing a template for a company creates its accounts and
4
+ * journals, links the company's default accounts, and points the taxes at their accounts; installing a
5
+ * localization also sets the accounts of its own taxes, its withholdings, the fiscal year and the number grouping.
6
+ * Each is applied once per company. Also here: the database triggers that keep posted entries immutable below the
7
+ * ORM (raw SQL, deletes), created idempotently with the module's defaults.
8
+ */
9
+ import type { KoshModule, LocalizationSpec } from '../modules-sdk/index.js';
1
10
  import type { Env } from './.kosh/bindings.js';
2
- import type { AccountType } from './module.js';
3
- export type ChartTemplate = 'generic' | 'bd';
4
- interface AccountSpec {
11
+ import { type AccountType } from './module.js';
12
+ /** A chart's code: `generic`, or a localization's key (`bd`). */
13
+ export type ChartTemplate = string;
14
+ export interface AccountSpec {
5
15
  readonly code: string;
6
16
  readonly name: string;
7
17
  readonly type: AccountType;
8
18
  readonly reconcile?: boolean;
9
19
  }
10
20
  /** Which accounts the company's defaults point to, by code. */
11
- interface Defaults {
21
+ export interface Defaults {
12
22
  readonly receivable: string;
13
23
  readonly payable: string;
14
24
  readonly exchangeGain: string;
@@ -19,7 +29,7 @@ interface Defaults {
19
29
  readonly income: string;
20
30
  readonly expense: string;
21
31
  }
22
- interface Chart {
32
+ export interface Chart {
23
33
  readonly label: string;
24
34
  readonly accounts: readonly AccountSpec[];
25
35
  readonly defaults: Defaults;
@@ -29,7 +39,16 @@ interface Chart {
29
39
  readonly purchase: string;
30
40
  };
31
41
  }
32
- export declare const CHARTS: Readonly<Record<ChartTemplate, Chart>>;
42
+ /** The accounts every chart starts from (a localization adds its own). */
43
+ export declare const COMMON_ACCOUNTS: readonly AccountSpec[];
44
+ /** The default accounts of the common set, by code. */
45
+ export declare const DEFAULT_ACCOUNTS: Defaults;
46
+ /** The charts Accounting ships: the generic one. Countries bring theirs (`chartsOf`). */
47
+ export declare const CHARTS: Readonly<Record<string, Chart>>;
48
+ /** Every chart the installed modules offer: the generic one and the localizations'. */
49
+ export declare function chartsOf(modules: readonly KoshModule[]): ReadonlyMap<string, Chart>;
50
+ /** The localizations of the installed modules, by key. */
51
+ export declare function localizationsOf(modules: readonly KoshModule[]): ReadonlyMap<string, LocalizationSpec>;
33
52
  export interface ChartInstalled {
34
53
  readonly template: ChartTemplate;
35
54
  readonly accounts: number;
@@ -43,7 +62,21 @@ export declare function installedChart(env: Env): Promise<ChartTemplate | null>;
43
62
  * and the tax accounts of the product module's taxes.
44
63
  * @throws {Error} when the company already has a chart (the caller turns it into a 409)
45
64
  */
46
- export declare function installChart(env: Env, template: ChartTemplate): Promise<ChartInstalled>;
65
+ export declare function installChart(env: Env, template: ChartTemplate, chart?: Chart): Promise<ChartInstalled>;
66
+ export interface LocalizationInstalled {
67
+ readonly localization: string;
68
+ /** The chart, when the company had none yet. */
69
+ readonly chart: ChartInstalled | null;
70
+ readonly taxes: number;
71
+ readonly withholdings: number;
72
+ readonly fiscalYear: string | null;
73
+ }
74
+ /**
75
+ * Sets a company up for a country (RFC 0016 §5.2), once and idempotently: its chart (unless it has one), the
76
+ * accounts of the localization's taxes, its withholdings (those it lacks, by name), the fiscal year's first month and
77
+ * the number grouping, and the current fiscal year when there is none. Everything is the company's data afterwards.
78
+ */
79
+ export declare function installLocalization(env: Env, localization: LocalizationSpec): Promise<LocalizationInstalled>;
47
80
  export declare class ChartInstalledError extends Error {
48
81
  readonly template: ChartTemplate;
49
82
  constructor(template: ChartTemplate);
@@ -54,4 +87,3 @@ export declare class ChartInstalledError extends Error {
54
87
  * reversal link, reconciliation marks) stay open.
55
88
  */
56
89
  export declare function installImmutability(env: Env): Promise<void>;
57
- export {};
@@ -1,12 +1,7 @@
1
- /**
2
- * Charts of accounts (RFC 0009 §5.6): the generic template and the Bangladesh one (RFC 0008 decision 2; VAT accounts
3
- * follow the Mushak structure: output VAT, input VAT, VAT payable, AT, SD). Installing a template for a company
4
- * creates its accounts and journals, links the company's default accounts, and points the taxes at their accounts.
5
- * A template is applied once per company. Also here: the database triggers that keep posted entries immutable
6
- * below the ORM (raw SQL, deletes), created idempotently with the module's defaults.
7
- */
8
1
  import { orm } from '../server/orm.js';
9
- const COMMON = [
2
+ import { fiscalYearOf } from './module.js';
3
+ /** The accounts every chart starts from (a localization adds its own). */
4
+ export const COMMON_ACCOUNTS = [
10
5
  { code: '1000', name: 'Cash', type: 'asset_cash' },
11
6
  { code: '1010', name: 'Bank', type: 'asset_cash' },
12
7
  { code: '1100', name: 'Accounts receivable', type: 'asset_receivable', reconcile: true },
@@ -35,7 +30,8 @@ const COMMON = [
35
30
  { code: '6900', name: 'Exchange loss', type: 'expense' },
36
31
  { code: '9999', name: 'Suspense', type: 'asset_current', reconcile: true },
37
32
  ];
38
- const DEFAULTS = {
33
+ /** The default accounts of the common set, by code. */
34
+ export const DEFAULT_ACCOUNTS = {
39
35
  receivable: '1100',
40
36
  payable: '2000',
41
37
  exchangeGain: '4910',
@@ -46,32 +42,16 @@ const DEFAULTS = {
46
42
  income: '4000',
47
43
  expense: '6300',
48
44
  };
45
+ /** The charts Accounting ships: the generic one. Countries bring theirs (`chartsOf`). */
49
46
  export const CHARTS = {
50
47
  generic: {
51
48
  label: 'Generic',
52
49
  accounts: [
53
- ...COMMON,
50
+ ...COMMON_ACCOUNTS,
54
51
  { code: '2200', name: 'VAT collected', type: 'liability_current' },
55
52
  { code: '1300', name: 'VAT paid', type: 'asset_current' },
56
53
  ],
57
- defaults: DEFAULTS,
58
- taxAccounts: { sale: '2200', purchase: '1300' },
59
- },
60
- bd: {
61
- label: 'Bangladesh',
62
- accounts: [
63
- ...COMMON,
64
- // VAT and SD Act 2012 (Mushak): output and input VAT, the net payable, advance tax, supplementary duty.
65
- { code: '2200', name: 'Output VAT (Mushak)', type: 'liability_current' },
66
- { code: '1300', name: 'Input VAT (Mushak)', type: 'asset_current' },
67
- { code: '2210', name: 'VAT payable', type: 'liability_current' },
68
- { code: '1310', name: 'Advance tax (AT) receivable', type: 'asset_current' },
69
- { code: '2220', name: 'Supplementary duty (SD) payable', type: 'liability_current' },
70
- { code: '1320', name: 'Advance income tax (AIT) receivable', type: 'asset_current' },
71
- { code: '2230', name: 'Tax deducted at source (TDS) payable', type: 'liability_current' },
72
- { code: '2240', name: 'VAT deducted at source (VDS) payable', type: 'liability_current' },
73
- ],
74
- defaults: DEFAULTS,
54
+ defaults: DEFAULT_ACCOUNTS,
75
55
  taxAccounts: { sale: '2200', purchase: '1300' },
76
56
  },
77
57
  };
@@ -82,6 +62,20 @@ const JOURNALS = [
82
62
  { code: 'BNK', name: 'Bank', type: 'bank', account: 'bank' },
83
63
  { code: 'MISC', name: 'Miscellaneous', type: 'general', account: null },
84
64
  ];
65
+ /** Every chart the installed modules offer: the generic one and the localizations'. */
66
+ export function chartsOf(modules) {
67
+ const out = new Map(Object.entries(CHARTS));
68
+ for (const m of modules) {
69
+ const l = m.localization;
70
+ if (l !== undefined)
71
+ out.set(l.key, { ...l.chart, label: l.label });
72
+ }
73
+ return out;
74
+ }
75
+ /** The localizations of the installed modules, by key. */
76
+ export function localizationsOf(modules) {
77
+ return new Map(modules.flatMap((m) => m.localization === undefined ? [] : [[m.localization.key, m.localization]]));
78
+ }
85
79
  /** Already-installed template of the environment's company, or null. */
86
80
  export async function installedChart(env) {
87
81
  const [company] = await env.model('res.company').browse([env.companyId]).load({});
@@ -92,8 +86,7 @@ export async function installedChart(env) {
92
86
  * and the tax accounts of the product module's taxes.
93
87
  * @throws {Error} when the company already has a chart (the caller turns it into a 409)
94
88
  */
95
- export async function installChart(env, template) {
96
- const chart = CHARTS[template];
89
+ export async function installChart(env, template, chart = CHARTS[template]) {
97
90
  const company = env.companyRef;
98
91
  const existing = await installedChart(env);
99
92
  if (existing !== null)
@@ -149,6 +142,107 @@ export async function installChart(env, template) {
149
142
  }
150
143
  return { template, accounts: accounts.length, journals: journals.length, taxes: linked };
151
144
  }
145
+ /**
146
+ * Sets a company up for a country (RFC 0016 §5.2), once and idempotently: its chart (unless it has one), the
147
+ * accounts of the localization's taxes, its withholdings (those it lacks, by name), the fiscal year's first month and
148
+ * the number grouping, and the current fiscal year when there is none. Everything is the company's data afterwards.
149
+ */
150
+ export async function installLocalization(env, localization) {
151
+ const company = env.companyRef;
152
+ const chartSpec = {
153
+ ...localization.chart,
154
+ label: localization.label,
155
+ };
156
+ const chart = (await installedChart(env)) === null
157
+ ? await installChart(env, localization.key, chartSpec)
158
+ : null;
159
+ const accountOf = async (code) => {
160
+ const found = await env.model('account.account').search({ where: { code, company }, limit: 1 });
161
+ const id = found.ids[0];
162
+ if (id === undefined)
163
+ throw new Error(`The ${localization.label} chart has no account ${code}.`);
164
+ return id;
165
+ };
166
+ let taxes = 0;
167
+ for (const [externalId, code] of Object.entries(localization.taxes ?? {})) {
168
+ let tax;
169
+ try {
170
+ tax = Number(await env.refId('account.tax', externalId));
171
+ }
172
+ catch (error) {
173
+ if (error instanceof orm.UnknownExternalIdError)
174
+ continue; // removed by the users
175
+ throw error;
176
+ }
177
+ await env
178
+ .model('account.tax')
179
+ .browse([orm.asId(tax, 'account.tax')])
180
+ .write({ account: await accountOf(code) });
181
+ taxes += 1;
182
+ }
183
+ for (const [externalId, target] of Object.entries(localization.components ?? {})) {
184
+ let component;
185
+ try {
186
+ component = Number(await env.refId('account.tax.component', externalId));
187
+ }
188
+ catch (error) {
189
+ if (error instanceof orm.UnknownExternalIdError)
190
+ continue; // removed by the users
191
+ throw error;
192
+ }
193
+ const codes = typeof target === 'string' ? { account: target } : target;
194
+ await env
195
+ .model('account.tax.component')
196
+ .browse([orm.asId(component, 'account.tax.component')])
197
+ .write({
198
+ account: await accountOf(codes.account),
199
+ ...(codes.reverseCharge === undefined
200
+ ? {}
201
+ : { reverseChargeAccount: await accountOf(codes.reverseCharge) }),
202
+ });
203
+ }
204
+ let withholdings = 0;
205
+ for (const w of localization.withholdings ?? []) {
206
+ const exists = await env
207
+ .model('account.withholding')
208
+ .search({ where: { name: w.name, company }, limit: 1 });
209
+ if (exists.length > 0)
210
+ continue;
211
+ await env.model('account.withholding').create([
212
+ {
213
+ name: w.name,
214
+ direction: w.direction,
215
+ base: w.base,
216
+ rate: w.rate,
217
+ threshold: w.threshold ?? '0',
218
+ account: await accountOf(w.account),
219
+ company,
220
+ },
221
+ ]);
222
+ withholdings += 1;
223
+ }
224
+ const start = localization.fiscalYearStart ?? 1;
225
+ await env.asSuperuser({ reason: `localize the company for ${localization.label}` }, (su) => su
226
+ .model('res.company')
227
+ .browse([company])
228
+ .write({
229
+ fiscalYearStart: start,
230
+ numberGrouping: localization.grouping ?? 'international',
231
+ country: localization.country,
232
+ }));
233
+ let fiscalYear = null;
234
+ const years = await env.model('account.fiscal.year').search({ where: { company }, limit: 1 });
235
+ if (years.length === 0) {
236
+ const { dateFrom, dateTo } = fiscalYearOf(env.today(), start);
237
+ const [y, m] = dateFrom.split('-').map(Number);
238
+ fiscalYear = m === 1 ? String(y) : `${y}–${String(y + 1).slice(2)}`;
239
+ await env
240
+ .model('account.fiscal.year')
241
+ .create([{ name: fiscalYear, dateFrom, dateTo, company }]);
242
+ }
243
+ await env.flush(); // the checks run in the caller's scope, not at commit (Shutro request #11)
244
+ return { localization: localization.key, chart, taxes, withholdings, fiscalYear };
245
+ }
152
246
  export class ChartInstalledError extends Error {
153
247
  template;
154
248
  constructor(template) {
@@ -18,13 +18,18 @@ export interface Settings {
18
18
  readonly chartTemplate: string | null;
19
19
  readonly lockDate: string | null;
20
20
  readonly taxLockDate: string | null;
21
+ /** Where the company is registered (ISO 3166 / 3166-2): taxes split by place of supply compare against it. */
22
+ readonly country: string | null;
23
+ readonly state: string | null;
21
24
  readonly accounts: Readonly<Record<string, number | null>>;
22
25
  }
23
26
  export declare function readSettings(env: Env): Promise<Settings>;
24
- /** The lock dates (managers). */
27
+ /** The lock dates, the company's country and state (managers). */
25
28
  export declare function updateSettings(env: Env, input: {
26
29
  readonly lockDate?: string | null;
27
30
  readonly taxLockDate?: string | null;
31
+ readonly country?: string | null;
32
+ readonly state?: string | null;
28
33
  }): Promise<Settings>;
29
34
  export interface AgingRow {
30
35
  readonly partner: number | null;
@@ -150,6 +150,8 @@ export async function readSettings(env) {
150
150
  chartTemplate: c?.chartTemplate ?? null,
151
151
  lockDate: c?.lockDate ?? null,
152
152
  taxLockDate: c?.taxLockDate ?? null,
153
+ country: c?.country ?? null,
154
+ state: c?.state ?? null,
153
155
  accounts: {
154
156
  receivable: c?.accountReceivable?.id ?? null,
155
157
  payable: c?.accountPayable?.id ?? null,
@@ -159,7 +161,7 @@ export async function readSettings(env) {
159
161
  },
160
162
  };
161
163
  }
162
- /** The lock dates (managers). */
164
+ /** The lock dates, the company's country and state (managers). */
163
165
  export async function updateSettings(env, input) {
164
166
  needs(env, 'account.settings', 'Changing the accounting settings');
165
167
  await env.asSuperuser({ reason: 'accounting settings' }, (su) => su
@@ -168,6 +170,8 @@ export async function updateSettings(env, input) {
168
170
  .write({
169
171
  ...(input.lockDate === undefined ? {} : { lockDate: input.lockDate }),
170
172
  ...(input.taxLockDate === undefined ? {} : { taxLockDate: input.taxLockDate }),
173
+ ...(input.country === undefined ? {} : { country: input.country }),
174
+ ...(input.state === undefined ? {} : { state: input.state }),
171
175
  }));
172
176
  return readSettings(env);
173
177
  }