diff options
Diffstat (limited to 'src/ui/imgui_extensions.cpp')
| -rw-r--r-- | src/ui/imgui_extensions.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/ui/imgui_extensions.cpp b/src/ui/imgui_extensions.cpp index 797da9d..63e8eeb 100644 --- a/src/ui/imgui_extensions.cpp +++ b/src/ui/imgui_extensions.cpp @@ -325,21 +325,20 @@ namespace ImGui memops::unalloc(buffer); } - void FormTaxRateCombo(char* tax_rate_id, char* orig_country, char* dest_country, bool has_error) + void FormTaxRateCombo(char* tax_internal_code, bool outgoing, bool has_error) { u32 tax_rate_count = administration::tax_rate_count(); tax_rate* buffer = (tax_rate*) memops::alloc(sizeof(tax_rate) * tax_rate_count); tax_rate* selected_tax_rate = NULL; - char* tax_country_codes[2] = {orig_country, dest_country}; - tax_rate_count = administration::tax_rate_get_by_country(buffer, strcmp(orig_country, dest_country) == 0 ? 1 : 2, tax_country_codes); + tax_rate_count = administration::tax_rate_get_all(buffer, outgoing ? tax_rate_type::TAX_RATE_OUTGOING_INVOICE : tax_rate_type::TAX_RATE_INCOMMING_INVOICE); // Select tax rate by given id. - if (strlen(tax_rate_id) > 0) + if (strlen(tax_internal_code) > 0) { for (u32 i = 0; i < tax_rate_count; i++) { - if (strcmp(buffer[i].id, tax_rate_id) == 0) + if (strcmp(buffer[i].internal_code, tax_internal_code) == 0) { selected_tax_rate = &buffer[i]; break; @@ -348,16 +347,12 @@ namespace ImGui } int selected_tax_rate_index = -1; - char rate_str_buf[40]; - rate_str_buf[0] = 0; + char rate_str_buf[MAX_LEN_LONG_DESC]; if (selected_tax_rate) { - if (strcmp(selected_tax_rate->country_code, "00") == 0) { - char category_code_desc[MAX_LEN_LONG_DESC]; - strops::format(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", selected_tax_rate->category_code); - strops::format(rate_str_buf, 40, "%s", locale::get(category_code_desc)); - } - else strops::format(rate_str_buf, 40, "%s/%.1f%%", selected_tax_rate->country_code, selected_tax_rate->rate); + char category_code_desc[MAX_LEN_LONG_DESC]; + strops::format(category_code_desc, MAX_LEN_LONG_DESC, "taxrate.code.%s", selected_tax_rate->internal_code); + strops::format(rate_str_buf, MAX_LEN_LONG_DESC, "%s", locale::get(category_code_desc)); } if (has_error) { @@ -369,14 +364,11 @@ namespace ImGui { for (u32 n = 0; n < tax_rate_count; n++) { - bool is_selected = selected_tax_rate && strcmp(selected_tax_rate->id, buffer[n].id) == 0; + bool is_selected = selected_tax_rate && strcmp(selected_tax_rate->internal_code, buffer[n].internal_code) == 0; - if (strcmp(buffer[n].country_code, "00") == 0) { - char category_code_desc[MAX_LEN_LONG_DESC]; - strops::format(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", buffer[n].category_code); - strops::format(rate_str_buf, 40, "%s", locale::get(category_code_desc)); - } - else strops::format(rate_str_buf, 40, "%s/%.1f%%", buffer[n].country_code, buffer[n].rate); + char category_code_desc[MAX_LEN_LONG_DESC]; + strops::format(category_code_desc, MAX_LEN_LONG_DESC, "taxrate.code.%s", buffer[n].internal_code); + strops::format(rate_str_buf, MAX_LEN_LONG_DESC, "%s", locale::get(category_code_desc)); if (ImGui::Selectable(rate_str_buf, is_selected)) { selected_tax_rate_index = n; @@ -391,7 +383,7 @@ namespace ImGui } if (selected_tax_rate_index != -1) { - strops::copy(tax_rate_id, buffer[selected_tax_rate_index].id, MAX_LEN_ID); + strops::copy(tax_internal_code, buffer[selected_tax_rate_index].internal_code, MAX_LEN_SHORT_DESC); } memops::unalloc(buffer); |
