Changeset - 6fa39f685829
[Not reviewed]
default
0 1 0
Dennis Fink - 3 years ago 2022-02-28 19:00:33
dennis.fink@c3l.lu
Fix stock_amount not being an integer
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
stockcli/stock.py
Show inline comments
 
@@ -39,49 +39,49 @@ def get_info_by_barcode(barcode: str) ->
 
        )
 

	
 
    purchase_quantity_unit = product["default_quantity_unit_purchase"]
 
    stock_quantity_unit = product["quantity_unit_stock"]
 

	
 
    purchase_to_stock_conversion = utils.get_request(
 
        f"objects/quantity_unit_conversions?query[]=from_qu_id={purchase_quantity_unit['id']}&query[]=to_qu_id={stock_quantity_unit['id']}"
 
    )  # type: list[dict[str, Any]]
 

	
 
    if len(purchase_to_stock_conversion) != 0:
 
        conversion = f"{purchase_to_stock_conversion[0]['factor']} {stock_quantity_unit['name_plural']}"
 
    else:
 
        conversion = ""
 

	
 
    grid.add_row(
 
        GreenBoldText("Purchase Quantity Unit:"),
 
        purchase_quantity_unit["name"],
 
        conversion,
 
    )
 
    grid.add_row(
 
        GreenBoldText("Stock Quantity Unit:"),
 
        stock_quantity_unit["name"],
 
    )
 

	
 
    stock_amount = product["stock_amount"]
 
    stock_amount = int(product["stock_amount"])
 
    grid.add_row(GreenBoldText("Overall Stock Amount:"), str(stock_amount))
 

	
 
    if stock_amount > 0:
 
        grid.add_row(GreenBoldText("Locations:"))
 
        locations = utils.get_request(
 
            f"stock/products/{product_id}/locations"
 
        )  # type: list[dict[str, Any]]
 

	
 
        for location in sorted(locations, key=itemgetter("location_name")):
 
            grid.add_row(
 
                f"[green bold]-[/green bold] [magenta]{location['location_name']}[/magenta]",
 
                location["amount"],
 
            )
 

	
 
    console.print(Panel(grid, title="[green bold]Product Info[/green bold]"))
 

	
 
    return
 

	
 

	
 
def transfer_by_barcode(barcode: str) -> None:
 

	
 
    product = utils.get_request(
 
        f"stock/products/by-barcode/{barcode}"
 
    )  # type: dict[str, Any]
0 comments (0 inline, 0 general)