mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 07:27:33 +08:00
remove compatibility code for migration
This commit is contained in:
+33
-49
@@ -21,9 +21,9 @@ export class Account implements AccountInfoResponse {
|
||||
public isAsset?: boolean;
|
||||
public isLiability?: boolean;
|
||||
public visible: boolean;
|
||||
public childrenAccounts?: Account[];
|
||||
public subAccounts?: Account[];
|
||||
|
||||
protected constructor(id: string, name: string, parentId: string, category: number, type: number, icon: string, color: string, currency: string, balance: number, comment: string, displayOrder: number, visible: boolean, balanceTime?: number, creditCardStatementDate?: number, isAsset?: boolean, isLiability?: boolean, childrenAccounts?: Account[]) {
|
||||
protected constructor(id: string, name: string, parentId: string, category: number, type: number, icon: string, color: string, currency: string, balance: number, comment: string, displayOrder: number, visible: boolean, balanceTime?: number, creditCardStatementDate?: number, isAsset?: boolean, isLiability?: boolean, subAccounts?: Account[]) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.parentId = parentId;
|
||||
@@ -41,10 +41,10 @@ export class Account implements AccountInfoResponse {
|
||||
this.isAsset = isAsset;
|
||||
this.isLiability = isLiability;
|
||||
|
||||
if (typeof(childrenAccounts) !== 'undefined') {
|
||||
this.childrenAccounts = childrenAccounts;
|
||||
if (typeof(subAccounts) !== 'undefined') {
|
||||
this.subAccounts = subAccounts;
|
||||
} else {
|
||||
this.childrenAccounts = undefined;
|
||||
this.subAccounts = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,22 +52,6 @@ export class Account implements AccountInfoResponse {
|
||||
return !this.visible;
|
||||
}
|
||||
|
||||
public get subAccounts(): AccountInfoResponse[] | undefined {
|
||||
if (typeof(this.childrenAccounts) === 'undefined') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const ret: AccountInfoResponse[] = [];
|
||||
|
||||
if (this.childrenAccounts) {
|
||||
for (const subCategory of this.childrenAccounts) {
|
||||
ret.push(subCategory);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public from(other: Account): void {
|
||||
this.id = other.id;
|
||||
this.category = other.category;
|
||||
@@ -83,19 +67,19 @@ export class Account implements AccountInfoResponse {
|
||||
this.visible = other.visible;
|
||||
}
|
||||
|
||||
public toCreateRequest(clientSessionId: string, childrenAccounts?: Account[], parentAccount?: Account): AccountCreateRequest {
|
||||
let subAccounts: AccountCreateRequest[] | undefined = undefined;
|
||||
public toCreateRequest(clientSessionId: string, subAccounts?: Account[], parentAccount?: Account): AccountCreateRequest {
|
||||
let subAccountCreateRequests: AccountCreateRequest[] | undefined = undefined;
|
||||
|
||||
if (this.type === AccountType.MultiSubAccounts.type) {
|
||||
subAccounts = [];
|
||||
subAccountCreateRequests = [];
|
||||
|
||||
if (!childrenAccounts) {
|
||||
childrenAccounts = this.childrenAccounts;
|
||||
if (!subAccounts) {
|
||||
subAccounts = this.subAccounts;
|
||||
}
|
||||
|
||||
if (childrenAccounts) {
|
||||
for (const subAccount of childrenAccounts) {
|
||||
subAccounts.push(subAccount.toCreateRequest(clientSessionId, undefined, this));
|
||||
if (subAccounts) {
|
||||
for (const subAccount of subAccounts) {
|
||||
subAccountCreateRequests.push(subAccount.toCreateRequest(clientSessionId, undefined, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,24 +95,24 @@ export class Account implements AccountInfoResponse {
|
||||
balanceTime: (parentAccount || this.type === AccountType.SingleAccount.type) && this.balanceTime ? this.balanceTime : 0,
|
||||
comment: this.comment,
|
||||
creditCardStatementDate: !parentAccount && this.category === AccountCategory.CreditCard.type ? this.creditCardStatementDate : undefined,
|
||||
subAccounts: !parentAccount ? subAccounts : undefined,
|
||||
subAccounts: !parentAccount ? subAccountCreateRequests : undefined,
|
||||
clientSessionId: !parentAccount ? clientSessionId : undefined
|
||||
};
|
||||
}
|
||||
|
||||
public toModifyRequest(childrenAccounts?: Account[], parentAccount?: Account): AccountModifyRequest {
|
||||
let subAccounts: AccountModifyRequest[] | undefined = undefined;
|
||||
public toModifyRequest(subAccounts?: Account[], parentAccount?: Account): AccountModifyRequest {
|
||||
let subAccountModifyRequests: AccountModifyRequest[] | undefined = undefined;
|
||||
|
||||
if (this.type === AccountType.MultiSubAccounts.type) {
|
||||
subAccounts = [];
|
||||
subAccountModifyRequests = [];
|
||||
|
||||
if (!childrenAccounts) {
|
||||
childrenAccounts = this.childrenAccounts;
|
||||
if (!subAccounts) {
|
||||
subAccounts = this.subAccounts;
|
||||
}
|
||||
|
||||
if (childrenAccounts) {
|
||||
for (const subAccount of childrenAccounts) {
|
||||
subAccounts.push(subAccount.toModifyRequest(undefined, this));
|
||||
if (subAccounts) {
|
||||
for (const subAccount of subAccounts) {
|
||||
subAccountModifyRequests.push(subAccount.toModifyRequest(undefined, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,7 +126,7 @@ export class Account implements AccountInfoResponse {
|
||||
comment: this.comment,
|
||||
creditCardStatementDate: !parentAccount && this.category === AccountCategory.CreditCard.type ? this.creditCardStatementDate : undefined,
|
||||
hidden: !this.visible,
|
||||
subAccounts: !parentAccount ? subAccounts : undefined,
|
||||
subAccounts: !parentAccount ? subAccountModifyRequests : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -152,12 +136,12 @@ export class Account implements AccountInfoResponse {
|
||||
} else if (this.type === AccountType.MultiSubAccounts.type && !subAccountId) {
|
||||
return this.id;
|
||||
} else if (this.type === AccountType.MultiSubAccounts.type && subAccountId) {
|
||||
if (!this.childrenAccounts || !this.childrenAccounts.length) {
|
||||
if (!this.subAccounts || !this.subAccounts.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.childrenAccounts.length; i++) {
|
||||
const subAccount = this.childrenAccounts[i];
|
||||
for (let i = 0; i < this.subAccounts.length; i++) {
|
||||
const subAccount = this.subAccounts[i];
|
||||
|
||||
if (subAccountId && subAccountId === subAccount.id) {
|
||||
return subAccount.id;
|
||||
@@ -176,12 +160,12 @@ export class Account implements AccountInfoResponse {
|
||||
} else if (this.type === AccountType.MultiSubAccounts.type && !subAccountId) {
|
||||
return this.comment;
|
||||
} else if (this.type === AccountType.MultiSubAccounts.type && subAccountId) {
|
||||
if (!this.childrenAccounts || !this.childrenAccounts.length) {
|
||||
if (!this.subAccounts || !this.subAccounts.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.childrenAccounts.length; i++) {
|
||||
const subAccount = this.childrenAccounts[i];
|
||||
for (let i = 0; i < this.subAccounts.length; i++) {
|
||||
const subAccount = this.subAccounts[i];
|
||||
|
||||
if (subAccountId && subAccountId === subAccount.id) {
|
||||
return subAccount.comment;
|
||||
@@ -195,15 +179,15 @@ export class Account implements AccountInfoResponse {
|
||||
}
|
||||
|
||||
public getSubAccountCurrencies(showHidden: boolean, subAccountId: string): string[] {
|
||||
if (!this.childrenAccounts || !this.childrenAccounts.length) {
|
||||
if (!this.subAccounts || !this.subAccounts.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const subAccountCurrenciesMap: Record<string, boolean> = {};
|
||||
const subAccountCurrencies: string[] = [];
|
||||
|
||||
for (let i = 0; i < this.childrenAccounts.length; i++) {
|
||||
const subAccount = this.childrenAccounts[i];
|
||||
for (let i = 0; i < this.subAccounts.length; i++) {
|
||||
const subAccount = this.subAccounts[i];
|
||||
|
||||
if (!showHidden && subAccount.hidden) {
|
||||
continue;
|
||||
@@ -324,7 +308,7 @@ export class AccountWithDisplayBalance extends Account {
|
||||
Account.creditCardStatementDate,
|
||||
Account.isAsset,
|
||||
Account.isLiability,
|
||||
Account.childrenAccounts
|
||||
Account.subAccounts
|
||||
);
|
||||
|
||||
this.displayBalance = displayBalance;
|
||||
|
||||
@@ -675,32 +675,12 @@ export interface TransactionStatisticResponseItem {
|
||||
readonly amount: number;
|
||||
}
|
||||
|
||||
export interface TransactionStatisticResponseWithInfo {
|
||||
readonly startTime: number;
|
||||
readonly endTime: number;
|
||||
readonly items: TransactionStatisticResponseItemWithInfo[];
|
||||
}
|
||||
|
||||
export interface TransactionStatisticResponseItemWithInfo extends TransactionStatisticResponseItem {
|
||||
readonly account?: AccountInfoResponse;
|
||||
readonly primaryAccount?: AccountInfoResponse;
|
||||
readonly category?: TransactionCategoryInfoResponse;
|
||||
readonly primaryCategory?: TransactionCategoryInfoResponse;
|
||||
readonly amountInDefaultCurrency: number | null;
|
||||
}
|
||||
|
||||
export interface TransactionStatisticTrendsResponseItem {
|
||||
readonly year: number;
|
||||
readonly month: number;
|
||||
readonly items: TransactionStatisticResponseItem[];
|
||||
}
|
||||
|
||||
export interface TransactionStatisticTrendsResponseItemWithInfo {
|
||||
readonly year: number;
|
||||
readonly month: number;
|
||||
readonly items: TransactionStatisticResponseItemWithInfo[];
|
||||
}
|
||||
|
||||
export interface YearMonthDataItem extends YearMonth, Record<string, unknown> {}
|
||||
|
||||
export interface YearMonthItems<T extends YearMonth> extends Record<string, unknown> {
|
||||
|
||||
@@ -13,9 +13,9 @@ export class TransactionCategory implements TransactionCategoryInfoResponse {
|
||||
public comment: string;
|
||||
public displayOrder: number;
|
||||
public visible: boolean;
|
||||
public secondaryCategories?: TransactionCategory[];
|
||||
public subCategories?: TransactionCategory[];
|
||||
|
||||
private constructor(id: string, name: string, parentId: string, type: CategoryType, icon: string, color: ColorValue, comment: string, displayOrder: number, visible: boolean, secondaryCategories?: TransactionCategory[]) {
|
||||
private constructor(id: string, name: string, parentId: string, type: CategoryType, icon: string, color: ColorValue, comment: string, displayOrder: number, visible: boolean, subCategories?: TransactionCategory[]) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.parentId = parentId;
|
||||
@@ -26,10 +26,10 @@ export class TransactionCategory implements TransactionCategoryInfoResponse {
|
||||
this.displayOrder = displayOrder;
|
||||
this.visible = visible;
|
||||
|
||||
if (secondaryCategories) {
|
||||
this.secondaryCategories = secondaryCategories;
|
||||
} else if (!secondaryCategories && (!parentId || parentId === '0')) {
|
||||
this.secondaryCategories = [];
|
||||
if (subCategories) {
|
||||
this.subCategories = subCategories;
|
||||
} else if (!subCategories && (!parentId || parentId === '0')) {
|
||||
this.subCategories = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,22 +37,6 @@ export class TransactionCategory implements TransactionCategoryInfoResponse {
|
||||
return !this.visible;
|
||||
}
|
||||
|
||||
public get subCategories(): TransactionCategoryInfoResponse[] | undefined {
|
||||
if (typeof(this.secondaryCategories) === 'undefined') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const ret: TransactionCategoryInfoResponse[] = [];
|
||||
|
||||
if (this.secondaryCategories) {
|
||||
for (const subCategory of this.secondaryCategories) {
|
||||
ret.push(subCategory);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public from(other: TransactionCategory): void {
|
||||
this.id = other.id;
|
||||
this.name = other.name;
|
||||
|
||||
Reference in New Issue
Block a user