From 0bd262436ebfa149b80c886efb3a9f89c02266b4 Mon Sep 17 00:00:00 2001
From: Quique <917-quique@users.noreply.0xacab.org>
Date: Wed, 7 Oct 2020 12:58:47 +0200
Subject: [PATCH] typo: Ammount -> Amount

---
 api/order.go                 |  6 +++---
 api/order_test.go            |  6 +++---
 api/purchase.go              |  8 ++++----
 api/purchase_test.go         |  8 ++++----
 api/topup.go                 |  4 ++--
 api/topup_test.go            |  2 +-
 src/ProductPicker.js         | 16 ++++++++--------
 src/Topup.js                 |  8 ++++----
 src/purchase/Purchase.js     |  6 +++---
 src/purchase/ShowPurchase.js |  2 +-
 10 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/api/order.go b/api/order.go
index 64d7564..1c05d46 100644
--- a/api/order.go
+++ b/api/order.go
@@ -34,7 +34,7 @@ type OrderPurchase struct {
 	OrderID       uint     `json:"order_id"`
 	Order         *Order   `json:"-"`
 	Price         int      `json:"price"`
-	Ammount       int      `json:"ammount"`
+	Amount        int      `json:"amount"`
 }
 
 type OrderGetResponse struct {
@@ -65,7 +65,7 @@ func (a *api) deactivateOrders() {
 	for _, order := range orders {
 		total := 0
 		for _, purchase := range order.Purchases {
-			total += purchase.Price * purchase.Ammount
+			total += purchase.Price * purchase.Amount
 		}
 
 		transaction := Transaction{
@@ -228,7 +228,7 @@ func (a *api) AddOrderPurchase(num int, w http.ResponseWriter, req *http.Request
 		found := false
 		for _, product := range order.Products {
 			if product.Code == p.ProductCode {
-				total += product.Price * p.Ammount
+				total += product.Price * p.Amount
 				purchase[i].Price = product.Price
 				found = true
 				break
diff --git a/api/order_test.go b/api/order_test.go
index b11144a..0343838 100644
--- a/api/order_test.go
+++ b/api/order_test.go
@@ -78,7 +78,7 @@ func TestOrderPurchase(t *testing.T) {
 	purchase := []OrderPurchase{
 		{
 			ProductCode: testProduct.Code,
-			Ammount:     3,
+			Amount:      3,
 			OrderID:     orders[0].ID,
 		},
 	}
@@ -173,7 +173,7 @@ func TestOrderDeactivation(t *testing.T) {
 	purchase := []OrderPurchase{
 		{
 			ProductCode: testProduct.Code,
-			Ammount:     3,
+			Amount:      3,
 			OrderID:     orders[0].ID,
 		},
 	}
@@ -256,7 +256,7 @@ func TestGetOrder(t *testing.T) {
 	purchase := []OrderPurchase{
 		{
 			ProductCode: testProduct.Code,
-			Ammount:     3,
+			Amount:      3,
 			OrderID:     orders[0].ID,
 		},
 	}
diff --git a/api/purchase.go b/api/purchase.go
index aa4010c..235e85e 100644
--- a/api/purchase.go
+++ b/api/purchase.go
@@ -16,7 +16,7 @@ type Purchase struct {
 	ProductCode   int     `json:"code" gorm:"column:product"`
 	Product       Product `json:"product" gorm:"foreignKey:ProductCode;references:Code"`
 	Price         int     `json:"price"`
-	Ammount       int     `json:"ammount"`
+	Amount        int     `json:"amount"`
 }
 
 func (a *api) AddPurchase(num int, w http.ResponseWriter, req *http.Request) {
@@ -37,7 +37,7 @@ func (a *api) AddPurchase(num int, w http.ResponseWriter, req *http.Request) {
 			return
 		}
 
-		total += product.Price * p.Ammount
+		total += product.Price * p.Amount
 		purchase[i].Price = product.Price
 	}
 	if total == 0 {
@@ -63,10 +63,10 @@ func (a *api) AddPurchase(num int, w http.ResponseWriter, req *http.Request) {
 		for _, p := range purchase {
 			err := tx.Model(&Product{}).
 				Where("code = ?", p.ProductCode).
-				Update("stock", gorm.Expr("stock - ?", p.Ammount)).Error
+				Update("stock", gorm.Expr("stock - ?", p.Amount)).Error
 			if err != nil {
 				httpStatus = http.StatusInternalServerError
-				return fmt.Errorf("Can't update product stock %d-%d: %v", p.ProductCode, p.Ammount, err)
+				return fmt.Errorf("Can't update product stock %d-%d: %v", p.ProductCode, p.Amount, err)
 			}
 		}
 		return nil
diff --git a/api/purchase_test.go b/api/purchase_test.go
index 92a4a42..0ba1285 100644
--- a/api/purchase_test.go
+++ b/api/purchase_test.go
@@ -14,7 +14,7 @@ func TestPurchaseAddListMine(t *testing.T) {
 	products := []Purchase{
 		{
 			ProductCode: testProduct.Code,
-			Ammount:     5,
+			Amount:      5,
 		},
 	}
 	resp := tapi.do("POST", "/purchase", products, nil)
@@ -30,7 +30,7 @@ func TestPurchaseAddListMine(t *testing.T) {
 	if len(transactions) != 1 {
 		t.Fatal("Wrong number of transactions", len(transactions), transactions)
 	}
-	if transactions[0].Total != -testProduct.Price*products[0].Ammount {
+	if transactions[0].Total != -testProduct.Price*products[0].Amount {
 		t.Error("Wrong total:", transactions[0].Total)
 	}
 	if len(transactions[0].Purchase) != 1 {
@@ -48,7 +48,7 @@ func TestPurchaseAddListMine(t *testing.T) {
 	if resp.StatusCode != http.StatusOK {
 		t.Error("Can't find the product:", resp.Status)
 	}
-	if product.Stock != testProduct.Stock-products[0].Ammount {
+	if product.Stock != testProduct.Stock-products[0].Amount {
 		t.Error("Wrong product stock:", product)
 	}
 
@@ -57,7 +57,7 @@ func TestPurchaseAddListMine(t *testing.T) {
 	if resp.StatusCode != http.StatusOK {
 		t.Error("Can't find the member:", resp.Status)
 	}
-	if member.Balance != testMember.Balance-(testProduct.Price*products[0].Ammount) {
+	if member.Balance != testMember.Balance-(testProduct.Price*products[0].Amount) {
 		t.Error("Wrong product balance:", member.Balance)
 	}
 }
diff --git a/api/topup.go b/api/topup.go
index e4d9d44..7db5cb4 100644
--- a/api/topup.go
+++ b/api/topup.go
@@ -21,7 +21,7 @@ func (a *api) AddTopup(adminNum int, w http.ResponseWriter, req *http.Request) {
 	var topup struct {
 		Member  int    `json:"member"`
 		Comment string `json:"comment"`
-		Ammount int    `json:"ammount"`
+		Amount  int    `json:"amount"`
 	}
 	err := json.NewDecoder(req.Body).Decode(&topup)
 	if err != nil {
@@ -38,7 +38,7 @@ func (a *api) AddTopup(adminNum int, w http.ResponseWriter, req *http.Request) {
 			Comment:   topup.Comment,
 		},
 		Type:  "topup",
-		Total: topup.Ammount,
+		Total: topup.Amount,
 	}
 	httpStatus, err := createTransaction(a.db, &transaction)
 	if err != nil {
diff --git a/api/topup_test.go b/api/topup_test.go
index 1801df5..8394956 100644
--- a/api/topup_test.go
+++ b/api/topup_test.go
@@ -14,7 +14,7 @@ func TestTopupAddListMine(t *testing.T) {
 	topup := map[string]interface{}{
 		"member":  testMember.Num,
 		"comment": "my topup",
-		"ammount": 20,
+		"amount":  20,
 	}
 	resp := tapi.doAdmin("POST", "/topup", topup, nil)
 	if resp.StatusCode != http.StatusCreated {
diff --git a/src/ProductPicker.js b/src/ProductPicker.js
index e4fe1e7..1dd21e0 100644
--- a/src/ProductPicker.js
+++ b/src/ProductPicker.js
@@ -19,9 +19,9 @@ class ProductPicker extends React.Component {
         this.props.setPicks(picks);
     }
 
-    setAmmount(index, ammount) {
+    setAmount(index, amount) {
         let picks = this.props.picks;
-        picks[index].ammount = parseInt(ammount);
+        picks[index].amount = parseInt(amount);
         this.props.setPicks(picks);
     }
 
@@ -41,7 +41,7 @@ class ProductPicker extends React.Component {
             code: product.code,
             name: product.name,
             price: product.price,
-            ammount: 1
+            amount: 1
         });
         this.props.setPicks(picks);
         this.setState({ code: "" });
@@ -60,13 +60,13 @@ class ProductPicker extends React.Component {
                     <Col>
                         {printMoney(p.price)+"€"}
                     </Col>
-                    {this.props.ammount &&
+                    {this.props.amount &&
                     <Col>
                         <Form.Control
                             type="number" min="1"
                             placeholder="cantidad"
-                            value={p.ammount}
-                            onChange={e => this.setAmmount(i, e.target.value)}
+                            value={p.amount}
+                            onChange={e => this.setAmount(i, e.target.value)}
                         />
                     </Col>
                     }
@@ -89,7 +89,7 @@ class ProductPicker extends React.Component {
                     <Col>
                         <h6>Precio</h6>
                     </Col>
-                    {this.props.ammount &&
+                    {this.props.amount &&
                     <Col>
                         <h6>Cantidad</h6>
                     </Col>
@@ -116,7 +116,7 @@ class ProductPicker extends React.Component {
                         />
                     </Col>
                     <Col></Col>
-                    {this.props.ammount &&
+                    {this.props.amount &&
                     <Col></Col>
                     }
                     <Col sm={1}></Col>
diff --git a/src/Topup.js b/src/Topup.js
index ecf4fbc..0139ab3 100644
--- a/src/Topup.js
+++ b/src/Topup.js
@@ -13,7 +13,7 @@ class Topup extends React.Component {
         this.state = {
             members: [],
             numInvalid: false,
-            ammount: 0,
+            amount: 0,
             num: null,
             name: "",
             comment: "",
@@ -53,7 +53,7 @@ class Topup extends React.Component {
         const body = JSON.stringify({
             member: parseInt(this.state.num),
             comment: this.state.comment,
-            ammount: parseInt(this.state.ammount)*100
+            amount: parseInt(this.state.amount)*100
         });
         fetch("/api/topup", {headers: {'x-authentication': this.context.token}, method: "POST", body})
             .then(response => {
@@ -119,8 +119,8 @@ class Topup extends React.Component {
                             <Form.Control
                                 type="number"
                                 placeholder="euros"
-                                value={this.state.ammount}
-                                onChange={e => this.setState({ammount: e.target.value})}
+                                value={this.state.amount}
+                                onChange={e => this.setState({amount: e.target.value})}
                             />
                             <InputGroup.Append>
                                 <InputGroup.Text>.00 €</InputGroup.Text>
diff --git a/src/purchase/Purchase.js b/src/purchase/Purchase.js
index 115e254..0dac522 100644
--- a/src/purchase/Purchase.js
+++ b/src/purchase/Purchase.js
@@ -21,7 +21,7 @@ class Purchase extends React.Component {
     }
 
     setPurchase(purchase) {
-        const add = (acc, p) => acc + (p.price*p.ammount);
+        const add = (acc, p) => acc + (p.price*p.amount);
         const total = purchase.reduce(add, 0);
         this.setState({ purchase, total });
     }
@@ -31,7 +31,7 @@ class Purchase extends React.Component {
         const body = JSON.stringify(this.state.purchase.map(p => {
             return {
                 code: p.code,
-                ammount: p.ammount
+                amount: p.amount
             };
         }));
         fetch("/api/purchase", {headers: {'x-authentication': this.context.token}, method: "POST", body})
@@ -83,7 +83,7 @@ class Purchase extends React.Component {
         return (
             <Container>
                 {alert}
-                <ProductPicker ammount
+                <ProductPicker amount
                     picks={this.state.purchase}
                     setPicks={purchase => this.setPurchase(purchase)}
                 />
diff --git a/src/purchase/ShowPurchase.js b/src/purchase/ShowPurchase.js
index 93a8518..0a0da36 100644
--- a/src/purchase/ShowPurchase.js
+++ b/src/purchase/ShowPurchase.js
@@ -6,7 +6,7 @@ const columns = [
     {dataField: 'code', text: 'Codigo'},
     {dataField: 'product.name', text: 'Nombre'},
     {dataField: 'price', text: 'Precio', formatter: cell => printMoney(cell)+" €"},
-    {dataField: 'ammount', text: 'Cantidad'},
+    {dataField: 'amount', text: 'Cantidad'},
 ]
 
 function ShowPurchase(props) {
-- 
GitLab