diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-18 23:10:20 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-18 23:10:20 +0200 |
| commit | 18bfbc423d188683973a0a3d6c31c9225158e262 (patch) | |
| tree | e88ab359e6455d44dc7687769ae1281133485acc /src/administration.cpp | |
| parent | e5e059538bbbf1993df854bd95e9bbf4bb1d7aaa (diff) | |
tax rate refactor
Diffstat (limited to 'src/administration.cpp')
| -rw-r--r-- | src/administration.cpp | 179 |
1 files changed, 1 insertions, 178 deletions
diff --git a/src/administration.cpp b/src/administration.cpp index f79a0af..d01ec61 100644 --- a/src/administration.cpp +++ b/src/administration.cpp @@ -39,13 +39,6 @@ static s32 create_id() return g_administration.next_id; } -static int compare_tax_countries(const void *a, const void *b) -{ - tax_rate *objA = (tax_rate *)a; - tax_rate *objB = (tax_rate *)b; - return strcmp(objA->country_code, objB->country_code); -} - time_t administration::get_default_invoice_expire_duration() // TODO depricated { return (30 * 24 * 60 * 60); // 30 days @@ -53,170 +46,6 @@ time_t administration::get_default_invoice_expire_duration() // TODO depricated static char* get_default_currency_for_country(char* country_code); -static void create_default_tax_rates() -{ - #define ADD_BRACKET(_country, _rate, _code)\ - {\ - tax_rate* tb = (tax_rate*)memops::alloc(sizeof(tax_rate));\ - strops::format(tb->id, sizeof(tb->id), "T/%d", create_id());\ - memops::copy(tb->country_code, _country, sizeof(tb->country_code));\ - tb->rate = _rate;\ - memops::copy(tb->category_code, _code, sizeof(tb->category_code));\ - list_append(&g_administration.tax_rates, tb);\ - g_administration.next_id++;\ - if (taxrate_changed_event_callback) taxrate_changed_event_callback(tb);\ - if (data_changed_event_callback) data_changed_event_callback();\ - } - - // General rates shared between countries. - // Category options: https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL5305/ - - // TODO unimplemented category L, M, B - - ADD_BRACKET("00", 0.0f, "AE"); // Vat Reverse Charge - ADD_BRACKET("00", 0.0f, "E"); // Exempt from Tax - ADD_BRACKET("00", 0.0f, "Z"); // Zero rated goods - ADD_BRACKET("00", 0.0f, "G"); // Free export item, VAT not charged - ADD_BRACKET("00", 0.0f, "O"); // Services outside scope of tax - ADD_BRACKET("00", 0.0f, "K#G"); // VAT exempt for EEA intra-community supply of goods - ADD_BRACKET("00", 0.0f, "K#S"); // VAT exempt for EEA intra-community supply of services - - // Austria - ADD_BRACKET("AT", 20.0f, "S"); - ADD_BRACKET("AT", 10.0f, "S"); - ADD_BRACKET("AT", 13.0f, "S"); - - // Belgium - ADD_BRACKET("BE", 21.0f, "S"); - ADD_BRACKET("BE", 6.0f, "S"); - ADD_BRACKET("BE", 12.0f, "S"); - - // Bulgaria - ADD_BRACKET("BG", 20.0f, "S"); - ADD_BRACKET("BG", 9.0f, "S"); - - // Cyprus - ADD_BRACKET("CY", 19.0f, "S"); - ADD_BRACKET("CY", 5.0f, "S"); - ADD_BRACKET("CY", 9.0f, "S"); - - // Czechia - ADD_BRACKET("CZ", 21.0f, "S"); - ADD_BRACKET("CZ", 12.0f, "S"); - - // Croatia - ADD_BRACKET("HR", 25.0f, "S"); - ADD_BRACKET("HR", 5.0f, "S"); - ADD_BRACKET("HR", 13.0f, "S"); - - // Denmark - ADD_BRACKET("DK", 25.0f, "S"); - - // Estonia - ADD_BRACKET("EE", 22.0f, "S"); - ADD_BRACKET("EE", 9.0f, "S"); - - // Finland - ADD_BRACKET("FI", 25.5f, "S"); - ADD_BRACKET("FI", 10.0f, "S"); - ADD_BRACKET("FI", 14.0f, "S"); - - // France - ADD_BRACKET("FR", 20.0f, "S"); - ADD_BRACKET("FR", 5.5f, "S"); - ADD_BRACKET("FR", 10.0f, "S"); - ADD_BRACKET("FR", 2.1f, "S"); - - // Germany - ADD_BRACKET("DE", 19.0f, "S"); - ADD_BRACKET("DE", 7.0f, "S"); - - // Greece - ADD_BRACKET("GR", 24.0f, "S"); - ADD_BRACKET("GR", 6.0f, "S"); - ADD_BRACKET("GR", 13.0f, "S"); - - // Hungary - ADD_BRACKET("HU", 27.0f, "S"); - ADD_BRACKET("HU", 5.0f, "S"); - ADD_BRACKET("HU", 18.0f, "S"); - - // Ireland - ADD_BRACKET("IE", 23.0f, "S"); - ADD_BRACKET("IE", 9.0f, "S"); - ADD_BRACKET("IE", 13.5f, "S"); - ADD_BRACKET("IE", 4.8f, "S"); - - // Italy - ADD_BRACKET("IT", 22.0f, "S"); - ADD_BRACKET("IT", 5.0f, "S"); - ADD_BRACKET("IT", 10.0f, "S"); - ADD_BRACKET("IT", 4.0f, "S"); - - // Latvia - ADD_BRACKET("LV", 21.0f, "S"); - ADD_BRACKET("LV", 5.0f, "S"); - ADD_BRACKET("LV", 12.0f, "S"); - - // Lithuania - ADD_BRACKET("LT", 21.0f, "S"); - ADD_BRACKET("LT", 5.0f, "S"); - ADD_BRACKET("LT", 9.0f, "S"); - - // Luxembourg - ADD_BRACKET("LU", 17.0f, "S"); - ADD_BRACKET("LU", 8.0f, "S"); - ADD_BRACKET("LU", 14.0f, "S"); - ADD_BRACKET("LU", 3.0f, "S"); - - // Malta - ADD_BRACKET("MT", 18.0f, "S"); - ADD_BRACKET("MT", 5.0f, "S"); - ADD_BRACKET("MT", 7.0f, "S"); - - // Netherlands - ADD_BRACKET("NL", 21.0f, "S"); - ADD_BRACKET("NL", 9.0f, "S"); - - // Poland - ADD_BRACKET("PL", 23.0f, "S"); - ADD_BRACKET("PL", 5.0f, "S"); - ADD_BRACKET("PL", 8.0f, "S"); - - // Portugal - ADD_BRACKET("PT", 23.0f, "S"); - ADD_BRACKET("PT", 6.0f, "S"); - ADD_BRACKET("PT", 13.0f, "S"); - - // Romania - ADD_BRACKET("RO", 19.0f, "S"); - ADD_BRACKET("RO", 5.0f, "S"); - ADD_BRACKET("RO", 9.0f, "S"); - - // Slovakia - ADD_BRACKET("SK", 23.0f, "S"); - ADD_BRACKET("SK", 5.0f, "S"); - ADD_BRACKET("SK", 19.0f, "S"); - - // Slovenia - ADD_BRACKET("SI", 22.0f, "S"); - ADD_BRACKET("SI", 5.0f, "S"); - ADD_BRACKET("SI", 9.5f, "S"); - - // Spain - ADD_BRACKET("ES", 21.0f, "S"); - ADD_BRACKET("ES", 10.0f, "S"); - ADD_BRACKET("ES", 4.0f, "S"); - - // Sweden - ADD_BRACKET("SE", 25.0f, "S"); - ADD_BRACKET("SE", 6.0f, "S"); - ADD_BRACKET("SE", 12.0f, "S"); - - list_attributes_comparator(&g_administration.tax_rates, compare_tax_countries); - list_sort(&g_administration.tax_rates, -1); -} - static void create_default_cost_centers() { #define ADD_COSTCENTER(_description, _code)\ @@ -354,7 +183,6 @@ void administration::create_empty(char* save_file) void administration::create_default(char* save_file) { administration::create_empty(save_file); - create_default_tax_rates(); create_default_cost_centers(); //administration::create_debug_data(); } @@ -392,7 +220,7 @@ s32 administration::get_next_sequence_number() return g_administration.next_sequence_number; } -bool administration::can_create_invoices() +bool administration::can_create_invoices() // TODO rename to be more generic as it is used for more than invoices { return administration::contact_is_valid(g_administration.company_info) == A_ERR_SUCCESS; } @@ -1280,8 +1108,6 @@ a_err administration::tax_rate_import(tax_rate data) return A_ERR_GENERIC; } - list_attributes_comparator(&g_administration.tax_rates, compare_tax_countries); - list_sort(&g_administration.tax_rates, -1); return A_ERR_SUCCESS; } @@ -1297,9 +1123,6 @@ a_err administration::tax_rate_add(tax_rate data) g_administration.next_id++; - list_attributes_comparator(&g_administration.tax_rates, compare_tax_countries); - list_sort(&g_administration.tax_rates, -1); - if (taxrate_changed_event_callback) taxrate_changed_event_callback(&data); if (data_changed_event_callback) data_changed_event_callback(); |
