summaryrefslogtreecommitdiff
path: root/src/administration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/administration.cpp')
-rw-r--r--src/administration.cpp152
1 files changed, 76 insertions, 76 deletions
diff --git a/src/administration.cpp b/src/administration.cpp
index 5476718..724f25f 100644
--- a/src/administration.cpp
+++ b/src/administration.cpp
@@ -233,27 +233,27 @@ char* administration::get_default_currency()
char* administration::get_currency_symbol_for_currency(char* code)
{
// Major European currencies
- if (strcmp(code, "EUR") == 0) return "€"; // Euro
- if (strcmp(code, "GBP") == 0) return "£"; // British Pound
- if (strcmp(code, "CHF") == 0) return "CHF"; // Swiss Franc (no special sign, usually "CHF")
- if (strcmp(code, "NOK") == 0) return "kr"; // Norwegian Krone
- if (strcmp(code, "SEK") == 0) return "kr"; // Swedish Krona
- if (strcmp(code, "DKK") == 0) return "kr"; // Danish Krone
- if (strcmp(code, "ISK") == 0) return "kr"; // Icelandic Króna
- if (strcmp(code, "CZK") == 0) return "Kč"; // Czech Koruna
- if (strcmp(code, "PLN") == 0) return "zł"; // Polish Złoty
- if (strcmp(code, "HUF") == 0) return "Ft"; // Hungarian Forint
- if (strcmp(code, "RON") == 0) return "lei"; // Romanian Leu
- if (strcmp(code, "BGN") == 0) return "лв"; // Bulgarian Lev
- if (strcmp(code, "HRK") == 0) return "kn"; // Croatian Kuna (before Euro, now EUR since 2023)
- if (strcmp(code, "RSD") == 0) return "дин"; // Serbian Dinar
- if (strcmp(code, "MKD") == 0) return "ден"; // Macedonian Denar
- if (strcmp(code, "ALL") == 0) return "L"; // Albanian Lek
- if (strcmp(code, "MDL") == 0) return "L"; // Moldovan Leu
- if (strcmp(code, "BYN") == 0) return "Br"; // Belarusian Ruble
- if (strcmp(code, "UAH") == 0) return "₴"; // Ukrainian Hryvnia
- if (strcmp(code, "RUB") == 0) return "₽"; // Russian Ruble
- if (strcmp(code, "TRY") == 0) return "₺"; // Turkish Lira
+ if (strops::equals(code, "EUR")) return "€"; // Euro
+ if (strops::equals(code, "GBP")) return "£"; // British Pound
+ if (strops::equals(code, "CHF")) return "CHF"; // Swiss Franc (no special sign, usually "CHF")
+ if (strops::equals(code, "NOK")) return "kr"; // Norwegian Krone
+ if (strops::equals(code, "SEK")) return "kr"; // Swedish Krona
+ if (strops::equals(code, "DKK")) return "kr"; // Danish Krone
+ if (strops::equals(code, "ISK")) return "kr"; // Icelandic Króna
+ if (strops::equals(code, "CZK")) return "Kč"; // Czech Koruna
+ if (strops::equals(code, "PLN")) return "zł"; // Polish Złoty
+ if (strops::equals(code, "HUF")) return "Ft"; // Hungarian Forint
+ if (strops::equals(code, "RON")) return "lei"; // Romanian Leu
+ if (strops::equals(code, "BGN")) return "лв"; // Bulgarian Lev
+ if (strops::equals(code, "HRK")) return "kn"; // Croatian Kuna (before Euro, now EUR since 2023)
+ if (strops::equals(code, "RSD")) return "дин"; // Serbian Dinar
+ if (strops::equals(code, "MKD")) return "ден"; // Macedonian Denar
+ if (strops::equals(code, "ALL")) return "L"; // Albanian Lek
+ if (strops::equals(code, "MDL")) return "L"; // Moldovan Leu
+ if (strops::equals(code, "BYN")) return "Br"; // Belarusian Ruble
+ if (strops::equals(code, "UAH")) return "₴"; // Ukrainian Hryvnia
+ if (strops::equals(code, "RUB")) return "₽"; // Russian Ruble
+ if (strops::equals(code, "TRY")) return "₺"; // Turkish Lira
// Unknown currency
return "?";
@@ -506,7 +506,7 @@ void administration::create_income_statement(income_statement* statement)
assert(yy == quarter->year && qq == quarter->quarter);
quarter->is_empty = 0;
- if (strcmp(inv->project_id, "") == 0) {
+ if (strops::equals(inv->project_id, "")) {
if (inv->is_outgoing) {
quarter->uncategorized_revenue += inv->total;
quarter->uncategorized_taxes += inv->tax;
@@ -523,7 +523,7 @@ void administration::create_income_statement(income_statement* statement)
int project_report_index = -1;
for (u32 x = 0; x < quarter->report_count; x++)
{
- if (strcmp(quarter->reports[x].project_id, inv->project_id) == 0) {
+ if (strops::equals(quarter->reports[x].project_id, inv->project_id)) {
project_report_index = x;
break;
}
@@ -542,11 +542,11 @@ void administration::create_income_statement(income_statement* statement)
report->expenses_total += inv->total;
quarter->profit -= inv->total;
- if (strcmp(inv->cost_center_id, "") != 0) {
+ if (strops::equals(inv->cost_center_id, "") != 0) {
int expense_report_index = -1;
for (u32 x = 0; x < report->expense_count; x++)
{
- if (strcmp(report->expenses[x].cost_center_id, inv->cost_center_id) == 0) {
+ if (strops::equals(report->expenses[x].cost_center_id, inv->cost_center_id)) {
expense_report_index = x;
break;
}
@@ -627,7 +627,7 @@ void administration::company_info_set(contact data)
// =======================
a_err administration::contact_import(contact data)
{
- if (strcmp(data.id, MY_COMPANY_ID) == 0)
+ if (strops::equals(data.id, MY_COMPANY_ID))
{
administration::company_info_import(data);
return A_ERR_SUCCESS;
@@ -674,7 +674,7 @@ a_err administration::contact_update(contact data)
while (list_iterator_hasnext(&g_administration.contacts)) {
contact* c = (contact *)list_iterator_next(&g_administration.contacts);
- if (strcmp(c->id, data.id) == 0) {
+ if (strops::equals(c->id, data.id)) {
memops::copy(c, &data, sizeof(data));
if (contact_changed_event_callback) contact_changed_event_callback(c);
@@ -695,7 +695,7 @@ a_err administration::contact_remove(contact data)
while (list_iterator_hasnext(&g_administration.contacts)) {
contact* c = (contact *)list_iterator_next(&g_administration.contacts);
- if (strcmp(c->id, data.id) == 0) {
+ if (strops::equals(c->id, data.id)) {
list_iterator_stop(&g_administration.contacts);
if (list_delete(&g_administration.contacts, c) != 0) return A_ERR_GENERIC;
@@ -769,7 +769,7 @@ a_err administration::contact_get_by_id(contact* buffer, char* id)
{
// Include company info in contact lookup because this might be
// used in forms.
- if (strcmp(id, g_administration.company_info.id) == 0)
+ if (strops::equals(id, g_administration.company_info.id))
{
*buffer = g_administration.company_info;
return A_ERR_SUCCESS;
@@ -780,7 +780,7 @@ a_err administration::contact_get_by_id(contact* buffer, char* id)
while (list_iterator_hasnext(&g_administration.contacts)) {
contact c = *(contact *)list_iterator_next(&g_administration.contacts);
- if (strcmp(c.id, id) == 0) {
+ if (strops::equals(c.id, id)) {
list_iterator_stop(&g_administration.contacts);
*buffer = c;
result = A_ERR_SUCCESS;
@@ -868,7 +868,7 @@ a_err administration::project_get_by_id(project* buffer, char* id)
list_iterator_start(&g_administration.projects);
while (list_iterator_hasnext(&g_administration.projects)) {
project c = *(project *)list_iterator_next(&g_administration.projects);
- if (strcmp(c.id, id) == 0)
+ if (strops::equals(c.id, id))
{
*buffer = c;
list_iterator_stop(&g_administration.projects);
@@ -985,7 +985,7 @@ a_err administration::project_update(project data)
while (list_iterator_hasnext(&g_administration.projects)) {
project* c = (project *)list_iterator_next(&g_administration.projects);
- if (strcmp(c->id, data.id) == 0) {
+ if (strops::equals(c->id, data.id)) {
memops::copy(c, &data, sizeof(data));
list_iterator_stop(&g_administration.projects);
@@ -1006,7 +1006,7 @@ a_err administration::project_remove(project data)
while (list_iterator_hasnext(&g_administration.projects)) {
project* c = (project *)list_iterator_next(&g_administration.projects);
- if (strcmp(c->id, data.id) == 0) {
+ if (strops::equals(c->id, data.id)) {
list_iterator_stop(&g_administration.projects);
if (list_delete(&g_administration.projects, c) != 0) return A_ERR_GENERIC;
@@ -1049,7 +1049,7 @@ a_err administration::tax_rate_remove(tax_rate data)
while (list_iterator_hasnext(&g_administration.tax_rates)) {
tax_rate* c = (tax_rate *)list_iterator_next(&g_administration.tax_rates);
- if (strcmp(c->internal_code, data.internal_code) == 0)
+ if (strops::equals(c->internal_code, data.internal_code))
{
list_iterator_stop(&g_administration.tax_rates);
if (list_delete(&g_administration.tax_rates, c) != 0) return A_ERR_GENERIC;
@@ -1071,7 +1071,7 @@ a_err administration::tax_rate_exists(tax_rate data)
while (list_iterator_hasnext(&g_administration.tax_rates)) {
tax_rate c = *(tax_rate *)list_iterator_next(&g_administration.tax_rates);
- if (strcmp(c.internal_code, data.internal_code) == 0)
+ if (strops::equals(c.internal_code, data.internal_code))
{
list_iterator_stop(&g_administration.tax_rates);
return A_ERR_SUCCESS;
@@ -1089,7 +1089,7 @@ a_err administration::tax_rate_get_by_internal_code(tax_rate* buffer, char* id)
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.internal_code, id) == 0)
+ if (strops::equals(c.internal_code, id))
{
*buffer = c;
list_iterator_stop(&g_administration.tax_rates);
@@ -1175,7 +1175,7 @@ a_err administration::cost_center_get_by_id(cost_center* buffer, char* id)
list_iterator_start(&g_administration.cost_centers);
while (list_iterator_hasnext(&g_administration.cost_centers)) {
cost_center c = *(cost_center *)list_iterator_next(&g_administration.cost_centers);
- if (strcmp(c.id, id) == 0)
+ if (strops::equals(c.id, id))
{
*buffer = c;
list_iterator_stop(&g_administration.cost_centers);
@@ -1210,7 +1210,7 @@ static bool get_cost_center_by_code(char* code, cost_center* buffer)
while (list_iterator_hasnext(&g_administration.cost_centers)) {
cost_center c = *(cost_center *)list_iterator_next(&g_administration.cost_centers);
*buffer = c;
- if (strcmp(code, c.code) == 0) {
+ if (strops::equals(code, c.code)) {
result = true;
break;
}
@@ -1274,7 +1274,7 @@ a_err administration::cost_center_update(cost_center data)
while (list_iterator_hasnext(&g_administration.cost_centers)) {
cost_center* c = (cost_center *)list_iterator_next(&g_administration.cost_centers);
- if (strcmp(c->id, data.id) == 0) {
+ if (strops::equals(c->id, data.id)) {
memops::copy(c, &data, sizeof(data));
list_iterator_stop(&g_administration.cost_centers);
@@ -1297,35 +1297,35 @@ static char* get_default_currency_for_country(char* country_code)
return "EUR"; // default
// Non-euro EU currencies
- if (strcmp(country_code, "BG") == 0) return "BGN"; // Bulgaria
- else if (strcmp(country_code, "CZ") == 0) return "CZK"; // Czechia
- else if (strcmp(country_code, "DK") == 0) return "DKK"; // Denmark
- else if (strcmp(country_code, "HU") == 0) return "HUF"; // Hungary
- else if (strcmp(country_code, "PL") == 0) return "PLN"; // Poland
- else if (strcmp(country_code, "RO") == 0) return "RON"; // Romania
- else if (strcmp(country_code, "SE") == 0) return "SEK"; // Sweden
+ if (strops::equals(country_code, "BG")) return "BGN"; // Bulgaria
+ else if (strops::equals(country_code, "CZ")) return "CZK"; // Czechia
+ else if (strops::equals(country_code, "DK")) return "DKK"; // Denmark
+ else if (strops::equals(country_code, "HU")) return "HUF"; // Hungary
+ else if (strops::equals(country_code, "PL")) return "PLN"; // Poland
+ else if (strops::equals(country_code, "RO")) return "RON"; // Romania
+ else if (strops::equals(country_code, "SE")) return "SEK"; // Sweden
// Eurozone members
- else if (strcmp(country_code, "AT") == 0) return "EUR"; // Austria
- else if (strcmp(country_code, "BE") == 0) return "EUR"; // Belgium
- else if (strcmp(country_code, "CY") == 0) return "EUR"; // Cyprus
- else if (strcmp(country_code, "DE") == 0) return "EUR"; // Germany
- else if (strcmp(country_code, "EE") == 0) return "EUR"; // Estonia
- else if (strcmp(country_code, "ES") == 0) return "EUR"; // Spain
- else if (strcmp(country_code, "FI") == 0) return "EUR"; // Finland
- else if (strcmp(country_code, "FR") == 0) return "EUR"; // France
- else if (strcmp(country_code, "GR") == 0) return "EUR"; // Greece
- else if (strcmp(country_code, "HR") == 0) return "EUR"; // Croatia
- else if (strcmp(country_code, "IE") == 0) return "EUR"; // Ireland
- else if (strcmp(country_code, "IT") == 0) return "EUR"; // Italy
- else if (strcmp(country_code, "LT") == 0) return "EUR"; // Lithuania
- else if (strcmp(country_code, "LU") == 0) return "EUR"; // Luxembourg
- else if (strcmp(country_code, "LV") == 0) return "EUR"; // Latvia
- else if (strcmp(country_code, "MT") == 0) return "EUR"; // Malta
- else if (strcmp(country_code, "NL") == 0) return "EUR"; // Netherlands
- else if (strcmp(country_code, "PT") == 0) return "EUR"; // Portugal
- else if (strcmp(country_code, "SI") == 0) return "EUR"; // Slovenia
- else if (strcmp(country_code, "SK") == 0) return "EUR"; // Slovakia
+ else if (strops::equals(country_code, "AT")) return "EUR"; // Austria
+ else if (strops::equals(country_code, "BE")) return "EUR"; // Belgium
+ else if (strops::equals(country_code, "CY")) return "EUR"; // Cyprus
+ else if (strops::equals(country_code, "DE")) return "EUR"; // Germany
+ else if (strops::equals(country_code, "EE")) return "EUR"; // Estonia
+ else if (strops::equals(country_code, "ES")) return "EUR"; // Spain
+ else if (strops::equals(country_code, "FI")) return "EUR"; // Finland
+ else if (strops::equals(country_code, "FR")) return "EUR"; // France
+ else if (strops::equals(country_code, "GR")) return "EUR"; // Greece
+ else if (strops::equals(country_code, "HR")) return "EUR"; // Croatia
+ else if (strops::equals(country_code, "IE")) return "EUR"; // Ireland
+ else if (strops::equals(country_code, "IT")) return "EUR"; // Italy
+ else if (strops::equals(country_code, "LT")) return "EUR"; // Lithuania
+ else if (strops::equals(country_code, "LU")) return "EUR"; // Luxembourg
+ else if (strops::equals(country_code, "LV")) return "EUR"; // Latvia
+ else if (strops::equals(country_code, "MT")) return "EUR"; // Malta
+ else if (strops::equals(country_code, "NL")) return "EUR"; // Netherlands
+ else if (strops::equals(country_code, "PT")) return "EUR"; // Portugal
+ else if (strops::equals(country_code, "SI")) return "EUR"; // Slovenia
+ else if (strops::equals(country_code, "SK")) return "EUR"; // Slovakia
// Default fallback
return "EUR";
@@ -1373,7 +1373,7 @@ static void administration_recalculate_invoice_totals(invoice* invoice)
}
list_iterator_stop(&invoice->billing_items);
- if (strcmp(invoice->currency, administration::get_default_currency()) == 0) {
+ if (strops::equals(invoice->currency, administration::get_default_currency())) {
invoice->tax = invoice->orig_tax;
invoice->total = invoice->orig_total;
invoice->net = invoice->orig_net;
@@ -1418,7 +1418,7 @@ a_err administration::invoice_remove(invoice* inv)
while (list_iterator_hasnext(&g_administration.invoices)) {
invoice* c = (invoice *)list_iterator_next(&g_administration.invoices);
- if (strcmp(c->id, inv->id) == 0)
+ if (strops::equals(c->id, inv->id))
{
list_iterator_stop(&g_administration.invoices);
administration_destroy_list(&c->billing_items);
@@ -1460,7 +1460,7 @@ a_err administration::invoice_update(invoice* inv)
while (list_iterator_hasnext(&g_administration.invoices)) {
invoice* c = (invoice *)list_iterator_next(&g_administration.invoices);
- if (strcmp(c->id, inv->id) == 0)
+ if (strops::equals(c->id, inv->id))
{
memops::copy(c, inv, sizeof(invoice));
list_iterator_stop(&g_administration.invoices);
@@ -1482,7 +1482,7 @@ a_err administration::invoice_import(invoice* inv)
inv->issued_at -= (inv->issued_at % 86400);
inv->delivered_at -= (inv->delivered_at % 86400);
inv->expires_at -= (inv->expires_at % 86400);
- inv->is_outgoing = strcmp(inv->supplier.id, MY_COMPANY_ID) == 0;
+ inv->is_outgoing = strops::equals(inv->supplier.id, MY_COMPANY_ID);
invoice copy = administration::invoice_create_copy(inv); // Create copy to make copy of billing item list.
invoice* new_inv = (invoice*)memops::alloc(sizeof(invoice));
@@ -1507,7 +1507,7 @@ a_err administration::invoice_add(invoice* inv)
inv->issued_at -= (inv->issued_at % 86400);
inv->delivered_at -= (inv->delivered_at % 86400);
inv->expires_at -= (inv->expires_at % 86400);
- inv->is_outgoing = strcmp(inv->supplier.id, MY_COMPANY_ID) == 0;
+ inv->is_outgoing = strops::equals(inv->supplier.id, MY_COMPANY_ID);
inv->payment_means.payment_method = PAYMENT_METHOD_STANDING_AGREEMENT;
strops::copy(inv->payment_means.payee_bank_account, inv->supplier.bank_account, sizeof(inv->payment_means.payee_bank_account));
@@ -1590,7 +1590,7 @@ a_err administration::invoice_get_by_id(invoice* buffer, char* id)
while (list_iterator_hasnext(&g_administration.invoices)) {
invoice c = *(invoice *)list_iterator_next(&g_administration.invoices);
- if (strcmp(c.id, id) == 0) {
+ if (strops::equals(c.id, id)) {
list_iterator_stop(&g_administration.invoices);
*buffer = c;
result = A_ERR_SUCCESS;
@@ -1630,7 +1630,7 @@ bool administration::invoice_get_subtotal_for_tax_rate(invoice* invoice, tax_rat
while (list_iterator_hasnext(&invoice->billing_items)) {
billing_item* c = (billing_item *)list_iterator_next(&invoice->billing_items);
- if (strcmp(c->tax_internal_code, rate.internal_code) == 0)
+ if (strops::equals(c->tax_internal_code, rate.internal_code))
{
result = true;
buffer->tax += c->tax;
@@ -1658,7 +1658,7 @@ u32 administration::invoice_get_tax_rates(invoice* invoice, tax_rate* buffer)
bool exists = false;
for (u32 i = 0; i < write_cursor; i++) {
- if (strcmp(buffer[i].internal_code, c.tax_internal_code) == 0) {
+ if (strops::equals(buffer[i].internal_code, c.tax_internal_code)) {
exists = true;
break;
}
@@ -1787,7 +1787,7 @@ a_err administration::billing_item_remove_from_invoice(invoice* invoice, billing
while (list_iterator_hasnext(&invoice->billing_items)) {
billing_item* c = (billing_item *)list_iterator_next(&invoice->billing_items);
- if (strcmp(c->id, item.id) == 0) {
+ if (strops::equals(c->id, item.id)) {
list_iterator_stop(&invoice->billing_items);
if (list_delete(&invoice->billing_items, c) != 0) return A_ERR_GENERIC;
memops::unalloc(c);
@@ -1805,7 +1805,7 @@ a_err administration::billing_item_update_in_invoice(invoice* invoice, billing_i
while (list_iterator_hasnext(&invoice->billing_items)) {
billing_item* c = (billing_item *)list_iterator_next(&invoice->billing_items);
- if (strcmp(c->id, item.id) == 0) {
+ if (strops::equals(c->id, item.id)) {
memops::copy(c, &item, sizeof(billing_item));
list_iterator_stop(&invoice->billing_items);