Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add InventorySupplyTree #57

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading