26 #include <glib/gi18n.h>
29 #include "dialog-utils.h"
33 #include "gnome-utils/gnc-warnings.h"
34 #include "pricecell.h"
37 #include "split-register-model.h"
38 #include "split-register-model-save.h"
39 #include "split-register-p.h"
40 #include "engine-helpers.h"
46 static gboolean use_red_for_negative = TRUE;
53 gnc_split_register_get_rbaln (
VirtualLocation virt_loc, gpointer user_data, gboolean subaccounts)
57 SRInfo *info = gnc_split_register_get_info (reg);
62 GList *children = NULL;
65 balance = gnc_numeric_zero();
68 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
70 gnc_get_current_book ()))
71 return gnc_numeric_zero();
75 return gnc_numeric_zero();
78 account = gnc_split_register_get_default_account(reg);
87 children = g_list_append(children, account);
91 row = virt_loc.vcell_loc.virt_row;
92 virt_loc.vcell_loc.virt_row = 0;
94 while (virt_loc.vcell_loc.virt_row <= row )
97 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
103 Split *secondary = node->data;
112 for (child = children; child; child = child->next)
114 if (account == child->data)
127 virt_loc.vcell_loc.virt_row += i;
131 g_list_free(children);
144 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
150 if (cursor_class != CURSOR_CLASS_SPLIT)
155 if (virt_cell_loc_equal (virt_loc.vcell_loc,
156 reg->
table->current_cursor_loc.vcell_loc) &&
157 gnc_table_layout_get_cell_changed (reg->
table->layout, XFRM_CELL, FALSE))
161 name = gnc_table_layout_get_cell_value (reg->
table->layout, XFRM_CELL);
182 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
188 if (cursor_class != CURSOR_CLASS_SPLIT)
193 if (virt_cell_loc_equal (virt_loc.vcell_loc,
194 reg->
table->current_cursor_loc.vcell_loc) &&
195 gnc_table_layout_get_cell_changed (reg->
table->layout, XFRM_CELL, FALSE))
199 name = gnc_table_layout_get_cell_value (reg->
table->layout, XFRM_CELL);
231 return _(
"Due Date");
242 case RECEIVABLE_REGISTER:
243 case PAYABLE_REGISTER:
258 case RECEIVABLE_REGISTER:
259 case PAYABLE_REGISTER:
281 case RECEIVABLE_REGISTER:
282 return _(
"Customer");
283 case PAYABLE_REGISTER:
286 return _(
"Description");
298 case RECEIVABLE_REGISTER:
299 case PAYABLE_REGISTER:
303 return _(
"Reconciled:R") + 11;
332 return _(
"Transfer");
374 if (!gnc_split_register_use_security_cells (reg, virt_loc))
377 commod = gnc_split_register_get_split_commodity (reg, virt_loc);
381 return _(
"Exch. Rate");
391 if (!gnc_split_register_use_security_cells (reg, virt_loc))
394 commod = gnc_split_register_get_split_commodity (reg, virt_loc);
398 return _(
"Oth. Curr.");
406 SRInfo *info = gnc_split_register_get_info (reg);
408 if (info->tcredit_str)
409 return info->tcredit_str;
415 info->tcredit_str = g_strdup_printf (_(
"Tot %s"),
string);
418 if (info->tcredit_str)
419 return info->tcredit_str;
421 info->tcredit_str = g_strdup (_(
"Tot Credit"));
423 return info->tcredit_str;
431 SRInfo *info = gnc_split_register_get_info (reg);
433 if (info->tdebit_str)
434 return info->tdebit_str;
439 info->tdebit_str = g_strdup_printf (_(
"Tot %s"),
string);
442 if (info->tdebit_str)
443 return info->tdebit_str;
445 info->tdebit_str = g_strdup (_(
"Tot Debit"));
447 return info->tdebit_str;
454 return _(
"Tot Shares");
475 return _(
"Debit Formula");
482 return _(
"Credit Formula");
488 Account *account = gnc_split_register_get_default_account (reg);
497 account = gnc_split_register_get_default_account (reg);
498 if (!trans || !account)
return gnc_numeric_zero();
506 const guint32 *color_table,
509 const char *cursor_name;
512 gboolean double_alternate_virt;
513 guint32 colorbase = 0;
516 colorbase = COLOR_UNKNOWN_FG;
519 return color_table[colorbase + COLOR_UNKNOWN_BG];
521 if (gnc_table_virtual_location_in_header (reg->
table, virt_loc))
522 return color_table[colorbase + COLOR_HEADER_BG];
524 vcell = gnc_table_get_virtual_cell (reg->
table, virt_loc.vcell_loc);
525 if (!vcell || !vcell->cellblock)
526 return color_table[colorbase + COLOR_UNKNOWN_BG];
528 if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
529 (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
530 return color_table[colorbase + COLOR_UNKNOWN_BG];
532 is_current = virt_cell_loc_equal (reg->
table->current_cursor_loc.vcell_loc,
535 cursor_name = vcell->cellblock->cursor_name;
537 if (g_strcmp0 (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
538 g_strcmp0 (cursor_name, CURSOR_SINGLE_LEDGER) == 0)
541 return vcell->start_primary_color ?
542 color_table[colorbase + COLOR_PRIMARY_BG_ACTIVE] :
543 color_table[colorbase + COLOR_SECONDARY_BG_ACTIVE];
545 return vcell->start_primary_color ?
546 color_table[colorbase + COLOR_PRIMARY_BG] : color_table[colorbase + COLOR_SECONDARY_BG];
549 if (g_strcmp0 (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
550 g_strcmp0 (cursor_name, CURSOR_DOUBLE_JOURNAL_NUM_ACTN) == 0 ||
551 g_strcmp0 (cursor_name, CURSOR_DOUBLE_LEDGER) == 0 ||
552 g_strcmp0 (cursor_name, CURSOR_DOUBLE_LEDGER_NUM_ACTN) == 0)
555 GNC_PREF_ALT_COLOR_BY_TRANS);
558 if (double_alternate_virt)
559 return vcell->start_primary_color ?
560 color_table[colorbase + COLOR_PRIMARY_BG_ACTIVE] :
561 color_table[colorbase + COLOR_SECONDARY_BG_ACTIVE];
563 return (virt_loc.phys_row_offset % 2 == 0) ?
564 color_table[colorbase + COLOR_PRIMARY_BG_ACTIVE] :
565 color_table[colorbase + COLOR_SECONDARY_BG_ACTIVE];
568 if (double_alternate_virt)
569 return vcell->start_primary_color ?
570 color_table[colorbase + COLOR_PRIMARY_BG] :
571 color_table[colorbase + COLOR_SECONDARY_BG];
573 return (virt_loc.phys_row_offset % 2 == 0) ?
574 color_table[colorbase + COLOR_PRIMARY_BG] :
575 color_table[colorbase + COLOR_SECONDARY_BG];
578 if (g_strcmp0 (cursor_name, CURSOR_SPLIT) == 0)
581 return color_table[colorbase + COLOR_SPLIT_BG_ACTIVE];
583 return color_table[colorbase + COLOR_SPLIT_BG];
586 PWARN (
"Unexpected cursor: %s\n", cursor_name);
588 return color_table[colorbase + COLOR_UNKNOWN_BG];
594 const guint32 *color_table)
596 const guint32 red_color = color_table[COLOR_NEGATIVE];
598 const char * cell_name;
603 fg_color = gnc_split_register_get_color_internal (virt_loc, reg, color_table, TRUE);
605 if (!use_red_for_negative)
608 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
612 cell_name = gnc_table_get_cell_name (reg->
table, virt_loc);
614 if (gnc_cell_name_equal (cell_name, TSHRS_CELL))
616 else if (gnc_cell_name_equal (cell_name, SHRS_CELL))
618 if (virt_cell_loc_equal (reg->
table->current_cursor_loc.vcell_loc,
620 value = gnc_price_cell_get_value
626 else if (gnc_cell_name_equal (cell_name, BALN_CELL))
628 else if (gnc_cell_name_equal (cell_name, RBALN_CELL))
629 value = gnc_split_register_get_rbaln (virt_loc, reg, TRUE);
630 else if (gnc_cell_name_equal (cell_name, TBALN_CELL))
633 if ((gnc_cell_name_equal (cell_name, BALN_CELL)) ||
634 (gnc_cell_name_equal (cell_name, RBALN_CELL)) ||
635 (gnc_cell_name_equal (cell_name, TBALN_CELL)))
638 if (gnc_reverse_balance (account))
653 return gnc_split_register_get_fg_color_internal (virt_loc, reg, reg_colors_default);
661 return gnc_split_register_get_fg_color_internal (virt_loc, reg, reg_colors_gtkrc);
674 return gnc_split_register_get_color_internal (virt_loc, reg, reg_colors_default, FALSE);
688 return gnc_split_register_get_color_internal (virt_loc, reg, reg_colors_gtkrc, FALSE);
702 trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
710 return gnc_split_register_get_bg_color (virt_loc, NULL, user_data);
722 vcell = gnc_table_get_virtual_cell (reg->
table, virt_loc.vcell_loc);
723 if (!vcell || !vcell->cellblock)
726 if (virt_loc.phys_col_offset < vcell->cellblock->start_col ||
727 virt_loc.phys_col_offset > vcell->cellblock->stop_col)
729 borders->top = CELL_BORDER_LINE_NONE;
730 borders->bottom = CELL_BORDER_LINE_NONE;
731 borders->left = CELL_BORDER_LINE_NONE;
732 borders->right = CELL_BORDER_LINE_NONE;
737 gnc_split_register_cursor_name_to_class (vcell->cellblock->cursor_name);
739 if (cursor_class == CURSOR_CLASS_TRANS &&
740 virt_loc.phys_col_offset == vcell->cellblock->start_col)
741 borders->left = CELL_BORDER_LINE_NONE;
743 if (cursor_class == CURSOR_CLASS_TRANS &&
744 virt_loc.phys_col_offset == vcell->cellblock->stop_col)
745 borders->right = CELL_BORDER_LINE_NONE;
747 if (cursor_class == CURSOR_CLASS_SPLIT)
749 borders->top = CELL_BORDER_LINE_LIGHT;
750 borders->bottom = CELL_BORDER_LINE_LIGHT;
751 borders->left = MIN (borders->left, CELL_BORDER_LINE_LIGHT);
752 borders->right = MIN (borders->right, CELL_BORDER_LINE_LIGHT);
754 if (virt_loc.phys_col_offset == vcell->cellblock->start_col)
755 borders->left = CELL_BORDER_LINE_LIGHT;
756 if (virt_loc.phys_col_offset == vcell->cellblock->stop_col)
757 borders->right = CELL_BORDER_LINE_LIGHT;
764 gboolean *conditionally_changed,
772 trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
793 cell = (
RecnCell *)gnc_table_layout_get_cell (reg->
table->layout, TYPE_CELL);
797 return gnc_recn_cell_get_flag (cell);
803 gboolean *conditionally_changed,
813 is_current = virt_cell_loc_equal (reg->
table->current_cursor_loc.vcell_loc,
818 type = gnc_split_register_get_type_value (reg, virt_loc);
822 const char *typestr =
823 gnc_split_register_get_type_entry (virt_loc, translate,
824 conditionally_changed, user_data);
838 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
855 gboolean *conditionally_changed,
863 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
882 cell = gnc_table_get_cell (reg->
table, virt_loc);
883 if (!cell || !cell->value || *cell->value ==
'\0')
886 g_date_clear (&date, 1);
887 gnc_date_cell_get_date_gdate ((
DateCell *) cell, &date);
889 g_date_strftime (
string,
sizeof (
string), _(
"%A %d %B %Y"), &date);
891 return g_strdup (
string);
897 gboolean *conditionally_changed,
902 return _(
"Scheduled");
908 gboolean *conditionally_changed,
915 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
918 return gnc_get_num_action (trans, split);
924 gboolean *conditionally_changed,
931 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
934 return gnc_get_num_action (trans, NULL);
944 help = gnc_table_get_entry (reg->
table, virt_loc);
945 if (!help || *help ==
'\0')
948 case RECEIVABLE_REGISTER:
949 case PAYABLE_REGISTER:
951 _(
"Enter a reference, such as an invoice or check number, "
952 "common to all entry lines (splits)") :
953 _(
"Enter a reference, such as an invoice or check number, "
954 "unique to each entry line (split)");
958 _(
"Enter a reference, such as a check number, "
959 "common to all entry lines (splits)") :
960 _(
"Enter a reference, such as a check number, "
961 "unique to each entry line (split)");
965 return g_strdup (help);
975 help = gnc_table_get_entry (reg->
table, virt_loc);
976 if (!help || *help ==
'\0')
979 case RECEIVABLE_REGISTER:
980 case PAYABLE_REGISTER:
981 help = _(
"Enter a transaction reference, such as an invoice "
982 "or check number, common to all entry lines (splits)");
985 help = _(
"Enter a transaction reference "
986 "that will be common to all entry lines (splits)");
990 return g_strdup (help);
996 gboolean *conditionally_changed,
1003 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1016 help = gnc_table_get_entry (reg->
table, virt_loc);
1017 if (!help || *help ==
'\0')
1020 case RECEIVABLE_REGISTER:
1021 help = _(
"Enter the name of the Customer");
1023 case PAYABLE_REGISTER:
1024 help = _(
"Enter the name of the Vendor");
1027 help = _(
"Enter a description of the transaction");
1030 return g_strdup (help);
1036 gboolean *conditionally_changed,
1043 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1056 help = gnc_table_get_entry (reg->
table, virt_loc);
1057 if (!help || *help ==
'\0')
1058 help = _(
"Enter notes for the transaction");
1060 return g_strdup (help);
1066 gboolean *conditionally_changed,
1073 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1089 help = gnc_table_get_entry (reg->
table, virt_loc);
1090 if (!help || *help ==
'\0')
1091 help = _(
"Reason the transaction was voided");
1093 return g_strdup (help);
1099 gboolean *conditionally_changed,
1103 Split *split, *osplit;
1106 SRInfo *info = gnc_split_register_get_info (reg);
1108 if (info->rate_reset == RATE_RESET_REQD && info->auto_complete)
1111 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1120 txn = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
1123 !gnc_split_register_needs_conv_rate(reg, txn,
1137 return xaccPrintAmount (convrate, gnc_default_price_print_info ());
1143 gboolean *conditionally_changed,
1149 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1169 gboolean *conditionally_changed,
1173 Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
1175 return gnc_get_num_action (NULL, split);
1185 help = gnc_table_get_entry (reg->
table, virt_loc);
1186 if (!help || *help ==
'\0')
1188 _(
"Enter an action type, or choose one from the list") :
1189 _(
"Enter a reference number, such as the next check number, or choose an action type from the list");
1191 return g_strdup (help);
1197 gboolean *conditionally_changed,
1203 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1215 help = gnc_table_get_entry (reg->
table, virt_loc);
1216 if (!help || *help ==
'\0')
1217 help = _(
"Enter a description of the split");
1218 return g_strdup (help);
1224 gboolean *conditionally_changed,
1228 SRInfo *info = gnc_split_register_get_info (reg);
1234 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1237 gnc_get_current_book ()))
1240 is_trans = gnc_cell_name_equal
1241 (gnc_table_get_cell_name (reg->
table, virt_loc), TBALN_CELL);
1250 account = gnc_split_register_get_default_account (reg);
1252 if (gnc_reverse_balance (account))
1255 return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
1261 gboolean *conditionally_changed,
1268 if (!gnc_split_register_use_security_cells (reg, virt_loc))
1271 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1277 return xaccPrintAmount (price, gnc_default_price_print_info ());
1287 help = gnc_table_get_entry (reg->
table, virt_loc);
1288 if (!help || *help ==
'\0')
1289 help = _(
"Enter the effective share price");
1291 return g_strdup (help);
1297 gboolean *conditionally_changed,
1304 if (!gnc_split_register_use_security_cells (reg, virt_loc))
1307 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1313 return xaccPrintAmount (shares, gnc_split_amount_print_info (split, FALSE));
1323 help = gnc_table_get_entry (reg->
table, virt_loc);
1324 if (!help || *help ==
'\0')
1325 help = _(
"Enter the number of shares bought or sold");
1327 return g_strdup (help);
1333 gboolean *conditionally_changed,
1340 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1344 return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
1350 gboolean *conditionally_changed,
1353 static char *name = NULL;
1358 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1374 help = gnc_table_get_entry (reg->
table, virt_loc);
1375 if (!help || *help ==
'\0')
1376 help = _(
"Enter the account to transfer from, "
1377 "or choose one from the list");
1379 return g_strdup (help);
1385 gboolean *conditionally_changed,
1388 static char *name = NULL;
1394 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1411 name = g_strdup (SPLIT_TRANS_STR);
1413 name = g_strdup (STOCK_SPLIT_STR);
1415 name = g_strdup (
"");
1431 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1439 help = gnc_split_register_get_mxfrm_entry (virt_loc, FALSE,
1441 if (!help || *help ==
'\0')
1442 help = _(
"Enter the account to transfer from, "
1443 "or choose one from the list");
1452 help = _(
"This transaction has multiple splits; "
1453 "press the Split button to see them all");
1455 help = _(
"This transaction is a stock split; "
1456 "press the Split button to see details");
1461 return g_strdup (help);
1469 GList *children, *child;
1474 parent = gnc_split_register_get_default_account(reg);
1481 children = g_list_append(children, parent);
1483 for (child = children; child; child = child->next)
1488 g_list_free(children);
1496 gboolean *conditionally_changed,
1500 const char * cell_name;
1504 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1508 cell_name = gnc_table_get_cell_name (reg->
table, virt_loc);
1512 case GENERAL_LEDGER:
1525 gnc_cell_name_equal (cell_name, TDEBT_CELL))
1529 gnc_cell_name_equal (cell_name, TCRED_CELL))
1534 return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
1547 case ASSET_REGISTER:
1548 case CREDIT_REGISTER:
1549 case LIABILITY_REGISTER:
1550 case INCOME_REGISTER:
1551 case EXPENSE_REGISTER:
1552 case EQUITY_REGISTER:
1553 case TRADING_REGISTER:
1554 case GENERAL_LEDGER:
1559 case STOCK_REGISTER:
1560 case CURRENCY_REGISTER:
1561 case PORTFOLIO_LEDGER:
1562 case RECEIVABLE_REGISTER:
1563 case PAYABLE_REGISTER:
1580 if (!gnc_split_reg_has_rate_cell (reg->type))
1595 gboolean *conditionally_changed,
1604 is_debit = gnc_cell_name_equal
1605 (gnc_table_get_cell_name (reg->
table, virt_loc), DEBT_CELL);
1607 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1608 trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
1626 MonetaryList *imbal_list;
1636 if (imbal_list->next)
1643 imbal_mon = imbal_list->data;
1670 if (conditionally_changed)
1671 *conditionally_changed = TRUE;
1675 acc = gnc_split_register_get_default_account (reg);
1676 if (gnc_split_register_needs_conv_rate (reg, trans, acc))
1679 xaccTransGetAccountConvRate(trans, acc),
1690 return xaccPrintAmount (imbalance, gnc_account_print_info (acc, FALSE));
1700 account = gnc_split_register_get_default_account (reg);
1706 gboolean use_symbol, is_current;
1707 is_current = virt_cell_loc_equal (reg->
table->current_cursor_loc.vcell_loc,
1708 virt_loc.vcell_loc);
1710 if (reg->type == STOCK_REGISTER ||
1711 reg->type == CURRENCY_REGISTER ||
1712 reg->type == PORTFOLIO_LEDGER)
1717 if (gnc_split_register_use_security_cells(reg, virt_loc))
1720 amount_commodity = currency;
1725 amount_commodity = split_commodity;
1733 print_info = gnc_commodity_print_info(amount_commodity, use_symbol);
1744 print_info = gnc_commodity_print_info(split_commodity, use_symbol);
1755 case STOCK_REGISTER:
1756 case CURRENCY_REGISTER:
1757 case PORTFOLIO_LEDGER:
1759 print_info = gnc_commodity_print_info (currency, FALSE);
1765 amount = xaccSplitConvertAmount(split, account);
1768 print_info = gnc_account_print_info (account, FALSE);
1784 return xaccPrintAmount (amount, print_info);
1793 gboolean *conditionally_changed,
1797 SRInfo *info = gnc_split_register_get_info (reg);
1804 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1806 gnc_get_current_book ()))
1813 balance = gnc_split_register_get_rbaln (virt_loc, user_data, TRUE);
1817 account = gnc_split_register_get_default_account (reg);
1819 if (gnc_reverse_balance (account))
1822 return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
1834 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1835 if (!split)
return FALSE;
1838 if (!txn)
return FALSE;
1852 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
1853 return XACC_CELL_ALLOW_READ_ONLY;
1855 return XACC_CELL_ALLOW_NONE;
1862 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
1863 return XACC_CELL_ALLOW_READ_ONLY;
1865 return XACC_CELL_ALLOW_ALL;
1872 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
1873 return XACC_CELL_ALLOW_READ_ONLY;
1875 return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
1885 type = gnc_split_register_get_type_value (reg, virt_loc);
1890 return XACC_CELL_ALLOW_NONE;
1893 return XACC_CELL_ALLOW_READ_ONLY;
1900 return XACC_CELL_ALLOW_SHADOW;
1910 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
1911 return XACC_CELL_ALLOW_READ_ONLY;
1913 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1916 return XACC_CELL_ALLOW_NONE;
1918 return XACC_CELL_ALLOW_ALL;
1927 if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
1928 return XACC_CELL_ALLOW_READ_ONLY;
1930 if (gnc_split_register_use_security_cells (reg, virt_loc))
1931 return XACC_CELL_ALLOW_ALL;
1933 return XACC_CELL_ALLOW_SHADOW;
1940 const gchar *reason;
1941 const gchar *format =
1942 _(
"Cannot modify or delete this transaction. This transaction is "
1943 "marked read-only because:\n\n'%s'");
1945 if (!trans)
return FALSE;
1950 dialog = gtk_message_dialog_new(NULL,
1956 gtk_dialog_run(GTK_DIALOG(dialog));
1957 gtk_widget_destroy(dialog);
1965 gnc_split_register_confirm (
VirtualLocation virt_loc, gpointer user_data)
1968 SRInfo *info = gnc_split_register_get_info (reg);
1972 const char *cell_name;
1977 if (info->change_confirmed)
1980 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
1985 if (xaccTransWarnReadOnly(trans))
1987 if (gnc_table_layout_get_cell_changed (reg->
table->layout, RECN_CELL, FALSE))
1988 recn = gnc_recn_cell_get_flag
1989 ((
RecnCell *) gnc_table_layout_get_cell (reg->
table->layout, RECN_CELL));
1994 cell_name = gnc_table_get_cell_name (reg->
table, virt_loc);
1997 change_ok = (g_strcmp0(cell_name,
"notes") == 0) || (g_strcmp0(cell_name,
"memo") == 0) || (g_strcmp0(cell_name,
"action") == 0);
2001 GtkWidget *dialog, *window;
2004 const gchar *message;
2008 title = _(
"Change reconciled split?");
2010 _(
"You are about to change a reconciled split. Doing so might make "
2011 "future reconciliation difficult! Continue with this change?");
2015 title = _(
"Change split linked to a reconciled split?");
2017 _(
"You are about to change a split that is linked to a reconciled split. "
2018 "Doing so might make future reconciliation difficult! Continue with this change?");
2022 window = gnc_split_register_get_parent(reg);
2024 gtk_message_dialog_new(GTK_WINDOW(window),
2025 GTK_DIALOG_DESTROY_WITH_PARENT,
2026 GTK_MESSAGE_WARNING,
2029 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
2031 gtk_dialog_add_button(GTK_DIALOG(dialog), _(
"Chan_ge Split"),
2033 response = gnc_dialog_run(GTK_DIALOG(dialog), GNC_PREF_WARN_REG_RECD_SPLIT_MOD);
2034 gtk_widget_destroy(dialog);
2035 if (response != GTK_RESPONSE_YES)
2038 info->change_confirmed = TRUE;
2045 gnc_split_register_guid_malloc (
void)
2059 gboolean *conditionally_changed,
2062 static char *name = NULL;
2069 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
2078 "sx-account", &guid,
2089 gboolean *conditionally_changed,
2093 Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
2094 char *formula = NULL;
2097 "sx-debit-formula", &formula,
2110 help = gnc_table_get_entry (reg->
table, virt_loc);
2111 if (!help || *help ==
'\0')
2112 help = _(
"Enter debit formula for real transaction");
2114 return g_strdup (help);
2120 gboolean *conditionally_changed,
2124 Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
2125 char *formula = NULL;
2128 "sx-credit-formula", &formula,
2140 const char *help = gnc_table_get_entry (reg->
table, virt_loc);
2142 if (!help || *help ==
'\0')
2143 help = _(
"Enter credit formula for real transaction");
2145 return g_strdup (help);
2153 const char *help = gnc_table_get_entry(reg->
table, virt_loc);
2155 return g_strdup (help);
2161 gboolean *conditionally_changed,
2164 PERR(
"The function called always returned either NULL or an empty string "
2165 "while issuing dire warnings about how incorrect it is. That code "
2166 "has been removed and the function if called raises this error and "
2173 split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
2175 return gnc_split_register_get_debcred_entry (virt_loc,
2177 conditionally_changed,
2180 kvpf = xaccSplitGetSlots (split);
2181 PWARN(
"We're very close to \"wrong\". \"Fix it immediately!!!\"" );
2186 const char * cell_name;
2189 PWARN(
"This code is wrong. Fix it immediately!!!!");
2193 amount = gnc_numeric_zero ();
2199 cell_name = gnc_table_get_cell_name (reg->
table, virt_loc);
2202 gnc_cell_name_equal (cell_name, DEBT_CELL))
2206 gnc_cell_name_equal (cell_name, CRED_CELL))
2212 return xaccPrintAmount (amount, gnc_default_print_info (FALSE));
2220 gnc_split_register_guid_free (gpointer guid)
2226 gnc_split_register_guid_copy (gpointer p_to, gconstpointer p_from)
2231 g_return_if_fail (to != NULL);
2237 gnc_split_register_colorize_negative (gpointer gsettings, gchar *key, gpointer unused)
2240 GNC_PREF_NEGATIVE_IN_RED);
2245 gnc_split_register_model_add_hooks (gpointer unused)
2248 gnc_split_register_colorize_negative,
2252 GNC_PREF_NEGATIVE_IN_RED);
2258 gnc_split_register_model_new (
void)
2261 static GOnce once = G_ONCE_INIT;
2263 g_once(&once, gnc_split_register_model_add_hooks, NULL);
2265 model = gnc_table_model_new ();
2267 gnc_table_model_set_entry_handler (model,
2268 gnc_split_register_get_date_entry,
2271 gnc_table_model_set_entry_handler (model,
2272 gnc_split_register_get_due_date_entry,
2275 gnc_table_model_set_entry_handler (model,
2276 gnc_split_register_get_num_entry,
2279 gnc_table_model_set_entry_handler (model,
2280 gnc_split_register_get_tran_num_entry,
2283 gnc_table_model_set_entry_handler (model,
2284 gnc_split_register_get_desc_entry,
2287 gnc_table_model_set_entry_handler (model,
2288 gnc_split_register_get_notes_entry,
2291 gnc_table_model_set_entry_handler (model,
2292 gnc_split_register_get_vnotes_entry,
2295 gnc_table_model_set_entry_handler (model,
2296 gnc_split_register_get_rate_entry,
2299 gnc_table_model_set_entry_handler (model,
2300 gnc_split_register_get_recn_entry,
2303 gnc_table_model_set_entry_handler (model,
2304 gnc_split_register_get_action_entry,
2307 gnc_table_model_set_entry_handler (model,
2308 gnc_split_register_get_memo_entry,
2311 gnc_table_model_set_entry_handler (model,
2312 gnc_split_register_get_balance_entry,
2315 gnc_table_model_set_entry_handler (model,
2316 gnc_split_register_get_balance_entry,
2319 gnc_table_model_set_entry_handler (model,
2320 gnc_split_register_get_price_entry,
2323 gnc_table_model_set_entry_handler (model,
2324 gnc_split_register_get_shares_entry,
2327 gnc_table_model_set_entry_handler (model,
2328 gnc_split_register_get_tshares_entry,
2331 gnc_table_model_set_entry_handler (model,
2332 gnc_split_register_get_xfrm_entry,
2335 gnc_table_model_set_entry_handler (model,
2336 gnc_split_register_get_mxfrm_entry,
2339 gnc_table_model_set_entry_handler (model,
2340 gnc_split_register_get_tdebcred_entry,
2343 gnc_table_model_set_entry_handler (model,
2344 gnc_split_register_get_tdebcred_entry,
2347 gnc_table_model_set_entry_handler (model,
2348 gnc_split_register_get_type_entry,
2351 gnc_table_model_set_entry_handler (model,
2352 gnc_split_register_get_debcred_entry,
2355 gnc_table_model_set_entry_handler (model,
2356 gnc_split_register_get_debcred_entry,
2359 gnc_table_model_set_entry_handler (model,
2360 gnc_split_register_get_rbaln_entry,
2364 gnc_table_model_set_label_handler (model,
2365 gnc_split_register_get_date_label,
2368 gnc_table_model_set_label_handler (model,
2369 gnc_split_register_get_due_date_label,
2372 gnc_table_model_set_label_handler (model,
2373 gnc_split_register_get_num_label,
2376 gnc_table_model_set_label_handler (model,
2377 gnc_split_register_get_tran_num_label,
2380 gnc_table_model_set_label_handler (model,
2381 gnc_split_register_get_desc_label,
2384 gnc_table_model_set_label_handler (model,
2385 gnc_split_register_get_recn_label,
2388 gnc_table_model_set_label_handler (model,
2389 gnc_split_register_get_baln_label,
2392 gnc_table_model_set_label_handler (model,
2393 gnc_split_register_get_action_label,
2396 gnc_table_model_set_label_handler (model,
2397 gnc_split_register_get_xfrm_label,
2400 gnc_table_model_set_label_handler (model,
2401 gnc_split_register_get_memo_label,
2404 gnc_table_model_set_label_handler (model,
2405 gnc_split_register_get_debit_label,
2408 gnc_table_model_set_label_handler (model,
2409 gnc_split_register_get_credit_label,
2412 gnc_table_model_set_label_handler (model,
2413 gnc_split_register_get_price_label,
2416 gnc_table_model_set_label_handler (model,
2417 gnc_split_register_get_shares_label,
2420 gnc_table_model_set_label_handler (model,
2421 gnc_split_register_get_mxfrm_label,
2424 gnc_table_model_set_label_handler (model,
2425 gnc_split_register_get_tcredit_label,
2428 gnc_table_model_set_label_handler (model,
2429 gnc_split_register_get_tdebit_label,
2432 gnc_table_model_set_label_handler (model,
2433 gnc_split_register_get_tshares_label,
2436 gnc_table_model_set_label_handler (model,
2437 gnc_split_register_get_tbalance_label,
2440 gnc_table_model_set_label_handler (model,
2441 gnc_split_register_get_type_label,
2444 gnc_table_model_set_label_handler (model,
2445 gnc_split_register_get_notes_label,
2448 gnc_table_model_set_label_handler (model,
2449 gnc_split_register_get_fdebit_label,
2452 gnc_table_model_set_label_handler (model,
2453 gnc_split_register_get_fcredit_label,
2456 gnc_table_model_set_label_handler (model,
2457 gnc_split_register_get_tbalance_label,
2461 gnc_table_model_set_default_help_handler(
2462 model, gnc_split_register_get_default_help);
2464 gnc_table_model_set_help_handler (model,
2465 gnc_split_register_get_date_help,
2468 gnc_table_model_set_help_handler (model,
2469 gnc_split_register_get_date_help,
2472 gnc_table_model_set_help_handler (model,
2473 gnc_split_register_get_num_help,
2476 gnc_table_model_set_help_handler (model,
2477 gnc_split_register_get_tran_num_help,
2480 gnc_table_model_set_help_handler (model,
2481 gnc_split_register_get_desc_help,
2484 gnc_table_model_set_help_handler (model,
2485 gnc_split_register_get_price_help,
2488 gnc_table_model_set_help_handler (model,
2489 gnc_split_register_get_shares_help,
2492 gnc_table_model_set_help_handler (model,
2493 gnc_split_register_get_action_help,
2496 gnc_table_model_set_help_handler (model,
2497 gnc_split_register_get_memo_help,
2500 gnc_table_model_set_help_handler (model,
2501 gnc_split_register_get_notes_help,
2504 gnc_table_model_set_help_handler (model,
2505 gnc_split_register_get_vnotes_help,
2508 gnc_table_model_set_help_handler (model,
2509 gnc_split_register_get_xfrm_help,
2512 gnc_table_model_set_help_handler (model,
2513 gnc_split_register_get_mxfrm_help,
2516 gnc_table_model_set_help_handler (model,
2517 gnc_split_register_get_fcred_help,
2520 gnc_table_model_set_help_handler (model,
2521 gnc_split_register_get_fdebt_help,
2525 gnc_table_model_set_io_flags_handler(
2526 model, gnc_split_register_get_standard_io_flags, DATE_CELL);
2533 gnc_table_model_set_io_flags_handler(
2534 model, gnc_split_register_get_rate_io_flags, RATE_CELL);
2536 gnc_table_model_set_io_flags_handler(
2537 model, gnc_split_register_get_ddue_io_flags, DDUE_CELL);
2539 gnc_table_model_set_io_flags_handler(
2540 model, gnc_split_register_get_standard_io_flags, NUM_CELL);
2542 gnc_table_model_set_io_flags_handler(
2543 model, gnc_split_register_get_standard_io_flags, TNUM_CELL);
2545 gnc_table_model_set_io_flags_handler(
2546 model, gnc_split_register_get_standard_io_flags, DESC_CELL);
2548 gnc_table_model_set_io_flags_handler(
2549 model, gnc_split_register_get_standard_io_flags, ACTN_CELL);
2551 gnc_table_model_set_io_flags_handler(
2552 model, gnc_split_register_get_standard_io_flags, XFRM_CELL);
2554 gnc_table_model_set_io_flags_handler(
2555 model, gnc_split_register_get_standard_io_flags, MEMO_CELL);
2557 gnc_table_model_set_io_flags_handler(
2558 model, gnc_split_register_get_standard_io_flags, MXFRM_CELL);
2560 gnc_table_model_set_io_flags_handler(
2561 model, gnc_split_register_get_standard_io_flags, NOTES_CELL);
2563 gnc_table_model_set_io_flags_handler(
2564 model, gnc_split_register_get_inactive_io_flags, VNOTES_CELL);
2566 gnc_table_model_set_io_flags_handler(
2567 model, gnc_split_register_get_debcred_io_flags, CRED_CELL);
2569 gnc_table_model_set_io_flags_handler(
2570 model, gnc_split_register_get_debcred_io_flags, DEBT_CELL);
2572 gnc_table_model_set_io_flags_handler(
2573 model, gnc_split_register_get_recn_io_flags, RECN_CELL);
2575 gnc_table_model_set_io_flags_handler(
2576 model, gnc_split_register_get_recn_io_flags, TYPE_CELL);
2578 gnc_table_model_set_io_flags_handler(
2579 model, gnc_split_register_get_security_io_flags, PRIC_CELL);
2581 gnc_table_model_set_io_flags_handler(
2582 model, gnc_split_register_get_security_io_flags, SHRS_CELL);
2585 gnc_table_model_set_fg_color_handler(
2586 model, gnc_split_register_get_fg_color, SHRS_CELL);
2588 gnc_table_model_set_fg_color_handler(
2589 model, gnc_split_register_get_fg_color, TSHRS_CELL);
2591 gnc_table_model_set_fg_color_handler(
2592 model, gnc_split_register_get_fg_color, BALN_CELL);
2594 gnc_table_model_set_fg_color_handler(
2595 model, gnc_split_register_get_fg_color, TBALN_CELL);
2597 gnc_table_model_set_fg_color_handler(
2598 model, gnc_split_register_get_fg_color, RBALN_CELL);
2600 gnc_table_model_set_fg_color_handler(
2601 model, gnc_split_register_get_gtkrc_fg_color,
"gtkrc");
2604 gnc_table_model_set_default_bg_color_handler(
2605 model, gnc_split_register_get_bg_color);
2607 gnc_table_model_set_bg_color_handler(
2608 model, gnc_split_register_get_gtkrc_bg_color,
"gtkrc");
2610 gnc_table_model_set_bg_color_handler(
2611 model, gnc_split_register_get_debcred_bg_color, DEBT_CELL);
2613 gnc_table_model_set_bg_color_handler(
2614 model, gnc_split_register_get_debcred_bg_color, CRED_CELL);
2616 gnc_table_model_set_bg_color_handler(
2617 model, gnc_split_register_get_debcred_bg_color, TDEBT_CELL);
2619 gnc_table_model_set_bg_color_handler(
2620 model, gnc_split_register_get_debcred_bg_color, TCRED_CELL);
2622 gnc_table_model_set_bg_color_handler(
2623 model, gnc_split_register_get_debcred_bg_color, FCRED_CELL);
2625 gnc_table_model_set_bg_color_handler(
2626 model, gnc_split_register_get_debcred_bg_color, FDEBT_CELL);
2629 gnc_table_model_set_default_cell_border_handler(
2630 model, gnc_split_register_get_border);
2633 gnc_table_model_set_default_confirm_handler(
2634 model, gnc_split_register_confirm);
2636 model->cell_data_allocator = gnc_split_register_guid_malloc;
2637 model->cell_data_deallocator = gnc_split_register_guid_free;
2638 model->cell_data_copy = gnc_split_register_guid_copy;
2640 gnc_split_register_model_add_save_handlers (model);
2646 gnc_template_register_model_new (
void)
2650 model = gnc_split_register_model_new ();
2652 gnc_table_model_set_entry_handler(
2653 model, gnc_split_register_get_inactive_date_entry, DATE_CELL );
2655 gnc_table_model_set_entry_handler(
2656 model, gnc_split_register_get_inactive_date_entry, DDUE_CELL );
2658 gnc_table_model_set_io_flags_handler(
2659 model, gnc_split_register_get_inactive_io_flags, DATE_CELL );
2661 gnc_table_model_set_io_flags_handler(
2662 model, gnc_split_register_get_inactive_io_flags, DDUE_CELL );
2664 gnc_table_model_set_entry_handler(
2665 model, gnc_template_register_get_xfrm_entry, XFRM_CELL);
2667 gnc_table_model_set_entry_handler(
2668 model, gnc_template_register_get_fdebt_entry, FDEBT_CELL);
2670 gnc_table_model_set_entry_handler(
2671 model, gnc_template_register_get_fcred_entry, FCRED_CELL);
2673 gnc_table_model_set_entry_handler(
2674 model, gnc_template_register_get_debcred_entry, DEBT_CELL);
2676 gnc_table_model_set_entry_handler(
2677 model, gnc_template_register_get_debcred_entry, CRED_CELL);
2679 gnc_table_model_set_io_flags_handler(
2680 model, gnc_split_register_get_standard_io_flags, FCRED_CELL);
2682 gnc_table_model_set_io_flags_handler(
2683 model, gnc_split_register_get_standard_io_flags, FDEBT_CELL);
2685 gnc_template_register_model_add_save_handlers (model);
const char * gnc_split_register_get_debit_string(SplitRegister *reg)
gboolean xaccTransHasReconciledSplits(const Transaction *trans)
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
char xaccTransGetTxnType(const Transaction *trans)
int gnc_commodity_get_fraction(const gnc_commodity *cm)
void xaccTransGetDateDueTS(const Transaction *trans, Timespec *ts)
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
Split * xaccTransGetSplit(const Transaction *trans, int i)
const char * gnc_print_date(Timespec ts)
gboolean xaccTransUseTradingAccounts(const Transaction *trans)
gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans)
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
gboolean xaccAccountIsPriced(const Account *acc)
gnc_numeric xaccTransGetAccountBalance(const Transaction *trans, const Account *account)
The type, style and table for the register.
gboolean use_tran_num_for_num_field
gnc_numeric gnc_numeric_neg(gnc_numeric a)
const char * xaccTransGetVoidReason(const Transaction *trans)
char xaccSplitGetReconcile(const Split *split)
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
CursorClass gnc_split_register_get_cursor_class(SplitRegister *reg, VirtualCellLocation vcell_loc)
Use a 64-bit unsigned int timespec.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Transaction * xaccSplitGetParent(const Split *split)
gboolean xaccTransIsBalanced(const Transaction *trans)
SplitRegisterType
Register types.
#define PERR(format, args...)
gnc_numeric xaccSplitGetBalance(const Split *s)
gboolean string_to_gnc_numeric(const gchar *str, gnc_numeric *n)
gboolean gnc_numeric_negative_p(gnc_numeric a)
gnc_commodity * gnc_default_currency(void)
#define PWARN(format, args...)
const char * xaccTransGetNotes(const Transaction *trans)
gchar * gnc_get_account_name_for_register(const Account *account)
Split * xaccSplitLookup(const GncGUID *guid, QofBook *book)
gnc_numeric gnc_numeric_convert(gnc_numeric n, gint64 denom, gint how)
char * kvp_value_get_string(const KvpValue *value)
GncGUID * guid_malloc(void)
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
gnc_numeric gnc_numeric_mul(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
void gnc_monetary_list_free(MonetaryList *list)
const char * xaccTransGetDescription(const Transaction *trans)
gnc_numeric gnc_numeric_abs(gnc_numeric a)
KvpValue * kvp_frame_get_slot_path(KvpFrame *frame, const gchar *first_key,...)
gnc_numeric gnc_numeric_div(gnc_numeric x, gnc_numeric y, gint64 denom, gint how)
gboolean gnc_split_register_current_trans_expanded(SplitRegister *reg)
gnc_numeric xaccSplitGetSharePrice(const Split *split)
const char * xaccTransGetReadOnly(const Transaction *trans)
All type declarations for the whole Gnucash engine.
API for checkbook register display area.
gboolean gnc_numeric_positive_p(gnc_numeric a)
Generic api to store and retrieve preferences.
GList * gnc_account_get_descendants(const Account *account)
const char * gnc_split_register_get_credit_string(SplitRegister *reg)
gnc_numeric xaccSplitGetValue(const Split *split)
Account * xaccSplitGetAccount(const Split *s)
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
const GncGUID * guid_null(void)
gnc_commodity * xaccTransGetCurrency(const Transaction *trans)
MonetaryList * xaccTransGetImbalance(const Transaction *trans)
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Split * xaccSplitGetOtherSplit(const Split *split)
const char * xaccSplitGetMemo(const Split *split)
const char * xaccSplitGetType(const Split *s)
Account * gnc_account_lookup_for_register(const Account *base_account, const gchar *name)
SplitList * xaccTransGetSplitList(const Transaction *trans)
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
void xaccTransGetDatePostedTS(const Transaction *trans, Timespec *ts)
gnc_numeric xaccTransGetAccountAmount(const Transaction *trans, const Account *acc)
gboolean gnc_commodity_is_iso(const gnc_commodity *cm)
const gchar * QofLogModule
gnc_numeric xaccSplitGetAmount(const Split *split)
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)