Adapt entry ledger to credit notes

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21551 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens
2011-11-10 15:05:16 +00:00
parent a216bc3d95
commit 490cacf980
9 changed files with 263 additions and 69 deletions
+77 -30
View File
@@ -672,21 +672,21 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data)
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 @@ 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);
}
@@ -1442,11 +1457,21 @@ 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);
@@ -1455,6 +1480,11 @@ 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);
@@ -1759,14 +1789,17 @@ gnc_invoice_get_title (InvoiceWindow *iw)
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 @@ gnc_invoice_get_title (InvoiceWindow *iw)
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 @@ gnc_invoice_get_title (InvoiceWindow *iw)
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 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
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 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
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 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
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:
+53 -8
View File
@@ -103,7 +103,7 @@ gnc_entry_ledger_get_account_by_name (GncEntryLedger *ledger, BasicCell * bcell,
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 @@ GncTaxTable * gnc_entry_ledger_get_taxtable (GncEntryLedger *ledger,
/* 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,14 +298,28 @@ GncEntryLedger * gnc_entry_ledger_new (QofBook *book, GncEntryLedgerType type)
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;
}
@@ -420,7 +434,7 @@ static void create_invoice_query (GncEntryLedger *ledger)
*
* 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 @@ static void create_invoice_query (GncEntryLedger *ledger)
{
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 @@ static void create_invoice_query (GncEntryLedger *ledger)
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 @@ void gnc_entry_ledger_set_readonly (GncEntryLedger *ledger, gboolean readonly)
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 @@ void gnc_entry_ledger_set_readonly (GncEntryLedger *ledger, gboolean readonly)
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 */
}
}
@@ -35,10 +35,16 @@ typedef enum
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;
@@ -99,11 +99,14 @@ gnc_entry_ledger_save (GncEntryLedger *ledger, gboolean do_commit)
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 @@ gnc_entry_ledger_verify_can_save (GncEntryLedger *ledger)
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 @@ find_entry_in_book_by_desc(GncEntryLedger *reg, const char* desc)
{
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 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
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 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
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 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
switch (ledger->type)
{
case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
price = gncEntryGetInvPrice (auto_entry);
break;
default:
@@ -559,6 +574,7 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
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 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
{
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 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
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 @@ gnc_entry_ledger_check_close (GtkWidget *parent, GncEntryLedger *ledger)
{
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;
@@ -105,16 +105,22 @@ gnc_entry_ledger_set_watches (GncEntryLedger *ledger, GList *entries)
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;
@@ -170,14 +170,20 @@ static void gnc_entry_ledger_layout_add_cursors (GncEntryLedger *ledger,
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 @@ static void gnc_entry_ledger_set_cells (GncEntryLedger *ledger,
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 @@ static void gnc_entry_ledger_set_cells (GncEntryLedger *ledger,
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 @@ static void gnc_entry_ledger_set_cells (GncEntryLedger *ledger,
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);
@@ -207,6 +207,8 @@ load_xfer_type_cells (GncEntryLedger *ledger)
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 @@ load_xfer_type_cells (GncEntryLedger *ledger)
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 @@ load_description_cell (GncEntryLedger *ledger)
{
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 @@ void gnc_entry_ledger_load_xfer_cells (GncEntryLedger *ledger)
/* 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 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
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 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
gnc_option_db_destroy (odb);
if (ledger->is_invoice)
if (ledger->is_cust_doc)
{
gncEntrySetInvTaxTable (blank_entry, table);
gncEntrySetInvTaxIncluded (blank_entry, taxincluded);
@@ -292,7 +292,7 @@ static const char * get_pric_entry (VirtualLocation virt_loc,
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 @@ static const char * get_qty_entry (VirtualLocation virt_loc,
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 @@ static const char * get_taxable_entry (VirtualLocation virt_loc,
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 @@ static const char * get_taxtable_entry (VirtualLocation virt_loc,
}
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 @@ static const char * get_taxincluded_entry (VirtualLocation virt_loc,
}
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 @@ static const char * get_value_entry (VirtualLocation virt_loc,
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 @@ static const char * get_taxval_entry (VirtualLocation virt_loc,
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 @@ static char * get_inv_help (VirtualLocation virt_loc, gpointer user_data)
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 @@ static CellIOFlags get_inv_io_flags (VirtualLocation virt_loc,
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 @@ static CellIOFlags get_qty_io_flags (VirtualLocation virt_loc, gpointer user_dat
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 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
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 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
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 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
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 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
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 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
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;
+15 -14
View File
@@ -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;
};