summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2025-10-18 09:10:08 +0200
committerAldrik Ramaekers <aldrikboy@gmail.com>2025-10-18 09:10:08 +0200
commite5e059538bbbf1993df854bd95e9bbf4bb1d7aaa (patch)
treeb0949aef3ec22172b6b3eab8dd409c9d3f118a37
parent0dc33a4dd49eb560e98b24090969fd618a4c6198 (diff)
remove country list from config
-rw-r--r--TODO2
-rw-r--r--include/config.hpp9
-rw-r--r--manual/OpenBooks_Manual.pdfbin127011 -> 128283 bytes
-rw-r--r--src/ui/imgui_extensions.cpp17
-rw-r--r--src/ui/ui_main.cpp2
5 files changed, 11 insertions, 19 deletions
diff --git a/TODO b/TODO
index 9b69dbe..d244d70 100644
--- a/TODO
+++ b/TODO
@@ -5,13 +5,13 @@ Refactor:
- refactor _add functions to use _import functions
- replace strncpy and similar with strops functions
- There is alot of memory leakage
-- remove country list from config and use country namespace iteration.
Testing:
- write tests for all NL tax categories
- write tests for strops.hpp
- write tests that check error handling for corrupt files. (e.g. references to tax rates, project and cost center that failed to load)
- it is possible a referenced tax rate is loaded after an invoice is loaded. This means all invoices need to be recalculated after file load. (try to write a test for this).
+- peppol testing: add a billing item for each tax category.
Improvements:
- AI importer: all address data should be editable because import is not perfect
diff --git a/include/config.hpp b/include/config.hpp
index aecec75..76b8022 100644
--- a/include/config.hpp
+++ b/include/config.hpp
@@ -32,15 +32,6 @@
namespace config {
static const char* PROGRAM_VERSION = "0.1.0"; // major.minor.patch
- // TODO get rid of this and use country iter
- static const char* country_codes[] = {
- "AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR",
- "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL",
- "PL", "PT", "RO", "SK", "SI", "ES", "SE"
- };
-
- static s32 country_count = sizeof(country_codes) / sizeof(country_codes[0]);
-
namespace colors {
static const ImU32 COLOR_ERROR_OUTLINE = IM_COL32(255, 0, 0, 80);
static const ImU32 COLOR_ERROR = IM_COL32(235, 64, 52, 255);
diff --git a/manual/OpenBooks_Manual.pdf b/manual/OpenBooks_Manual.pdf
index 8b92215..1fef2aa 100644
--- a/manual/OpenBooks_Manual.pdf
+++ b/manual/OpenBooks_Manual.pdf
Binary files differ
diff --git a/src/ui/imgui_extensions.cpp b/src/ui/imgui_extensions.cpp
index 0bfd5c8..797da9d 100644
--- a/src/ui/imgui_extensions.cpp
+++ b/src/ui/imgui_extensions.cpp
@@ -3,6 +3,7 @@
#include "memops.hpp"
#include "config.hpp"
#include "locales.hpp"
+#include "countries.hpp"
#include "administration.hpp"
#include "tinyfiledialogs.h"
@@ -51,7 +52,7 @@ namespace ImGui
{
const char *filterPatterns[] = { "*.pdf" };
const char *file = tinyfd_openFileDialog(
- "Choose a file", // dialog title // @locale::get
+ "Choose a file", // dialog title // @localize
NULL, // default path
1, // number of filter patterns
filterPatterns, // filter patterns array
@@ -74,7 +75,7 @@ namespace ImGui
result = true;
}
ImGui::SameLine();
- ImGui::TextWrapped("Selected: %s", buffer); // @locale::get
+ ImGui::TextWrapped("Selected: %s", buffer); // @localize
}
@@ -88,16 +89,16 @@ namespace ImGui
ImGui::SetNextItemWidth(widthAvailable*0.5f);
const char* countries[30];
- for (int x = 0; x < config::country_count; x++)
+ for (int x = 0; x < country::get_count(); x++)
{
char locale_str[20];
- strops::format(locale_str, 20, "country.%s", config::country_codes[x]);
+ strops::format(locale_str, 20, "country.%s", country::get_code_by_index(x));
countries[x] = locale::get(locale_str);
}
- for (int i = 0; i < config::country_count; i++)
+ for (int i = 0; i < country::get_count(); i++)
{
- if (strcmp(config::country_codes[i], buffer) == 0)
+ if (strcmp(country::get_code_by_index(i), buffer) == 0)
{
selected_country = countries[i];
break;
@@ -113,7 +114,7 @@ namespace ImGui
if (ImGui::BeginCombo(locale::get("contact.form.country"), selected_country))
{
- for (int n = 0; n < config::country_count; n++)
+ for (int n = 0; n < country::get_count(); n++)
{
bool is_selected = (selected_country == countries[n]);
if (ImGui::Selectable(countries[n], is_selected)) {
@@ -134,7 +135,7 @@ namespace ImGui
}
if (selected_country_index != -1) {
- strops::copy(buffer, config::country_codes[selected_country_index], buf_size);
+ strops::copy(buffer, country::get_code_by_index(selected_country_index), buf_size);
}
}
diff --git a/src/ui/ui_main.cpp b/src/ui/ui_main.cpp
index cf30840..84dab1b 100644
--- a/src/ui/ui_main.cpp
+++ b/src/ui/ui_main.cpp
@@ -112,7 +112,7 @@ void ui::draw_main()
if (ImGui::Button(locale::get("nav.contacts"), ImVec2(buttonWidth, 24))) ui::set_state(ui::main_state::UI_CONTACTS);
static bool reports_opened = true;
- if (ImGui::Button(locale::get("nav.reports"), ImVec2(buttonWidth, 24))) reports_opened = !reports_opened;
+ ImGui::Button(locale::get("nav.reports"), ImVec2(buttonWidth, 24));
if (reports_opened)
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(20.0f, 0.0f));