summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--include/administration.hpp12
-rw-r--r--include/config.hpp2
-rw-r--r--include/exporter.hpp4
-rw-r--r--include/importer.hpp8
-rw-r--r--src/administration.cpp50
-rw-r--r--src/administration_reader.cpp54
-rw-r--r--src/administration_writer.cpp60
-rw-r--r--src/exporter.cpp6
-rw-r--r--src/importer.cpp78
-rw-r--r--src/ui/imgui_extensions.cpp10
-rw-r--r--src/ui/ui_contacts.cpp2
-rw-r--r--src/ui/ui_expenses.cpp6
-rw-r--r--src/ui/ui_invoices.cpp4
-rw-r--r--src/ui/ui_settings.cpp8
-rw-r--r--tests/administration_rw_tests.cpp14
-rw-r--r--tests/administration_validation_tests.cpp40
-rw-r--r--tests/test_helper.cpp20
18 files changed, 190 insertions, 189 deletions
diff --git a/TODO b/TODO
index 1aa0c8e..2605211 100644
--- a/TODO
+++ b/TODO
@@ -13,6 +13,7 @@ Refactor:
Testing:
- write tests for strops.hpp
- write tests that check error handling for corrupt files. (e.g. references to tax rates, project and cost center that failed to load)
+- write tests for document saving
Features:
- Refactor contact and project UI to be like invoice & expenses
diff --git a/include/administration.hpp b/include/administration.hpp
index 51e72d8..be3f6c0 100644
--- a/include/administration.hpp
+++ b/include/administration.hpp
@@ -92,7 +92,7 @@ typedef struct
typedef struct
{
char name[MAX_LEN_LONG_DESC];
- address address;
+ address addr;
} delivery_info;
typedef enum
@@ -105,7 +105,7 @@ typedef struct
{
char id[MAX_LEN_ID]; // C/[id]
char name[MAX_LEN_LONG_DESC];
- address address;
+ address addr;
contact_type type;
char taxid[MAX_LEN_TAXID]; // Required for business contact
char businessid[MAX_LEN_BUSINESSID]; // Required for business contact
@@ -264,7 +264,7 @@ typedef struct
char payee_account_name[MAX_LEN_LONG_DESC]; // Name of account where payment is made to.
char service_provider_id[MAX_LEN_LONG_DESC]; // BIC or national clearing code.
char payer_bank_account[MAX_LEN_BANK]; // Sender IBAN or BBAN account.
- payment_method payment_method;
+ payment_method method;
} payment_information;
typedef struct
@@ -293,7 +293,7 @@ typedef struct
time_t issued_at;
time_t expires_at;
time_t delivered_at;
- document document; // path to copy of document for incomming invoice.
+ document orig_document; // path to copy of document for incomming invoice.
char project_id[MAX_LEN_ID]; // Optional.
char cost_center_id[MAX_LEN_ID]; // For incomming invoices. optional.
list_t billing_items;
@@ -455,9 +455,9 @@ typedef struct
// Service providers.
u32 ai_service_count;
ai_service all_ai_services[MAX_AI_SERVICES];
- ai_service ai_service; // @TODO rename to active_ai_service
+ ai_service active_ai_service;
- email_service email_service;
+ email_service active_email_service;
} ledger;
// Add/Update result codes.
diff --git a/include/config.hpp b/include/config.hpp
index fb1d304..b7b38d5 100644
--- a/include/config.hpp
+++ b/include/config.hpp
@@ -31,7 +31,7 @@
#define u64 uint64_t
#define SIMULATE_EMAIL 1
-#define SIMULATE_SLOW_DISK 1
+#define SIMULATE_SLOW_DISK 0
#define SIMULATE_WRITE_FAILURE 0
#define PROGRAM_VERSION "0.1.0" // major.minor.patch
diff --git a/include/exporter.hpp b/include/exporter.hpp
index 3ac57b0..d328bf6 100644
--- a/include/exporter.hpp
+++ b/include/exporter.hpp
@@ -32,7 +32,7 @@ namespace exporter {
EXPORT_STARTING,
EXPORT_WAITING_FOR_RESPONSE,
EXPORT_DONE,
- } status;
+ } export_status;
typedef void (*send_email_callback)(e_err err);
@@ -41,7 +41,7 @@ namespace exporter {
time_t started_at;
time_t done_at;
e_err error;
- status status;
+ export_status status;
const char* sender;
const char* recipient;
const char* subject;
diff --git a/include/importer.hpp b/include/importer.hpp
index b432b45..731d1ff 100644
--- a/include/importer.hpp
+++ b/include/importer.hpp
@@ -37,7 +37,7 @@ namespace importer {
IMPORT_QUERYING,
IMPORT_WAITING_FOR_RESPONSE,
IMPORT_DONE,
- } status;
+ } import_status;
typedef struct
{
@@ -45,14 +45,14 @@ namespace importer {
invoice result;
char file_path[MAX_LEN_PATH];
i_err error;
- status status;
+ import_status status;
} invoice_request;
typedef struct
{
time_t started_at;
i_err error;
- status status;
+ import_status status;
u32 result_count;
char result[MAX_MODEL_LIST_RESULT_COUNT][MAX_LEN_SHORT_DESC];
ai_provider service;
@@ -77,7 +77,7 @@ namespace importer {
} email_provider_impl;
const char* error_to_string(i_err error);
- const char* status_to_string(status status);
+ const char* status_to_string(import_status status);
ai_provider_impl get_ai_provider_implementation(ai_provider provider);
diff --git a/src/administration.cpp b/src/administration.cpp
index 3905c74..41ad2fc 100644
--- a/src/administration.cpp
+++ b/src/administration.cpp
@@ -134,7 +134,7 @@ void administration_create()
list_init(&g_administration.cost_centers);
strops::copy(g_administration.path, "", sizeof(g_administration.path));
- memops::zero(&g_administration.ai_service, sizeof(ai_service));
+ memops::zero(&g_administration.active_ai_service, sizeof(ai_service));
memops::zero(&g_administration.all_ai_services, sizeof(g_administration.all_ai_services));
// Load all tax rates.
@@ -235,7 +235,7 @@ void administration::create_default(const char* save_file)
// =======================
ai_service administration::get_active_ai_service()
{
- return g_administration.ai_service;
+ return g_administration.active_ai_service;
}
ai_service administration::get_ai_service(ai_provider provider)
@@ -245,12 +245,12 @@ ai_service administration::get_ai_service(ai_provider provider)
email_service administration::get_email_service()
{
- return g_administration.email_service;
+ return g_administration.active_email_service;
}
void administration::set_email_service(email_service provider)
{
- g_administration.email_service = provider;
+ g_administration.active_email_service = provider;
if (administration_data_changed_event_callback) administration_data_changed_event_callback();
}
@@ -262,7 +262,7 @@ void administration::import_ai_service(ai_service service)
void administration::set_active_ai_service(ai_service service)
{
g_administration.all_ai_services[(u32)service.provider] = service;
- g_administration.ai_service = service;
+ g_administration.active_ai_service = service;
if (administration_data_changed_event_callback) administration_data_changed_event_callback();
}
@@ -375,7 +375,7 @@ void administration::create_tax_statement(tax_statement* statement)
{
STOPWATCH_START;
- char* country_code = company_info_get().address.country_code;
+ char* country_code = company_info_get().addr.country_code;
assert(statement);
statement->report_count = 0;
@@ -676,14 +676,14 @@ contact administration::company_info_get()
void administration::company_info_import(contact data)
{
g_administration.company_info = data;
- strops::copy(g_administration.default_currency, get_default_currency_for_country(g_administration.company_info.address.country_code), MAX_LEN_CURRENCY);
+ strops::copy(g_administration.default_currency, get_default_currency_for_country(g_administration.company_info.addr.country_code), MAX_LEN_CURRENCY);
}
void administration::company_info_set(contact data)
{
strops::copy(data.id, MY_COMPANY_ID, sizeof(data.id));
g_administration.company_info = data;
- strops::copy(g_administration.default_currency, get_default_currency_for_country(g_administration.company_info.address.country_code), MAX_LEN_CURRENCY);
+ strops::copy(g_administration.default_currency, get_default_currency_for_country(g_administration.company_info.addr.country_code), MAX_LEN_CURRENCY);
if (contact_changed_event_callback) contact_changed_event_callback(&data);
}
@@ -877,10 +877,10 @@ a_err administration::addressee_is_valid(delivery_info data)
{
a_err result = A_ERR_SUCCESS;
if (strops::empty(data.name)) result |= A_ERR_MISSING_NAME;
- if (strops::empty(data.address.city)) result |= A_ERR_MISSING_CITY;
- if (strops::empty(data.address.postal)) result |= A_ERR_MISSING_POSTAL;
- if (strops::empty(data.address.address1)) result |= A_ERR_MISSING_ADDRESS1;
- if (strops::empty(data.address.country_code)) result |= A_ERR_MISSING_COUNTRYCODE;
+ if (strops::empty(data.addr.city)) result |= A_ERR_MISSING_CITY;
+ if (strops::empty(data.addr.postal)) result |= A_ERR_MISSING_POSTAL;
+ if (strops::empty(data.addr.address1)) result |= A_ERR_MISSING_ADDRESS1;
+ if (strops::empty(data.addr.country_code)) result |= A_ERR_MISSING_COUNTRYCODE;
return result;
}
@@ -890,10 +890,10 @@ a_err administration::contact_is_valid(contact data)
a_err result = A_ERR_SUCCESS;
if (strops::empty(data.name)) result |= A_ERR_MISSING_NAME;
if (strops::empty(data.email)) result |= A_ERR_MISSING_EMAIL;
- if (strops::empty(data.address.city)) result |= A_ERR_MISSING_CITY;
- if (strops::empty(data.address.postal)) result |= A_ERR_MISSING_POSTAL;
- if (strops::empty(data.address.address1)) result |= A_ERR_MISSING_ADDRESS1;
- if (strops::empty(data.address.country_code)) result |= A_ERR_MISSING_COUNTRYCODE;
+ if (strops::empty(data.addr.city)) result |= A_ERR_MISSING_CITY;
+ if (strops::empty(data.addr.postal)) result |= A_ERR_MISSING_POSTAL;
+ if (strops::empty(data.addr.address1)) result |= A_ERR_MISSING_ADDRESS1;
+ if (strops::empty(data.addr.country_code)) result |= A_ERR_MISSING_COUNTRYCODE;
if (data.type == contact_type::CONTACT_BUSINESS)
{
@@ -1414,7 +1414,7 @@ invoice administration::invoice_create_empty()
result.delivered_at = result.issued_at;
result.expires_at = result.issued_at + administration::get_default_invoice_expire_duration();
list_init(&result.billing_items);
- strops::copy(result.currency, get_default_currency_for_country(g_administration.company_info.address.country_code), MAX_LEN_CURRENCY);
+ strops::copy(result.currency, get_default_currency_for_country(g_administration.company_info.addr.country_code), MAX_LEN_CURRENCY);
return result;
}
@@ -1505,12 +1505,12 @@ a_err administration::invoice_remove(invoice* inv)
static void invoice_set_addressee(invoice* inv, contact contact)
{
memops::copy(&inv->addressee.name, &contact.name, sizeof(inv->addressee.name));
- memops::copy(&inv->addressee.address.address1, &contact.address.address1, sizeof(inv->addressee.address.address1));
- memops::copy(&inv->addressee.address.address2, &contact.address.address2, sizeof(inv->addressee.address.address2));
- memops::copy(&inv->addressee.address.city, &contact.address.city, sizeof(inv->addressee.address.city));
- memops::copy(&inv->addressee.address.postal, &contact.address.postal, sizeof(inv->addressee.address.postal));
- memops::copy(&inv->addressee.address.region, &contact.address.region, sizeof(inv->addressee.address.region));
- memops::copy(&inv->addressee.address.country_code, &contact.address.country_code, sizeof(inv->addressee.address.country_code));
+ memops::copy(&inv->addressee.addr.address1, &contact.addr.address1, sizeof(inv->addressee.addr.address1));
+ memops::copy(&inv->addressee.addr.address2, &contact.addr.address2, sizeof(inv->addressee.addr.address2));
+ memops::copy(&inv->addressee.addr.city, &contact.addr.city, sizeof(inv->addressee.addr.city));
+ memops::copy(&inv->addressee.addr.postal, &contact.addr.postal, sizeof(inv->addressee.addr.postal));
+ memops::copy(&inv->addressee.addr.region, &contact.addr.region, sizeof(inv->addressee.addr.region));
+ memops::copy(&inv->addressee.addr.country_code, &contact.addr.country_code, sizeof(inv->addressee.addr.country_code));
}
a_err administration::invoice_update(invoice* inv)
@@ -1542,7 +1542,7 @@ a_err administration::invoice_update(invoice* inv)
a_err administration::invoice_import(invoice* inv)
{
- inv->is_triangulation = !memops::equals(&inv->addressee.address, &inv->customer.address, sizeof(address));
+ inv->is_triangulation = !memops::equals(&inv->addressee.addr, &inv->customer.addr, sizeof(address));
inv->issued_at -= (inv->issued_at % 86400);
inv->delivered_at -= (inv->delivered_at % 86400);
@@ -1574,7 +1574,7 @@ a_err administration::invoice_add(invoice* inv)
inv->expires_at -= (inv->expires_at % 86400);
inv->is_outgoing = strops::equals(inv->supplier.id, MY_COMPANY_ID);
- inv->payment_means.payment_method = PAYMENT_METHOD_STANDING_AGREEMENT;
+ inv->payment_means.method = PAYMENT_METHOD_STANDING_AGREEMENT;
strops::copy(inv->payment_means.payee_bank_account, inv->supplier.bank_account, sizeof(inv->payment_means.payee_bank_account));
strops::copy(inv->payment_means.payee_account_name, inv->supplier.name, sizeof(inv->payment_means.payee_account_name));
strops::copy(inv->payment_means.service_provider_id, "", sizeof(inv->payment_means.service_provider_id));
diff --git a/src/administration_reader.cpp b/src/administration_reader.cpp
index 81f5b02..aadc853 100644
--- a/src/administration_reader.cpp
+++ b/src/administration_reader.cpp
@@ -137,13 +137,13 @@ bool administration_reader::read_invoice_from_xml(invoice* result, char* buffer,
data.delivered_at = xml_get_date_x(root, "cac:Delivery", "cbc:ActualDeliveryDate", 0);
// References
- xml_get_str_x(root, data.document.copy_path, MAX_LEN_PATH, "cac:AdditionalDocumentReference", "cbc:ID", 0);
- xml_get_str_x(root, data.document.original_path, MAX_LEN_PATH, "cac:AdditionalDocumentReference", "cbc:DocumentDescription", 0);
+ xml_get_str_x(root, data.orig_document.copy_path, MAX_LEN_PATH, "cac:AdditionalDocumentReference", "cbc:ID", 0);
+ xml_get_str_x(root, data.orig_document.original_path, MAX_LEN_PATH, "cac:AdditionalDocumentReference", "cbc:DocumentDescription", 0);
xml_get_str_x(root, data.project_id, MAX_LEN_ID, "cac:ProjectReference", "cbc:ID", 0);
xml_get_str(root, data.cost_center_id, MAX_LEN_ID, "cac:AccountingCost");
// Payment means
- data.payment_means.payment_method = (payment_method)xml_get_s32_x(root, "cac:PaymentMeans", "cbc:PaymentMeansCode", 0);
+ data.payment_means.method = (payment_method)xml_get_s32_x(root, "cac:PaymentMeans", "cbc:PaymentMeansCode", 0);
xml_get_str_x(root, data.payment_means.payee_bank_account, MAX_LEN_BANK, "cac:PaymentMeans", "cac:PayeeFinancialAccount", "cbc:ID", 0);
xml_get_str_x(root, data.payment_means.payee_account_name, MAX_LEN_LONG_DESC, "cac:PaymentMeans", "cac:PayeeFinancialAccount", "cbc:Name", 0);
xml_get_str_x(root, data.payment_means.service_provider_id, MAX_LEN_ID, "cac:PaymentMeans", "cac:PayeeFinancialAccount", "cac:FinancialInstitutionBranch", "cac:FinancialInstitution", "cbc:ID", 0);
@@ -159,12 +159,12 @@ bool administration_reader::read_invoice_from_xml(invoice* result, char* buffer,
xml_get_str_x(root, data.supplier.id, MAX_LEN_ID, "cac:AccountingSupplierParty", "cac:Party", "cac:Contact", "cbc:Name", 0);
strops::copy(data.supplier.bank_account, data.payment_means.payee_bank_account, MAX_LEN_BANK);
xml_get_str_x(root, data.supplier.name, MAX_LEN_LONG_DESC, "cac:AccountingSupplierParty", "cac:Party", "cac:PartyName", "cbc:Name", 0);
- xml_get_str_x(root, data.supplier.address.address1, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:StreetName", 0);
- xml_get_str_x(root, data.supplier.address.address2, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:AdditionalStreetName", 0);
- xml_get_str_x(root, data.supplier.address.city, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:CityName", 0);
- xml_get_str_x(root, data.supplier.address.postal, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:PostalZone", 0);
- xml_get_str_x(root, data.supplier.address.region, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:CountrySubentity", 0);
- xml_get_str_x(root, data.supplier.address.country_code, MAX_LEN_COUNTRY_CODE, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cac:Country", "cbc:IdentificationCode", 0);
+ xml_get_str_x(root, data.supplier.addr.address1, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:StreetName", 0);
+ xml_get_str_x(root, data.supplier.addr.address2, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:AdditionalStreetName", 0);
+ xml_get_str_x(root, data.supplier.addr.city, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:CityName", 0);
+ xml_get_str_x(root, data.supplier.addr.postal, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:PostalZone", 0);
+ xml_get_str_x(root, data.supplier.addr.region, MAX_LEN_ADDRESS, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cbc:CountrySubentity", 0);
+ xml_get_str_x(root, data.supplier.addr.country_code, MAX_LEN_COUNTRY_CODE, "cac:AccountingSupplierParty", "cac:Party", "cac:PostalAddress", "cac:Country", "cbc:IdentificationCode", 0);
xml_get_str_x(root, data.supplier.taxid, MAX_LEN_TAXID, "cac:AccountingSupplierParty", "cac:Party", "cac:PartyTaxScheme", "cbc:CompanyID", 0);
xml_get_str_x(root, data.supplier.businessid, MAX_LEN_BUSINESSID, "cac:AccountingSupplierParty", "cac:Party", "cac:PartyIdentification", "cbc:ID", 0);
xml_get_str_x(root, data.supplier.phone_number, MAX_LEN_PHONE, "cac:AccountingSupplierParty", "cac:Party", "cac:Contact", "cbc:Telephone", 0);
@@ -174,12 +174,12 @@ bool administration_reader::read_invoice_from_xml(invoice* result, char* buffer,
xml_get_str_x(root, data.customer.id, MAX_LEN_ID, "cac:AccountingCustomerParty", "cac:Party", "cac:Contact", "cbc:Name", 0);
strops::copy(data.customer.bank_account, data.payment_means.payer_bank_account, MAX_LEN_BANK);
xml_get_str_x(root, data.customer.name, MAX_LEN_LONG_DESC, "cac:AccountingCustomerParty", "cac:Party", "cac:PartyName", "cbc:Name", 0);
- xml_get_str_x(root, data.customer.address.address1, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:StreetName", 0);
- xml_get_str_x(root, data.customer.address.address2, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:AdditionalStreetName", 0);
- xml_get_str_x(root, data.customer.address.city, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:CityName", 0);
- xml_get_str_x(root, data.customer.address.postal, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:PostalZone", 0);
- xml_get_str_x(root, data.customer.address.region, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:CountrySubentity", 0);
- xml_get_str_x(root, data.customer.address.country_code, MAX_LEN_COUNTRY_CODE, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cac:Country", "cbc:IdentificationCode", 0);
+ xml_get_str_x(root, data.customer.addr.address1, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:StreetName", 0);
+ xml_get_str_x(root, data.customer.addr.address2, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:AdditionalStreetName", 0);
+ xml_get_str_x(root, data.customer.addr.city, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:CityName", 0);
+ xml_get_str_x(root, data.customer.addr.postal, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:PostalZone", 0);
+ xml_get_str_x(root, data.customer.addr.region, MAX_LEN_ADDRESS, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cbc:CountrySubentity", 0);
+ xml_get_str_x(root, data.customer.addr.country_code, MAX_LEN_COUNTRY_CODE, "cac:AccountingCustomerParty", "cac:Party", "cac:PostalAddress", "cac:Country", "cbc:IdentificationCode", 0);
xml_get_str_x(root, data.customer.taxid, MAX_LEN_TAXID, "cac:AccountingCustomerParty", "cac:Party", "cac:PartyTaxScheme", "cbc:CompanyID", 0);
xml_get_str_x(root, data.customer.businessid, MAX_LEN_BUSINESSID, "cac:AccountingCustomerParty", "cac:Party", "cac:PartyIdentification", "cbc:ID", 0);
xml_get_str_x(root, data.customer.phone_number, MAX_LEN_PHONE, "cac:AccountingCustomerParty", "cac:Party", "cac:Contact", "cbc:Telephone", 0);
@@ -191,12 +191,12 @@ bool administration_reader::read_invoice_from_xml(invoice* result, char* buffer,
// Addressee
xml_get_str_x(root, data.addressee.name, MAX_LEN_LONG_DESC, "cac:Delivery", "cac:DeliveryParty", "cac:PartyName", "cbc:Name", 0);
- xml_get_str_x(root, data.addressee.address.address1, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:StreetName", 0);
- xml_get_str_x(root, data.addressee.address.address2, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:AdditionalStreetName", 0);
- xml_get_str_x(root, data.addressee.address.city, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:CityName", 0);
- xml_get_str_x(root, data.addressee.address.postal, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:PostalZone", 0);
- xml_get_str_x(root, data.addressee.address.region, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:CountrySubentity", 0);
- xml_get_str_x(root, data.addressee.address.country_code, MAX_LEN_COUNTRY_CODE, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cac:Country", "cbc:IdentificationCode", 0);
+ xml_get_str_x(root, data.addressee.addr.address1, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:StreetName", 0);
+ xml_get_str_x(root, data.addressee.addr.address2, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:AdditionalStreetName", 0);
+ xml_get_str_x(root, data.addressee.addr.city, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:CityName", 0);
+ xml_get_str_x(root, data.addressee.addr.postal, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:PostalZone", 0);
+ xml_get_str_x(root, data.addressee.addr.region, MAX_LEN_ADDRESS, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cbc:CountrySubentity", 0);
+ xml_get_str_x(root, data.addressee.addr.country_code, MAX_LEN_COUNTRY_CODE, "cac:Delivery", "cac:DeliveryLocation", "cac:Address", "cac:Country", "cbc:IdentificationCode", 0);
size_t child_count = xml_node_children(root);
for (size_t x = 0; x < child_count; x++)
@@ -316,12 +316,12 @@ bool administration_reader::import_contact(char* buffer, size_t buffer_size)
xml_get_str(root, data.bank_account, MAX_LEN_BANK, "BankAccount");
struct xml_node* node_address = xml_easy_child(root, (uint8_t *)"Address", 0);
- xml_get_str(node_address, data.address.address1, MAX_LEN_ADDRESS, "AddressLine1");
- xml_get_str(node_address, data.address.address2, MAX_LEN_ADDRESS, "AddressLine2");
- xml_get_str(node_address, data.address.country_code, MAX_LEN_COUNTRY_CODE, "CountryCode");
- xml_get_str(node_address, data.address.city, MAX_LEN_ADDRESS, "City");
- xml_get_str(node_address, data.address.postal, MAX_LEN_ADDRESS, "Postal");
- xml_get_str(node_address, data.address.region, MAX_LEN_ADDRESS, "Region");
+ xml_get_str(node_address, data.addr.address1, MAX_LEN_ADDRESS, "AddressLine1");
+ xml_get_str(node_address, data.addr.address2, MAX_LEN_ADDRESS, "AddressLine2");
+ xml_get_str(node_address, data.addr.country_code, MAX_LEN_COUNTRY_CODE, "CountryCode");
+ xml_get_str(node_address, data.addr.city, MAX_LEN_ADDRESS, "City");
+ xml_get_str(node_address, data.addr.postal, MAX_LEN_ADDRESS, "Postal");
+ xml_get_str(node_address, data.addr.region, MAX_LEN_ADDRESS, "Region");
a_err result = administration::contact_import(data);
if (result == A_ERR_SUCCESS) {
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp
index ee0ccdb..ad6f200 100644
--- a/src/administration_writer.cpp
+++ b/src/administration_writer.cpp
@@ -337,7 +337,7 @@ static const char* get_eas_id_for_contact(contact *contact)
}
// https://docs.peppol.eu/poacc/billing/3.0/codelist/eas/
- char* country_code = contact->address.country_code;
+ char* country_code = contact->addr.country_code;
// Countries using tax identification numbers.
if (strops::equals(country_code, "AT")) return contact->taxid; // Austria
@@ -379,7 +379,7 @@ static const char* get_eas_scheme_for_contact(contact contact)
return "0203"; // @Hack
}
- address addr = contact.address;
+ address addr = contact.addr;
// https://docs.peppol.eu/poacc/billing/3.0/codelist/eas/
char* country_code = addr.country_code;
@@ -469,7 +469,7 @@ static const char* _get_file_extension(const char *path) {
static void _add_document_to_zip(invoice* inv)
{
- document* doc = &inv->document;
+ document* doc = &inv->orig_document;
if (strops::empty(doc->copy_path) && !strops::empty(doc->original_path))
{
@@ -552,8 +552,8 @@ bool administration_writer::save_invoice_blocking(invoice inv)
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(file_content, buf_length, "{{INVOICE_DOCUMENT_COPY}}", inv.orig_document.copy_path);
+ strops::replace(file_content, buf_length, "{{INVOICE_DOCUMENT_ORIG}}", inv.orig_document.original_path);
//strops::replace_int32(file_content, buf_length, "{{INVOICE_STATUS}}", (s32)inv.status);
// Supplier data
@@ -561,12 +561,12 @@ bool administration_writer::save_invoice_blocking(invoice inv)
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);
- 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_STREET}}", inv.supplier.addr.address1);
+ strops::replace(file_content, buf_length, "{{SUPPLIER_STREET2}}", inv.supplier.addr.address2);
+ strops::replace(file_content, buf_length, "{{SUPPLIER_CITY}}", inv.supplier.addr.city);
+ strops::replace(file_content, buf_length, "{{SUPPLIER_POSTAL}}", inv.supplier.addr.postal);
+ strops::replace(file_content, buf_length, "{{SUPPLIER_REGION}}", inv.supplier.addr.region);
+ strops::replace(file_content, buf_length, "{{SUPPLIER_COUNTRY}}", inv.supplier.addr.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);
@@ -578,12 +578,12 @@ bool administration_writer::save_invoice_blocking(invoice inv)
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);
- 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_STREET}}", inv.customer.addr.address1);
+ strops::replace(file_content, buf_length, "{{CUSTOMER_STREET2}}", inv.customer.addr.address2);
+ strops::replace(file_content, buf_length, "{{CUSTOMER_CITY}}", inv.customer.addr.city);
+ strops::replace(file_content, buf_length, "{{CUSTOMER_POSTAL}}", inv.customer.addr.postal);
+ strops::replace(file_content, buf_length, "{{CUSTOMER_REGION}}", inv.customer.addr.region);
+ strops::replace(file_content, buf_length, "{{CUSTOMER_COUNTRY}}", inv.customer.addr.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);
@@ -595,15 +595,15 @@ bool administration_writer::save_invoice_blocking(invoice inv)
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_STREET}}", inv.addressee.addr.address1);
+ strops::replace(file_content, buf_length, "{{DELIVERY_STREET2}}", inv.addressee.addr.address2);
+ strops::replace(file_content, buf_length, "{{DELIVERY_CITY}}", inv.addressee.addr.city);
+ strops::replace(file_content, buf_length, "{{DELIVERY_POSTAL}}", inv.addressee.addr.postal);
+ strops::replace(file_content, buf_length, "{{DELIVERY_REGION}}", inv.addressee.addr.region);
+ strops::replace(file_content, buf_length, "{{DELIVERY_COUNTRY}}", inv.addressee.addr.country_code);
// Payment means
- strops::replace_int32(file_content, buf_length, "{{PAYMENT_TYPE}}", inv.payment_means.payment_method);
+ strops::replace_int32(file_content, buf_length, "{{PAYMENT_TYPE}}", inv.payment_means.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);
@@ -884,12 +884,12 @@ bool administration_writer::save_contact_blocking(contact c)
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_ADDRESS1}}", c.addr.address1);
+ strops::replace(file_content, buf_length, "{{CONTACT_ADDRESS2}}", c.addr.address2);
+ strops::replace(file_content, buf_length, "{{CONTACT_COUNTRY}}", c.addr.country_code);
+ strops::replace(file_content, buf_length, "{{CONTACT_CITY}}", c.addr.city);
+ strops::replace(file_content, buf_length, "{{CONTACT_POSTAL}}", c.addr.postal);
+ strops::replace(file_content, buf_length, "{{CONTACT_REGION}}", c.addr.region);
char final_path[50];
strops::format(final_path, 50, "%s.xml", c.id);
diff --git a/src/exporter.cpp b/src/exporter.cpp
index 54d2b59..21ff778 100644
--- a/src/exporter.cpp
+++ b/src/exporter.cpp
@@ -40,12 +40,12 @@ exporter::email_provider_impl exporter::get_email_provider_implementation(email_
static int _send_email_t(void* arg) {
exporter::export_request* request = (exporter::export_request*)arg;
- request->status = exporter::status::EXPORT_WAITING_FOR_RESPONSE;
+ request->status = exporter::export_status::EXPORT_WAITING_FOR_RESPONSE;
exporter::email_provider_impl impl = exporter::get_email_provider_implementation(administration::get_email_service().provider);
request->error = impl.send_email(request->sender, request->recipient, request->subject, request->text);
- request->status = exporter::status::EXPORT_DONE;
+ request->status = exporter::export_status::EXPORT_DONE;
request->done_at = time(NULL);
if (request->callback) request->callback(request->error);
@@ -58,7 +58,7 @@ exporter::export_request* exporter::send_email(const char* sender, const char* r
exporter::export_request* result = (exporter::export_request*)memops::alloc(sizeof(exporter::export_request));
result->started_at = time(NULL);
result->error = E_ERR_SUCCESS;
- result->status = exporter::status::EXPORT_STARTING;
+ result->status = exporter::export_status::EXPORT_STARTING;
result->sender = sender;
result->recipient = recipient;
result->subject = subject;
diff --git a/src/importer.cpp b/src/importer.cpp
index c3757ce..23bdcbe 100644
--- a/src/importer.cpp
+++ b/src/importer.cpp
@@ -69,22 +69,22 @@ static void _batch_query_response_handler(invoice* buffer, char* json)
}
else if (strops::equals(rb, "5")) {
strops::get_json_value(json, "address1", rb, alloc_size);
- strops::copy(buffer->supplier.address.address1, rb, sizeof(buffer->supplier.address.address1));
+ strops::copy(buffer->supplier.addr.address1, rb, sizeof(buffer->supplier.addr.address1));
strops::get_json_value(json, "address2", rb, alloc_size);
- strops::copy(buffer->supplier.address.address2, rb, sizeof(buffer->supplier.address.address2));
+ strops::copy(buffer->supplier.addr.address2, rb, sizeof(buffer->supplier.addr.address2));
strops::get_json_value(json, "city", rb, alloc_size);
- strops::copy(buffer->supplier.address.city, rb, sizeof(buffer->supplier.address.city));
+ strops::copy(buffer->supplier.addr.city, rb, sizeof(buffer->supplier.addr.city));
strops::get_json_value(json, "postal", rb, alloc_size);
- strops::copy(buffer->supplier.address.postal, rb, sizeof(buffer->supplier.address.postal));
+ strops::copy(buffer->supplier.addr.postal, rb, sizeof(buffer->supplier.addr.postal));
strops::get_json_value(json, "region", rb, alloc_size);
- strops::copy(buffer->supplier.address.region, rb, sizeof(buffer->supplier.address.region));
+ strops::copy(buffer->supplier.addr.region, rb, sizeof(buffer->supplier.addr.region));
strops::get_json_value(json, "country_code", rb, alloc_size);
- strops::copy(buffer->supplier.address.country_code, rb, sizeof(buffer->supplier.address.country_code));
+ strops::copy(buffer->supplier.addr.country_code, rb, sizeof(buffer->supplier.addr.country_code));
strops::get_json_value(json, "is_business", rb, alloc_size);
buffer->supplier.type = (strops::equals(rb, "true")) ? contact_type::CONTACT_BUSINESS : contact_type::CONTACT_CONSUMER;
@@ -109,22 +109,22 @@ static void _batch_query_response_handler(invoice* buffer, char* json)
}
else if (strops::equals(rb, "6")) {
strops::get_json_value(json, "address1", rb, alloc_size);
- strops::copy(buffer->customer.address.address1, rb, sizeof(buffer->customer.address.address1));
+ strops::copy(buffer->customer.addr.address1, rb, sizeof(buffer->customer.addr.address1));
strops::get_json_value(json, "address2", rb, alloc_size);
- strops::copy(buffer->customer.address.address2, rb, sizeof(buffer->customer.address.address2));
+ strops::copy(buffer->customer.addr.address2, rb, sizeof(buffer->customer.addr.address2));
strops::get_json_value(json, "city", rb, alloc_size);
- strops::copy(buffer->customer.address.city, rb, sizeof(buffer->customer.address.city));
+ strops::copy(buffer->customer.addr.city, rb, sizeof(buffer->customer.addr.city));
strops::get_json_value(json, "postal", rb, alloc_size);
- strops::copy(buffer->customer.address.postal, rb, sizeof(buffer->customer.address.postal));
+ strops::copy(buffer->customer.addr.postal, rb, sizeof(buffer->customer.addr.postal));
strops::get_json_value(json, "region", rb, alloc_size);
- strops::copy(buffer->customer.address.region, rb, sizeof(buffer->customer.address.region));
+ strops::copy(buffer->customer.addr.region, rb, sizeof(buffer->customer.addr.region));
strops::get_json_value(json, "country_code", rb, alloc_size);
- strops::copy(buffer->customer.address.country_code, rb, sizeof(buffer->customer.address.country_code));
+ strops::copy(buffer->customer.addr.country_code, rb, sizeof(buffer->customer.addr.country_code));
strops::get_json_value(json, "is_business", rb, alloc_size);
buffer->customer.type = (strops::equals(rb, "true")) ? contact_type::CONTACT_BUSINESS : contact_type::CONTACT_CONSUMER;
@@ -149,22 +149,22 @@ static void _batch_query_response_handler(invoice* buffer, char* json)
}
else if (strops::equals(rb, "7")) {
strops::get_json_value(json, "address1", rb, alloc_size);
- strops::copy(buffer->addressee.address.address1, rb, sizeof(buffer->addressee.address.address1));
+ strops::copy(buffer->addressee.addr.address1, rb, sizeof(buffer->addressee.addr.address1));
strops::get_json_value(json, "address2", rb, alloc_size);
- strops::copy(buffer->addressee.address.address2, rb, sizeof(buffer->addressee.address.address2));
+ strops::copy(buffer->addressee.addr.address2, rb, sizeof(buffer->addressee.addr.address2));
strops::get_json_value(json, "city", rb, alloc_size);
- strops::copy(buffer->addressee.address.city, rb, sizeof(buffer->addressee.address.city));
+ strops::copy(buffer->addressee.addr.city, rb, sizeof(buffer->addressee.addr.city));
strops::get_json_value(json, "postal", rb, alloc_size);
- strops::copy(buffer->addressee.address.postal, rb, sizeof(buffer->addressee.address.postal));
+ strops::copy(buffer->addressee.addr.postal, rb, sizeof(buffer->addressee.addr.postal));
strops::get_json_value(json, "region", rb, alloc_size);
- strops::copy(buffer->addressee.address.region, rb, sizeof(buffer->addressee.address.region));
+ strops::copy(buffer->addressee.addr.region, rb, sizeof(buffer->addressee.addr.region));
strops::get_json_value(json, "country_code", rb, alloc_size);
- strops::copy(buffer->addressee.address.country_code, rb, sizeof(buffer->addressee.address.country_code));
+ strops::copy(buffer->addressee.addr.country_code, rb, sizeof(buffer->addressee.addr.country_code));
strops::get_json_value(json, "name", rb, alloc_size);
strops::copy(buffer->addressee.name, rb, sizeof(buffer->addressee.name));
@@ -210,16 +210,16 @@ static int _ai_document_to_invoice_t(void *arg)
char* file_path = request->file_path;
importer::ai_provider_impl impl = importer::get_ai_provider_implementation(administration::get_active_ai_service().provider);
- request->status = importer::status::IMPORT_UPLOADING_FILE;
+ request->status = importer::import_status::IMPORT_UPLOADING_FILE;
char file_id[100];
if (!impl.upload_file(file_path, file_id, 100)) {
- request->status = importer::status::IMPORT_DONE;
+ request->status = importer::import_status::IMPORT_DONE;
request->error = I_ERR_FAILED_UPLOAD;
return 0;
}
- request->status = importer::status::IMPORT_WAITING_FOR_RESPONSE;
+ request->status = importer::import_status::IMPORT_WAITING_FOR_RESPONSE;
const char* queries[] = {
"What is the invoice number/ID? Return json containing sequential_number (string), query_id = 1 (string)",
@@ -252,14 +252,14 @@ static int _ai_document_to_invoice_t(void *arg)
invoice inv = administration::invoice_create_empty();
if (!impl.batch_query_with_file(queries, sizeof(queries) / sizeof(char*), file_id, &inv, _batch_query_response_handler)) {
- request->status = importer::status::IMPORT_DONE;
+ request->status = importer::import_status::IMPORT_DONE;
request->error = I_ERR_FAILED_QUERY;
return 0;
}
inv.extras.status = invoice_status::INVOICE_RECEIVED;
- inv.is_triangulation = !memops::equals(&inv.addressee.address, &inv.customer.address, sizeof(address));
+ inv.is_triangulation = !memops::equals(&inv.addressee.addr, &inv.customer.addr, sizeof(address));
strops::copy(inv.customer.id, MY_COMPANY_ID, MAX_LEN_ID);
@@ -268,10 +268,10 @@ static int _ai_document_to_invoice_t(void *arg)
strops::copy(inv.cost_center_id, "", MAX_LEN_ID);
// Set document references and save copy to disk.
- strops::copy(inv.document.original_path, file_path, MAX_LEN_PATH);
- strops::copy(inv.document.copy_path, "", MAX_LEN_PATH);
+ strops::copy(inv.orig_document.original_path, file_path, MAX_LEN_PATH);
+ strops::copy(inv.orig_document.copy_path, "", MAX_LEN_PATH);
- request->status = importer::status::IMPORT_DONE;
+ request->status = importer::import_status::IMPORT_DONE;
request->result = administration::invoice_create_copy(&inv);
return 0;
}
@@ -281,7 +281,7 @@ importer::invoice_request* importer::ai_document_to_invoice(char* file_path)
importer::invoice_request* result = (importer::invoice_request*)memops::alloc(sizeof(importer::invoice_request));
result->started_at = time(NULL);
result->error = I_ERR_SUCCESS;
- result->status = importer::status::IMPORT_STARTING;
+ result->status = importer::import_status::IMPORT_STARTING;
strops::copy(result->file_path, file_path, MAX_LEN_PATH);
thrd_t thr;
@@ -298,20 +298,20 @@ static int _ai_get_available_models_t(void* arg)
importer::ai_provider_impl impl = importer::get_ai_provider_implementation(request->service);
if (!impl.get_available_models) {
- request->status = importer::status::IMPORT_DONE;
+ request->status = importer::import_status::IMPORT_DONE;
request->error = I_ERR_UNIMPLEMENTED;
return 0;
}
- request->status = importer::status::IMPORT_WAITING_FOR_RESPONSE;
+ request->status = importer::import_status::IMPORT_WAITING_FOR_RESPONSE;
if (!impl.get_available_models(request)) {
- request->status = importer::status::IMPORT_DONE;
+ request->status = importer::import_status::IMPORT_DONE;
request->error = I_ERR_FAILED_QUERY;
return 0;
}
- request->status = importer::status::IMPORT_DONE;
+ request->status = importer::import_status::IMPORT_DONE;
return 0;
}
@@ -321,14 +321,14 @@ importer::model_list_request* importer::ai_get_available_models(ai_provider serv
importer::model_list_request* result = (importer::model_list_request*)memops::alloc(sizeof(importer::model_list_request));
result->started_at = time(NULL);
result->error = I_ERR_SUCCESS;
- result->status = importer::status::IMPORT_STARTING;
+ result->status = importer::import_status::IMPORT_STARTING;
result->result_count = 0;
result->service = service;
memops::zero(result->result, sizeof(result->result));
thrd_t thr;
if (thrd_create(&thr, _ai_get_available_models_t, result) != thrd_success) {
- result->status = importer::status::IMPORT_DONE;
+ result->status = importer::import_status::IMPORT_DONE;
result->error = I_ERR_FAILED_QUERY;
return 0;
}
@@ -336,15 +336,15 @@ importer::model_list_request* importer::ai_get_available_models(ai_provider serv
return result;
}
-const char* importer::status_to_string(importer::status status)
+const char* importer::status_to_string(importer::import_status status)
{
switch(status)
{
- case importer::status::IMPORT_STARTING: return locale::get("import.status.starting");
- case importer::status::IMPORT_UPLOADING_FILE: return locale::get("import.status.uploading_file");
- case importer::status::IMPORT_QUERYING: return locale::get("import.status.querying");
- case importer::status::IMPORT_WAITING_FOR_RESPONSE: return locale::get("import.status.waiting_for_result");
- case importer::status::IMPORT_DONE: return locale::get("import.status.done");
+ case importer::import_status::IMPORT_STARTING: return locale::get("import.status.starting");
+ case importer::import_status::IMPORT_UPLOADING_FILE: return locale::get("import.status.uploading_file");
+ case importer::import_status::IMPORT_QUERYING: return locale::get("import.status.querying");
+ case importer::import_status::IMPORT_WAITING_FOR_RESPONSE: return locale::get("import.status.waiting_for_result");
+ case importer::import_status::IMPORT_DONE: return locale::get("import.status.done");
}
return "";
}
diff --git a/src/ui/imgui_extensions.cpp b/src/ui/imgui_extensions.cpp
index 2c13546..4112568 100644
--- a/src/ui/imgui_extensions.cpp
+++ b/src/ui/imgui_extensions.cpp
@@ -455,7 +455,7 @@ namespace ImGui
for (int i = 0; i < autocomplete_count; i++)
{
autocomplete_strings[i] = (char*)memops::alloc(200);
- strops::format(autocomplete_strings[i], 200, "%s (%s %s)", autocomplete_list[i].name, autocomplete_list[i].address.address1, autocomplete_list[i].address.address2);
+ strops::format(autocomplete_strings[i], 200, "%s (%s %s)", autocomplete_list[i].name, autocomplete_list[i].addr.address1, autocomplete_list[i].addr.address2);
}
int autocomplete_index = ImGui::InputTextWithAutocomplete(locale::get("contact.form.fullname"),
@@ -486,7 +486,7 @@ namespace ImGui
if (with_autocomplete) _ContactFormNameAutocomplete(buffer, last_err & A_ERR_MISSING_NAME);
else ImGui::InputTextWithErrorHint(locale::get("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), last_err & A_ERR_MISSING_NAME);
- ImGui::AddressForm(&buffer->address, last_err, active_countries_only);
+ ImGui::AddressForm(&buffer->addr, last_err, active_countries_only);
ImGui::ContactTypeDropdown(&buffer->type);
@@ -775,7 +775,7 @@ namespace ImGui
ImGui::InputTextWithErrorHint(locale::get("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), last_err & A_ERR_MISSING_NAME);
- ImGui::AddressForm(&buffer->address, last_err);
+ ImGui::AddressForm(&buffer->addr, last_err);
if (viewing_only) ImGui::EndDisabled();
ImGui::PopID();
@@ -799,7 +799,7 @@ namespace ImGui
static time_t status_changed_at = 0;
static e_err last_err;
- if (active_request && active_request->status == exporter::status::EXPORT_DONE && is_new_request)
+ if (active_request && active_request->status == exporter::export_status::EXPORT_DONE && is_new_request)
{
is_new_request = false;
show_status_change = true;
@@ -807,7 +807,7 @@ namespace ImGui
status_changed_at = time(NULL);
}
- if (active_request && active_request->status != exporter::status::EXPORT_DONE) {
+ if (active_request && active_request->status != exporter::export_status::EXPORT_DONE) {
is_new_request = true;
ImGui::BeginDisabled();
ImGui::BeginCombo("##sendStatus", NULL, 1 << 20);
diff --git a/src/ui/ui_contacts.cpp b/src/ui/ui_contacts.cpp
index b1fa01b..99896ce 100644
--- a/src/ui/ui_contacts.cpp
+++ b/src/ui/ui_contacts.cpp
@@ -110,7 +110,7 @@ static void draw_contact_list()
}
ImGui::TableSetColumnIndex(1); ImGui::Text(c.name);
- ImGui::TableSetColumnIndex(2); ImGui::Text("%s %s", c.address.address1, c.address.address2);
+ ImGui::TableSetColumnIndex(2); ImGui::Text("%s %s", c.addr.address1, c.addr.address2);
ImGui::TableSetColumnIndex(3);
diff --git a/src/ui/ui_expenses.cpp b/src/ui/ui_expenses.cpp
index 168517f..6ac043f 100644
--- a/src/ui/ui_expenses.cpp
+++ b/src/ui/ui_expenses.cpp
@@ -109,8 +109,8 @@ static void draw_expense_form(invoice* buffer, bool viewing_only = false)
ImGui::Separator();
ImGui::Spacing();
- if (ImGui::FileSelect(locale::get("ui.fileselect.text"), buffer->document.original_path)) {
- buffer->document.copy_path[0] = 0;
+ if (ImGui::FileSelect(locale::get("ui.fileselect.text"), buffer->orig_document.original_path)) {
+ buffer->orig_document.copy_path[0] = 0;
}
ImGui::Spacing();
@@ -415,7 +415,7 @@ static void draw_import_request()
{
assert(active_import_request);
- if (active_import_request->status == importer::status::IMPORT_DONE) {
+ if (active_import_request->status == importer::import_status::IMPORT_DONE) {
if (active_import_request->error == I_ERR_SUCCESS) {
active_invoice = active_import_request->result;
current_view_state = ui::view_state::CREATE;
diff --git a/src/ui/ui_invoices.cpp b/src/ui/ui_invoices.cpp
index 7356207..c222050 100644
--- a/src/ui/ui_invoices.cpp
+++ b/src/ui/ui_invoices.cpp
@@ -225,8 +225,8 @@ static void draw_invoice_form(invoice* buffer, bool viewing_only = false)
ImGui::Separator();
ImGui::Spacing();
- if (ImGui::FileSelect(locale::get("ui.fileselect.text"), buffer->document.original_path)) {
- buffer->document.copy_path[0] = 0;
+ if (ImGui::FileSelect(locale::get("ui.fileselect.text"), buffer->orig_document.original_path)) {
+ buffer->orig_document.copy_path[0] = 0;
}
ImGui::Spacing();
diff --git a/src/ui/ui_settings.cpp b/src/ui/ui_settings.cpp
index 854d065..f0a0a53 100644
--- a/src/ui/ui_settings.cpp
+++ b/src/ui/ui_settings.cpp
@@ -54,7 +54,7 @@ void ui::setup_settings()
if (administration::company_info_is_valid()) {
tax_rates = (tax_rate*)memops::alloc(sizeof(tax_rate) * 400);
- tax_rate_count = country::get_available_tax_rates(administration::company_info_get().address.country_code, tax_rates, 400);
+ tax_rate_count = country::get_available_tax_rates(administration::company_info_get().addr.country_code, tax_rates, 400);
cost_center_count = administration::cost_center_count();
cost_centers = (cost_center*)memops::alloc(cost_center_count * sizeof(cost_center));
@@ -296,7 +296,7 @@ static void draw_ai_service_ui()
}
// Default to first result in model list, or hardcoded default model.
- if (model_request->status == importer::status::IMPORT_DONE) {
+ if (model_request->status == importer::import_status::IMPORT_DONE) {
if (set_model_on_load) {
set_model_on_load = false;
@@ -309,7 +309,7 @@ static void draw_ai_service_ui()
}
}
- if (model_request->status == importer::status::IMPORT_DONE && model_request->error == I_ERR_SUCCESS) {
+ if (model_request->status == importer::import_status::IMPORT_DONE && model_request->error == I_ERR_SUCCESS) {
if (ImGui::BeginCombo(locale::get("settings.services.ai_service.model"), new_ai_service.model_name))
{
for (u32 n = 0; n < model_request->result_count; n++)
@@ -328,7 +328,7 @@ static void draw_ai_service_ui()
{
if (ImGui::BeginComboPreview())
{
- if (model_request->status != importer::status::IMPORT_DONE) {
+ if (model_request->status != importer::import_status::IMPORT_DONE) {
ImGui::LoadingIndicatorCircleSmall();
ImGui::SameLine();
}
diff --git a/tests/administration_rw_tests.cpp b/tests/administration_rw_tests.cpp
index 2a009e4..b610948 100644
--- a/tests/administration_rw_tests.cpp
+++ b/tests/administration_rw_tests.cpp
@@ -110,10 +110,10 @@ TEST _administration_rw_contact(void)
{
pw = administration::contact_create_empty();
strops::copy(pw.name, "John Johnsson", sizeof(pw.name));
- strops::copy(pw.address.address1, "Address 1", sizeof(pw.address.address1));
- strops::copy(pw.address.country_code, "FR", sizeof(pw.address.country_code));
- strops::copy(pw.address.city, "Paris", sizeof(pw.address.city));
- strops::copy(pw.address.postal, "12345", sizeof(pw.address.postal));
+ strops::copy(pw.addr.address1, "Address 1", sizeof(pw.addr.address1));
+ strops::copy(pw.addr.country_code, "FR", sizeof(pw.addr.country_code));
+ strops::copy(pw.addr.city, "Paris", sizeof(pw.addr.city));
+ strops::copy(pw.addr.postal, "12345", sizeof(pw.addr.postal));
strops::copy(pw.email, "test@test.com", sizeof(pw.email));
pw.type = contact_type::CONTACT_CONSUMER;
@@ -173,8 +173,8 @@ TEST _assert_invoices_are_equal(invoice inv, invoice invr)
ASSERT_EQ(invr.issued_at, inv.issued_at);
ASSERT_EQ(invr.expires_at, inv.expires_at);
ASSERT_EQ(invr.delivered_at, inv.delivered_at);
- ASSERT_STR_EQ(invr.document.original_path, inv.document.original_path);
- ASSERT_STR_EQ(invr.document.copy_path, inv.document.copy_path);
+ ASSERT_STR_EQ(invr.orig_document.original_path, inv.orig_document.original_path);
+ ASSERT_STR_EQ(invr.orig_document.copy_path, inv.orig_document.copy_path);
ASSERT_STR_EQ(invr.project_id, inv.project_id);
ASSERT_STR_EQ(invr.cost_center_id, inv.cost_center_id);
@@ -324,7 +324,7 @@ TEST _administration_rw_b2b2c_invoice(void)
inv.supplier = _create_nl_business();
inv.customer = _create_nl_business();
strops::copy(inv.addressee.name, "Piet Pinda", sizeof(inv.addressee.name));
- inv.addressee.address = _create_nl_consumer().address;
+ inv.addressee.addr = _create_nl_consumer().addr;
inv.is_triangulation = 1;
inv.is_outgoing = 1;
inv.issued_at = time(NULL);
diff --git a/tests/administration_validation_tests.cpp b/tests/administration_validation_tests.cpp
index cd2aa0c..aae7007 100644
--- a/tests/administration_validation_tests.cpp
+++ b/tests/administration_validation_tests.cpp
@@ -148,10 +148,10 @@ contact _create_test_contact()
{
contact p1 = administration::contact_create_empty();
strops::copy(p1.name, "John Johnsson", sizeof(p1.name));
- strops::copy(p1.address.address1, "Address 1", sizeof(p1.address.address1));
- strops::copy(p1.address.country_code, "FR", sizeof(p1.address.country_code));
- strops::copy(p1.address.city, "Paris", sizeof(p1.address.city));
- strops::copy(p1.address.postal, "12345", sizeof(p1.address.postal));
+ strops::copy(p1.addr.address1, "Address 1", sizeof(p1.addr.address1));
+ strops::copy(p1.addr.country_code, "FR", sizeof(p1.addr.country_code));
+ strops::copy(p1.addr.city, "Paris", sizeof(p1.addr.city));
+ strops::copy(p1.addr.postal, "12345", sizeof(p1.addr.postal));
strops::copy(p1.email, "test@test.com", sizeof(p1.email));
p1.type = contact_type::CONTACT_CONSUMER;
return p1;
@@ -166,13 +166,13 @@ TEST _administration_validate_contact_add(void)
strops::copy(p1.name, "", sizeof(p1.name));
ASSERT_EQ(administration::contact_add(p1), A_ERR_MISSING_NAME);
- strops::copy(p1.address.address1, "", sizeof(p1.address.address1));
+ strops::copy(p1.addr.address1, "", sizeof(p1.addr.address1));
ASSERT_EQ(administration::contact_add(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1);
- strops::copy(p1.address.city, "", sizeof(p1.address.city));
+ strops::copy(p1.addr.city, "", sizeof(p1.addr.city));
ASSERT_EQ(administration::contact_add(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY);
- strops::copy(p1.address.postal, "", sizeof(p1.address.postal));
+ strops::copy(p1.addr.postal, "", sizeof(p1.addr.postal));
ASSERT_EQ(administration::contact_add(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY|A_ERR_MISSING_POSTAL);
- strops::copy(p1.address.country_code, "", sizeof(p1.address.country_code));
+ strops::copy(p1.addr.country_code, "", sizeof(p1.addr.country_code));
ASSERT_EQ(administration::contact_add(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY|A_ERR_MISSING_POSTAL|A_ERR_MISSING_COUNTRYCODE);
p1.type = contact_type::CONTACT_BUSINESS;
@@ -192,13 +192,13 @@ TEST _administration_validate_contact_update(void)
strops::copy(p1.name, "", sizeof(p1.name));
ASSERT_EQ(administration::contact_update(p1), A_ERR_MISSING_NAME);
- strops::copy(p1.address.address1, "", sizeof(p1.address.address1));
+ strops::copy(p1.addr.address1, "", sizeof(p1.addr.address1));
ASSERT_EQ(administration::contact_update(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1);
- strops::copy(p1.address.city, "", sizeof(p1.address.city));
+ strops::copy(p1.addr.city, "", sizeof(p1.addr.city));
ASSERT_EQ(administration::contact_update(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY);
- strops::copy(p1.address.postal, "", sizeof(p1.address.postal));
+ strops::copy(p1.addr.postal, "", sizeof(p1.addr.postal));
ASSERT_EQ(administration::contact_update(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY|A_ERR_MISSING_POSTAL);
- strops::copy(p1.address.country_code, "", sizeof(p1.address.country_code));
+ strops::copy(p1.addr.country_code, "", sizeof(p1.addr.country_code));
ASSERT_EQ(administration::contact_update(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY|A_ERR_MISSING_POSTAL|A_ERR_MISSING_COUNTRYCODE);
p1.type = contact_type::CONTACT_BUSINESS;
@@ -207,10 +207,10 @@ TEST _administration_validate_contact_update(void)
strops::copy(p1.id, "-1", sizeof(p1.id));
strops::copy(p1.name, "John Johnsson", sizeof(p1.name));
- strops::copy(p1.address.address1, "Address 1", sizeof(p1.address.address1));
- strops::copy(p1.address.country_code, "FR", sizeof(p1.address.country_code));
- strops::copy(p1.address.city, "Paris", sizeof(p1.address.city));
- strops::copy(p1.address.postal, "12345", sizeof(p1.address.postal));
+ strops::copy(p1.addr.address1, "Address 1", sizeof(p1.addr.address1));
+ strops::copy(p1.addr.country_code, "FR", sizeof(p1.addr.country_code));
+ strops::copy(p1.addr.city, "Paris", sizeof(p1.addr.city));
+ strops::copy(p1.addr.postal, "12345", sizeof(p1.addr.postal));
p1.type = contact_type::CONTACT_CONSUMER;
ASSERT_EQ(administration::contact_update(p1), A_ERR_NOT_FOUND);
@@ -243,13 +243,13 @@ TEST _administration_validate_contact_isvalid(void)
strops::copy(p1.name, "", sizeof(p1.name));
ASSERT_EQ(administration::contact_is_valid(p1), A_ERR_MISSING_NAME);
- strops::copy(p1.address.address1, "", sizeof(p1.address.address1));
+ strops::copy(p1.addr.address1, "", sizeof(p1.addr.address1));
ASSERT_EQ(administration::contact_is_valid(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1);
- strops::copy(p1.address.city, "", sizeof(p1.address.city));
+ strops::copy(p1.addr.city, "", sizeof(p1.addr.city));
ASSERT_EQ(administration::contact_is_valid(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY);
- strops::copy(p1.address.postal, "", sizeof(p1.address.postal));
+ strops::copy(p1.addr.postal, "", sizeof(p1.addr.postal));
ASSERT_EQ(administration::contact_is_valid(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY|A_ERR_MISSING_POSTAL);
- strops::copy(p1.address.country_code, "", sizeof(p1.address.country_code));
+ strops::copy(p1.addr.country_code, "", sizeof(p1.addr.country_code));
ASSERT_EQ(administration::contact_is_valid(p1), A_ERR_MISSING_NAME|A_ERR_MISSING_ADDRESS1|A_ERR_MISSING_CITY|A_ERR_MISSING_POSTAL|A_ERR_MISSING_COUNTRYCODE);
p1.type = contact_type::CONTACT_BUSINESS;
diff --git a/tests/test_helper.cpp b/tests/test_helper.cpp
index ada084b..9dc9898 100644
--- a/tests/test_helper.cpp
+++ b/tests/test_helper.cpp
@@ -19,11 +19,11 @@ static contact _create_nl_business()
{
contact pw = administration::contact_create_empty();
strops::copy(pw.name, "Dutch Company BV", sizeof(pw.name));
- strops::copy(pw.address.address1, "Address 1", sizeof(pw.address.address1));
- strops::copy(pw.address.country_code, "NL", sizeof(pw.address.country_code));
- strops::copy(pw.address.city, "Amsterdam", sizeof(pw.address.city));
- strops::copy(pw.address.region, "Noord-Holland", sizeof(pw.address.region));
- strops::copy(pw.address.postal, "1234AA", sizeof(pw.address.postal));
+ strops::copy(pw.addr.address1, "Address 1", sizeof(pw.addr.address1));
+ strops::copy(pw.addr.country_code, "NL", sizeof(pw.addr.country_code));
+ strops::copy(pw.addr.city, "Amsterdam", sizeof(pw.addr.city));
+ strops::copy(pw.addr.region, "Noord-Holland", sizeof(pw.addr.region));
+ strops::copy(pw.addr.postal, "1234AA", sizeof(pw.addr.postal));
strops::copy(pw.taxid, "T123", sizeof(pw.taxid));
strops::copy(pw.businessid, "B321", sizeof(pw.businessid));
strops::copy(pw.email, "test@test.com", sizeof(pw.email));
@@ -37,11 +37,11 @@ static contact _create_nl_consumer()
{
contact pw = administration::contact_create_empty();
strops::copy(pw.name, "Piet Pinda", sizeof(pw.name));
- strops::copy(pw.address.address1, "Address 2", sizeof(pw.address.address1));
- strops::copy(pw.address.country_code, "NL", sizeof(pw.address.country_code));
- strops::copy(pw.address.city, "Maastricht", sizeof(pw.address.city));
- strops::copy(pw.address.region, "Limburg", sizeof(pw.address.region));
- strops::copy(pw.address.postal, "4321AA", sizeof(pw.address.postal));
+ strops::copy(pw.addr.address1, "Address 2", sizeof(pw.addr.address1));
+ strops::copy(pw.addr.country_code, "NL", sizeof(pw.addr.country_code));
+ strops::copy(pw.addr.city, "Maastricht", sizeof(pw.addr.city));
+ strops::copy(pw.addr.region, "Limburg", sizeof(pw.addr.region));
+ strops::copy(pw.addr.postal, "4321AA", sizeof(pw.addr.postal));
strops::copy(pw.email, "test@test.com", sizeof(pw.email));
strops::copy(pw.phone_number, "+317654321", sizeof(pw.phone_number));
pw.type = contact_type::CONTACT_CONSUMER;