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