summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/administration.hpp7
-rw-r--r--src/administration.cpp181
-rw-r--r--src/locales/en.cpp22
-rw-r--r--src/ui/ui_main.cpp14
-rw-r--r--src/ui/ui_projects.cpp2
-rw-r--r--src/ui/ui_settings.cpp62
6 files changed, 195 insertions, 93 deletions
diff --git a/include/administration.hpp b/include/administration.hpp
index 79ca6ab..aca0131 100644
--- a/include/administration.hpp
+++ b/include/administration.hpp
@@ -7,7 +7,7 @@ typedef struct
{
char country_code[3];
float rate;
- char description[16];
+ char description[32];
} country_tax_bracket;
typedef struct
@@ -136,4 +136,7 @@ bool administration_create_project(project data);
bool administration_update_project(project data);
char* administration_project_get_status_string(project data);
u32 administration_get_project_count();
-u32 administration_get_projects(u32 page_index, u32 page_size, project* buffer); \ No newline at end of file
+u32 administration_get_projects(u32 page_index, u32 page_size, project* buffer);
+
+u32 administration_get_tax_bracket_count();
+u32 administration_get_tax_brackets(country_tax_bracket* buffer); \ No newline at end of file
diff --git a/src/administration.cpp b/src/administration.cpp
index 5e323d0..0353276 100644
--- a/src/administration.cpp
+++ b/src/administration.cpp
@@ -15,7 +15,7 @@ static void administration_create_default_tax_brackets()
country_tax_bracket* tb = (country_tax_bracket*)malloc(sizeof(country_tax_bracket));\
memcpy(tb->country_code, _country, sizeof(tb->country_code));\
tb->rate = _rate;\
- memcpy(tb->description, _country, sizeof(tb->description));\
+ memcpy(tb->description, _description, sizeof(tb->description));\
list_append(&g_administration.tax_brackets, tb);\
}
@@ -24,136 +24,136 @@ static void administration_create_default_tax_brackets()
ADD_BRACKET("00", 0.0f, "tax.exempt");
// Austria
- ADD_BRACKET("AT", 20.0f, "Standard");
- ADD_BRACKET("AT", 10.0f, "Reduced");
- ADD_BRACKET("AT", 13.0f, "Reduced");
+ ADD_BRACKET("AT", 20.0f, "tax.standard");
+ ADD_BRACKET("AT", 10.0f, "tax.reduced");
+ ADD_BRACKET("AT", 13.0f, "tax.reduced");
// Belgium
- ADD_BRACKET("BE", 21.0f, "Standard");
- ADD_BRACKET("BE", 6.0f, "Reduced");
- ADD_BRACKET("BE", 12.0f, "Reduced");
+ ADD_BRACKET("BE", 21.0f, "tax.standard");
+ ADD_BRACKET("BE", 6.0f, "tax.reduced");
+ ADD_BRACKET("BE", 12.0f, "tax.reduced");
// Bulgaria
- ADD_BRACKET("BG", 20.0f, "Standard");
- ADD_BRACKET("BG", 9.0f, "Reduced");
+ ADD_BRACKET("BG", 20.0f, "tax.standard");
+ ADD_BRACKET("BG", 9.0f, "tax.reduced");
// Cyprus
- ADD_BRACKET("CY", 19.0f, "Standard");
- ADD_BRACKET("CY", 5.0f, "Reduced");
- ADD_BRACKET("CY", 9.0f, "Reduced");
+ ADD_BRACKET("CY", 19.0f, "tax.standard");
+ ADD_BRACKET("CY", 5.0f, "tax.reduced");
+ ADD_BRACKET("CY", 9.0f, "tax.reduced");
// Czechia
- ADD_BRACKET("CZ", 21.0f, "Standard");
- ADD_BRACKET("CZ", 12.0f, "Reduced");
+ ADD_BRACKET("CZ", 21.0f, "tax.standard");
+ ADD_BRACKET("CZ", 12.0f, "tax.reduced");
// Croatia
- ADD_BRACKET("HR", 25.0f, "Standard");
- ADD_BRACKET("HR", 5.0f, "Reduced");
- ADD_BRACKET("HR", 13.0f, "Reduced");
+ ADD_BRACKET("HR", 25.0f, "tax.standard");
+ ADD_BRACKET("HR", 5.0f, "tax.reduced");
+ ADD_BRACKET("HR", 13.0f, "tax.reduced");
// Denmark
- ADD_BRACKET("DK", 25.0f, "Standard");
+ ADD_BRACKET("DK", 25.0f, "tax.standard");
// Estonia
- ADD_BRACKET("EE", 22.0f, "Standard");
- ADD_BRACKET("EE", 9.0f, "Reduced");
+ ADD_BRACKET("EE", 22.0f, "tax.standard");
+ ADD_BRACKET("EE", 9.0f, "tax.reduced");
// Finland
- ADD_BRACKET("FI", 25.5f, "Standard");
- ADD_BRACKET("FI", 10.0f, "Reduced");
- ADD_BRACKET("FI", 14.0f, "Reduced");
+ ADD_BRACKET("FI", 25.5f, "tax.standard");
+ ADD_BRACKET("FI", 10.0f, "tax.reduced");
+ ADD_BRACKET("FI", 14.0f, "tax.reduced");
// France
- ADD_BRACKET("FR", 20.0f, "Standard");
- ADD_BRACKET("FR", 5.5f, "Reduced");
- ADD_BRACKET("FR", 10.0f, "Reduced");
- ADD_BRACKET("FR", 2.1f, "SuperReduced");
+ ADD_BRACKET("FR", 20.0f, "tax.standard");
+ ADD_BRACKET("FR", 5.5f, "tax.reduced");
+ ADD_BRACKET("FR", 10.0f, "tax.reduced");
+ ADD_BRACKET("FR", 2.1f, "tax.superReduced");
// Germany
- ADD_BRACKET("DE", 19.0f, "Standard");
- ADD_BRACKET("DE", 7.0f, "Reduced");
+ ADD_BRACKET("DE", 19.0f, "tax.standard");
+ ADD_BRACKET("DE", 7.0f, "tax.reduced");
// Greece
- ADD_BRACKET("GR", 24.0f, "Standard");
- ADD_BRACKET("GR", 6.0f, "Reduced");
- ADD_BRACKET("GR", 13.0f, "Reduced");
+ ADD_BRACKET("GR", 24.0f, "tax.standard");
+ ADD_BRACKET("GR", 6.0f, "tax.reduced");
+ ADD_BRACKET("GR", 13.0f, "tax.reduced");
// Hungary
- ADD_BRACKET("HU", 27.0f, "Standard");
- ADD_BRACKET("HU", 5.0f, "Reduced");
- ADD_BRACKET("HU", 18.0f, "Reduced");
+ ADD_BRACKET("HU", 27.0f, "tax.standard");
+ ADD_BRACKET("HU", 5.0f, "tax.reduced");
+ ADD_BRACKET("HU", 18.0f, "tax.reduced");
// Ireland
- ADD_BRACKET("IE", 23.0f, "Standard");
- ADD_BRACKET("IE", 9.0f, "Reduced");
- ADD_BRACKET("IE", 13.5f, "Reduced");
- ADD_BRACKET("IE", 4.8f, "SuperReduced");
+ ADD_BRACKET("IE", 23.0f, "tax.standard");
+ ADD_BRACKET("IE", 9.0f, "tax.reduced");
+ ADD_BRACKET("IE", 13.5f, "tax.reduced");
+ ADD_BRACKET("IE", 4.8f, "tax.superReduced");
// Italy
- ADD_BRACKET("IT", 22.0f, "Standard");
- ADD_BRACKET("IT", 5.0f, "Reduced");
- ADD_BRACKET("IT", 10.0f, "Reduced");
- ADD_BRACKET("IT", 4.0f, "SuperReduced");
+ ADD_BRACKET("IT", 22.0f, "tax.standard");
+ ADD_BRACKET("IT", 5.0f, "tax.reduced");
+ ADD_BRACKET("IT", 10.0f, "tax.reduced");
+ ADD_BRACKET("IT", 4.0f, "tax.superReduced");
// Latvia
- ADD_BRACKET("LV", 21.0f, "Standard");
- ADD_BRACKET("LV", 5.0f, "Reduced");
- ADD_BRACKET("LV", 12.0f, "Reduced");
+ ADD_BRACKET("LV", 21.0f, "tax.standard");
+ ADD_BRACKET("LV", 5.0f, "tax.reduced");
+ ADD_BRACKET("LV", 12.0f, "tax.reduced");
// Lithuania
- ADD_BRACKET("LT", 21.0f, "Standard");
- ADD_BRACKET("LT", 5.0f, "Reduced");
- ADD_BRACKET("LT", 9.0f, "Reduced");
+ ADD_BRACKET("LT", 21.0f, "tax.standard");
+ ADD_BRACKET("LT", 5.0f, "tax.reduced");
+ ADD_BRACKET("LT", 9.0f, "tax.reduced");
// Luxembourg
- ADD_BRACKET("LU", 17.0f, "Standard");
- ADD_BRACKET("LU", 8.0f, "Reduced");
- ADD_BRACKET("LU", 14.0f, "Reduced");
- ADD_BRACKET("LU", 3.0f, "SuperReduced");
+ ADD_BRACKET("LU", 17.0f, "tax.standard");
+ ADD_BRACKET("LU", 8.0f, "tax.reduced");
+ ADD_BRACKET("LU", 14.0f, "tax.reduced");
+ ADD_BRACKET("LU", 3.0f, "tax.superReduced");
// Malta
- ADD_BRACKET("MT", 18.0f, "Standard");
- ADD_BRACKET("MT", 5.0f, "Reduced");
- ADD_BRACKET("MT", 7.0f, "Reduced");
+ ADD_BRACKET("MT", 18.0f, "tax.standard");
+ ADD_BRACKET("MT", 5.0f, "tax.reduced");
+ ADD_BRACKET("MT", 7.0f, "tax.reduced");
// Netherlands
- ADD_BRACKET("NL", 21.0f, "Standard");
- ADD_BRACKET("NL", 9.0f, "Reduced");
+ ADD_BRACKET("NL", 21.0f, "tax.standard");
+ ADD_BRACKET("NL", 9.0f, "tax.reduced");
// Poland
- ADD_BRACKET("PL", 23.0f, "Standard");
- ADD_BRACKET("PL", 5.0f, "Reduced");
- ADD_BRACKET("PL", 8.0f, "Reduced");
+ ADD_BRACKET("PL", 23.0f, "tax.standard");
+ ADD_BRACKET("PL", 5.0f, "tax.reduced");
+ ADD_BRACKET("PL", 8.0f, "tax.reduced");
// Portugal
- ADD_BRACKET("PT", 23.0f, "Standard");
- ADD_BRACKET("PT", 6.0f, "Reduced");
- ADD_BRACKET("PT", 13.0f, "Reduced");
+ ADD_BRACKET("PT", 23.0f, "tax.standard");
+ ADD_BRACKET("PT", 6.0f, "tax.reduced");
+ ADD_BRACKET("PT", 13.0f, "tax.reduced");
// Romania
- ADD_BRACKET("RO", 19.0f, "Standard");
- ADD_BRACKET("RO", 5.0f, "Reduced");
- ADD_BRACKET("RO", 9.0f, "Reduced");
+ ADD_BRACKET("RO", 19.0f, "tax.standard");
+ ADD_BRACKET("RO", 5.0f, "tax.reduced");
+ ADD_BRACKET("RO", 9.0f, "tax.reduced");
// Slovakia
- ADD_BRACKET("SK", 23.0f, "Standard");
- ADD_BRACKET("SK", 5.0f, "Reduced");
- ADD_BRACKET("SK", 19.0f, "Reduced");
+ ADD_BRACKET("SK", 23.0f, "tax.standard");
+ ADD_BRACKET("SK", 5.0f, "tax.reduced");
+ ADD_BRACKET("SK", 19.0f, "tax.reduced");
// Slovenia
- ADD_BRACKET("SI", 22.0f, "Standard");
- ADD_BRACKET("SI", 5.0f, "Reduced");
- ADD_BRACKET("SI", 9.5f, "Reduced");
+ ADD_BRACKET("SI", 22.0f, "tax.standard");
+ ADD_BRACKET("SI", 5.0f, "tax.reduced");
+ ADD_BRACKET("SI", 9.5f, "tax.reduced");
// Spain
- ADD_BRACKET("ES", 21.0f, "Standard");
- ADD_BRACKET("ES", 10.0f, "Reduced");
- ADD_BRACKET("ES", 4.0f, "SuperReduced");
+ ADD_BRACKET("ES", 21.0f, "tax.standard");
+ ADD_BRACKET("ES", 10.0f, "tax.reduced");
+ ADD_BRACKET("ES", 4.0f, "tax.superReduced");
// Sweden
- ADD_BRACKET("SE", 25.0f, "Standard");
- ADD_BRACKET("SE", 6.0f, "Reduced");
- ADD_BRACKET("SE", 12.0f, "Reduced");
+ ADD_BRACKET("SE", 25.0f, "tax.standard");
+ ADD_BRACKET("SE", 6.0f, "tax.reduced");
+ ADD_BRACKET("SE", 12.0f, "tax.reduced");
}
void administration_create()
@@ -161,7 +161,7 @@ void administration_create()
list_init(&g_administration.contacts);
list_init(&g_administration.projects);
list_init(&g_administration.tax_brackets);
- strops_copy(g_administration.path, "[unsaved project]", sizeof(g_administration.path)); // @localize
+ strops_copy(g_administration.path, "", sizeof(g_administration.path));
administration_create_default_tax_brackets();
}
@@ -357,4 +357,25 @@ contact administration_get_company_info()
void administration_set_company_info(contact data)
{
g_administration.company_info = data;
+}
+
+u32 administration_get_tax_bracket_count()
+{
+ return list_size(&g_administration.tax_brackets);
+}
+
+u32 administration_get_tax_brackets(country_tax_bracket* buffer)
+{
+ assert(buffer);
+
+ u32 write_cursor = 0;
+
+ list_iterator_start(&g_administration.tax_brackets);
+ while (list_iterator_hasnext(&g_administration.tax_brackets)) {
+ country_tax_bracket c = *(country_tax_bracket *)list_iterator_next(&g_administration.tax_brackets);
+ buffer[write_cursor++] = c;
+ }
+ list_iterator_stop(&g_administration.tax_brackets);
+
+ return write_cursor;
} \ No newline at end of file
diff --git a/src/locales/en.cpp b/src/locales/en.cpp
index 2b2f2b6..3c208ef 100644
--- a/src/locales/en.cpp
+++ b/src/locales/en.cpp
@@ -1,6 +1,10 @@
#include "locales.hpp"
locale_entry en_locales[] = {
+ // General UI strings.
+ {"ui.unsavedProject", "[unsaved project]"},
+ {"ui.workingOn", "Working on"},
+
// General form buttons.
{"form.create", "+ Create"},
{"form.back", "Back"},
@@ -15,6 +19,13 @@ locale_entry en_locales[] = {
{"form.confirmCancelProject", "Are you sure you want to cancel this Project?"},
{"form.required", "required"},
+ // Tax strings.
+ {"tax.reverse_charge", "Reverse tax"},
+ {"tax.exempt", "Tax exempt"},
+ {"tax.standard", "Standard Rate"},
+ {"tax.reduced", "Reduced Rate"},
+ {"tax.superReduced", "Super Reduced Rate"},
+
// Countries
{ "country.AT", "Austria" },
{ "country.BE", "Belgium" },
@@ -51,7 +62,8 @@ locale_entry en_locales[] = {
{"nav.reports", "Reports"},
{"nav.reports.results", "Results"},
{"nav.reports.tax", "Tax return"},
- {"nav.Projects", "Projects"},
+ {"nav.projects", "Projects"},
+ {"nav.settings", "Settings"},
// Contact strings.
{"contact.form.identifier", "Identifier"},
@@ -69,7 +81,7 @@ locale_entry en_locales[] = {
{"contact.table.address", "Address"},
// Project strings.
- {"contact.form.identifier", "Identifier"},
+ {"project.form.identifier", "Identifier"},
{"project.form.description", "Description"},
{"project.table.identifier", "Identifier"},
{"project.table.status", "Status"},
@@ -77,6 +89,12 @@ locale_entry en_locales[] = {
{"project.state.running", "Running"},
{"project.state.cancelled", "Cancelled"},
{"project.state.paused", "Paused"},
+
+ // Settings strings.
+ {"settings.table.company", "Company"},
+ {"settings.table.vatrates", "VAT Rates"},
+ {"settings.vat.table.country", "Country"},
+ {"settings.vat.table.rates", "Rates"},
};
const int en_locale_count = sizeof(en_locales) / sizeof(en_locales[0]); \ No newline at end of file
diff --git a/src/ui/ui_main.cpp b/src/ui/ui_main.cpp
index 8af8dbc..10f9cea 100644
--- a/src/ui/ui_main.cpp
+++ b/src/ui/ui_main.cpp
@@ -91,8 +91,8 @@ void ui_draw_main()
ImGui::PopStyleVar();
}
- if (ImGui::Button(localize("nav.Projects"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::PROJECTS);
- if (ImGui::Button("Settings", ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::SETTINGS); //@localize
+ if (ImGui::Button(localize("nav.projects"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::PROJECTS);
+ if (ImGui::Button(localize("nav.settings"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::SETTINGS);
ImGui::PopStyleColor(1);
ImGui::PopStyleVar(3);
@@ -122,8 +122,14 @@ void ui_draw_main()
ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGuiWindowFlags_NoCollapse);
-
- ImGui::Text("Working on: %s", administration_get_file_path()); // @localize
+
+ char* path = administration_get_file_path();
+ if (strlen(path) == 0) {
+ ImGui::Text("%s: %s", localize("ui.workingOn"), localize("ui.unsavedProject"));
+ }
+ else {
+ ImGui::Text("%s: %s", localize("ui.workingOn"), administration_get_file_path());
+ }
ImGui::End();
ImGui::PopStyleVar();
diff --git a/src/ui/ui_projects.cpp b/src/ui/ui_projects.cpp
index a349814..a831f60 100644
--- a/src/ui/ui_projects.cpp
+++ b/src/ui/ui_projects.cpp
@@ -35,7 +35,7 @@ static void draw_project_form()
float widthAvailable = ImGui::GetContentRegionAvail().x;
ImGui::SetNextItemWidth(widthAvailable*0.2f);
- ImGui::InputText(localize("contact.form.identifier"), active_project.id, IM_ARRAYSIZE(active_project.id));
+ ImGui::InputText(localize("project.form.identifier"), active_project.id, IM_ARRAYSIZE(active_project.id));
if (!viewing_only) ImGui::EndDisabled();
ImGui::SetNextItemWidth(widthAvailable*0.5f);
diff --git a/src/ui/ui_settings.cpp b/src/ui/ui_settings.cpp
index 041b672..97e0503 100644
--- a/src/ui/ui_settings.cpp
+++ b/src/ui/ui_settings.cpp
@@ -1,3 +1,7 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "strops.hpp"
#include "ui.hpp"
#include "imgui.h"
#include "administration.hpp"
@@ -6,17 +10,67 @@
extern bool draw_contact_form(contact* buffer, bool back_button_enabled = true, bool viewing_only = false);
static contact company_info;
+country_tax_bracket* tax_brackets;
+u32 tax_bracket_count;
+
void ui_setup_settings()
{
company_info = administration_get_company_info();
+
+ tax_bracket_count = administration_get_tax_bracket_count();
+ tax_brackets = (country_tax_bracket*)malloc(tax_bracket_count * sizeof(country_tax_bracket));
+ administration_get_tax_brackets(tax_brackets);
+}
+
+static void ui_draw_vat_rates()
+{
+ if (ImGui::BeginTable("TableVatRates", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
+
+ ImGui::TableSetupColumn(localize("settings.vat.table.country"), ImGuiTableColumnFlags_WidthFixed, 140);
+ ImGui::TableSetupColumn(localize("settings.vat.table.rates"));
+
+ char prev_country[3];
+ prev_country[0] = 0;
+
+ for (u32 i = 0; i < tax_bracket_count; i++) {
+ country_tax_bracket c = tax_brackets[i];
+
+ if (strcmp(c.country_code, "00") == 0)
+ {
+ strops_copy(prev_country, c.country_code, 3);
+ }
+ else if (strcmp(c.country_code, prev_country) != 0)
+ {
+ strops_copy(prev_country, c.country_code, 3);
+
+ ImGui::TableNextRow();
+ ImGui::TableSetColumnIndex(0); ImGui::Text("");
+ ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(69, 69, 69, 255));
+ ImGui::TableSetColumnIndex(1); ImGui::Text("");
+ ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(69, 69, 69, 255));
+
+ ImGui::TableNextRow();
+
+ char locale_buf[20];
+ snprintf(locale_buf, sizeof(locale_buf), "country.%s", c.country_code);
+ ImGui::TableSetColumnIndex(0); ImGui::Text(localize(locale_buf));
+ ImGui::TableSetColumnIndex(1); ImGui::Text("");
+ }
+
+ ImGui::TableNextRow();
+ ImGui::TableSetColumnIndex(0); ImGui::Text(localize(c.description));
+ ImGui::TableSetColumnIndex(1); ImGui::Text("%.2f%%", c.rate);
+ }
+
+ ImGui::EndTable();
+ }
}
void ui_draw_settings()
{
- // @localize
if (ImGui::BeginTabBar("SettingsTabBar"))
{
- if (ImGui::BeginTabItem("Company"))
+ if (ImGui::BeginTabItem(localize("settings.table.company")))
{
bool save = draw_contact_form(&company_info, false);
@@ -25,9 +79,9 @@ void ui_draw_settings()
}
ImGui::EndTabItem();
}
- if (ImGui::BeginTabItem("VAT Rates"))
+ if (ImGui::BeginTabItem(localize("settings.table.vatrates")))
{
- ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah");
+ ui_draw_vat_rates();
ImGui::EndTabItem();
}
ImGui::EndTabBar();