/* * Copyright (c) 2025 Aldrik Ramaekers * * 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 "strops.hpp" #include "countries.hpp" #include "countries/nl.cpp" static country_impl country_map[] = { _nl_country_impl, // Add new countries here. }; static const u32 country_map_count = sizeof(country_map) / sizeof(country_map[0]); s32 country::get_count() { return country_map_count; } char* country::get_code_by_index(s32 index) { return country_map[index].country_code; } static s32 get_index_by_country_code(char* country_code) { for (u32 i = 0; i < country_map_count; i++) { if (strops::equals(country_map[i].country_code, country_code)) { return i; } } return -1; } bool country::is_EU(char* country_code) { s32 index = get_index_by_country_code(country_code); if (index == -1) return 0; return country_map[index].is_EU; } time_t country::get_default_invoice_expire_duration(char* country_code) { s32 index = get_index_by_country_code(country_code); if (index == -1) return 0; return country_map[index].get_default_invoice_expire_duration(); } bool country::tax_is_implemented(char* country_code) { s32 index = get_index_by_country_code(country_code); if (index == -1) return false; return country_map[index].fill_tax_report_with_categories && country_map[index].add_billing_item_to_tax_report; } void country::fill_tax_report_with_categories(char* country_code, tax_report* report) { s32 index = get_index_by_country_code(country_code); assert(index != -1); country_map[index].fill_tax_report_with_categories(report); } bool country::add_billing_item_to_tax_report(char* country_code, tax_report* report, invoice* inv, billing_item* item) { s32 index = get_index_by_country_code(country_code); assert(index != -1); return country_map[index].add_billing_item_to_tax_report(report, inv, item); } float country::calculate_tax_report_final(char* country_code, tax_report* report) { s32 index = get_index_by_country_code(country_code); assert(index != -1); return country_map[index].calculate_tax_report_final(report); } time_t country::get_invoice_date_to_use_for_tax_report(char* country_code, invoice* inv) { s32 index = get_index_by_country_code(country_code); assert(index != -1); return country_map[index].get_invoice_date_to_use_for_tax_report(inv); }