Fix autofill on credit note ledgers.

Note: this introduces a subtle change in how autofill works for business
ledgers: quantities will from now on always be autofilled to positive
values. See the comment in the code for more details.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21574 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2011-11-17 22:24:22 +00:00
parent 1357c9e737
commit 3338a102e3
2 changed files with 17 additions and 2 deletions

View File

@ -543,9 +543,21 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
set_value_combo_cell (cell, account_name);
g_free (account_name);
/* Auto-complete quantity cell */
/* Auto-complete quantity cell
* Note: we always autofill a positive quantity value. This allows us to
* - reuse invoice entries on credit note ledgers, meaning you can credit
* some invoice entry via autofill without having to manually fix the sign
* on the credit note.
* - autofill credit note entries on other credit note entries (without having
* to juggle sign reversals internally)
* - autofill credit note entries on invoice ledgers
*
* Disadvantage: invoice entries with explicitly set negative quantities will
* be autofilled to positive quantities in later uses. But it seems less common
* to me to require a negative entry again next time.
*/
cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_QTY_CELL);
set_value_price_cell (cell, gncEntryGetQuantity (auto_entry));
set_value_price_cell (cell, gnc_numeric_abs(gncEntryGetQuantity (auto_entry)));
/* Auto-complete price cell */
{

View File

@ -1274,6 +1274,9 @@ static void gnc_entry_ledger_model_new_handlers (TableModel *model,
case GNCENTRY_INVOICE_VIEWER:
case GNCENTRY_BILL_VIEWER:
case GNCENTRY_EXPVOUCHER_VIEWER:
case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
/* make this table read-only */
gnc_table_model_set_read_only (model, TRUE);
break;