]> Dogcows Code - chaz/homebank/blob - src/hb-export.c
import homebank-5.1.7
[chaz/homebank] / src / hb-export.c
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2018 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 #include "homebank.h"
21 #include "hb-export.h"
22
23 /****************************************************************************/
24 /* Debug macros */
25 /****************************************************************************/
26 #define MYDEBUG 0
27
28 #if MYDEBUG
29 #define DB(x) (x);
30 #else
31 #define DB(x);
32 #endif
33
34 /* our global datas */
35 extern struct HomeBank *GLOBALS;
36 extern struct Preferences *PREFS;
37
38 /* = = = = = = = = = = = = = = = = = = = = */
39
40 static void hb_export_qif_elt_txn(GIOChannel *io, Account *acc)
41 {
42 GString *elt;
43 GList *list;
44 GDate *date;
45 char amountbuf[G_ASCII_DTOSTR_BUF_SIZE];
46 gchar *sbuf;
47 gint count, i;
48
49 elt = g_string_sized_new(255);
50
51 date = g_date_new ();
52
53 list = g_queue_peek_head_link(acc->txn_queue);
54 while (list != NULL)
55 {
56 Transaction *txn = list->data;
57 Payee *payee;
58 Category *cat;
59 gchar *txt;
60
61 g_date_set_julian (date, txn->date);
62 //#1270876
63 switch(PREFS->dtex_datefmt)
64 {
65 case 0: //"m-d-y"
66 g_string_append_printf (elt, "D%02d/%02d/%04d\n",
67 g_date_get_month(date),
68 g_date_get_day(date),
69 g_date_get_year(date)
70 );
71 break;
72 case 1: //"d-m-y"
73 g_string_append_printf (elt, "D%02d/%02d/%04d\n",
74 g_date_get_day(date),
75 g_date_get_month(date),
76 g_date_get_year(date)
77 );
78 break;
79 case 2: //"y-m-d"
80 g_string_append_printf (elt, "D%04d/%02d/%02d\n",
81 g_date_get_year(date),
82 g_date_get_month(date),
83 g_date_get_day(date)
84 );
85 break;
86 }
87
88 //g_ascii_dtostr (amountbuf, sizeof (amountbuf), txn->amount);
89 g_ascii_formatd (amountbuf, sizeof (amountbuf), "%.2f", txn->amount);
90 g_string_append_printf (elt, "T%s\n", amountbuf);
91
92 sbuf = "";
93 if(txn->status == TXN_STATUS_CLEARED)
94 sbuf = "c";
95 else
96 if(txn->status == TXN_STATUS_RECONCILED)
97 sbuf = "R";
98
99 g_string_append_printf (elt, "C%s\n", sbuf);
100
101 if( txn->paymode == PAYMODE_CHECK)
102 g_string_append_printf (elt, "N%s\n", txn->info);
103
104 //Ppayee
105 payee = da_pay_get(txn->kpay);
106 if(payee)
107 g_string_append_printf (elt, "P%s\n", payee->name);
108
109 // Mmemo
110 g_string_append_printf (elt, "M%s\n", txn->memo);
111
112 // LCategory of transaction
113 // L[Transfer account name]
114 // LCategory of transaction/Class of transaction
115 // L[Transfer account]/Class of transaction
116 if( txn->paymode == PAYMODE_INTXFER && txn->kacc == acc->key)
117 {
118 //#579260
119 Account *dstacc = da_acc_get(txn->kxferacc);
120 if(dstacc)
121 g_string_append_printf (elt, "L[%s]\n", dstacc->name);
122 }
123 else
124 {
125 cat = da_cat_get(txn->kcat);
126 if(cat)
127 {
128 txt = da_cat_get_fullname(cat);
129 g_string_append_printf (elt, "L%s\n", txt);
130 g_free(txt);
131 }
132 }
133
134 // splits
135 count = da_splits_count(txn->splits);
136 for(i=0;i<count;i++)
137 {
138 Split *s = txn->splits[i];
139
140 cat = da_cat_get(s->kcat);
141 if(cat)
142 {
143 txt = da_cat_get_fullname(cat);
144 g_string_append_printf (elt, "S%s\n", txt);
145 g_free(txt);
146 }
147
148 g_string_append_printf (elt, "E%s\n", s->memo);
149
150 g_ascii_formatd (amountbuf, sizeof (amountbuf), "%.2f", s->amount);
151 g_string_append_printf (elt, "$%s\n", amountbuf);
152 }
153
154 g_string_append (elt, "^\n");
155
156
157 list = g_list_next(list);
158 }
159
160 g_io_channel_write_chars(io, elt->str, -1, NULL, NULL);
161
162 g_string_free(elt, TRUE);
163
164 g_date_free(date);
165
166 }
167
168
169
170 static void hb_export_qif_elt_acc(GIOChannel *io, Account *acc)
171 {
172 GString *elt;
173 gchar *type;
174
175 elt = g_string_sized_new(255);
176
177 // account export
178 //#987144 fixed account type
179 switch(acc->type)
180 {
181 case ACC_TYPE_BANK : type = "Bank"; break;
182 case ACC_TYPE_CASH : type = "Cash"; break;
183 case ACC_TYPE_ASSET : type = "Oth A"; break;
184 case ACC_TYPE_CREDITCARD : type = "CCard"; break;
185 case ACC_TYPE_LIABILITY : type = "Oth L"; break;
186 default : type = "Bank"; break;
187 }
188
189 g_string_assign(elt, "!Account\n");
190 g_string_append_printf (elt, "N%s\n", acc->name);
191 g_string_append_printf (elt, "T%s\n", type);
192 g_string_append (elt, "^\n");
193 g_string_append_printf (elt, "!Type:%s\n", type);
194
195 g_io_channel_write_chars(io, elt->str, -1, NULL, NULL);
196
197 g_string_free(elt, TRUE);
198 }
199
200
201 void hb_export_qif_account_single(gchar *filename, Account *acc)
202 {
203 GIOChannel *io;
204
205 io = g_io_channel_new_file(filename, "w", NULL);
206 if(io == NULL)
207 {
208 g_message("file error on: %s", filename);
209 //retval = XML_IO_ERROR;
210 }
211 else
212 {
213 hb_export_qif_elt_acc(io, acc);
214 hb_export_qif_elt_txn(io, acc);
215 g_io_channel_unref (io);
216 }
217 }
218
219
220 void hb_export_qif_account_all(gchar *filename)
221 {
222 GIOChannel *io;
223 GList *lacc, *list;
224
225 io = g_io_channel_new_file(filename, "w", NULL);
226 if(io == NULL)
227 {
228 g_message("file error on: %s", filename);
229 //retval = XML_IO_ERROR;
230 }
231 else
232 {
233 //todo: save accounts in order
234 //todo: save transfer transaction once
235
236 lacc = list = g_hash_table_get_values(GLOBALS->h_acc);
237 while (list != NULL)
238 {
239 Account *item = list->data;
240
241 hb_export_qif_elt_acc(io, item);
242 hb_export_qif_elt_txn(io, item);
243
244 list = g_list_next(list);
245 }
246 g_list_free(lacc);
247
248 g_io_channel_unref (io);
249 }
250
251 }
252
253
254 /* = = = = = = = = beta feature version = = = = = = = = */
255
256 //static GtkPrintSettings *settings = NULL;
257 //static GtkPageSetup *page_setup = NULL;
258
259
260 static void papersize(PdfPrintContext *ppc)
261 {
262 //GList *list, *item;
263 const gchar *name;
264 GtkPaperSize *ps;
265
266 DB( g_print("[papersize]\n") );
267
268 name = gtk_paper_size_get_default();
269
270 DB( g_print("- def paper is %s\n", name) );
271
272 ps = gtk_paper_size_new(name);
273
274
275
276 /*GtkPageSetup *new_page_setup;
277
278 if (settings == NULL)
279 settings = gtk_print_settings_new ();
280
281 new_page_setup = gtk_print_run_page_setup_dialog (NULL,
282 page_setup, settings);
283
284 if (page_setup)
285 g_object_unref (page_setup);
286
287 page_setup = new_page_setup;
288 */
289
290 //#if MYDEBUG == 1
291 gdouble w, h, mt, mb, ml, mr;
292 w = gtk_paper_size_get_width(ps, GTK_UNIT_MM);
293 h = gtk_paper_size_get_height(ps, GTK_UNIT_MM);
294 mt = gtk_paper_size_get_default_top_margin(ps, GTK_UNIT_MM);
295 mr = gtk_paper_size_get_default_right_margin(ps, GTK_UNIT_MM);
296 mb = gtk_paper_size_get_default_bottom_margin(ps, GTK_UNIT_MM);
297 ml = gtk_paper_size_get_default_left_margin(ps, GTK_UNIT_MM);
298
299 DB( g_print("- name: %s\n", gtk_paper_size_get_display_name(ps)) );
300 DB( g_print("- w: %f (%f)\n- h: %f (%f)\n", w, w/PANGO_SCALE, h, h/PANGO_SCALE) );
301 DB( g_print("- margin: %f %f %f %f\n", mt, mr, mb, ml) );
302
303 ppc->w = w * 2.83;
304 ppc->h = h * 2.83;
305 ppc->mt = mt * 2.83;
306 ppc->mr = mr * 2.83;
307 ppc->mb = mb * 2.83;
308 ppc->ml = ml * 2.83;
309
310 //#endif
311
312 gtk_paper_size_free(ps);
313
314 /* list all paper size */
315 /*
316 list = gtk_paper_size_get_paper_sizes (FALSE);
317 item = g_list_first(list);
318 while(item != NULL)
319 {
320 ps = item->data;
321 if(ps != NULL)
322 {
323 g_print("- name: %s\n", gtk_paper_size_get_display_name(ps));
324 gtk_paper_size_free(ps);
325 }
326 item = g_list_next(item);
327 }
328 g_list_free (list);
329 */
330 }
331
332
333 #define FONT "Helvetica 9px"
334
335 //#define PDF_MARGIN 24
336 #define PDF_COL_MARGIN 8
337 #define PDF_LINE_MARGIN 2
338 #define PDF_FONT_NORMAL 9
339 #define PDF_FONT_TITLE 12
340
341
342 #define HELPDRAW 0
343 #define RULEHINT 1
344
345 #define HEX_R(xcol) (((xcol>>24) & 0xFF)/255)
346 #define HEX_G(xcol) (((xcol>>16) & 0xFF)/255)
347 #define HEX_B(xcol) (((xcol>> 8) & 0xFF)/255)
348
349
350 #if HELPDRAW == 1
351 static void hb_pdf_draw_help_rect(cairo_t *cr, gint32 xcol, double x, double y, double w, double h)
352 {
353 cairo_save (cr);
354
355 cairo_set_line_width(cr, 1.0);
356 cairo_set_source_rgba(cr, HEX_R(xcol), HEX_G(xcol), HEX_B(xcol), 1.0); //alpha is unused for now
357 cairo_rectangle (cr, x, y, w, h);
358 cairo_stroke(cr);
359
360 cairo_restore(cr);
361 }
362 #endif
363
364
365
366
367 static void hb_pdf_draw_line(PdfPrintContext *ppc, cairo_t *cr, gdouble y, gboolean bold, gboolean rulehint)
368 {
369 PangoLayout *layout;
370 gint i;
371 gdouble x;
372
373 /* Create a PangoLayout, set the font and text */
374 layout = pango_cairo_create_layout (cr);
375
376 //desc = pango_font_description_from_string (FONT);
377 if(bold)
378 pango_font_description_set_weight(ppc->desc, PANGO_WEIGHT_BOLD);
379 else
380 pango_font_description_set_weight(ppc->desc, PANGO_WEIGHT_NORMAL);
381
382 pango_layout_set_font_description (layout, ppc->desc);
383
384
385 x = ppc->ml;
386
387 /* rule hint */
388 #if RULEHINT == 1
389 if( rulehint )
390 {
391 cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
392 cairo_rectangle (cr, x, y, ppc->w - ppc->ml - ppc->mr, PDF_FONT_NORMAL);
393 cairo_fill(cr);
394 }
395 #endif
396
397
398 cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
399 cairo_move_to(cr, x, y);
400
401 for(i=0;i<PDF_NUMCOL;i++)
402 {
403 if(ppc->column_txt[i] != NULL)
404 {
405 int width, height;
406
407 pango_layout_set_text (layout, ppc->column_txt[i], -1);
408 pango_layout_get_size (layout, &width, &height);
409 if( i==1 || i==2 || i==3 )
410 {
411 pango_layout_set_width(layout, ppc->column_width[i]*PANGO_SCALE);
412 pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
413 }
414
415 //cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
416
417 if( i==0 || i==4 || i==6 ) // pad right: date/amount/balance
418 {
419 //if(*ppc->column_txt[i] != '-')
420 //cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.66); //grey
421 cairo_move_to(cr, x + ppc->column_width[i] - (width/PANGO_SCALE) , y);
422 }
423 else
424 cairo_move_to(cr, x, y);
425
426 pango_cairo_show_layout (cr, layout);
427
428 /* test line */
429 /*cairo_set_line_width(cr, 1.0);
430 cairo_move_to(cr, x, y + .5);
431 cairo_line_to(cr, x + ppc->column_width[i], y+.5);
432 cairo_stroke(cr);
433 */
434
435 }
436 x += ppc->column_width[i] + PDF_COL_MARGIN;
437 }
438
439 g_object_unref (layout);
440
441 }
442
443
444 static void hb_pdf_set_col_title(PdfPrintContext *ppc)
445 {
446 ppc->column_txt[0] = _("Date");
447 ppc->column_txt[1] = _("Info");
448 ppc->column_txt[2] = _("Payee");
449 ppc->column_txt[3] = _("Memo");
450 ppc->column_txt[4] = _("Amount");
451 ppc->column_txt[5] = "C";
452 ppc->column_txt[6] = _("Balance");
453 }
454
455
456 void hb_export_pdf_listview(GtkTreeView *treeview, gchar *filepath, gchar *accname)
457 {
458 cairo_surface_t *surf;
459 cairo_t *cr;
460 PdfPrintContext ppc;
461 PangoFontDescription *desc;
462 PangoLayout *layout;
463 GtkTreeModel *model;
464 GtkTreeIter iter;
465 gboolean valid;
466 gint i, col;
467
468
469 DB( g_print("[gtk-chart] export to pdf\n") );
470
471 model = gtk_tree_view_get_model(treeview);
472
473 papersize(&ppc);
474
475 //gchar *filename = "/home/max/Desktop/hb-txn-export.pdf";
476 double width; //=210 * 2.83;
477 double height; //=297 * 2.83;
478
479 width = ppc.w;
480 height = ppc.h;
481
482 surf = cairo_pdf_surface_create (filepath, width, height);
483
484 if( cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS )
485 //todo: manage error later on
486 return;
487
488
489 cr = cairo_create (surf);
490 //cairo_pdf_surface_set_size(surf, width * 2.83, height * 2.83);
491
492 //g_print("width=%d\n", cairo_image_surface_get_width( surf));
493 double x1, x2, y1, y2;
494 cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
495
496 DB( g_print("surface w=%f, h=%f\n", x2 - x1, y2 - y1) );
497 double pwidth = x2 - x1;
498
499
500 /* Create a PangoLayout, set the font and text */
501 layout = pango_cairo_create_layout (cr);
502
503 /* get and copy the font from the treeview widget */
504 gtk_style_context_get(gtk_widget_get_style_context(GTK_WIDGET(treeview)), GTK_STATE_FLAG_NORMAL, "font", &desc, NULL);
505 ppc.desc = pango_font_description_copy(desc);
506
507 DB( g_print("family: %s\n", pango_font_description_get_family(desc)) );
508 DB( g_print("size: %d (%d)\n", pango_font_description_get_size (desc), pango_font_description_get_size (desc )/PANGO_SCALE) );
509
510
511
512 /* header is 1 line for date page number at top, then a title in bold, then 2 empty lines */
513 gint header_height = PDF_FONT_NORMAL * 2 + PDF_FONT_TITLE;
514 gint nb_lines = gtk_tree_model_iter_n_children(model, NULL);
515
516 /* should include here the headertitle line */
517
518 gint lpp = floor ((height-header_height-ppc.mt-ppc.mb) / (PDF_FONT_NORMAL + PDF_LINE_MARGIN));
519 gint page, num_pages = (nb_lines - 1) / lpp + 1;
520
521 DB( g_print("\n - should pdf %d lines, lpp=%d, num_pages=%d\n", nb_lines, lpp, num_pages) );
522
523
524 gint tot_lines = 0;
525 gint cur_page_line = 1;
526
527 gchar dbuffer[255];
528 gchar amtbuf[G_ASCII_DTOSTR_BUF_SIZE];
529 gchar balbuf[G_ASCII_DTOSTR_BUF_SIZE];
530
531 GDate *date = g_date_new ();
532
533 //cairo_set_font_size(cr, PDF_FONT_NORMAL);
534 pango_font_description_set_absolute_size(ppc.desc, PDF_FONT_NORMAL * PANGO_SCALE);
535 pango_layout_set_font_description (layout, ppc.desc);
536
537 /* reset struct */
538 hb_pdf_set_col_title(&ppc);
539
540 for(col=0;col<PDF_NUMCOL;col++)
541 {
542 int tw, th;
543
544 ppc.column_width[col] = 0;
545 pango_layout_set_text (layout, ppc.column_txt[col], -1);
546 pango_layout_get_size (layout, &tw, &th);
547 ppc.column_width[col] = MAX(ppc.column_width[col], tw / PANGO_SCALE);
548 }
549
550
551 DB( g_print(" - compute width\n") );
552
553 /* first pass to get max width */
554 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
555 while (valid)
556 {
557 Transaction *txn;
558 int tw, th;
559
560 gtk_tree_model_get (model, &iter, LST_DSPOPE_DATAS, &txn, -1);
561
562 i = 0;
563 g_date_set_julian (date, txn->date);
564 g_date_strftime (dbuffer, 255-1, "%x", date);
565 pango_layout_set_text (layout, dbuffer, -1);
566 pango_layout_get_size (layout, &tw, &th);
567 ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);
568
569 i = 1;
570 if(txn->info != NULL && strlen(txn->info) > 0)
571 {
572 pango_layout_set_text (layout, txn->info, -1);
573 pango_layout_get_size (layout, &tw, &th);
574 ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);
575 }
576
577 i = 4;
578 hb_strfnum(amtbuf, G_ASCII_DTOSTR_BUF_SIZE-1, txn->amount, txn->kcur, GLOBALS->minor);
579 pango_layout_set_text (layout, amtbuf, -1);
580 pango_layout_get_size (layout, &tw, &th);
581 ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);
582
583 i = 5;
584 pango_layout_set_text (layout, "R", -1);
585 pango_layout_get_size (layout, &tw, &th);
586 ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);
587
588 i = 6;
589 hb_strfnum(balbuf, G_ASCII_DTOSTR_BUF_SIZE-1, txn->balance, txn->kcur, GLOBALS->minor);
590 pango_layout_set_text (layout, balbuf, -1);
591 pango_layout_get_size (layout, &tw, &th);
592 ppc.column_width[i] = MAX(ppc.column_width[i], tw / PANGO_SCALE);
593
594 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
595 }
596
597 /* distribute remaining size */
598 gdouble tmp = pwidth - ppc.ml - ppc.mr - (PDF_COL_MARGIN*PDF_NUMCOL);
599
600
601 DB( g_print(" page width=%f, remain width=%f\n", pwidth, tmp) );
602
603 tmp -= ppc.column_width[0];
604 tmp -= ppc.column_width[4];
605 tmp -= ppc.column_width[5];
606 tmp -= ppc.column_width[6];
607
608 /* info=1/4 payee=1/4 memo=2/4 */
609 ppc.column_width[1] = tmp / 4;;
610 ppc.column_width[2] = tmp / 4;
611 ppc.column_width[3] = 2*tmp / 4;
612
613 DB( g_print(" page width=%f, remain width=%f\n", width, tmp) );
614
615 #if MYDEBUG == 1
616 for(i=0;i<PDF_NUMCOL;i++)
617 g_print(" col%d=%g ", i, ppc.column_width[i]);
618
619 g_print("\n");
620 #endif
621
622 DB( g_print("\n - start printing\n") );
623
624 gint y;
625 page = 1;
626 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
627 while (valid)
628 {
629 Transaction *txn;
630 int tw, th;
631
632 gtk_tree_model_get (model, &iter, LST_DSPOPE_DATAS, &txn, -1);
633
634 //DB( g_print(" - %d, %d, %s\n", x, y, txn->memo) );
635 if(cur_page_line == 1)
636 {
637 //helpdraw
638 #if HELPDRAW == 1
639 //page with margin
640 hb_pdf_draw_help_rect(cr, 0xFF0000FF, ppc.ml+0.5, ppc.mt+0.5, width-(ppc.ml+ppc.mr), height - (ppc.mt+ppc.mb));
641 hb_pdf_draw_help_rect(cr, 0xFF00FFFF, ppc.ml+0.5, ppc.mt+0.5, width-(ppc.ml+ppc.mr), header_height);
642 #endif
643
644 cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
645
646 // draw account title
647 pango_font_description_set_absolute_size(ppc.desc, PDF_FONT_TITLE * PANGO_SCALE);
648 pango_layout_set_font_description (layout, ppc.desc);
649
650 pango_layout_set_text (layout, accname, -1);
651 pango_layout_get_pixel_size (layout, &tw, &th);
652 cairo_move_to(cr, pwidth/2 - (tw/2), ppc.mt);
653 pango_cairo_show_layout (cr, layout);
654
655 // draw column titles
656 pango_font_description_set_absolute_size(ppc.desc, PDF_FONT_NORMAL * PANGO_SCALE);
657 pango_layout_set_font_description (layout, ppc.desc);
658
659 g_sprintf(dbuffer, "Page %d/%d", page, num_pages);
660 pango_layout_set_text (layout, dbuffer, -1);
661 pango_layout_get_pixel_size (layout, &tw, &th);
662 cairo_move_to(cr, pwidth - ppc.mr - tw, ppc.mt);
663 pango_cairo_show_layout (cr, layout);
664
665 //x = ppc.ml;
666 y = ppc.mt + header_height - (PDF_FONT_NORMAL + PDF_LINE_MARGIN);
667 hb_pdf_set_col_title(&ppc);
668
669 hb_pdf_draw_line(&ppc, cr, y, TRUE, FALSE);
670 }
671
672 /* print a single line */
673 //x = ppc.ml;
674 y = ppc.mt + header_height + (cur_page_line * (PDF_FONT_NORMAL + PDF_LINE_MARGIN));
675
676
677
678 /* reset struct */
679 for(i=0;i<PDF_NUMCOL;i++)
680 {
681 ppc.column_txt[i] = NULL;
682 }
683
684 i = 0;
685 g_date_set_julian (date, txn->date);
686 g_date_strftime (dbuffer, 255-1, "%x", date);
687 ppc.column_txt[i] = dbuffer;
688
689 i = 1;
690 ppc.column_txt[i] = txn->info;
691
692 i = 2;
693 Payee *p = da_pay_get(txn->kpay);
694 if(p)
695 ppc.column_txt[i] = p->name;
696
697 i = 3;
698 /*Category *c = da_cat_get(txn->kcat);
699 if(c)
700 ppc.column_txt[i] = da_cat_get_fullname(c);*/
701 ppc.column_txt[i] = txn->memo;
702
703 i = 4;
704 hb_strfnum(amtbuf, G_ASCII_DTOSTR_BUF_SIZE-1, txn->amount, txn->kcur, GLOBALS->minor);
705 ppc.column_txt[i] = amtbuf;
706
707 i = 5;
708 ppc.column_txt[i] = "";
709 if(txn->status == TXN_STATUS_CLEARED)
710 ppc.column_txt[i] = "c";
711 else
712 if(txn->status == TXN_STATUS_RECONCILED)
713 ppc.column_txt[i] = "R";
714
715 i = 6;
716 hb_strfnum(balbuf, G_ASCII_DTOSTR_BUF_SIZE-1, txn->balance, txn->kcur, GLOBALS->minor);
717 ppc.column_txt[i] = balbuf;
718
719 hb_pdf_draw_line(&ppc, cr, y, FALSE, (cur_page_line % 2));
720
721 /* free any fullcat name */
722 /*if(ppc.column_txt[3] != NULL)
723 g_free(ppc.column_txt[3]);*/
724
725 /* export page */
726 if(cur_page_line >= lpp)
727 {
728 DB( g_print("\n - next page %d\n", page) );
729
730 cairo_show_page(cr);
731 cur_page_line = 0;
732 page++;
733 }
734
735 cur_page_line++;
736 tot_lines++;
737 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
738 }
739
740 g_date_free(date);
741
742 g_object_unref (layout);
743 pango_font_description_free (ppc.desc);
744
745 cairo_destroy (cr);
746 cairo_surface_destroy (surf);
747
748 }
749
750
This page took 0.064232 seconds and 4 git commands to generate.