summaryrefslogtreecommitdiff
path: root/src/countries/nl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/countries/nl.cpp')
-rw-r--r--src/countries/nl.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/countries/nl.cpp b/src/countries/nl.cpp
new file mode 100644
index 0000000..85005d6
--- /dev/null
+++ b/src/countries/nl.cpp
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2025 Aldrik Ramaekers <aldrik.ramaekers@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include "countries.hpp"
+
+time_t _nl_get_default_invoice_expire_duration()
+{
+ return (15 * 24 * 60 * 60); // 15 days
+}
+
+void _nl_fill_tax_report_with_categories(tax_report* report)
+{
+ report->lines[report->line_count++] = tax_line {"1a", 0.0f, 0.0f};
+ report->lines[report->line_count++] = tax_line {"1b", 0.0f, 0.0f};
+ report->lines[report->line_count++] = tax_line {"1c", 0.0f, 0.0f};
+ report->lines[report->line_count++] = tax_line {"1d", 0.0f, 0.0f};
+ report->lines[report->line_count++] = tax_line {"1e", 0.0f, 0.0f};
+
+ report->lines[report->line_count++] = tax_line {"2a", 0.0f, 0.0f};
+
+ report->lines[report->line_count++] = tax_line {"3a", 0.0f, 0.0f};
+ report->lines[report->line_count++] = tax_line {"3b", 0.0f, 0.0f};
+ report->lines[report->line_count++] = tax_line {"3c", 0.0f, 0.0f};
+
+ report->lines[report->line_count++] = tax_line {"4a", 0.0f, 0.0f};
+ report->lines[report->line_count++] = tax_line {"4b", 0.0f, 0.0f};
+
+ report->lines[report->line_count++] = tax_line {"5a", 0.0f, 0.0f};
+ report->lines[report->line_count++] = tax_line {"5b", 0.0f, 0.0f};
+
+ report->lines[report->line_count++] = tax_line {"Total", 0.0f, 0.0f};
+}
+
+char* _nl_get_tax_category_for_billing_item(invoice* inv, billing_item* item)
+{
+ // https://goedestartbelastingdienst.nl/wiki/view/7494ecb4-f6d2-4f85-a200-5a3ee5d45b75/btw-aangifte-het-invullen-van-de-verschillende-rubrieken
+
+ tax_rate rate;
+ a_err err = administration::tax_rate_get_by_id(&rate, item->tax_rate_id);
+ if (err != A_ERR_SUCCESS) return 0;
+
+
+ /*
+ We moeten 5a ook nog berekenen, dus misschien tax_report meegeven en hier alles doen wat nodig is?
+ we moeten ook nog het uiteindelijke bedrag uitregenen 5a-5b dus dat moet ook hier gebeuren.
+
+ */
+
+ // Outgoing = 1 + 3
+ if (inv->is_outgoing) {
+
+ if (strops::equals(inv->customer.address.country_code, "NL"))
+ {
+ if (rate.rate == 21.0f) return "1a";
+ else if (rate.rate == 9.0f) return "1b";
+ // TODO 1c
+ else if (rate.rate > 0.0f) return "1d";
+ else if (rate.rate == 0.0f) return "1e";
+ }
+ else if (!country::is_EU(inv->customer.address.country_code)) return "3a";
+ else return "3b";
+ // TODO 3c
+
+ }
+
+ // Incomming = 2 + 4 + 5
+ else {
+
+ if (strops::equals(inv->customer.address.country_code, "NL")) {
+ if (strops::equals(rate.category_code, "AE")) return "2a"; // NL reverse charge.
+ else return "5b";
+ }
+
+ if (!country::is_EU(inv->customer.address.country_code)) return "4a";
+ else return "4b";
+
+ }
+ return 0;
+}
+
+country_impl _nl_country_impl = {
+ "NL",
+ true,
+ _nl_get_default_invoice_expire_duration,
+ _nl_fill_tax_report_with_categories,
+ _nl_get_tax_category_for_billing_item,
+}; \ No newline at end of file