diff options
| author | Aldrik Ramaekers <aldrik@mailbox.org> | 2025-12-27 16:01:51 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@mailbox.org> | 2025-12-27 16:01:51 +0100 |
| commit | 28c730a2e35ce81634dd4d47bf8e92e4552ec17c (patch) | |
| tree | c1aa994a9c241972f81e1ab8403a6b1dc37f14da /src | |
| parent | 178e8c135a60e9f206dcfbad8bab7bb868e6a294 (diff) | |
fix warnings
Diffstat (limited to 'src')
| -rw-r--r-- | src/administration.cpp | 4 | ||||
| -rw-r--r-- | src/administration_writer.cpp | 87 | ||||
| -rw-r--r-- | src/ai_providers/DeepSeek.cpp | 2 | ||||
| -rw-r--r-- | src/ai_providers/openAI.cpp | 6 | ||||
| -rw-r--r-- | src/countries.cpp | 12 | ||||
| -rw-r--r-- | src/countries/nl.cpp | 12 | ||||
| -rw-r--r-- | src/importer.cpp | 2 | ||||
| -rw-r--r-- | src/main_linux.cpp | 6 | ||||
| -rw-r--r-- | src/ui/ui_contacts.cpp | 6 | ||||
| -rw-r--r-- | src/ui/ui_invoices.cpp | 2 | ||||
| -rw-r--r-- | src/ui/ui_projects.cpp | 4 |
11 files changed, 79 insertions, 64 deletions
diff --git a/src/administration.cpp b/src/administration.cpp index d7e4eed..b4f626e 100644 --- a/src/administration.cpp +++ b/src/administration.cpp @@ -431,7 +431,7 @@ void administration::create_tax_statement(tax_statement* statement) logger::info("Created tax statement in %.3fms.", STOPWATCH_TIME); } -tax_line* administration::get_tax_line_from_report(tax_report* quarter, char* category) +tax_line* administration::get_tax_line_from_report(tax_report* quarter, const char* category) { for (u32 t = 0; t < quarter->line_count; t++) { @@ -1899,6 +1899,8 @@ a_err administration::billing_item_add_to_invoice(invoice* invoice, billing_item memops::copy(tb, &item, sizeof(billing_item)); strops::format(tb->id, sizeof(tb->id), "B/%d", create_id()); strops::copy(tb->currency, invoice->currency, MAX_LEN_CURRENCY); // Set billing item currency to invoice currency. + + logger::info("XD: %s\n", tb->tax_internal_code); administration_recalculate_billing_item_totals(tb); if (!list_append(&invoice->billing_items, tb)) { diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp index f12cf1f..45c8cdd 100644 --- a/src/administration_writer.cpp +++ b/src/administration_writer.cpp @@ -241,7 +241,7 @@ static char* copy_template(const char* template_str, int* buf_size) return file_content; } -static bool zip_entry_exists(char* entry) +static bool zip_entry_exists(const char* entry) { mtx_lock(&_save_file_mutex); @@ -255,7 +255,7 @@ static bool zip_entry_exists(char* entry) return result == 0; } -static bool delete_entry_by_name(char* entry) +static bool delete_entry_by_name(const char* entry) { STOPWATCH_START; @@ -265,8 +265,8 @@ static bool delete_entry_by_name(char* entry) struct zip_t *zip_write = zip_open(administration::get_file_path(), 0, 'a'); if (!zip_write) zip_write = zip_open(administration::get_file_path(), 0, 'w'); - char* indices[1] = {entry}; - if (zip_entries_delete(zip_write, indices, 1) < 0) result = 0; + const char* indices[1] = {entry}; + if (zip_entries_delete(zip_write, (char* const*)indices, 1) < 0) result = 0; zip_close(zip_write); if (result) logger::info("Deleted entry '%s' in %.3fms.", entry, STOPWATCH_TIME); @@ -277,7 +277,7 @@ static bool delete_entry_by_name(char* entry) return result; } -bool administration_writer::delete_entry(char* id) +bool administration_writer::delete_entry(const char* id) { char final_path[50]; strops::format(final_path, 50, "%s.xml", id); @@ -285,7 +285,7 @@ bool administration_writer::delete_entry(char* id) return delete_entry_by_name(final_path); } -static bool write_to_zip(char* entry_to_replace, char* orig_content, int final_length) +static bool write_to_zip(const char* entry_to_replace, char* orig_content, int final_length) { mtx_lock(&_save_file_mutex); @@ -318,53 +318,54 @@ static bool write_to_zip(char* entry_to_replace, char* orig_content, int final_l //// Invoices ///////////////////////////// -static char* get_eas_id_for_contact(contact contact) +static const char* get_eas_id_for_contact(contact *contact) { - if (contact.type == contact_type::CONTACT_CONSUMER) { + //return contact.businessid; + if (contact->type == contact_type::CONTACT_CONSUMER) { return "[CONSUMER]"; } // https://docs.peppol.eu/poacc/billing/3.0/codelist/eas/ - char* country_code = contact.address.country_code; + char* country_code = contact->address.country_code; // Countries using tax identification numbers. - if (strops::equals(country_code, "AT")) return contact.taxid; // Austria - if (strops::equals(country_code, "BE")) return contact.taxid; // Belgium - if (strops::equals(country_code, "BG")) return contact.taxid; // Bulgaria - if (strops::equals(country_code, "CY")) return contact.taxid; // Cyprus - if (strops::equals(country_code, "CZ")) return contact.taxid; // Czech Republic - if (strops::equals(country_code, "DE")) return contact.taxid; // Germany - if (strops::equals(country_code, "EE")) return contact.taxid; // Estonia - if (strops::equals(country_code, "FR")) return contact.taxid; // France - if (strops::equals(country_code, "GR")) return contact.taxid; // Greece - if (strops::equals(country_code, "HR")) return contact.taxid; // Croatia - if (strops::equals(country_code, "HU")) return contact.taxid; // Hungary - if (strops::equals(country_code, "IE")) return contact.taxid; // Ireland - if (strops::equals(country_code, "LU")) return contact.taxid; // Luxembourg - if (strops::equals(country_code, "LV")) return contact.taxid; // Latvia - if (strops::equals(country_code, "MT")) return contact.taxid; // Malta - if (strops::equals(country_code, "PL")) return contact.taxid; // Poland - if (strops::equals(country_code, "PT")) return contact.taxid; // Portugal - if (strops::equals(country_code, "RO")) return contact.taxid; // Romania - if (strops::equals(country_code, "SI")) return contact.taxid; // Slovenia - if (strops::equals(country_code, "SK")) return contact.taxid; // Slovakia - if (strops::equals(country_code, "ES")) return contact.taxid; // Spain + if (strops::equals(country_code, "AT")) return contact->taxid; // Austria + if (strops::equals(country_code, "BE")) return contact->taxid; // Belgium + if (strops::equals(country_code, "BG")) return contact->taxid; // Bulgaria + if (strops::equals(country_code, "CY")) return contact->taxid; // Cyprus + if (strops::equals(country_code, "CZ")) return contact->taxid; // Czech Republic + if (strops::equals(country_code, "DE")) return contact->taxid; // Germany + if (strops::equals(country_code, "EE")) return contact->taxid; // Estonia + if (strops::equals(country_code, "FR")) return contact->taxid; // France + if (strops::equals(country_code, "GR")) return contact->taxid; // Greece + if (strops::equals(country_code, "HR")) return contact->taxid; // Croatia + if (strops::equals(country_code, "HU")) return contact->taxid; // Hungary + if (strops::equals(country_code, "IE")) return contact->taxid; // Ireland + if (strops::equals(country_code, "LU")) return contact->taxid; // Luxembourg + if (strops::equals(country_code, "LV")) return contact->taxid; // Latvia + if (strops::equals(country_code, "MT")) return contact->taxid; // Malta + if (strops::equals(country_code, "PL")) return contact->taxid; // Poland + if (strops::equals(country_code, "PT")) return contact->taxid; // Portugal + if (strops::equals(country_code, "RO")) return contact->taxid; // Romania + if (strops::equals(country_code, "SI")) return contact->taxid; // Slovenia + if (strops::equals(country_code, "SK")) return contact->taxid; // Slovakia + if (strops::equals(country_code, "ES")) return contact->taxid; // Spain // Countries using business identification numbers. - if (strops::equals(country_code, "NL")) return contact.businessid; // Netherlands - if (strops::equals(country_code, "SE")) return contact.businessid; // Sweden - if (strops::equals(country_code, "LT")) return contact.businessid; // Lithuania - if (strops::equals(country_code, "IT")) return contact.businessid; // Italy - if (strops::equals(country_code, "FI")) return contact.businessid; // Finland - if (strops::equals(country_code, "DK")) return contact.businessid; // Denmark - - return contact.businessid; // Unknown country code + if (strops::equals(country_code, "NL")) return contact->businessid; // Netherlands + if (strops::equals(country_code, "SE")) return contact->businessid; // Sweden + if (strops::equals(country_code, "LT")) return contact->businessid; // Lithuania + if (strops::equals(country_code, "IT")) return contact->businessid; // Italy + if (strops::equals(country_code, "FI")) return contact->businessid; // Finland + if (strops::equals(country_code, "DK")) return contact->businessid; // Denmark + + return contact->businessid; // Unknown country code } -static char* get_eas_scheme_for_contact(contact contact) +static const char* get_eas_scheme_for_contact(contact contact) { if (contact.type == contact_type::CONTACT_CONSUMER) { - return "0203"; // Hack + return "0203"; // @Hack } address addr = contact.address; @@ -399,7 +400,7 @@ static char* get_eas_scheme_for_contact(contact contact) if (strops::equals(country_code, "SK")) return "9950"; // Slovakia if (strops::equals(country_code, "ES")) return "9920"; // Spain - return "0203"; // Hack + return "0203"; // @Hack } bool isEmptyTag(const char *start, const char *end) { @@ -518,7 +519,7 @@ bool administration_writer::save_invoice_blocking(invoice inv) // Supplier data strops::replace(file_content, buf_length, "{{SUPPLIER_ENDPOINT_SCHEME}}", get_eas_scheme_for_contact(inv.supplier)); - strops::replace(file_content, buf_length, "{{SUPPLIER_ENDPOINT_ID}}", get_eas_id_for_contact(inv.supplier)); + strops::replace(file_content, buf_length, "{{SUPPLIER_ENDPOINT_ID}}", get_eas_id_for_contact(&inv.supplier)); strops::replace(file_content, buf_length, "{{SUPPLIER_ID}}", inv.supplier.id); strops::replace(file_content, buf_length, "{{SUPPLIER_NAME}}", inv.supplier.name); strops::replace(file_content, buf_length, "{{SUPPLIER_STREET}}", inv.supplier.address.address1); @@ -535,7 +536,7 @@ bool administration_writer::save_invoice_blocking(invoice inv) // Customer data strops::replace(file_content, buf_length, "{{CUSTOMER_ENDPOINT_SCHEME}}", get_eas_scheme_for_contact(inv.customer)); - strops::replace(file_content, buf_length, "{{CUSTOMER_ENDPOINT_ID}}", get_eas_id_for_contact(inv.customer)); + strops::replace(file_content, buf_length, "{{CUSTOMER_ENDPOINT_ID}}", get_eas_id_for_contact(&inv.customer)); strops::replace(file_content, buf_length, "{{CUSTOMER_ID}}", inv.customer.id); strops::replace(file_content, buf_length, "{{CUSTOMER_NAME}}", inv.customer.name); strops::replace(file_content, buf_length, "{{CUSTOMER_STREET}}", inv.customer.address.address1); diff --git a/src/ai_providers/DeepSeek.cpp b/src/ai_providers/DeepSeek.cpp index ede31f8..c34e299 100644 --- a/src/ai_providers/DeepSeek.cpp +++ b/src/ai_providers/DeepSeek.cpp @@ -24,7 +24,7 @@ #define QUERY_BUFFER_SIZE 1000000 char* query_buffer = 0; -static bool _DeepSeek_query_with_file(char* query, size_t query_length, char* file_id, char** response) +static bool _DeepSeek_query_with_file(const char* query, size_t query_length, char* file_id, char** response) { (void)file_id; (void)query_length; diff --git a/src/ai_providers/openAI.cpp b/src/ai_providers/openAI.cpp index 3e5104d..d1495dc 100644 --- a/src/ai_providers/openAI.cpp +++ b/src/ai_providers/openAI.cpp @@ -24,7 +24,7 @@ #include "logger.hpp" #include "importer.hpp" -static bool _openAI_batch_query_with_file(char** queries, size_t query_count, char* file_id, invoice* buffer, importer::batch_query_response_handler response_handler) +static bool _openAI_batch_query_with_file(const char** queries, size_t query_count, char* file_id, invoice* buffer, importer::batch_query_response_handler response_handler) { const char *api_key = administration::get_ai_service().api_key_public; httplib::SSLClient cli("api.openai.com", 443); @@ -94,7 +94,7 @@ static bool _openAI_batch_query_with_file(char** queries, size_t query_count, ch return 1; } -static bool _openAI_query_with_file(char* query, size_t query_length, char* file_id, char** response) +static bool _openAI_query_with_file(const char* query, size_t query_length, char* file_id, char** response) { const char *api_key = administration::get_ai_service().api_key_public; @@ -102,7 +102,7 @@ static bool _openAI_query_with_file(char* query, size_t query_length, char* file //cli.enable_server_certificate_verification(false); char* query_escaped = strops::prep_str_for_json(query, query_length); - memops::unalloc(query); + //memops::unalloc(query); size_t body_size = query_length + 200; char* body = (char*)memops::alloc(body_size); diff --git a/src/countries.cpp b/src/countries.cpp index 34aacf1..5d1ea5a 100644 --- a/src/countries.cpp +++ b/src/countries.cpp @@ -226,12 +226,12 @@ s32 country::get_count() return country_map_count; } -char* country::get_code_by_index(s32 index) +const char* country::get_code_by_index(s32 index) { return country_map[index].country_code; } -static s32 get_index_by_country_code(char* country_code) +static s32 get_index_by_country_code(const char* country_code) { for (u32 i = 0; i < country_map_count; i++) { @@ -242,7 +242,7 @@ static s32 get_index_by_country_code(char* country_code) return -1; } -bool country::is_EU(char* country_code) +bool country::is_EU(const char* country_code) { s32 index = get_index_by_country_code(country_code); if (index == -1) return 0; @@ -250,7 +250,7 @@ bool country::is_EU(char* country_code) return country_map[index].is_EU; } -bool country::is_enabled(char* country_code) +bool country::is_enabled(const char* country_code) { s32 index = get_index_by_country_code(country_code); if (index == -1) return 0; @@ -266,7 +266,7 @@ time_t country::get_default_invoice_expire_duration(char* country_code) return country_map[index].get_default_invoice_expire_duration(); } -bool country::tax_is_implemented(char* country_code) +bool country::tax_is_implemented(const char* country_code) { s32 index = get_index_by_country_code(country_code); if (index == -1) return false; @@ -307,7 +307,7 @@ time_t country::get_invoice_date_to_use_for_tax_report(char* country_code, invoi return country_map[index].get_invoice_date_to_use_for_tax_report(inv); } -u32 country::get_available_tax_rates(char* country_code, tax_rate* buffer, u32 buffer_size) +u32 country::get_available_tax_rates(const char* country_code, tax_rate* buffer, u32 buffer_size) { s32 index = get_index_by_country_code(country_code); assert(index != -1); diff --git a/src/countries/nl.cpp b/src/countries/nl.cpp index 8a56e71..ac44ad9 100644 --- a/src/countries/nl.cpp +++ b/src/countries/nl.cpp @@ -145,7 +145,7 @@ time_t _nl_get_invoice_date_to_use_for_tax_report(invoice* inv) return inv->issued_at; } -static tax_rate _create_tax_rate(tax_rate_type type, char* internal_code, char* category_code, float rate, ...) +static tax_rate _create_tax_rate(tax_rate_type type, const char* internal_code, const char* category_code, float rate, ...) { tax_rate result; result.type = type; @@ -170,7 +170,7 @@ static tax_rate _create_tax_rate(tax_rate_type type, char* internal_code, char* return result; } -static tax_rate _create_tax_rate(tax_rate_type type, char* internal_code, float rate, ...) +static tax_rate _create_tax_rate(tax_rate_type type, const char* internal_code, float rate, ...) { tax_rate result; memops::zero(&result, sizeof(tax_rate)); @@ -201,7 +201,13 @@ u32 _nl_get_available_tax_rates(tax_rate* buffer, u32 buffer_size) assert(buffer); u32 cc = 0; - #define ADD(_line) if (cc < buffer_size) buffer[cc++] = _line; else assert(0); + #define ADD(_line) \ + if (cc < buffer_size) \ + { \ + tax_rate data = _line;\ + memops::copy(&buffer[cc++], (const void*)&data, sizeof(tax_rate)); \ + } \ + else assert(0); // Outgoing ADD(_create_tax_rate(tax_rate_type::TAX_RATE_OUTGOING_INVOICE, "NL/21", "S", 21.00, "NL/1a", 0)); diff --git a/src/importer.cpp b/src/importer.cpp index e3d8048..3c56062 100644 --- a/src/importer.cpp +++ b/src/importer.cpp @@ -219,7 +219,7 @@ static int _ai_document_to_invoice_t(void *arg) request->status = importer::status::IMPORT_WAITING_FOR_RESPONSE; - char* queries[] = { + const char* queries[] = { "What is the invoice number/ID? Return json containing sequential_number (string), query_id = 1 (string)", "When was this invoice issued? Return json containing issued_at (time_t value), query_id = 2 (string). If not found, issued_at = 0", "When does this invoice expire? Return json containing expires_at (time_t value), query_id = 3 (string). If not found, expires_at = 0", diff --git a/src/main_linux.cpp b/src/main_linux.cpp index f30f063..e1dd7f6 100644 --- a/src/main_linux.cpp +++ b/src/main_linux.cpp @@ -74,9 +74,9 @@ int main(int argc, char** argv) ImGui_ImplOpenGL2_Init(); style.FontSizeBase = 18.0f; - io.Fonts->AddFontFromFileTTF("build/Segoe UI.ttf"); - ui::fontBold = io.Fonts->AddFontFromFileTTF("build/Segoe UI Bold.ttf"); - ui::fontBig = io.Fonts->AddFontFromFileTTF("build/Segoe UI Bold.ttf", 30); + io.Fonts->AddFontFromFileTTF("build/Roboto-Regular.ttf"); + ui::fontBold = io.Fonts->AddFontFromFileTTF("build/Roboto-Bold.ttf"); + ui::fontBig = io.Fonts->AddFontFromFileTTF("build/Roboto-Bold.ttf", 30); ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); diff --git a/src/ui/ui_contacts.cpp b/src/ui/ui_contacts.cpp index 5d92f8a..a9559c5 100644 --- a/src/ui/ui_contacts.cpp +++ b/src/ui/ui_contacts.cpp @@ -31,7 +31,7 @@ static contact active_contact; void ui::setup_contacts() { current_view_state = ui::view_state::LIST_ALL; - active_contact = active_contact = administration::contact_create_empty(); + active_contact = administration::contact_create_empty(); memops::zero(&selected_for_removal, sizeof(contact)); } @@ -87,7 +87,7 @@ static void draw_contact_list() ImGui::TableSetupColumn(locale::get("contact.table.identifier"), ImGuiTableColumnFlags_WidthFixed, 80); ImGui::TableSetupColumn(locale::get("contact.table.name"), ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn(locale::get("contact.table.address"), ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 160); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 170); ImGui::TableHeadersRow(); contact contact_list[items_per_page]; @@ -214,5 +214,7 @@ void ui::draw_contacts() ImGui::ContactForm(&active_contact, true, false); break; + + default: break; } }
\ No newline at end of file diff --git a/src/ui/ui_invoices.cpp b/src/ui/ui_invoices.cpp index ff3c73b..c4d393c 100644 --- a/src/ui/ui_invoices.cpp +++ b/src/ui/ui_invoices.cpp @@ -545,5 +545,7 @@ void ui::draw_invoices() case ui::view_state::CREATE: draw_invoice_create(); break; case ui::view_state::EDIT_EXISTING: draw_invoice_update(); break; case ui::view_state::VIEW_EXISTING: draw_invoice_view(); break; + + default: break; } }
\ No newline at end of file diff --git a/src/ui/ui_projects.cpp b/src/ui/ui_projects.cpp index 94f2be6..42dba92 100644 --- a/src/ui/ui_projects.cpp +++ b/src/ui/ui_projects.cpp @@ -122,7 +122,7 @@ static void draw_project_list() ImGui::TableSetupColumn(locale::get("project.table.identifier"), ImGuiTableColumnFlags_WidthFixed, 80); ImGui::TableSetupColumn(locale::get("project.table.status"), ImGuiTableColumnFlags_WidthFixed, 140); ImGui::TableSetupColumn(locale::get("project.table.description"), ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 160); + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 175); ImGui::TableHeadersRow(); project project_list[items_per_page]; @@ -198,5 +198,7 @@ void ui::draw_projects() case ui::view_state::CREATE: draw_project_form(); break; case ui::view_state::EDIT_EXISTING: draw_project_form(); break; case ui::view_state::VIEW_EXISTING: draw_project_form(); break; + + default: break; } }
\ No newline at end of file |
