@tomei/finance 0.2.2 → 0.2.4
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 +1 -2
- package/dist/account/account.js +28 -23
- package/dist/account/account.js.map +1 -1
- package/dist/interfaces/account-system-entity.interface.d.ts +7 -0
- package/dist/interfaces/account-system-entity.interface.js +3 -0
- package/dist/interfaces/account-system-entity.interface.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/finance-customer-migration.js +33 -33
- package/migrations/finance-payment-migration.js +89 -89
- package/package.json +1 -1
- package/src/account/account.repository.ts +44 -44
- package/src/account/account.ts +30 -25
- package/src/account/interfaces/account.repository.interface.ts +4 -4
- package/src/config.ts +178 -178
- package/src/customer/entities/customer.entity.ts +53 -53
- package/src/customer/finance-customer.repository.ts +20 -20
- package/src/customer/index.ts +15 -15
- package/src/customer/interfaces/customer.repository.interface.ts +3 -3
- package/src/customer/interfaces/finance-customer-attr.interface.ts +4 -4
- package/src/customer/interfaces/finance-customer.repository.interface.ts +3 -3
- package/src/interfaces/account-system-entity.interface.ts +7 -0
- package/src/interfaces/index.ts +3 -3
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
async up(queryInterface, Sequelize) {
|
|
5
|
-
await queryInterface.createTable('finance_Customer', {
|
|
6
|
-
CustomerId: {
|
|
7
|
-
type: Sequelize.STRING(30),
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
allowNull: false,
|
|
10
|
-
},
|
|
11
|
-
SystemCode: {
|
|
12
|
-
type: Sequelize.STRING(30),
|
|
13
|
-
allowNull: false,
|
|
14
|
-
},
|
|
15
|
-
AccSystemCode: {
|
|
16
|
-
type: Sequelize.STRING(30),
|
|
17
|
-
allowNull: false,
|
|
18
|
-
},
|
|
19
|
-
AccSystemCustomerId: {
|
|
20
|
-
type: Sequelize.STRING(30),
|
|
21
|
-
allowNull: false,
|
|
22
|
-
},
|
|
23
|
-
CustomerRefId: {
|
|
24
|
-
type: Sequelize.STRING(30),
|
|
25
|
-
allowNull: false,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
async down(queryInterface) {
|
|
31
|
-
await queryInterface.dropTable('finance_Customer');
|
|
32
|
-
},
|
|
33
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
await queryInterface.createTable('finance_Customer', {
|
|
6
|
+
CustomerId: {
|
|
7
|
+
type: Sequelize.STRING(30),
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
},
|
|
11
|
+
SystemCode: {
|
|
12
|
+
type: Sequelize.STRING(30),
|
|
13
|
+
allowNull: false,
|
|
14
|
+
},
|
|
15
|
+
AccSystemCode: {
|
|
16
|
+
type: Sequelize.STRING(30),
|
|
17
|
+
allowNull: false,
|
|
18
|
+
},
|
|
19
|
+
AccSystemCustomerId: {
|
|
20
|
+
type: Sequelize.STRING(30),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
CustomerRefId: {
|
|
24
|
+
type: Sequelize.STRING(30),
|
|
25
|
+
allowNull: false,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
async down(queryInterface) {
|
|
31
|
+
await queryInterface.dropTable('finance_Customer');
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
async up(queryInterface, Sequelize) {
|
|
5
|
-
await queryInterface.createTable('finance_Payment', {
|
|
6
|
-
PaymentId: {
|
|
7
|
-
type: Sequelize.STRING(30),
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
allowNull: false,
|
|
10
|
-
},
|
|
11
|
-
AccountNo: {
|
|
12
|
-
type: Sequelize.STRING(30),
|
|
13
|
-
allowNull: false,
|
|
14
|
-
references: {
|
|
15
|
-
model: 'finance_Account',
|
|
16
|
-
key: 'AccountNo',
|
|
17
|
-
},
|
|
18
|
-
onUpdate: 'CASCADE',
|
|
19
|
-
onDelete: 'CASCADE',
|
|
20
|
-
},
|
|
21
|
-
PaymentType: {
|
|
22
|
-
type: Sequelize.ENUM(['Payment Received', 'Payout']),
|
|
23
|
-
defaultValue: 'Payment Received',
|
|
24
|
-
allowNull: false,
|
|
25
|
-
},
|
|
26
|
-
PaymentDate: {
|
|
27
|
-
type: Sequelize.DATE,
|
|
28
|
-
allowNull: false,
|
|
29
|
-
},
|
|
30
|
-
Currency: {
|
|
31
|
-
type: Sequelize.CHAR(3),
|
|
32
|
-
allowNull: false,
|
|
33
|
-
},
|
|
34
|
-
Amount: {
|
|
35
|
-
type: Sequelize.DECIMAL(10, 2),
|
|
36
|
-
allowNull: false,
|
|
37
|
-
},
|
|
38
|
-
Status: {
|
|
39
|
-
type: Sequelize.STRING(20),
|
|
40
|
-
allowNull: false,
|
|
41
|
-
},
|
|
42
|
-
Method: {
|
|
43
|
-
type: Sequelize.STRING,
|
|
44
|
-
allowNull: false,
|
|
45
|
-
},
|
|
46
|
-
MethodParty: {
|
|
47
|
-
type: Sequelize.STRING(255),
|
|
48
|
-
allowNull: false,
|
|
49
|
-
},
|
|
50
|
-
MethodAccountName: {
|
|
51
|
-
type: Sequelize.STRING(100),
|
|
52
|
-
allowNull: true,
|
|
53
|
-
},
|
|
54
|
-
MethodAccountNo: {
|
|
55
|
-
type: Sequelize.STRING(100),
|
|
56
|
-
allowNull: true,
|
|
57
|
-
},
|
|
58
|
-
TransactionId: {
|
|
59
|
-
type: Sequelize.STRING(100),
|
|
60
|
-
allowNull: true,
|
|
61
|
-
},
|
|
62
|
-
ApprovalId: {
|
|
63
|
-
type: Sequelize.STRING(100),
|
|
64
|
-
allowNull: true,
|
|
65
|
-
},
|
|
66
|
-
ReceivedBy: {
|
|
67
|
-
type: Sequelize.STRING(30),
|
|
68
|
-
allowNull: false,
|
|
69
|
-
},
|
|
70
|
-
UpdatedAt: {
|
|
71
|
-
allowNull: false,
|
|
72
|
-
defaultValue: new Date(),
|
|
73
|
-
type: Sequelize.DATE,
|
|
74
|
-
},
|
|
75
|
-
UpdatedBy: {
|
|
76
|
-
allowNull: false,
|
|
77
|
-
type: Sequelize.STRING,
|
|
78
|
-
},
|
|
79
|
-
Remarks: {
|
|
80
|
-
type: Sequelize.TEXT,
|
|
81
|
-
allowNull: true,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
async down(queryInterface) {
|
|
87
|
-
await queryInterface.dropTable('finance_Payment');
|
|
88
|
-
},
|
|
89
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface, Sequelize) {
|
|
5
|
+
await queryInterface.createTable('finance_Payment', {
|
|
6
|
+
PaymentId: {
|
|
7
|
+
type: Sequelize.STRING(30),
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
},
|
|
11
|
+
AccountNo: {
|
|
12
|
+
type: Sequelize.STRING(30),
|
|
13
|
+
allowNull: false,
|
|
14
|
+
references: {
|
|
15
|
+
model: 'finance_Account',
|
|
16
|
+
key: 'AccountNo',
|
|
17
|
+
},
|
|
18
|
+
onUpdate: 'CASCADE',
|
|
19
|
+
onDelete: 'CASCADE',
|
|
20
|
+
},
|
|
21
|
+
PaymentType: {
|
|
22
|
+
type: Sequelize.ENUM(['Payment Received', 'Payout']),
|
|
23
|
+
defaultValue: 'Payment Received',
|
|
24
|
+
allowNull: false,
|
|
25
|
+
},
|
|
26
|
+
PaymentDate: {
|
|
27
|
+
type: Sequelize.DATE,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
},
|
|
30
|
+
Currency: {
|
|
31
|
+
type: Sequelize.CHAR(3),
|
|
32
|
+
allowNull: false,
|
|
33
|
+
},
|
|
34
|
+
Amount: {
|
|
35
|
+
type: Sequelize.DECIMAL(10, 2),
|
|
36
|
+
allowNull: false,
|
|
37
|
+
},
|
|
38
|
+
Status: {
|
|
39
|
+
type: Sequelize.STRING(20),
|
|
40
|
+
allowNull: false,
|
|
41
|
+
},
|
|
42
|
+
Method: {
|
|
43
|
+
type: Sequelize.STRING,
|
|
44
|
+
allowNull: false,
|
|
45
|
+
},
|
|
46
|
+
MethodParty: {
|
|
47
|
+
type: Sequelize.STRING(255),
|
|
48
|
+
allowNull: false,
|
|
49
|
+
},
|
|
50
|
+
MethodAccountName: {
|
|
51
|
+
type: Sequelize.STRING(100),
|
|
52
|
+
allowNull: true,
|
|
53
|
+
},
|
|
54
|
+
MethodAccountNo: {
|
|
55
|
+
type: Sequelize.STRING(100),
|
|
56
|
+
allowNull: true,
|
|
57
|
+
},
|
|
58
|
+
TransactionId: {
|
|
59
|
+
type: Sequelize.STRING(100),
|
|
60
|
+
allowNull: true,
|
|
61
|
+
},
|
|
62
|
+
ApprovalId: {
|
|
63
|
+
type: Sequelize.STRING(100),
|
|
64
|
+
allowNull: true,
|
|
65
|
+
},
|
|
66
|
+
ReceivedBy: {
|
|
67
|
+
type: Sequelize.STRING(30),
|
|
68
|
+
allowNull: false,
|
|
69
|
+
},
|
|
70
|
+
UpdatedAt: {
|
|
71
|
+
allowNull: false,
|
|
72
|
+
defaultValue: new Date(),
|
|
73
|
+
type: Sequelize.DATE,
|
|
74
|
+
},
|
|
75
|
+
UpdatedBy: {
|
|
76
|
+
allowNull: false,
|
|
77
|
+
type: Sequelize.STRING,
|
|
78
|
+
},
|
|
79
|
+
Remarks: {
|
|
80
|
+
type: Sequelize.TEXT,
|
|
81
|
+
allowNull: true,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
async down(queryInterface) {
|
|
87
|
+
await queryInterface.dropTable('finance_Payment');
|
|
88
|
+
},
|
|
89
|
+
};
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/sequelize';
|
|
3
|
-
import { AccountModel } from './entities/account.entity';
|
|
4
|
-
import { BaseRepository } from '@tomei/general';
|
|
5
|
-
import {
|
|
6
|
-
IAccountAttr,
|
|
7
|
-
ICreateAccountAttr,
|
|
8
|
-
} from './interfaces/account-attr.interface';
|
|
9
|
-
import { IAccountRepository } from './interfaces/account.repository.interface';
|
|
10
|
-
|
|
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
|
-
|
|
23
|
-
create(data: ICreateAccountAttr, options?: any): Promise<AccountModel> | any {
|
|
24
|
-
return this.accountModel.create({ ...data }, options);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
findAll(options: any): Promise<AccountModel[]> {
|
|
28
|
-
return this.accountModel.findAll(options);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
findAllWithPagination(
|
|
32
|
-
options: any,
|
|
33
|
-
): Promise<{ count: number; rows: AccountModel[] }> {
|
|
34
|
-
return this.accountModel.findAndCountAll(options);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
findOne(options: any): Promise<AccountModel> {
|
|
38
|
-
return this.accountModel.findOne(options);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
update(data: IAccountAttr, options?: any): any {
|
|
42
|
-
return this.accountModel.update({ ...data }, options);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/sequelize';
|
|
3
|
+
import { AccountModel } from './entities/account.entity';
|
|
4
|
+
import { BaseRepository } from '@tomei/general';
|
|
5
|
+
import {
|
|
6
|
+
IAccountAttr,
|
|
7
|
+
ICreateAccountAttr,
|
|
8
|
+
} from './interfaces/account-attr.interface';
|
|
9
|
+
import { IAccountRepository } from './interfaces/account.repository.interface';
|
|
10
|
+
|
|
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
|
+
|
|
23
|
+
create(data: ICreateAccountAttr, options?: any): Promise<AccountModel> | any {
|
|
24
|
+
return this.accountModel.create({ ...data }, options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
findAll(options: any): Promise<AccountModel[]> {
|
|
28
|
+
return this.accountModel.findAll(options);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
findAllWithPagination(
|
|
32
|
+
options: any,
|
|
33
|
+
): Promise<{ count: number; rows: AccountModel[] }> {
|
|
34
|
+
return this.accountModel.findAndCountAll(options);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
findOne(options: any): Promise<AccountModel> {
|
|
38
|
+
return this.accountModel.findOne(options);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
update(data: IAccountAttr, options?: any): any {
|
|
42
|
+
return this.accountModel.update({ ...data }, options);
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/account/account.ts
CHANGED
|
@@ -22,33 +22,38 @@ export class Account {
|
|
|
22
22
|
private AccountType: string;
|
|
23
23
|
private AccountSubtype: string;
|
|
24
24
|
|
|
25
|
+
constructor();
|
|
25
26
|
constructor(
|
|
26
|
-
accountRepository
|
|
27
|
-
accountNo
|
|
27
|
+
accountRepository?: IBaseRepository<AccountModel>,
|
|
28
|
+
accountNo?: string,
|
|
28
29
|
) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
if (accountRepository && accountNo) {
|
|
31
|
+
this.accountRepository = accountRepository;
|
|
32
|
+
this.AccountNo = accountNo;
|
|
33
|
+
const accountData = this.accountRepository.findOne({
|
|
34
|
+
where: { AccountNo: accountNo },
|
|
35
|
+
});
|
|
36
|
+
if (accountData) {
|
|
37
|
+
this.isNewRecord = false;
|
|
38
|
+
this.ParentAccountNo = accountData.ParentAccountNo;
|
|
39
|
+
this.SystemCode = accountData.SystemCode;
|
|
40
|
+
this.AccSystemCode = accountData.AccSystemCode;
|
|
41
|
+
this.AccSystemAccountId = accountData.AccSystemAccountId;
|
|
42
|
+
this.Name = accountData.Name;
|
|
43
|
+
this.Description = accountData.Description;
|
|
44
|
+
this.AccountType = accountData.AccountType;
|
|
45
|
+
this.AccountSubtype = accountData.AccountSubtype;
|
|
46
|
+
this.OwnerId = accountData.OwnerId;
|
|
47
|
+
this.OwnerType = accountData.OwnerType;
|
|
48
|
+
this.RelatedObjectId = accountData.RelatedObjectId;
|
|
49
|
+
this.RelatedObjectType = accountData.RelatedObjectType;
|
|
50
|
+
this.AccSystemCode = accountData.AccSystemCode;
|
|
51
|
+
} else {
|
|
52
|
+
const notFoundError = new RecordNotFoundError('No Record Found.');
|
|
53
|
+
throw notFoundError;
|
|
54
|
+
}
|
|
55
|
+
} else if (accountRepository || accountNo) {
|
|
56
|
+
throw new Error('AccountNo and AccountRepository both are required.');
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBaseRepository } from '@tomei/general';
|
|
2
|
-
import { AccountModel } from '../entities/account.entity';
|
|
3
|
-
|
|
4
|
-
export type IAccountRepository = IBaseRepository<AccountModel>;
|
|
1
|
+
import { IBaseRepository } from '@tomei/general';
|
|
2
|
+
import { AccountModel } from '../entities/account.entity';
|
|
3
|
+
|
|
4
|
+
export type IAccountRepository = IBaseRepository<AccountModel>;
|