Closed wvengen closed 8 years ago
This code lets you see the states used by Vokomokum: https://www.assembla.com/spaces/vokomokum/git/source/master/order/cgi-bin/adm_ord_status.cgi#ln40
If've started to implement this upstream on feature/boxfills. Configuration works (enable the feature in configuration screen, and setting it for the order).
To document, I'll share my considerations on the rules for the boxill (=reduce shortages) phase.
I think this would be captured by the following in the decrease shortage phase:
art_q = <sum of all member quantities>
art_t = <sum of all member tolerances>
mem_q = <desired quantity for member>
mem_t = <allowed tolerance for member>
unit_quantity = <how many units make a box>
# how many units are still needed to fulfill all member quantities
missing_units = unit_quantity - ((art_q % unit_quantity) + art_t)
missing_units = 0 IF missing_units < 0 OR missing_units == unit_quantity
# number of boxes to order at supplier
boxes = FLOOR(art_q/unit_quantity)
IF art_q%unit_quantity>0 AND art%unit_quantity + art_t > unit_quantity THEN boxes += 1
delta_art_q = art_q[after_change] - art_q[before_change]
delta_art_t = art_t[after_change] - art_t[before_change]
(etc.)
IF delta_missing_units < 0 AND delta_boxes >= 0 AND delta_art_t >= 0 THEN ALLOW
ELSE IF delta_art_q > 0 AND delta_art_q == -delta_art_t THEN ALLOW
ELSE DENY
(If the terms quantity, tolerance and unit_quantity are new you to, it is explained here in German.)
One open question:
(The open question about admins being able to change in any case, matters because this check could very well go into the OrderArticle model, where it refuses to save when the conditions are not met if the order is in the boxfill phase. If an admin should still be able to save it, either the model should somehow know who initiated the change, or the check should move to the controller, so that it is only executed for member ordering. Both cases require some more thinking for a clean solution.)
Upstream supports this via https://github.com/foodcoops/foodsoft/pull/387
Implemented via #170. It would be useful to have this tested by someone else at some point.
For dry ordering, Vokomokum needs a decrease shortage phase: at the end of the ordering period, members can only change amounts that don't increase a shortage in wholesale packages. When a member visits the ordering page, he only sees articles with a shortage, to help him fill it.