Commit 766dc9ee authored by Maxime Doyen's avatar Maxime Doyen

4.5.5 beta

parent 640b99df
This diff is collapsed.
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -66,8 +66,10 @@ struct account_data
Transaction *cur_ope;
guint32 accnum;
Account *acc;
Account *acc;
gboolean do_sort;
/* status counters */
gint hidden, total;
gdouble totalsum;
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -129,8 +129,6 @@ void ui_mainwindow_action(GtkWidget *widget, gpointer user_data);
void ui_mainwindow_toggle_minor(GtkWidget *widget, gpointer user_data);
void ui_mainwindow_clear(GtkWidget *widget, gpointer user_data);
void ui_mainwindow_busy(GtkWidget *widget, gboolean state);
gboolean ui_dialog_msg_savechanges(GtkWidget *widget, gpointer user_data);
void ui_mainwindow_update(GtkWidget *widget, gpointer user_data);
......@@ -234,13 +232,13 @@ static const gchar *ui_info =
" <menuitem action='Save'/>"
" <menuitem action='SaveAs'/>"
" <menuitem action='Revert'/>"
" <separator/>"
" <menuitem action='FileImport'/>"
" <menuitem action='ExportQIF'/>"
//" <separator/>"
// print to come here
" <separator/>"
" <menuitem action='Properties'/>"
" <separator/>"
" <menuitem action='FileImport'/>"
" <menuitem action='ExportQIF'/>"
" <menuitem action='Anonymize'/>"
" <separator/>"
" <menuitem action='Close'/>"
......@@ -425,7 +423,7 @@ GdkPixbuf *pixbuf;
"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
"MA 02110-1301, USA.";
static const gchar *copyright = "Copyright \xc2\xa9 1995-2013 - Maxime DOYEN";
static const gchar *copyright = "Copyright \xc2\xa9 1995-2014 - Maxime DOYEN";
pathfilename = g_build_filename(homebank_app_get_images_dir(), "splash.png", NULL);
......@@ -539,7 +537,7 @@ gboolean result;
static void ui_mainwindow_action_properties(void)
{
create_defhbfile_window();
create_defhbfile_dialog();
ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE));
}
......@@ -617,7 +615,7 @@ GtkTreeModel *model;
static void ui_mainwindow_action_defbudget(void)
{
create_defbudget_window();
ui_bud_manage_dialog();
ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE));
}
......@@ -993,12 +991,10 @@ gboolean file_clear = GPOINTER_TO_INT(user_data);
if(file_clear == TRUE)
{
//ui_start_assistant();
ui_start_assistant();
ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
ui_mainwindow_populate_upcoming(GLOBALS->mainwindow, NULL);
ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL);
ui_mainwindow_action_help_welcome();
}
}
......@@ -1035,6 +1031,9 @@ gint account = 1, count;
ope->date = date;
ope->kacc = account;
if( PREFS->heritdate == FALSE ) //fix: 318733
ope->date = GLOBALS->today;
deftransaction_set_transaction(window, ope);
result = gtk_dialog_run (GTK_DIALOG (window));
......@@ -1051,6 +1050,8 @@ gint account = 1, count;
ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
count++;
//store last date
date = ope->date;
}
da_transaction_free(ope);
......@@ -1089,11 +1090,13 @@ GtkTreeModel *model;
GtkTreeIter iter;
GList *list;
gint range;
guint n_result, i;
guint n_result, i, n_items;
GArray *garray;
gdouble total;
gdouble total, other;
//Account *acc;
#define MAX_TOPSPENDING 5
DB( g_print("\n[ui-mainwindow] populate_topspending\n") );
data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
......@@ -1209,13 +1212,18 @@ next1:
// we need to sort this and limit before
g_array_sort(garray, (GCompareFunc)tmptop_compare_func);
for(i=0 ; i<MIN(garray->len,5) ; i++)
n_items = MIN(garray->len,MAX_TOPSPENDING);
other = 0;
for(i=0 ; i<garray->len ; i++)
{
struct tmptop *item;
item = &g_array_index (garray, struct tmptop, i);
total += item->value;
if(i >= n_items)
other += item->value;
DB( g_print(" - %d : k='%d' v='%f' t='%f'\n", i, item->key, item->value, total) );
}
......@@ -1225,7 +1233,7 @@ next1:
gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_top), NULL); /* Detach model from view */
/* insert into the treeview */
for(i=0 ; i<MIN(garray->len,5) ; i++)
for(i=0 ; i<MIN(garray->len,MAX_TOPSPENDING) ; i++)
{
gchar *name;
Category *entry;
......@@ -1254,6 +1262,19 @@ next1:
}
// append test
if(ABS(other) > 0)
{
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
gtk_list_store_set (GTK_LIST_STORE(model), &iter,
LST_TOPSPEND_ID, n_items,
LST_TOPSPEND_KEY, 0,
LST_TOPSPEND_NAME, _("Other"),
LST_TOPSPEND_AMOUNT, other,
LST_TOPSPEND_RATE, (gint)(((ABS(other)*100)/ABS(total)) + 0.5),
-1);
}
/* Re-attach model to view */
gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_top), model);
g_object_unref(model);
......@@ -1359,12 +1380,8 @@ gint usermode = GPOINTER_TO_INT(user_data);
//data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
ui_mainwindow_busy(widget, TRUE);
count = hbfile_insert_scheduled_transactions();
ui_mainwindow_busy(widget, FALSE);
//inform the user
if(usermode == TRUE)
{
......@@ -1904,45 +1921,6 @@ gint flags;
}
void ui_mainwindow_busy(GtkWidget *widget, gboolean state)
{
struct hbfile_data *data;
GtkWidget *window;
GdkWindow *gdkwindow;
GdkCursor *cursor;
DB( g_print("\n[ui-mainwindow] busy: %d\n", state) );
window = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
data = g_object_get_data(G_OBJECT(window), "inst_data");
gdkwindow = gtk_widget_get_window(window);
// should busy ?
if(state == TRUE)
{
cursor = gdk_cursor_new(GDK_WATCH);
gdk_window_set_cursor(gdkwindow, cursor);
gdk_cursor_unref(cursor);
//gtk_grab_add(data->busy_popup);
gtk_widget_set_sensitive(window, FALSE);
gtk_action_group_set_sensitive(data->actions, FALSE);
/* make sure chnages is up */
while (gtk_events_pending ())
gtk_main_iteration ();
}
// unbusy
else
{
gtk_widget_set_sensitive(window, TRUE);
gtk_action_group_set_sensitive(data->actions, TRUE);
gdk_window_set_cursor(gdkwindow, NULL);
//gtk_grab_remove(data->busy_popup);
}
}
static void
......@@ -2440,7 +2418,6 @@ GtkWidget *label, *align, *widget;
data->TX_topamount = label;
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
data->CY_range = make_daterange(label, FALSE);
gtk_box_pack_end (GTK_BOX (hbox), data->CY_range, FALSE, FALSE, 0);
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -21,7 +21,7 @@
#include "gtk-chart-colors.h"
char *chart_colors[] =
const char *chart_colors[] =
{
"HomeBank",
"Money",
......@@ -34,8 +34,6 @@ char *chart_colors[] =
};
struct rgbcol money_colors[] =
{
{ 255, 193, 96 },
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -20,20 +20,22 @@
#ifndef __GTK_COLORS_H__
#define __GTK_COLORS_H__
#include <cairo.h>
#define MASKCOL 255
#define COLTO16(col8) ( (col8 | col8<<8 ) )
#define COLTOOVER(col8) ( (col8 + MASKCOL) / 2 )
#define OVER_ALPHA .33
#define OVER_ALPHA .15
#define OVER_COLOR (MASKCOL * OVER_ALPHA)
#define COLTOCAIRO(col8) ( (col8 / 255.0) )
#define COLTOCAIROOVER(col8) ( ((col8 * (1 - OVER_ALPHA)) + OVER_COLOR ) / 255.0 )
/* new stuff */
#define CHART_FONT_SIZE_NORMAL 10
#define CHART_FONT_SIZE_TITLE 16
#define CHART_FONT_SIZE_PERIOD 12
#define CHART_FONT_SIZE_TITLE 18
#define CHART_FONT_SIZE_PERIOD 11
//typedef struct _rgbcol RgbCol;
......@@ -64,7 +66,7 @@ enum colmap
CHART_COLMAP_ANALYTICS,
};
extern char *chart_colors[];
extern const char *chart_colors[];
extern struct rgbcol global_colors[];
extern struct rgbcol money_colors[];
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -27,6 +27,8 @@
#include "gtk-chart.h"
#define HELPDRAW 0
#define MYDEBUG 0
#if MYDEBUG
......@@ -35,8 +37,6 @@
#define DB(x);
#endif
#define HELPDRAW 0
static void gtk_chart_class_init (GtkChartClass *klass);
static void gtk_chart_init (GtkChart *chart);
static void gtk_chart_destroy (GtkObject *chart);
......@@ -1247,7 +1247,8 @@ cairo_t *cr;
a1 = ((360 * (sum / chart->total)) - 90) * (M_PI / 180);
sum += ABS(chart->datas1[i]);
a2 = ((360 * (sum / chart->total)) - 90) * (M_PI / 180);
if(i < chart->entries-1) a2 += 0.0175;
dx = cx;
dy = cy;
......@@ -1332,7 +1333,7 @@ cairo_t *cr;
#if CHART_PIE_DONUT == 1
a1 = 0;
a2 = 2 * M_PI;
radius = chart->rayon/4;
radius = (gint)((chart->rayon/3) * (1 / PHI));
cairo_arc(cr, cx, cy, radius, a1, a2);
cairo_user_set_rgbcol(cr, &global_colors[WHITE]);
......@@ -1391,6 +1392,7 @@ double h;
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
......@@ -1400,7 +1402,7 @@ static void chart_sizeallocate(GtkWidget *widget, GtkAllocation *allocation, gpo
GtkChart *chart = GTK_CHART(user_data);
DB( g_print("\n[gtkchart] sizeallocate\n") );
DB( g_print("w=%d h=%d\n", widget->allocation.width, widget->allocation.height) );
DB( g_print("w=%d h=%d\n", allocation->width, allocation->height) );
chart_calculation(chart);
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -702,7 +702,7 @@ GtkDateEntry *dateentry = user_data;
DB( g_print("\n[dateentry] entry key pressed: state=%04x, keyval=%04x\n", event->state, event->keyval) );
if( event->keyval == GDK_Up )
if( event->keyval == GDK_KEY_Up )
{
if( !(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) )
{
......@@ -724,7 +724,7 @@ GtkDateEntry *dateentry = user_data;
return TRUE;
}
else
if( event->keyval == GDK_Down )
if( event->keyval == GDK_KEY_Down )
{
if( !(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) )
{
......@@ -876,7 +876,7 @@ GtkDateEntry *dateentry = user_data;
DB( g_print("\n[dateentry] key pressed%d\n", event->keyval) );
if (event->keyval != GDK_Escape)
if (event->keyval != GDK_KEY_Escape)
return FALSE;
g_signal_stop_emission_by_name (widget, "key_press_event");
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -233,6 +233,23 @@ da_asg_get(guint32 key)
}
static gint
assign_glist_key_compare_func(Assign *a, Assign *b)
{
return a->key - b->key;
}
GList *assign_glist_sorted(gint column)
{
GList *list = g_hash_table_get_values(GLOBALS->h_rul);
//if(column == 0)
return g_list_sort(list, (GCompareFunc)assign_glist_key_compare_func);
//else
// return g_list_sort(list, (GCompareFunc)assign_glist_name_compare_func);
}
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -52,5 +52,7 @@ guint32 da_asg_get_max_key(void);
Assign *da_asg_get_by_name(gchar *name);
Assign *da_asg_get(guint32 key);
GList *assign_glist_sorted(gint column);
#endif
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......
/* HomeBank -- Free, easy, personal accounting for everyone.
* Copyright (C) 1995-2013 Maxime DOYEN
* Copyright (C) 1995-2014 Maxime DOYEN
*
* This file is part of HomeBank.
*
......@@ -33,4 +33,243 @@
/* our global datas */
extern struct HomeBank *GLOBALS;
extern struct Preferences *PREFS;
/* = = = = = = = = = = = = = = = = = = = = */
static void hb_export_qif_elt_txn(GIOChannel *io, Account *acc)
{
GString *elt;
GList *list;
GDate *date;
char amountbuf[G_ASCII_DTOSTR_BUF_SIZE];
gint count, i;
elt = g_string_sized_new(255);
date = g_date_new ();
list = g_list_first(GLOBALS->ope_list);
while (list != NULL)
{
Transaction *txn = list->data;
Payee *payee;
Category *cat;
gchar *txt;
if( txn->kacc == acc->key )
{
g_date_set_julian (date, txn->date);
//#1270876
switch(PREFS->dtex_datefmt)
{
case 0: //"m-d-y"
g_string_append_printf (elt, "D%02d/%02d/%04d\n",
g_date_get_month(date),
g_date_get_day(date),
g_date_get_year(date)
);
break;
case 1: //"d-m-y"
g_string_append_printf (elt, "D%02d/%02d/%04d\n",
g_date_get_day(date),
g_date_get_month(date),
g_date_get_year(date)
);
break;
case 2: //"y-m-d"
g_string_append_printf (elt, "D%04d/%02d/%02d\n",
g_date_get_year(date),
g_date_get_month(date),
g_date_get_day(date)
);
break;
}
//g_ascii_dtostr (amountbuf, sizeof (amountbuf), txn->amount);
g_ascii_formatd (amountbuf, sizeof (amountbuf), "%.2f", txn->amount);
g_string_append_printf (elt, "T%s\n", amountbuf);
g_string_append_printf (elt, "C%s\n", txn->flags & OF_VALID ? "R" : "");
if( txn->paymode == PAYMODE_CHECK)
g_string_append_printf (elt, "N%s\n", txn->info);
//Ppayee
payee = da_pay_get(txn->kpay);
if(payee)
g_string_append_printf (elt, "P%s\n", payee->name);
// Mmemo
g_string_append_printf (elt, "M%s\n", txn->wording);
// LCategory of transaction
// L[Transfer account name]
// LCategory of transaction/Class of transaction
// L[Transfer account]/Class of transaction
if( txn->paymode == PAYMODE_INTXFER && txn->kacc == acc->key)
{
//#579260
Account *dstacc = da_acc_get(txn->kxferacc);
if(dstacc)
g_string_append_printf (elt, "L[%s]\n", dstacc->name);
}
else
{
cat = da_cat_get(txn->kcat);
if(cat)
{
txt = da_cat_get_fullname(cat);
g_string_append_printf (elt, "L%s\n", txt);
g_free(txt);
}
}
// splits
count = da_transaction_splits_count(txn);
for(i=0;i<count;i++)
{
Split *s = txn->splits[i];
cat = da_cat_get(s->kcat);
if(cat)
{
txt = da_cat_get_fullname(cat);
g_string_append_printf (elt, "S%s\n", txt);
g_free(txt);
}
g_string_append_printf (elt, "E%s\n", s->memo);
g_ascii_formatd (amountbuf, sizeof (amountbuf), "%.2f", s->amount);
g_string_append_printf (elt, "$%s\n", amountbuf);
}
g_string_append (elt, "^\n");
}
list = g_list_next(list);
}
g_io_channel_write_chars(io, elt->str, -1, NULL, NULL);
g_string_free(elt, TRUE);
g_date_free(date);
}
static void hb_export_qif_elt_acc(GIOChannel *io, Account *acc)
{
GString *elt;
gchar *type;
elt = g_string_sized_new(255);
// account export
//#987144 fixed account type
switch(acc->type)
{
case ACC_TYPE_BANK : type = "Bank"; break;
case ACC_TYPE_CASH : type = "Cash"; break;
case ACC_TYPE_ASSET : type = "Oth A"; break;
case ACC_TYPE_CREDITCARD : type = "CCard"; break;
case ACC_TYPE_LIABILITY : type = "Oth L"; break;
default : type = "Bank"; break;
}
g_string_assign(elt, "!Account\n");
g_string_append_printf (elt, "N%s\n", acc->name);
g_string_append_printf (elt, "T%s\n", type);
g_string_append (elt, "^\n");
g_string_append_printf (elt, "!Type:%s\n", type);
g_io_channel_write_chars(io, elt->str, -1, NULL, NULL);
g_string_free(elt, TRUE);
}
void hb_export_qif_account_single(gchar *filename, Account *acc)
{
GIOChannel *io;
gchar *newname;
newname = homebank_filepath_with_extention(filename, "qif");
io = g_io_channel_new_file(newname, "w", NULL);
if(io == NULL)
{
g_message("file error on: %s", newname);
//retval = XML_IO_ERROR;
}
else
{
hb_export_qif_elt_acc(io, acc);
hb_export_qif_elt_txn(io, acc);
g_io_channel_unref (io);
}
g_free(newname);
}
void hb_export_qif_account_all(gchar *filename)