Lee Morgan 11 месяцев назад
Родитель
Сommit
dcf6924944
2 измененных файлов с 17 добавлено и 5 удалено
  1. 2 5
      src/views/js/data/Account.js
  2. 15 0
      src/views/js/data/Income.js

+ 2 - 5
src/views/js/data/Account.js

@@ -2,6 +2,7 @@ import EncryptionHandler from "../EncryptionHandler.js";
 import Notifier from "../Notifier.js";
 import Format from "../Format.js";
 import Transaction from "./Transaction.js";
+import Income from "./Income.js";
 
 export default class Account{
     constructor(id, iv, data){
@@ -64,11 +65,7 @@ export default class Account{
     }
 
     async addIncome(name, amount){
-        this._income.push({
-            id: crypto.randomUUID(),
-            name: name,
-            amount: this.toCents(amount)
-        });
+        this._income.push(Income.create(name, this.toCents(amount)));
 
         await this.save();
     }

+ 15 - 0
src/views/js/data/Income.js

@@ -0,0 +1,15 @@
+export default class Income{
+    constructor(id, name, amount){
+        this._id = id;
+        this._name = name;
+        this._amount = amount;
+    }
+
+    static create(name, amount){
+        return new Income(
+            crypto.randomUUID(),
+            name,
+            amount
+        );
+    }
+}