597
600
/* = = = = = = = = = = = = = = = = */
603
static void list_txn_to_string_line(GString *node, gchar sep, Transaction *ope, guint32 kcat, gchar *memo, gdouble amount, gboolean incacc)
608
char strbuf[G_ASCII_DTOSTR_BUF_SIZE];
613
Account *acc = da_acc_get(ope->kacc);
615
g_string_append (node, (acc != NULL) ? acc->name : "");
616
g_string_append_c (node, sep );
620
hb_sprint_date(strbuf, ope->date);
621
g_string_append (node, strbuf );
622
g_string_append_c (node, sep );
625
g_snprintf(strbuf, sizeof (strbuf), "%d", ope->paymode);
626
g_string_append (node, strbuf );
627
g_string_append_c (node, sep );
630
g_string_append (node, (ope->info != NULL) ? ope->info : "" );
631
g_string_append_c (node, sep );
634
payee = da_pay_get(ope->kpay);
635
g_string_append (node, (payee->name != NULL) ? payee->name : "");
636
g_string_append_c (node, sep );
639
g_string_append (node, (memo != NULL) ? memo : "" );
640
g_string_append_c (node, sep );
646
//g_ascii_dtostr (amountbuf, sizeof (amountbuf), ope->amount);
647
//#1750257 use locale numdigit
648
//g_ascii_formatd (amountbuf, sizeof (amountbuf), "%.2f", ope->amount);
649
//TODO: or not we should use the currency fmt here
650
g_snprintf(strbuf, sizeof (strbuf), "%.2f", amount);
652
DB( g_print("amount = %f '%s'\n", amount, strbuf) );
653
g_string_append (node, strbuf );
654
g_string_append_c (node, sep );
657
g_string_append (node, transaction_get_status_string(ope) );
658
g_string_append_c (node, sep );
662
category = da_cat_get(kcat);
663
g_string_append (node, (category->fullname != NULL) ? category->fullname : "" );
664
g_string_append_c (node, sep );
667
tags = tags_tostring(ope->tags);
668
g_string_append (node, tags != NULL ? tags : "");
672
g_string_append (node, "\n" );
599
677
//#1847907 v 5.3.2 add reconcile as c column like in pdf export
600
GString *list_txn_to_string(GtkTreeView *treeview, gboolean clipboard)
678
GString *list_txn_to_string(GtkTreeView *treeview, gboolean clipboard, gboolean incsplit, gboolean incacc)
602
680
struct list_txn_data *data = NULL;
603
681
GtkTreeModel *model;
604
682
GtkTreeIter iter;
608
685
Transaction *ope;
610
gchar *payeename, *categoryname;
611
686
gdouble amount, samount;
615
char amountbuf[G_ASCII_DTOSTR_BUF_SIZE];
617
689
data = g_object_get_data(G_OBJECT(treeview), "inst_data");
619
691
node = g_string_new(NULL);
623
g_string_append (node, "date\tpaymode\tinfo\tpayee\tmemo\tamount\tc\tcategory\ttags\n");
624
format = "%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n";
628
g_string_append (node, "date;paymode;info;payee;memo;amount;c;category;tags\n");
629
format = "%s;%d;%s;%s;%s;%s;%s;%s;%s\n";
693
sep = (clipboard == TRUE) ? '\t' : ';';
698
g_string_append (node, "account" );
699
g_string_append_c (node, sep );
701
g_string_append (node, "date" );
702
g_string_append_c (node, sep );
703
g_string_append (node, "paymode" );
704
g_string_append_c (node, sep );
705
g_string_append (node, "info" );
706
g_string_append_c (node, sep );
707
g_string_append (node, "payee" );
708
g_string_append_c (node, sep );
709
g_string_append (node, "memo" );
710
g_string_append_c (node, sep );
711
g_string_append (node, "amount" );
712
g_string_append_c (node, sep );
713
g_string_append (node, "c" );
714
g_string_append_c (node, sep );
715
g_string_append (node, "category" );
716
g_string_append_c (node, sep );
717
g_string_append (node, "tags");
718
g_string_append (node, "\n" );
632
721
model = gtk_tree_view_get_model(treeview);
633
722
valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
638
727
MODEL_TXN_SPLITAMT, &samount,
641
hb_sprint_date(datebuf, ope->date);
643
payee = da_pay_get(ope->kpay);
644
payeename = (payee->name == NULL) ? "" : payee->name;
645
category = da_cat_get(ope->kcat);
646
categoryname = (category->name == NULL) ? NULL : category->fullname;
647
tags = tags_tostring(ope->tags);
649
amount = ope->amount;
650
//for detail display the split part (if any)
651
if( data && (data->list_type == LIST_TXN_TYPE_DETAIL) )
655
//g_ascii_dtostr (amountbuf, sizeof (amountbuf), ope->amount);
656
//#1750257 use locale numdigit
657
//g_ascii_formatd (amountbuf, sizeof (amountbuf), "%.2f", ope->amount);
658
//TODO: we should use the currency fmt here
659
g_snprintf(amountbuf, sizeof (amountbuf), "%.2f", amount);
661
DB( g_print("amount = %f '%s'\n", amount, amountbuf) );
663
g_string_append_printf(node, format,
666
ope->info != NULL ? ope->info : "",
668
ope->memo != NULL ? ope->memo : "",
670
transaction_get_status_string(ope),
671
categoryname != NULL ? categoryname : "",
672
tags != NULL ? tags : ""
730
//normal export: if we don't want split or the txn has no split
731
if( (incsplit == FALSE) )
733
amount = ope->amount;
734
//for detail display the split part (if any)
735
if( data && (data->list_type == LIST_TXN_TYPE_DETAIL) )
737
list_txn_to_string_line(node, sep, ope, ope->kcat, ope->memo, amount, incacc);
741
if( (ope->splits == NULL) )
743
list_txn_to_string_line(node, sep, ope, ope->kcat, ope->memo, ope->amount, incacc);
747
guint i, nbsplit = da_splits_length(ope->splits);
749
for(i=0;i<nbsplit;i++)
751
Split *split = da_splits_get(ope->splits, i);
752
list_txn_to_string_line(node, sep, ope, split->kcat, split->memo, split->amount, incacc);
678
757
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);