ekwo-os 0.4.1
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 +873 -0
- package/dist/args.d.ts +57 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +134 -0
- package/dist/args.js.map +1 -0
- package/dist/assets/expected-objects.json +9432 -0
- package/dist/assets/migrations/20260911120000_core_companies.sql +260 -0
- package/dist/assets/migrations/20260911120100_accounts_journals.sql +211 -0
- package/dist/assets/migrations/20260911120200_contacts.sql +90 -0
- package/dist/assets/migrations/20260911120300_taxes.sql +146 -0
- package/dist/assets/migrations/20260911120400_entries.sql +338 -0
- package/dist/assets/migrations/20260911120500_documents.sql +279 -0
- package/dist/assets/migrations/20260911120600_payments_reconciliation.sql +251 -0
- package/dist/assets/migrations/20260911120700_bank.sql +178 -0
- package/dist/assets/migrations/20260911120800_analytics_attachments.sql +128 -0
- package/dist/assets/migrations/20260911120900_post_document.sql +279 -0
- package/dist/assets/migrations/20260911121000_reporting.sql +235 -0
- package/dist/assets/migrations/20260911121100_country_templates.sql +226 -0
- package/dist/assets/migrations/20260911121200_fec.sql +71 -0
- package/dist/assets/migrations/20260911130000_instance.sql +77 -0
- package/dist/assets/migrations/20260911130100_instance_members.sql +224 -0
- package/dist/assets/migrations/20260911140000_instance_admins.sql +112 -0
- package/dist/assets/migrations/20260911160000_tax_posting_templates_unique.sql +17 -0
- package/dist/assets/migrations/20260911170000_document_amount_paid.sql +82 -0
- package/dist/assets/migrations/20260911173000_post_payment.sql +122 -0
- package/dist/assets/migrations/20260911173100_sequence_counters_under_rls.sql +84 -0
- package/dist/assets/migrations/20260911183000_country_journal_defaults.sql +143 -0
- package/dist/assets/migrations/20260911193853_line_account_defaults.sql +274 -0
- package/dist/assets/migrations/20260911195054_products.sql +221 -0
- package/dist/assets/migrations/20260911210131_anon_surface.sql +85 -0
- package/dist/assets/migrations/20260912074712_country_packs.sql +318 -0
- package/dist/assets/migrations/20260912080311_report_code_and_region.sql +198 -0
- package/dist/assets/migrations/20260912081014_pack_certification_maintained.sql +31 -0
- package/dist/assets/migrations/20260912081015_pack_certification_backfill.sql +16 -0
- package/dist/assets/migrations/20260912090407_tax_report_boxes.sql +329 -0
- package/dist/assets/migrations/20260912091917_tax_on_base_value.sql +25 -0
- package/dist/assets/migrations/20260912091918_tax_engine_columns.sql +776 -0
- package/dist/assets/migrations/20260912094412_opening_and_closing.sql +759 -0
- package/dist/assets/migrations/20260912095825_charts_of_accounts.sql +326 -0
- package/dist/assets/migrations/20260912100412_financial_statements.sql +632 -0
- package/dist/assets/migrations/20260912104719_one_formula_evaluator.sql +209 -0
- package/dist/assets/migrations/20260912105720_entry_kind_appropriation.sql +26 -0
- package/dist/assets/migrations/20260912105721_appropriation_entry_kind.sql +444 -0
- package/dist/assets/migrations/20260912111751_document_rules.sql +274 -0
- package/dist/assets/migrations/20260912112132_cash_basis_vat_and_fx.sql +1189 -0
- package/dist/assets/migrations/20260913074512_modules.sql +493 -0
- package/dist/assets/migrations/20260913075903_asset_disposal_roles.sql +47 -0
- package/dist/assets/migrations/20260913083216_capabilities.sql +637 -0
- package/dist/assets/migrations/20260913083901_company_invitations.sql +262 -0
- package/dist/assets/migrations/20260913084402_user_preferences.sql +376 -0
- package/dist/assets/migrations/20260913084847_company_profile.sql +261 -0
- package/dist/assets/migrations/20260913085436_numbering_reads_the_pack.sql +235 -0
- package/dist/assets/migrations/20260913085932_api_keys.sql +303 -0
- package/dist/assets/migrations/20260913090216_fiscal_year_bounds.sql +159 -0
- package/dist/assets/migrations/20260913092527_entries_import.sql +219 -0
- package/dist/assets/migrations/20260913101536_null_safe_guards.sql +188 -0
- package/dist/assets/migrations/20260913102115_installer_is_named.sql +462 -0
- package/dist/assets/migrations/20260913102758_no_currency_default.sql +138 -0
- package/dist/assets/migrations/20260913103355_cash_basis_needs_a_box.sql +453 -0
- package/dist/assets/migrations/20260913104014_aged_balance_named_group.sql +79 -0
- package/dist/assets/migrations/20260913104232_foreign_key_indexes.sql +144 -0
- package/dist/assets/migrations/20260913105120_declared_no_reader.sql +41 -0
- package/dist/assets/migrations/20260913111407_pack_languages.sql +223 -0
- package/dist/assets/migrations/20260913112233_schema_comments_for_a_reader.sql +27 -0
- package/dist/assets/migrations/20260913114535_fec_opening_balances.sql +307 -0
- package/dist/assets/migrations/20260914103412_audit_log.sql +509 -0
- package/dist/assets/migrations/20260914111907_pack_upgrade.sql +428 -0
- package/dist/assets/migrations/20260914120500_rounding_reads_the_currency.sql +206 -0
- package/dist/assets/migrations/20260914121200_amounts_round_at_the_currency.sql +2403 -0
- package/dist/assets/migrations/20260914134325_schema_version_0_2_0.sql +36 -0
- package/dist/assets/migrations/20260914143915_accounts_in_use.sql +428 -0
- package/dist/assets/migrations/20260914144731_account_code_frozen.sql +99 -0
- package/dist/assets/migrations/20260914151207_schema_grants_its_own_rights.sql +284 -0
- package/dist/assets/migrations/20260914152840_pack_upgrade_records_its_own_line.sql +237 -0
- package/dist/assets/migrations/20260914163943_declaration_periodicity.sql +349 -0
- package/dist/assets/migrations/20260915094000_foreign_services_received.sql +37 -0
- package/dist/assets/migrations/20260915094500_mentions_read_a_foreign_service.sql +72 -0
- package/dist/assets/migrations/20260915153000_document_shares.sql +568 -0
- package/dist/assets/migrations/20260915160000_ec_sales_list.sql +181 -0
- package/dist/assets/migrations/20260915161842_pack_sources.sql +56 -0
- package/dist/assets/migrations/20260915170500_schema_version_0_3_0.sql +45 -0
- package/dist/assets/migrations/20260915174500_a_vat_category_is_a_code.sql +177 -0
- package/dist/assets/migrations/20260915180000_document_rule_references.sql +85 -0
- package/dist/assets/migrations/20260915181000_territories.sql +342 -0
- package/dist/assets/migrations/20260915181500_ec_sales_list_reads_the_territories.sql +222 -0
- package/dist/assets/migrations/20260915182000_intracom_triangular.sql +53 -0
- package/dist/assets/migrations/20260915182500_a_triangular_supply_says_reverse_charge.sql +99 -0
- package/dist/assets/migrations/20260915191200_a_document_knows_its_language.sql +633 -0
- package/dist/assets/migrations/20260915195000_a_price_that_holds_its_tax.sql +649 -0
- package/dist/assets/migrations/20260915200000_a_posting_names_its_boxes.sql +1004 -0
- package/dist/assets/migrations/20260916094500_a_company_files_more_than_one_declaration.sql +795 -0
- package/dist/assets/migrations/20260916103000_a_ledger_line_names_its_posting.sql +902 -0
- package/dist/assets/migrations/20260916123000_a_vocabulary_for_a_tax_that_is_not_a_vat.sql +144 -0
- package/dist/assets/migrations/20260916124000_a_box_can_be_a_rate_of_a_box.sql +525 -0
- package/dist/assets/migrations/20260916125000_a_tax_follows_the_territory.sql +1318 -0
- package/dist/assets/migrations/20260916126000_a_tax_point_and_its_exception.sql +1211 -0
- package/dist/assets/migrations/20260917090000_a_counterparty_that_learns.sql +561 -0
- package/dist/assets/migrations/20260917120000_what_the_money_pays.sql +545 -0
- package/dist/assets/migrations/20260917150000_a_filing_is_a_row.sql +488 -0
- package/dist/assets/migrations/20260917170000_when_it_is_due.sql +194 -0
- package/dist/assets/migrations/20260917180000_a_box_is_a_number_and_a_kind.sql +213 -0
- package/dist/assets/migrations/20260917190000_what_a_declaration_owes.sql +486 -0
- package/dist/assets/migrations/20260917200000_what_moved_after_it_went.sql +227 -0
- package/dist/assets/migrations/20260918090000_a_form_names_its_file.sql +27 -0
- package/dist/assets/migrations/20260918110000_a_deposit_and_what_came_back.sql +286 -0
- package/dist/assets/migrations/20260918113741_a_fourth_preset_is_named.sql +9 -0
- package/dist/assets/migrations/20260918113807_a_client_reads_and_hands_over.sql +96 -0
- package/dist/assets/migrations/20260918114322_two_definer_functions_check_their_caller.sql +75 -0
- package/dist/assets/migrations/20260918130000_every_company_somebody_keeps.sql +177 -0
- package/dist/assets/migrations/20260918140000_a_session_nobody_prepared.sql +40 -0
- package/dist/assets/migrations/20260918141107_a_line_keeps_the_tax_it_was_posted_with.sql +256 -0
- package/dist/assets/migrations/20260918141342_a_company_has_an_electronic_address.sql +66 -0
- package/dist/assets/migrations/20260918141605_an_invoice_reads_whole_from_the_views.sql +313 -0
- package/dist/assets/migrations/20260918141627_a_policy_asks_once.sql +132 -0
- package/dist/assets/migrations/20260918143352_a_suggestion_reads_the_words_once.sql +204 -0
- package/dist/assets/migrations/20260918143417_a_reference_of_the_caller_and_a_rehearsal.sql +115 -0
- package/dist/assets/migrations/20260918150712_a_company_leaves_with_its_books.sql +1119 -0
- package/dist/assets/migrations/20260918150931_a_statement_is_imported_once.sql +654 -0
- package/dist/assets/migrations/20260918161204_a_posted_document_does_not_move.sql +437 -0
- package/dist/assets/migrations/20260918161538_a_posted_entry_does_not_move.sql +252 -0
- package/dist/assets/migrations/20260918171946_an_entry_is_posted_by_post_entry.sql +289 -0
- package/dist/assets/migrations/20260918174312_schema_version_0_4_0.sql +53 -0
- package/dist/assets/modules/assets/module.json +13 -0
- package/dist/assets/modules/assets/supabase/migrations/20260913081447_assets.sql +1190 -0
- package/dist/assets/modules/assets/supabase/migrations/20260913104234_foreign_key_indexes.sql +47 -0
- package/dist/assets/modules/assets/supabase/migrations/20260913104500_assets_capabilities.sql +145 -0
- package/dist/assets/modules/assets/supabase/migrations/20260914122100_assets_round_at_the_currency.sql +564 -0
- package/dist/assets/modules/assets/supabase/migrations/20260914145012_assets_accounts_in_use.sql +37 -0
- package/dist/assets/modules/assets/supabase/migrations/20260914151530_assets_grants_its_own_rights.sql +63 -0
- package/dist/assets/modules/assets/supabase/migrations/20260918113912_assets_client_reads.sql +20 -0
- package/dist/assets/modules/assets/supabase/migrations/20260918150801_assets_leave_with_the_company.sql +41 -0
- package/dist/assets/modules/budgets/module.json +12 -0
- package/dist/assets/modules/budgets/supabase/migrations/20260913083012_budgets.sql +210 -0
- package/dist/assets/modules/budgets/supabase/migrations/20260913104233_foreign_key_indexes.sql +37 -0
- package/dist/assets/modules/budgets/supabase/migrations/20260913104501_budgets_capabilities.sql +72 -0
- package/dist/assets/modules/budgets/supabase/migrations/20260914122400_budgets_round_at_the_currency.sql +68 -0
- package/dist/assets/modules/budgets/supabase/migrations/20260914145048_budgets_accounts_in_use.sql +30 -0
- package/dist/assets/modules/budgets/supabase/migrations/20260914151812_budgets_grants_its_own_rights.sql +31 -0
- package/dist/assets/modules/budgets/supabase/migrations/20260918113954_budgets_client_reads.sql +20 -0
- package/dist/assets/modules/budgets/supabase/migrations/20260918150823_budgets_leave_with_the_company.sql +37 -0
- package/dist/assets/modules/schema/module.1.json +69 -0
- package/dist/assets/seed/00_currencies.sql +15 -0
- package/dist/assets/seed/00_territories.sql +280 -0
- package/dist/assets/seed/05_framework_generic.sql +110 -0
- package/dist/assets/seed/10_pack_be.sql +1284 -0
- package/dist/assets/seed/11_pack_fr.sql +1112 -0
- package/dist/assets/seed/12_pack_lu.sql +2484 -0
- package/dist/assets/seed/13_pack_ee.sql +733 -0
- package/dist/assets/seed/14_pack_gb.sql +796 -0
- package/dist/assets/seed/15_pack_us.sql +751 -0
- package/dist/assets/seed/90_demo_company.sql +368 -0
- package/dist/assets/seed/modules/assets/10_pack_be.sql +58 -0
- package/dist/assets/seed/modules/assets/11_pack_fr.sql +57 -0
- package/dist/assets/seed/modules/assets/14_pack_gb.sql +58 -0
- package/dist/assets/seed/modules/assets/15_pack_us.sql +60 -0
- package/dist/auth.d.ts +59 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +134 -0
- package/dist/auth.js.map +1 -0
- package/dist/bin.d.ts +6 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +8 -0
- package/dist/bin.js.map +1 -0
- package/dist/books.d.ts +60 -0
- package/dist/books.d.ts.map +1 -0
- package/dist/books.js +168 -0
- package/dist/books.js.map +1 -0
- package/dist/bootstrap.d.ts +236 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +459 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/bundle.d.ts +27 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +47 -0
- package/dist/bundle.js.map +1 -0
- package/dist/checklist.d.ts +35 -0
- package/dist/checklist.d.ts.map +1 -0
- package/dist/checklist.js +64 -0
- package/dist/checklist.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +318 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/company.d.ts +59 -0
- package/dist/commands/company.d.ts.map +1 -0
- package/dist/commands/company.js +287 -0
- package/dist/commands/company.js.map +1 -0
- package/dist/commands/contact.d.ts +9 -0
- package/dist/commands/contact.d.ts.map +1 -0
- package/dist/commands/contact.js +82 -0
- package/dist/commands/contact.js.map +1 -0
- package/dist/commands/demo.d.ts +19 -0
- package/dist/commands/demo.d.ts.map +1 -0
- package/dist/commands/demo.js +72 -0
- package/dist/commands/demo.js.map +1 -0
- package/dist/commands/doctor.d.ts +12 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +68 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/document.d.ts +17 -0
- package/dist/commands/document.d.ts.map +1 -0
- package/dist/commands/document.js +217 -0
- package/dist/commands/document.js.map +1 -0
- package/dist/commands/init.d.ts +31 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +535 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.d.ts +24 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +128 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/migrate.d.ts +30 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +115 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/module.d.ts +32 -0
- package/dist/commands/module.d.ts.map +1 -0
- package/dist/commands/module.js +285 -0
- package/dist/commands/module.js.map +1 -0
- package/dist/commands/pack.d.ts +22 -0
- package/dist/commands/pack.d.ts.map +1 -0
- package/dist/commands/pack.js +481 -0
- package/dist/commands/pack.js.map +1 -0
- package/dist/commands/payment.d.ts +15 -0
- package/dist/commands/payment.d.ts.map +1 -0
- package/dist/commands/payment.js +97 -0
- package/dist/commands/payment.js.map +1 -0
- package/dist/commands/register.d.ts +20 -0
- package/dist/commands/register.d.ts.map +1 -0
- package/dist/commands/register.js +134 -0
- package/dist/commands/register.js.map +1 -0
- package/dist/commands/status.d.ts +8 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +134 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/whoami.d.ts +21 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +133 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/company.d.ts +16 -0
- package/dist/company.d.ts.map +1 -0
- package/dist/company.js +26 -0
- package/dist/company.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +50 -0
- package/dist/config.js.map +1 -0
- package/dist/connection.d.ts +79 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +116 -0
- package/dist/connection.js.map +1 -0
- package/dist/context.d.ts +47 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +93 -0
- package/dist/context.js.map +1 -0
- package/dist/doctor.d.ts +45 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +448 -0
- package/dist/doctor.js.map +1 -0
- package/dist/grants.d.ts +88 -0
- package/dist/grants.d.ts.map +1 -0
- package/dist/grants.js +174 -0
- package/dist/grants.js.map +1 -0
- package/dist/identity.d.ts +54 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +132 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory.d.ts +155 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +303 -0
- package/dist/inventory.js.map +1 -0
- package/dist/migrations.d.ts +76 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +226 -0
- package/dist/migrations.js.map +1 -0
- package/dist/module/read.d.ts +91 -0
- package/dist/module/read.d.ts.map +1 -0
- package/dist/module/read.js +172 -0
- package/dist/module/read.js.map +1 -0
- package/dist/output.d.ts +110 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +173 -0
- package/dist/output.js.map +1 -0
- package/dist/pack/certification.d.ts +27 -0
- package/dist/pack/certification.d.ts.map +1 -0
- package/dist/pack/certification.js +38 -0
- package/dist/pack/certification.js.map +1 -0
- package/dist/pack/compile.d.ts +75 -0
- package/dist/pack/compile.d.ts.map +1 -0
- package/dist/pack/compile.js +801 -0
- package/dist/pack/compile.js.map +1 -0
- package/dist/pack/filing.d.ts +48 -0
- package/dist/pack/filing.d.ts.map +1 -0
- package/dist/pack/filing.js +56 -0
- package/dist/pack/filing.js.map +1 -0
- package/dist/pack/read.d.ts +766 -0
- package/dist/pack/read.d.ts.map +1 -0
- package/dist/pack/read.js +2336 -0
- package/dist/pack/read.js.map +1 -0
- package/dist/pack/schema.d.ts +26 -0
- package/dist/pack/schema.d.ts.map +1 -0
- package/dist/pack/schema.js +181 -0
- package/dist/pack/schema.js.map +1 -0
- package/dist/pack/territories.d.ts +98 -0
- package/dist/pack/territories.d.ts.map +1 -0
- package/dist/pack/territories.js +0 -0
- package/dist/pack/territories.js.map +1 -0
- package/dist/pack/upgrade.d.ts +86 -0
- package/dist/pack/upgrade.d.ts.map +1 -0
- package/dist/pack/upgrade.js +76 -0
- package/dist/pack/upgrade.js.map +1 -0
- package/dist/pack/vat-codes.d.ts +273 -0
- package/dist/pack/vat-codes.d.ts.map +1 -0
- package/dist/pack/vat-codes.js +513 -0
- package/dist/pack/vat-codes.js.map +1 -0
- package/dist/profiles.d.ts +67 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +187 -0
- package/dist/profiles.js.map +1 -0
- package/dist/prompt.d.ts +40 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +120 -0
- package/dist/prompt.js.map +1 -0
- package/dist/registry.d.ts +84 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +104 -0
- package/dist/registry.js.map +1 -0
- package/dist/rest.d.ts +81 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +245 -0
- package/dist/rest.js.map +1 -0
- package/dist/schema.d.ts +15 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +15 -0
- package/dist/schema.js.map +1 -0
- package/dist/seeds.d.ts +27 -0
- package/dist/seeds.d.ts.map +1 -0
- package/dist/seeds.js +47 -0
- package/dist/seeds.js.map +1 -0
- package/dist/session.d.ts +39 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +92 -0
- package/dist/session.js.map +1 -0
- package/dist/sql.d.ts +48 -0
- package/dist/sql.d.ts.map +1 -0
- package/dist/sql.js +112 -0
- package/dist/sql.js.map +1 -0
- package/dist/status.d.ts +94 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +120 -0
- package/dist/status.js.map +1 -0
- package/dist/ui.d.ts +55 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +114 -0
- package/dist/ui.js.map +1 -0
- package/package.json +29 -0
- package/schema/output.1.json +613 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
-- Ekwo OS — a country has charts of accounts, not one chart.
|
|
2
|
+
--
|
|
3
|
+
-- `account_templates` was keyed on `(country, code)`, which says a country
|
|
4
|
+
-- has exactly one chart. That is false in both countries this release ships:
|
|
5
|
+
-- a Belgian ASBL keeps its books on the PCMN adapted by the royal decree of
|
|
6
|
+
-- 2019, a French association on the plan comptable of ANC 2018-06, and both
|
|
7
|
+
-- differ from the chart a company uses while sharing its taxes and its VAT
|
|
8
|
+
-- return. It is false again in Germany (SKR03 and SKR04) and wherever a
|
|
9
|
+
-- profession has its own chart.
|
|
10
|
+
--
|
|
11
|
+
-- So a chart becomes a dimension:
|
|
12
|
+
--
|
|
13
|
+
-- `chart_templates` the charts a country offers, one of them its
|
|
14
|
+
-- default, each naming the statements it
|
|
15
|
+
-- reports on and the audience it is for.
|
|
16
|
+
-- `account_templates.chart_code` which chart a template account belongs to;
|
|
17
|
+
-- the natural key becomes
|
|
18
|
+
-- `(country, chart_code, code)`.
|
|
19
|
+
-- `company_packs.chart_code` which chart a company copied.
|
|
20
|
+
--
|
|
21
|
+
-- `default` is the value every existing row is backfilled with. It is a
|
|
22
|
+
-- mechanism word, not a country and not a chart name: the pack says the chart
|
|
23
|
+
-- is called PCMN or PCG, in its own data, where a name belongs.
|
|
24
|
+
--
|
|
25
|
+
-- **Journals do not get a chart.** A country's journals, its taxes and its
|
|
26
|
+
-- declaration form are common to its charts: an association buys, sells and
|
|
27
|
+
-- banks through the same journals as a company, and files the same VAT
|
|
28
|
+
-- return. Only the accounts differ, and the statements that present them.
|
|
29
|
+
-- The day a chart genuinely needs its own journal, `journal_templates` takes
|
|
30
|
+
-- the same column; nothing here forecloses it.
|
|
31
|
+
--
|
|
32
|
+
-- **The roles stay on `country_defaults`.** Which account is receivable,
|
|
33
|
+
-- payable or suspense is declared once per country, and `ekwo pack check`
|
|
34
|
+
-- refuses a pack whose role codes — and whose tax posting accounts — are not
|
|
35
|
+
-- in *every* chart it ships. That is the constraint that lets one set of
|
|
36
|
+
-- taxes install on any chart of the country, and it is checked where it can
|
|
37
|
+
-- be read, in the pack, rather than discovered at install time.
|
|
38
|
+
|
|
39
|
+
-- ---------------------------------------------------------------------------
|
|
40
|
+
-- chart_templates
|
|
41
|
+
-- ---------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
create table if not exists chart_templates (
|
|
44
|
+
country char(2) not null,
|
|
45
|
+
code text not null,
|
|
46
|
+
name text not null,
|
|
47
|
+
name_i18n jsonb not null default '{}'::jsonb,
|
|
48
|
+
is_default boolean not null default false,
|
|
49
|
+
audience text,
|
|
50
|
+
statements text[] not null default '{}'::text[],
|
|
51
|
+
certification_status pack_certification,
|
|
52
|
+
legal_reference text,
|
|
53
|
+
primary key (country, code),
|
|
54
|
+
constraint chart_templates_country_format check (country ~ '^[A-Z]{2}$')
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
comment on table chart_templates is
|
|
58
|
+
'Charts of accounts a country offers, from the `charts` list of packs/<cc>/pack.json. One of them is the default `ekwo init` installs when nobody names one.';
|
|
59
|
+
comment on column chart_templates.code is
|
|
60
|
+
'Immutable once published. `default` on the chart a country shipped before this table existed.';
|
|
61
|
+
comment on column chart_templates.audience is
|
|
62
|
+
'Who keeps books on this chart — companies, nonprofits, a profession. Free text from the pack: the core does nothing with it, an installer shows it.';
|
|
63
|
+
comment on column chart_templates.statements is
|
|
64
|
+
'Codes of the financial statements this chart reports on. Empty means the generic framework by account type is all there is.';
|
|
65
|
+
comment on column chart_templates.certification_status is
|
|
66
|
+
'How much this chart in particular has been read, when it differs from the pack as a whole. Null means the pack''s own status stands.';
|
|
67
|
+
|
|
68
|
+
-- One default per country, and a country with charts has one.
|
|
69
|
+
create unique index if not exists chart_templates_one_default_idx
|
|
70
|
+
on chart_templates (country) where is_default;
|
|
71
|
+
|
|
72
|
+
-- ---------------------------------------------------------------------------
|
|
73
|
+
-- account_templates gains its chart
|
|
74
|
+
--
|
|
75
|
+
-- The column lands with a default so every published row is `default`, then
|
|
76
|
+
-- the unique key is widened. The old key has to go: `(country, code)` would
|
|
77
|
+
-- refuse the second chart's 400000 outright.
|
|
78
|
+
-- ---------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
alter table account_templates
|
|
81
|
+
add column if not exists chart_code text not null default 'default';
|
|
82
|
+
|
|
83
|
+
comment on column account_templates.chart_code is
|
|
84
|
+
'Which chart of the country this account belongs to. Part of the natural key: two charts of one country may carry the same code with different meanings.';
|
|
85
|
+
|
|
86
|
+
do $$
|
|
87
|
+
begin
|
|
88
|
+
if exists (
|
|
89
|
+
select 1 from pg_constraint
|
|
90
|
+
where conname = 'account_templates_country_code_key'
|
|
91
|
+
and conrelid = 'account_templates'::regclass
|
|
92
|
+
) then
|
|
93
|
+
alter table account_templates drop constraint account_templates_country_code_key;
|
|
94
|
+
end if;
|
|
95
|
+
end;
|
|
96
|
+
$$;
|
|
97
|
+
|
|
98
|
+
create unique index if not exists account_templates_chart_code_idx
|
|
99
|
+
on account_templates (country, chart_code, code);
|
|
100
|
+
|
|
101
|
+
-- Every country that already holds a chart holds one called `default`. The
|
|
102
|
+
-- name is the code until a pack says better — and the compiled seed of every
|
|
103
|
+
-- pack says better on the next `psql -f`.
|
|
104
|
+
insert into chart_templates (country, code, name, is_default)
|
|
105
|
+
select distinct t.country, t.chart_code, t.chart_code, true
|
|
106
|
+
from account_templates t
|
|
107
|
+
on conflict (country, code) do nothing;
|
|
108
|
+
|
|
109
|
+
alter table account_templates
|
|
110
|
+
drop constraint if exists account_templates_chart_fk;
|
|
111
|
+
alter table account_templates
|
|
112
|
+
add constraint account_templates_chart_fk
|
|
113
|
+
foreign key (country, chart_code) references chart_templates (country, code);
|
|
114
|
+
|
|
115
|
+
-- ---------------------------------------------------------------------------
|
|
116
|
+
-- company_packs remembers which chart
|
|
117
|
+
-- ---------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
alter table company_packs
|
|
120
|
+
add column if not exists chart_code text not null default 'default';
|
|
121
|
+
|
|
122
|
+
comment on column company_packs.chart_code is
|
|
123
|
+
'Chart of the pack this company copied. `ekwo status` prints it, and `ekwo pack upgrade` compares against the same chart.';
|
|
124
|
+
|
|
125
|
+
-- ---------------------------------------------------------------------------
|
|
126
|
+
-- install_country_template, on a chart
|
|
127
|
+
--
|
|
128
|
+
-- Four arguments now, so the three-argument version is dropped first: an
|
|
129
|
+
-- overload with a default would make the existing three-argument call
|
|
130
|
+
-- ambiguous and PostgreSQL would refuse it.
|
|
131
|
+
-- ---------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
drop function if exists install_country_template(uuid, char, char);
|
|
134
|
+
|
|
135
|
+
create or replace function install_country_template(
|
|
136
|
+
p_company_id uuid,
|
|
137
|
+
p_country char(2),
|
|
138
|
+
p_language char(2) default null,
|
|
139
|
+
p_chart_code text default null
|
|
140
|
+
)
|
|
141
|
+
returns void
|
|
142
|
+
language plpgsql
|
|
143
|
+
as $$
|
|
144
|
+
declare
|
|
145
|
+
v_defaults country_defaults%rowtype;
|
|
146
|
+
r record;
|
|
147
|
+
v_tax_id uuid;
|
|
148
|
+
v_language char(2);
|
|
149
|
+
v_version text;
|
|
150
|
+
v_chart text;
|
|
151
|
+
v_charts text;
|
|
152
|
+
begin
|
|
153
|
+
if not exists (select 1 from companies where id = p_company_id) then
|
|
154
|
+
raise exception 'unknown_company: %', p_company_id;
|
|
155
|
+
end if;
|
|
156
|
+
|
|
157
|
+
-- Which chart. The caller names one, or the pack's default stands. A named
|
|
158
|
+
-- chart that does not exist is an error that lists what does: guessing here
|
|
159
|
+
-- would install the wrong plan of accounts and nobody would notice for a
|
|
160
|
+
-- year.
|
|
161
|
+
if p_chart_code is null then
|
|
162
|
+
select c.code into v_chart
|
|
163
|
+
from chart_templates c
|
|
164
|
+
where c.country = p_country and c.is_default;
|
|
165
|
+
if v_chart is null then
|
|
166
|
+
-- No pack for this country, or a pack that names no default chart.
|
|
167
|
+
raise exception 'unknown_country_template: no chart of accounts seeded for %', p_country;
|
|
168
|
+
end if;
|
|
169
|
+
else
|
|
170
|
+
select c.code into v_chart
|
|
171
|
+
from chart_templates c
|
|
172
|
+
where c.country = p_country and c.code = p_chart_code;
|
|
173
|
+
if v_chart is null then
|
|
174
|
+
select string_agg(c.code, ', ' order by c.code) into v_charts
|
|
175
|
+
from chart_templates c where c.country = p_country;
|
|
176
|
+
raise exception 'unknown_chart: % has no chart %. It has: %',
|
|
177
|
+
p_country, p_chart_code, coalesce(v_charts, 'none');
|
|
178
|
+
end if;
|
|
179
|
+
end if;
|
|
180
|
+
|
|
181
|
+
if not exists (
|
|
182
|
+
select 1 from account_templates
|
|
183
|
+
where country = p_country and chart_code = v_chart
|
|
184
|
+
) then
|
|
185
|
+
raise exception 'unknown_country_template: chart % of % holds no account', v_chart, p_country;
|
|
186
|
+
end if;
|
|
187
|
+
|
|
188
|
+
-- The language of the copy: what the caller asked for, else what the
|
|
189
|
+
-- company keeps its books in.
|
|
190
|
+
select coalesce(p_language, c.language) into v_language
|
|
191
|
+
from companies c where c.id = p_company_id;
|
|
192
|
+
|
|
193
|
+
-- 1. Accounts, without the hierarchy.
|
|
194
|
+
insert into accounts (company_id, code, name, name_i18n, statement_hint,
|
|
195
|
+
account_type, reconcilable)
|
|
196
|
+
select p_company_id, t.code,
|
|
197
|
+
coalesce(nullif(t.name_i18n ->> v_language, ''), t.name),
|
|
198
|
+
t.name_i18n, t.statement_hint, t.account_type, t.reconcilable
|
|
199
|
+
from account_templates t
|
|
200
|
+
where t.country = p_country
|
|
201
|
+
and t.chart_code = v_chart
|
|
202
|
+
on conflict (company_id, code) do nothing;
|
|
203
|
+
|
|
204
|
+
-- 2. Hierarchy, now that every code exists.
|
|
205
|
+
update accounts a
|
|
206
|
+
set parent_id = p.id
|
|
207
|
+
from account_templates t
|
|
208
|
+
join accounts p on p.company_id = p_company_id and p.code = t.parent_code
|
|
209
|
+
where a.company_id = p_company_id
|
|
210
|
+
and a.code = t.code
|
|
211
|
+
and t.country = p_country
|
|
212
|
+
and t.chart_code = v_chart
|
|
213
|
+
and t.parent_code is not null
|
|
214
|
+
and a.parent_id is null;
|
|
215
|
+
|
|
216
|
+
-- 3. Journals. Common to every chart of the country.
|
|
217
|
+
insert into journals (company_id, code, name, journal_type)
|
|
218
|
+
select p_company_id, t.code, t.name, t.journal_type
|
|
219
|
+
from journal_templates t
|
|
220
|
+
where t.country = p_country
|
|
221
|
+
on conflict (company_id, code) do nothing;
|
|
222
|
+
|
|
223
|
+
-- 4. Taxes and their postings. Also common: a chart changes how a company
|
|
224
|
+
-- presents itself, not what it owes.
|
|
225
|
+
for r in
|
|
226
|
+
select * from tax_templates where country = p_country order by sequence, code
|
|
227
|
+
loop
|
|
228
|
+
v_tax_id := null;
|
|
229
|
+
insert into taxes (company_id, code, name, description, amount_type, amount,
|
|
230
|
+
applies_to, treatment, country, valid_from, valid_to,
|
|
231
|
+
legal_reference, vat_category, exemption_code, sequence,
|
|
232
|
+
tax_kind, recoverable, jurisdiction, price_include,
|
|
233
|
+
cash_basis, cash_basis_transition_account_id)
|
|
234
|
+
values (p_company_id, r.code, r.name, r.description, r.amount_type, r.amount,
|
|
235
|
+
r.applies_to, r.treatment, p_country, r.valid_from, r.valid_to,
|
|
236
|
+
r.legal_reference, r.vat_category, r.exemption_code, r.sequence,
|
|
237
|
+
r.tax_kind, r.recoverable, r.jurisdiction, r.price_include,
|
|
238
|
+
r.cash_basis, account_id_by_code(p_company_id, r.cash_basis_transition_account_code))
|
|
239
|
+
on conflict (company_id, code) do nothing
|
|
240
|
+
returning id into v_tax_id;
|
|
241
|
+
|
|
242
|
+
if v_tax_id is null then
|
|
243
|
+
continue;
|
|
244
|
+
end if;
|
|
245
|
+
|
|
246
|
+
insert into tax_postings (tax_id, company_id, document_kind, posting_type,
|
|
247
|
+
factor_percent, account_id, declaration_box,
|
|
248
|
+
box_factor_percent, report_code, sequence)
|
|
249
|
+
select v_tax_id, p_company_id, tp.document_kind, tp.posting_type,
|
|
250
|
+
tp.factor_percent, account_id_by_code(p_company_id, tp.account_code),
|
|
251
|
+
tp.declaration_box, tp.box_factor_percent, tp.report_code, tp.sequence
|
|
252
|
+
from tax_posting_templates tp
|
|
253
|
+
where tp.tax_template_id = r.id
|
|
254
|
+
order by tp.sequence;
|
|
255
|
+
end loop;
|
|
256
|
+
|
|
257
|
+
-- 5. Roles.
|
|
258
|
+
select * into v_defaults from country_defaults where country = p_country;
|
|
259
|
+
if found then
|
|
260
|
+
update companies c
|
|
261
|
+
set receivable_account_id = coalesce(c.receivable_account_id, account_id_by_code(p_company_id, v_defaults.receivable_code)),
|
|
262
|
+
payable_account_id = coalesce(c.payable_account_id, account_id_by_code(p_company_id, v_defaults.payable_code)),
|
|
263
|
+
suspense_account_id = coalesce(c.suspense_account_id, account_id_by_code(p_company_id, v_defaults.suspense_code)),
|
|
264
|
+
rounding_account_id = coalesce(c.rounding_account_id, account_id_by_code(p_company_id, v_defaults.rounding_code)),
|
|
265
|
+
retained_earnings_account_id = coalesce(c.retained_earnings_account_id, account_id_by_code(p_company_id, v_defaults.retained_earnings_code)),
|
|
266
|
+
default_sales_account_id = coalesce(c.default_sales_account_id, account_id_by_code(p_company_id, v_defaults.sales_account_code)),
|
|
267
|
+
default_purchase_account_id = coalesce(c.default_purchase_account_id, account_id_by_code(p_company_id, v_defaults.purchase_account_code)),
|
|
268
|
+
sales_journal_id = coalesce(c.sales_journal_id, (select id from journals where company_id = p_company_id and code = v_defaults.sales_journal_code)),
|
|
269
|
+
purchase_journal_id = coalesce(c.purchase_journal_id, (select id from journals where company_id = p_company_id and code = v_defaults.purchase_journal_code)),
|
|
270
|
+
miscellaneous_journal_id = coalesce(c.miscellaneous_journal_id, (select id from journals where company_id = p_company_id and code = v_defaults.misc_journal_code))
|
|
271
|
+
where c.id = p_company_id;
|
|
272
|
+
|
|
273
|
+
-- 6. The financial journals point at their account.
|
|
274
|
+
update journals j
|
|
275
|
+
set default_account_id = account_id_by_code(p_company_id, v_defaults.bank_account_code)
|
|
276
|
+
where j.company_id = p_company_id
|
|
277
|
+
and j.journal_type = 'bank'
|
|
278
|
+
and j.default_account_id is null
|
|
279
|
+
and v_defaults.bank_account_code is not null;
|
|
280
|
+
|
|
281
|
+
update journals j
|
|
282
|
+
set default_account_id = account_id_by_code(p_company_id, v_defaults.cash_account_code)
|
|
283
|
+
where j.company_id = p_company_id
|
|
284
|
+
and j.journal_type = 'cash'
|
|
285
|
+
and j.default_account_id is null
|
|
286
|
+
and v_defaults.cash_account_code is not null;
|
|
287
|
+
end if;
|
|
288
|
+
|
|
289
|
+
-- 7. What was copied, from which version, and on which chart.
|
|
290
|
+
v_version := coalesce((select version from country_packs where country = p_country), '1.0.0');
|
|
291
|
+
|
|
292
|
+
insert into company_packs (company_id, country, version, chart_code)
|
|
293
|
+
values (p_company_id, p_country, v_version, v_chart)
|
|
294
|
+
on conflict (company_id, country) do update
|
|
295
|
+
set version = excluded.version,
|
|
296
|
+
chart_code = excluded.chart_code,
|
|
297
|
+
upgraded_at = now()
|
|
298
|
+
where company_packs.version is distinct from excluded.version
|
|
299
|
+
or company_packs.chart_code is distinct from excluded.chart_code;
|
|
300
|
+
end;
|
|
301
|
+
$$;
|
|
302
|
+
|
|
303
|
+
comment on function install_country_template(uuid, char, char, text) is
|
|
304
|
+
'Copies one chart of a country pack into a company in one language, with the country''s journals and taxes, wires the default roles, and records the pack version and the chart in company_packs.';
|
|
305
|
+
|
|
306
|
+
-- Companies installed before this migration copied the chart that was the
|
|
307
|
+
-- only one: `default`, which their `company_packs` row now carries by the
|
|
308
|
+
-- column's own default.
|
|
309
|
+
|
|
310
|
+
-- ---------------------------------------------------------------------------
|
|
311
|
+
-- Row level security
|
|
312
|
+
--
|
|
313
|
+
-- A chart is reference data, like the accounts it holds: any signed-in user
|
|
314
|
+
-- may read it, and nothing but the generated seed writes it.
|
|
315
|
+
-- ---------------------------------------------------------------------------
|
|
316
|
+
|
|
317
|
+
alter table chart_templates enable row level security;
|
|
318
|
+
|
|
319
|
+
create policy chart_templates_select on chart_templates
|
|
320
|
+
for select using (auth.uid() is not null);
|
|
321
|
+
|
|
322
|
+
comment on policy chart_templates_select on chart_templates is
|
|
323
|
+
'Reference data, readable by any signed-in user. No write policy: a chart comes from a pack.';
|
|
324
|
+
|
|
325
|
+
-- Rule 6 of supabase/migrations/README.md.
|
|
326
|
+
revoke execute on all functions in schema public from public;
|