heikkilevanto / beertracker

Simple script to track the beers I drink
GNU General Public License v2.0
2 stars 1 forks source link

Editing box wine volumes #183

Closed heikkilevanto closed 3 months ago

heikkilevanto commented 3 years ago

Does not recalculate the box volume.

heikkilevanto commented 3 years ago

One way to do this: When reading the file, I keep track of the latest wine of the same type. Make sure that is not the line we are trying to edit. That way, we recalculate the amount correctly, at least as long as we are editing the latest line.

The general case is more tricky, if we edit a line back in the history, it is not enough to recalculate the box volume at the end of that line, but all subsequent lines need to be recalculated. Hmm...

In any case, it might make sense to have a list for a given box, that would sum up the actual amounts, and show if we have a difference.

heikkilevanto commented 3 years ago

A better way would be to keep a running tally of the contents of the current box when writing the edited file, and update each line with the correct volume. That might be surprising, if editing the raw data file, but I could live with that, and no other user would be able to do that.

heikkilevanto commented 3 years ago

Actually, it is wrong to keep the remaining volume in the data file at all. Better to calculate it while reading the file, and append to the lines at that stage. That way, editing and deleting lines will just work. All I need is a marker that a line belongs to a box (B1:). If there is a volume, that should override the running calculation. Always on the first line, but maybe later, if I edit a line to have one.

heikkilevanto commented 3 years ago

I should drop the whole negative price thing, and indicate a new box simply with a comment like (B:300) which will automagically be expanded to the next free box number: (B2:300)

When reading the file, keep track of the box volumes. If one mentioned on a line, use that, otherwise deduct the abs(volume) from the box, and display that.

heikkilevanto commented 3 months ago

Dropping the whole box wine thing