1 /* HomeBank -- Free, easy, personal accounting for everyone. 2 * Copyright (C) 1995-2021 Maxime DOYEN 3 * 4 * This file is part of HomeBank. 5 * 6 * HomeBank is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * HomeBank is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __HB_REPORT_H__ 21 #define __HB_REPORT_H__ 22 23 24 typedef enum 25 { 26 REPORT_SRC_CATEGORY, 27 REPORT_SRC_SUBCATEGORY, 28 REPORT_SRC_PAYEE, 29 REPORT_SRC_ACCOUNT, 30 REPORT_SRC_TAG, 31 REPORT_SRC_MONTH, 32 REPORT_SRC_YEAR, 33 } HbReportSrc; 34 35 36 typedef enum { 37 REPORT_TYPE_EXPENSE, 38 REPORT_TYPE_INCOME, 39 REPORT_TYPE_TOTAL 40 } HbReportType; 41 42 43 typedef enum 44 { 45 REPORT_INTVL_DAY, 46 REPORT_INTVL_WEEK, 47 REPORT_INTVL_MONTH, 48 REPORT_INTVL_QUARTER, 49 REPORT_INTVL_HALFYEAR, 50 REPORT_INTVL_YEAR, 51 } HbReportIntvl; 52 53 54 typedef enum 55 { 56 REPORT_RESULT_TOTAL, 57 REPORT_RESULT_CUMUL, 58 REPORT_RESULT_BALANCE, 59 } HbReportResult; 60 61 62 typedef struct _datatable DataTable; 63 typedef struct _datarow DataRow; 64 65 66 typedef struct _carcost CarCost; 67 68 struct _carcost 69 { 70 guint32 kparent; 71 guint32 kcat; 72 guint32 date; 73 gchar *memo; 74 gdouble amount; 75 gboolean partial; 76 guint meter; 77 gdouble fuel; 78 guint dist; 79 }; 80 81 82 CarCost *da_vehiclecost_malloc(void); 83 void da_vehiclecost_free(CarCost *item); 84 void da_vehiclecost_destroy(GList *list); 85 86 void da_datatable_free(DataTable *dt); 87 DataTable *da_datatable_malloc(gshort type, guint32 nbrows, guint32 nbcols); 88 89 void datatable_init_items(DataTable *dt, gint src, guint32 jfrom); 90 91 void datatable_amount_add(DataTable *dt, guint32 idx, gdouble value); 92 93 94 DataTable *report_compute_total(gint tmpsrc, Filter *flt, GQueue *txn_queue); 95 DataTable *report_compute_trend(gint tmpsrc, gint tmpintvl, Filter *flt, GQueue *txn_queue); 96 97 gint report_items_count(gint src, guint32 jfrom, guint32 jto); 98 gint report_items_get_pos(gint tmpsrc, guint jfrom, Transaction *ope); 99 100 gint report_interval_get_pos(gint intvl, guint jfrom, Transaction *ope); 101 gint report_interval_count(gint intvl, guint32 jfrom, guint32 jto); 102 void report_interval_snprint_name(gchar *s, gint slen, gint intvl, guint32 jfrom, gint idx); 103 104 gdouble report_acc_initbalance_get(Filter *flt); 105 gdouble report_txn_amount_get(Filter *flt, Transaction *txn); 106 107 108 struct _datarow 109 { 110 guint32 key; 111 guint32 pos; 112 //gint type; 113 gchar *label; //row label 114 115 //todo: for total mode: I should just keep some simple gdouble inc/exp here 116 //and do not allocate extra memory for nothing 117 118 gdouble *expense; //array for each row column 119 gdouble *income; 120 //gdouble *value; 121 }; 122 123 124 struct _datatable 125 { 126 gshort mode; //0=total / 1=time 127 128 guint32 nbrows; //nb of items: cat/subcat/pay/acc/... 129 guint32 nbcols; //nb of intervals: d, w, m, q, hy, y 130 131 DataRow **rows; //array of _datarow struct per key of item 132 //gchar **coltitle; //array of column title 133 134 DataRow *totrow; //for trend 135 136 gdouble totexp; 137 gdouble totinc; 138 }; 139 140 141 #endif 142 143