Skip to content

Commit

Permalink
add InventorySupplyTree (#57)
Browse files Browse the repository at this point in the history
Fixes #54

Co-authored-by: Harry Pierson <[email protected]>
  • Loading branch information
devhawk and Harry Pierson authored Oct 17, 2023
1 parent 0c51239 commit 83591fa
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,26 @@ def forJson(self):
"party": self.supplier.name,
}

class InventorySupplyTree(NamedTuple):
product: SupplyAtom
maker: OkwParty

def getProduct(self):
return self.product

def print(self, indent: int):
buffer = " " * indent
print(
buffer
+ "Maker Inventory: {}/{}".format(self.supplier.name, self.product.description)
)

def forJson(self):
return {
"product": self.product.forJson(),
"type": "inventory",
# "party": self.maker.name,
}

class MadeSupplyTree(NamedTuple):
product: SupplyAtom
Expand Down Expand Up @@ -223,7 +243,7 @@ def query(self, product: SupplyAtom) -> Generator[SupplyTree, None, None]:
# find a supply tree for each bom in the design
for bom in design.bom:
if bom in maker.inventory:
supplies.append(SuppliedSupplyTree(bom, maker))
supplies.append(InventorySupplyTree(bom, maker))
else:
for tree in self.query(bom):
supplies.append(tree)
Expand Down

0 comments on commit 83591fa

Please sign in to comment.