28 #include <glib/gi18n.h> 45 static const char * get_iacct_label (VirtualLocation virt_loc, gpointer data)
47 return _(
"Income Account");
50 static const char * get_bacct_label (VirtualLocation virt_loc, gpointer data)
52 return _(
"Expense Account");
55 static const char * get_actn_label (VirtualLocation virt_loc, gpointer data)
60 static const char * get_date_label (VirtualLocation virt_loc, gpointer data)
65 static const char * get_desc_label (VirtualLocation virt_loc, gpointer data)
67 return _(
"Description");
70 static const char * get_disc_label (VirtualLocation virt_loc, gpointer data)
75 static const char * get_distype_label (VirtualLocation virt_loc, gpointer data)
77 return _(
"Discount Type");
80 static const char * get_dishow_label (VirtualLocation virt_loc, gpointer data)
82 return _(
"Discount How");
85 static const char * get_pric_label (VirtualLocation virt_loc, gpointer data)
87 return _(
"Unit Price");
90 static const char * get_qty_label (VirtualLocation virt_loc, gpointer data)
95 static const char * get_taxtable_label (VirtualLocation virt_loc, gpointer data)
97 return _(
"Tax Table");
100 static const char * get_taxable_label (VirtualLocation virt_loc, gpointer data)
102 return _(
"Taxable?");
105 static const char * get_taxincluded_label (VirtualLocation virt_loc, gpointer data)
107 return _(
"Tax Included?");
110 static const char * get_inv_label (VirtualLocation virt_loc, gpointer data)
112 return _(
"Invoiced?");
115 static const char * get_value_label (VirtualLocation virt_loc, gpointer data)
117 return _(
"Subtotal");
120 static const char * get_taxval_label (VirtualLocation virt_loc, gpointer data)
125 static const char * get_billable_label (VirtualLocation virt_loc, gpointer data)
127 return _(
"Billable?");
130 static const char * get_payment_label (VirtualLocation virt_loc, gpointer data)
137 static const char * get_iacct_entry (VirtualLocation virt_loc,
139 gboolean *conditionally_changed,
142 static char *name = NULL;
144 GncEntryLedger *ledger = user_data;
154 static const char * get_bacct_entry (VirtualLocation virt_loc,
156 gboolean *conditionally_changed,
159 static char *name = NULL;
161 GncEntryLedger *ledger = user_data;
171 static const char * get_actn_entry (VirtualLocation virt_loc,
173 gboolean *conditionally_changed,
176 GncEntryLedger *ledger = user_data;
180 return gncEntryGetAction (entry);
183 static const char * get_date_entry (VirtualLocation virt_loc,
185 gboolean *conditionally_changed,
188 GncEntryLedger *ledger = user_data;
192 memset (dateBuff, 0,
sizeof (dateBuff));
197 static const char * get_desc_entry (VirtualLocation virt_loc,
199 gboolean *conditionally_changed,
202 GncEntryLedger *ledger = user_data;
206 return gncEntryGetDescription (entry);
209 static const char * get_disc_entry (VirtualLocation virt_loc,
211 gboolean *conditionally_changed,
214 GncEntryLedger *ledger = user_data;
216 gnc_numeric discount;
219 discount = gncEntryGetInvDiscount (entry);
226 static const char * get_distype_entry (VirtualLocation virt_loc,
228 gboolean *conditionally_changed,
231 GncEntryLedger *ledger = user_data;
236 type = gncEntryGetInvDiscountType (entry);
240 return gnc_entry_ledger_type_string_getter (type +
'0');
251 static const char * get_dishow_entry (VirtualLocation virt_loc,
253 gboolean *conditionally_changed,
256 GncEntryLedger *ledger = user_data;
261 type = gncEntryGetInvDiscountHow (entry);
265 return gnc_entry_ledger_how_string_getter (type +
'0');
276 static const char * get_pric_entry (VirtualLocation virt_loc,
278 gboolean *conditionally_changed,
281 GncEntryLedger *ledger = user_data;
286 if (ledger->is_cust_doc)
287 price = gncEntryGetInvPrice (entry);
289 price = gncEntryGetBillPrice (entry);
297 static const char * get_qty_entry (VirtualLocation virt_loc,
299 gboolean *conditionally_changed,
302 GncEntryLedger *ledger = user_data;
315 static const char * get_taxable_entry (VirtualLocation virt_loc,
317 gboolean *conditionally_changed,
320 GncEntryLedger *ledger = user_data;
325 if (ledger->is_cust_doc)
326 taxable = gncEntryGetInvTaxable (entry);
328 taxable = gncEntryGetBillTaxable (entry);
330 return gnc_checkbox_cell_get_string (taxable);
334 gnc_entry_ledger_get_taxable_value (VirtualLocation virt_loc,
336 gboolean *conditionally_changed,
339 GncEntryLedger *ledger = user_data;
342 is_current = virt_cell_loc_equal(ledger->table->current_cursor_loc.vcell_loc,
345 return gnc_entry_ledger_get_checkmark (ledger, ENTRY_TAXABLE_CELL);
349 get_taxable_entry (virt_loc, translate, conditionally_changed,
351 if (valstr && *valstr !=
' ')
357 static const char * get_taxtable_entry (VirtualLocation virt_loc,
359 gboolean *conditionally_changed,
362 GncEntryLedger *ledger = user_data;
368 if (!conditionally_changed)
370 taxable = gnc_entry_ledger_get_taxable_value (virt_loc, translate,
371 conditionally_changed,
378 if (ledger->is_cust_doc)
379 table = gncEntryGetInvTaxTable (entry);
381 table = gncEntryGetBillTaxTable (entry);
383 return gncTaxTableGetName (
table);
386 static const char * get_taxincluded_entry (VirtualLocation virt_loc,
388 gboolean *conditionally_changed,
391 GncEntryLedger *ledger = user_data;
393 gboolean taxable, taxincluded;
396 if (!conditionally_changed)
398 taxable = gnc_entry_ledger_get_taxable_value (virt_loc, translate,
399 conditionally_changed,
406 if (ledger->is_cust_doc)
407 taxincluded = gncEntryGetInvTaxIncluded (entry);
409 taxincluded = gncEntryGetBillTaxIncluded (entry);
411 return gnc_checkbox_cell_get_string (taxincluded);
414 static const char * get_inv_entry (VirtualLocation virt_loc,
416 gboolean *conditionally_changed,
419 GncEntryLedger *ledger = user_data;
424 return gnc_checkbox_cell_get_string (gncEntryGetInvoice (entry) != NULL);
433 static const char * get_value_entry (VirtualLocation virt_loc,
435 gboolean *conditionally_changed,
438 GncEntryLedger *ledger = user_data;
442 if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc,
448 gnc_entry_ledger_compute_value (ledger, &value, NULL);
460 value = gncEntryGetDocValue (entry, TRUE, ledger->is_cust_doc, ledger->is_credit_note);
466 static const char * get_taxval_entry (VirtualLocation virt_loc,
468 gboolean *conditionally_changed,
471 GncEntryLedger *ledger = user_data;
475 if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc,
481 gnc_entry_ledger_compute_value (ledger, NULL, &value);
493 value = gncEntryGetDocTaxValue (entry, TRUE, ledger->is_cust_doc, ledger->is_credit_note);
499 static const char * get_billable_entry (VirtualLocation virt_loc,
501 gboolean *conditionally_changed,
504 GncEntryLedger *ledger = user_data;
508 return gnc_checkbox_cell_get_string (gncEntryGetBillable (entry));
511 static const char * get_payment_entry (VirtualLocation virt_loc,
513 gboolean *conditionally_changed,
516 GncEntryLedger *ledger = user_data;
518 GncEntryPaymentType type;
525 type = gncEntryGetBillPayment (entry);
529 case GNC_PAYMENT_CASH:
531 case GNC_PAYMENT_CARD:
534 g_warning (
"Invalid payment type: %d", type);
541 static char * get_acct_help (VirtualLocation virt_loc, gpointer user_data)
544 GncEntryLedger *ledger = user_data;
546 help = gnc_table_get_entry (ledger->table, virt_loc);
547 if (!help || *help ==
'\0')
548 help = _(
"Enter the income/expense account for the Entry, " 549 "or choose one from the list");
551 return g_strdup (help);
554 static char * get_actn_help (VirtualLocation virt_loc, gpointer user_data)
556 GncEntryLedger *ledger = user_data;
559 help = gnc_table_get_entry (ledger->table, virt_loc);
560 if (!help || *help ==
'\0')
561 help = _(
"Enter the type of Entry");
563 return g_strdup (help);
566 static char * get_date_help (VirtualLocation virt_loc, gpointer user_data)
568 GncEntryLedger *ledger = user_data;
572 cell = gnc_table_get_cell (ledger->table, virt_loc);
573 if (!cell || !cell->value || *cell->value ==
'\0')
580 static char * get_desc_help (VirtualLocation virt_loc, gpointer user_data)
582 GncEntryLedger *ledger = user_data;
585 help = gnc_table_get_entry (ledger->table, virt_loc);
586 if (!help || *help ==
'\0')
587 help = _(
"Enter the Entry Description");
589 return g_strdup (help);
592 static char * get_disc_help (VirtualLocation virt_loc, gpointer user_data)
594 GncEntryLedger *ledger = user_data;
598 type = gnc_entry_ledger_get_type (ledger, ENTRY_DISTYPE_CELL);
603 help = _(
"Enter the Discount Amount");
606 help = _(
"Enter the Discount Percent");
609 help = _(
"Enter the Discount … unknown type");
613 return g_strdup (help);
616 static char * get_distype_help (VirtualLocation virt_loc, gpointer user_data)
618 GncEntryLedger *ledger = user_data;
622 type = gnc_entry_ledger_get_type (ledger, ENTRY_DISTYPE_CELL);
627 help = _(
"Discount Type: Monetary Value");
630 help = _(
"Discount Type: Percent");
633 help = _(
"Select the Discount Type");
636 return g_strdup (help);
639 static char * get_dishow_help (VirtualLocation virt_loc, gpointer user_data)
641 GncEntryLedger *ledger = user_data;
645 type = gnc_entry_ledger_get_type (ledger, ENTRY_DISHOW_CELL);
649 case GNC_DISC_PRETAX:
650 help = _(
"Tax computed after discount is applied");
652 case GNC_DISC_SAMETIME:
653 help = _(
"Discount and tax both applied on pretax value");
655 case GNC_DISC_POSTTAX:
656 help = _(
"Discount computed after tax is applied");
659 help = _(
"Select how to compute the Discount and Taxes");
662 return g_strdup (help);
665 static char * get_pric_help (VirtualLocation virt_loc, gpointer user_data)
667 GncEntryLedger *ledger = user_data;
670 help = gnc_table_get_entry (ledger->table, virt_loc);
671 if (!help || *help ==
'\0')
672 help = _(
"Enter the unit-Price for this Entry");
674 return g_strdup (help);
677 static char * get_qty_help (VirtualLocation virt_loc, gpointer user_data)
679 GncEntryLedger *ledger = user_data;
682 help = gnc_table_get_entry (ledger->table, virt_loc);
683 if (!help || *help ==
'\0')
684 help = _(
"Enter the Quantity of units for this Entry");
686 return g_strdup (help);
689 static char * get_taxtable_help (VirtualLocation virt_loc, gpointer user_data)
691 GncEntryLedger *ledger = user_data;
694 help = gnc_table_get_entry (ledger->table, virt_loc);
695 if (!help || *help ==
'\0')
696 help = _(
"Enter the Tax Table to apply to this entry");
698 return g_strdup (help);
701 static char * get_taxable_help (VirtualLocation virt_loc, gpointer user_data)
705 help = _(
"Is this entry taxable?");
707 return g_strdup (help);
710 static char * get_taxincluded_help (VirtualLocation virt_loc, gpointer user_data)
714 help = _(
"Is the tax already included in the price of this entry?");
716 return g_strdup (help);
719 static char * get_inv_help (VirtualLocation virt_loc, gpointer user_data)
721 GncEntryLedger *ledger = user_data;
724 switch (ledger->type)
726 case GNCENTRY_ORDER_ENTRY:
727 case GNCENTRY_ORDER_VIEWER:
728 case GNCENTRY_BILL_ENTRY:
729 case GNCENTRY_BILL_VIEWER:
730 case GNCENTRY_EXPVOUCHER_ENTRY:
731 case GNCENTRY_EXPVOUCHER_VIEWER:
732 help = _(
"Is this entry invoiced?");
734 case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
735 case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
736 case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
737 case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
738 help = _(
"Is this entry credited?");
740 case GNCENTRY_INVOICE_ENTRY:
741 case GNCENTRY_INVOICE_VIEWER:
742 help = _(
"Include this entry on this invoice?");
744 case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
745 case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
746 help = _(
"Include this entry on this credit note?");
749 help = _(
"Unknown EntryLedger Type");
752 return g_strdup (help);
755 static char * get_value_help (VirtualLocation virt_loc, gpointer user_data)
757 GncEntryLedger *ledger = user_data;
760 help = gnc_table_get_entry (ledger->table, virt_loc);
761 if (!help || *help ==
'\0')
762 help = _(
"The subtotal value of this entry");
764 return g_strdup (help);
767 static char * get_taxval_help (VirtualLocation virt_loc, gpointer user_data)
769 GncEntryLedger *ledger = user_data;
772 help = gnc_table_get_entry (ledger->table, virt_loc);
773 if (!help || *help ==
'\0')
774 help = _(
"The total tax of this entry ");
776 return g_strdup (help);
779 static char * get_billable_help (VirtualLocation virt_loc, gpointer user_data)
783 help = _(
"Is this entry billable to a customer or job?");
785 return g_strdup (help);
788 static char * get_payment_help (VirtualLocation virt_loc, gpointer user_data)
792 help = _(
"How did you pay for this item?");
794 return g_strdup (help);
799 static CellIOFlags get_standard_io_flags (VirtualLocation virt_loc,
802 GncEntryLedger *ledger = user_data;
803 switch (ledger->type)
805 case GNCENTRY_ORDER_ENTRY:
806 case GNCENTRY_BILL_ENTRY:
807 case GNCENTRY_EXPVOUCHER_ENTRY:
816 if (gncEntryGetInvoice (entry) != NULL)
817 return XACC_CELL_ALLOW_SHADOW;
821 return XACC_CELL_ALLOW_ALL;
825 static CellIOFlags get_typecell_io_flags (VirtualLocation virt_loc,
828 return (get_standard_io_flags (virt_loc, user_data) |
829 XACC_CELL_ALLOW_EXACT_ONLY);
832 static CellIOFlags get_inv_io_flags (VirtualLocation virt_loc,
835 GncEntryLedger *ledger = user_data;
837 switch (ledger->type)
839 case GNCENTRY_INVOICE_ENTRY:
840 case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
847 if ((gncEntryGetOrder (entry) != NULL) || (gncEntryGetBill (entry) != NULL))
848 return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
853 return XACC_CELL_ALLOW_SHADOW;
857 static CellIOFlags get_value_io_flags (VirtualLocation virt_loc,
860 return XACC_CELL_ALLOW_SHADOW;
863 static CellIOFlags get_tax_io_flags (VirtualLocation virt_loc,
866 GncEntryLedger *ledger = user_data;
869 taxable = gnc_entry_ledger_get_checkmark (ledger, ENTRY_TAXABLE_CELL);
873 return get_standard_io_flags (virt_loc, user_data);
876 return XACC_CELL_ALLOW_SHADOW;
879 static CellIOFlags get_taxincluded_io_flags (VirtualLocation virt_loc,
882 CellIOFlags flags = get_tax_io_flags (virt_loc, user_data);
883 if (flags == XACC_CELL_ALLOW_SHADOW)
885 return flags | XACC_CELL_ALLOW_EXACT_ONLY;
888 static CellIOFlags get_qty_io_flags (VirtualLocation virt_loc, gpointer user_data)
890 GncEntryLedger *ledger = user_data;
892 CellIOFlags flags = get_standard_io_flags (virt_loc, user_data);
895 if (!ledger->is_cust_doc || flags == XACC_CELL_ALLOW_SHADOW)
902 if (gncEntryGetBillable (entry))
903 return XACC_CELL_ALLOW_SHADOW;
911 gnc_entry_ledger_get_cell_color_internal (VirtualLocation virt_loc,
912 GncEntryLedger *ledger)
916 guint32 colorbase = 0;
923 return (colorbase + COLOR_UNDEFINED);
925 if (gnc_table_virtual_location_in_header (ledger->table, virt_loc))
926 return (colorbase + COLOR_HEADER);
929 if (!vcell || !vcell->cellblock)
930 return (colorbase + COLOR_UNDEFINED);
932 if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
933 (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
934 return (colorbase + COLOR_UNDEFINED);
936 is_current = virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc,
941 (colorbase + COLOR_PRIMARY_ACTIVE) :
942 (colorbase + COLOR_SECONDARY_ACTIVE);
945 (colorbase + COLOR_PRIMARY) : (colorbase + COLOR_SECONDARY);
950 gnc_entry_ledger_get_cell_color (VirtualLocation virt_loc,
951 gboolean *hatching, gpointer user_data)
953 GncEntryLedger *ledger = user_data;
958 return gnc_entry_ledger_get_cell_color_internal (virt_loc, ledger);
963 static void gnc_entry_ledger_save_cells (gpointer save_data,
966 GncEntryLedger *ledger = user_data;
967 GncEntry *entry = save_data;
969 g_return_if_fail (entry != NULL);
973 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
974 ENTRY_IACCT_CELL, TRUE))
978 acc = gnc_entry_ledger_get_account (ledger, ENTRY_IACCT_CELL);
981 gncEntrySetInvAccount (entry, acc);
984 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
985 ENTRY_BACCT_CELL, TRUE))
989 acc = gnc_entry_ledger_get_account (ledger, ENTRY_BACCT_CELL);
992 gncEntrySetBillAccount (entry, acc);
995 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
996 ENTRY_ACTN_CELL, TRUE))
1000 value = gnc_table_layout_get_cell_value (ledger->table->layout,
1002 gncEntrySetAction (entry, value);
1005 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1006 ENTRY_DATE_CELL, TRUE))
1011 cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_DATE_CELL);
1022 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1023 ENTRY_DESC_CELL, TRUE))
1027 value = gnc_table_layout_get_cell_value (ledger->table->layout,
1029 gncEntrySetDescription (entry, value);
1032 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1033 ENTRY_DISC_CELL, TRUE))
1037 if (gnc_entry_ledger_get_numeric (ledger, ENTRY_DISC_CELL, &amount))
1038 gncEntrySetInvDiscount (entry, amount);
1041 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1042 ENTRY_DISTYPE_CELL, TRUE))
1046 type = gnc_entry_ledger_get_type (ledger, ENTRY_DISTYPE_CELL);
1049 gncEntrySetInvDiscountType (entry, type);
1052 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1053 ENTRY_DISHOW_CELL, TRUE))
1057 type = gnc_entry_ledger_get_type (ledger, ENTRY_DISHOW_CELL);
1060 gncEntrySetInvDiscountHow (entry, type);
1063 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1064 ENTRY_QTY_CELL, TRUE))
1068 if (gnc_entry_ledger_get_numeric (ledger, ENTRY_QTY_CELL, &amount))
1074 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1075 ENTRY_BILLABLE_CELL, TRUE))
1079 billable = gnc_entry_ledger_get_checkmark (ledger, ENTRY_BILLABLE_CELL);
1080 gncEntrySetBillable (entry, billable);
1083 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1084 ENTRY_PAYMENT_CELL, TRUE))
1088 value = gnc_table_layout_get_cell_value (ledger->table->layout,
1089 ENTRY_PAYMENT_CELL);
1090 if (!g_strcmp0 (value, _(
"Cash")))
1091 gncEntrySetBillPayment (entry, GNC_PAYMENT_CASH);
1092 else if (!g_strcmp0 (value, _(
"Charge")))
1093 gncEntrySetBillPayment (entry, GNC_PAYMENT_CARD);
1095 g_warning (
"Invalid Payment cell: %s", value ? value :
"(null)");
1098 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1099 ENTRY_PRIC_CELL, TRUE))
1103 if (gnc_entry_ledger_get_numeric (ledger, ENTRY_PRIC_CELL, &amount))
1105 if (ledger->is_cust_doc)
1106 gncEntrySetInvPrice (entry, amount);
1108 gncEntrySetBillPrice (entry, amount);
1112 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1113 ENTRY_TAXABLE_CELL, TRUE))
1117 taxable = gnc_entry_ledger_get_checkmark (ledger, ENTRY_TAXABLE_CELL);
1118 if (ledger->is_cust_doc)
1119 gncEntrySetInvTaxable (entry, taxable);
1121 gncEntrySetBillTaxable (entry, taxable);
1125 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1126 ENTRY_TAXTABLE_CELL, TRUE))
1130 table = gnc_entry_ledger_get_taxtable (ledger, ENTRY_TAXTABLE_CELL);
1133 if (ledger->is_cust_doc)
1134 gncEntrySetInvTaxTable (entry,
table);
1136 gncEntrySetBillTaxTable (entry,
table);
1140 if (gnc_table_layout_get_cell_changed (ledger->table->layout,
1141 ENTRY_TAXINCLUDED_CELL, TRUE))
1143 gboolean taxincluded;
1145 taxincluded = gnc_entry_ledger_get_checkmark (ledger,
1146 ENTRY_TAXINCLUDED_CELL);
1147 if (ledger->is_cust_doc)
1148 gncEntrySetInvTaxIncluded (entry, taxincluded);
1150 gncEntrySetBillTaxIncluded (entry, taxincluded);
1153 if (ledger->type == GNCENTRY_INVOICE_ENTRY ||
1154 ledger->type == GNCENTRY_CUST_CREDIT_NOTE_ENTRY)
1158 inv_value = gnc_entry_ledger_get_checkmark (ledger, ENTRY_INV_CELL);
1163 if (gncEntryGetInvoice (entry) == NULL)
1164 gncInvoiceAddEntry (ledger->invoice, entry);
1170 if ((gncEntryGetOrder (entry) != NULL) ||
1171 (gncEntryGetBill (entry) != NULL))
1172 gncInvoiceRemoveEntry (ledger->invoice, entry);
1179 static void gnc_entry_ledger_model_new_handlers (
TableModel *model,
1180 GncEntryLedgerType type)
1185 gpointer entry_handler;
1186 gpointer label_handler;
1187 gpointer help_handler;
1188 gpointer io_flags_handler;
1191 { ENTRY_IACCT_CELL, get_iacct_entry, get_iacct_label, get_acct_help, get_standard_io_flags },
1192 { ENTRY_BACCT_CELL, get_bacct_entry, get_bacct_label, get_acct_help, get_standard_io_flags },
1193 { ENTRY_ACTN_CELL, get_actn_entry, get_actn_label, get_actn_help, get_standard_io_flags },
1194 { ENTRY_DATE_CELL, get_date_entry, get_date_label, get_date_help, get_standard_io_flags },
1195 { ENTRY_DESC_CELL, get_desc_entry, get_desc_label, get_desc_help, get_standard_io_flags },
1196 { ENTRY_DISC_CELL, get_disc_entry, get_disc_label, get_disc_help, get_standard_io_flags },
1197 { ENTRY_DISTYPE_CELL, get_distype_entry, get_distype_label, get_distype_help, get_typecell_io_flags },
1198 { ENTRY_DISHOW_CELL, get_dishow_entry, get_dishow_label, get_dishow_help, get_typecell_io_flags },
1199 { ENTRY_PRIC_CELL, get_pric_entry, get_pric_label, get_pric_help, get_standard_io_flags },
1200 { ENTRY_QTY_CELL, get_qty_entry, get_qty_label, get_qty_help, get_qty_io_flags },
1201 { ENTRY_TAXABLE_CELL, get_taxable_entry, get_taxable_label, get_taxable_help, get_typecell_io_flags },
1202 { ENTRY_TAXTABLE_CELL, get_taxtable_entry, get_taxtable_label, get_taxtable_help, get_tax_io_flags },
1203 { ENTRY_TAXINCLUDED_CELL, get_taxincluded_entry, get_taxincluded_label, get_taxincluded_help, get_taxincluded_io_flags },
1204 { ENTRY_INV_CELL, get_inv_entry, get_inv_label, get_inv_help, get_inv_io_flags },
1205 { ENTRY_VALUE_CELL, get_value_entry, get_value_label, get_value_help, get_value_io_flags },
1206 { ENTRY_TAXVAL_CELL, get_taxval_entry, get_taxval_label, get_taxval_help, get_value_io_flags },
1207 { ENTRY_BILLABLE_CELL, get_billable_entry, get_billable_label, get_billable_help, get_typecell_io_flags },
1208 { ENTRY_PAYMENT_CELL, get_payment_entry, get_payment_label, get_payment_help, get_standard_io_flags },
1213 gnc_table_model_set_default_cell_color_handler (model, gnc_entry_ledger_get_cell_color);
1215 for (i = 0; i < (
sizeof(models) /
sizeof(*models)); i++)
1217 if (models[i].entry_handler)
1218 gnc_table_model_set_entry_handler (model, models[i].entry_handler,
1220 if (models[i].label_handler)
1221 gnc_table_model_set_label_handler (model, models[i].label_handler,
1223 if (models[i].help_handler)
1224 gnc_table_model_set_help_handler (model, models[i].help_handler,
1226 if (models[i].io_flags_handler)
1227 gnc_table_model_set_io_flags_handler (model, models[i].io_flags_handler,
1237 gnc_table_model_set_post_save_handler (model, gnc_entry_ledger_save_cells);
1241 case GNCENTRY_ORDER_VIEWER:
1242 case GNCENTRY_INVOICE_VIEWER:
1243 case GNCENTRY_BILL_VIEWER:
1244 case GNCENTRY_EXPVOUCHER_VIEWER:
1245 case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
1246 case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
1247 case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
1249 gnc_table_model_set_read_only (model, TRUE);
1262 model = gnc_table_model_new ();
1263 gnc_entry_ledger_model_new_handlers (model, type);
utility functions for the GnuCash UI
holds information about each virtual cell.
TableModel * gnc_entry_ledger_model_new(GncEntryLedgerType type)
Public Interface.
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
GncEntry * gnc_entry_ledger_get_entry(GncEntryLedger *ledger, VirtualCellLocation vcell_loc)
Returns the GncEntry at the given location, or NULL if the location is not valid. ...
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
void gncEntrySetDocQuantity(GncEntry *entry, gnc_numeric quantity, gboolean is_cn)
Set the internal quantity converting from the quantity as visible on the physical document...
time64 gncEntryGetDate(const GncEntry *entry)
DEPRECATED - use gncEntryGetDateGDate() instead! (Because the time-of-day is a misleading extra infor...
char * gnc_get_account_name_for_register(const Account *account)
Get either the full name of the account or the simple name, depending on the configuration parameter ...
Account handling public routines.
VirtualCell * gnc_table_get_virtual_cell(Table *table, VirtualCellLocation vcell_loc)
returns the virtual cell associated with a particular virtual location.
void gnc_date_cell_get_date(DateCell *cell, time64 *time, gboolean warn)
Set a time64 to the value in the DateCell.
void gnc_date_cell_commit(DateCell *cell)
Commits any pending changes to the value of the cell.
char * gnc_print_time64(time64 time, const char *format)
print a time64 as a date string per format
unsigned int start_primary_color
visible in the GUI
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
void gncEntrySetDate(GncEntry *entry, time64 date)
DEPRECATED - use gncEntrySetDateGDate() instead! (Because the time-of-day is a misleading extra infor...
The DateCell object implements a date handling cell.
time64 time64CanonicalDayTime(time64 t)
convert a time64 on a certain day (localtime) to the time64 representing midday on that day...
GncEntry * gnc_entry_ledger_get_blank_entry(GncEntryLedger *ledger)
Exported Functions.
size_t qof_print_date_buff(char *buff, size_t buflen, time64 secs)
Convenience: calls through to qof_print_date_dmy_buff().
gnc_numeric gncEntryGetDocQuantity(const GncEntry *entry, gboolean is_cn)
Get the quantity as on the physical document.
modtime is the internal date of the last modtime See libgnucash/engine/TaxTableBillTermImmutability.txt for an explanation of the following Code that handles refcount, parent, child, invisible and children is identical to that in ::GncBillTerm