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,274 @@
|
|
|
1
|
+
-- Ekwo OS — what a country requires on a document, as data.
|
|
2
|
+
--
|
|
3
|
+
-- An invoice is the one object where a country speaks loudest, and until this
|
|
4
|
+
-- migration the core answered for it: a number built as CODE/YYYY/NNNN, no
|
|
5
|
+
-- idea what the legal payment term was, no e-invoicing profile, no bank
|
|
6
|
+
-- format, and the legal mentions nowhere at all — a renderer either hard-coded
|
|
7
|
+
-- "Autoliquidation" or printed nothing. Three groups of columns and one table
|
|
8
|
+
-- move all of it into the pack.
|
|
9
|
+
--
|
|
10
|
+
-- **Nothing here is executable.** No function is added, no default is written
|
|
11
|
+
-- into the schema. Two views read the data so a renderer or the e-invoice
|
|
12
|
+
-- brick can print it, and that is the whole of the behaviour.
|
|
13
|
+
--
|
|
14
|
+
-- **No column carries a default**, for the reason P0-8 gave when it landed
|
|
15
|
+
-- the closing style: a default legal payment term is one country's law given
|
|
16
|
+
-- to every country that has not spoken. A silent pack gets null, and a reader
|
|
17
|
+
-- that needs the value raises by name rather than quietly printing Belgium's
|
|
18
|
+
-- answer on a Chilean invoice.
|
|
19
|
+
|
|
20
|
+
-- ---------------------------------------------------------------------------
|
|
21
|
+
-- The country model gains the document rules
|
|
22
|
+
--
|
|
23
|
+
-- `numbering_gapless` and `number_format` describe the number, and they are
|
|
24
|
+
-- two questions rather than one. Whether a number may skip is the law — most
|
|
25
|
+
-- of Europe forbids a hole, some countries only ask for an order. What the
|
|
26
|
+
-- number *looks like* is a pattern, and whether it restarts each year is
|
|
27
|
+
-- readable in the pattern itself, because a pattern that carries the year
|
|
28
|
+
-- restarts with it.
|
|
29
|
+
--
|
|
30
|
+
-- The grammar of `number_format` is four tokens and literal text around them:
|
|
31
|
+
--
|
|
32
|
+
-- {CODE} the journal or document-series code
|
|
33
|
+
-- {YYYY} the year of the document, four digits — {YY} for two
|
|
34
|
+
-- {MM} the month, two digits
|
|
35
|
+
-- {NNNN} the counter, zero-padded to as many N as are written
|
|
36
|
+
--
|
|
37
|
+
-- `next_entry_number()` builds `CODE/YYYY/NNNN` today and does not read this
|
|
38
|
+
-- column: a numbering engine that consumes a pattern is its own change, and
|
|
39
|
+
-- the two packs that exist declare exactly the pattern the engine produces, so
|
|
40
|
+
-- nothing moves under anybody's feet when it does.
|
|
41
|
+
--
|
|
42
|
+
-- `tax_point_rule` is the country's general rule, and the exception lives on
|
|
43
|
+
-- the tax: France taxes goods on delivery and services on collection, and the
|
|
44
|
+
-- second is `taxes.cash_basis`, not a second country column.
|
|
45
|
+
alter table country_defaults
|
|
46
|
+
add column if not exists numbering_gapless boolean,
|
|
47
|
+
add column if not exists number_format text,
|
|
48
|
+
add column if not exists legal_payment_days integer,
|
|
49
|
+
add column if not exists late_payment_reference text,
|
|
50
|
+
add column if not exists tax_point_rule text,
|
|
51
|
+
add column if not exists einvoice_profile text,
|
|
52
|
+
add column if not exists einvoice_mandatory_from date,
|
|
53
|
+
add column if not exists party_scheme text,
|
|
54
|
+
add column if not exists vat_scheme text,
|
|
55
|
+
add column if not exists bank_statement_formats text[],
|
|
56
|
+
add column if not exists payment_formats text[],
|
|
57
|
+
add column if not exists fiscal_year_default text;
|
|
58
|
+
|
|
59
|
+
comment on column country_defaults.numbering_gapless is
|
|
60
|
+
'True where the law forbids a hole in the sequence of invoice numbers. Null until the pack says so.';
|
|
61
|
+
comment on column country_defaults.number_format is
|
|
62
|
+
'Pattern of a document number: {CODE}, {YYYY} or {YY}, {MM}, {NNNN} zero-padded to as many N as are written, with literal text between them. Read by nothing yet; next_entry_number() produces CODE/YYYY/NNNN.';
|
|
63
|
+
comment on column country_defaults.legal_payment_days is
|
|
64
|
+
'Payment term the law sets in the absence of an agreement, in days. Not a company''s own terms, which are documents.payment_terms.';
|
|
65
|
+
comment on column country_defaults.late_payment_reference is
|
|
66
|
+
'Where the interest rate and the recovery indemnity for a late payment come from, in one sentence a renderer can print or an accountant can follow.';
|
|
67
|
+
comment on column country_defaults.tax_point_rule is
|
|
68
|
+
'When the tax becomes chargeable under this country''s general rule. A tax that departs from it says so itself, with cash_basis.';
|
|
69
|
+
comment on column country_defaults.einvoice_profile is
|
|
70
|
+
'The structured invoice this country expects: peppol-bis-3, factur-x-en16931, xrechnung, a PINT profile. Null where electronic invoicing is not a thing.';
|
|
71
|
+
comment on column country_defaults.einvoice_mandatory_from is
|
|
72
|
+
'The day the obligation starts. Where reception and emission start on different days, this is reception, which is what binds every company at once.';
|
|
73
|
+
comment on column country_defaults.party_scheme is
|
|
74
|
+
'ISO 6523 ICD of the identifier a party is addressed by on the network, four digits. The pack carries the value; the core never guesses one.';
|
|
75
|
+
comment on column country_defaults.vat_scheme is
|
|
76
|
+
'ISO 6523 ICD of the VAT identifier, four digits. Distinct from party_scheme: a company is addressed by its registration number and taxed on its VAT number, and they are not the same identifier.';
|
|
77
|
+
comment on column country_defaults.bank_statement_formats is
|
|
78
|
+
'Statement formats a bank of this country delivers, most usual first. A list, because a country rarely has one.';
|
|
79
|
+
comment on column country_defaults.payment_formats is
|
|
80
|
+
'Payment initiation formats a bank of this country accepts, most usual first.';
|
|
81
|
+
comment on column country_defaults.fiscal_year_default is
|
|
82
|
+
'Month the financial year usually opens on: calendar, april, july, october. A default offered, never imposed — fiscal_years holds what a company actually keeps.';
|
|
83
|
+
|
|
84
|
+
alter table country_defaults
|
|
85
|
+
add constraint country_defaults_legal_payment_days_positive
|
|
86
|
+
check (legal_payment_days is null or legal_payment_days >= 0),
|
|
87
|
+
add constraint country_defaults_tax_point_rule_known
|
|
88
|
+
check (tax_point_rule is null or tax_point_rule in ('invoice_date', 'delivery_date', 'payment_date')),
|
|
89
|
+
add constraint country_defaults_party_scheme_format
|
|
90
|
+
check (party_scheme is null or party_scheme ~ '^[0-9]{4}$'),
|
|
91
|
+
add constraint country_defaults_vat_scheme_format
|
|
92
|
+
check (vat_scheme is null or vat_scheme ~ '^[0-9]{4}$'),
|
|
93
|
+
add constraint country_defaults_fiscal_year_default_known
|
|
94
|
+
check (fiscal_year_default is null or fiscal_year_default in ('calendar', 'april', 'july', 'october'));
|
|
95
|
+
|
|
96
|
+
-- ---------------------------------------------------------------------------
|
|
97
|
+
-- legal_mention_templates — the sentences a country requires on an invoice
|
|
98
|
+
--
|
|
99
|
+
-- `applies_when` is a **closed vocabulary**, not an expression language, for
|
|
100
|
+
-- the same reason a declaration total is a plus list and a minus list: an
|
|
101
|
+
-- accountant reads `reverse_charge` and knows what it means, and a pack that
|
|
102
|
+
-- could write a condition would be a pack that executes. Nine values cover
|
|
103
|
+
-- the European invoice; the day a country needs a tenth it is a discussion
|
|
104
|
+
-- about the core, not a field a pack may fill with anything.
|
|
105
|
+
--
|
|
106
|
+
-- always printed on every document of the country
|
|
107
|
+
-- reverse_charge the buyer accounts for the tax, domestically
|
|
108
|
+
-- intra_eu_goods an exempt supply of goods inside the Union
|
|
109
|
+
-- intra_eu_services a service taxed where the customer is
|
|
110
|
+
-- export a supply outside the Union
|
|
111
|
+
-- exempt an exemption that is not one of the three above
|
|
112
|
+
-- small_business the seller is under a franchise regime
|
|
113
|
+
-- late_payment interest and recovery costs, on what the seller issues
|
|
114
|
+
-- cash_basis the tax falls due when the invoice is paid
|
|
115
|
+
--
|
|
116
|
+
-- Like a declaration form, these are **not copied into a company**: an
|
|
117
|
+
-- operator does not get to rewrite the sentence the law demands. They are
|
|
118
|
+
-- reference data with a validity, and a wording that changes is a new row
|
|
119
|
+
-- with a `valid_from`, never an edit to the old one.
|
|
120
|
+
create table legal_mention_templates (
|
|
121
|
+
id uuid primary key default gen_random_uuid(),
|
|
122
|
+
country char(2) not null,
|
|
123
|
+
code text not null,
|
|
124
|
+
applies_when text not null,
|
|
125
|
+
text text not null,
|
|
126
|
+
text_i18n jsonb not null default '{}'::jsonb,
|
|
127
|
+
sequence integer not null default 10,
|
|
128
|
+
valid_from date not null default date '1970-01-01',
|
|
129
|
+
valid_to date,
|
|
130
|
+
legal_reference text,
|
|
131
|
+
unique (country, code),
|
|
132
|
+
constraint legal_mention_templates_country_format check (country ~ '^[A-Z]{2}$'),
|
|
133
|
+
constraint legal_mention_templates_validity check (valid_to is null or valid_to >= valid_from),
|
|
134
|
+
constraint legal_mention_templates_applies_when_known check (
|
|
135
|
+
applies_when in (
|
|
136
|
+
'always', 'reverse_charge', 'intra_eu_goods', 'intra_eu_services',
|
|
137
|
+
'export', 'exempt', 'small_business', 'late_payment', 'cash_basis'
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
comment on table legal_mention_templates is
|
|
143
|
+
'The sentences a country requires on an invoice, and the closed condition that says when each applies. Reference data filled by a pack, never copied into a company.';
|
|
144
|
+
comment on column legal_mention_templates.applies_when is
|
|
145
|
+
'One of nine conditions. A closed vocabulary and not an expression: a pack that could write a condition would be a pack that executes.';
|
|
146
|
+
comment on column legal_mention_templates.text is
|
|
147
|
+
'The mention in the pack''s own language. Other languages are in text_i18n, by language code.';
|
|
148
|
+
comment on column legal_mention_templates.sequence is
|
|
149
|
+
'Order the mentions are printed in.';
|
|
150
|
+
comment on column legal_mention_templates.legal_reference is
|
|
151
|
+
'The article that requires this sentence. A mention without a source cannot be reviewed.';
|
|
152
|
+
|
|
153
|
+
create index legal_mention_templates_country_idx
|
|
154
|
+
on legal_mention_templates (country, sequence, code);
|
|
155
|
+
|
|
156
|
+
-- ---------------------------------------------------------------------------
|
|
157
|
+
-- document_legal_mentions — which of them apply to one document
|
|
158
|
+
--
|
|
159
|
+
-- A view, so it is a query and never a rule somebody can forget to call. The
|
|
160
|
+
-- join is deliberately small, and it decides on three things only:
|
|
161
|
+
--
|
|
162
|
+
-- 1. the country of the document, which is the company's `fiscal_country` —
|
|
163
|
+
-- the country whose VAT rules apply, not the company's address;
|
|
164
|
+
-- 2. the validity of the mention on the document's own date, so a reprint
|
|
165
|
+
-- of an old invoice carries the wording of its own year;
|
|
166
|
+
-- 3. the condition, resolved from the **treatments of the taxes the lines
|
|
167
|
+
-- carry** — which is where the reverse charge, the intra-EU exemption
|
|
168
|
+
-- and the export already live, so nothing new has to be recorded on a
|
|
169
|
+
-- document for its mentions to come out right.
|
|
170
|
+
--
|
|
171
|
+
-- Two conditions are not about a tax. `late_payment` is about the direction:
|
|
172
|
+
-- interest and recovery costs belong on what the seller issues, never on a
|
|
173
|
+
-- purchase invoice somebody else wrote. `small_business` is about a regime
|
|
174
|
+
-- the core does not record — there is no franchise flag on a company — so the
|
|
175
|
+
-- view **never selects it**, and says so here rather than pretending: the row
|
|
176
|
+
-- exists so a renderer that knows the regime can fetch the sentence by its
|
|
177
|
+
-- code, and the day the regime becomes a column this view gains one branch.
|
|
178
|
+
create or replace view document_legal_mentions
|
|
179
|
+
with (security_invoker = true) as
|
|
180
|
+
with document_taxes as (
|
|
181
|
+
select d.id as document_id,
|
|
182
|
+
d.company_id,
|
|
183
|
+
c.fiscal_country as country,
|
|
184
|
+
d.document_date,
|
|
185
|
+
d.doc_type,
|
|
186
|
+
coalesce(
|
|
187
|
+
array_agg(distinct t.treatment::text) filter (where t.treatment is not null),
|
|
188
|
+
array[]::text[]
|
|
189
|
+
) as treatments,
|
|
190
|
+
coalesce(bool_or(t.cash_basis), false) as on_cash_basis
|
|
191
|
+
from documents d
|
|
192
|
+
join companies c on c.id = d.company_id
|
|
193
|
+
left join document_lines l on l.document_id = d.id
|
|
194
|
+
left join taxes t on t.id = l.tax_id
|
|
195
|
+
group by d.id, d.company_id, c.fiscal_country, d.document_date, d.doc_type
|
|
196
|
+
)
|
|
197
|
+
select dt.document_id,
|
|
198
|
+
dt.company_id,
|
|
199
|
+
m.country,
|
|
200
|
+
m.code,
|
|
201
|
+
m.applies_when,
|
|
202
|
+
m.text,
|
|
203
|
+
m.text_i18n,
|
|
204
|
+
m.sequence,
|
|
205
|
+
m.legal_reference
|
|
206
|
+
from document_taxes dt
|
|
207
|
+
join legal_mention_templates m
|
|
208
|
+
on m.country = dt.country
|
|
209
|
+
and m.valid_from <= dt.document_date
|
|
210
|
+
and (m.valid_to is null or m.valid_to >= dt.document_date)
|
|
211
|
+
where case m.applies_when
|
|
212
|
+
when 'always' then true
|
|
213
|
+
when 'reverse_charge' then dt.treatments && array['domestic_reverse_charge']
|
|
214
|
+
when 'intra_eu_goods' then dt.treatments && array['intracom_goods', 'intracom_acquisition_goods']
|
|
215
|
+
when 'intra_eu_services' then dt.treatments && array['intracom_services', 'intracom_acquisition_services']
|
|
216
|
+
when 'export' then dt.treatments && array['export']
|
|
217
|
+
when 'exempt' then dt.treatments && array['exempt']
|
|
218
|
+
when 'cash_basis' then dt.on_cash_basis
|
|
219
|
+
when 'late_payment' then dt.doc_type in ('sale_invoice', 'sale_credit_note')
|
|
220
|
+
else false
|
|
221
|
+
end;
|
|
222
|
+
|
|
223
|
+
comment on view document_legal_mentions is
|
|
224
|
+
'The legal mentions that apply to a document: its country, the validity of the mention on its date, and the treatments of the taxes its lines carry. A small_business mention never comes out, because no column records the regime.';
|
|
225
|
+
|
|
226
|
+
-- ---------------------------------------------------------------------------
|
|
227
|
+
-- document_line_items gains what decides a mention on the line
|
|
228
|
+
--
|
|
229
|
+
-- The document-level sentence is the view above; what a line contributes to it
|
|
230
|
+
-- is its tax treatment, and EN 16931 asks for the exemption reason code beside
|
|
231
|
+
-- it (BT-121). Both were one join away and nobody had it, so a renderer that
|
|
232
|
+
-- wanted to say *why* a line carries no VAT had to go back to `taxes`.
|
|
233
|
+
create or replace view document_line_items
|
|
234
|
+
with (security_invoker = true) as
|
|
235
|
+
select l.id as document_line_id,
|
|
236
|
+
l.document_id,
|
|
237
|
+
l.company_id,
|
|
238
|
+
l.sequence,
|
|
239
|
+
l.line_type,
|
|
240
|
+
l.name as item_name, -- BT-153
|
|
241
|
+
l.description as item_description, -- BT-154
|
|
242
|
+
p.code as seller_item_identifier, -- BT-155
|
|
243
|
+
l.product_id,
|
|
244
|
+
p.kind as product_kind,
|
|
245
|
+
l.quantity, -- BT-129
|
|
246
|
+
l.unit_code, -- BT-130
|
|
247
|
+
l.unit_price, -- BT-146
|
|
248
|
+
l.discount_percent,
|
|
249
|
+
l.amount_untaxed, -- BT-131
|
|
250
|
+
l.tax_id,
|
|
251
|
+
l.vat_category, -- BT-151
|
|
252
|
+
l.vat_rate, -- BT-152
|
|
253
|
+
l.account_id,
|
|
254
|
+
t.treatment as tax_treatment,
|
|
255
|
+
t.exemption_code as tax_exemption_code, -- BT-121
|
|
256
|
+
t.cash_basis as tax_cash_basis
|
|
257
|
+
from document_lines l
|
|
258
|
+
left join products p on p.id = l.product_id
|
|
259
|
+
left join taxes t on t.id = l.tax_id;
|
|
260
|
+
|
|
261
|
+
comment on view document_line_items is
|
|
262
|
+
'Document lines with the EN 16931 item terms — BT-153 name, BT-154 description, BT-155 the seller identifier — and what decides a legal mention on the line: the treatment of its tax, its exemption reason (BT-121) and whether the tax falls due on collection.';
|
|
263
|
+
|
|
264
|
+
-- ---------------------------------------------------------------------------
|
|
265
|
+
-- Row level security
|
|
266
|
+
--
|
|
267
|
+
-- Read by anyone signed in, written by nobody: the sentence the law demands is
|
|
268
|
+
-- not something an operator edits, exactly like a box of a declaration form.
|
|
269
|
+
-- No policy for insert, update or delete, so the seed — which runs as the
|
|
270
|
+
-- owner — is the only thing that fills the table.
|
|
271
|
+
alter table legal_mention_templates enable row level security;
|
|
272
|
+
|
|
273
|
+
create policy legal_mention_templates_select on legal_mention_templates
|
|
274
|
+
for select using (auth.uid() is not null);
|