sde1000 / quicktill

Figure out where all the money and stock went to
GNU General Public License v3.0
43 stars 9 forks source link

Stock-take feature #203

Open sde1000 opened 4 years ago

sde1000 commented 4 years ago

A stock-take is a way to record waste across a number of different stock items or stock types in an atomic fashion. We want to take a snapshot of the state at the start of the stock-take, build up a list of record-waste, finish-item and add-item actions, and apply them all in one go. (Or throw them away if we abandon the stock-take.)

A stock-take has a "scope": the set of types of item that we want to check. How should this scope be defined? At the moment, "department" seems to be the obvious selector. Will we ever need others? Eg. "all stock from Milton" or "everything that has been on sale on a particular stock line"? The danger here is in conflating Department as an accounting-level feature (used to split stock into purchase and sales accounts) with Department as a stock-organisation feature.

Do we want to store the scope in the database along with the stock-take? What would we use it for? Deciding whether a stock addition ("discovered stock") is valid? Could be useful. How would we store it? A list of stock types? Could this get large, quickly? (A few thousand stock types; one copy per stock take. But purge that copy when the stock take is completed?)

Let's say we store the scope as a set of departments, for now. Add an accessor method to the stock-take to retrieve the list (or filter another query by the list, probably more usefully), and that makes it easier to change it in the future.

What about whether we stock-take by items or by quantities? Where do we store that? Does it ever make sense to include both methods in a single stock-take? How would we split them up — separate scopes for each method? What if the scopes overlapped? (Main example in our data: snacks — some are on "regular" stock lines and others on "display" or "continuous".) I don't think we can go with different scopes, they will have to be combined.

Ok, having different methods in the database sounds like a bad idea. Let's say that everything is done as stock-take-by-item, and we add some user-interface on top of that to perform stock-take-by-quantity. (Eg. show a list of stocktypes in the UI, with 'expand' toggles to additionally show items.) Does this work? If the total for a stocktype is edited, we can re-write the totals for the underlying items. If the total for an item is edited, we can re-write the total for the stocktype. (Or just change what is reported by the server, calculated from the underlying items.)

Actually, "all stock-types" stored in the database for the stock-take scope sounds like a better idea now: it gives us somewhere to hang our intermediate flags, like whether a particular type is shown expanded.

So stock-take procedure looks like:

sde1000 commented 4 years ago

Initial version in be48851991a5258eda6f6c894123b46ec90c1b2c

sde1000 commented 4 years ago

Some UI tweaks needed:

sde1000 commented 4 years ago

More tweaks!

sde1000 commented 3 years ago

"Name this stock-take" page added in c0a8d9a54083bc67f94012561e1c5b62fe597fc9

sde1000 commented 2 years ago

Stock-keeping quantities added to Unit in 0445ce6e2e5c8aca427f95b1e933f8af5de4d86c