summaryrefslogtreecommitdiff
path: root/src/ui/ui_invoices.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/ui_invoices.cpp')
-rw-r--r--src/ui/ui_invoices.cpp46
1 files changed, 23 insertions, 23 deletions
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);