Skip to content
Snippets Groups Projects
Commit 7b61e336 authored by BEAUVAIS ANTOINE's avatar BEAUVAIS ANTOINE
Browse files

Added quantity to transactions.

parent 210caacf
Branches
1 merge request!1Merge 'develop' changes into 'master'.
......@@ -60,8 +60,7 @@ public class ApiSubmitTransactionController
if(t == null)
throw new ApiBadRequestException("Missing JSON body.");
if(t.getItem() == null || t.getType() == null ||
t.getAmount() == null)
if(!t.checkIfValid())
throw new ApiBadRequestException("Invalid JSON schema.");
System.out.println("Transaction : " + t.getItem() +
......
......@@ -18,11 +18,15 @@ public class Transaction {
private final BigDecimal amount;
public Transaction(Integer item, Integer type, BigDecimal amount)
private final Integer quantity;
public Transaction(Integer item, Integer type, BigDecimal amount,
Integer quantity)
{
this.item = item;
this.type = type;
this.amount = amount;
this.quantity = quantity;
}
public Integer getItem()
......@@ -40,4 +44,15 @@ public class Transaction {
return this.amount;
}
public Integer getQuantity()
{
return this.quantity;
}
public boolean checkIfValid()
{
return (this.item != null && this.type != null
&& this.amount != null && this.quantity != null);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment