Explorar o código

Bug fixes. Ensure that income amounts working properly everywhere.

Lee Morgan hai 11 meses
pai
achega
d64427e956

+ 1 - 1
src/views/js/data/Account.js

@@ -136,7 +136,7 @@ export default class Account{
     }
 
     async addIncome(name, amount){
-        this._income.push(Income.create(name, Format.dollarsToCents(amount)));
+        this._income.push(Income.create(name, amount));
 
         await this.save();
     }

+ 1 - 3
src/views/js/data/Income.js

@@ -1,5 +1,3 @@
-import Format from "../Format.js";
-
 export default class Income{
     constructor(id, name, amount, active){
         this._id = id;
@@ -26,7 +24,7 @@ export default class Income{
 
     set amount(v){
         if(typeof v === String) v = Number(v);
-        this._amount = Format.dollarsToCents(v);
+        this._amount = v;
     }
 
     get type(){

+ 2 - 1
src/views/js/pages/CreateIncome.js

@@ -1,5 +1,6 @@
 import Page from "./Page.js";
 import Elem from "../Elem.js";
+import Format from "../Format.js";
 
 export default class CreateIncome extends Page{
     constructor(){
@@ -13,7 +14,7 @@ export default class CreateIncome extends Page{
 
         await user.account.addIncome(
             this.container.querySelector(".name").value,
-            this.container.querySelector(".amount").value
+            Format.dollarsToCents(this.container.querySelector(".amount").value)
         );
         changePage("home");
     }

+ 1 - 1
src/views/js/pages/EditIncome.js

@@ -13,7 +13,7 @@ export default class EditIncome extends Page{
         event.preventDefault();
 
         income.name = this.container.querySelector(".name").value;
-        income.amount = this.container.querySelector(".amount").value;
+        income.amount = Format.dollarsToCents(this.container.querySelector(".amount").value);
 
         user.account.save();
         changePage("viewIncome");