From 8d5c72406c1848dc7ab83daf4702fa13ce754530 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Tue, 16 Sep 2025 19:26:15 +0200 Subject: renamed country_tax_bracket to tax_rate --- src/ui/ui_expenses.cpp | 12 ++++++------ src/ui/ui_invoices.cpp | 46 +++++++++++++++++++++++----------------------- src/ui/ui_settings.cpp | 50 +++++++++++++++++++++++++------------------------- 3 files changed, 54 insertions(+), 54 deletions(-) (limited to 'src/ui') diff --git a/src/ui/ui_expenses.cpp b/src/ui/ui_expenses.cpp index 808d7fb..cd5e186 100644 --- a/src/ui/ui_expenses.cpp +++ b/src/ui/ui_expenses.cpp @@ -17,13 +17,13 @@ static invoice active_invoice = {0}; static invoice selected_for_removal = {0}; static cost_center* cost_center_list_buffer = 0; -static country_tax_bracket* tax_bracket_list_buffer = 0; +static tax_rate* tax_rate_list_buffer = 0; static project* project_list_buffer = 0; static billing_item* invoice_items_buffer = 0; void ui_draw_address_form(address* buffer); void draw_contact_form_ex(contact* buffer, bool viewing_only = false, bool with_autocomplete = false, bool* on_autocomplete = 0); -void draw_tax_bracket_selector(char* tax_bracket_id, country_tax_bracket* buffer, char* country_code); +void draw_tax_rate_selector(char* tax_rate_id, tax_rate* buffer, char* country_code); bool draw_currency_selector(char* currency); void draw_costcenter_selector(char* costcenter_id, cost_center* buffer) @@ -101,7 +101,7 @@ void draw_project_selector(char* project_id, project* buffer) void ui_destroy_expenses() { free(cost_center_list_buffer); - free(tax_bracket_list_buffer); + free(tax_rate_list_buffer); free(project_list_buffer); free(invoice_items_buffer); } @@ -114,8 +114,8 @@ void ui_setup_expenses() u32 costcenter_count = administration_cost_center_count(); cost_center_list_buffer = (cost_center*) malloc(sizeof(cost_center) * costcenter_count); - u32 tax_bracket_count = administration_tax_bracket_count(); - tax_bracket_list_buffer = (country_tax_bracket*) malloc(sizeof(country_tax_bracket) * tax_bracket_count); + u32 tax_rate_count = administration_tax_rate_count(); + tax_rate_list_buffer = (tax_rate*) malloc(sizeof(tax_rate) * tax_rate_count); u32 project_count = administration_project_count(); project_list_buffer = (project*) malloc(sizeof(project) * project_count); @@ -215,7 +215,7 @@ static void draw_expense_items_form(invoice* invoice) ImGui::TableSetColumnIndex(6); ImGui::PushItemWidth(-1); // TODO: should be country of invoice issuer - draw_tax_bracket_selector(item.tax_bracket_id, tax_bracket_list_buffer, administration_company_info_get().address.country_code); + draw_tax_rate_selector(item.tax_rate_id, tax_rate_list_buffer, administration_company_info_get().address.country_code); ImGui::PopItemWidth(); ImGui::TableSetColumnIndex(7); diff --git a/src/ui/ui_invoices.cpp b/src/ui/ui_invoices.cpp index 75f46b3..99fac37 100644 --- a/src/ui/ui_invoices.cpp +++ b/src/ui/ui_invoices.cpp @@ -17,7 +17,7 @@ static view_state current_view_state = view_state::LIST; static invoice active_invoice = {0}; static invoice selected_for_removal = {0}; -static country_tax_bracket* tax_bracket_list_buffer = 0; +static tax_rate* tax_rate_list_buffer = 0; static billing_item* invoice_items_buffer = 0; static project* project_list_buffer = 0; @@ -27,7 +27,7 @@ void draw_project_selector(char* project_id, project* buffer); void ui_destroy_invoices() { - free(tax_bracket_list_buffer); + free(tax_rate_list_buffer); free(invoice_items_buffer); free(project_list_buffer); } @@ -37,8 +37,8 @@ void ui_setup_invoices() current_view_state = view_state::LIST; active_invoice = administration_invoice_create_empty(); - u32 tax_bracket_count = administration_tax_bracket_count(); - tax_bracket_list_buffer = (country_tax_bracket*) malloc(sizeof(country_tax_bracket) * tax_bracket_count); + u32 tax_rate_count = administration_tax_rate_count(); + tax_rate_list_buffer = (tax_rate*) malloc(sizeof(tax_rate) * tax_rate_count); u32 invoice_items_count = MAX_BILLING_ITEMS; invoice_items_buffer = (billing_item*)malloc(sizeof(billing_item) * invoice_items_count); @@ -47,42 +47,42 @@ void ui_setup_invoices() project_list_buffer = (project*) malloc(sizeof(project) * project_count); } -void draw_tax_bracket_selector(char* tax_bracket_id, country_tax_bracket* buffer, char* country_code) +void draw_tax_rate_selector(char* tax_rate_id, tax_rate* buffer, char* country_code) { - country_tax_bracket* selected_tax_bracket = NULL; - u32 tax_bracket_count = administration_tax_bracket_get_by_country(buffer, country_code); + tax_rate* selected_tax_rate = NULL; + u32 tax_rate_count = administration_tax_rate_get_by_country(buffer, country_code); - // Select tax bracket by given id. - if (strlen(tax_bracket_id) > 0) + // Select tax rate by given id. + if (strlen(tax_rate_id) > 0) { - for (u32 i = 0; i < tax_bracket_count; i++) + for (u32 i = 0; i < tax_rate_count; i++) { - if (strcmp(buffer[i].id, tax_bracket_id) == 0) + if (strcmp(buffer[i].id, tax_rate_id) == 0) { - selected_tax_bracket = &buffer[i]; + selected_tax_rate = &buffer[i]; break; } } } - int selected_tax_bracket_index = -1; + int selected_tax_rate_index = -1; char rate_str_buf[40]; rate_str_buf[0] = 0; - if (selected_tax_bracket) + if (selected_tax_rate) { - if (strcmp(selected_tax_bracket->country_code, "00") == 0) { + if (strcmp(selected_tax_rate->country_code, "00") == 0) { char category_code_desc[MAX_LEN_LONG_DESC]; - snprintf(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", selected_tax_bracket->category_code); + snprintf(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", selected_tax_rate->category_code); snprintf(rate_str_buf, 40, "%s", localize(category_code_desc)); } - else snprintf(rate_str_buf, 40, "%s/%.1f%%", selected_tax_bracket->country_code, selected_tax_bracket->rate); + else snprintf(rate_str_buf, 40, "%s/%.1f%%", selected_tax_rate->country_code, selected_tax_rate->rate); } if (ImGui::BeginCombo("##Tax Bracket", rate_str_buf)) { - for (u32 n = 0; n < tax_bracket_count; n++) + for (u32 n = 0; n < tax_rate_count; n++) { - bool is_selected = selected_tax_bracket && strcmp(selected_tax_bracket->id, buffer[n].id) == 0; + bool is_selected = selected_tax_rate && strcmp(selected_tax_rate->id, buffer[n].id) == 0; if (strcmp(buffer[n].country_code, "00") == 0) { char category_code_desc[MAX_LEN_LONG_DESC]; @@ -92,14 +92,14 @@ void draw_tax_bracket_selector(char* tax_bracket_id, country_tax_bracket* buffer else snprintf(rate_str_buf, 40, "%s/%.1f%%", buffer[n].country_code, buffer[n].rate); if (ImGui::Selectable(rate_str_buf, is_selected)) { - selected_tax_bracket_index = n; + selected_tax_rate_index = n; } } ImGui::EndCombo(); } - if (selected_tax_bracket_index != -1) { - strops_copy(tax_bracket_id, buffer[selected_tax_bracket_index].id, MAX_LEN_ID); + if (selected_tax_rate_index != -1) { + strops_copy(tax_rate_id, buffer[selected_tax_rate_index].id, MAX_LEN_ID); } } @@ -248,7 +248,7 @@ static void draw_invoice_items_form(invoice* invoice) ImGui::TableSetColumnIndex(6); ImGui::PushItemWidth(-1); - draw_tax_bracket_selector(item.tax_bracket_id, tax_bracket_list_buffer, administration_company_info_get().address.country_code); + draw_tax_rate_selector(item.tax_rate_id, tax_rate_list_buffer, administration_company_info_get().address.country_code); ImGui::PopItemWidth(); ImGui::TableSetColumnIndex(7); diff --git a/src/ui/ui_settings.cpp b/src/ui/ui_settings.cpp index ae251d9..06cefe6 100644 --- a/src/ui/ui_settings.cpp +++ b/src/ui/ui_settings.cpp @@ -12,8 +12,8 @@ extern void draw_contact_form(contact* buffer, bool viewing_only = false); static contact company_info; -u32 tax_bracket_count; -country_tax_bracket* tax_brackets = 0; +u32 tax_rate_count; +tax_rate* tax_rates = 0; u32 cost_center_count; cost_center* cost_centers = 0; @@ -22,7 +22,7 @@ static int select_company_tab = 0; void ui_destroy_settings() { - free(tax_brackets); + free(tax_rates); free(cost_centers); } @@ -31,9 +31,9 @@ void ui_setup_settings() select_company_tab = 1; company_info = administration_company_info_get(); - tax_bracket_count = administration_tax_bracket_count(); - tax_brackets = (country_tax_bracket*)malloc(tax_bracket_count * sizeof(country_tax_bracket)); - administration_tax_bracket_get_all(tax_brackets); + tax_rate_count = administration_tax_rate_count(); + tax_rates = (tax_rate*)malloc(tax_rate_count * sizeof(tax_rate)); + administration_tax_rate_get_all(tax_rates); cost_center_count = administration_cost_center_count(); cost_centers = (cost_center*)malloc(cost_center_count * sizeof(cost_center)); @@ -43,7 +43,7 @@ void ui_setup_settings() static void ui_draw_vat_rates() { static bool is_adding_item = false; - static country_tax_bracket new_tax_bracket; + static tax_rate new_tax_rate; static bool is_editing_item = false; static u32 editing_item_index = 0; @@ -57,8 +57,8 @@ static void ui_draw_vat_rates() char prev_country[MAX_LEN_COUNTRY_CODE]; prev_country[0] = 0; - for (u32 i = 0; i < tax_bracket_count; i++) { - country_tax_bracket c = tax_brackets[i]; + for (u32 i = 0; i < tax_rate_count; i++) { + tax_rate c = tax_rates[i]; // Set to false for shared rates. bool can_be_modified = false; @@ -98,8 +98,8 @@ static void ui_draw_vat_rates() if (ImGui::Button(btn_name, ImVec2(20,20))) { is_adding_item = true; is_editing_item = false; - new_tax_bracket = administration_tax_bracket_create_empty(); - strops_copy(new_tax_bracket.country_code, c.country_code, 3); + new_tax_rate = administration_tax_rate_create_empty(); + strops_copy(new_tax_rate.country_code, c.country_code, 3); } ImGui::PopStyleVar(); } @@ -107,7 +107,7 @@ static void ui_draw_vat_rates() ImGui::TableSetColumnIndex(1); ImGui::Text(""); } - // Column 1: description of tax bracket. Is only displayed on shared tax brackets for clarity. + // Column 1: description of tax rate. Is only displayed on shared tax rates for clarity. ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); @@ -120,17 +120,17 @@ static void ui_draw_vat_rates() ImGui::TableSetColumnIndex(1); if (is_editing_item && editing_item_index == i) { - ImGui::InputFloat("##Rate", &new_tax_bracket.rate, 1.0f, 5.0f, "%.2f"); + ImGui::InputFloat("##Rate", &new_tax_rate.rate, 1.0f, 5.0f, "%.2f"); - if (new_tax_bracket.rate < 0.0f) new_tax_bracket.rate = 0.0f; - if (new_tax_bracket.rate > 100.0f) new_tax_bracket.rate = 100.0f; + if (new_tax_rate.rate < 0.0f) new_tax_rate.rate = 0.0f; + if (new_tax_rate.rate > 100.0f) new_tax_rate.rate = 100.0f; ImGui::SameLine(); if (ImGui::Button(localize("form.save"))) { is_editing_item = false; is_adding_item = false; - administration_tax_bracket_update(new_tax_bracket); + administration_tax_rate_update(new_tax_rate); ui_destroy_settings(); ui_setup_settings(); @@ -140,7 +140,7 @@ static void ui_draw_vat_rates() if (ImGui::Button(localize("form.cancel"))) { is_editing_item = false; is_adding_item = false; - memset(&new_tax_bracket, 0, sizeof(new_tax_bracket)); + memset(&new_tax_rate, 0, sizeof(new_tax_rate)); } } else @@ -152,31 +152,31 @@ static void ui_draw_vat_rates() is_editing_item = true; is_adding_item = false; editing_item_index = i; - new_tax_bracket = c; + new_tax_rate = c; } } // When adding a new entry it is displayed at the bottom of the list of the country we are adding to. // Check for end of list (for last country in the list), or check if next country differs from current country. // If it is different we have reached the end of the list for the current country. - if (i == tax_bracket_count-1 || (i < tax_bracket_count-1 && strcmp(tax_brackets[i+1].country_code, c.country_code) != 0)) + if (i == tax_rate_count-1 || (i < tax_rate_count-1 && strcmp(tax_rates[i+1].country_code, c.country_code) != 0)) { - if (is_adding_item && strcmp(new_tax_bracket.country_code, prev_country) == 0) + if (is_adding_item && strcmp(new_tax_rate.country_code, prev_country) == 0) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); ImGui::Text(""); ImGui::TableSetColumnIndex(1); - ImGui::InputFloat("##Rate", &new_tax_bracket.rate, 1.0f, 5.0f, "%.2f"); + ImGui::InputFloat("##Rate", &new_tax_rate.rate, 1.0f, 5.0f, "%.2f"); - if (new_tax_bracket.rate < 0.0f) new_tax_bracket.rate = 0.0f; - if (new_tax_bracket.rate > 100.0f) new_tax_bracket.rate = 100.0f; + if (new_tax_rate.rate < 0.0f) new_tax_rate.rate = 0.0f; + if (new_tax_rate.rate > 100.0f) new_tax_rate.rate = 100.0f; ImGui::SameLine(); if (ImGui::Button(localize("form.save"))) { is_editing_item = false; is_adding_item = false; - administration_tax_bracket_add(new_tax_bracket); + administration_tax_rate_add(new_tax_rate); ui_destroy_settings(); ui_setup_settings(); @@ -186,7 +186,7 @@ static void ui_draw_vat_rates() if (ImGui::Button(localize("form.cancel"))) { is_editing_item = false; is_adding_item = false; - memset(&new_tax_bracket, 0, sizeof(new_tax_bracket)); + memset(&new_tax_rate, 0, sizeof(new_tax_rate)); } } } -- cgit v1.2.3-70-g09d2