summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/STORAGE.rst8
-rw-r--r--include/administration.hpp32
-rw-r--r--include/administration_reader.hpp2
-rw-r--r--include/administration_writer.hpp4
-rw-r--r--include/file_templates.hpp2
-rw-r--r--src/administration.cpp142
-rw-r--r--src/administration_reader.cpp10
-rw-r--r--src/administration_writer.cpp70
-rw-r--r--src/ui/ui_expenses.cpp12
-rw-r--r--src/ui/ui_invoices.cpp46
-rw-r--r--src/ui/ui_settings.cpp50
-rw-r--r--tests/administration_rw_tests.cpp22
12 files changed, 200 insertions, 200 deletions
diff --git a/docs/STORAGE.rst b/docs/STORAGE.rst
index 4af6398..5c04ad5 100644
--- a/docs/STORAGE.rst
+++ b/docs/STORAGE.rst
@@ -39,7 +39,7 @@ Administration
- contacts **list** — List of contacts
- projects **list** — List of projects
- invoices **list** — List of invoices
-- tax brackets **list** — List of available tax brackets
+- tax rates **list** — List of available tax rates
- AI service — Which AI service to use
- AI key — API key for selected AI service
- email service — Which email service to use
@@ -93,7 +93,7 @@ Billing item
- id **auto** — reference id **B/[id]**
- invoice **auto** — reference to invoice **I/[id]**
- description **required** — Description of billed item
-- tax bracket **required** — Tax bracket (e.g. 0%, 21%, exempt, reversed)
+- tax rate **required** — Tax rate (e.g. 0%, 21%, exempt, reversed)
- tax section **required** — Tax section (e.g. 1a up to 4b in The Netherlands)
- amount **required** — Amount of items, or a percentage
- amount is percentage **required** — Amount of items, or a percentage
@@ -123,10 +123,10 @@ Cost center
- code **required** — Internal code of cost center
- description **required** — Description of cost center
-Tax bracket
+Tax rate
-----------
- id **auto** — reference id **T/[id]**
- country code **required** — 2 letter country code
-- description **required** — Description of tax bracket
+- description **required** — Description of tax rate
- rate **required** — Tax rate %
diff --git a/include/administration.hpp b/include/administration.hpp
index 6123df4..7c1b0d0 100644
--- a/include/administration.hpp
+++ b/include/administration.hpp
@@ -33,7 +33,7 @@ typedef struct
char country_code[MAX_LEN_COUNTRY_CODE]; // 2 letter country code
float rate; // 0-100%
char category_code[MAX_LEN_CODE]; // Category code. https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL5305/
-} country_tax_bracket;
+} tax_rate;
typedef struct
{
@@ -115,7 +115,7 @@ typedef struct
float allowance; // Total discount.
float net; // Total net, with discount.
char currency[MAX_LEN_CURRENCY]; // 3 letter code
- char tax_bracket_id[MAX_LEN_ID]; // T/[id]
+ char tax_rate_id[MAX_LEN_ID]; // T/[id]
float tax;
float total;
} billing_item;
@@ -308,7 +308,7 @@ typedef void (*data_changed_event)();
typedef void (*data_deleted_event)(char id[MAX_LEN_ID]);
typedef void (*invoice_changed_event)(invoice* invoice);
typedef void (*contact_changed_event)(contact* contact);
-typedef void (*taxbracket_changed_event)(country_tax_bracket* bracket);
+typedef void (*taxrate_changed_event)(tax_rate* rate);
typedef void (*costcenter_changed_event)(cost_center* cost_center);
typedef void (*project_changed_event)(project* project);
@@ -324,7 +324,7 @@ typedef struct
list_t contacts;
list_t projects;
- list_t tax_brackets;
+ list_t tax_rates;
list_t cost_centers;
u32 invoice_count;
@@ -367,7 +367,7 @@ void administration_set_data_changed_event_callback(data_changed_event ev);
void administration_set_data_deleted_event_callback(data_deleted_event ev);
void administration_set_invoice_changed_event_callback(invoice_changed_event ev);
void administration_set_contact_changed_event_callback(contact_changed_event ev);
-void administration_set_taxbracket_changed_event_callback(taxbracket_changed_event ev);
+void administration_set_taxrate_changed_event_callback(taxrate_changed_event ev);
void administration_set_costcenter_changed_event_callback(costcenter_changed_event ev);
void administration_set_project_changed_event_callback(project_changed_event ev);
@@ -425,17 +425,17 @@ u32 administration_project_get_all(project* buffer);
u32 administration_project_get_partial_list(u32 page_index, u32 page_size, project* buffer);
a_err administration_project_get_by_id(project* buffer, char* id);
-// Tax bracket functions.
+// Tax rate functions.
// =======================
-u32 administration_tax_bracket_count();
-country_tax_bracket administration_tax_bracket_create_empty();
-a_err administration_tax_bracket_import(country_tax_bracket data);
-a_err administration_tax_bracket_add(country_tax_bracket data);
-a_err administration_tax_bracket_update(country_tax_bracket data);
+u32 administration_tax_rate_count();
+tax_rate administration_tax_rate_create_empty();
+a_err administration_tax_rate_import(tax_rate data);
+a_err administration_tax_rate_add(tax_rate data);
+a_err administration_tax_rate_update(tax_rate data);
-a_err administration_tax_bracket_get_by_id(country_tax_bracket* buffer, char* id);
-u32 administration_tax_bracket_get_all(country_tax_bracket* buffer);
-u32 administration_tax_bracket_get_by_country(country_tax_bracket* buffer, char* country_code);
+a_err administration_tax_rate_get_by_id(tax_rate* buffer, char* id);
+u32 administration_tax_rate_get_all(tax_rate* buffer);
+u32 administration_tax_rate_get_by_country(tax_rate* buffer, char* country_code);
// Cost center functions.
// =======================
@@ -470,8 +470,8 @@ u32 administration_invoice_get_partial_list_outgoing(u32 page_index, u32 pag
u32 administration_invoice_get_partial_list_incomming(u32 page_index, u32 page_size, invoice* buffer);
u32 administration_invoice_get_all(invoice* buffer);
-u32 administration_invoice_get_tax_brackets(invoice* invoice, country_tax_bracket* buffer);
-bool administration_invoice_get_subtotal_for_tax_bracket(invoice* invoice, country_tax_bracket bracket, tax_subtotal* buffer);
+u32 administration_invoice_get_tax_rates(invoice* invoice, tax_rate* buffer);
+bool administration_invoice_get_subtotal_for_tax_rate(invoice* invoice, tax_rate rate, tax_subtotal* buffer);
// Billing item functions.
// =======================
diff --git a/include/administration_reader.hpp b/include/administration_reader.hpp
index ed932bc..d94947e 100644
--- a/include/administration_reader.hpp
+++ b/include/administration_reader.hpp
@@ -4,7 +4,7 @@ bool administration_reader_open_new();
bool administration_reader_open_existing(char* file_path);
bool administration_reader_import_administration_info(char* buffer, size_t buffer_size);
-bool administration_reader_import_tax_bracket(char* buffer, size_t buffer_size);
+bool administration_reader_import_tax_rate(char* buffer, size_t buffer_size);
bool administration_reader_import_cost_center(char* buffer, size_t buffer_size);
bool administration_reader_import_project(char* buffer, size_t buffer_size);
bool administration_reader_import_contact(char* buffer, size_t buffer_size); \ No newline at end of file
diff --git a/include/administration_writer.hpp b/include/administration_writer.hpp
index f1235ae..08fe301 100644
--- a/include/administration_writer.hpp
+++ b/include/administration_writer.hpp
@@ -14,12 +14,12 @@ bool administration_writer_start_new();
bool administration_writer_delete_entry(char* id);
bool administration_writer_save_project_blocking(project project);
bool administration_writer_save_cost_center_blocking(cost_center cost);
-bool administration_writer_save_tax_bracket_blocking(country_tax_bracket bracket);
+bool administration_writer_save_tax_rate_blocking(tax_rate rate);
bool administration_writer_save_contact_blocking(contact c);
bool administration_writer_save_invoice_blocking(invoice inv);
// Archiving functions.
bool administration_writer_save_all_administration_info_blocking();
-bool administration_writer_save_all_tax_brackets_blocking();
+bool administration_writer_save_all_tax_rates_blocking();
bool administration_writer_save_all_cost_centers_blocking();
bool administration_writer_save_all_async(); \ No newline at end of file
diff --git a/include/file_templates.hpp b/include/file_templates.hpp
index ff3252f..d6f9b7d 100644
--- a/include/file_templates.hpp
+++ b/include/file_templates.hpp
@@ -14,7 +14,7 @@ const char* costcenter_save_template =
" <Description>{{COSTCENTER_DESCRIPTION}}</Description>\n"
"</CostCenter>";
-const char* taxbracket_save_template =
+const char* taxrate_save_template =
"<CountryTaxBracket>\n"
" <Id>{{TAXBRACKET_ID}}</Id>\n"
" <CountryCode>{{TAXBRACKET_COUNTRY}}</CountryCode>\n"
diff --git a/src/administration.cpp b/src/administration.cpp
index 955e377..41dbf90 100644
--- a/src/administration.cpp
+++ b/src/administration.cpp
@@ -17,7 +17,7 @@ data_changed_event data_changed_event_callback = 0;
data_deleted_event data_deleted_event_callback = 0;
invoice_changed_event invoice_changed_event_callback = 0;
contact_changed_event contact_changed_event_callback = 0;
-taxbracket_changed_event taxbracket_changed_event_callback = 0;
+taxrate_changed_event taxrate_changed_event_callback = 0;
costcenter_changed_event costcenter_changed_event_callback = 0;
project_changed_event project_changed_event_callback = 0;
@@ -28,21 +28,21 @@ static s32 administration_create_id()
#define ADD_BRACKET(_country, _rate, _code)\
{\
- country_tax_bracket* tb = (country_tax_bracket*)malloc(sizeof(country_tax_bracket));\
+ tax_rate* tb = (tax_rate*)malloc(sizeof(tax_rate));\
snprintf(tb->id, sizeof(tb->id), "T/%d", administration_create_id());\
memcpy(tb->country_code, _country, sizeof(tb->country_code));\
tb->rate = _rate;\
memcpy(tb->category_code, _code, sizeof(tb->category_code));\
- list_append(&g_administration.tax_brackets, tb);\
+ list_append(&g_administration.tax_rates, tb);\
g_administration.next_id++;\
- if (taxbracket_changed_event_callback) taxbracket_changed_event_callback(tb);\
+ if (taxrate_changed_event_callback) taxrate_changed_event_callback(tb);\
if (data_changed_event_callback) data_changed_event_callback();\
}
static int compare_tax_countries(const void *a, const void *b)
{
- country_tax_bracket *objA = (country_tax_bracket *)a;
- country_tax_bracket *objB = (country_tax_bracket *)b;
+ tax_rate *objA = (tax_rate *)a;
+ tax_rate *objB = (tax_rate *)b;
return strcmp(objA->country_code, objB->country_code);
}
@@ -108,18 +108,18 @@ static void administration_get_random_billing_items(invoice* inv)
if (item.net < item.discount) item.discount = 0.0f;
- country_tax_bracket buffer[20];
- u32 bracket_count = administration_tax_bracket_get_by_country(buffer, inv->supplier.address.country_code);
- country_tax_bracket rand_bracket = buffer[rand() % bracket_count];
- strops_copy(item.tax_bracket_id, rand_bracket.id, MAX_LEN_ID);
+ tax_rate buffer[20];
+ u32 rate_count = administration_tax_rate_get_by_country(buffer, inv->supplier.address.country_code);
+ tax_rate rand_rate = buffer[rand() % rate_count];
+ strops_copy(item.tax_rate_id, rand_rate.id, MAX_LEN_ID);
administration_billing_item_add_to_invoice(inv, item);
}
}
-static void administration_create_default_tax_brackets()
+static void administration_create_default_tax_rates()
{
- // General brackets shared between countries.
+ // General rates shared between countries.
// Category options: https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL5305/
// TODO unimplemented category L, M, B
@@ -263,8 +263,8 @@ static void administration_create_default_tax_brackets()
ADD_BRACKET("SE", 6.0f, "S");
ADD_BRACKET("SE", 12.0f, "S");
- list_attributes_comparator(&g_administration.tax_brackets, compare_tax_countries);
- list_sort(&g_administration.tax_brackets, -1);
+ list_attributes_comparator(&g_administration.tax_rates, compare_tax_countries);
+ list_sort(&g_administration.tax_rates, -1);
}
static void administration_create_default_cost_centers()
@@ -426,9 +426,9 @@ void administration_set_contact_changed_event_callback(contact_changed_event ev)
contact_changed_event_callback = ev;
}
-void administration_set_taxbracket_changed_event_callback(taxbracket_changed_event ev)
+void administration_set_taxrate_changed_event_callback(taxrate_changed_event ev)
{
- taxbracket_changed_event_callback = ev;
+ taxrate_changed_event_callback = ev;
}
void administration_set_costcenter_changed_event_callback(costcenter_changed_event ev)
@@ -453,7 +453,7 @@ void administration_create()
list_init(&g_administration.invoices);
list_init(&g_administration.contacts);
list_init(&g_administration.projects);
- list_init(&g_administration.tax_brackets);
+ list_init(&g_administration.tax_rates);
list_init(&g_administration.cost_centers);
strops_copy(g_administration.path, "", sizeof(g_administration.path));
@@ -477,7 +477,7 @@ void administration_destroy()
administration_destroy_list(&g_administration.invoices);
administration_destroy_list(&g_administration.contacts);
administration_destroy_list(&g_administration.projects);
- administration_destroy_list(&g_administration.tax_brackets);
+ administration_destroy_list(&g_administration.tax_rates);
administration_destroy_list(&g_administration.cost_centers);
}
@@ -506,7 +506,7 @@ void administration_create_empty(char* save_file)
void administration_create_default(char* save_file)
{
administration_create_empty(save_file);
- administration_create_default_tax_brackets();
+ administration_create_default_tax_rates();
administration_create_default_cost_centers();
//administration_create_debug_data();
}
@@ -1217,128 +1217,128 @@ project administration_project_create_empty()
return result;
}
-// Tax bracket functions.
+// Tax rate functions.
// =======================
-country_tax_bracket administration_tax_bracket_create_empty()
+tax_rate administration_tax_rate_create_empty()
{
- country_tax_bracket result;
- memset(&result, 0, sizeof(country_tax_bracket));
+ tax_rate result;
+ memset(&result, 0, sizeof(tax_rate));
snprintf(result.id, sizeof(result.id), "T/%d", administration_create_id());
snprintf(result.category_code, sizeof(result.category_code), "S"); // S = standard rate.
return result;
}
-a_err administration_tax_bracket_get_by_id(country_tax_bracket* buffer, char* id)
+a_err administration_tax_rate_get_by_id(tax_rate* buffer, char* id)
{
assert(buffer);
- 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);
+ list_iterator_start(&g_administration.tax_rates);
+ while (list_iterator_hasnext(&g_administration.tax_rates)) {
+ tax_rate c = *(tax_rate *)list_iterator_next(&g_administration.tax_rates);
if (strcmp(c.id, id) == 0)
{
*buffer = c;
- list_iterator_stop(&g_administration.tax_brackets);
+ list_iterator_stop(&g_administration.tax_rates);
return a_err::A_ERR_SUCCESS;
}
}
- list_iterator_stop(&g_administration.tax_brackets);
+ list_iterator_stop(&g_administration.tax_rates);
return a_err::A_ERR_NOT_FOUND;
}
-u32 administration_tax_bracket_count()
+u32 administration_tax_rate_count()
{
- return list_size(&g_administration.tax_brackets);
+ return list_size(&g_administration.tax_rates);
}
-a_err administration_tax_bracket_import(country_tax_bracket data)
+a_err administration_tax_rate_import(tax_rate data)
{
- country_tax_bracket* tb = (country_tax_bracket*)malloc(sizeof(country_tax_bracket));
+ tax_rate* tb = (tax_rate*)malloc(sizeof(tax_rate));
if (!tb) return a_err::A_ERR_GENERIC;
- memcpy((void*)tb, (void*)&data, sizeof(country_tax_bracket));
- if (!list_append(&g_administration.tax_brackets, tb)) {
+ memcpy((void*)tb, (void*)&data, sizeof(tax_rate));
+ if (!list_append(&g_administration.tax_rates, tb)) {
return a_err::A_ERR_GENERIC;
}
- list_attributes_comparator(&g_administration.tax_brackets, compare_tax_countries);
- list_sort(&g_administration.tax_brackets, -1);
+ list_attributes_comparator(&g_administration.tax_rates, compare_tax_countries);
+ list_sort(&g_administration.tax_rates, -1);
return a_err::A_ERR_SUCCESS;
}
-a_err administration_tax_bracket_add(country_tax_bracket data)
+a_err administration_tax_rate_add(tax_rate data)
{
- country_tax_bracket* tb = (country_tax_bracket*)malloc(sizeof(country_tax_bracket));
+ tax_rate* tb = (tax_rate*)malloc(sizeof(tax_rate));
if (!tb) return a_err::A_ERR_GENERIC;
- memcpy((void*)tb, (void*)&data, sizeof(country_tax_bracket));
- if (!list_append(&g_administration.tax_brackets, tb)) {
+ memcpy((void*)tb, (void*)&data, sizeof(tax_rate));
+ if (!list_append(&g_administration.tax_rates, tb)) {
return a_err::A_ERR_GENERIC;
}
g_administration.next_id++;
- list_attributes_comparator(&g_administration.tax_brackets, compare_tax_countries);
- list_sort(&g_administration.tax_brackets, -1);
+ list_attributes_comparator(&g_administration.tax_rates, compare_tax_countries);
+ list_sort(&g_administration.tax_rates, -1);
- if (taxbracket_changed_event_callback) taxbracket_changed_event_callback(&data);
+ if (taxrate_changed_event_callback) taxrate_changed_event_callback(&data);
if (data_changed_event_callback) data_changed_event_callback();
return a_err::A_ERR_SUCCESS;
}
-u32 administration_tax_bracket_get_by_country(country_tax_bracket* buffer, char* country_code)
+u32 administration_tax_rate_get_by_country(tax_rate* buffer, char* country_code)
{
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);
+ list_iterator_start(&g_administration.tax_rates);
+ while (list_iterator_hasnext(&g_administration.tax_rates)) {
+ tax_rate c = *(tax_rate *)list_iterator_next(&g_administration.tax_rates);
if (strcmp(c.country_code, country_code) == 0 || strcmp(c.country_code, "00") == 0) buffer[write_cursor++] = c;
}
- list_iterator_stop(&g_administration.tax_brackets);
+ list_iterator_stop(&g_administration.tax_rates);
return write_cursor;
}
-u32 administration_tax_bracket_get_all(country_tax_bracket* buffer)
+u32 administration_tax_rate_get_all(tax_rate* 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);
+ list_iterator_start(&g_administration.tax_rates);
+ while (list_iterator_hasnext(&g_administration.tax_rates)) {
+ tax_rate c = *(tax_rate *)list_iterator_next(&g_administration.tax_rates);
buffer[write_cursor++] = c;
}
- list_iterator_stop(&g_administration.tax_brackets);
+ list_iterator_stop(&g_administration.tax_rates);
return write_cursor;
}
-a_err administration_tax_bracket_update(country_tax_bracket data)
+a_err administration_tax_rate_update(tax_rate data)
{
- 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);
+ list_iterator_start(&g_administration.tax_rates);
+ while (list_iterator_hasnext(&g_administration.tax_rates)) {
+ tax_rate* c = (tax_rate *)list_iterator_next(&g_administration.tax_rates);
if (strcmp(c->id, data.id) == 0) {
memcpy(c, &data, sizeof(data));
- list_iterator_stop(&g_administration.tax_brackets);
+ list_iterator_stop(&g_administration.tax_rates);
- if (taxbracket_changed_event_callback) taxbracket_changed_event_callback(c);
+ if (taxrate_changed_event_callback) taxrate_changed_event_callback(c);
if (data_changed_event_callback) data_changed_event_callback();
return a_err::A_ERR_SUCCESS;
}
}
- list_iterator_stop(&g_administration.tax_brackets);
+ list_iterator_stop(&g_administration.tax_rates);
return a_err::A_ERR_NOT_FOUND;
}
@@ -1777,7 +1777,7 @@ u32 administration_invoice_get_all(invoice* buffer)
return write_cursor;
}
-bool administration_invoice_get_subtotal_for_tax_bracket(invoice* invoice, country_tax_bracket bracket, tax_subtotal* buffer)
+bool administration_invoice_get_subtotal_for_tax_rate(invoice* invoice, tax_rate rate, tax_subtotal* buffer)
{
bool result = false;
@@ -1790,7 +1790,7 @@ bool administration_invoice_get_subtotal_for_tax_bracket(invoice* invoice, count
while (list_iterator_hasnext(&invoice->billing_items)) {
billing_item* c = (billing_item *)list_iterator_next(&invoice->billing_items);
- if (strcmp(c->tax_bracket_id, bracket.id) == 0)
+ if (strcmp(c->tax_rate_id, rate.id) == 0)
{
result = true;
buffer->tax += c->tax;
@@ -1804,7 +1804,7 @@ bool administration_invoice_get_subtotal_for_tax_bracket(invoice* invoice, count
return result;
}
-u32 administration_invoice_get_tax_brackets(invoice* invoice, country_tax_bracket* buffer)
+u32 administration_invoice_get_tax_rates(invoice* invoice, tax_rate* buffer)
{
u32 write_cursor = 0;
@@ -1812,20 +1812,20 @@ u32 administration_invoice_get_tax_brackets(invoice* invoice, country_tax_bracke
while (list_iterator_hasnext(&invoice->billing_items)) {
billing_item c = *(billing_item *)list_iterator_next(&invoice->billing_items);
- country_tax_bracket bracket;
- a_err found = administration_tax_bracket_get_by_id(&bracket, c.tax_bracket_id);
+ tax_rate rate;
+ a_err found = administration_tax_rate_get_by_id(&rate, c.tax_rate_id);
if (found == a_err::A_ERR_SUCCESS) {
bool exists = false;
for (u32 i = 0; i < write_cursor; i++) {
- if (strcmp(buffer[i].id, c.tax_bracket_id) == 0) {
+ if (strcmp(buffer[i].id, c.tax_rate_id) == 0) {
exists = true;
break;
}
}
if (!exists) {
- buffer[write_cursor++] = bracket;
+ buffer[write_cursor++] = rate;
}
}
}
@@ -1913,10 +1913,10 @@ static void administration_recalculate_billing_item_totals(billing_item* item)
}
}
- country_tax_bracket bracket;
- if (administration_tax_bracket_get_by_id(&bracket, item->tax_bracket_id) == a_err::A_ERR_SUCCESS)
+ tax_rate rate;
+ if (administration_tax_rate_get_by_id(&rate, item->tax_rate_id) == a_err::A_ERR_SUCCESS)
{
- item->tax = item->net * (bracket.rate/100.0f);
+ item->tax = item->net * (rate.rate/100.0f);
}
item->total = item->net + item->tax;
diff --git a/src/administration_reader.cpp b/src/administration_reader.cpp
index b7dfa8f..529d8c0 100644
--- a/src/administration_reader.cpp
+++ b/src/administration_reader.cpp
@@ -60,7 +60,7 @@ bool administration_reader_open_existing(char* file_path)
}
else if (strops_prefix("T/", name))
{
- administration_reader_import_tax_bracket(buffer, (size_t)size);
+ administration_reader_import_tax_rate(buffer, (size_t)size);
}
else if (strops_prefix("E/", name))
{
@@ -221,7 +221,7 @@ bool administration_reader_import_cost_center(char* buffer, size_t buffer_size)
return result;
}
-bool administration_reader_import_tax_bracket(char* buffer, size_t buffer_size)
+bool administration_reader_import_tax_rate(char* buffer, size_t buffer_size)
{
STOPWATCH_START;
@@ -230,14 +230,14 @@ bool administration_reader_import_tax_bracket(char* buffer, size_t buffer_size)
struct xml_node* root = xml_document_root(document);
- country_tax_bracket data = {0};
+ tax_rate data = {0};
_get_xml_str(root, data.id, MAX_LEN_ID, "Id");
_get_xml_str(root, data.country_code, MAX_LEN_COUNTRY_CODE, "CountryCode");
_get_xml_str(root, data.category_code, MAX_LEN_CODE, "Category");
data.rate = _get_xml_float(root, "Rate");
- bool result = administration_tax_bracket_import(data);
- log_add("Loaded tax bracket info in %.3fms. id=%s country_code=%s category_code=%s rate=%.2f",
+ bool result = administration_tax_rate_import(data);
+ log_add("Loaded tax rate info in %.3fms. id=%s country_code=%s category_code=%s rate=%.2f",
STOPWATCH_TIME, data.id, data.country_code, data.category_code, data.rate);
return result;
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp
index d19fb51..119f4b4 100644
--- a/src/administration_writer.cpp
+++ b/src/administration_writer.cpp
@@ -34,9 +34,9 @@ static void on_contact_changed_changed(contact* contact)
administration_writer_save_contact_blocking(*contact);
}
-static void on_taxbracket_changed_changed(country_tax_bracket* bracket)
+static void on_taxrate_changed_changed(tax_rate* rate)
{
- administration_writer_save_tax_bracket_blocking(*bracket);
+ administration_writer_save_tax_rate_blocking(*rate);
}
static void on_costcenter_changed_changed(cost_center* cost_center)
@@ -55,7 +55,7 @@ bool administration_writer_create()
administration_set_data_deleted_event_callback(on_administration_data_deleted);
administration_set_invoice_changed_event_callback(on_invoice_changed);
administration_set_contact_changed_event_callback(on_contact_changed_changed);
- administration_set_taxbracket_changed_event_callback(on_taxbracket_changed_changed);
+ administration_set_taxrate_changed_event_callback(on_taxrate_changed_changed);
administration_set_costcenter_changed_event_callback(on_costcenter_changed_changed);
administration_set_project_changed_event_callback(on_project_changed_changed);
@@ -292,27 +292,27 @@ bool administration_writer_save_invoice_blocking(invoice inv)
// Tax breakdown
strops_replace_float(file_content, buf_length, "{{TOTAL_TAX_AMOUNT}}", inv.tax, 2);
{ // Create tax subtotal list.
- country_tax_bracket* tax_bracket_buffer = (country_tax_bracket*)malloc(sizeof(country_tax_bracket)*administration_billing_item_count(&inv));
- u32 tax_bracket_count = administration_invoice_get_tax_brackets(&inv, tax_bracket_buffer);
+ tax_rate* tax_rate_buffer = (tax_rate*)malloc(sizeof(tax_rate)*administration_billing_item_count(&inv));
+ u32 tax_rate_count = administration_invoice_get_tax_rates(&inv, tax_rate_buffer);
- u32 tax_subtotal_list_buffer_size = (u32)strlen(peppol_invoice_tax_subtotal_template) * 2 * tax_bracket_count; // Ballpark list size.
+ u32 tax_subtotal_list_buffer_size = (u32)strlen(peppol_invoice_tax_subtotal_template) * 2 * tax_rate_count; // Ballpark list size.
char* tax_subtotal_list_buffer = (char*)malloc(tax_subtotal_list_buffer_size);
memset(tax_subtotal_list_buffer, 0, tax_subtotal_list_buffer_size);
u32 tax_subtotal_list_buffer_cursor = 0;
- for (u32 i = 0; i < tax_bracket_count; i++)
+ for (u32 i = 0; i < tax_rate_count; i++)
{
int tax_entry_buf_length = 0;
char* tax_entry_file_content = administration_writer_copy_template(peppol_invoice_tax_subtotal_template, &tax_entry_buf_length);
tax_subtotal subtotal;
- administration_invoice_get_subtotal_for_tax_bracket(&inv, tax_bracket_buffer[i], &subtotal);
+ administration_invoice_get_subtotal_for_tax_rate(&inv, tax_rate_buffer[i], &subtotal);
strops_replace(tax_entry_file_content, tax_entry_buf_length, "{{CURRENCY}}", inv.currency);
strops_replace_float(tax_entry_file_content, tax_entry_buf_length, "{{TAXABLE_AMOUNT}}", subtotal.net, 2);
strops_replace_float(tax_entry_file_content, tax_entry_buf_length, "{{TAX_AMOUNT}}", subtotal.tax, 2);
- strops_replace(tax_entry_file_content, tax_entry_buf_length, "{{TAX_CATEGORY}}", tax_bracket_buffer[i].category_code);
- strops_replace_float(tax_entry_file_content, tax_entry_buf_length, "{{TAX_PERCENT}}", tax_bracket_buffer[i].rate, 2);
+ strops_replace(tax_entry_file_content, tax_entry_buf_length, "{{TAX_CATEGORY}}", tax_rate_buffer[i].category_code);
+ strops_replace_float(tax_entry_file_content, tax_entry_buf_length, "{{TAX_PERCENT}}", tax_rate_buffer[i].rate, 2);
u32 content_len = (u32)strlen(tax_entry_file_content);
memcpy(tax_subtotal_list_buffer+tax_subtotal_list_buffer_cursor, tax_entry_file_content, content_len);
@@ -324,7 +324,7 @@ bool administration_writer_save_invoice_blocking(invoice inv)
strops_replace(file_content, buf_length, "{{TAX_SUBTOTAL_LIST}}", tax_subtotal_list_buffer);
free(tax_subtotal_list_buffer);
- free(tax_bracket_buffer);
+ free(tax_rate_buffer);
}
// Totals
@@ -349,19 +349,19 @@ bool administration_writer_save_invoice_blocking(invoice inv)
char* billing_item_file_content = administration_writer_copy_template(peppol_invoice_line_template, &billing_item_buf_length);
billing_item bi = billing_item_buffer[i];
- country_tax_bracket bracket;
- administration_tax_bracket_get_by_id(&bracket, bi.tax_bracket_id);
+ tax_rate rate;
+ administration_tax_rate_get_by_id(&rate, bi.tax_rate_id);
strops_replace(billing_item_file_content, billing_item_buf_length, "{{CURRENCY}}", inv.currency);
strops_replace(billing_item_file_content, billing_item_buf_length, "{{LINE_ID}}", bi.id);
strops_replace(billing_item_file_content, billing_item_buf_length, "{{ITEM_NAME}}", bi.description);
- strops_replace(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_CATEGORY}}", bracket.category_code);
- strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_PERCENT}}", bracket.rate, 2);
+ strops_replace(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_CATEGORY}}", rate.category_code);
+ strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{LINE_TAX_PERCENT}}", rate.rate, 2);
strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{LINE_AMOUNT}}", bi.net, 2); // line amount = net_per_item * items_count - discount
strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{QUANTITY}}", bi.amount, 2);
strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{UNIT_PRICE}}", bi.net_per_item, 2); // unit price before discount
strops_replace(billing_item_file_content, billing_item_buf_length, "{{UNIT_CODE}}", bi.amount_is_percentage ? "%" : "X");
- strops_replace(billing_item_file_content, billing_item_buf_length, "{{TAX_BRACKET_ID}}", bi.tax_bracket_id);
+ strops_replace(billing_item_file_content, billing_item_buf_length, "{{TAX_BRACKET_ID}}", bi.tax_rate_id);
if (bi.discount_is_percentage) {
strops_replace(billing_item_file_content, billing_item_buf_length, "{{ALLOWANCE_IS_PERCENTAGE}}",
@@ -523,24 +523,24 @@ bool administration_writer_save_all_cost_centers_blocking()
}
/////////////////////////////
-//// Tax brackets
+//// Tax rates
/////////////////////////////
-bool administration_writer_save_tax_bracket_blocking(country_tax_bracket bracket)
+bool administration_writer_save_tax_rate_blocking(tax_rate rate)
{
STOPWATCH_START;
bool result = 1;
int buf_length = 0;
- char* file_content = administration_writer_copy_template(taxbracket_save_template, &buf_length);
+ char* file_content = administration_writer_copy_template(taxrate_save_template, &buf_length);
- strops_replace(file_content, buf_length, "{{TAXBRACKET_ID}}", bracket.id);
- strops_replace(file_content, buf_length, "{{TAXBRACKET_COUNTRY}}", bracket.country_code);
- strops_replace_float(file_content, buf_length, "{{TAXBRACKET_RATE}}", bracket.rate, 2);
- strops_replace(file_content, buf_length, "{{TAXBRACKET_CATEGORY}}", bracket.category_code);
+ strops_replace(file_content, buf_length, "{{TAXBRACKET_ID}}", rate.id);
+ strops_replace(file_content, buf_length, "{{TAXBRACKET_COUNTRY}}", rate.country_code);
+ strops_replace_float(file_content, buf_length, "{{TAXBRACKET_RATE}}", rate.rate, 2);
+ strops_replace(file_content, buf_length, "{{TAXBRACKET_CATEGORY}}", rate.category_code);
//// Write to Disk.
char final_path[50];
- snprintf(final_path, 50, "%s.xml", bracket.id);
+ snprintf(final_path, 50, "%s.xml", rate.id);
int final_length = (int)strlen(file_content);
if (!xml_parse_document((uint8_t*)file_content, final_length)) result = 0;
@@ -548,26 +548,26 @@ bool administration_writer_save_tax_bracket_blocking(country_tax_bracket bracket
free(file_content);
- log_add("Saved tax bracket '%s/%.1f' in %.3fms.", bracket.country_code, bracket.rate, STOPWATCH_TIME);
+ log_add("Saved tax rate '%s/%.1f' in %.3fms.", rate.country_code, rate.rate, STOPWATCH_TIME);
return result;
}
-bool administration_writer_save_all_tax_brackets_blocking()
+bool administration_writer_save_all_tax_rates_blocking()
{
//// Get all data.
- u32 num_brackets = administration_tax_bracket_count();
- u32 buffer_size = sizeof(country_tax_bracket) * num_brackets;
- country_tax_bracket* bracket_buffer = (country_tax_bracket*)malloc(buffer_size);
- num_brackets = administration_tax_bracket_get_all(bracket_buffer);
+ u32 num_rates = administration_tax_rate_count();
+ u32 buffer_size = sizeof(tax_rate) * num_rates;
+ tax_rate* rate_buffer = (tax_rate*)malloc(buffer_size);
+ num_rates = administration_tax_rate_get_all(rate_buffer);
bool result = 1;
- for (u32 i = 0; i < num_brackets; i++) {
- country_tax_bracket c = bracket_buffer[i];
- if (!administration_writer_save_tax_bracket_blocking(c)) result = 0;
+ for (u32 i = 0; i < num_rates; i++) {
+ tax_rate c = rate_buffer[i];
+ if (!administration_writer_save_tax_rate_blocking(c)) result = 0;
}
- free(bracket_buffer);
+ free(rate_buffer);
return result;
}
@@ -671,7 +671,7 @@ static int administration_writer_write_all_t(void *arg) {
if (!administration_writer_save_all_invoices_blocking()) result = 0;
if (!administration_writer_save_all_projects_blocking()) result = 0;
if (!administration_writer_save_all_administration_info_blocking()) result = 0;
- if (!administration_writer_save_all_tax_brackets_blocking()) result = 0;
+ if (!administration_writer_save_all_tax_rates_blocking()) result = 0;
if (!administration_writer_save_all_cost_centers_blocking()) result = 0;
if (!administration_writer_save_all_contacts_blocking()) result = 0;
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));
}
}
}
diff --git a/tests/administration_rw_tests.cpp b/tests/administration_rw_tests.cpp
index 8f38046..d69b7dd 100644
--- a/tests/administration_rw_tests.cpp
+++ b/tests/administration_rw_tests.cpp
@@ -30,32 +30,32 @@ static void teardown_cb(void *data) {
unlink(test_file_path);
}
-TEST _administration_rw_taxbracket(void)
+TEST _administration_rw_taxrate(void)
{
- country_tax_bracket pw;
- country_tax_bracket pr;
+ tax_rate pw;
+ tax_rate pr;
u32 count;
administration_writer_create();
administration_create_empty(test_file_path);
{
- pw = administration_tax_bracket_create_empty();
+ pw = administration_tax_rate_create_empty();
strops_copy(pw.country_code, "NL", sizeof(pw.country_code));
pw.rate = 10.0f;
strops_copy(pw.category_code, "S", sizeof(pw.category_code));
- count = administration_tax_bracket_count();
- administration_tax_bracket_add(pw);
+ count = administration_tax_rate_count();
+ administration_tax_rate_add(pw);
- ASSERT_EQ(count+1, administration_tax_bracket_count());
+ ASSERT_EQ(count+1, administration_tax_rate_count());
}
administration_reader_open_existing(test_file_path);
{
- ASSERT_EQ(count+1, administration_tax_bracket_count());
- ASSERT_EQ(1, administration_tax_bracket_get_by_id(&pr, pw.id));
- ASSERT_MEM_EQ(&pw, &pr, sizeof(country_tax_bracket));
+ ASSERT_EQ(count+1, administration_tax_rate_count());
+ ASSERT_EQ(1, administration_tax_rate_get_by_id(&pr, pw.id));
+ ASSERT_MEM_EQ(&pw, &pr, sizeof(tax_rate));
}
PASS();
@@ -177,7 +177,7 @@ SUITE(administration_rw) {
SET_SETUP(setup_cb, NULL);
SET_TEARDOWN(teardown_cb, NULL);
- RUN_TEST(_administration_rw_taxbracket);
+ RUN_TEST(_administration_rw_taxrate);
RUN_TEST(_administration_rw_costcenter);
RUN_TEST(_administration_rw_project);
RUN_TEST(_administration_rw_contact);