From 026e38982f5388cede0cd7ebad2ea7571d1d57ed Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 7 Sep 2025 08:39:01 +0200 Subject: income statement generation --- include/administration.hpp | 53 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) (limited to 'include/administration.hpp') diff --git a/include/administration.hpp b/include/administration.hpp index 015b1c3..45effee 100644 --- a/include/administration.hpp +++ b/include/administration.hpp @@ -20,6 +20,9 @@ #define MAX_LEN_BUSINESSID 32 #define MAX_LEN_TAX_SECTION 16 +#define MAX_LEN_INCOME_STATEMENT_REPORT_QUARTERS 400 +#define MAX_LEN_QUARTERLY_REPORT_PROJECTS 200 +#define MAX_LEN_PROJECT_REPORT_COSTCENTERS 50 #define MAX_BILLING_ITEMS 50 typedef struct @@ -237,7 +240,7 @@ typedef struct time_t expires_at; time_t delivered_at; char document[MAX_LEN_PATH]; // path to copy of document for incomming invoice. - char project_id[MAX_LEN_ID]; // For incomming invoices. optional. + char project_id[MAX_LEN_ID]; // Optional. char cost_center_id[MAX_LEN_ID]; // For incomming invoices. optional. list_t billing_items; @@ -263,6 +266,43 @@ typedef struct contact customer; } invoice; +typedef struct +{ + char cost_center_id[MAX_LEN_ID]; + char description[MAX_LEN_LONG_DESC]; + float total; +} project_expense; + +typedef struct +{ + char project_id[MAX_LEN_ID]; + char description[MAX_LEN_LONG_DESC]; + u32 expense_count; + project_expense expenses[MAX_LEN_PROJECT_REPORT_COSTCENTERS]; + float expenses_total; // Sum of all expenses. (incl uncategorized) + float revenue; + float taxes; +} project_report; + +typedef struct +{ + float uncategorized_expenses; // Sum of expenses without project. + float uncategorized_revenue; + float uncategorized_taxes; + + u32 report_count; + project_report reports[MAX_LEN_QUARTERLY_REPORT_PROJECTS]; + u16 year; // 00-99 + u8 quarter; // 0-3 + char quarter_str[MAX_LEN_SHORT_DESC]; +} quarterly_report; + +typedef struct +{ + u32 quarter_count; + quarterly_report quarters[MAX_LEN_INCOME_STATEMENT_REPORT_QUARTERS]; +} income_statement; + typedef struct { contact company_info; // Company info used for invoices. User cannot create invoices when this is empty/invalid. @@ -286,12 +326,13 @@ typedef struct void administration_create(); void administration_destroy(); -// General functions. +// Other functions. // ======================= -administration* administation_get(); +administration* administration_get(); char* administration_file_path_get(); contact administration_company_info_get(); void administration_company_info_set(contact data); +void administration_create_income_statement(income_statement* statement); // Contact functions. // ======================= @@ -324,6 +365,7 @@ bool administration_project_is_valid(project data); char* administration_project_get_status_string(project data); u32 administration_project_get_all(project* buffer); u32 administration_project_get_partial_list(u32 page_index, u32 page_size, project* buffer); +bool administration_project_get_by_id(project* buffer, char* id); // Tax bracket functions. // ======================= @@ -345,12 +387,13 @@ bool administration_cost_center_verify_code(char* code); bool administration_cost_center_verify_description(char* text); u32 administration_cost_center_get_all(cost_center* buffer); +bool administration_cost_center_get_by_id(cost_center* buffer, char* id); // Invoice functions. // ======================= u32 administration_invoice_count(); -u32 administation_invoice_get_incomming_count(); -u32 administation_invoice_get_outgoing_count(); +u32 administration_invoice_get_incomming_count(); +u32 administration_invoice_get_outgoing_count(); invoice administration_invoice_create_empty(); bool administration_invoice_add(invoice* invoice); bool administration_invoice_update(invoice* invoice); -- cgit v1.2.3-70-g09d2