mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Make invoice totals always document values. These functions are only
used for displaying. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21992 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -684,22 +684,6 @@ gnc_invoice_window_postCB (GtkWidget *unused_widget, gpointer data)
|
||||
is_cust_doc = (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_CUSTOMER);
|
||||
is_cn = gncInvoiceGetIsCreditNote (invoice);
|
||||
|
||||
// /* Make sure that the invoice/credit note has a positive balance */
|
||||
// if (gnc_numeric_negative_p(gncInvoiceGetTotal(invoice)))
|
||||
// {
|
||||
// gnc_error_dialog(iw_get_window(iw), "%s",
|
||||
// _("You may not post an invoice with a negative total value."));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (iw->total_cash_label &&
|
||||
// gnc_numeric_negative_p(gncInvoiceGetTotalOf(invoice, GNC_PAYMENT_CASH)))
|
||||
// {
|
||||
// gnc_error_dialog(iw_get_window(iw), "%s",
|
||||
// _("You may not post an expense voucher with a negative total cash value."));
|
||||
// return;
|
||||
// }
|
||||
|
||||
/* Ok, we can post this invoice. Ask for verification, set the due date,
|
||||
* post date, and posted account
|
||||
*/
|
||||
@@ -1482,33 +1466,18 @@ gnc_invoice_redraw_all_cb (GnucashRegister *g_reg, gpointer data)
|
||||
if (iw->total_label)
|
||||
{
|
||||
amount = gncInvoiceGetTotal (invoice);
|
||||
/* Credit notes have their value signs reversed internally.
|
||||
* So reverse here as well before displaying
|
||||
*/
|
||||
if (iw->is_credit_note)
|
||||
amount = gnc_numeric_neg (amount);
|
||||
gnc_invoice_reset_total_label (GTK_LABEL (iw->total_label), amount, currency);
|
||||
}
|
||||
|
||||
if (iw->total_subtotal_label)
|
||||
{
|
||||
amount = gncInvoiceGetTotalSubtotal (invoice);
|
||||
/* Credit notes have their value signs reversed internally.
|
||||
* So reverse here as well before displaying
|
||||
*/
|
||||
if (iw->is_credit_note)
|
||||
amount = gnc_numeric_neg (amount);
|
||||
gnc_invoice_reset_total_label (GTK_LABEL (iw->total_subtotal_label), amount, currency);
|
||||
}
|
||||
|
||||
if (iw->total_tax_label)
|
||||
{
|
||||
amount = gncInvoiceGetTotalTax (invoice);
|
||||
/* Credit notes have their value signs reversed internally.
|
||||
* So reverse here as well before displaying
|
||||
*/
|
||||
if (iw->is_credit_note)
|
||||
amount = gnc_numeric_neg (amount);
|
||||
gnc_invoice_reset_total_label (GTK_LABEL (iw->total_tax_label), amount, currency);
|
||||
}
|
||||
|
||||
@@ -1518,21 +1487,11 @@ gnc_invoice_redraw_all_cb (GnucashRegister *g_reg, gpointer data)
|
||||
{
|
||||
gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (iw->to_charge_edit));
|
||||
to_charge_amt = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(iw->to_charge_edit));
|
||||
/* Credit notes have their value signs reversed internally.
|
||||
* So reverse here as well before displaying
|
||||
*/
|
||||
if (iw->is_credit_note)
|
||||
to_charge_amt = gnc_numeric_neg (to_charge_amt);
|
||||
}
|
||||
|
||||
if (iw->total_cash_label)
|
||||
{
|
||||
amount = gncInvoiceGetTotalOf (invoice, GNC_PAYMENT_CASH);
|
||||
/* Credit notes have their value signs reversed internally.
|
||||
* So reverse here as well before displaying
|
||||
*/
|
||||
if (iw->is_credit_note)
|
||||
amount = gnc_numeric_neg (amount);
|
||||
amount = gnc_numeric_sub (amount, to_charge_amt,
|
||||
gnc_commodity_get_fraction (currency), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_invoice_reset_total_label (GTK_LABEL (iw->total_cash_label), amount, currency);
|
||||
@@ -1541,11 +1500,6 @@ gnc_invoice_redraw_all_cb (GnucashRegister *g_reg, gpointer data)
|
||||
if (iw->total_charge_label)
|
||||
{
|
||||
amount = gncInvoiceGetTotalOf (invoice, GNC_PAYMENT_CARD);
|
||||
/* Credit notes have their value signs reversed internally.
|
||||
* So reverse here as well before displaying
|
||||
*/
|
||||
if (iw->is_credit_note)
|
||||
amount = gnc_numeric_neg (amount);
|
||||
amount = gnc_numeric_add (amount, to_charge_amt,
|
||||
gnc_commodity_get_fraction (currency), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_invoice_reset_total_label (GTK_LABEL (iw->total_charge_label), amount, currency);
|
||||
|
||||
@@ -783,7 +783,7 @@ gncInvoiceGetTotalInternal (GncInvoice *invoice, gboolean use_value,
|
||||
{
|
||||
GList *node;
|
||||
gnc_numeric total = gnc_numeric_zero();
|
||||
gboolean is_cust_doc;
|
||||
gboolean is_cust_doc, is_cn;
|
||||
|
||||
g_return_val_if_fail (invoice, total);
|
||||
|
||||
@@ -791,6 +791,7 @@ gncInvoiceGetTotalInternal (GncInvoice *invoice, gboolean use_value,
|
||||
* The GncEntry code needs to know to return the proper entry amounts
|
||||
*/
|
||||
is_cust_doc = (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_CUSTOMER);
|
||||
is_cn = gncInvoiceGetIsCreditNote (invoice);
|
||||
|
||||
for (node = gncInvoiceGetEntries(invoice); node; node = node->next)
|
||||
{
|
||||
@@ -800,7 +801,7 @@ gncInvoiceGetTotalInternal (GncInvoice *invoice, gboolean use_value,
|
||||
if (use_payment_type && gncEntryGetBillPayment (entry) != type)
|
||||
continue;
|
||||
|
||||
value = gncEntryGetIntValue (entry, FALSE, is_cust_doc);
|
||||
value = gncEntryGetDocValue (entry, FALSE, is_cust_doc, is_cn);
|
||||
if (gnc_numeric_check (value) == GNC_ERROR_OK)
|
||||
{
|
||||
if (use_value)
|
||||
@@ -811,7 +812,7 @@ gncInvoiceGetTotalInternal (GncInvoice *invoice, gboolean use_value,
|
||||
|
||||
if (use_tax)
|
||||
{
|
||||
tax = gncEntryGetIntTaxValue (entry, FALSE, is_cust_doc);
|
||||
tax = gncEntryGetDocTaxValue (entry, FALSE, is_cust_doc, is_cn);
|
||||
if (gnc_numeric_check (tax) == GNC_ERROR_OK)
|
||||
total = gnc_numeric_add (total, tax, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
|
||||
else
|
||||
|
||||
@@ -152,7 +152,8 @@ Transaction * gncInvoiceGetPostedTxn (const GncInvoice *invoice);
|
||||
Account * gncInvoiceGetPostedAcc (const GncInvoice *invoice);
|
||||
/** @} */
|
||||
|
||||
/** return the "total" amount of the invoice */
|
||||
/** Return the "total" amount of the invoice as seen on the document
|
||||
* (and shown to the user in the reports and invoice ledger). */
|
||||
gnc_numeric gncInvoiceGetTotal (GncInvoice *invoice);
|
||||
gnc_numeric gncInvoiceGetTotalOf (GncInvoice *invoice, GncEntryPaymentType type);
|
||||
gnc_numeric gncInvoiceGetTotalSubtotal (GncInvoice *invoice);
|
||||
|
||||
Reference in New Issue
Block a user