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