26 #include <glib/gi18n.h> 29 #include "dialog-utils.h" 30 #include "dialog-doclink-utils.h" 37 #include "gnc-warnings.h" 45 #include "engine-helpers.h" 48 static QofLogModule log_module = GNC_MOD_LEDGER;
51 static gboolean use_red_for_negative = TRUE;
58 gnc_split_register_get_rbaln (VirtualLocation virt_loc, gpointer user_data,
61 SplitRegister* reg = user_data;
63 SRInfo* info = gnc_split_register_get_info (reg);
68 GList* children = NULL;
71 balance = gnc_numeric_zero();
74 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
76 gnc_get_current_book()))
77 return gnc_numeric_zero();
81 return gnc_numeric_zero();
84 account = gnc_split_register_get_default_account (reg);
93 children = g_list_prepend (children, account);
97 row = virt_loc.vcell_loc.virt_row;
98 virt_loc.vcell_loc.virt_row = 0;
100 while (virt_loc.vcell_loc.virt_row <= row)
103 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
109 Split* secondary = node->data;
118 for (child = children; child; child = child->next)
120 if (account == child->data)
133 virt_loc.vcell_loc.virt_row += i;
137 g_list_free (children);
142 static gnc_commodity*
143 gnc_split_register_get_split_commodity (SplitRegister* reg,
144 VirtualLocation virt_loc)
150 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
156 if (cursor_class != CURSOR_CLASS_SPLIT)
161 if (virt_cell_loc_equal (virt_loc.vcell_loc,
162 reg->table->current_cursor_loc.vcell_loc) &&
163 gnc_table_layout_get_cell_changed (reg->table->layout, XFRM_CELL, FALSE))
167 name = gnc_table_layout_get_cell_value (reg->table->layout, XFRM_CELL);
182 gnc_split_register_use_security_cells (SplitRegister* reg,
183 VirtualLocation virt_loc)
189 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
195 if (cursor_class != CURSOR_CLASS_SPLIT)
200 if (virt_cell_loc_equal (virt_loc.vcell_loc,
201 reg->table->current_cursor_loc.vcell_loc) &&
202 gnc_table_layout_get_cell_changed (reg->table->layout, XFRM_CELL, FALSE))
206 name = gnc_table_layout_get_cell_value (reg->table->layout, XFRM_CELL);
230 gnc_split_register_get_date_label (VirtualLocation virt_loc,
237 gnc_split_register_get_due_date_label (VirtualLocation virt_loc,
240 return _ (
"Due Date");
244 gnc_split_register_get_num_label (VirtualLocation virt_loc,
247 SplitRegister* reg = user_data;
251 case RECEIVABLE_REGISTER:
252 case PAYABLE_REGISTER:
265 gnc_split_register_get_tran_num_label (VirtualLocation virt_loc,
268 SplitRegister* reg = user_data;
272 case RECEIVABLE_REGISTER:
273 case PAYABLE_REGISTER:
275 case GENERAL_JOURNAL:
279 if (reg->use_tran_num_for_num_field)
288 gnc_split_register_get_desc_label (VirtualLocation virt_loc,
291 SplitRegister* reg = user_data;
295 case RECEIVABLE_REGISTER:
296 return _ (
"Customer");
297 case PAYABLE_REGISTER:
300 return _ (
"Description");
305 gnc_split_register_get_recn_label (VirtualLocation virt_loc,
308 SplitRegister* reg = user_data;
312 case RECEIVABLE_REGISTER:
313 case PAYABLE_REGISTER:
317 return C_ (
"Column header for 'Reconciled'",
"R");
322 gnc_split_register_get_baln_label (VirtualLocation virt_loc,
325 return _ (
"Balance");
329 gnc_split_register_get_action_label (VirtualLocation virt_loc,
336 gnc_split_register_get_doclink_label (VirtualLocation virt_loc,
339 return C_ (
"Column header for 'Document Link'",
"L");
343 gnc_split_register_get_xfrm_label (VirtualLocation virt_loc,
346 return _ (
"Account");
350 gnc_split_register_get_mxfrm_label (VirtualLocation virt_loc,
353 return _ (
"Transfer");
357 gnc_split_register_get_memo_label (VirtualLocation virt_loc,
364 gnc_split_register_get_type_label (VirtualLocation virt_loc,
371 gnc_split_register_get_rate_label (VirtualLocation virt_loc,
378 gnc_split_register_get_debit_label (VirtualLocation virt_loc,
381 SplitRegister* reg = user_data;
387 gnc_split_register_get_credit_label (VirtualLocation virt_loc,
390 SplitRegister* reg = user_data;
396 gnc_split_register_get_price_label (VirtualLocation virt_loc,
399 SplitRegister* reg = user_data;
400 gnc_commodity* commod;
402 if (!gnc_split_register_use_security_cells (reg, virt_loc))
405 commod = gnc_split_register_get_split_commodity (reg, virt_loc);
409 return _ (
"Exch. Rate");
413 gnc_split_register_get_shares_label (VirtualLocation virt_loc,
416 SplitRegister* reg = user_data;
417 gnc_commodity* commod;
419 if (!gnc_split_register_use_security_cells (reg, virt_loc))
422 commod = gnc_split_register_get_split_commodity (reg, virt_loc);
426 return _ (
"Oth. Curr.");
430 gnc_split_register_get_tcredit_label (VirtualLocation virt_loc,
433 SplitRegister* reg = user_data;
434 SRInfo* info = gnc_split_register_get_info (reg);
436 if (info->tcredit_str)
437 return info->tcredit_str;
443 info->tcredit_str = g_strdup_printf (_ (
"Tot %s"),
string);
446 if (info->tcredit_str)
447 return info->tcredit_str;
449 info->tcredit_str = g_strdup (_ (
"Tot Credit"));
451 return info->tcredit_str;
455 gnc_split_register_get_tdebit_label (VirtualLocation virt_loc,
458 SplitRegister* reg = user_data;
459 SRInfo* info = gnc_split_register_get_info (reg);
461 if (info->tdebit_str)
462 return info->tdebit_str;
467 info->tdebit_str = g_strdup_printf (_ (
"Tot %s"),
string);
470 if (info->tdebit_str)
471 return info->tdebit_str;
473 info->tdebit_str = g_strdup (_ (
"Tot Debit"));
475 return info->tdebit_str;
479 gnc_split_register_get_tshares_label (VirtualLocation virt_loc,
482 return _ (
"Tot Shares");
486 gnc_split_register_get_tbalance_label (VirtualLocation virt_loc,
489 return _ (
"Balance");
493 gnc_split_register_get_notes_label (VirtualLocation virt_loc,
500 gnc_split_register_get_fdebit_label (VirtualLocation virt_loc,
503 return _ (
"Debit Formula");
507 gnc_split_register_get_fcredit_label (VirtualLocation virt_loc,
510 return _ (
"Credit Formula");
516 gnc_split_register_get_recn_tooltip (VirtualLocation virt_loc,
519 SplitRegister* reg = user_data;
522 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
530 memset (datebuff, 0,
sizeof (datebuff));
532 return g_strdup_printf (_ (
"Reconciled on %s"), datebuff);
544 gnc_split_register_get_doclink_tooltip (VirtualLocation virt_loc,
547 SplitRegister* reg = user_data;
551 trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
560 return gnc_doclink_get_unescaped_just_uri (uri);
566 get_trans_total_amount (SplitRegister* reg, Transaction* trans)
568 Account* account = gnc_split_register_get_default_account (reg);
573 get_trans_total_balance (SplitRegister* reg, Transaction* trans)
577 account = gnc_split_register_get_default_account (reg);
578 if (!trans || !account)
return gnc_numeric_zero();
584 gnc_split_register_use_negative_color (VirtualLocation virt_loc,
587 const char* cell_name;
588 gnc_numeric value = gnc_numeric_zero();
591 if (!use_red_for_negative)
594 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
598 cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
600 if (gnc_cell_name_equal (cell_name, TSHRS_CELL))
602 else if (gnc_cell_name_equal (cell_name, SHRS_CELL))
604 if (virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
607 ((
PriceCell*) gnc_table_layout_get_cell (reg->table->layout,
612 else if (gnc_cell_name_equal (cell_name, BALN_CELL))
614 else if (gnc_cell_name_equal (cell_name, RBALN_CELL))
615 value = gnc_split_register_get_rbaln (virt_loc, reg, TRUE);
616 else if (gnc_cell_name_equal (cell_name, TBALN_CELL))
619 if ((gnc_cell_name_equal (cell_name, BALN_CELL)) ||
620 (gnc_cell_name_equal (cell_name, RBALN_CELL)) ||
621 (gnc_cell_name_equal (cell_name, TBALN_CELL)))
624 if (gnc_reverse_balance (account))
635 gnc_split_register_get_cell_color_internal (VirtualLocation virt_loc,
638 const char* cursor_name;
641 guint32 colorbase = 0;
645 if (gnc_split_register_use_negative_color (virt_loc, reg))
646 colorbase = COLOR_NEGATIVE;
649 return (colorbase + COLOR_UNDEFINED);
651 if (gnc_table_virtual_location_in_header (reg->table, virt_loc))
652 return (colorbase + COLOR_HEADER);
655 if (!vcell || !vcell->cellblock)
656 return (colorbase + COLOR_UNDEFINED);
658 if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
659 (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
660 return (colorbase + COLOR_UNDEFINED);
662 is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
665 cursor_name = vcell->cellblock->cursor_name;
667 if (g_strcmp0 (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
668 g_strcmp0 (cursor_name, CURSOR_SINGLE_LEDGER) == 0)
672 (colorbase + COLOR_PRIMARY_ACTIVE) :
673 (colorbase + COLOR_SECONDARY_ACTIVE);
676 (colorbase + COLOR_PRIMARY) : (colorbase + COLOR_SECONDARY);
679 if (g_strcmp0 (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
680 g_strcmp0 (cursor_name, CURSOR_DOUBLE_JOURNAL_NUM_ACTN) == 0 ||
681 g_strcmp0 (cursor_name, CURSOR_DOUBLE_LEDGER) == 0 ||
682 g_strcmp0 (cursor_name, CURSOR_DOUBLE_LEDGER_NUM_ACTN) == 0)
686 if (reg->double_alt_color)
688 (colorbase + COLOR_PRIMARY_ACTIVE) :
689 (colorbase + COLOR_SECONDARY_ACTIVE);
691 return (virt_loc.phys_row_offset % 2 == 0) ?
692 (colorbase + COLOR_PRIMARY_ACTIVE) :
693 (colorbase + COLOR_SECONDARY_ACTIVE);
696 if (reg->double_alt_color)
698 (colorbase + COLOR_PRIMARY) :
699 (colorbase + COLOR_SECONDARY);
701 return (virt_loc.phys_row_offset % 2 == 0) ?
702 (colorbase + COLOR_PRIMARY) :
703 (colorbase + COLOR_SECONDARY);
706 if (g_strcmp0 (cursor_name, CURSOR_SPLIT) == 0)
709 return (colorbase + COLOR_SPLIT_ACTIVE);
711 return (colorbase + COLOR_SPLIT);
714 PWARN (
"Unexpected cursor: %s\n", cursor_name);
716 return (colorbase + COLOR_UNDEFINED);
721 gnc_split_register_get_cell_color (VirtualLocation virt_loc,
725 SplitRegister* reg = user_data;
730 return gnc_split_register_get_cell_color_internal (virt_loc, reg);
735 gnc_split_register_get_debcred_color (VirtualLocation virt_loc,
739 SplitRegister* reg = user_data;
745 trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
752 return gnc_split_register_get_cell_color_internal (virt_loc, reg);
756 gnc_split_register_get_border (VirtualLocation virt_loc,
760 SplitRegister* reg = user_data;
765 if (!vcell || !vcell->cellblock)
768 if (virt_loc.phys_col_offset < vcell->cellblock->start_col ||
769 virt_loc.phys_col_offset > vcell->cellblock->stop_col)
771 borders->top = CELL_BORDER_LINE_NONE;
772 borders->bottom = CELL_BORDER_LINE_NONE;
773 borders->left = CELL_BORDER_LINE_NONE;
774 borders->right = CELL_BORDER_LINE_NONE;
779 gnc_split_register_cursor_name_to_class (vcell->cellblock->cursor_name);
781 if (cursor_class == CURSOR_CLASS_SPLIT)
783 borders->top = CELL_BORDER_LINE_LIGHT;
784 borders->bottom = CELL_BORDER_LINE_LIGHT;
785 borders->left = MIN (borders->left, CELL_BORDER_LINE_LIGHT);
786 borders->right = MIN (borders->right, CELL_BORDER_LINE_LIGHT);
788 if (virt_loc.phys_col_offset == vcell->cellblock->start_col)
789 borders->left = CELL_BORDER_LINE_NORMAL;
790 if (virt_loc.phys_col_offset == vcell->cellblock->stop_col)
791 borders->right = CELL_BORDER_LINE_NORMAL;
796 gnc_split_register_get_doclink_entry (VirtualLocation virt_loc,
798 gboolean* conditionally_changed,
801 SplitRegister* reg = user_data;
807 cell = (
Doclinkcell *)gnc_table_layout_get_cell (reg->table->layout, DOCLINK_CELL);
812 trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
824 if (!scheme || g_strcmp0 (scheme,
"file") == 0)
834 if (gnc_doclink_get_use_glyphs (cell))
835 return gnc_doclink_get_glyph_from_flag (link_flag);
850 gnc_split_register_get_doclink_help (VirtualLocation virt_loc,
854 return g_strdup (
" ");
860 gnc_split_register_get_doclink_value (SplitRegister* reg,
861 VirtualLocation virt_loc)
865 cell = (
Doclinkcell *)gnc_table_layout_get_cell (reg->table->layout, DOCLINK_CELL);
869 return gnc_doclink_cell_get_flag (cell);
874 gnc_split_register_get_type_entry (VirtualLocation virt_loc,
876 gboolean* conditionally_changed,
879 SplitRegister* reg = user_data;
884 trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
900 gnc_split_register_get_type_value (SplitRegister* reg,
901 VirtualLocation virt_loc)
905 cell = (
RecnCell*)gnc_table_layout_get_cell (reg->table->layout, TYPE_CELL);
909 return gnc_recn_cell_get_flag (cell);
913 gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
915 gboolean* conditionally_changed,
918 SplitRegister* reg = user_data;
925 is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
930 type = gnc_split_register_get_type_value (reg, virt_loc);
934 const char* typestr =
935 gnc_split_register_get_type_entry (virt_loc, translate,
936 conditionally_changed, user_data);
950 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
960 memset (dateBuff, 0,
sizeof (dateBuff));
966 gnc_split_register_get_date_entry (VirtualLocation virt_loc,
968 gboolean* conditionally_changed,
971 SplitRegister* reg = user_data;
976 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
981 memset (dateBuff, 0,
sizeof (dateBuff));
987 gnc_split_register_get_date_help (VirtualLocation virt_loc,
990 SplitRegister* reg = user_data;
994 cell = gnc_table_get_cell (reg->table, virt_loc);
995 if (!cell || !cell->value || *cell->value ==
'\0')
1006 gnc_split_register_get_inactive_date_entry (VirtualLocation virt_loc,
1008 gboolean* conditionally_changed,
1013 return _ (
"Scheduled");
1017 gnc_split_register_get_num_entry (VirtualLocation virt_loc,
1019 gboolean* conditionally_changed,
1022 SplitRegister* reg = user_data;
1026 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1029 return gnc_get_num_action (trans, split);
1033 gnc_split_register_get_tran_num_entry (VirtualLocation virt_loc,
1035 gboolean* conditionally_changed,
1038 SplitRegister* reg = user_data;
1042 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1045 return gnc_get_num_action (trans, NULL);
1049 gnc_split_register_get_num_help (VirtualLocation virt_loc,
1052 SplitRegister* reg = user_data;
1055 help = gnc_table_get_entry (reg->table, virt_loc);
1056 if (!help || *help ==
'\0')
1059 case RECEIVABLE_REGISTER:
1060 case PAYABLE_REGISTER:
1061 help = reg->use_tran_num_for_num_field ?
1062 _ (
"Enter a reference, such as an invoice or check number, " 1063 "common to all entry lines (splits)") :
1064 _ (
"Enter a reference, such as an invoice or check number, " 1065 "unique to each entry line (split)");
1068 help = reg->use_tran_num_for_num_field ?
1069 _ (
"Enter a reference, such as a check number, " 1070 "common to all entry lines (splits)") :
1071 _ (
"Enter a reference, such as a check number, " 1072 "unique to each entry line (split)");
1076 return g_strdup (help);
1080 gnc_split_register_get_tran_num_help (VirtualLocation virt_loc,
1083 SplitRegister* reg = user_data;
1086 help = gnc_table_get_entry (reg->table, virt_loc);
1087 if (!help || *help ==
'\0')
1090 case RECEIVABLE_REGISTER:
1091 case PAYABLE_REGISTER:
1092 help = _ (
"Enter a transaction reference, such as an invoice " 1093 "or check number, common to all entry lines (splits)");
1096 help = _ (
"Enter a transaction reference " 1097 "that will be common to all entry lines (splits)");
1101 return g_strdup (help);
1105 gnc_split_register_get_desc_entry (VirtualLocation virt_loc,
1107 gboolean* conditionally_changed,
1110 SplitRegister* reg = user_data;
1114 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1121 gnc_split_register_get_desc_help (VirtualLocation virt_loc,
1124 SplitRegister* reg = user_data;
1127 help = gnc_table_get_entry (reg->table, virt_loc);
1128 if (!help || *help ==
'\0')
1131 case RECEIVABLE_REGISTER:
1132 help = _ (
"Enter the name of the Customer");
1134 case PAYABLE_REGISTER:
1135 help = _ (
"Enter the name of the Vendor");
1138 help = _ (
"Enter a description of the transaction");
1141 return g_strdup (help);
1145 gnc_split_register_get_notes_entry (VirtualLocation virt_loc,
1147 gboolean* conditionally_changed,
1150 SplitRegister* reg = user_data;
1154 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1161 gnc_split_register_get_notes_help (VirtualLocation virt_loc,
1164 SplitRegister* reg = user_data;
1167 help = gnc_table_get_entry (reg->table, virt_loc);
1168 if (!help || *help ==
'\0')
1169 help = _ (
"Enter notes for the transaction");
1171 return g_strdup (help);
1175 gnc_split_register_get_vnotes_entry (VirtualLocation virt_loc,
1177 gboolean* conditionally_changed,
1180 SplitRegister* reg = user_data;
1184 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1194 gnc_split_register_get_vnotes_help (VirtualLocation virt_loc,
1197 SplitRegister* reg = user_data;
1200 help = gnc_table_get_entry (reg->table, virt_loc);
1201 if (!help || *help ==
'\0')
1202 help = _ (
"Reason the transaction was voided");
1204 return g_strdup (help);
1208 gnc_split_register_get_rate_entry (VirtualLocation virt_loc,
1210 gboolean* conditionally_changed,
1213 SplitRegister* reg = user_data;
1214 Split* split, *osplit;
1216 gnc_numeric amount, value, convrate;
1217 gnc_commodity* curr;
1218 SRInfo* info = gnc_split_register_get_info (reg);
1220 if (info->rate_reset == RATE_RESET_REQD && info->auto_complete)
1223 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1232 txn = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
1235 !gnc_split_register_needs_conv_rate (reg, txn,
1250 return xaccPrintAmount (convrate, gnc_default_price_print_info (curr));
1254 gnc_split_register_get_recn_entry (VirtualLocation virt_loc,
1256 gboolean* conditionally_changed,
1259 SplitRegister* reg = user_data;
1262 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1280 gnc_split_register_get_action_entry (VirtualLocation virt_loc,
1282 gboolean* conditionally_changed,
1285 SplitRegister* reg = user_data;
1286 Split* split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1288 return gnc_get_num_action (NULL, split);
1292 gnc_split_register_get_action_help (VirtualLocation virt_loc,
1295 SplitRegister* reg = user_data;
1298 help = gnc_table_get_entry (reg->table, virt_loc);
1299 if (!help || *help ==
'\0')
1300 help = reg->use_tran_num_for_num_field ?
1301 _ (
"Enter an action type, or choose one from the list") :
1302 _ (
"Enter a reference number, such as the next check number, or choose an action type from the list");
1304 return g_strdup (help);
1308 gnc_split_register_get_memo_entry (VirtualLocation virt_loc,
1310 gboolean* conditionally_changed,
1313 SplitRegister* reg = user_data;
1316 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1322 gnc_split_register_get_memo_help (VirtualLocation virt_loc,
1325 SplitRegister* reg = user_data;
1328 help = gnc_table_get_entry (reg->table, virt_loc);
1329 if (!help || *help ==
'\0')
1330 help = _ (
"Enter a description of the split");
1331 return g_strdup (help);
1335 gnc_split_register_get_balance_entry (VirtualLocation virt_loc,
1337 gboolean* conditionally_changed,
1340 SplitRegister* reg = user_data;
1341 SRInfo* info = gnc_split_register_get_info (reg);
1342 gnc_numeric balance;
1347 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1349 gnc_get_current_book()))
1352 is_trans = gnc_cell_name_equal
1353 (gnc_table_get_cell_name (reg->table, virt_loc), TBALN_CELL);
1362 account = gnc_split_register_get_default_account (reg);
1364 if (gnc_reverse_balance (account))
1368 reg->mismatched_commodities));
1372 gnc_split_register_get_price_entry (VirtualLocation virt_loc,
1374 gboolean* conditionally_changed,
1377 SplitRegister* reg = user_data;
1379 gnc_commodity* curr;
1382 if (!gnc_split_register_use_security_cells (reg, virt_loc))
1385 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1396 gnc_split_register_get_price_help (VirtualLocation virt_loc,
1399 SplitRegister* reg = user_data;
1402 help = gnc_table_get_entry (reg->table, virt_loc);
1403 if (!help || *help ==
'\0')
1404 help = _ (
"Enter the effective share price");
1406 return g_strdup (help);
1410 gnc_split_register_get_shares_entry (VirtualLocation virt_loc,
1412 gboolean* conditionally_changed,
1415 SplitRegister* reg = user_data;
1419 if (!gnc_split_register_use_security_cells (reg, virt_loc))
1422 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1428 return xaccPrintAmount (shares, gnc_split_amount_print_info (split, FALSE));
1432 gnc_split_register_get_shares_help (VirtualLocation virt_loc,
1435 SplitRegister* reg = user_data;
1438 help = gnc_table_get_entry (reg->table, virt_loc);
1439 if (!help || *help ==
'\0')
1440 help = _ (
"Enter the number of shares bought or sold");
1442 return g_strdup (help);
1446 gnc_split_register_get_tshares_entry (VirtualLocation virt_loc,
1448 gboolean* conditionally_changed,
1451 SplitRegister* reg = user_data;
1455 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1459 return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
1463 gnc_split_register_get_xfrm_entry (VirtualLocation virt_loc,
1465 gboolean* conditionally_changed,
1468 static char* name = NULL;
1470 SplitRegister* reg = user_data;
1473 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1478 reg->show_leaf_accounts);
1484 gnc_split_register_get_xfrm_help (VirtualLocation virt_loc,
1487 SplitRegister* reg = user_data;
1490 help = gnc_table_get_entry (reg->table, virt_loc);
1491 if (!help || *help ==
'\0')
1492 help = _ (
"Enter the account to transfer from, " 1493 "or choose one from the list");
1495 return g_strdup (help);
1499 gnc_split_register_get_mxfrm_entry (VirtualLocation virt_loc,
1501 gboolean* conditionally_changed,
1504 static char* name = NULL;
1506 SplitRegister* reg = user_data;
1510 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1520 reg->show_leaf_accounts);
1528 name = g_strdup (SPLIT_TRANS_STR);
1530 name = g_strdup (STOCK_SPLIT_STR);
1532 name = g_strdup (
"");
1539 gnc_split_register_get_mxfrm_help (VirtualLocation virt_loc,
1544 SplitRegister* reg = user_data;
1548 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1556 help = gnc_split_register_get_mxfrm_entry (virt_loc, FALSE,
1558 if (!help || *help ==
'\0')
1559 help = _ (
"Enter the account to transfer from, " 1560 "or choose one from the list");
1569 help = _ (
"This transaction has multiple splits; " 1570 "press the Split button to see them all");
1572 help = _ (
"This transaction is a stock split; " 1573 "press the Split button to see details");
1578 return g_strdup (help);
1585 get_trans_total_value_subaccounts (SplitRegister* reg, Transaction* trans)
1587 GList* children, *child;
1589 gnc_numeric total = gnc_numeric_zero();
1592 parent = gnc_split_register_get_default_account (reg);
1600 children = g_list_prepend (children, parent);
1602 for (child = children; child; child = child->next)
1608 g_list_free (children);
1614 gnc_split_register_get_tdebcred_entry (VirtualLocation virt_loc,
1616 gboolean* conditionally_changed,
1619 SplitRegister* reg = user_data;
1620 const char* cell_name;
1624 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1628 cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
1632 case GENERAL_JOURNAL:
1645 gnc_cell_name_equal (cell_name, TDEBT_CELL))
1649 gnc_cell_name_equal (cell_name, TCRED_CELL))
1655 reg->mismatched_commodities));
1668 case ASSET_REGISTER:
1669 case CREDIT_REGISTER:
1670 case LIABILITY_REGISTER:
1671 case INCOME_REGISTER:
1672 case EXPENSE_REGISTER:
1673 case EQUITY_REGISTER:
1674 case TRADING_REGISTER:
1675 case GENERAL_JOURNAL:
1678 case RECEIVABLE_REGISTER:
1679 case PAYABLE_REGISTER:
1682 case STOCK_REGISTER:
1683 case CURRENCY_REGISTER:
1684 case PORTFOLIO_LEDGER:
1695 gnc_split_register_needs_conv_rate (SplitRegister* reg,
1696 Transaction* txn,
Account* acc)
1698 gnc_commodity* txn_cur, *acc_com;
1714 gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
1716 gboolean* conditionally_changed,
1719 SplitRegister* reg = user_data;
1723 gnc_commodity* currency;
1725 is_debit = gnc_cell_name_equal
1726 (gnc_table_get_cell_name (reg->table, virt_loc), DEBT_CELL);
1728 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1729 trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
1737 gnc_numeric imbalance;
1747 MonetaryList* imbal_list;
1748 gnc_monetary* imbal_mon;
1757 if (imbal_list->next)
1764 imbal_mon = imbal_list->data;
1791 if (conditionally_changed)
1792 *conditionally_changed = TRUE;
1796 acc = gnc_split_register_get_default_account (reg);
1797 if (gnc_split_register_needs_conv_rate (reg, trans, acc))
1800 xaccTransGetAccountConvRate (trans, acc),
1812 reg->mismatched_commodities));
1817 gnc_commodity* split_commodity;
1820 gnc_commodity* commodity;
1822 account = gnc_split_register_get_default_account (reg);
1828 gboolean use_symbol, is_current;
1829 is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
1830 virt_loc.vcell_loc);
1832 if (reg->type == STOCK_REGISTER ||
1833 reg->type == CURRENCY_REGISTER ||
1834 reg->type == PORTFOLIO_LEDGER)
1836 gnc_commodity* amount_commodity;
1839 if (gnc_split_register_use_security_cells (reg, virt_loc))
1842 amount_commodity = currency;
1847 amount_commodity = split_commodity;
1855 print_info = gnc_commodity_print_info (amount_commodity, use_symbol);
1866 print_info = gnc_commodity_print_info (split_commodity, use_symbol);
1873 case STOCK_REGISTER:
1874 case CURRENCY_REGISTER:
1875 case PORTFOLIO_LEDGER:
1877 print_info = gnc_commodity_print_info (currency, reg->mismatched_commodities);
1889 amount = xaccSplitConvertAmount(split, account);
1893 print_info = gnc_account_print_info (account, reg->mismatched_commodities);
1894 print_info.commodity = commodity;
1917 gnc_split_register_get_rbaln_entry (VirtualLocation virt_loc,
1919 gboolean* conditionally_changed,
1922 SplitRegister* reg = user_data;
1923 SRInfo* info = gnc_split_register_get_info (reg);
1926 gnc_numeric balance;
1930 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1932 gnc_get_current_book()))
1939 balance = gnc_split_register_get_rbaln (virt_loc, user_data, TRUE);
1943 account = gnc_split_register_get_default_account (reg);
1945 if (gnc_reverse_balance (account))
1948 return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
1952 gnc_split_register_cursor_is_readonly (VirtualLocation virt_loc,
1955 SplitRegister* reg = user_data;
1960 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1976 if (!txn)
return FALSE;
1987 gnc_split_register_get_inactive_io_flags (VirtualLocation virt_loc,
1990 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
1991 return XACC_CELL_ALLOW_READ_ONLY;
1993 return XACC_CELL_ALLOW_NONE;
1997 gnc_split_register_get_standard_io_flags (VirtualLocation virt_loc,
2000 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
2001 return XACC_CELL_ALLOW_READ_ONLY;
2003 return XACC_CELL_ALLOW_ALL;
2007 gnc_split_register_get_recn_io_flags (VirtualLocation virt_loc,
2010 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
2011 return XACC_CELL_ALLOW_READ_ONLY;
2013 return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
2017 gnc_split_register_get_doclink_io_flags (VirtualLocation virt_loc,
2020 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
2021 return XACC_CELL_ALLOW_READ_ONLY;
2023 return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
2027 gnc_split_register_get_ddue_io_flags (VirtualLocation virt_loc,
2030 SplitRegister* reg = user_data;
2033 type = gnc_split_register_get_type_value (reg, virt_loc);
2038 return XACC_CELL_ALLOW_NONE;
2041 return XACC_CELL_ALLOW_READ_ONLY;
2045 gnc_split_register_get_rate_io_flags (VirtualLocation virt_loc,
2048 return XACC_CELL_ALLOW_SHADOW;
2052 gnc_split_register_get_debcred_io_flags (VirtualLocation virt_loc,
2055 SplitRegister* reg = user_data;
2058 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
2059 return XACC_CELL_ALLOW_READ_ONLY;
2061 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
2064 return XACC_CELL_ALLOW_NONE;
2066 return XACC_CELL_ALLOW_ALL;
2070 gnc_split_register_get_security_io_flags (VirtualLocation virt_loc,
2073 SplitRegister* reg = user_data;
2075 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
2076 return XACC_CELL_ALLOW_READ_ONLY;
2078 if (gnc_split_register_use_security_cells (reg, virt_loc))
2079 return XACC_CELL_ALLOW_ALL;
2081 return XACC_CELL_ALLOW_SHADOW;
2085 xaccTransWarnReadOnly (GtkWidget* parent, Transaction* trans)
2088 const gchar* reason;
2089 const gchar* format =
2090 _ (
"Cannot modify or delete this transaction. This transaction is " 2091 "marked read-only because:\n\n'%s'");
2093 if (!trans)
return FALSE;
2098 dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
2104 gtk_dialog_run (GTK_DIALOG (dialog));
2105 gtk_widget_destroy (dialog);
2111 static gboolean reg_trans_has_reconciled_splits (SplitRegister* reg,
2118 Split* split = node->data;
2120 if (!xaccTransStillHasSplit (trans, split))
2124 (g_list_index (reg->unrecn_splits, split) == -1))
2132 gnc_split_register_confirm (VirtualLocation virt_loc, gpointer user_data)
2134 SplitRegister* reg = user_data;
2135 SRInfo* info = gnc_split_register_get_info (reg);
2139 const char* cell_name;
2140 gboolean protected_split_cell, protected_trans_cell;
2141 const gchar* title = NULL;
2142 const gchar* message = NULL;
2146 if (info->change_confirmed)
2149 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
2154 if (xaccTransWarnReadOnly (gnc_split_register_get_parent (reg), trans))
2157 if (!reg_trans_has_reconciled_splits (reg, trans))
2160 if (gnc_table_layout_get_cell_changed (reg->table->layout, RECN_CELL, FALSE))
2161 recn = gnc_recn_cell_get_flag
2162 ((
RecnCell*) gnc_table_layout_get_cell (reg->table->layout, RECN_CELL));
2163 else if (g_list_index (reg->unrecn_splits, split) != -1)
2169 cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
2172 if (g_strcmp0 (cell_name,
"transfer") == 0)
2176 protected_split_cell = (g_strcmp0 (cell_name,
"account") == 0) ||
2177 (g_strcmp0 (cell_name,
"transfer") == 0) ||
2178 (g_strcmp0 (cell_name,
"debit") == 0) ||
2179 (g_strcmp0 (cell_name,
"credit") == 0);
2180 protected_trans_cell = (g_strcmp0 (cell_name,
"date") == 0) ||
2181 (g_strcmp0 (cell_name,
"num") == 0) ||
2182 (g_strcmp0 (cell_name,
"description") == 0);
2184 PINFO (
"Protected transaction cell %d, Protected split cell %d, Cell is %s",
2185 protected_trans_cell, protected_split_cell, cell_name);
2187 if (protected_trans_cell)
2189 GList* acc_g_list = NULL;
2190 gchar* acc_list = NULL;
2191 gchar* message_format;
2195 Split* split = node->data;
2199 acc_g_list = g_list_prepend (acc_g_list, name);
2203 title = _ (
"Change transaction containing a reconciled split?");
2205 _ (
"The transaction you are about to change contains reconciled splits in the following accounts:\n%s" 2206 "\n\nAre you sure you want to continue with this change?");
2208 message = g_strdup_printf (message_format, acc_list);
2209 g_list_free_full (acc_g_list, g_free);
2213 if (protected_split_cell)
2215 title = _ (
"Change reconciled split?");
2217 _ (
"You are about to change a protected field of a reconciled split. " 2218 "If you continue editing this split it will be unreconciled. " 2219 "This might make future reconciliation difficult! Continue with this change?");
2222 if ((recn ==
YREC && protected_split_cell) || protected_trans_cell)
2224 GtkWidget* dialog, *window;
2228 window = gnc_split_register_get_parent (reg);
2230 gtk_message_dialog_new (GTK_WINDOW (window),
2231 GTK_DIALOG_DESTROY_WITH_PARENT,
2232 GTK_MESSAGE_WARNING,
2235 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
2238 if (protected_split_cell)
2239 gtk_dialog_add_button (GTK_DIALOG (dialog), _ (
"Chan_ge Split"),
2242 gtk_dialog_add_button (GTK_DIALOG (dialog), _ (
"Chan_ge Transaction"),
2244 response = gnc_dialog_run (GTK_DIALOG (dialog),
2245 GNC_PREF_WARN_REG_RECD_SPLIT_MOD);
2246 gtk_widget_destroy (dialog);
2247 if (response != GTK_RESPONSE_YES)
2251 if (recn ==
YREC && protected_split_cell)
2253 if (g_list_index (reg->unrecn_splits, split) == -1)
2255 reg->unrecn_splits = g_list_append (reg->unrecn_splits, split);
2256 gnc_recn_cell_set_flag
2257 ((
RecnCell*) gnc_table_layout_get_cell (reg->table->layout, RECN_CELL),
2262 PINFO (
"Unreconcile split list length is %d",
2263 g_list_length (reg->unrecn_splits));
2264 info->change_confirmed = TRUE;
2270 gnc_split_register_guid_malloc (
void)
2282 gnc_template_register_get_xfrm_entry (VirtualLocation virt_loc,
2284 gboolean* conditionally_changed,
2287 static char* name = NULL;
2289 SplitRegister* reg = user_data;
2294 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
2303 "sx-account", &guid,
2307 reg->show_leaf_accounts) : NULL;
2313 gnc_template_register_get_fdebt_entry (VirtualLocation virt_loc,
2315 gboolean* conditionally_changed,
2318 SplitRegister* reg = user_data;
2319 Split* split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
2320 static char* formula = NULL;
2327 "sx-debit-formula", &formula,
2335 gnc_split_register_get_fdebt_help (VirtualLocation virt_loc,
2338 SplitRegister* reg = user_data;
2341 help = gnc_table_get_entry (reg->table, virt_loc);
2342 if (!help || *help ==
'\0')
2343 help = _ (
"Enter debit formula for real transaction");
2345 return g_strdup (help);
2349 gnc_template_register_get_fcred_entry (VirtualLocation virt_loc,
2351 gboolean* conditionally_changed,
2354 SplitRegister* reg = user_data;
2355 Split* split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
2356 static char* formula = NULL;
2363 "sx-credit-formula", &formula,
2372 gnc_split_register_get_fcred_help (VirtualLocation virt_loc,
2375 SplitRegister* reg = user_data;
2376 const char* help = gnc_table_get_entry (reg->table, virt_loc);
2378 if (!help || *help ==
'\0')
2379 help = _ (
"Enter credit formula for real transaction");
2381 return g_strdup (help);
2385 gnc_split_register_get_default_help (VirtualLocation virt_loc,
2388 SplitRegister* reg = user_data;
2389 const char* help = gnc_table_get_entry (reg->table, virt_loc);
2391 return g_strdup (help);
2403 gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,
2405 gboolean* conditionally_changed,
2408 SplitRegister* reg = user_data;
2410 gnc_numeric* amount, amount2;
2411 const char* cell_name;
2413 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
2415 return gnc_split_register_get_debcred_entry (virt_loc,
2417 conditionally_changed,
2420 cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
2421 if (gnc_cell_name_equal (cell_name, DEBT_CELL))
2423 "sx-debit-numeric", &amount,
2427 "sx-credit-numeric", &amount,
2441 gnc_default_print_info (reg->mismatched_commodities));
2445 gnc_split_register_guid_free (gpointer guid)
2451 gnc_split_register_guid_copy (gpointer p_to, gconstpointer p_from)
2456 g_return_if_fail (to != NULL);
2462 gnc_split_register_colorize_negative (gpointer gsettings, gchar* key,
2466 GNC_PREF_NEGATIVE_IN_RED);
2471 gnc_split_register_model_add_hooks (gpointer unused)
2474 GNC_PREF_NEGATIVE_IN_RED,
2475 gnc_split_register_colorize_negative,
2478 gnc_prefs_set_reg_negative_color_pref_id (
id);
2482 GNC_PREF_NEGATIVE_IN_RED);
2488 gnc_split_register_model_new (
void)
2491 static GOnce once = G_ONCE_INIT;
2493 g_once (&once, gnc_split_register_model_add_hooks, NULL);
2495 model = gnc_table_model_new();
2498 gnc_table_model_set_entry_handler (model,
2499 gnc_split_register_get_date_entry,
2502 gnc_table_model_set_entry_handler (model,
2503 gnc_split_register_get_due_date_entry,
2506 gnc_table_model_set_entry_handler (model,
2507 gnc_split_register_get_num_entry,
2510 gnc_table_model_set_entry_handler (model,
2511 gnc_split_register_get_tran_num_entry,
2514 gnc_table_model_set_entry_handler (model,
2515 gnc_split_register_get_desc_entry,
2518 gnc_table_model_set_entry_handler (model,
2519 gnc_split_register_get_notes_entry,
2522 gnc_table_model_set_entry_handler (model,
2523 gnc_split_register_get_vnotes_entry,
2526 gnc_table_model_set_entry_handler (model,
2527 gnc_split_register_get_rate_entry,
2530 gnc_table_model_set_entry_handler (model,
2531 gnc_split_register_get_recn_entry,
2534 gnc_table_model_set_entry_handler (model,
2535 gnc_split_register_get_action_entry,
2538 gnc_table_model_set_entry_handler (model,
2539 gnc_split_register_get_memo_entry,
2542 gnc_table_model_set_entry_handler (model,
2543 gnc_split_register_get_balance_entry,
2546 gnc_table_model_set_entry_handler (model,
2547 gnc_split_register_get_balance_entry,
2550 gnc_table_model_set_entry_handler (model,
2551 gnc_split_register_get_price_entry,
2554 gnc_table_model_set_entry_handler (model,
2555 gnc_split_register_get_shares_entry,
2558 gnc_table_model_set_entry_handler (model,
2559 gnc_split_register_get_tshares_entry,
2562 gnc_table_model_set_entry_handler (model,
2563 gnc_split_register_get_xfrm_entry,
2566 gnc_table_model_set_entry_handler (model,
2567 gnc_split_register_get_mxfrm_entry,
2570 gnc_table_model_set_entry_handler (model,
2571 gnc_split_register_get_tdebcred_entry,
2574 gnc_table_model_set_entry_handler (model,
2575 gnc_split_register_get_tdebcred_entry,
2578 gnc_table_model_set_entry_handler (model,
2579 gnc_split_register_get_doclink_entry,
2582 gnc_table_model_set_entry_handler (model,
2583 gnc_split_register_get_type_entry,
2586 gnc_table_model_set_entry_handler (model,
2587 gnc_split_register_get_debcred_entry,
2590 gnc_table_model_set_entry_handler (model,
2591 gnc_split_register_get_debcred_entry,
2594 gnc_table_model_set_entry_handler (model,
2595 gnc_split_register_get_rbaln_entry,
2599 gnc_table_model_set_label_handler (model,
2600 gnc_split_register_get_date_label,
2603 gnc_table_model_set_label_handler (model,
2604 gnc_split_register_get_due_date_label,
2607 gnc_table_model_set_label_handler (model,
2608 gnc_split_register_get_num_label,
2611 gnc_table_model_set_label_handler (model,
2612 gnc_split_register_get_tran_num_label,
2615 gnc_table_model_set_label_handler (model,
2616 gnc_split_register_get_desc_label,
2619 gnc_table_model_set_label_handler (model,
2620 gnc_split_register_get_recn_label,
2623 gnc_table_model_set_label_handler (model,
2624 gnc_split_register_get_baln_label,
2627 gnc_table_model_set_label_handler (model,
2628 gnc_split_register_get_action_label,
2631 gnc_table_model_set_label_handler (model,
2632 gnc_split_register_get_xfrm_label,
2635 gnc_table_model_set_label_handler (model,
2636 gnc_split_register_get_memo_label,
2639 gnc_table_model_set_label_handler (model,
2640 gnc_split_register_get_debit_label,
2643 gnc_table_model_set_label_handler (model,
2644 gnc_split_register_get_credit_label,
2647 gnc_table_model_set_label_handler (model,
2648 gnc_split_register_get_price_label,
2651 gnc_table_model_set_label_handler (model,
2652 gnc_split_register_get_rate_label,
2655 gnc_table_model_set_label_handler (model,
2656 gnc_split_register_get_shares_label,
2659 gnc_table_model_set_label_handler (model,
2660 gnc_split_register_get_mxfrm_label,
2663 gnc_table_model_set_label_handler (model,
2664 gnc_split_register_get_tcredit_label,
2667 gnc_table_model_set_label_handler (model,
2668 gnc_split_register_get_tdebit_label,
2671 gnc_table_model_set_label_handler (model,
2672 gnc_split_register_get_tshares_label,
2675 gnc_table_model_set_label_handler (model,
2676 gnc_split_register_get_tbalance_label,
2679 gnc_table_model_set_label_handler (model,
2680 gnc_split_register_get_doclink_label,
2683 gnc_table_model_set_label_handler (model,
2684 gnc_split_register_get_type_label,
2687 gnc_table_model_set_label_handler (model,
2688 gnc_split_register_get_notes_label,
2691 gnc_table_model_set_label_handler (model,
2692 gnc_split_register_get_fdebit_label,
2695 gnc_table_model_set_label_handler (model,
2696 gnc_split_register_get_fcredit_label,
2699 gnc_table_model_set_label_handler (model,
2700 gnc_split_register_get_tbalance_label,
2705 gnc_table_model_set_tooltip_handler (model,
2706 gnc_split_register_get_recn_tooltip,
2709 gnc_table_model_set_tooltip_handler (model,
2710 gnc_split_register_get_doclink_tooltip,
2715 gnc_table_model_set_default_help_handler (
2716 model, gnc_split_register_get_default_help);
2718 gnc_table_model_set_help_handler (model,
2719 gnc_split_register_get_date_help,
2722 gnc_table_model_set_help_handler (model,
2723 gnc_split_register_get_date_help,
2726 gnc_table_model_set_help_handler (model,
2727 gnc_split_register_get_num_help,
2730 gnc_table_model_set_help_handler (model,
2731 gnc_split_register_get_tran_num_help,
2734 gnc_table_model_set_help_handler (model,
2735 gnc_split_register_get_desc_help,
2738 gnc_table_model_set_help_handler (model,
2739 gnc_split_register_get_price_help,
2742 gnc_table_model_set_help_handler (model,
2743 gnc_split_register_get_shares_help,
2746 gnc_table_model_set_help_handler (model,
2747 gnc_split_register_get_action_help,
2750 gnc_table_model_set_help_handler (model,
2751 gnc_split_register_get_memo_help,
2754 gnc_table_model_set_help_handler (model,
2755 gnc_split_register_get_notes_help,
2758 gnc_table_model_set_help_handler (model,
2759 gnc_split_register_get_vnotes_help,
2762 gnc_table_model_set_help_handler (model,
2763 gnc_split_register_get_xfrm_help,
2766 gnc_table_model_set_help_handler (model,
2767 gnc_split_register_get_mxfrm_help,
2770 gnc_table_model_set_help_handler (model,
2771 gnc_split_register_get_fcred_help,
2774 gnc_table_model_set_help_handler (model,
2775 gnc_split_register_get_fdebt_help,
2778 gnc_table_model_set_help_handler (model,
2779 gnc_split_register_get_doclink_help,
2783 gnc_table_model_set_io_flags_handler (
2784 model, gnc_split_register_get_standard_io_flags, DATE_CELL);
2791 gnc_table_model_set_io_flags_handler (
2792 model, gnc_split_register_get_rate_io_flags, RATE_CELL);
2794 gnc_table_model_set_io_flags_handler (
2795 model, gnc_split_register_get_ddue_io_flags, DDUE_CELL);
2797 gnc_table_model_set_io_flags_handler (
2798 model, gnc_split_register_get_standard_io_flags, NUM_CELL);
2800 gnc_table_model_set_io_flags_handler (
2801 model, gnc_split_register_get_standard_io_flags, TNUM_CELL);
2803 gnc_table_model_set_io_flags_handler (
2804 model, gnc_split_register_get_standard_io_flags, DESC_CELL);
2806 gnc_table_model_set_io_flags_handler (
2807 model, gnc_split_register_get_standard_io_flags, ACTN_CELL);
2809 gnc_table_model_set_io_flags_handler (
2810 model, gnc_split_register_get_standard_io_flags, XFRM_CELL);
2812 gnc_table_model_set_io_flags_handler (
2813 model, gnc_split_register_get_standard_io_flags, MEMO_CELL);
2815 gnc_table_model_set_io_flags_handler (
2816 model, gnc_split_register_get_standard_io_flags, MXFRM_CELL);
2818 gnc_table_model_set_io_flags_handler (
2819 model, gnc_split_register_get_standard_io_flags, NOTES_CELL);
2821 gnc_table_model_set_io_flags_handler (
2822 model, gnc_split_register_get_inactive_io_flags, VNOTES_CELL);
2824 gnc_table_model_set_io_flags_handler (
2825 model, gnc_split_register_get_debcred_io_flags, CRED_CELL);
2827 gnc_table_model_set_io_flags_handler (
2828 model, gnc_split_register_get_debcred_io_flags, DEBT_CELL);
2830 gnc_table_model_set_io_flags_handler (
2831 model, gnc_split_register_get_recn_io_flags, RECN_CELL);
2833 gnc_table_model_set_io_flags_handler (
2834 model, gnc_split_register_get_doclink_io_flags, DOCLINK_CELL);
2836 gnc_table_model_set_io_flags_handler (
2837 model, gnc_split_register_get_recn_io_flags, TYPE_CELL);
2839 gnc_table_model_set_io_flags_handler (
2840 model, gnc_split_register_get_security_io_flags, PRIC_CELL);
2842 gnc_table_model_set_io_flags_handler (
2843 model, gnc_split_register_get_security_io_flags, SHRS_CELL);
2846 gnc_table_model_set_default_cell_color_handler (
2847 model, gnc_split_register_get_cell_color);
2849 gnc_table_model_set_cell_color_handler (
2850 model, gnc_split_register_get_debcred_color, DEBT_CELL);
2852 gnc_table_model_set_cell_color_handler (
2853 model, gnc_split_register_get_debcred_color, CRED_CELL);
2855 gnc_table_model_set_cell_color_handler (
2856 model, gnc_split_register_get_debcred_color, TDEBT_CELL);
2858 gnc_table_model_set_cell_color_handler (
2859 model, gnc_split_register_get_debcred_color, TCRED_CELL);
2861 gnc_table_model_set_cell_color_handler (
2862 model, gnc_split_register_get_debcred_color, FCRED_CELL);
2864 gnc_table_model_set_cell_color_handler (
2865 model, gnc_split_register_get_debcred_color, FDEBT_CELL);
2868 gnc_table_model_set_default_cell_border_handler (
2869 model, gnc_split_register_get_border);
2872 gnc_table_model_set_default_confirm_handler (
2873 model, gnc_split_register_confirm);
2875 model->cell_data_allocator = gnc_split_register_guid_malloc;
2876 model->cell_data_deallocator = gnc_split_register_guid_free;
2877 model->cell_data_copy = gnc_split_register_guid_copy;
2879 gnc_split_register_model_add_save_handlers (model);
2885 gnc_template_register_model_new (
void)
2889 model = gnc_split_register_model_new();
2891 gnc_table_model_set_entry_handler (
2892 model, gnc_split_register_get_inactive_date_entry, DATE_CELL);
2894 gnc_table_model_set_entry_handler (
2895 model, gnc_split_register_get_inactive_date_entry, DDUE_CELL);
2897 gnc_table_model_set_io_flags_handler (
2898 model, gnc_split_register_get_inactive_io_flags, DATE_CELL);
2900 gnc_table_model_set_io_flags_handler (
2901 model, gnc_split_register_get_inactive_io_flags, DDUE_CELL);
2903 gnc_table_model_set_entry_handler (
2904 model, gnc_template_register_get_xfrm_entry, XFRM_CELL);
2906 gnc_table_model_set_entry_handler (
2907 model, gnc_template_register_get_fdebt_entry, FDEBT_CELL);
2909 gnc_table_model_set_entry_handler (
2910 model, gnc_template_register_get_fcred_entry, FCRED_CELL);
2912 gnc_table_model_set_entry_handler (
2913 model, gnc_template_register_get_debcred_entry, DEBT_CELL);
2915 gnc_table_model_set_entry_handler (
2916 model, gnc_template_register_get_debcred_entry, CRED_CELL);
2918 gnc_table_model_set_io_flags_handler (
2919 model, gnc_split_register_get_standard_io_flags, FCRED_CELL);
2921 gnc_table_model_set_io_flags_handler (
2922 model, gnc_split_register_get_standard_io_flags, FDEBT_CELL);
2924 gnc_template_register_model_add_save_handlers (model);
The RecnCell object implements a cell handler that will cycle through a series of single-character va...
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
const char * gnc_split_register_get_credit_string(SplitRegister *reg)
Return the credit string used in the register.
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
Split * xaccTransGetSplit(const Transaction *trans, int i)
Return a pointer to the indexed split in this transaction's split list.
gchar * gnc_uri_get_scheme(const gchar *uri)
Extracts the scheme from a uri.
gboolean xaccTransUseTradingAccounts(const Transaction *trans)
Determine whether this transaction should use commodity trading accounts.
gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans)
Returns TRUE if this Transaction is read-only because its posted-date is older than the "auto-readonl...
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Register a callback that gets triggered when the given preference changes.
gchar * gnc_g_list_stringjoin(GList *list_of_strings, const gchar *sep)
Return a string joining a GList whose elements are gchar* strings.
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
gnc_numeric xaccTransGetAccountBalance(const Transaction *trans, const Account *account)
Get the account balance for the specified account after the last split in the specified transaction...
char xaccTransGetTxnType(Transaction *trans)
Returns the Transaction Type: note this type will be derived from the transaction splits...
#define TXN_TYPE_INVOICE
Transaction is an invoice.
#define PINFO(format, args...)
Print an informational note.
Transaction * gnc_split_register_get_current_trans(SplitRegister *reg)
Gets the transaction at the current cursor location, which may be on the transaction itself or on any...
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
const char * xaccTransGetVoidReason(const Transaction *trans)
Returns the user supplied textual reason why a transaction was voided.
holds information about each virtual cell.
const char * xaccTransGetReadOnly(Transaction *trans)
Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text...
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
CursorClass gnc_split_register_get_cursor_class(SplitRegister *reg, VirtualCellLocation vcell_loc)
Returns the class of the cursor at the given virtual cell location.
Save handlers for the SplitRegister Model and Template SplitRegister model.
gboolean gnc_split_reg_has_rate_cell(SplitRegisterType type)
Determine if we need to perform any conversion on the splits in this transaction, and if so...
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
TableModels specialized for SplitRegister and template SplitRegister.
The Doclinkcell object implements a cell handler that will cycle through a series of single-character...
gboolean xaccTransIsBalanced(const Transaction *trans)
Returns true if the transaction is balanced according to the rules currently in effect.
gnc_numeric xaccSplitGetBalance(const Split *s)
Returns the running balance up to and including the indicated split.
gboolean gnc_split_register_current_trans_expanded(SplitRegister *reg)
Return TRUE if current trans is expanded and style is REG_STYLE_LEDGER.
const char * xaccTransGetDocLink(const Transaction *trans)
Gets the transaction Document Link.
gboolean gnc_numeric_negative_p(gnc_numeric a)
Returns 1 if a < 0, otherwise returns 0.
#define VREC
split is void
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
#define PWARN(format, args...)
Log a warning.
const char * xaccTransGetNotes(const Transaction *trans)
Gets the transaction Notes.
#define TXN_TYPE_NONE
No transaction type.
Split * xaccSplitLookup(const GncGUID *guid, QofBook *book)
The xaccSplitLookup() subroutine will return the split associated with the given id, or NULL if there is no such split.
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
const char * gnc_split_register_get_debit_string(SplitRegister *reg)
Return the debit string used in the register.
gnc_numeric gnc_numeric_convert(gnc_numeric n, gint64 denom, gint how)
Change the denominator of a gnc_numeric value to the specified denominator under standard arguments '...
Reduce the result value by common factor elimination, using the smallest possible value for the denom...
GncGUID * guid_malloc(void)
Allocate memory for a GUID.
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
The xaccTransGetImbalanceValue() method returns the total value of the transaction.
CursorClass
Types of cursors.
#define YREC
The Split has been reconciled.
char * gnc_get_account_name_for_split_register(const Account *account, gboolean show_leaf_accounts)
Get either the full name of the account or the simple name, depending on the show_leaf_accounts.
gnc_numeric gnc_numeric_mul(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Multiply a times b, returning the product.
The PriceCell object implements a cell handler that stores a single double-precision value...
VirtualCell * gnc_table_get_virtual_cell(Table *table, VirtualCellLocation vcell_loc)
returns the virtual cell associated with a particular virtual location.
void gnc_monetary_list_free(MonetaryList *list)
Free a MonetaryList and all the monetaries it points to.
void gnc_date_cell_get_date(DateCell *cell, time64 *time, gboolean warn)
Set a time64 to the value in the DateCell.
char * gnc_print_time64(time64 time, const char *format)
print a time64 as a date string per format
time64 xaccTransRetDatePosted(const Transaction *trans)
Retrieve the posted date of the transaction.
private declarations for SplitRegister
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
unsigned int start_primary_color
visible in the GUI
gnc_numeric gnc_numeric_abs(gnc_numeric a)
Returns a newly created gnc_numeric that is the absolute value of the given gnc_numeric value...
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
gnc_numeric gnc_numeric_div(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Division.
gnc_numeric xaccSplitGetSharePrice(const Split *split)
Returns the price of the split, that is, the value divided by the amount.
All type declarations for the whole Gnucash engine.
API for checkbook register display area.
gboolean gnc_numeric_positive_p(gnc_numeric a)
Returns 1 if a > 0, otherwise returns 0.
Account * gnc_account_lookup_for_register(const Account *base_account, const char *name)
Retrieve the account matching the given name starting from the descendants of base_account.
Generic api to store and retrieve preferences.
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
time64 xaccSplitGetDateReconciled(const Split *split)
Retrieve the date when the Split was reconciled.
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
gnc_commodity * xaccTransGetCurrency(const Transaction *trans)
Returns the valuation commodity of this transaction.
MonetaryList * xaccTransGetImbalance(const Transaction *trans)
The xaccTransGetImbalance method returns a list giving the value of the transaction in each currency ...
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
Split * xaccSplitGetOtherSplit(const Split *split)
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits...
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
const char * gnc_get_doclink_str(char link_flag)
Get a string representing the document link type.
Utility functions for convert uri in separate components and back.
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
The DateCell object implements a date handling cell.
File path resolution utility functions.
const char * xaccSplitGetType(const Split *s)
The xaccIsPeerSplit() is a convenience routine that returns TRUE (a non-zero value) if the two splits...
SplitRegisterType
Register types.
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
The type used to store guids in C.
gnc_numeric gnc_price_cell_get_value(PriceCell *cell)
return the value of a price cell
time64 xaccTransRetDateDue(const Transaction *trans)
Dates and txn-type for A/R and A/P "invoice" postings.
size_t qof_print_date_buff(char *buff, size_t buflen, time64 secs)
Convenience: calls through to qof_print_date_dmy_buff().
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
gnc_numeric xaccTransGetAccountAmount(const Transaction *trans, const Account *acc)
Same as xaccTransGetAccountValue, but uses the Account's commodity.
gboolean gnc_commodity_is_iso(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency.
gnc_numeric xaccTransGetAccountValue(const Transaction *trans, const Account *acc)
The xaccTransGetAccountValue() method returns the total value applied to a particular account...
#define NREC
not reconciled or cleared
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...