API Reference¶
Convenience collection of all main service classes
- class django_ctb.services.PartSatisfactionManager(*, part: Part, project_build: ProjectBuild)¶
Manages satisfaction of combined demand for parts in a project build. This is a receptacle in which to accumulate project parts which use a common part, then to assess the stock of said part (or it’s equivalents), finally creating reservations or shortages.
Use
add_project_partto accumulate project parts, then useensure_reservationto create a reservation (and inventory actions).- __init__(*, part: Part, project_build: ProjectBuild)¶
Provide a part and a project build. Then use
add_project_partto add any project parts which call for the same part. Once all project parts are tabulated, callensure_reservationto create the actual reservation.
- add_project_part(*, project_part: ProjectPart)¶
Add a project part for consideration in this manager. Increases the number of
neededparts, and tracks the project part itself for association to the reservation (should it come to pass).
- ensure_reservation() ProjectBuildPartReservation¶
Idempotent creation of reservations for an individual part to satisfy build. Creates inventory actions to trace the reservation, and alters inventory line quantities to suit.
- class django_ctb.services.ProjectBuildPartReservationService¶
Handles deletion of Project Build Part Reservations and restocking of inventory lines
- delete_reservation(reservation: ProjectBuildPartReservation)¶
Deletes reservation after crediting inventory lines and deleting inventory actions. Will not act on a utilized reservation.
- class django_ctb.services.ProjectBuildService¶
Service for clearing and completing project builds.
- cancel_build(build_pk)¶
Finds a project build by PK then removes any reservations or shortages associated with the project. Removes cleared status.
Ignores any project build which is marked completed.
- clear_to_build(build_pk)¶
Finds a project build by PK then reserves sufficient stock of parts to complete a project, or—barring availability—reserves stock of parts which are pletiful enough to complete the project build and creates shortages for those unfortunate parts which have low stocks.
Ignores any project build which is completed.
- complete_build(build_pk)¶
Finds a project build by PK then marks it complete. This will mark any reservation associated with the project as utilized. Will only find project builds which are not complete and have been cleared.
- class django_ctb.services.ProjectVersionBomService¶
Downloads BOM from repo at specified commit and creates project parts for each line.
- sync(project_version_pk)¶
Finds a project version by PK then downloads BOM from repository and creates project parts for each row. BOM rows which cannot be matched to any part in the system will be flagged with a
missing_part_description. Parts available through supported vendors (Mouser) will be autopopulated provided the PartNum is known.Rows referencing footprints which are configured with implicit project parts will cause additional project parts to be created to represent the implicit parts.
Upon completion of the sync process the commit hash where the BOM was found will be saved and the project version will be marked synced.
- class django_ctb.services.VendorOrderService¶
Service for creating vendor orders, and seeing their fulfillment through to altering inventory stock. Provides traceability through inventory actions.
- complete_order(order_pk)¶
Looks up a vendor order by PK then updates inventory lines for each part in the order, creates inventory action with change details. Marks vendor order as fulfilled.
Ignores any vendor order marked fulfilled.
- generate_vendor_orders(build_pk)¶
Looks up a project build by PK then creates or updates vendor orders and order lines to cover shortfalls for the given project build. Searches for appropriate vendors for each part. Will silently ignore parts that don’t have vendors.
Ignores any project build which is completed.
Services for interacting with the Mouser Search API
- class django_ctb.mouser.services.MouserPartService¶
Service for interacting with local instances of Mouser Part data
- create_vendor_part(row: BillOfMaterialsRow) VendorPart¶
Creates new vendor part for a BOM row, initiates job to populate part data from Mouser API
- class django_ctb.mouser.services.MouserService¶
Get data from the Mouser API to create parts
- exception MissingPart¶
The part cannot be located in the Mouser Search API
Services for interacting with the GitHub API
- class django_ctb.github.services.GithubService¶
Service for interacting with the GitHub API. Doesn’t use a client, just calls directly for these minimal public endpoints.