Skip to main content

FAQ

How is raw material added to the system?

Raw materials are added to the system through the ReceivedMaterial model. When a vendor delivers materials, the following process occurs:

  1. A new ReceivedMaterial record is created with:
  2. Vendor information
  3. Material reference
  4. Quantity (units)
  5. Purchase order number
  6. Shipping information (carrier, bill of lading)
  7. Receipt date
  8. Batch/lot number (auto-generated if not provided)

  9. When a ReceivedMaterial record is saved:

  10. The system validates that quantity is positive and receipt date is not in the future
  11. An automatic MaterialInventory record is created or updated for the material
  12. The rcvd field in MaterialInventory is updated to reflect the new quantity
  13. A MaterialTransaction is implicitly created showing movement of material to the RAW stage

The system tracks all received materials with their metadata, allowing for batch traceability from vendor to final product.

How is raw material allocated?

Raw materials are allocated through the MaterialTransaction model. The process moves materials from the RAW stage to the ALLOCATED stage:

  1. When materials are assigned to a specific production order, a MaterialTransaction record is created with:
  2. Material reference
  3. From_stage = "RAW"
  4. To_stage = "ALLOCATED"
  5. Quantity needed for the production run

  6. This allocation reduces the available quantity in the RAW stage while increasing the amount in the ALLOCATED stage, as tracked by:

  7. The quantity_in_stage() method in the Material model
  8. Corresponding fields in the MaterialInventory model

This allocation mechanism reserves materials for specific production batches without physically removing them from inventory, ensuring materials are not double-counted or over-allocated.

How do we track batched material?

Batched materials are tracked through multiple models:

  1. BatchTicket model:
  2. Links to a specific OrderItem
  3. Contains manufacturing details (EPA numbers, quantities, temperatures)
  4. Automatically generates a unique lot number (format: CP[YY][DayOfYear][BatchLetter])
  5. Tracks the total quantity of materials used in a batch

  6. BatchMaterial model:

  7. Links to a BatchTicket
  8. Records each specific component used in the batch
  9. Stores each component's lot number, manufacturer, description, etc.
  10. Tracks planned weight versus actual weight used

  11. MaterialTransaction records track the movement:

  12. From ALLOCATED stage to BATCHED stage
  13. Records the specific quantity used in production

The system maintains complete batch traceability by connecting raw materials to finished goods through the batch ticket system.

How do we track materials and components that have been assigned to an assembly line?

Materials assigned to assembly lines are tracked through the MPSRecord (Master Production Schedule) and associated models:

  1. The MPSRecord model:
  2. Links to a specific OrderItem (which contains product and quantity information)
  3. Assigns production to a specific Line
  4. Schedules production during a specific Shift
  5. Tracks start and end dates
  6. Monitors production status (Scheduled, Running, Delayed, Completed)

  7. The ProductionRecord model:

  8. Tracks actual production against an MPSRecord
  9. Records quantity produced
  10. Timestamps when production occurred
  11. Relates back to the line and order item through the MPSRecord

  12. MaterialTransaction records track movement of components:

  13. From BATCHED stage to other stages as assembly progresses

This system provides visibility into: - Which materials are at which assembly line - Production progress compared to schedule - Remaining quantity to be produced - Expected completion dates

How finished/assembled material move to shipped?

Finished materials move to shipped through the following flow:

  1. When production is complete on an assembly line, the system:
  2. Updates the status of the MPSRecord to "Completed"
  3. Creates a MaterialTransaction record moving materials from FINISHED to SHIPPED stage

  4. The MaterialTransaction model records:

  5. Material reference
  6. From_stage = "FINISHED"
  7. To_stage = "SHIPPED"
  8. Quantity being shipped

  9. The Order model:

  10. Tracks the overall order status (Open, Closed, Cancelled)
  11. May be updated to "Closed" when all items are shipped
  12. Records the closed date

This flow ensures accurate tracking of inventory throughout the entire lifecycle, from receipt to shipment.

How does material go from running to finished?

Materials transition from running to finished status through:

  1. The ProductionRecord model:
  2. Records actual quantities produced against an MPSRecord
  3. Each record represents completed units of production

  4. When production is complete:

  5. The MPSRecord status is updated from "Running" to "Completed"
  6. The percent_complete property reaches 100%
  7. A MaterialTransaction record is created moving materials from BATCHED (or intermediate stages) to FINISHED

  8. The system calculates:

  9. Total produced quantity via total_produced_quantity property
  10. Remaining quantity via remaining_quantity property
  11. Completion percentage via percent_complete property

This transition represents the point where materials have completed the production process and are ready for shipping.

How do we determine quantity on hand for raw materials, components, batched materials, packaged/finished materials, and shipped materials?

Quantities are determined through several mechanisms:

  1. For raw materials:
  2. The MaterialInventory.qoh property calculates: beginning balance + received - batched - adjustments
  3. The Material.raw property calls quantity_in_stage(InventoryStages.RAW)

  4. For allocated components:

  5. The Material model's quantity_in_stage(InventoryStages.ALLOCATED) method calculates:

    • Sum of quantities moved TO the ALLOCATED stage
    • Minus sum of quantities moved FROM the ALLOCATED stage
  6. For batched materials:

  7. The Material.batched property (via quantity_in_stage(InventoryStages.BATCHED))
  8. The BatchTicket and BatchMaterial models track specific details

  9. For finished materials:

  10. The Material.finished property (via quantity_in_stage(InventoryStages.FINISHED))
  11. The ProductionRecord model tracks completed quantities

  12. For shipped materials:

  13. The Material.shipped property (via quantity_in_stage(InventoryStages.SHIPPED))

The MaterialTransaction model is the core tracking mechanism, recording all movements between stages with appropriate quantities. The system optimizes inventory calculations using prefetching and caching with prefetch_inventory_data().

How can I be informed of insufficient quantity for materials when a new sales order is entered?

The current model doesn't explicitly implement an alert system for insufficient quantities, but several components can be leveraged to build this functionality:

  1. Using the Material.quantity_in_stage() method:
  2. When a new order is created, the system can check available raw material quantities
  3. Compare required quantities (from BOM) against available quantities (RAW stage)

  4. Implementing an order validation method:

  5. Add a method to the Order or OrderItem models that checks material availability
  6. Calculate requirements based on the BillofMaterial for each product

  7. Using the get_bom_usages() method:

  8. This method in the Material model already identifies where materials are used
  9. Can be extended to validate quantities against new orders

  10. Signal-based validation:

  11. Add Django signals to the Order or OrderItem models
  12. Trigger validation when new orders are created or modified
  13. Raise warnings or prevent creation when insufficient materials are detected

To implement this, I recommend adding: 1. A method to OrderItem that calculates required materials based on BOM 2. A validation function that compares requirements against available inventory 3. A notification mechanism that alerts users to insufficient quantities 4. An optional reservation system that tentatively allocates materials to orders

This would ensure that sales orders cannot be created or confirmed without sufficient materials available, or at minimum would warn users of potential shortages.