feat: document totals, VAT summary, stamp duty, withholding and installments (#48)
The engine now computes the totals of every document it saves: line amounts with cascaded discounts, footer discount on goods, VAT summary per tax code with the tax on the group total, prices with VAT split back once per group, split payment and cash-basis exigibility, stamp duty above the threshold of the fiscal pack, social security contribution, withholding (also on part of the amount) and ENASARCO taken off the amount to pay. Installments come from the payment terms with end of month, fixed day, the customer's excluded months and VAT on the first installment. The figures live in two shared tables keyed by family (ADR 0033) and are rewritten in the same transaction as the document. DocumentEditor serves the screens: radars, values proposed by party and item, totals preview without saving, linked documents and open documents to fulfil. The copy service can merge several documents of one party, the base of deferred invoicing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ddd2273f7e
commit
f12848865d
21 files changed
+1916
-31
No files matched your search
@@ -991,6 +991,26 @@ Migrazioni applicate in ordine:
|
||||
|
||||
- indice unico `ux_discount_policies_code` su `code`
|
||||
|
||||
#### `document_installments`
|
||||
|
||||
| Colonna | Tipo | Null | Default | Note |
|
||||
|---|---|---|---|---|
|
||||
| `id` | Int64 | no | | chiave primaria, identity |
|
||||
| `family` | String(40) | no | | |
|
||||
| `document_id` | Int64 | no | | |
|
||||
| `number` | Int32 | no | | |
|
||||
| `due_date` | Date | no | | |
|
||||
| `amount` | Decimal(19,6) | no | | |
|
||||
| `payment_method_id` | Int64 | sì | | -> `payment_methods` (Restrict) |
|
||||
| `created_at` | DateTimeUtc | no | | |
|
||||
| `created_by` | String(100) | sì | | |
|
||||
| `updated_at` | DateTimeUtc | sì | | |
|
||||
| `updated_by` | String(100) | sì | | |
|
||||
| `row_version` | Int64 | no | `1` | |
|
||||
|
||||
- indice `ix_document_installments_document` su `family`, `document_id`
|
||||
- indice `ix_document_installments_due` su `due_date`
|
||||
|
||||
#### `document_links`
|
||||
|
||||
| Colonna | Tipo | Null | Default | Note |
|
||||
@@ -1038,6 +1058,30 @@ Migrazioni applicate in ordine:
|
||||
|
||||
- indice unico `ux_document_numerators_code_year` su `code`, `year`
|
||||
|
||||
#### `document_tax_summaries`
|
||||
|
||||
| Colonna | Tipo | Null | Default | Note |
|
||||
|---|---|---|---|---|
|
||||
| `id` | Int64 | no | | chiave primaria, identity |
|
||||
| `family` | String(40) | no | | |
|
||||
| `document_id` | Int64 | no | | |
|
||||
| `tax_code_id` | Int64 | sì | | -> `tax_codes` (Restrict) |
|
||||
| `rate` | Decimal(19,6) | no | | |
|
||||
| `nature` | String(10) | sì | | |
|
||||
| `exigibility` | String(40) | no | | |
|
||||
| `non_deductible_percent` | Decimal(19,6) | no | `0` | |
|
||||
| `legal_reference` | String(100) | sì | | |
|
||||
| `taxable` | Decimal(19,6) | no | | |
|
||||
| `tax` | Decimal(19,6) | no | | |
|
||||
| `non_deductible_tax` | Decimal(19,6) | no | `0` | |
|
||||
| `created_at` | DateTimeUtc | no | | |
|
||||
| `created_by` | String(100) | sì | | |
|
||||
| `updated_at` | DateTimeUtc | sì | | |
|
||||
| `updated_by` | String(100) | sì | | |
|
||||
| `row_version` | Int64 | no | `1` | |
|
||||
|
||||
- indice `ix_document_tax_summaries_document` su `family`, `document_id`
|
||||
|
||||
#### `document_types`
|
||||
|
||||
| Colonna | Tipo | Null | Default | Note |
|
||||
@@ -1160,6 +1204,7 @@ Migrazioni applicate in ordine:
|
||||
| `fulfillment_closed` | Bool | no | `false` | |
|
||||
| `source_family` | String(40) | sì | | |
|
||||
| `source_line_id` | Int64 | sì | | |
|
||||
| `withholding_excluded` | Bool | no | `false` | |
|
||||
| `account_code` | String(20) | sì | | |
|
||||
| `cost_center_id` | Int64 | sì | | -> `cost_centers` (Restrict) |
|
||||
| `job_id` | Int64 | sì | | -> `jobs` (Restrict) |
|
||||
@@ -1227,6 +1272,27 @@ Migrazioni applicate in ordine:
|
||||
| `withholding_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `social_security_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `net_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `prices_include_tax` | Bool | no | `false` | |
|
||||
| `footer_discount_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `exigibility` | String(40) | sì | | |
|
||||
| `split_payment` | Bool | no | `false` | |
|
||||
| `stamp_duty_charged` | Bool | no | `false` | |
|
||||
| `withholding_rate` | Decimal(19,6) | sì | | |
|
||||
| `withholding_base_percent` | Decimal(19,6) | no | `100` | |
|
||||
| `withholding_type` | String(4) | sì | | |
|
||||
| `withholding_reason` | String(2) | sì | | |
|
||||
| `social_security_fund` | String(4) | sì | | |
|
||||
| `social_security_rate` | Decimal(19,6) | sì | | |
|
||||
| `social_security_tax_code_id` | Int64 | sì | | -> `tax_codes` (Restrict) |
|
||||
| `social_security_withheld` | Bool | no | `false` | |
|
||||
| `enasarco_rate` | Decimal(19,6) | sì | | |
|
||||
| `enasarco_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `cig` | String(15) | sì | | |
|
||||
| `cup` | String(15) | sì | | |
|
||||
| `transport_by` | String(40) | sì | | |
|
||||
| `related_document_id` | Int64 | sì | | -> `inventory_documents` (Restrict) |
|
||||
| `related_number` | String(30) | sì | | |
|
||||
| `related_date` | Date | sì | | |
|
||||
| `notes` | Text | sì | | |
|
||||
| `gl_entry_id` | Int64 | sì | | |
|
||||
| `vat_protocol` | Int64 | sì | | |
|
||||
@@ -1740,6 +1806,9 @@ Migrazioni applicate in ordine:
|
||||
| `updated_at` | DateTimeUtc | sì | | |
|
||||
| `updated_by` | String(100) | sì | | |
|
||||
| `row_version` | Int64 | no | `1` | |
|
||||
| `excluded_month1` | Int32 | sì | | |
|
||||
| `excluded_month2` | Int32 | sì | | |
|
||||
| `excluded_months_day` | Int32 | sì | | |
|
||||
|
||||
- indice unico `ux_party_sales_terms_party` su `party_id`
|
||||
|
||||
@@ -1867,6 +1936,7 @@ Migrazioni applicate in ordine:
|
||||
| `fulfillment_closed` | Bool | no | `false` | |
|
||||
| `source_family` | String(40) | sì | | |
|
||||
| `source_line_id` | Int64 | sì | | |
|
||||
| `withholding_excluded` | Bool | no | `false` | |
|
||||
| `account_code` | String(20) | sì | | |
|
||||
| `cost_center_id` | Int64 | sì | | -> `cost_centers` (Restrict) |
|
||||
| `job_id` | Int64 | sì | | -> `jobs` (Restrict) |
|
||||
@@ -1934,6 +2004,27 @@ Migrazioni applicate in ordine:
|
||||
| `withholding_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `social_security_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `net_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `prices_include_tax` | Bool | no | `false` | |
|
||||
| `footer_discount_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `exigibility` | String(40) | sì | | |
|
||||
| `split_payment` | Bool | no | `false` | |
|
||||
| `stamp_duty_charged` | Bool | no | `false` | |
|
||||
| `withholding_rate` | Decimal(19,6) | sì | | |
|
||||
| `withholding_base_percent` | Decimal(19,6) | no | `100` | |
|
||||
| `withholding_type` | String(4) | sì | | |
|
||||
| `withholding_reason` | String(2) | sì | | |
|
||||
| `social_security_fund` | String(4) | sì | | |
|
||||
| `social_security_rate` | Decimal(19,6) | sì | | |
|
||||
| `social_security_tax_code_id` | Int64 | sì | | -> `tax_codes` (Restrict) |
|
||||
| `social_security_withheld` | Bool | no | `false` | |
|
||||
| `enasarco_rate` | Decimal(19,6) | sì | | |
|
||||
| `enasarco_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `cig` | String(15) | sì | | |
|
||||
| `cup` | String(15) | sì | | |
|
||||
| `transport_by` | String(40) | sì | | |
|
||||
| `related_document_id` | Int64 | sì | | -> `purchase_documents` (Restrict) |
|
||||
| `related_number` | String(30) | sì | | |
|
||||
| `related_date` | Date | sì | | |
|
||||
| `notes` | Text | sì | | |
|
||||
| `gl_entry_id` | Int64 | sì | | |
|
||||
| `vat_protocol` | Int64 | sì | | |
|
||||
@@ -1976,6 +2067,7 @@ Migrazioni applicate in ordine:
|
||||
| `fulfillment_closed` | Bool | no | `false` | |
|
||||
| `source_family` | String(40) | sì | | |
|
||||
| `source_line_id` | Int64 | sì | | |
|
||||
| `withholding_excluded` | Bool | no | `false` | |
|
||||
| `account_code` | String(20) | sì | | |
|
||||
| `cost_center_id` | Int64 | sì | | -> `cost_centers` (Restrict) |
|
||||
| `job_id` | Int64 | sì | | -> `jobs` (Restrict) |
|
||||
@@ -2043,6 +2135,27 @@ Migrazioni applicate in ordine:
|
||||
| `withholding_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `social_security_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `net_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `prices_include_tax` | Bool | no | `false` | |
|
||||
| `footer_discount_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `exigibility` | String(40) | sì | | |
|
||||
| `split_payment` | Bool | no | `false` | |
|
||||
| `stamp_duty_charged` | Bool | no | `false` | |
|
||||
| `withholding_rate` | Decimal(19,6) | sì | | |
|
||||
| `withholding_base_percent` | Decimal(19,6) | no | `100` | |
|
||||
| `withholding_type` | String(4) | sì | | |
|
||||
| `withholding_reason` | String(2) | sì | | |
|
||||
| `social_security_fund` | String(4) | sì | | |
|
||||
| `social_security_rate` | Decimal(19,6) | sì | | |
|
||||
| `social_security_tax_code_id` | Int64 | sì | | -> `tax_codes` (Restrict) |
|
||||
| `social_security_withheld` | Bool | no | `false` | |
|
||||
| `enasarco_rate` | Decimal(19,6) | sì | | |
|
||||
| `enasarco_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `cig` | String(15) | sì | | |
|
||||
| `cup` | String(15) | sì | | |
|
||||
| `transport_by` | String(40) | sì | | |
|
||||
| `related_document_id` | Int64 | sì | | -> `purchase_orders` (Restrict) |
|
||||
| `related_number` | String(30) | sì | | |
|
||||
| `related_date` | Date | sì | | |
|
||||
| `notes` | Text | sì | | |
|
||||
| `gl_entry_id` | Int64 | sì | | |
|
||||
| `vat_protocol` | Int64 | sì | | |
|
||||
@@ -2118,6 +2231,7 @@ Migrazioni applicate in ordine:
|
||||
| `fulfillment_closed` | Bool | no | `false` | |
|
||||
| `source_family` | String(40) | sì | | |
|
||||
| `source_line_id` | Int64 | sì | | |
|
||||
| `withholding_excluded` | Bool | no | `false` | |
|
||||
| `account_code` | String(20) | sì | | |
|
||||
| `cost_center_id` | Int64 | sì | | -> `cost_centers` (Restrict) |
|
||||
| `job_id` | Int64 | sì | | -> `jobs` (Restrict) |
|
||||
@@ -2185,6 +2299,27 @@ Migrazioni applicate in ordine:
|
||||
| `withholding_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `social_security_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `net_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `prices_include_tax` | Bool | no | `false` | |
|
||||
| `footer_discount_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `exigibility` | String(40) | sì | | |
|
||||
| `split_payment` | Bool | no | `false` | |
|
||||
| `stamp_duty_charged` | Bool | no | `false` | |
|
||||
| `withholding_rate` | Decimal(19,6) | sì | | |
|
||||
| `withholding_base_percent` | Decimal(19,6) | no | `100` | |
|
||||
| `withholding_type` | String(4) | sì | | |
|
||||
| `withholding_reason` | String(2) | sì | | |
|
||||
| `social_security_fund` | String(4) | sì | | |
|
||||
| `social_security_rate` | Decimal(19,6) | sì | | |
|
||||
| `social_security_tax_code_id` | Int64 | sì | | -> `tax_codes` (Restrict) |
|
||||
| `social_security_withheld` | Bool | no | `false` | |
|
||||
| `enasarco_rate` | Decimal(19,6) | sì | | |
|
||||
| `enasarco_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `cig` | String(15) | sì | | |
|
||||
| `cup` | String(15) | sì | | |
|
||||
| `transport_by` | String(40) | sì | | |
|
||||
| `related_document_id` | Int64 | sì | | -> `sale_documents` (Restrict) |
|
||||
| `related_number` | String(30) | sì | | |
|
||||
| `related_date` | Date | sì | | |
|
||||
| `notes` | Text | sì | | |
|
||||
| `gl_entry_id` | Int64 | sì | | |
|
||||
| `vat_protocol` | Int64 | sì | | |
|
||||
@@ -2227,6 +2362,7 @@ Migrazioni applicate in ordine:
|
||||
| `fulfillment_closed` | Bool | no | `false` | |
|
||||
| `source_family` | String(40) | sì | | |
|
||||
| `source_line_id` | Int64 | sì | | |
|
||||
| `withholding_excluded` | Bool | no | `false` | |
|
||||
| `account_code` | String(20) | sì | | |
|
||||
| `cost_center_id` | Int64 | sì | | -> `cost_centers` (Restrict) |
|
||||
| `job_id` | Int64 | sì | | -> `jobs` (Restrict) |
|
||||
@@ -2294,6 +2430,27 @@ Migrazioni applicate in ordine:
|
||||
| `withholding_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `social_security_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `net_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `prices_include_tax` | Bool | no | `false` | |
|
||||
| `footer_discount_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `exigibility` | String(40) | sì | | |
|
||||
| `split_payment` | Bool | no | `false` | |
|
||||
| `stamp_duty_charged` | Bool | no | `false` | |
|
||||
| `withholding_rate` | Decimal(19,6) | sì | | |
|
||||
| `withholding_base_percent` | Decimal(19,6) | no | `100` | |
|
||||
| `withholding_type` | String(4) | sì | | |
|
||||
| `withholding_reason` | String(2) | sì | | |
|
||||
| `social_security_fund` | String(4) | sì | | |
|
||||
| `social_security_rate` | Decimal(19,6) | sì | | |
|
||||
| `social_security_tax_code_id` | Int64 | sì | | -> `tax_codes` (Restrict) |
|
||||
| `social_security_withheld` | Bool | no | `false` | |
|
||||
| `enasarco_rate` | Decimal(19,6) | sì | | |
|
||||
| `enasarco_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `cig` | String(15) | sì | | |
|
||||
| `cup` | String(15) | sì | | |
|
||||
| `transport_by` | String(40) | sì | | |
|
||||
| `related_document_id` | Int64 | sì | | -> `sale_orders` (Restrict) |
|
||||
| `related_number` | String(30) | sì | | |
|
||||
| `related_date` | Date | sì | | |
|
||||
| `notes` | Text | sì | | |
|
||||
| `gl_entry_id` | Int64 | sì | | |
|
||||
| `vat_protocol` | Int64 | sì | | |
|
||||
@@ -2336,6 +2493,7 @@ Migrazioni applicate in ordine:
|
||||
| `fulfillment_closed` | Bool | no | `false` | |
|
||||
| `source_family` | String(40) | sì | | |
|
||||
| `source_line_id` | Int64 | sì | | |
|
||||
| `withholding_excluded` | Bool | no | `false` | |
|
||||
| `account_code` | String(20) | sì | | |
|
||||
| `cost_center_id` | Int64 | sì | | -> `cost_centers` (Restrict) |
|
||||
| `job_id` | Int64 | sì | | -> `jobs` (Restrict) |
|
||||
@@ -2403,6 +2561,27 @@ Migrazioni applicate in ordine:
|
||||
| `withholding_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `social_security_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `net_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `prices_include_tax` | Bool | no | `false` | |
|
||||
| `footer_discount_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `exigibility` | String(40) | sì | | |
|
||||
| `split_payment` | Bool | no | `false` | |
|
||||
| `stamp_duty_charged` | Bool | no | `false` | |
|
||||
| `withholding_rate` | Decimal(19,6) | sì | | |
|
||||
| `withholding_base_percent` | Decimal(19,6) | no | `100` | |
|
||||
| `withholding_type` | String(4) | sì | | |
|
||||
| `withholding_reason` | String(2) | sì | | |
|
||||
| `social_security_fund` | String(4) | sì | | |
|
||||
| `social_security_rate` | Decimal(19,6) | sì | | |
|
||||
| `social_security_tax_code_id` | Int64 | sì | | -> `tax_codes` (Restrict) |
|
||||
| `social_security_withheld` | Bool | no | `false` | |
|
||||
| `enasarco_rate` | Decimal(19,6) | sì | | |
|
||||
| `enasarco_amount` | Decimal(19,6) | no | `0` | |
|
||||
| `cig` | String(15) | sì | | |
|
||||
| `cup` | String(15) | sì | | |
|
||||
| `transport_by` | String(40) | sì | | |
|
||||
| `related_document_id` | Int64 | sì | | -> `sale_quotations` (Restrict) |
|
||||
| `related_number` | String(30) | sì | | |
|
||||
| `related_date` | Date | sì | | |
|
||||
| `notes` | Text | sì | | |
|
||||
| `gl_entry_id` | Int64 | sì | | |
|
||||
| `vat_protocol` | Int64 | sì | | |
|
||||
|
||||
Reference in new issue
Block a user