Changeset - 2fddb86c05a9
[Not reviewed]
default
0 1 0
Dennis Fink - 2 years ago 2022-03-01 10:48:26
dennis.fink@c3l.lu
Specifiy in prompts that 0 can be used to abort
1 file changed with 12 insertions and 5 deletions:
0 comments (0 inline, 0 general)
stockcli/stock.py
Show inline comments
 
@@ -121,13 +121,13 @@ def transfer_by_barcode(barcode: str) ->
 
            title="[green bold]Product Info[/green bold]",
 
            subtitle="[blue]Transfer stock[/blue]",
 
        )
 
    )
 

	
 
    from_id = int_prompt.ask(
 
        "From",
 
        "From (Enter 0 to abort)",
 
        choices=choices,
 
        default=int(choices[0]),
 
    )
 

	
 
    if not from_id:
 
        return
 
@@ -150,21 +150,21 @@ def transfer_by_barcode(barcode: str) ->
 
            title="[green bold]Locations[/green bold]",
 
            subtitle="[blue]Transfer Stock[/blue]",
 
        )
 
    )
 

	
 
    to_id = int_prompt.ask(
 
        "To",
 
        "To (Enter 0 to abort)",
 
        choices=choices,
 
        default=int(choices[0]),
 
    )
 

	
 
    if not to_id:
 
        return
 

	
 
    amount = int_prompt.ask("Amount")
 
    amount = int_prompt.ask("Amount (Enter 0 to abort)")
 

	
 
    if not amount:
 
        return
 

	
 
    data = {"amount": amount, "location_id_from": from_id, "location_id_to": to_id}
 

	
 
@@ -194,13 +194,17 @@ def add_by_barcode(barcode: str) -> None
 
            grid,
 
            title="[green bold]Product Info[/green bold]",
 
            subtitle="[blue]Add Stock[/blue]",
 
        )
 
    )
 

	
 
    amount = int_prompt.ask("Amount")
 
    amount = int_prompt.ask("Amount (Enter 0 to abort)")
 

	
 
    if not amount:
 
        return
 

	
 
    data = {"amount": amount, "transaction_type": "purchase"}
 

	
 
    response = utils.post_request(
 
        f"stock/products/by-barcode/{barcode}/add", data
 
    )  # type: dict[str, Any]
 
    console.print("Successfully added!")
 
@@ -228,13 +232,16 @@ def update_by_barcode(barcode: str) -> N
 
        Panel(
 
            grid,
 
            title="[green bold]Product Info[/green bold]",
 
            subtitle="[blue]Update stock[/blue]",
 
        )
 
    )
 
    amount = prompt.ask("Amount")
 
    amount = int_prompt.ask("Amount (Enter 0 to abort)")
 

	
 
    if not amount:
 
        return
 

	
 
    data = {
 
        "new_amount": amount,
 
    }
 

	
 
    response = utils.post_request(
0 comments (0 inline, 0 general)