r21551 - gnucash/trunk/src/business - Adapt entry ledger to credit notes
Geert Janssens
gjanssens at code.gnucash.org
Thu Nov 10 10:05:16 EST 2011
Author: gjanssens
Date: 2011-11-10 10:05:16 -0500 (Thu, 10 Nov 2011)
New Revision: 21551
Trac: http://svn.gnucash.org/trac/changeset/21551
Modified:
gnucash/trunk/src/business/business-gnome/dialog-invoice.c
gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
gnucash/trunk/src/business/business-ledger/gncEntryLedger.h
gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerDisplay.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerLayout.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerP.h
Log:
Adapt entry ledger to credit notes
Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2011-11-10 15:05:16 UTC (rev 21551)
@@ -672,21 +672,21 @@
reverse = (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_CUSTOMER);
- /* Make sure that the invoice 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;
- }
+// /* 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;
- }
+// 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
@@ -1421,18 +1421,33 @@
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);
}
@@ -1442,11 +1457,21 @@
{
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);
@@ -1455,6 +1480,11 @@
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);
@@ -1759,14 +1789,17 @@
switch (iw->dialog_type)
{
case NEW_INVOICE:
- wintitle = _("New Invoice");
+ wintitle = iw->is_credit_note ? _("New Credit Note")
+ : _("New Invoice");
break;
case MOD_INVOICE:
case EDIT_INVOICE:
- wintitle = _("Edit Invoice");
+ wintitle = iw->is_credit_note ? _("Edit Credit Note")
+ : _("Edit Invoice");
break;
case VIEW_INVOICE:
- wintitle = _("View Invoice");
+ wintitle = iw->is_credit_note ? _("View Credit Note")
+ : _("View Invoice");
break;
}
break;
@@ -1774,14 +1807,17 @@
switch (iw->dialog_type)
{
case NEW_INVOICE:
- wintitle = _("New Bill");
+ wintitle = iw->is_credit_note ? _("New Credit Note")
+ : _("New Bill");
break;
case MOD_INVOICE:
case EDIT_INVOICE:
- wintitle = _("Edit Bill");
+ wintitle = iw->is_credit_note ? _("Edit Credit Note")
+ : _("Edit Bill");
break;
case VIEW_INVOICE:
- wintitle = _("View Bill");
+ wintitle = iw->is_credit_note ? _("View Credit Note")
+ : _("View Bill");
break;
}
break;
@@ -1789,14 +1825,17 @@
switch (iw->dialog_type)
{
case NEW_INVOICE:
- wintitle = _("New Expense Voucher");
+ wintitle = iw->is_credit_note ? _("New Credit Note")
+ : _("New Expense Voucher");
break;
case MOD_INVOICE:
case EDIT_INVOICE:
- wintitle = _("Edit Expense Voucher");
+ wintitle = iw->is_credit_note ? _("Edit Credit Note")
+ : _("Edit Expense Voucher");
break;
case VIEW_INVOICE:
- wintitle = _("View Expense Voucher");
+ wintitle = iw->is_credit_note ? _("View Credit Note")
+ : _("View Expense Voucher");
break;
}
break;
@@ -2052,8 +2091,10 @@
GncOwnerType owner_type;
GncEntryLedgerType ledger_type;
const gchar *gconf_section = NULL;
+ gboolean is_credit_note = FALSE;
- invoice = gncInvoiceLookup(iw->book, &iw->invoice_guid);
+ invoice = gncInvoiceLookup (iw->book, &iw->invoice_guid);
+ is_credit_note = gncInvoiceGetIsCreditNote (invoice);
iw->page = page;
@@ -2133,13 +2174,16 @@
switch (owner_type)
{
case GNC_OWNER_CUSTOMER:
- ledger_type = GNCENTRY_INVOICE_ENTRY;
+ ledger_type = is_credit_note ? GNCENTRY_CUST_CREDIT_NOTE_ENTRY
+ : GNCENTRY_INVOICE_ENTRY;
break;
case GNC_OWNER_VENDOR:
- ledger_type = GNCENTRY_BILL_ENTRY;
+ ledger_type = is_credit_note ? GNCENTRY_VEND_CREDIT_NOTE_ENTRY
+ : GNCENTRY_BILL_ENTRY;
break;
case GNC_OWNER_EMPLOYEE:
- ledger_type = GNCENTRY_EXPVOUCHER_ENTRY;
+ ledger_type = is_credit_note ? GNCENTRY_EMPL_CREDIT_NOTE_ENTRY
+ : GNCENTRY_EXPVOUCHER_ENTRY;
break;
default:
g_warning ("Invalid owner type");
@@ -2150,15 +2194,18 @@
switch (owner_type)
{
case GNC_OWNER_CUSTOMER:
- ledger_type = GNCENTRY_INVOICE_VIEWER;
+ ledger_type = is_credit_note ? GNCENTRY_CUST_CREDIT_NOTE_VIEWER
+ : GNCENTRY_INVOICE_VIEWER;
gconf_section = GCONF_SECTION_INVOICE;
break;
case GNC_OWNER_VENDOR:
- ledger_type = GNCENTRY_BILL_VIEWER;
+ ledger_type = is_credit_note ? GNCENTRY_VEND_CREDIT_NOTE_VIEWER
+ : GNCENTRY_BILL_VIEWER;
gconf_section = GCONF_SECTION_BILL;
break;
case GNC_OWNER_EMPLOYEE:
- ledger_type = GNCENTRY_EXPVOUCHER_VIEWER;
+ ledger_type = is_credit_note ? GNCENTRY_EMPL_CREDIT_NOTE_VIEWER
+ : GNCENTRY_EXPVOUCHER_VIEWER;
gconf_section = GCONF_SECTION_BILL;
break;
default:
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedger.c 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedger.c 2011-11-10 15:05:16 UTC (rev 21551)
@@ -103,7 +103,7 @@
account_types = g_list_prepend (account_types, (gpointer)ACCT_TYPE_CREDIT);
account_types = g_list_prepend (account_types, (gpointer)ACCT_TYPE_ASSET);
account_types = g_list_prepend (account_types, (gpointer)ACCT_TYPE_LIABILITY);
- if ( ledger->is_invoice )
+ if ( ledger->is_cust_doc )
account_types = g_list_prepend (account_types, (gpointer)ACCT_TYPE_INCOME);
else
account_types = g_list_prepend (account_types, (gpointer)ACCT_TYPE_EXPENSE);
@@ -161,7 +161,7 @@
/* If it has not changed, pull in the table from the entry */
entry = gnc_entry_ledger_get_current_entry (ledger);
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
return gncEntryGetInvTaxTable (entry);
else
return gncEntryGetBillTaxTable (entry);
@@ -298,15 +298,29 @@
case GNCENTRY_ORDER_VIEWER:
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
- ledger->is_invoice = TRUE;
+ ledger->is_cust_doc = TRUE;
+ ledger->is_credit_note = FALSE;
break;
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_BILL_VIEWER:
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER:
case GNCENTRY_NUM_REGISTER_TYPES:
- ledger->is_invoice = FALSE;
+ ledger->is_cust_doc = FALSE;
+ ledger->is_credit_note = FALSE;
break;
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
+ ledger->is_cust_doc = TRUE;
+ ledger->is_credit_note = TRUE;
+ break;
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
+ ledger->is_cust_doc = FALSE;
+ ledger->is_credit_note = TRUE;
+ break;
}
ledger->blank_entry_guid = *guid_null();
@@ -420,7 +434,7 @@
*
* 1. book AND
* 2. ( Entry->I-TYPE == ledger->invoice
- * #if I-TYPE == Invoice (entry only)
+ * #if I-TYPE == Invoice/Cust Credit Note (entry only)
* OR
* 3. ( Entry->Invoice == NULL AND
* ( Entry->Billable == TRUE AND
@@ -444,12 +458,18 @@
{
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
type = ENTRY_INVOICE;
break;
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_BILL_VIEWER:
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
type = ENTRY_BILL;
break;
default:
@@ -463,7 +483,8 @@
gncInvoiceGetGUID (ledger->invoice), QOF_QUERY_OR);
/* Term 3 */
- if (ledger->type == GNCENTRY_INVOICE_ENTRY &&
+ if ((ledger->type == GNCENTRY_INVOICE_ENTRY ||
+ ledger->type == GNCENTRY_CUST_CREDIT_NOTE_ENTRY) &&
gncOwnerGetEndGUID (gncInvoiceGetOwner (ledger->invoice)) != NULL)
{
@@ -603,8 +624,20 @@
ledger->type = GNCENTRY_EXPVOUCHER_VIEWER;
create_invoice_query (ledger);
break;
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ ledger->type = GNCENTRY_CUST_CREDIT_NOTE_VIEWER;
+ create_invoice_query (ledger);
+ break;
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ ledger->type = GNCENTRY_VEND_CREDIT_NOTE_VIEWER;
+ create_invoice_query (ledger);
+ break;
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ ledger->type = GNCENTRY_EMPL_CREDIT_NOTE_VIEWER;
+ create_invoice_query (ledger);
+ break;
default:
- return; /* Nothing to do */
+ return; /* Nothing to do */
}
}
else
@@ -626,8 +659,20 @@
ledger->type = GNCENTRY_EXPVOUCHER_ENTRY;
create_invoice_query (ledger);
break;
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
+ ledger->type = GNCENTRY_CUST_CREDIT_NOTE_ENTRY;
+ create_invoice_query (ledger);
+ break;
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
+ ledger->type = GNCENTRY_VEND_CREDIT_NOTE_ENTRY;
+ create_invoice_query (ledger);
+ break;
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
+ ledger->type = GNCENTRY_EMPL_CREDIT_NOTE_ENTRY;
+ create_invoice_query (ledger);
+ break;
default:
- return; /* Nothing to do */
+ return; /* Nothing to do */
}
}
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedger.h
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedger.h 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedger.h 2011-11-10 15:05:16 UTC (rev 21551)
@@ -35,10 +35,16 @@
GNCENTRY_ORDER_VIEWER,
GNCENTRY_INVOICE_ENTRY,
GNCENTRY_INVOICE_VIEWER,
+ GNCENTRY_CUST_CREDIT_NOTE_ENTRY,
+ GNCENTRY_CUST_CREDIT_NOTE_VIEWER,
GNCENTRY_BILL_ENTRY,
GNCENTRY_BILL_VIEWER,
+ GNCENTRY_VEND_CREDIT_NOTE_ENTRY,
+ GNCENTRY_VEND_CREDIT_NOTE_VIEWER,
GNCENTRY_EXPVOUCHER_ENTRY,
GNCENTRY_EXPVOUCHER_VIEWER,
+ GNCENTRY_EMPL_CREDIT_NOTE_ENTRY,
+ GNCENTRY_EMPL_CREDIT_NOTE_VIEWER,
GNCENTRY_NUM_REGISTER_TYPES
} GncEntryLedgerType;
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c 2011-11-10 15:05:16 UTC (rev 21551)
@@ -99,11 +99,14 @@
gncOrderAddEntry (ledger->order, blank_entry);
break;
case GNCENTRY_INVOICE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
/* Anything entered on an invoice entry must be part of the invoice! */
gncInvoiceAddEntry (ledger->invoice, blank_entry);
break;
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_EXPVOUCHER_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
/* Anything entered on an invoice entry must be part of the invoice! */
gncBillAddEntry (ledger->invoice, blank_entry);
break;
@@ -176,12 +179,15 @@
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;
@@ -304,6 +310,8 @@
{
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
use_invoice = TRUE;
break;
default:
@@ -425,6 +433,9 @@
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_EXPVOUCHER_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
break;
default:
return FALSE;
@@ -512,11 +523,14 @@
switch (ledger->type)
{
case GNCENTRY_INVOICE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_IACCT_CELL);
account_name = gnc_get_account_name_for_register (gncEntryGetInvAccount(auto_entry));
break;
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_BILL_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_BACCT_CELL);
account_name = gnc_get_account_name_for_register (gncEntryGetBillAccount(auto_entry));
break;
@@ -539,6 +553,7 @@
switch (ledger->type)
{
case GNCENTRY_INVOICE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
price = gncEntryGetInvPrice (auto_entry);
break;
default:
@@ -559,6 +574,7 @@
switch (ledger->type)
{
case GNCENTRY_INVOICE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
taxable = gncEntryGetInvTaxable (auto_entry);
taxincluded = gncEntryGetInvTaxIncluded (auto_entry);
taxtable = gncEntryGetInvTaxTable (auto_entry);
@@ -642,12 +658,18 @@
{
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
cell_name = ENTRY_IACCT_CELL;
break;
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_BILL_VIEWER:
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
cell_name = ENTRY_BACCT_CELL;
break;
default:
@@ -836,6 +858,7 @@
switch (ledger->type)
{
case GNCENTRY_INVOICE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
if (gncEntryGetOrder (entry) != NULL)
{
dialog = gtk_message_dialog_new(GTK_WINDOW(ledger->parent),
@@ -971,7 +994,8 @@
{
gboolean dontask = FALSE;
- if (ledger->type == GNCENTRY_INVOICE_ENTRY)
+ if (ledger->type == GNCENTRY_INVOICE_ENTRY ||
+ ledger->type == GNCENTRY_CUST_CREDIT_NOTE_ENTRY)
{
gboolean inv_value;
gboolean only_inv_changed = FALSE;
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerDisplay.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerDisplay.c 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerDisplay.c 2011-11-10 15:05:16 UTC (rev 21551)
@@ -105,16 +105,22 @@
break;
case GNCENTRY_INVOICE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
/* Watch the invoice owner to see when items get added via orders */
gnc_gui_component_watch_entity (ledger->component_id,
gncOwnerGetGUID
(gncInvoiceGetOwner (ledger->invoice)),
QOF_EVENT_MODIFY);
case GNCENTRY_INVOICE_VIEWER:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_BILL_VIEWER:
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
type = GNC_INVOICE_MODULE_NAME;
break;
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerLayout.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerLayout.c 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerLayout.c 2011-11-10 15:05:16 UTC (rev 21551)
@@ -170,14 +170,20 @@
case GNCENTRY_ORDER_VIEWER:
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
num_cols = 15;
break;
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_BILL_VIEWER:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
num_cols = 12;
break;
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
num_cols = 10;
break;
default:
@@ -204,6 +210,8 @@
case GNCENTRY_ORDER_VIEWER:
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
curs = gnc_table_layout_get_cursor (layout, "cursor");
gnc_table_layout_set_cell (layout, curs, ENTRY_DATE_CELL, 0, 0);
@@ -226,6 +234,8 @@
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_BILL_VIEWER:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
curs = gnc_table_layout_get_cursor (layout, "cursor");
gnc_table_layout_set_cell (layout, curs, ENTRY_DATE_CELL, 0, 0);
@@ -245,6 +255,8 @@
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
curs = gnc_table_layout_get_cursor (layout, "cursor");
gnc_table_layout_set_cell (layout, curs, ENTRY_DATE_CELL, 0, 0);
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c 2011-11-10 15:05:16 UTC (rev 21551)
@@ -207,6 +207,8 @@
case GNCENTRY_ORDER_VIEWER:
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
qf = gnc_get_shared_account_name_quickfill (root, IKEY,
skip_expense_acct_cb, NULL);
store = gnc_get_shared_account_name_list_store (root, IKEY,
@@ -217,6 +219,10 @@
case GNCENTRY_BILL_VIEWER:
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
case GNCENTRY_NUM_REGISTER_TYPES:
qf = gnc_get_shared_account_name_quickfill (root, EKEY,
skip_income_acct_cb, NULL);
@@ -284,6 +290,8 @@
{
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
shared_quickfill = gnc_get_shared_entry_desc_quickfill(ledger->book, DESC_QF_KEY_INVOICES, TRUE);
break;
default:
@@ -306,7 +314,7 @@
/* XXX (FIXME): This should be in a config file! */
/* Copy GncEntry information from the list to the rows of the Ledger. */
/* XXX This code is a cut-n-paste job from the SplitRegister code;
- * the split-regsiter should be generalized to the point where a cut-n-paste
+ * the split-register should be generalized to the point where a cut-n-paste
* like this isn't required, and this should be trashed.
*/
void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
@@ -344,6 +352,9 @@
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_BILL_ENTRY:
case GNCENTRY_EXPVOUCHER_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
gnc_suspend_gui_refresh ();
@@ -430,7 +441,7 @@
gnc_option_db_destroy (odb);
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
{
gncEntrySetInvTaxTable (blank_entry, table);
gncEntrySetInvTaxIncluded (blank_entry, taxincluded);
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c 2011-11-10 15:05:16 UTC (rev 21551)
@@ -292,7 +292,7 @@
gnc_numeric price;
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
price = gncEntryGetInvPrice (entry);
else
price = gncEntryGetBillPrice (entry);
@@ -318,6 +318,13 @@
if (gnc_numeric_zero_p (qty))
return NULL;
+ /* Credit notes have negative quantities, but the ledger should
+ * display it as on the document, meaning positive.
+ * So reverse the quantity for credit notes.
+ */
+ if (ledger->is_credit_note)
+ qty = gnc_numeric_neg (qty);
+
return xaccPrintAmount (qty, gnc_default_print_info (FALSE));
}
@@ -331,7 +338,7 @@
gboolean taxable;
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
taxable = gncEntryGetInvTaxable (entry);
else
taxable = gncEntryGetBillTaxable (entry);
@@ -384,7 +391,7 @@
}
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
table = gncEntryGetInvTaxTable (entry);
else
table = gncEntryGetBillTaxTable (entry);
@@ -412,7 +419,7 @@
}
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
taxincluded = gncEntryGetInvTaxIncluded (entry);
else
taxincluded = gncEntryGetBillTaxIncluded (entry);
@@ -460,8 +467,16 @@
if (entry == gnc_entry_ledger_get_blank_entry (ledger))
return NULL;
- value = gncEntryReturnValue (entry, ledger->is_invoice);
+ value = gncEntryReturnValue (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));
}
@@ -486,9 +501,16 @@
if (entry == gnc_entry_ledger_get_blank_entry (ledger))
return NULL;
- value = gncEntryReturnTaxValue (entry, ledger->is_invoice);
+ 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));
}
@@ -735,12 +757,22 @@
case GNCENTRY_BILL_VIEWER:
case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER:
- help = _("Is this entry Invoiced?");
+ help = _("Is this entry invoiced?");
break;
+ case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
+ case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
+ help = _("Is this entry credited?");
+ break;
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER:
help = _("Include this entry on this invoice?");
break;
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
+ help = _("Include this entry on this credit note?");
+ break;
default:
help = _("Unknown EntryLedger Type");
}
@@ -833,8 +865,9 @@
switch (ledger->type)
{
case GNCENTRY_INVOICE_ENTRY:
+ case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
{
- /* This cell should be mutably IFF this entry is attached to
+ /* This cell should be immutable IFF this entry is attached to
* a bill, order, or something else.
*/
GncEntry * entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
@@ -887,7 +920,7 @@
CellIOFlags flags = get_standard_io_flags (virt_loc, user_data);
/* If this isn't an invoice, or the flags are already read-only ... */
- if (!ledger->is_invoice || flags == XACC_CELL_ALLOW_SHADOW)
+ if (!ledger->is_cust_doc || flags == XACC_CELL_ALLOW_SHADOW)
return flags;
/* ok, if this is an invoice ledger AND this entry is attached to a
@@ -1047,7 +1080,15 @@
gnc_numeric amount;
if (gnc_entry_ledger_get_numeric (ledger, ENTRY_QTY_CELL, &amount))
+ {
+ /* Credit notes have negative quantities, but the ledger should
+ * display it as on the document, meaning positive.
+ * So reverse the quantity for credit notes.
+ */
+ if (ledger->is_credit_note)
+ amount = gnc_numeric_neg (amount);
gncEntrySetQuantity (entry, amount);
+ }
}
if (gnc_table_layout_get_cell_changed (ledger->table->layout,
@@ -1081,7 +1122,7 @@
if (gnc_entry_ledger_get_numeric (ledger, ENTRY_PRIC_CELL, &amount))
{
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
gncEntrySetInvPrice (entry, amount);
else
gncEntrySetBillPrice (entry, amount);
@@ -1094,7 +1135,7 @@
gboolean taxable;
taxable = gnc_entry_ledger_get_checkmark (ledger, ENTRY_TAXABLE_CELL);
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
gncEntrySetInvTaxable (entry, taxable);
else
gncEntrySetBillTaxable (entry, taxable);
@@ -1109,7 +1150,7 @@
table = gnc_entry_ledger_get_taxtable (ledger, ENTRY_TAXTABLE_CELL);
if (table)
{
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
gncEntrySetInvTaxTable (entry, table);
else
gncEntrySetBillTaxTable (entry, table);
@@ -1123,13 +1164,14 @@
taxincluded = gnc_entry_ledger_get_checkmark (ledger,
ENTRY_TAXINCLUDED_CELL);
- if (ledger->is_invoice)
+ if (ledger->is_cust_doc)
gncEntrySetInvTaxIncluded (entry, taxincluded);
else
gncEntrySetBillTaxIncluded (entry, taxincluded);
}
- if (ledger->type == GNCENTRY_INVOICE_ENTRY)
+ if (ledger->type == GNCENTRY_INVOICE_ENTRY ||
+ ledger->type == GNCENTRY_CUST_CREDIT_NOTE_ENTRY)
{
gboolean inv_value;
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerP.h
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerP.h 2011-11-10 15:05:05 UTC (rev 21550)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerP.h 2011-11-10 15:05:16 UTC (rev 21551)
@@ -30,28 +30,29 @@
struct GncEntryLedger_s
{
- GncGUID blank_entry_guid;
- gboolean blank_entry_edited;
+ GncGUID blank_entry_guid;
+ gboolean blank_entry_edited;
gboolean traverse_to_new;
- gboolean loading; /* To keep from recursing from events */
- gboolean full_refresh; /* Is a full refresh ok? */
- gint component_id; /* To register for events */
+ gboolean loading; /* To keep from recursing from events */
+ gboolean full_refresh; /* Is a full refresh ok? */
+ gint component_id; /* To register for events */
- Timespec last_date_entered;
+ Timespec last_date_entered;
- GncEntry * hint_entry; /* A Hint for where to display */
+ GncEntry * hint_entry; /* A Hint for where to display */
- GtkWidget * parent;
- QofBook * book;
- Table * table;
- GncOrder * order;
- GncInvoice * invoice;
- QofQuery * query;
+ GtkWidget * parent;
+ QofBook * book;
+ Table * table;
+ GncOrder * order;
+ GncInvoice * invoice;
+ QofQuery * query;
GncEntryLedgerType type;
- gboolean is_invoice; /* is this an invoice (or a bill)? */
+ gboolean is_cust_doc; /* is this document customer or vendor related ? */
+ gboolean is_credit_note; /* is this an invoice (or a bill)? */
const gchar * gconf_section;
};
More information about the gnucash-changes
mailing list