-
Notifications
You must be signed in to change notification settings - Fork 827
/
Copy pathAccount.cpp
6409 lines (5473 loc) · 199 KB
/
Account.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/********************************************************************\
* Account.c -- Account data structure implementation *
* Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1997-2003 Linas Vepstas <linas@linas.org> *
* Copyright (C) 2007 David Hampton <hampton@employees.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
* *
\********************************************************************/
#include <config.h>
#include "gnc-prefs.h"
#include <glib.h>
#include <glib/gi18n.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "AccountP.hpp"
#include "Account.hpp"
#include "Split.h"
#include "Transaction.h"
#include "TransactionP.hpp"
#include "gnc-event.h"
#include "gnc-glib-utils.h"
#include "gnc-lot.h"
#include "gnc-pricedb.h"
#include "qofinstance-p.h"
#include "gnc-features.h"
#include "guid.hpp"
#include <numeric>
#include <map>
#include <unordered_set>
static QofLogModule log_module = GNC_MOD_ACCOUNT;
/* The Canonical Account Separator. Pre-Initialized. */
static gchar account_separator[8] = ".";
static gunichar account_uc_separator = ':';
static bool imap_convert_bayes_to_flat_run = false;
/* Predefined KVP paths */
static const std::string KEY_ASSOC_INCOME_ACCOUNT("ofx/associated-income-account");
static const std::string KEY_RECONCILE_INFO("reconcile-info");
static const std::string KEY_INCLUDE_CHILDREN("include-children");
static const std::string KEY_POSTPONE("postpone");
static const std::string KEY_LOT_MGMT("lot-mgmt");
static const std::string KEY_ONLINE_ID("online_id");
static const std::string KEY_IMP_APPEND_TEXT("import-append-text");
static const std::string AB_KEY("hbci");
static const std::string AB_ACCOUNT_ID("account-id");
static const std::string AB_ACCOUNT_UID("account-uid");
static const std::string AB_BANK_CODE("bank-code");
static const std::string AB_TRANS_RETRIEVAL("trans-retrieval");
static const std::string KEY_BALANCE_LIMIT("balance-limit");
static const std::string KEY_BALANCE_HIGHER_LIMIT_VALUE("higher-value");
static const std::string KEY_BALANCE_LOWER_LIMIT_VALUE("lower-value");
static const std::string KEY_BALANCE_INCLUDE_SUB_ACCTS("inlude-sub-accts");
using FinalProbabilityVec=std::vector<std::pair<std::string, int32_t>>;
using ProbabilityVec=std::vector<std::pair<std::string, struct AccountProbability>>;
using FlatKvpEntry=std::pair<std::string, KvpValue*>;
enum
{
LAST_SIGNAL
};
enum
{
PROP_0,
PROP_NAME, /* Table */
PROP_FULL_NAME, /* Constructed */
PROP_CODE, /* Table */
PROP_DESCRIPTION, /* Table */
PROP_COLOR, /* KVP */
PROP_NOTES, /* KVP */
PROP_TYPE, /* Table */
// PROP_PARENT, /* Table, Not a property */
PROP_COMMODITY, /* Table */
PROP_COMMODITY_SCU, /* Table */
PROP_NON_STD_SCU, /* Table */
PROP_END_BALANCE, /* Constructed */
PROP_END_NOCLOSING_BALANCE, /* Constructed */
PROP_END_CLEARED_BALANCE, /* Constructed */
PROP_END_RECONCILED_BALANCE, /* Constructed */
PROP_TAX_RELATED, /* KVP */
PROP_TAX_CODE, /* KVP */
PROP_TAX_SOURCE, /* KVP */
PROP_TAX_COPY_NUMBER, /* KVP */
PROP_HIDDEN, /* Table slot exists, but in KVP in memory & xml */
PROP_PLACEHOLDER, /* Table slot exists, but in KVP in memory & xml */
PROP_AUTO_INTEREST,
PROP_FILTER, /* KVP */
PROP_SORT_ORDER, /* KVP */
PROP_SORT_REVERSED,
PROP_LOT_NEXT_ID, /* KVP */
PROP_ONLINE_ACCOUNT, /* KVP */
PROP_IMP_APPEND_TEXT, /* KVP */
PROP_IS_OPENING_BALANCE, /* KVP */
PROP_OFX_INCOME_ACCOUNT, /* KVP */
PROP_AB_ACCOUNT_ID, /* KVP */
PROP_AB_ACCOUNT_UID, /* KVP */
PROP_AB_BANK_CODE, /* KVP */
PROP_AB_TRANS_RETRIEVAL, /* KVP */
PROP_RUNTIME_0,
PROP_POLICY, /* Cached Value */
PROP_MARK, /* Runtime Value */
PROP_SORT_DIRTY, /* Runtime Value */
PROP_BALANCE_DIRTY, /* Runtime Value */
PROP_START_BALANCE, /* Runtime Value */
PROP_START_NOCLOSING_BALANCE, /* Runtime Value */
PROP_START_CLEARED_BALANCE, /* Runtime Value */
PROP_START_RECONCILED_BALANCE, /* Runtime Value */
};
#define GET_PRIVATE(o) \
((AccountPrivate*)gnc_account_get_instance_private((Account*)o))
/* This map contains a set of strings representing the different column types. */
static const std::map<GNCAccountType, const char*> gnc_acct_debit_strs = {
{ ACCT_TYPE_NONE, N_("Funds In") },
{ ACCT_TYPE_BANK, N_("Deposit") },
{ ACCT_TYPE_CASH, N_("Receive") },
{ ACCT_TYPE_CREDIT, N_("Payment") },
{ ACCT_TYPE_ASSET, N_("Increase") },
{ ACCT_TYPE_LIABILITY, N_("Decrease") },
{ ACCT_TYPE_STOCK, N_("Buy") },
{ ACCT_TYPE_MUTUAL, N_("Buy") },
{ ACCT_TYPE_CURRENCY, N_("Buy") },
{ ACCT_TYPE_INCOME, N_("Charge") },
{ ACCT_TYPE_EXPENSE, N_("Expense") },
{ ACCT_TYPE_PAYABLE, N_("Payment") },
{ ACCT_TYPE_RECEIVABLE, N_("Invoice") },
{ ACCT_TYPE_TRADING, N_("Decrease") },
{ ACCT_TYPE_EQUITY, N_("Decrease") },
};
static const char* dflt_acct_debit_str = N_("Debit");
/* This map contains a set of strings representing the different column types. */
static const std::map<GNCAccountType, const char*> gnc_acct_credit_strs = {
{ ACCT_TYPE_NONE, N_("Funds Out") },
{ ACCT_TYPE_BANK, N_("Withdrawal") },
{ ACCT_TYPE_CASH, N_("Spend") },
{ ACCT_TYPE_CREDIT, N_("Charge") },
{ ACCT_TYPE_ASSET, N_("Decrease") },
{ ACCT_TYPE_LIABILITY, N_("Increase") },
{ ACCT_TYPE_STOCK, N_("Sell") },
{ ACCT_TYPE_MUTUAL, N_("Sell") },
{ ACCT_TYPE_CURRENCY, N_("Sell") },
{ ACCT_TYPE_INCOME, N_("Income") },
{ ACCT_TYPE_EXPENSE, N_("Rebate") },
{ ACCT_TYPE_PAYABLE, N_("Bill") },
{ ACCT_TYPE_RECEIVABLE, N_("Payment") },
{ ACCT_TYPE_TRADING, N_("Increase") },
{ ACCT_TYPE_EQUITY, N_("Increase") },
};
static const char* dflt_acct_credit_str = N_("Credit");
/********************************************************************\
* Because I can't use C++ for this project, doesn't mean that I *
* can't pretend to! These functions perform actions on the *
* account data structure, in order to encapsulate the knowledge *
* of the internals of the Account in one file. *
\********************************************************************/
static void xaccAccountBringUpToDate (Account *acc);
/********************************************************************\
* gnc_get_account_separator *
* returns the current account separator character *
* *
* Args: none *
* Returns: account separator character *
\*******************************************************************/
const gchar *
gnc_get_account_separator_string (void)
{
return account_separator;
}
gunichar
gnc_get_account_separator (void)
{
return account_uc_separator;
}
void
gnc_set_account_separator (const gchar *separator)
{
gunichar uc;
gint count;
uc = g_utf8_get_char_validated(separator, -1);
if ((uc == (gunichar) - 2) || (uc == (gunichar) - 1) || g_unichar_isalnum(uc))
{
account_uc_separator = ':';
strcpy(account_separator, ":");
return;
}
account_uc_separator = uc;
count = g_unichar_to_utf8(uc, account_separator);
account_separator[count] = '\0';
}
gchar *gnc_account_name_violations_errmsg (const gchar *separator, GList* invalid_account_names)
{
gchar *message = nullptr;
if ( !invalid_account_names )
return nullptr;
auto account_list {gnc_g_list_stringjoin (invalid_account_names, "\n")};
/* Translators: The first %s will be the account separator character,
the second %s is a list of account names.
The resulting string will be displayed to the user if there are
account names containing the separator character. */
message = g_strdup_printf(
_("The separator character \"%s\" is used in one or more account names.\n\n"
"This will result in unexpected behaviour. "
"Either change the account names or choose another separator character.\n\n"
"Below you will find the list of invalid account names:\n"
"%s"), separator, account_list );
g_free ( account_list );
return message;
}
struct ViolationData
{
GList *list;
const gchar *separator;
};
static void
check_acct_name (Account *acct, gpointer user_data)
{
auto cb {static_cast<ViolationData*>(user_data)};
auto name {xaccAccountGetName (acct)};
if (g_strstr_len (name, -1, cb->separator))
cb->list = g_list_prepend (cb->list, g_strdup (name));
}
GList *gnc_account_list_name_violations (QofBook *book, const gchar *separator)
{
g_return_val_if_fail (separator != nullptr, nullptr);
if (!book) return nullptr;
ViolationData cb = { nullptr, separator };
gnc_account_foreach_descendant (gnc_book_get_root_account (book),
(AccountCb)check_acct_name, &cb);
return cb.list;
}
/********************************************************************\
\********************************************************************/
static inline void mark_account (Account *acc);
void
mark_account (Account *acc)
{
qof_instance_set_dirty(&acc->inst);
}
/********************************************************************\
\********************************************************************/
/* GObject Initialization */
G_DEFINE_TYPE_WITH_PRIVATE(Account, gnc_account, QOF_TYPE_INSTANCE)
static void
gnc_account_init(Account* acc)
{
AccountPrivate *priv;
priv = GET_PRIVATE(acc);
priv->parent = nullptr;
priv->accountName = qof_string_cache_insert("");
priv->accountCode = qof_string_cache_insert("");
priv->description = qof_string_cache_insert("");
priv->type = ACCT_TYPE_NONE;
priv->mark = 0;
priv->policy = xaccGetFIFOPolicy();
priv->lots = nullptr;
priv->commodity = nullptr;
priv->commodity_scu = 0;
priv->non_standard_scu = FALSE;
priv->balance = gnc_numeric_zero();
priv->noclosing_balance = gnc_numeric_zero();
priv->cleared_balance = gnc_numeric_zero();
priv->reconciled_balance = gnc_numeric_zero();
priv->starting_balance = gnc_numeric_zero();
priv->starting_noclosing_balance = gnc_numeric_zero();
priv->starting_cleared_balance = gnc_numeric_zero();
priv->starting_reconciled_balance = gnc_numeric_zero();
priv->balance_dirty = FALSE;
priv->higher_balance_limit = {};
priv->lower_balance_limit = {};
priv->include_sub_account_balances = {};
new (&priv->children) AccountVec ();
new (&priv->splits) SplitsVec ();
priv->splits_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
priv->sort_dirty = FALSE;
}
static void
gnc_account_dispose (GObject *acctp)
{
G_OBJECT_CLASS(gnc_account_parent_class)->dispose(acctp);
}
static void
gnc_account_finalize(GObject* acctp)
{
G_OBJECT_CLASS(gnc_account_parent_class)->finalize(acctp);
}
/* Note that g_value_set_object() refs the object, as does
* g_object_get(). But g_object_get() only unrefs once when it disgorges
* the object, leaving an unbalanced ref, which leaks. So instead of
* using g_value_set_object(), use g_value_take_object() which doesn't
* ref the object when used in get_property().
*/
static void
gnc_account_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
Account *account;
AccountPrivate *priv;
g_return_if_fail(GNC_IS_ACCOUNT(object));
account = GNC_ACCOUNT(object);
priv = GET_PRIVATE(account);
switch (prop_id)
{
case PROP_NAME:
g_value_set_string(value, priv->accountName);
break;
case PROP_FULL_NAME:
g_value_take_string(value, gnc_account_get_full_name(account));
break;
case PROP_CODE:
g_value_set_string(value, priv->accountCode);
break;
case PROP_DESCRIPTION:
g_value_set_string(value, priv->description);
break;
case PROP_COLOR:
g_value_set_string(value, xaccAccountGetColor(account));
break;
case PROP_NOTES:
g_value_set_string(value, xaccAccountGetNotes(account));
break;
case PROP_TYPE:
// NEED TO BE CONVERTED TO A G_TYPE_ENUM
g_value_set_int(value, priv->type);
break;
case PROP_COMMODITY:
g_value_take_object(value, priv->commodity);
break;
case PROP_COMMODITY_SCU:
g_value_set_int(value, priv->commodity_scu);
break;
case PROP_NON_STD_SCU:
g_value_set_boolean(value, priv->non_standard_scu);
break;
case PROP_SORT_DIRTY:
g_value_set_boolean(value, priv->sort_dirty);
break;
case PROP_BALANCE_DIRTY:
g_value_set_boolean(value, priv->balance_dirty);
break;
case PROP_START_BALANCE:
g_value_set_boxed(value, &priv->starting_balance);
break;
case PROP_START_NOCLOSING_BALANCE:
g_value_set_boxed(value, &priv->starting_noclosing_balance);
break;
case PROP_START_CLEARED_BALANCE:
g_value_set_boxed(value, &priv->starting_cleared_balance);
break;
case PROP_START_RECONCILED_BALANCE:
g_value_set_boxed(value, &priv->starting_reconciled_balance);
break;
case PROP_END_BALANCE:
g_value_set_boxed(value, &priv->balance);
break;
case PROP_END_NOCLOSING_BALANCE:
g_value_set_boxed(value, &priv->noclosing_balance);
break;
case PROP_END_CLEARED_BALANCE:
g_value_set_boxed(value, &priv->cleared_balance);
break;
case PROP_END_RECONCILED_BALANCE:
g_value_set_boxed(value, &priv->reconciled_balance);
break;
case PROP_POLICY:
/* MAKE THIS A BOXED VALUE */
g_value_set_pointer(value, priv->policy);
break;
case PROP_MARK:
g_value_set_int(value, priv->mark);
break;
case PROP_TAX_RELATED:
g_value_set_boolean(value, xaccAccountGetTaxRelated(account));
break;
case PROP_TAX_CODE:
g_value_set_string(value, xaccAccountGetTaxUSCode(account));
break;
case PROP_TAX_SOURCE:
g_value_set_string(value,
xaccAccountGetTaxUSPayerNameSource(account));
break;
case PROP_TAX_COPY_NUMBER:
g_value_set_int64(value,
xaccAccountGetTaxUSCopyNumber(account));
break;
case PROP_HIDDEN:
g_value_set_boolean(value, xaccAccountGetHidden(account));
break;
case PROP_AUTO_INTEREST:
g_value_set_boolean (value, xaccAccountGetAutoInterest (account));
break;
case PROP_IS_OPENING_BALANCE:
g_value_set_boolean(value, xaccAccountGetIsOpeningBalance(account));
break;
case PROP_PLACEHOLDER:
g_value_set_boolean(value, xaccAccountGetPlaceholder(account));
break;
case PROP_FILTER:
g_value_set_string(value, xaccAccountGetFilter(account));
break;
case PROP_SORT_ORDER:
g_value_set_string(value, xaccAccountGetSortOrder(account));
break;
case PROP_SORT_REVERSED:
g_value_set_boolean(value, xaccAccountGetSortReversed(account));
break;
case PROP_LOT_NEXT_ID:
/* Pre-set the value in case the frame is empty */
g_value_set_int64 (value, 0);
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {KEY_LOT_MGMT, "next-id"});
break;
case PROP_ONLINE_ACCOUNT:
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {KEY_ONLINE_ID});
break;
case PROP_IMP_APPEND_TEXT:
g_value_set_boolean(value, xaccAccountGetAppendText(account));
break;
case PROP_OFX_INCOME_ACCOUNT:
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {KEY_ASSOC_INCOME_ACCOUNT});
break;
case PROP_AB_ACCOUNT_ID:
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_ACCOUNT_ID});
break;
case PROP_AB_ACCOUNT_UID:
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_ACCOUNT_UID});
break;
case PROP_AB_BANK_CODE:
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_BANK_CODE});
break;
case PROP_AB_TRANS_RETRIEVAL:
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_TRANS_RETRIEVAL});
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gnc_account_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
Account *account;
gnc_numeric *number;
g_return_if_fail(GNC_IS_ACCOUNT(object));
account = GNC_ACCOUNT(object);
if (prop_id < PROP_RUNTIME_0)
g_assert (qof_instance_get_editlevel(account));
switch (prop_id)
{
case PROP_NAME:
xaccAccountSetName(account, g_value_get_string(value));
break;
case PROP_CODE:
xaccAccountSetCode(account, g_value_get_string(value));
break;
case PROP_DESCRIPTION:
xaccAccountSetDescription(account, g_value_get_string(value));
break;
case PROP_COLOR:
xaccAccountSetColor(account, g_value_get_string(value));
break;
case PROP_NOTES:
xaccAccountSetNotes(account, g_value_get_string(value));
break;
case PROP_TYPE:
// NEED TO BE CONVERTED TO A G_TYPE_ENUM
xaccAccountSetType(account, static_cast<GNCAccountType>(g_value_get_int(value)));
break;
case PROP_COMMODITY:
xaccAccountSetCommodity(account, static_cast<gnc_commodity*>(g_value_get_object(value)));
break;
case PROP_COMMODITY_SCU:
xaccAccountSetCommoditySCU(account, g_value_get_int(value));
break;
case PROP_NON_STD_SCU:
xaccAccountSetNonStdSCU(account, g_value_get_boolean(value));
break;
case PROP_SORT_DIRTY:
gnc_account_set_sort_dirty(account);
break;
case PROP_BALANCE_DIRTY:
gnc_account_set_balance_dirty(account);
break;
case PROP_START_BALANCE:
number = static_cast<gnc_numeric*>(g_value_get_boxed(value));
gnc_account_set_start_balance(account, *number);
break;
case PROP_START_CLEARED_BALANCE:
number = static_cast<gnc_numeric*>(g_value_get_boxed(value));
gnc_account_set_start_cleared_balance(account, *number);
break;
case PROP_START_RECONCILED_BALANCE:
number = static_cast<gnc_numeric*>(g_value_get_boxed(value));
gnc_account_set_start_reconciled_balance(account, *number);
break;
case PROP_POLICY:
gnc_account_set_policy(account, static_cast<GNCPolicy*>(g_value_get_pointer(value)));
break;
case PROP_MARK:
xaccAccountSetMark(account, g_value_get_int(value));
break;
case PROP_TAX_RELATED:
xaccAccountSetTaxRelated(account, g_value_get_boolean(value));
break;
case PROP_TAX_CODE:
xaccAccountSetTaxUSCode(account, g_value_get_string(value));
break;
case PROP_TAX_SOURCE:
xaccAccountSetTaxUSPayerNameSource(account,
g_value_get_string(value));
break;
case PROP_TAX_COPY_NUMBER:
xaccAccountSetTaxUSCopyNumber(account,
g_value_get_int64(value));
break;
case PROP_HIDDEN:
xaccAccountSetHidden(account, g_value_get_boolean(value));
break;
case PROP_AUTO_INTEREST:
xaccAccountSetAutoInterest (account, g_value_get_boolean (value));
break;
case PROP_IS_OPENING_BALANCE:
xaccAccountSetIsOpeningBalance (account, g_value_get_boolean (value));
break;
case PROP_PLACEHOLDER:
xaccAccountSetPlaceholder(account, g_value_get_boolean(value));
break;
case PROP_FILTER:
xaccAccountSetFilter(account, g_value_get_string(value));
break;
case PROP_SORT_ORDER:
xaccAccountSetSortOrder(account, g_value_get_string(value));
break;
case PROP_SORT_REVERSED:
xaccAccountSetSortReversed(account, g_value_get_boolean(value));
break;
case PROP_LOT_NEXT_ID:
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {KEY_LOT_MGMT, "next-id"});
break;
case PROP_ONLINE_ACCOUNT:
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {KEY_ONLINE_ID});
break;
case PROP_IMP_APPEND_TEXT:
xaccAccountSetAppendText(account, g_value_get_boolean(value));
break;
case PROP_OFX_INCOME_ACCOUNT:
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {KEY_ASSOC_INCOME_ACCOUNT});
break;
case PROP_AB_ACCOUNT_ID:
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_ACCOUNT_ID});
break;
case PROP_AB_ACCOUNT_UID:
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_ACCOUNT_UID});
break;
case PROP_AB_BANK_CODE:
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_BANK_CODE});
break;
case PROP_AB_TRANS_RETRIEVAL:
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_TRANS_RETRIEVAL});
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gnc_account_class_init (AccountClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = gnc_account_dispose;
gobject_class->finalize = gnc_account_finalize;
gobject_class->set_property = gnc_account_set_property;
gobject_class->get_property = gnc_account_get_property;
g_object_class_install_property
(gobject_class,
PROP_NAME,
g_param_spec_string ("name",
"Account Name",
"The accountName is an arbitrary string "
"assigned by the user. It is intended to "
"a short, 5 to 30 character long string "
"that is displayed by the GUI as the "
"account mnemonic. Account names may be "
"repeated. but no two accounts that share "
"a parent may have the same name.",
nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_FULL_NAME,
g_param_spec_string ("fullname",
"Full Account Name",
"The name of the account concatenated with "
"all its parent account names to indicate "
"a unique account.",
nullptr,
static_cast<GParamFlags>(G_PARAM_READABLE)));
g_object_class_install_property
(gobject_class,
PROP_CODE,
g_param_spec_string ("code",
"Account Code",
"The account code is an arbitrary string "
"assigned by the user. It is intended to "
"be reporting code that is a synonym for "
"the accountName.",
nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_DESCRIPTION,
g_param_spec_string ("description",
"Account Description",
"The account description is an arbitrary "
"string assigned by the user. It is intended "
"to be a longer, 1-5 sentence description of "
"what this account is all about.",
nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_COLOR,
g_param_spec_string ("color",
"Account Color",
"The account color is a color string assigned "
"by the user. It is intended to highlight the "
"account based on the users wishes.",
nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_NOTES,
g_param_spec_string ("notes",
"Account Notes",
"The account notes is an arbitrary provided "
"for the user to attach any other text that "
"they would like to associate with the account.",
nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_TYPE,
g_param_spec_int ("type",
"Account Type",
"The account type, picked from the enumerated list "
"that includes ACCT_TYPE_BANK, ACCT_TYPE_STOCK, "
"ACCT_TYPE_CREDIT, ACCT_TYPE_INCOME, etc.",
ACCT_TYPE_NONE,
NUM_ACCOUNT_TYPES - 1,
ACCT_TYPE_BANK,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_COMMODITY,
g_param_spec_object ("commodity",
"Commodity",
"The commodity field denotes the kind of "
"'stuff' stored in this account, whether "
"it is USD, gold, stock, etc.",
GNC_TYPE_COMMODITY,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_COMMODITY_SCU,
g_param_spec_int ("commodity-scu",
"Commodity SCU",
"The smallest fraction of the commodity that is "
"tracked. This number is used as the denominator "
"value in 1/x, so a value of 100 says that the "
"commodity can be divided into hundredths. E.G."
"1 USD can be divided into 100 cents.",
0,
G_MAXINT32,
GNC_COMMODITY_MAX_FRACTION,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_NON_STD_SCU,
g_param_spec_boolean ("non-std-scu",
"Non-std SCU",
"TRUE if the account SCU doesn't match "
"the commodity SCU. This indicates a case "
"where the two were accidentally set to "
"mismatched values in older versions of "
"GnuCash.",
FALSE,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_SORT_DIRTY,
g_param_spec_boolean("sort-dirty",
"Sort Dirty",
"TRUE if the splits in the account needs to be "
"resorted. This flag is set by the accounts "
"code for certain internal modifications, or "
"when external code calls the engine to say a "
"split has been modified in a way that may "
"affect the sort order of the account. Note: "
"This value can only be set to TRUE.",
FALSE,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_BALANCE_DIRTY,
g_param_spec_boolean("balance-dirty",
"Balance Dirty",
"TRUE if the running balances in the account "
"needs to be recalculated. This flag is set "
"by the accounts code for certain internal "
"modifications, or when external code calls "
"the engine to say a split has been modified. "
"Note: This value can only be set to TRUE.",
FALSE,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_START_BALANCE,
g_param_spec_boxed("start-balance",
"Starting Balance",
"The starting balance for the account. This "
"parameter is intended for use with backends that "
"do not return the complete list of splits for an "
"account, but rather return a partial list. In "
"such a case, the backend will typically return "
"all of the splits after some certain date, and "
"the 'starting balance' will represent the "
"summation of the splits up to that date.",
GNC_TYPE_NUMERIC,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_START_NOCLOSING_BALANCE,
g_param_spec_boxed("start-noclosing-balance",
"Starting No-closing Balance",
"The starting balance for the account, ignoring closing."
"This parameter is intended for use with backends "
"that do not return the complete list of splits "
"for an account, but rather return a partial "
"list. In such a case, the backend will "
"typically return all of the splits after "
"some certain date, and the 'starting noclosing "
"balance' will represent the summation of the "
"splits up to that date, ignoring closing splits.",
GNC_TYPE_NUMERIC,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_START_CLEARED_BALANCE,
g_param_spec_boxed("start-cleared-balance",
"Starting Cleared Balance",
"The starting cleared balance for the account. "
"This parameter is intended for use with backends "
"that do not return the complete list of splits "
"for an account, but rather return a partial "
"list. In such a case, the backend will "
"typically return all of the splits after "
"some certain date, and the 'starting cleared "
"balance' will represent the summation of the "
"splits up to that date.",
GNC_TYPE_NUMERIC,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_START_RECONCILED_BALANCE,
g_param_spec_boxed("start-reconciled-balance",
"Starting Reconciled Balance",
"The starting reconciled balance for the "
"account. This parameter is intended for use "
"with backends that do not return the complete "
"list of splits for an account, but rather return "
"a partial list. In such a case, the backend "
"will typically return all of the splits after "
"some certain date, and the 'starting reconciled "
"balance' will represent the summation of the "
"splits up to that date.",
GNC_TYPE_NUMERIC,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_END_BALANCE,
g_param_spec_boxed("end-balance",
"Ending Account Balance",
"This is the current ending balance for the "
"account. It is computed from the sum of the "
"starting balance and all splits in the account.",
GNC_TYPE_NUMERIC,
G_PARAM_READABLE));
g_object_class_install_property
(gobject_class,
PROP_END_NOCLOSING_BALANCE,
g_param_spec_boxed("end-noclosing-balance",
"Ending Account Noclosing Balance",
"This is the current ending no-closing balance for "
"the account. It is computed from the sum of the "
"starting balance and all cleared splits in the "
"account.",
GNC_TYPE_NUMERIC,
G_PARAM_READABLE));
g_object_class_install_property
(gobject_class,
PROP_END_CLEARED_BALANCE,
g_param_spec_boxed("end-cleared-balance",
"Ending Account Cleared Balance",
"This is the current ending cleared balance for "
"the account. It is computed from the sum of the "
"starting balance and all cleared splits in the "
"account.",
GNC_TYPE_NUMERIC,
G_PARAM_READABLE));
g_object_class_install_property
(gobject_class,
PROP_END_RECONCILED_BALANCE,
g_param_spec_boxed("end-reconciled-balance",
"Ending Account Reconciled Balance",
"This is the current ending reconciled balance "
"for the account. It is computed from the sum of "
"the starting balance and all reconciled splits "
"in the account.",
GNC_TYPE_NUMERIC,
static_cast<GParamFlags>(G_PARAM_READABLE)));
g_object_class_install_property
(gobject_class,
PROP_POLICY,
g_param_spec_pointer ("policy",
"Policy",
"The account lots policy.",
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_MARK,
g_param_spec_int ("acct-mark",
"Account Mark",
"Ipsum Lorem",
0,
G_MAXINT16,
0,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_TAX_RELATED,
g_param_spec_boolean ("tax-related",
"Tax Related",
"Whether the account maps to an entry on an "
"income tax document.",
FALSE,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_IS_OPENING_BALANCE,
g_param_spec_boolean ("opening-balance",
"Opening Balance",
"Whether the account holds opening balances",
FALSE,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_TAX_CODE,
g_param_spec_string ("tax-code",
"Tax Code",
"This is the code for mapping an account to a "
"specific entry on a taxable document. In the "
"United States it is used to transfer totals "
"into tax preparation software.",
nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_TAX_SOURCE,
g_param_spec_string ("tax-source",
"Tax Source",
"This specifies where exported name comes from.",
nullptr,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_TAX_COPY_NUMBER,
g_param_spec_int64 ("tax-copy-number",
"Tax Copy Number",
"This specifies the copy number of the tax "
"form/schedule.",
(gint64)1,
G_MAXINT64,
(gint64)1,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_HIDDEN,
g_param_spec_boolean ("hidden",
"Hidden",
"Whether the account should be hidden in the "
"account tree.",
FALSE,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_AUTO_INTEREST,