static const char * get_taxval_entry (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; gnc_numeric value; /* Check if this is the current cursor */ if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc)) { /* Sign attention: this function works with values as seen * on-screen in the ledger, so they are always in the proper sign. */ gnc_entry_ledger_compute_value (ledger, NULL, &value); } else { GncEntry *entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc); if (entry == gnc_entry_ledger_get_blank_entry (ledger)) return NULL; /* Ledger should display values with the same sign as on the document * so get the document value instead of the internal value here. */ value = gncEntryGetDocTaxValue (entry, TRUE, ledger->is_cust_doc, ledger->is_credit_note); } return xaccPrintAmount (value, gnc_default_print_info (FALSE)); }
static const char * get_taxval_entry (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; gnc_numeric value; /* Check if this is the current cursor */ if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc)) { gnc_entry_ledger_compute_value (ledger, NULL, &value); } else { GncEntry *entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc); if (entry == gnc_entry_ledger_get_blank_entry (ledger)) return NULL; value = gncEntryReturnTaxValue (entry, ledger->is_cust_doc); } /* Credit notes have negative values, but the ledger should * display it as on the document, meaning positive. * So reverse the value for credit notes. */ if (ledger->is_credit_note) value = gnc_numeric_neg (value); return xaccPrintAmount (value, gnc_default_print_info (FALSE)); }
/** Verify whether we can save the entry, or warn the user when we can't * return TRUE if we can save, FALSE if there is a problem */ static gboolean gnc_entry_ledger_verify_can_save (GncEntryLedger *ledger) { gnc_numeric value; /* Compute the value and tax value of the current cursor */ gnc_entry_ledger_compute_value (ledger, &value, NULL); /* If there is a value, make sure there is an account */ if (! gnc_numeric_zero_p (value)) { switch (ledger->type) { case GNCENTRY_INVOICE_ENTRY: case GNCENTRY_CUST_CREDIT_NOTE_ENTRY: if (!gnc_entry_ledger_verify_acc_cell_ok (ledger, ENTRY_IACCT_CELL, _("This account should usually be of type income."))) return FALSE; break; case GNCENTRY_BILL_ENTRY: case GNCENTRY_EXPVOUCHER_ENTRY: case GNCENTRY_VEND_CREDIT_NOTE_ENTRY: case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY: if (!gnc_entry_ledger_verify_acc_cell_ok (ledger, ENTRY_BACCT_CELL, _("This account should usually be of type expense or asset."))) return FALSE; break; default: g_warning ("Unhandled ledger type"); break; } } return TRUE; }
static const char * get_value_entry (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data) { GncEntryLedger *ledger = user_data; gnc_numeric value; /* Credit notes need some attention here: the ledger displays values * as on the document, meaning positive for credit notes. Credit note * values are negative internally though. So depending on which values * are used to calculate the subtotal, the resulting subtotal has to be * sign-reversed before displaying. */ /* Check if this is the current cursor */ if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc)) { gnc_entry_ledger_compute_value (ledger, &value, NULL); /* Credit note info: this function works with values as seen * on-screen in the ledger, so they are always in the proper sign. * As per the above no sign reversal is needed for * credit note type ledgers. */ } else { GncEntry *entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc); if (entry == gnc_entry_ledger_get_blank_entry (ledger)) return NULL; value = gncEntryReturnValue (entry, ledger->is_cust_doc); /* Credit note info: this function works with internal values, * so they are negative for credit note type ledgers and have to * be sign-reversed as per the above. */ if (ledger->is_credit_note) value = gnc_numeric_neg (value); } return xaccPrintAmount (value, gnc_default_print_info (FALSE)); }