GNOME Bugzilla – Bug 421684
Add support for modifying lot information
Last modified: 2018-06-29 21:30:28 UTC
The lot-handling code currently requires a 100% LIFO model for lot assignment, which is often not the right choice. The user should be able to assign splits to lots from within the register interface.
Created attachment 85143 [details] [review] Adds support for viewing / editing lot information to the register. 2007-03-22 Klee Dienes <klee@mit.edu> * register/register-core/combocell.h (ComboCell): Add 'data' field. * register/register-gnome/combocell-gnome.c (select_item_cb): Add item-specific data to prototype and store it in the cell. (change_item_cb): Ditto. * register/register-gnome/gnucash-item-list.c (GMarshalFunc_VOID__POINTER_POINTER): New function. (gnc_item_list_class_init): Use GMarshalFunc_VOID__POINTER_POINTER to marshal the data for select_item and change_item. (tree_view_selection_changed): Get the GNCLot pointer from the model for the list selector and pass it to the select_item and change_item signals. * register/ledger-core/split-register-model-save.c (gnc_split_register_save_lot_cell): New function. Set the lot of the appropriate split to the passed-in lot. (gnc_split_register_model_add_save_handlers): Set gnc_split_register_save_lot_cell as the handler for the lot combocells. * register/ledger-core/split-register-model.c (gnc_split_register_get_lot_label): New handler. (gnc_split_register_get_lot_entry): New handler. Returns the name of the for the given location in the split register. (gnc_split_register_get_lot_help): New handler. (gnc_split_register_model_new): Set the handlers for LOT_CELL. * register/ledger-core/split-register.h (LOT_CELL): Define. * register/ledger-core/split-register-layout.c (gnc_split_register_set_cells): Insert "Lot" field for stock and currency registers. (gnc_split_register_layout_add_cells): Add lot cell. * register/ledger-core/split-register-load.c (gnc_split_register_load): Use gnc_split_register_load_lot_cells. (lot_handler): New function, used by gnc_make_account_lot_list_store. (gnc_make_account_lot_list_store): New function. Make a list store containing the names of all the lots for the account, and pointers to their respective GNCLot. (gnc_split_register_load_lot_cells): Load the menus for the lot cell combobuttons.
There are several limitations to the attached patch: - It only works for the "old" register code, with no attempt made to update the register-rewrite branch. - It only adds lot support to currency and stock accounts, not to all other account types. - It does not allow modification of the text field to change the lot selection, only the pull-down list. Changing the text field will result in no change to the lot being saved when the user goes to the next field (I was figuring there should be an easy way to set the field to be read-only, or just have a pull-down selection menu, but it wasn't obvious how to find out). - It does not update the lot menus for open registers when new lots are added or removed. The user has to close the registers and re-open them manually. I'm submitting this patch in its present state because: - I'm not sure if it's best for me to continue working on it in the top-of-tree branch or in the register-rewrite branch. Getting all the details right in the top-of-tree branch is looking to be a moderate hassle, and one I'd rather not undertake if I can just do it in the register-rewrite branch. On the other hand, the register-rewrite branch is "pretty damn complicated," at least at first glance. - I'm not sure if this is how the Gnucash maintainers would like to see lots handled at all, so I'd like to get some feedback before I do too much polish work. - (And the big one:) The pace of my Army training is about to ramp up significantly, and I may not get much time to work on this at all in the next several months. So better to submit an incomplete patch that still allows very effective tax-lot editing, than to keep it to myself until I have a chance to work on it again.
Comment on attachment 85143 [details] [review] Adds support for viewing / editing lot information to the register. thank you for this patch. Unfortunately, it does not apply cleanly anymore to current trunk. Can you please rebase it?
Will do, probably this weekend.
GnuCash bug tracking has moved to a new Bugzilla host. The new URL for this bug is https://bugs.gnucash.org/show_bug.cgi?id=421684. Please continue processing the bug there and please update any external references or bookmarks.