diff options
Diffstat (limited to 'src/administration_writer.cpp')
| -rw-r--r-- | src/administration_writer.cpp | 260 |
1 files changed, 130 insertions, 130 deletions
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp index 6f58a21..4f5a7ca 100644 --- a/src/administration_writer.cpp +++ b/src/administration_writer.cpp @@ -21,7 +21,7 @@ #include <stdlib.h> #include <threads.h> -#include "log.hpp" +#include "logger.hpp" #include "ui.hpp" #include "locales.hpp" #include "strops.hpp" @@ -122,8 +122,8 @@ static bool _administration_writer_delete_entry_by_name(char* entry) if (zip_entries_delete(zip_write, indices, 1) < 0) result = 0; zip_close(zip_write); - if (result) log_info("Deleted entry '%s' in %.3fms.", entry, STOPWATCH_TIME); - else log_error("Failed to delete entry '%s'.", entry); + if (result) logger::info("Deleted entry '%s' in %.3fms.", entry, STOPWATCH_TIME); + else logger::error("Failed to delete entry '%s'.", entry); return result; } @@ -303,7 +303,7 @@ static void _add_document_to_zip(invoice* inv) FILE* orig_file = fopen(doc->original_path, "rb"); if (orig_file == NULL) { - log_error("ERROR: original document file path does not exist."); + logger::error("ERROR: original document file path does not exist."); return; } @@ -318,11 +318,11 @@ static void _add_document_to_zip(invoice* inv) fclose(orig_file); if (administration_writer_write_to_zip(copy_path, file_copy, sz)) { - strops_copy(doc->copy_path, copy_path, MAX_LEN_PATH); - log_info("Made copy of '%s' to '%s'.", doc->original_path, doc->copy_path); + strops::copy(doc->copy_path, copy_path, MAX_LEN_PATH); + logger::info("Made copy of '%s' to '%s'.", doc->original_path, doc->copy_path); } else { - log_error("ERROR: failed to make copy of original document '%s'.", doc->original_path); + logger::error("ERROR: failed to make copy of original document '%s'.", doc->original_path); } free(file_copy); @@ -344,70 +344,70 @@ bool administration_writer_save_invoice_blocking(invoice inv) _add_document_to_zip(&inv); - strops_replace(file_content, buf_length, "{{INVOICE_ID}}", inv.id); - strops_replace(file_content, buf_length, "{{INVOICE_SEQUENCE_ID}}", inv.sequential_number); - strops_replace(file_content, buf_length, "{{CURRENCY}}", inv.currency); - strops_replace(file_content, buf_length, "{{PROJECT_ID}}", inv.project_id); - strops_replace(file_content, buf_length, "{{COST_CENTER_ID}}", inv.cost_center_id); - strops_replace(file_content, buf_length, "{{INVOICE_DOCUMENT_COPY}}", inv.document.copy_path); - strops_replace(file_content, buf_length, "{{INVOICE_DOCUMENT_ORIG}}", inv.document.original_path); - strops_replace_int32(file_content, buf_length, "{{INVOICE_STATUS}}", (s32)inv.status); + strops::replace(file_content, buf_length, "{{INVOICE_ID}}", inv.id); + strops::replace(file_content, buf_length, "{{INVOICE_SEQUENCE_ID}}", inv.sequential_number); + strops::replace(file_content, buf_length, "{{CURRENCY}}", inv.currency); + strops::replace(file_content, buf_length, "{{PROJECT_ID}}", inv.project_id); + strops::replace(file_content, buf_length, "{{COST_CENTER_ID}}", inv.cost_center_id); + strops::replace(file_content, buf_length, "{{INVOICE_DOCUMENT_COPY}}", inv.document.copy_path); + strops::replace(file_content, buf_length, "{{INVOICE_DOCUMENT_ORIG}}", inv.document.original_path); + strops::replace_int32(file_content, buf_length, "{{INVOICE_STATUS}}", (s32)inv.status); // Supplier data - strops_replace(file_content, buf_length, "{{SUPPLIER_ENDPOINT_SCHEME}}", administration_writer_get_eas_scheme_for_contact(inv.supplier)); - strops_replace(file_content, buf_length, "{{SUPPLIER_ENDPOINT_ID}}", administration_writer_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); - strops_replace(file_content, buf_length, "{{SUPPLIER_STREET2}}", inv.supplier.address.address2); - strops_replace(file_content, buf_length, "{{SUPPLIER_CITY}}", inv.supplier.address.city); - strops_replace(file_content, buf_length, "{{SUPPLIER_POSTAL}}", inv.supplier.address.postal); - strops_replace(file_content, buf_length, "{{SUPPLIER_REGION}}", inv.supplier.address.region); - strops_replace(file_content, buf_length, "{{SUPPLIER_COUNTRY}}", inv.supplier.address.country_code); - strops_replace(file_content, buf_length, "{{SUPPLIER_VAT_ID}}", inv.supplier.taxid); - strops_replace(file_content, buf_length, "{{SUPPLIER_LEGAL_NAME}}", inv.supplier.name); - strops_replace(file_content, buf_length, "{{SUPPLIER_BUSINESS_ID}}", inv.supplier.businessid); - strops_replace(file_content, buf_length, "{{SUPPLIER_PHONE_NUMBER}}", inv.supplier.phone_number); - strops_replace(file_content, buf_length, "{{SUPPLIER_EMAIL}}", inv.supplier.email); + strops::replace(file_content, buf_length, "{{SUPPLIER_ENDPOINT_SCHEME}}", administration_writer_get_eas_scheme_for_contact(inv.supplier)); + strops::replace(file_content, buf_length, "{{SUPPLIER_ENDPOINT_ID}}", administration_writer_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); + strops::replace(file_content, buf_length, "{{SUPPLIER_STREET2}}", inv.supplier.address.address2); + strops::replace(file_content, buf_length, "{{SUPPLIER_CITY}}", inv.supplier.address.city); + strops::replace(file_content, buf_length, "{{SUPPLIER_POSTAL}}", inv.supplier.address.postal); + strops::replace(file_content, buf_length, "{{SUPPLIER_REGION}}", inv.supplier.address.region); + strops::replace(file_content, buf_length, "{{SUPPLIER_COUNTRY}}", inv.supplier.address.country_code); + strops::replace(file_content, buf_length, "{{SUPPLIER_VAT_ID}}", inv.supplier.taxid); + strops::replace(file_content, buf_length, "{{SUPPLIER_LEGAL_NAME}}", inv.supplier.name); + strops::replace(file_content, buf_length, "{{SUPPLIER_BUSINESS_ID}}", inv.supplier.businessid); + strops::replace(file_content, buf_length, "{{SUPPLIER_PHONE_NUMBER}}", inv.supplier.phone_number); + strops::replace(file_content, buf_length, "{{SUPPLIER_EMAIL}}", inv.supplier.email); // Customer data - strops_replace(file_content, buf_length, "{{CUSTOMER_ENDPOINT_SCHEME}}", administration_writer_get_eas_scheme_for_contact(inv.customer)); - strops_replace(file_content, buf_length, "{{CUSTOMER_ENDPOINT_ID}}", administration_writer_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); - strops_replace(file_content, buf_length, "{{CUSTOMER_STREET2}}", inv.customer.address.address2); - strops_replace(file_content, buf_length, "{{CUSTOMER_CITY}}", inv.customer.address.city); - strops_replace(file_content, buf_length, "{{CUSTOMER_POSTAL}}", inv.customer.address.postal); - strops_replace(file_content, buf_length, "{{CUSTOMER_REGION}}", inv.customer.address.region); - strops_replace(file_content, buf_length, "{{CUSTOMER_COUNTRY}}", inv.customer.address.country_code); - strops_replace(file_content, buf_length, "{{CUSTOMER_VAT_ID}}", inv.customer.taxid); - strops_replace(file_content, buf_length, "{{CUSTOMER_LEGAL_NAME}}", inv.customer.name); - strops_replace(file_content, buf_length, "{{CUSTOMER_BUSINESS_ID}}", inv.customer.businessid); - strops_replace(file_content, buf_length, "{{CUSTOMER_PHONE_NUMBER}}", inv.customer.phone_number); - strops_replace(file_content, buf_length, "{{CUSTOMER_EMAIL}}", inv.customer.email); + strops::replace(file_content, buf_length, "{{CUSTOMER_ENDPOINT_SCHEME}}", administration_writer_get_eas_scheme_for_contact(inv.customer)); + strops::replace(file_content, buf_length, "{{CUSTOMER_ENDPOINT_ID}}", administration_writer_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); + strops::replace(file_content, buf_length, "{{CUSTOMER_STREET2}}", inv.customer.address.address2); + strops::replace(file_content, buf_length, "{{CUSTOMER_CITY}}", inv.customer.address.city); + strops::replace(file_content, buf_length, "{{CUSTOMER_POSTAL}}", inv.customer.address.postal); + strops::replace(file_content, buf_length, "{{CUSTOMER_REGION}}", inv.customer.address.region); + strops::replace(file_content, buf_length, "{{CUSTOMER_COUNTRY}}", inv.customer.address.country_code); + strops::replace(file_content, buf_length, "{{CUSTOMER_VAT_ID}}", inv.customer.taxid); + strops::replace(file_content, buf_length, "{{CUSTOMER_LEGAL_NAME}}", inv.customer.name); + strops::replace(file_content, buf_length, "{{CUSTOMER_BUSINESS_ID}}", inv.customer.businessid); + strops::replace(file_content, buf_length, "{{CUSTOMER_PHONE_NUMBER}}", inv.customer.phone_number); + strops::replace(file_content, buf_length, "{{CUSTOMER_EMAIL}}", inv.customer.email); // Delivery data tm_info = localtime(&inv.delivered_at); strftime(date_buffer, sizeof(date_buffer), "%Y-%m-%d", tm_info); - strops_replace(file_content, buf_length, "{{DELIVERY_DATE}}", date_buffer); - strops_replace(file_content, buf_length, "{{DELIVERY_NAME}}", inv.addressee.name); - strops_replace(file_content, buf_length, "{{DELIVERY_STREET}}", inv.addressee.address.address1); - strops_replace(file_content, buf_length, "{{DELIVERY_STREET2}}", inv.addressee.address.address2); - strops_replace(file_content, buf_length, "{{DELIVERY_CITY}}", inv.addressee.address.city); - strops_replace(file_content, buf_length, "{{DELIVERY_POSTAL}}", inv.addressee.address.postal); - strops_replace(file_content, buf_length, "{{DELIVERY_REGION}}", inv.addressee.address.region); - strops_replace(file_content, buf_length, "{{DELIVERY_COUNTRY}}", inv.addressee.address.country_code); + strops::replace(file_content, buf_length, "{{DELIVERY_DATE}}", date_buffer); + strops::replace(file_content, buf_length, "{{DELIVERY_NAME}}", inv.addressee.name); + strops::replace(file_content, buf_length, "{{DELIVERY_STREET}}", inv.addressee.address.address1); + strops::replace(file_content, buf_length, "{{DELIVERY_STREET2}}", inv.addressee.address.address2); + strops::replace(file_content, buf_length, "{{DELIVERY_CITY}}", inv.addressee.address.city); + strops::replace(file_content, buf_length, "{{DELIVERY_POSTAL}}", inv.addressee.address.postal); + strops::replace(file_content, buf_length, "{{DELIVERY_REGION}}", inv.addressee.address.region); + strops::replace(file_content, buf_length, "{{DELIVERY_COUNTRY}}", inv.addressee.address.country_code); // Payment means - strops_replace_int32(file_content, buf_length, "{{PAYMENT_TYPE}}", inv.payment_means.payment_method); - strops_replace(file_content, buf_length, "{{RECIPIENT_IBAN}}", inv.payment_means.payee_bank_account); - strops_replace(file_content, buf_length, "{{RECIPIENT_NAME}}", inv.payment_means.payee_account_name); - strops_replace(file_content, buf_length, "{{RECIPIENT_BIC}}", inv.payment_means.service_provider_id); - strops_replace(file_content, buf_length, "{{SENDER_IBAN}}", inv.payment_means.payer_bank_account); + strops::replace_int32(file_content, buf_length, "{{PAYMENT_TYPE}}", inv.payment_means.payment_method); + strops::replace(file_content, buf_length, "{{RECIPIENT_IBAN}}", inv.payment_means.payee_bank_account); + strops::replace(file_content, buf_length, "{{RECIPIENT_NAME}}", inv.payment_means.payee_account_name); + strops::replace(file_content, buf_length, "{{RECIPIENT_BIC}}", inv.payment_means.service_provider_id); + strops::replace(file_content, buf_length, "{{SENDER_IBAN}}", inv.payment_means.payer_bank_account); // Tax breakdown - strops_replace_float(file_content, buf_length, "{{TOTAL_TAX_AMOUNT}}", inv.tax, 2); + strops::replace_float(file_content, buf_length, "{{TOTAL_TAX_AMOUNT}}", inv.tax, 2); { // Create tax subtotal list. 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); @@ -425,11 +425,11 @@ bool administration_writer_save_invoice_blocking(invoice inv) tax_subtotal 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_rate_buffer[i].category_code); - strops_replace_float(tax_entry_file_content, tax_entry_buf_length, "{{TAX_PERCENT}}", tax_rate_buffer[i].rate, 2); + 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_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); @@ -438,17 +438,17 @@ bool administration_writer_save_invoice_blocking(invoice inv) } tax_subtotal_list_buffer[tax_subtotal_list_buffer_cursor] = 0; - strops_replace(file_content, buf_length, "{{TAX_SUBTOTAL_LIST}}", tax_subtotal_list_buffer); + strops::replace(file_content, buf_length, "{{TAX_SUBTOTAL_LIST}}", tax_subtotal_list_buffer); free(tax_subtotal_list_buffer); free(tax_rate_buffer); } // Totals - strops_replace_float(file_content, buf_length, "{{LINE_EXTENSION_AMOUNT}}", inv.net - inv.allowance, 2); - strops_replace_float(file_content, buf_length, "{{TAX_EXCLUSIVE_AMOUNT}}", inv.net, 2); - strops_replace_float(file_content, buf_length, "{{TAX_INCLUSIVE_AMOUNT}}", inv.total, 2); - strops_replace_float(file_content, buf_length, "{{PAYABLE_AMOUNT}}", inv.total, 2); + strops::replace_float(file_content, buf_length, "{{LINE_EXTENSION_AMOUNT}}", inv.net - inv.allowance, 2); + strops::replace_float(file_content, buf_length, "{{TAX_EXCLUSIVE_AMOUNT}}", inv.net, 2); + strops::replace_float(file_content, buf_length, "{{TAX_INCLUSIVE_AMOUNT}}", inv.total, 2); + strops::replace_float(file_content, buf_length, "{{PAYABLE_AMOUNT}}", inv.total, 2); // Invoice lines { @@ -469,27 +469,27 @@ bool administration_writer_save_invoice_blocking(invoice inv) 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}}", bi.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, "{{LINE_TAX_ID}}", bi.tax_rate_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}}", 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, "{{CURRENCY}}", bi.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, "{{LINE_TAX_ID}}", bi.tax_rate_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}}", 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"); if (bi.discount_is_percentage) { - strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_TOTAL_PERCENTAGE}}", bi.discount, 2); - strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_BASE_AMOUNT}}", bi.net + bi.allowance, 2); // Total net before discount. + strops::replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_TOTAL_PERCENTAGE}}", bi.discount, 2); + strops::replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_BASE_AMOUNT}}", bi.net + bi.allowance, 2); // Total net before discount. } else { - strops_replace(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_TOTAL_PERCENTAGE}}", ""); - strops_replace(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_BASE_AMOUNT}}", ""); + strops::replace(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_TOTAL_PERCENTAGE}}", ""); + strops::replace(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_BASE_AMOUNT}}", ""); } - strops_replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_TOTAL}}", bi.allowance, 2); + strops::replace_float(billing_item_file_content, billing_item_buf_length, "{{DISCOUNT_TOTAL}}", bi.allowance, 2); u32 content_len = (u32)strlen(billing_item_file_content); memcpy(billing_item_list_buffer+billing_item_list_buffer_cursor, billing_item_file_content, content_len); @@ -498,7 +498,7 @@ bool administration_writer_save_invoice_blocking(invoice inv) } billing_item_list_buffer[billing_item_list_buffer_cursor] = 0; - strops_replace(file_content, buf_length, "{{INVOICE_LINE_LIST}}", billing_item_list_buffer); + strops::replace(file_content, buf_length, "{{INVOICE_LINE_LIST}}", billing_item_list_buffer); free(billing_item_list_buffer); free(billing_item_buffer); @@ -507,11 +507,11 @@ bool administration_writer_save_invoice_blocking(invoice inv) // Dates tm_info = localtime(&inv.issued_at); strftime(date_buffer, sizeof(date_buffer), "%Y-%m-%d", tm_info); - strops_replace(file_content, buf_length, "{{ISSUE_DATE}}", date_buffer); + strops::replace(file_content, buf_length, "{{ISSUE_DATE}}", date_buffer); tm_info = localtime(&inv.expires_at); strftime(date_buffer, sizeof(date_buffer), "%Y-%m-%d", tm_info); - strops_replace(file_content, buf_length, "{{DUE_DATE}}", date_buffer); + strops::replace(file_content, buf_length, "{{DUE_DATE}}", date_buffer); _remove_empty_xml_tags(file_content, 5); @@ -525,8 +525,8 @@ bool administration_writer_save_invoice_blocking(invoice inv) free(file_content); - if (result) log_info("Saved invoice '%s' in %.3fms.", inv.sequential_number, STOPWATCH_TIME); - else log_error("Failed to save invoice '%s'.", inv.sequential_number); + if (result) logger::info("Saved invoice '%s' in %.3fms.", inv.sequential_number, STOPWATCH_TIME); + else logger::error("Failed to save invoice '%s'.", inv.sequential_number); return result; } @@ -562,17 +562,17 @@ bool administration_writer_save_project_blocking(project project) struct tm *tm_info = 0; char date_buffer[11]; // "YYYY-MM-DD" + null terminator - strops_replace(file_content, buf_length, "{{PROJECT_ID}}", project.id); - strops_replace(file_content, buf_length, "{{PROJECT_DESCRIPTION}}", project.description); - strops_replace_int32(file_content, buf_length, "{{PROJECT_STATE}}", project.state); + strops::replace(file_content, buf_length, "{{PROJECT_ID}}", project.id); + strops::replace(file_content, buf_length, "{{PROJECT_DESCRIPTION}}", project.description); + strops::replace_int32(file_content, buf_length, "{{PROJECT_STATE}}", project.state); tm_info = gmtime(&project.start_date); strftime(date_buffer, sizeof(date_buffer), "%Y-%m-%d", tm_info); - strops_replace(file_content, buf_length, "{{PROJECT_STARTDATE}}", date_buffer); + strops::replace(file_content, buf_length, "{{PROJECT_STARTDATE}}", date_buffer); tm_info = gmtime(&project.end_date); strftime(date_buffer, sizeof(date_buffer), "%Y-%m-%d", tm_info); - strops_replace(file_content, buf_length, "{{PROJECT_ENDDATE}}", date_buffer); + strops::replace(file_content, buf_length, "{{PROJECT_ENDDATE}}", date_buffer); //// Write to Disk. char final_path[50]; @@ -584,8 +584,8 @@ bool administration_writer_save_project_blocking(project project) free(file_content); - if (result) log_info("Saved project '%s' in %.3fms.", project.description, STOPWATCH_TIME); - else log_error("Failed to save project '%s'.", project.description); + if (result) logger::info("Saved project '%s' in %.3fms.", project.description, STOPWATCH_TIME); + else logger::error("Failed to save project '%s'.", project.description); return result; } @@ -618,9 +618,9 @@ bool administration_writer_save_cost_center_blocking(cost_center cost) int buf_length = 0; char* file_content = administration_writer_copy_template(file_template::costcenter_save_template, &buf_length); - strops_replace(file_content, buf_length, "{{COSTCENTER_ID}}", cost.id); - strops_replace(file_content, buf_length, "{{COSTCENTER_CODE}}", cost.code); - strops_replace(file_content, buf_length, "{{COSTCENTER_DESCRIPTION}}", cost.description); + strops::replace(file_content, buf_length, "{{COSTCENTER_ID}}", cost.id); + strops::replace(file_content, buf_length, "{{COSTCENTER_CODE}}", cost.code); + strops::replace(file_content, buf_length, "{{COSTCENTER_DESCRIPTION}}", cost.description); //// Write to Disk. char final_path[50]; @@ -632,8 +632,8 @@ bool administration_writer_save_cost_center_blocking(cost_center cost) free(file_content); - if (result) log_info("Saved cost center '%s' in %.3fms.", cost.code, STOPWATCH_TIME); - else log_error("Failed to save cost center '%s'.", cost.code); + if (result) logger::info("Saved cost center '%s' in %.3fms.", cost.code, STOPWATCH_TIME); + else logger::error("Failed to save cost center '%s'.", cost.code); return result; } @@ -666,10 +666,10 @@ bool administration_writer_save_tax_rate_blocking(tax_rate rate) int buf_length = 0; char* file_content = administration_writer_copy_template(file_template::taxrate_save_template, &buf_length); - 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); + 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]; @@ -681,8 +681,8 @@ bool administration_writer_save_tax_rate_blocking(tax_rate rate) free(file_content); - if (result) log_info("Saved tax rate '%s/%.1f' in %.3fms.", rate.country_code, rate.rate, STOPWATCH_TIME); - else log_error("Failed to save tax rate '%s/%.1f'.", rate.country_code, rate.rate); + if (result) logger::info("Saved tax rate '%s/%.1f' in %.3fms.", rate.country_code, rate.rate, STOPWATCH_TIME); + else logger::error("Failed to save tax rate '%s/%.1f'.", rate.country_code, rate.rate); return result; } @@ -717,20 +717,20 @@ bool administration_writer_save_contact_blocking(contact c) int buf_length = 0; char* file_content = administration_writer_copy_template(file_template::contact_save_template, &buf_length); - strops_replace(file_content, buf_length, "{{CONTACT_ID}}", c.id); - strops_replace(file_content, buf_length, "{{CONTACT_NAME}}", c.name); - strops_replace_int32(file_content, buf_length, "{{CONTACT_TYPE}}", c.type); - strops_replace(file_content, buf_length, "{{CONTACT_TAXID}}", c.taxid); - strops_replace(file_content, buf_length, "{{CONTACT_BUSINESSID}}", c.businessid); - strops_replace(file_content, buf_length, "{{CONTACT_EMAIL}}", c.email); - strops_replace(file_content, buf_length, "{{CONTACT_PHONENUMBER}}", c.phone_number); - strops_replace(file_content, buf_length, "{{CONTACT_BANKACCOUNT}}", c.bank_account); - strops_replace(file_content, buf_length, "{{CONTACT_ADDRESS1}}", c.address.address1); - strops_replace(file_content, buf_length, "{{CONTACT_ADDRESS2}}", c.address.address2); - strops_replace(file_content, buf_length, "{{CONTACT_COUNTRY}}", c.address.country_code); - strops_replace(file_content, buf_length, "{{CONTACT_CITY}}", c.address.city); - strops_replace(file_content, buf_length, "{{CONTACT_POSTAL}}", c.address.postal); - strops_replace(file_content, buf_length, "{{CONTACT_REGION}}", c.address.region); + strops::replace(file_content, buf_length, "{{CONTACT_ID}}", c.id); + strops::replace(file_content, buf_length, "{{CONTACT_NAME}}", c.name); + strops::replace_int32(file_content, buf_length, "{{CONTACT_TYPE}}", c.type); + strops::replace(file_content, buf_length, "{{CONTACT_TAXID}}", c.taxid); + strops::replace(file_content, buf_length, "{{CONTACT_BUSINESSID}}", c.businessid); + strops::replace(file_content, buf_length, "{{CONTACT_EMAIL}}", c.email); + strops::replace(file_content, buf_length, "{{CONTACT_PHONENUMBER}}", c.phone_number); + strops::replace(file_content, buf_length, "{{CONTACT_BANKACCOUNT}}", c.bank_account); + strops::replace(file_content, buf_length, "{{CONTACT_ADDRESS1}}", c.address.address1); + strops::replace(file_content, buf_length, "{{CONTACT_ADDRESS2}}", c.address.address2); + strops::replace(file_content, buf_length, "{{CONTACT_COUNTRY}}", c.address.country_code); + strops::replace(file_content, buf_length, "{{CONTACT_CITY}}", c.address.city); + strops::replace(file_content, buf_length, "{{CONTACT_POSTAL}}", c.address.postal); + strops::replace(file_content, buf_length, "{{CONTACT_REGION}}", c.address.region); char final_path[50]; snprintf(final_path, 50, "%s.xml", c.id); @@ -741,8 +741,8 @@ bool administration_writer_save_contact_blocking(contact c) free(file_content); - if (result) log_info("Saved contact '%s' in %.3fms.", c.name, STOPWATCH_TIME); - else log_error("Failed to save contact '%s'.", c.name); + if (result) logger::info("Saved contact '%s' in %.3fms.", c.name, STOPWATCH_TIME); + else logger::error("Failed to save contact '%s'.", c.name); return result; } @@ -781,13 +781,13 @@ bool administration_writer_save_all_administration_info_blocking() int buf_length = 0; char* file_content = administration_writer_copy_template(file_template::administration_save_template, &buf_length); - strops_replace_int32(file_content, buf_length, "{{NEXT_ID}}", administration_get_next_id()); - strops_replace_int32(file_content, buf_length, "{{NEXT_SEQUENCE_NUMBER}}", administration_get_next_sequence_number()); - strops_replace(file_content, buf_length, "{{PROGRAM_VERSION}}", config::PROGRAM_VERSION); + strops::replace_int32(file_content, buf_length, "{{NEXT_ID}}", administration_get_next_id()); + strops::replace_int32(file_content, buf_length, "{{NEXT_SEQUENCE_NUMBER}}", administration_get_next_sequence_number()); + strops::replace(file_content, buf_length, "{{PROGRAM_VERSION}}", config::PROGRAM_VERSION); ai_service ai_service = administration_get_ai_service(); - strops_replace_int32(file_content, buf_length, "{{AI_SERVICE_PROVIDER}}", (s32)ai_service.provider); - strops_replace(file_content, buf_length, "{{AI_SERVICE_PUBLIC_KEY}}", ai_service.api_key_public); + strops::replace_int32(file_content, buf_length, "{{AI_SERVICE_PROVIDER}}", (s32)ai_service.provider); + strops::replace(file_content, buf_length, "{{AI_SERVICE_PUBLIC_KEY}}", ai_service.api_key_public); //// Write to Disk. int final_length = (int)strlen(file_content); @@ -796,8 +796,8 @@ bool administration_writer_save_all_administration_info_blocking() free(file_content); - if (result) log_info("Saved administration info in %.3fms.", STOPWATCH_TIME); - else log_error("Failed to save administration info."); + if (result) logger::info("Saved administration info in %.3fms.", STOPWATCH_TIME); + else logger::error("Failed to save administration info."); return result; } |
