Add independent part management and catalogue suggestions (TC-19 to TC-25)
Summary
- Added independent part creation from the Station Inventory page
- Added part name, unit, station, and initial-quantity fields
- Allowed an initial inventory quantity of zero
- Allowed an existing part to be assigned to another station
- Added case-insensitive part-name matching to prevent duplicate master records
- Preserved automatic part creation when a new part name is entered in a production step
- Added automatic zero-quantity station inventory when a job step introduces a part
- Added searchable part suggestions to the production-step form
- Preserved existing station stock when an existing catalogue part is selected
Test Cases
TC-19 — Create part with zero quantity
An administrator can create a part directly from Station Inventory, assign it to any station, select its unit, and set its initial quantity to zero.
TC-20 — Assign existing part to another station
An existing part can be assigned to another station with an independent quantity. Name and unit matching is case-insensitive, and no duplicate part master record is created.
TC-21 — Protect existing station inventory
Attempting to add the same part to the same station again is rejected. Existing inventory quantities are not overwritten.
TC-22 — Reuse catalogue part in a job step
When a job-step part name matches an existing catalogue part, including differences in capitalization or surrounding spaces, the existing part is reused. A zero-stock station record is created only when the selected station does not already have one.
TC-23 — Create new part from a job step
When the entered job-step part name does not match the catalogue, a new part is created with the default unit pcs. Its selected station receives an initial inventory quantity of zero.
TC-24 — Display searchable part suggestions
The production-step part field displays catalogue suggestions while still allowing the administrator to enter a completely new part name.
TC-25 — Reject negative initial quantity
A negative initial station quantity is rejected without creating a part or inventory record.
Verification
Automated test suite:
python -m pytest -v
Result:
46 passed
Manual verification confirmed:
- A new part was created directly at Station 2 with quantity zero
- A part using unit
kgwas created at Station 4 - An existing part was assigned to Station 5 without creating a duplicate master record
- Existing parts appeared as job-step suggestions
- Selecting an existing part did not overwrite station stock
- Entering a new job-step part created it with zero station inventory
- Activating a job with insufficient stock created the expected warehouse transfer requests