summaryrefslogtreecommitdiff
path: root/src/countries
diff options
context:
space:
mode:
Diffstat (limited to 'src/countries')
-rw-r--r--src/countries/nl.cpp138
1 files changed, 47 insertions, 91 deletions
diff --git a/src/countries/nl.cpp b/src/countries/nl.cpp
index 795aff6..22a4ee2 100644
--- a/src/countries/nl.cpp
+++ b/src/countries/nl.cpp
@@ -35,29 +35,29 @@ 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, 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.1a", "NL/1a", 0.0f, 0.0f, true, true};
+ report->lines[report->line_count++] = tax_line {"taxes.nl.1b", "NL/1b", 0.0f, 0.0f, true, true};
+ report->lines[report->line_count++] = tax_line {"taxes.nl.1c", "NL/1c", 0.0f, 0.0f, true, true};
+ report->lines[report->line_count++] = tax_line {"taxes.nl.1d", "NL/1d", 0.0f, 0.0f, true, true};
+ report->lines[report->line_count++] = tax_line {"taxes.nl.1e", "NL/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.2a", "NL/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.3a", "NL/3a", 0.0f, 0.0f, true, false};
+ report->lines[report->line_count++] = tax_line {"taxes.nl.3b", "NL/3b", 0.0f, 0.0f, true, false};
+ report->lines[report->line_count++] = tax_line {"taxes.nl.3c", "NL/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.4a", "NL/4a", 0.0f, 0.0f, true, true};
+ report->lines[report->line_count++] = tax_line {"taxes.nl.4b", "NL/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.nl.5a", "NL/5a", 0.0f, 0.0f, false, true};
+ report->lines[report->line_count++] = tax_line {"taxes.nl.5b", "NL/5b", 0.0f, 0.0f, false, true};
- report->lines[report->line_count++] = tax_line {"taxes.total", "5c", 0.0f, 0.0f, false, true};
+ report->lines[report->line_count++] = tax_line {"taxes.total", "NL/5c", 0.0f, 0.0f, false, true};
}
bool _nl_add_billing_item_to_tax_report(tax_report* report, invoice* inv, billing_item* item)
@@ -71,100 +71,56 @@ bool _nl_add_billing_item_to_tax_report(tax_report* report, invoice* inv, billin
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, "NL/5a"); // Total owed.
- tax_line* a5 = administration::get_tax_line_from_report(report, "5a"); // Total owed.
-
- if (strops::equals(inv->customer.address.country_code, "NL"))
+ for (u32 i = 0; i < rate.tax_section_count; i++)
{
- if (rate.rate == 21.0f) {
- tax_line* tl = administration::get_tax_line_from_report(report, "1a");
- tl->total_net += totals.net;
- tl->total_tax += totals.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 += totals.net;
- tl->total_tax += totals.tax;
-
- a5->total_tax += totals.tax;
- }
- else if (rate.rate > 0.0f) {
- tax_line* tl = administration::get_tax_line_from_report(report, "1c");
- tl->total_net += totals.net;
- tl->total_tax += totals.tax;
-
- a5->total_tax += totals.tax;
- }
- // NOTE: category '1d' for private usage is not supported.
- else if (rate.rate == 0.0f) {
- tax_line* tl = administration::get_tax_line_from_report(report, "1e");
- tl->total_net += totals.net;
- tl->total_tax += totals.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 += totals.net;
- // Tax is paid to country of customer.
+ tax_line* line_rate = administration::get_tax_line_from_report(report, rate.tax_sections[i]);
+ line_rate->total_net += totals.net;
+ line_rate->total_tax += totals.tax;
}
- else {
- // TODO: 3b is for companies (intra community)
- tax_line* tl = administration::get_tax_line_from_report(report, "3b");
- tl->total_net += totals.net;
- // Tax is paid to country of customer.
+ if (rate.tax_section_count != 0) {
+ a5->total_tax += totals.tax;
}
- // TODO 3c is for sales to individuals
-
}
else {
- tax_line* a5 = administration::get_tax_line_from_report(report, "5a"); // Total owed.
- tax_line* b5 = administration::get_tax_line_from_report(report, "5b"); // Input tax.
-
- if (strops::equals(inv->supplier.address.country_code, "NL")) {
-
- // if (strops::equals(rate., "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?
-
- // a5->total_tax += totals.net * 0.21f;
- // b5->total_tax += totals.net * 0.21f;
- // }
- // else {
- // 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;
+ tax_line* a5 = administration::get_tax_line_from_report(report, "NL/5a"); // Total owed.
- a5->total_tax += totals.net * 0.21f;
- b5->total_tax += totals.net * 0.21f;
+ bool is_reverse_charge = 0;
+ for (u32 i = 0; i < rate.tax_section_count; i++)
+ {
+ if (strops::equals(rate.tax_sections[i], "NL/2a") ||
+ strops::equals(rate.tax_sections[i], "NL/4a") ||
+ strops::equals(rate.tax_sections[i], "NL/4b")) {
+ is_reverse_charge = 1;
+ }
}
- else {
- tax_line* tl = administration::get_tax_line_from_report(report, "4b");
- tl->total_net += totals.net;
- tl->total_tax += totals.net * 0.21f;
-
- a5->total_tax += totals.net * 0.21f;
- b5->total_tax += totals.net * 0.21f;
+
+ for (u32 i = 0; i < rate.tax_section_count; i++)
+ {
+ tax_line* line_rate = administration::get_tax_line_from_report(report, rate.tax_sections[i]);
+ if (is_reverse_charge) {
+ line_rate->total_net += totals.net;
+ line_rate->total_tax += totals.net / 100.0f * rate.rate;
+ }
+ else {
+ line_rate->total_net += totals.net;
+ line_rate->total_tax += totals.tax;
+ }
}
+ if (is_reverse_charge) a5->total_tax += totals.tax;
}
+
return 1;
}
float _nl_calculate_tax_report_final(tax_report* report)
{
- tax_line* a5 = administration::get_tax_line_from_report(report, "5a"); // Total owed.
- tax_line* b5 = administration::get_tax_line_from_report(report, "5b"); // Input tax.
- tax_line* total = administration::get_tax_line_from_report(report, "5c");
+ tax_line* a5 = administration::get_tax_line_from_report(report, "NL/5a"); // Total owed.
+ tax_line* b5 = administration::get_tax_line_from_report(report, "NL/5b"); // Input tax.
+ tax_line* total = administration::get_tax_line_from_report(report, "NL/5c");
total->total_tax = a5->total_tax - b5->total_tax;
if (total->total_tax < 0.0f) total->total_tax = (float)ceil(total->total_tax);