diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-11 09:41:14 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-11 09:41:14 +0200 |
| commit | d83e5e8cd66f05ca7e6aa9fc645788313d89dfe7 (patch) | |
| tree | 987e9c3acc0232e2df2109d776f410bee591eacd /src/countries/nl.cpp | |
| parent | cf5dfa405fa3d9b480794f7f2c32e325fdfd134c (diff) | |
multi currency invoice handling for tax report
Diffstat (limited to 'src/countries/nl.cpp')
| -rw-r--r-- | src/countries/nl.cpp | 115 |
1 files changed, 58 insertions, 57 deletions
diff --git a/src/countries/nl.cpp b/src/countries/nl.cpp index bc45b59..cf79ee2 100644 --- a/src/countries/nl.cpp +++ b/src/countries/nl.cpp @@ -26,30 +26,30 @@ time_t _nl_get_default_invoice_expire_duration() void _nl_fill_tax_report_with_categories(tax_report* report) { - report->lines[report->line_count++] = tax_line {"taxes.nl.1", "", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.1a", "1a", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.1b", "1b", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.1c", "1c", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.1d", "1d", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.1e", "1e", 0.0f, 0.0f}; - - report->lines[report->line_count++] = tax_line {"taxes.nl.2", "", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.2a", "2a", 0.0f, 0.0f}; - - report->lines[report->line_count++] = tax_line {"taxes.nl.3", "", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.3a", "3a", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.3b", "3b", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.3c", "3c", 0.0f, 0.0f}; - - report->lines[report->line_count++] = tax_line {"taxes.nl.4", "", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.4a", "4a", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.4b", "4b", 0.0f, 0.0f}; - - report->lines[report->line_count++] = tax_line {"taxes.nl.5", "", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.5a", "5a", 0.0f, 0.0f}; - report->lines[report->line_count++] = tax_line {"taxes.nl.5b", "5b", 0.0f, 0.0f}; - - report->lines[report->line_count++] = tax_line {"taxes.total", "5c", 0.0f, 0.0f}; + report->lines[report->line_count++] = tax_line {"taxes.nl.1", "", 0.0f, 0.0f, false, false}; + report->lines[report->line_count++] = tax_line {"taxes.nl.1a", "1a", 0.0f, 0.0f, true, true}; + report->lines[report->line_count++] = tax_line {"taxes.nl.1b", "1b", 0.0f, 0.0f, true, true}; + report->lines[report->line_count++] = tax_line {"taxes.nl.1c", "1c", 0.0f, 0.0f, true, true}; + report->lines[report->line_count++] = tax_line {"taxes.nl.1d", "1d", 0.0f, 0.0f, true, true}; + report->lines[report->line_count++] = tax_line {"taxes.nl.1e", "1e", 0.0f, 0.0f, true, false}; + + report->lines[report->line_count++] = tax_line {"taxes.nl.2", "", 0.0f, 0.0f, false, false}; + report->lines[report->line_count++] = tax_line {"taxes.nl.2a", "2a", 0.0f, 0.0f, true, true}; + + report->lines[report->line_count++] = tax_line {"taxes.nl.3", "", 0.0f, 0.0f, false, false}; + report->lines[report->line_count++] = tax_line {"taxes.nl.3a", "3a", 0.0f, 0.0f, true, false}; + report->lines[report->line_count++] = tax_line {"taxes.nl.3b", "3b", 0.0f, 0.0f, true, false}; + report->lines[report->line_count++] = tax_line {"taxes.nl.3c", "3c", 0.0f, 0.0f, true, false}; + + report->lines[report->line_count++] = tax_line {"taxes.nl.4", "", 0.0f, 0.0f, false, false}; + report->lines[report->line_count++] = tax_line {"taxes.nl.4a", "4a", 0.0f, 0.0f, true, true}; + report->lines[report->line_count++] = tax_line {"taxes.nl.4b", "4b", 0.0f, 0.0f, true, true}; + + report->lines[report->line_count++] = tax_line {"taxes.nl.5", "", 0.0f, 0.0f, false, false}; + report->lines[report->line_count++] = tax_line {"taxes.nl.5a", "5a", 0.0f, 0.0f, false, true}; + report->lines[report->line_count++] = tax_line {"taxes.nl.5b", "5b", 0.0f, 0.0f, false, true}; + + report->lines[report->line_count++] = tax_line {"taxes.total", "5c", 0.0f, 0.0f, false, true}; } bool _nl_add_billing_item_to_tax_report(tax_report* report, invoice* inv, billing_item* item) @@ -60,6 +60,8 @@ bool _nl_add_billing_item_to_tax_report(tax_report* report, invoice* inv, billin a_err err = administration::tax_rate_get_by_id(&rate, item->tax_rate_id); if (err != A_ERR_SUCCESS) return 0; + tax_subtotal totals = administration::billing_item_convert_to_default_currency(inv, *item); + if (inv->is_outgoing) { tax_line* a5 = administration::get_tax_line_from_report(report, "5a"); // Total owed. @@ -68,42 +70,42 @@ bool _nl_add_billing_item_to_tax_report(tax_report* report, invoice* inv, billin { if (rate.rate == 21.0f) { tax_line* tl = administration::get_tax_line_from_report(report, "1a"); - tl->total_net += item->net; - tl->total_tax += item->tax; + tl->total_net += totals.net; + tl->total_tax += totals.tax; - a5->total_tax += item->tax; + a5->total_tax += totals.tax; } else if (rate.rate == 9.0f) { - tax_line* tl = administration::get_tax_line_from_report(report, "1b"); - tl->total_net += item->net; - tl->total_tax += item->tax; + tax_line* tl = administration::get_tax_line_from_report(report, "1b"); + tl->total_net += totals.net; + tl->total_tax += totals.tax; - a5->total_tax += item->tax; + a5->total_tax += totals.tax; } // TODO 1c else if (rate.rate > 0.0f) { tax_line* tl = administration::get_tax_line_from_report(report, "1d"); - tl->total_net += item->net; - tl->total_tax += item->tax; + tl->total_net += totals.net; + tl->total_tax += totals.tax; - a5->total_tax += item->tax; + a5->total_tax += totals.tax; } else if (rate.rate == 0.0f) { - tax_line* tl = administration::get_tax_line_from_report(report, "1e"); - tl->total_net += item->net; - tl->total_tax += item->tax; + tax_line* tl = administration::get_tax_line_from_report(report, "1e"); + tl->total_net += totals.net; + tl->total_tax += totals.tax; - a5->total_tax += item->tax; + a5->total_tax += totals.tax; } } else if (!country::is_EU(inv->customer.address.country_code)) { tax_line* tl = administration::get_tax_line_from_report(report, "3a"); - tl->total_net += item->net; + tl->total_net += totals.net; // Tax is paid to country of customer. } else { tax_line* tl = administration::get_tax_line_from_report(report, "3b"); - tl->total_net += item->net; + tl->total_net += totals.net; // Tax is paid to country of customer. } // TODO 3c @@ -117,34 +119,31 @@ bool _nl_add_billing_item_to_tax_report(tax_report* report, invoice* inv, billin if (strops::equals(rate.category_code, "AE")) { // NL reverse charge. tax_line* tl = administration::get_tax_line_from_report(report, "2a"); + tl->total_net += totals.net; + tl->total_tax += totals.net * 0.21f; // TODO fr? - tl->total_net += item->net; - tl->total_tax += item->net * 0.21f; // TODO fr? - - a5->total_tax += item->net * 0.21f; - b5->total_tax += item->net * 0.21f; + a5->total_tax += totals.net * 0.21f; + b5->total_tax += totals.net * 0.21f; } else { - b5->total_tax += item->tax; + b5->total_tax += totals.tax; } } else if (!country::is_EU(inv->supplier.address.country_code)) { tax_line* tl = administration::get_tax_line_from_report(report, "4a"); + tl->total_net += totals.net; + tl->total_tax += totals.net * 0.21f; - tl->total_net += item->net; - tl->total_tax += item->net * 0.21f; - - a5->total_tax += item->net * 0.21f; - b5->total_tax += item->net * 0.21f; + a5->total_tax += totals.net * 0.21f; + b5->total_tax += totals.net * 0.21f; } else { tax_line* tl = administration::get_tax_line_from_report(report, "4b"); + tl->total_net += totals.net; + tl->total_tax += totals.net * 0.21f; - tl->total_net += item->net; - tl->total_tax += item->net * 0.21f; - - a5->total_tax += item->net * 0.21f; - b5->total_tax += item->net * 0.21f; + a5->total_tax += totals.net * 0.21f; + b5->total_tax += totals.net * 0.21f; } } @@ -158,7 +157,9 @@ float _nl_calculate_tax_report_final(tax_report* report) tax_line* total = administration::get_tax_line_from_report(report, "5c"); total->total_tax = a5->total_tax - b5->total_tax; - return (float)ceil(total->total_tax); + if (total->total_tax < 0.0f) total->total_tax = (float)ceil(total->total_tax); + else total->total_tax = (float)floor(total->total_tax); + return total->total_tax; } time_t _nl_get_invoice_date_to_use_for_tax_report(invoice* inv) |
