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/administration_writer.cpp | |
| parent | 178e8c135a60e9f206dcfbad8bab7bb868e6a294 (diff) | |
fix warnings
Diffstat (limited to 'src/administration_writer.cpp')
| -rw-r--r-- | src/administration_writer.cpp | 87 |
1 files changed, 44 insertions, 43 deletions
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); |
