| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import Format from "../Format.js";
- export default class Income{
- constructor(id, name, amount, active){
- this._id = id;
- this._name = name;
- this._amount = amount;
- this._active = active;
- }
- get id(){
- return this._id;
- }
- get name(){
- return this._name;
- }
- get amount(){
- return Format.centsToDollars(this._amount);
- }
- get type(){
- return "Income";
- }
- get active(){
- return this._active;
- }
- static create(name, amount){
- return new Income(
- crypto.randomUUID(),
- name,
- amount,
- true
- );
- }
- static fromObject(data){
- return new Income(
- data.id,
- data.name,
- data.amount,
- data.active
- );
- }
- serialize(){
- return {
- id: this._id,
- name: this._name,
- amount: this._amount,
- active: this._active
- };
- }
- }
|