From d8a9d534a5a39fd3d51a6ffaf92fde39a4b4077c Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 13 Sep 2025 12:40:22 +0200 Subject: save file import: contact, project, tax brackets, cost centers, administration info --- include/administration.hpp | 16 +++++++++++++--- include/administration_reader.hpp | 9 ++++++++- include/file_templates.hpp | 15 ++++++++------- include/strops.hpp | 3 ++- 4 files changed, 31 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/administration.hpp b/include/administration.hpp index b971e2c..fe3d7b2 100644 --- a/include/administration.hpp +++ b/include/administration.hpp @@ -25,6 +25,8 @@ #define MAX_LEN_PROJECT_REPORT_COSTCENTERS 50 #define MAX_BILLING_ITEMS 50 +#define MY_COMPANY_ID "C/1" + typedef struct { char id[MAX_LEN_ID]; // T/[id] @@ -63,7 +65,7 @@ typedef struct address address; contact_type type; char taxid[MAX_LEN_TAXID]; // Required for business contact - char businessid[MAX_LEN_TAXID]; // Required for business contact + char businessid[MAX_LEN_BUSINESSID]; // Required for business contact char email[MAX_LEN_EMAIL]; char phone_number[MAX_LEN_PHONE]; char bank_account[MAX_LEN_BANK]; @@ -308,6 +310,8 @@ typedef struct } income_statement; // Administration callback functions. +// These are called when adding/updating/deleting entries. +// These are NOT called when using import functions. typedef void (*data_changed_event)(); typedef void (*data_deleted_event)(char id[MAX_LEN_ID]); typedef void (*invoice_changed_event)(invoice* invoice); @@ -338,9 +342,10 @@ typedef struct // Setup functions. // ======================= -void administration_create(); -void administration_destroy(); +void administration_create(); // TODO remove and move into other setup functions +void administration_destroy(); // TODO remove and move into other setup functions void administration_create_empty(char* save_file); +void administration_create_from_file(char* save_file); // Callback functions. // ======================= @@ -357,6 +362,7 @@ void administration_set_project_changed_event_callback(project_changed_event administration* administration_get(); // TODO get rid of this and make indivual getters and setters char* administration_file_path_get(); contact administration_company_info_get(); +void administration_company_info_import(contact data); void administration_company_info_set(contact data); void administration_create_income_statement(income_statement* statement); char* administration_get_currency_symbol_from_currency(char* code); @@ -368,6 +374,7 @@ bool administration_has_save_path(); // ======================= u32 administration_contact_count(); contact administration_contact_create_empty(); +bool administration_contact_import(contact data); bool administration_contact_add(contact data); bool administration_contact_update(contact data); bool administration_contact_remove(contact data); @@ -385,6 +392,7 @@ u32 administration_contact_get_all(contact* buffer); // ======================= u32 administration_project_count(); project administration_project_create_empty(); +bool administration_project_import(project data); bool administration_project_add(project data); bool administration_project_update(project data); bool administration_project_remove(project data); @@ -400,6 +408,7 @@ bool administration_project_get_by_id(project* buffer, char* id); // Tax bracket functions. // ======================= u32 administration_tax_bracket_count(); +bool administration_tax_bracket_import(country_tax_bracket data); bool administration_tax_bracket_add(country_tax_bracket data); bool administration_tax_bracket_update(country_tax_bracket data); @@ -410,6 +419,7 @@ u32 administration_tax_bracket_get_by_country(country_tax_bracket* buffer, c // Cost center functions. // ======================= u32 administration_cost_center_count(); +bool administration_cost_center_import(cost_center data); bool administration_cost_center_add(cost_center data); bool administration_cost_center_update(cost_center data); diff --git a/include/administration_reader.hpp b/include/administration_reader.hpp index 528cc40..ed932bc 100644 --- a/include/administration_reader.hpp +++ b/include/administration_reader.hpp @@ -1,3 +1,10 @@ #pragma once -bool administration_reader_open_new(); \ No newline at end of file +bool administration_reader_open_new(); +bool administration_reader_open_existing(char* file_path); + +bool administration_reader_import_administration_info(char* buffer, size_t buffer_size); +bool administration_reader_import_tax_bracket(char* buffer, size_t buffer_size); +bool administration_reader_import_cost_center(char* buffer, size_t buffer_size); +bool administration_reader_import_project(char* buffer, size_t buffer_size); +bool administration_reader_import_contact(char* buffer, size_t buffer_size); \ No newline at end of file diff --git a/include/file_templates.hpp b/include/file_templates.hpp index de3f509..cb89050 100644 --- a/include/file_templates.hpp +++ b/include/file_templates.hpp @@ -5,22 +5,22 @@ const char* project_save_template = " {{PROJECT_STATE}}\n" " {{PROJECT_STARTDATE}}\n" " {{PROJECT_ENDDATE}}\n" -"\n"; +""; const char* costcenter_save_template = "\n" " {{COSTCENTER_ID}}\n" " {{COSTCENTER_CODE}}\n" " {{COSTCENTER_DESCRIPTION}}\n" -"\n"; +""; const char* taxbracket_save_template = "\n" " {{TAXBRACKET_ID}}\n" " {{TAXBRACKET_COUNTRY}}\n" " {{TAXBRACKET_RATE}}\n" -" {{TAXBRACKET_CATEGORY}}\n" -"\n"; +" {{TAXBRACKET_CATEGORY}}\n" +""; const char* contact_save_template = "\n" @@ -40,14 +40,15 @@ const char* contact_save_template = " {{CONTACT_POSTAL}}\n" " {{CONTACT_REGION}}\n" " \n" -"\n"; +""; const char* administration_save_template = "\n" " {{NEXT_ID}}\n" +" {{COMPANY_ID}}\n" " {{NEXT_SEQUENCE_NUMBER}}\n" " {{PROGRAM_VERSION}}\n" -"\n"; +""; const char* peppol_invoice_tax_subtotal_template = " \n" @@ -173,4 +174,4 @@ const char *peppol_invoice_template = "\n" " {{INVOICE_LINE_LIST}}" "\n" -"\n"; +""; diff --git a/include/strops.hpp b/include/strops.hpp index 2874c4d..412becc 100644 --- a/include/strops.hpp +++ b/include/strops.hpp @@ -6,4 +6,5 @@ char* strops_stristr(char* a, char* b); void strops_replace(char *buf, size_t buf_size, const char *search, const char *replace); void strops_replace_int32(char *buf, size_t buf_size, const char *search, int32_t number); void strops_replace_int64(char *buf, size_t buf_size, const char *search, int64_t number); -void strops_replace_float(char *buf, size_t buf_size, const char *search, float number, int decimals); \ No newline at end of file +void strops_replace_float(char *buf, size_t buf_size, const char *search, float number, int decimals); +bool strops_prefix(const char *pre, const char *str); \ No newline at end of file -- cgit v1.2.3-70-g09d2