@tomei/finance 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/account.d.ts +10 -10
- package/dist/account/account.js +9 -10
- package/dist/account/account.js.map +1 -1
- package/dist/account/account.repository.d.ts +16 -0
- package/dist/account/account.repository.js +46 -0
- package/dist/account/account.repository.js.map +1 -1
- package/dist/account/entities/account.entity.d.ts +0 -4
- package/dist/account/entities/account.entity.js +2 -8
- package/dist/account/entities/account.entity.js.map +1 -1
- package/dist/account/index.d.ts +3 -2
- package/dist/account/index.js +3 -1
- package/dist/account/index.js.map +1 -1
- package/dist/account/interfaces/account-attr.interface.d.ts +1 -6
- package/dist/account/interfaces/account.repository.interface.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/account/account.repository.ts +38 -38
- package/src/account/account.ts +18 -23
- package/src/account/entities/account.entity.ts +1 -11
- package/src/account/index.ts +2 -4
- package/src/account/interfaces/account-attr.interface.ts +1 -7
- package/src/account/interfaces/account.repository.interface.ts +1 -1
- /package/src/base/{repository/base.repository.abstract.ts → base.repository.abstract.ts} +0 -0
- /package/src/base/{repository/base.repository.interface.ts → base.repository.interface.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/sequelize';
|
|
3
|
+
import { BaseRepository } from 'src/base/base.repository.abstract';
|
|
4
|
+
import { AccountModel } from './entities/account.entity';
|
|
5
|
+
import {
|
|
6
|
+
IAccountAttr,
|
|
7
|
+
ICreateAccountAttr,
|
|
8
|
+
} from './interfaces/account-attr.interface';
|
|
9
|
+
import { IAccountRepository } from './interfaces/account.repository.interface';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class AccountRepository
|
|
13
|
+
extends BaseRepository<AccountModel>
|
|
14
|
+
implements IAccountRepository
|
|
15
|
+
{
|
|
16
|
+
constructor(
|
|
17
|
+
@InjectModel(AccountModel)
|
|
18
|
+
private readonly accountModel: typeof AccountModel,
|
|
19
|
+
) {
|
|
20
|
+
super(accountModel);
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
create(data: ICreateAccountAttr, options?: any): Promise<AccountModel> | any {
|
|
24
|
+
return this.accountModel.create({ ...data }, options);
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
findAll(options: any): Promise<AccountModel[]> {
|
|
28
|
+
return this.accountModel.findAll(options);
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
findAllWithPagination(
|
|
32
|
+
options: any,
|
|
33
|
+
): Promise<{ count: number; rows: AccountModel[] }> {
|
|
34
|
+
return this.accountModel.findAndCountAll(options);
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
findOne(options: any): Promise<AccountModel> {
|
|
38
|
+
return this.accountModel.findOne(options);
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
update(data: IAccountAttr, options?: any): any {
|
|
42
|
+
return this.accountModel.update({ ...data }, options);
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/account/account.ts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { ObjectBase, OwnerBase } from 'src/base';
|
|
2
|
-
import {
|
|
3
|
-
IAccountOptions,
|
|
4
|
-
ICreateAccountAttr,
|
|
5
|
-
} from './interfaces/account-attr.interface';
|
|
2
|
+
import { ICreateAccountAttr } from './interfaces/account-attr.interface';
|
|
6
3
|
import { IAccountRepository } from './interfaces/account.repository.interface';
|
|
7
|
-
import
|
|
4
|
+
import { QuickBookClient } from 'src/quickbook-client';
|
|
8
5
|
export class Account {
|
|
9
6
|
accountRepository: IAccountRepository;
|
|
10
7
|
intuitClient: any;
|
|
11
8
|
|
|
12
|
-
OwnerId: string;
|
|
13
|
-
OwnerType: string;
|
|
14
|
-
RelatedObjectId: string;
|
|
15
|
-
RelatedObjectType: string;
|
|
16
|
-
AccSystemId: string;
|
|
17
|
-
parentAccount: Account;
|
|
9
|
+
private OwnerId: string;
|
|
10
|
+
private OwnerType: string;
|
|
11
|
+
private RelatedObjectId: string;
|
|
12
|
+
private RelatedObjectType: string;
|
|
13
|
+
private AccSystemId: string;
|
|
18
14
|
|
|
15
|
+
parentAccountNo: string;
|
|
19
16
|
Owner: OwnerBase;
|
|
20
17
|
RelatedObject: ObjectBase;
|
|
21
18
|
|
|
@@ -26,18 +23,12 @@ export class Account {
|
|
|
26
23
|
constructor(
|
|
27
24
|
accountRepository: IAccountRepository,
|
|
28
25
|
SysCode: string,
|
|
29
|
-
|
|
26
|
+
params?: ICreateAccountAttr,
|
|
30
27
|
) {
|
|
31
28
|
this.accountRepository = accountRepository;
|
|
32
29
|
this.AccSystemId = SysCode;
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
this.init(options.params);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (options.account) {
|
|
39
|
-
this.parentAccount = options.account;
|
|
40
|
-
}
|
|
30
|
+
if (params) {
|
|
31
|
+
this.init(params);
|
|
41
32
|
}
|
|
42
33
|
}
|
|
43
34
|
|
|
@@ -69,13 +60,16 @@ export class Account {
|
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
this.OwnerId = params.Owner.Id;
|
|
72
|
-
this.OwnerType =
|
|
63
|
+
this.OwnerType = typeof this.Owner;
|
|
73
64
|
this.RelatedObjectId = params.RelatedObject.Id;
|
|
74
|
-
this.RelatedObjectType =
|
|
65
|
+
this.RelatedObjectType = typeof this.RelatedObject;
|
|
66
|
+
if (params.ParentAccountNo) {
|
|
67
|
+
this.parentAccountNo = params.ParentAccountNo;
|
|
68
|
+
}
|
|
75
69
|
this.isParamsInitialized = true;
|
|
76
70
|
}
|
|
77
71
|
|
|
78
|
-
async create(client:
|
|
72
|
+
async create(client: QuickBookClient, dbOptions: any) {
|
|
79
73
|
if (!this.Owner || !this.RelatedObject) {
|
|
80
74
|
throw new Error(
|
|
81
75
|
'Owner must be set before creating an account." or "RelatedObject must be set before creating an account.',
|
|
@@ -93,6 +87,7 @@ export class Account {
|
|
|
93
87
|
Owner: this.Owner,
|
|
94
88
|
RelatedObject: this.RelatedObject,
|
|
95
89
|
Client: client,
|
|
90
|
+
ParentAccountNo: this.parentAccountNo,
|
|
96
91
|
},
|
|
97
92
|
dbOptions,
|
|
98
93
|
);
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
UpdatedAt,
|
|
9
9
|
BeforeValidate,
|
|
10
10
|
} from 'sequelize-typescript';
|
|
11
|
-
import { IObject, IOwner } from 'src/base';
|
|
12
11
|
|
|
13
12
|
@Table({ tableName: 'finance_Account', createdAt: false, updatedAt: false })
|
|
14
13
|
export class AccountModel extends Model {
|
|
@@ -104,15 +103,6 @@ export class AccountModel extends Model {
|
|
|
104
103
|
|
|
105
104
|
@BeforeValidate
|
|
106
105
|
static beforeValidateProcess(instance: any) {
|
|
107
|
-
console.log(instance
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
Owner: IOwner;
|
|
111
|
-
RelatedObject: IObject;
|
|
112
|
-
|
|
113
|
-
constructor(Owner: IOwner, RelatedObject: IObject) {
|
|
114
|
-
super();
|
|
115
|
-
this.Owner = Owner;
|
|
116
|
-
this.RelatedObject = RelatedObject;
|
|
106
|
+
console.log(instance, '<<<<<<<');
|
|
117
107
|
}
|
|
118
108
|
}
|
package/src/account/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AccountModel } from './entities/account.entity';
|
|
2
2
|
import { Account } from './account';
|
|
3
|
-
|
|
3
|
+
import { AccountRepository } from './account.repository';
|
|
4
4
|
import {
|
|
5
|
-
IAccountOptions,
|
|
6
5
|
IAccountAttr,
|
|
7
6
|
ICreateAccountAttr,
|
|
8
7
|
} from './interfaces/account-attr.interface';
|
|
@@ -11,8 +10,7 @@ import { IAccountRepository } from './interfaces/account.repository.interface';
|
|
|
11
10
|
export {
|
|
12
11
|
AccountModel,
|
|
13
12
|
Account,
|
|
14
|
-
|
|
15
|
-
IAccountOptions,
|
|
13
|
+
AccountRepository,
|
|
16
14
|
IAccountAttr,
|
|
17
15
|
ICreateAccountAttr,
|
|
18
16
|
IAccountRepository,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ObjectBase, OwnerBase } from 'src/base';
|
|
2
|
-
import { Account } from '../account';
|
|
3
2
|
|
|
4
3
|
export interface IAccountAttr {
|
|
5
4
|
AccountNo: string;
|
|
@@ -18,11 +17,6 @@ export interface IAccountAttr {
|
|
|
18
17
|
export interface ICreateAccountAttr {
|
|
19
18
|
Owner: OwnerBase;
|
|
20
19
|
RelatedObject: ObjectBase;
|
|
21
|
-
AccSystemId: string;
|
|
22
20
|
Client?: any;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export interface IAccountOptions {
|
|
26
|
-
params?: ICreateAccountAttr;
|
|
27
|
-
account?: Account;
|
|
21
|
+
ParentAccountNo?: string;
|
|
28
22
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBaseRepository } from 'src/base/
|
|
1
|
+
import { IBaseRepository } from 'src/base/base.repository.interface';
|
|
2
2
|
import { AccountModel } from '../entities/account.entity';
|
|
3
3
|
|
|
4
4
|
export type IAccountRepository = IBaseRepository<AccountModel>;
|
|
File without changes
|
|
File without changes
|