fpiweb.support package

Submodules

fpiweb.support.BoxActivity module

BoxActivity.py - Record activity for changes to a box.

Error messages from this module are prefixed by 2nn, e.g. “201 - blah blah…”

class fpiweb.support.BoxActivity.BOX_ACTION(value)[source]

Bases: enum.Enum

Actions to be applied to a box.

ADD: str = 'add'
EMPTY: str = 'empty'
FILL: str = 'fill'
MOVE: str = 'move'
class fpiweb.support.BoxActivity.BoxActivityClass[source]

Bases: object

BoxManagementClass - Manage db for changes to a box.

I decided that (for now) empty boxes should not be added to the activity records. Activity records will show only when a box was filled or emptied. The activity records for filled boxes will show only their current location. Activity records for consumed boxes will show their last location. (tr)

For now, the activity records will not show empty boxes, damaged or discarded boxes removed from the inventory system.

box_empty(box_id: <django.db.models.query_utils.DeferredAttribute object at 0x7fe852df1790>)[source]

Record activity for a box being emptied (consumed).

This method expects the box record to still have the location, product, etc. information still in it. After recording the appropriate information in the activity record, this method will clear out the box so it will be empty again.

Parameters

box_id

Returns

box_fill(box_id: <django.db.models.query_utils.DeferredAttribute object at 0x7fe852df1790>)[source]

Record activity for a box being filled and added to inventory.

This method expects that the box record already has the box type. location, product, and expiration date filled in.

This method will write a new activity record that “starts the clock” for this box. If the box was already marked as checked in to inventory, the previous contents will be checked out and the new contents checked in.

Parameters

box_id – internal box ID of box being added to inventory

Returns

box_move(box_id: <django.db.models.query_utils.DeferredAttribute object at 0x7fe852df1790>)[source]

Record activity for a box being moved in tne inventory.

This method expects that the box record already has the box type. location, product, and expiration date filled in.

This method will change the current location of the box in the activity record. The old location will not be retained nor will any “clocks” for the activity record be updated.

If the box does not have an open activity record, a new one will be created.

Parameters

box_id – internal box ID of box being moved

Returns

box_new(box_id: <django.db.models.query_utils.DeferredAttribute object at 0x7fe852df1790>)[source]

Record that a new (empty) box has been added to inventory.

Parameters

box_id – internal box ID of box being added to inventory

Returns

compute_duration_days(date_filled: datetime.date) → tuple[source]

compute the days between the date filled and today

Parameters

date_filled

Returns

tuple of date consumed and number of days in box

fpiweb.support.BoxManagement module

BoxManagement.py - Manage box creating, filling, moving and emptying.

Error messages from this module are prefixed by 1nn, e.g. “101 - blah blah…”

class fpiweb.support.BoxManagement.BoxManagementClass[source]

Bases: object

BoxManagementClass - Manage db changes for box changes.

The public API’s validate parameter values. The private methods perform the actual actions.

box_consume(box: Union[fpiweb.models.Box, int])fpiweb.models.Box[source]

Consume (e.g. empty) a box. The box will be marked empty, the activity record will be updated, and the box will be returned.

Requirements:

  • The box must not be empty when passed in.

Exception:

131 - Box not in system

132 - The box was already empty

Parameters

box

Returns

the box record freshly emptied

box_fill(*, box: Union[fpiweb.models.Box, int], location: Union[fpiweb.models.Location, int], product: Union[fpiweb.models.Product, int], exp_year: int, exp_mo_start: int = 0, exp_mo_end: int = 0)[source]

Fill an individual box with product and add to the inventory. If the box is not empty, an activity record will empty the box of its previous contents and a new activity record will note the new contents profiled. If successful, it will return the box just filled.

Requirements:

  • Box record has not been modified

  • All required fields are valid

  • Optional month start and end, if specified, bracket one or more months

Exceptions:

111 - Attempting to fill a box that does not exist

112 - location supplied is not valid

113 - the product supplied is not valid

114 - the expiration year, start month, and/or end month are

not valid or are out of range

Parameters
  • box – Box record or id of a box already in the system

  • location – Target location record or ID

  • product – Target product record or ID

  • exp_year – year (current year +/- 10)

  • exp_mo_start – 1 - 12 if specified - usually beginning quarter

  • exp_mo_end – 1-12 if specified - usually ending quarter

Returns

box record after modifications

box_move(box: Union[fpiweb.models.Box, int], location: Union[fpiweb.models.Location, int])[source]

Move an individual box in the inventory. The activity record for this box will be changed to show the new location. The old location will be dropped from the activity record. If successful, the box record will be returned.

Requirements:

  • Box is filled

  • Location is valid

Exceptions:

121 - Box not in system

122 - Cannot move an empty box

123 - Location is not valid

Parameters
  • box

  • location

Returns

box_new(box_number: str, box_type: Union[str, int, fpiweb.models.BoxType])fpiweb.models.Box[source]

Add a new empty box to the inventory system. If successful it adds an activity record for an empty box and returns the box record just created.

Requirements:

  • Box number is valid, unique, and not previously assigned

  • Box type is valid

Exceptions:

101 - Box number supplied is not in the valid format (‘BOXnnnn’)

102 - Box number is not unique

102 - Box type is not valid

Parameters
  • box_number – in the form of ‘BOXnnnnn’

  • box_type – a valid box type code, BoxType record or record id

Returns

the newly created box record

pallet_finish(pallet: Union[fpiweb.models.Pallet, int, str])[source]

Finish the processing of a pallet of boxes into inventory. Each box of the pallet will be processed. Nothing will be returned.

Note - a pallet is still considered valid even if there are no boxes associated with it.

Requirements:

  • A valid pallet record, pallet name, or ID

  • A pallet status indicating if the boxes have just been filled or are being moved to a new location

Exception:

161 - An invalid pallet ID was passed in

162 - An invalid pallet name was passed in

166 - The pallet has an invalid location

Parameters

pallet

Returns