diff --git a/src/models/account.ts b/src/models/account.ts index 354ebc09..7c639be1 100644 --- a/src/models/account.ts +++ b/src/models/account.ts @@ -81,6 +81,43 @@ export class Account implements AccountInfoResponse { return !this.visible; } + public equals(other: Account): boolean { + const isEqual = this.id === other.id && + this.name === other.name && + this.parentId === other.parentId && + this.category === other.category && + this.type === other.type && + this.icon === other.icon && + this.color === other.color && + this.currency === other.currency && + this.balance === other.balance && + this.balanceTime === other.balanceTime && + this.comment === other.comment && + this.displayOrder === other.displayOrder && + this.visible === other.visible && + this.creditCardStatementDate === other.creditCardStatementDate; + + if (!isEqual) { + return false; + } + + if (this.subAccounts && other.subAccounts) { + if (this.subAccounts.length !== other.subAccounts.length) { + return false; + } + + for (let i = 0; i < this.subAccounts.length; i++) { + if (!this.subAccounts[i].equals(other.subAccounts[i])) { + return false; + } + } + } else if ((this.subAccounts && this.subAccounts.length) || (other.subAccounts && other.subAccounts.length)) { + return false; + } + + return true; + } + public fillFrom(other: Account): void { this.id = other.id; this.category = other.category; diff --git a/src/models/transaction_category.ts b/src/models/transaction_category.ts index 4df40135..5605a94d 100644 --- a/src/models/transaction_category.ts +++ b/src/models/transaction_category.ts @@ -37,6 +37,38 @@ export class TransactionCategory implements TransactionCategoryInfoResponse { return !this.visible; } + public equals(other: TransactionCategory): boolean { + const isEqual = this.id === other.id && + this.name === other.name && + this.parentId === other.parentId && + this.type === other.type && + this.icon === other.icon && + this.color === other.color && + this.comment === other.comment && + this.displayOrder === other.displayOrder && + this.visible === other.visible; + + if (!isEqual) { + return false; + } + + if (this.subCategories && other.subCategories) { + if (this.subCategories.length !== other.subCategories.length) { + return false; + } + + for (let i = 0; i < this.subCategories.length; i++) { + if (!this.subCategories[i].equals(other.subCategories[i])) { + return false; + } + } + } else if ((this.subCategories && this.subCategories.length) || (other.subCategories && other.subCategories.length)) { + return false; + } + + return true; + } + public fillFrom(other: TransactionCategory): void { this.id = other.id; this.name = other.name; diff --git a/src/views/desktop/accounts/ListPage.vue b/src/views/desktop/accounts/ListPage.vue index 6ae10811..b3e9b83d 100644 --- a/src/views/desktop/accounts/ListPage.vue +++ b/src/views/desktop/accounts/ListPage.vue @@ -248,7 +248,7 @@ - + diff --git a/src/views/desktop/accounts/list/dialogs/EditDialog.vue b/src/views/desktop/accounts/list/dialogs/EditDialog.vue index 6a277b5b..e03fa162 100644 --- a/src/views/desktop/accounts/list/dialogs/EditDialog.vue +++ b/src/views/desktop/accounts/list/dialogs/EditDialog.vue @@ -1,5 +1,5 @@