@tomei/finance 0.2.13 → 0.2.14
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.js.map +1 -1
- package/dist/account-system-entity/account-system-entity.js +1 -1
- package/dist/account-system-entity/account-system-entity.js.map +1 -1
- package/dist/customer/entities/customer.entity.d.ts +1 -1
- package/dist/customer/entities/customer.entity.js +4 -4
- package/dist/customer/entities/customer.entity.js.map +1 -1
- package/dist/document/document-item.d.ts +4 -1
- package/dist/document/document-item.js.map +1 -1
- package/dist/document/entities/document-item.entity.d.ts +3 -0
- package/dist/document/entities/document-item.entity.js +22 -1
- package/dist/document/entities/document-item.entity.js.map +1 -1
- package/dist/document/interfaces/document-item-attr.interface.d.ts +4 -1
- package/dist/document/interfaces/document-item-attr.interface.js.map +1 -1
- package/dist/finance-company/finance-company.d.ts +7 -6
- package/dist/finance-company/finance-company.entity.d.ts +13 -0
- package/dist/finance-company/finance-company.entity.js +66 -0
- package/dist/finance-company/finance-company.entity.js.map +1 -0
- package/dist/finance-company/finance-company.js +43 -22
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/finance-company/finance-company.repository.d.ts +4 -9
- package/dist/finance-company/finance-company.repository.js +5 -30
- package/dist/finance-company/finance-company.repository.js.map +1 -1
- package/dist/finance-company/index.d.ts +2 -5
- package/dist/finance-company/index.js +2 -4
- package/dist/finance-company/index.js.map +1 -1
- package/dist/journal-entry/entities/journal-entry.entity.d.ts +5 -1
- package/dist/journal-entry/entities/journal-entry.entity.js +37 -6
- package/dist/journal-entry/entities/journal-entry.entity.js.map +1 -1
- package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +4 -2
- package/dist/journal-entry/journal-entry.d.ts +16 -9
- package/dist/journal-entry/journal-entry.js +34 -7
- package/dist/journal-entry/journal-entry.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/finance-company-migration.js +1 -3
- package/migrations/finance-document-item-migration.js +18 -6
- package/migrations/finance-journal-entry-migration.js +17 -3
- package/package.json +1 -1
- package/src/account/account.ts +0 -3
- package/src/account-system-entity/account-system-entity.ts +1 -1
- package/src/customer/entities/customer.entity.ts +1 -1
- package/src/document/document-item.ts +4 -1
- package/src/document/entities/document-item.entity.ts +19 -1
- package/src/document/interfaces/document-item-attr.interface.ts +4 -1
- package/src/finance-company/finance-company.entity.ts +41 -0
- package/src/finance-company/finance-company.repository.ts +5 -23
- package/src/finance-company/finance-company.ts +58 -34
- package/src/finance-company/index.ts +2 -11
- package/src/journal-entry/entities/journal-entry.entity.ts +43 -7
- package/src/journal-entry/interfaces/journal-entry-attr.interface.ts +4 -2
- package/src/journal-entry/journal-entry.ts +51 -17
- package/src/finance-company/entities/finance-company.entity.ts +0 -88
- package/src/finance-company/interfaces/finance-company-attr.interface.ts +0 -10
- package/src/finance-company/interfaces/finance-company.repository.interface.ts +0 -4
|
@@ -25,16 +25,14 @@ module.exports = {
|
|
|
25
25
|
allowNull: false,
|
|
26
26
|
},
|
|
27
27
|
PostedToAccSystemYN: {
|
|
28
|
-
type: Sequelize.
|
|
28
|
+
type: Sequelize.ENUM(['Y', 'N']),
|
|
29
29
|
allowNull: false,
|
|
30
30
|
},
|
|
31
31
|
PostedById: {
|
|
32
32
|
type: Sequelize.STRING(30),
|
|
33
|
-
allowNull: true,
|
|
34
33
|
},
|
|
35
34
|
PostedDateTime: {
|
|
36
35
|
type: Sequelize.DATE,
|
|
37
|
-
allowNull: true,
|
|
38
36
|
},
|
|
39
37
|
});
|
|
40
38
|
},
|
|
@@ -8,7 +8,7 @@ module.exports = {
|
|
|
8
8
|
allowNull: false,
|
|
9
9
|
primaryKey: true,
|
|
10
10
|
},
|
|
11
|
-
DocNo:{
|
|
11
|
+
DocNo: {
|
|
12
12
|
type: Sequelize.STRING(30),
|
|
13
13
|
allowNull: false,
|
|
14
14
|
references: {
|
|
@@ -18,11 +18,11 @@ module.exports = {
|
|
|
18
18
|
onUpdate: 'CASCADE',
|
|
19
19
|
onDelete: 'CASCADE',
|
|
20
20
|
},
|
|
21
|
-
Name:{
|
|
21
|
+
Name: {
|
|
22
22
|
type: Sequelize.STRING(200),
|
|
23
23
|
allowNull: false,
|
|
24
24
|
},
|
|
25
|
-
NameBM:{
|
|
25
|
+
NameBM: {
|
|
26
26
|
type: Sequelize.STRING(200),
|
|
27
27
|
allowNull: false,
|
|
28
28
|
},
|
|
@@ -56,7 +56,7 @@ module.exports = {
|
|
|
56
56
|
},
|
|
57
57
|
Quantity: {
|
|
58
58
|
type: Sequelize.DECIMAL(10, 2),
|
|
59
|
-
allowNull:
|
|
59
|
+
allowNull: true,
|
|
60
60
|
},
|
|
61
61
|
QuantityUOM: {
|
|
62
62
|
type: Sequelize.STRING(20),
|
|
@@ -70,7 +70,19 @@ module.exports = {
|
|
|
70
70
|
type: Sequelize.STRING(30),
|
|
71
71
|
allowNull: true,
|
|
72
72
|
},
|
|
73
|
-
|
|
73
|
+
TaxAmount: {
|
|
74
|
+
type: Sequelize.DECIMAL(10, 2),
|
|
75
|
+
allowNull: true,
|
|
76
|
+
},
|
|
77
|
+
TaxRate: {
|
|
78
|
+
type: Sequelize.DECIMAL(10, 2),
|
|
79
|
+
allowNull: true,
|
|
80
|
+
},
|
|
81
|
+
TaxInclusiveYN: {
|
|
82
|
+
type: Sequelize.ENUM(['Y', 'N']),
|
|
83
|
+
allowNull: true,
|
|
84
|
+
},
|
|
85
|
+
DtAccountNo: {
|
|
74
86
|
type: Sequelize.STRING(30),
|
|
75
87
|
allowNull: false,
|
|
76
88
|
references: {
|
|
@@ -80,7 +92,7 @@ module.exports = {
|
|
|
80
92
|
onUpdate: 'CASCADE',
|
|
81
93
|
onDelete: 'CASCADE',
|
|
82
94
|
},
|
|
83
|
-
CtAccountNo:{
|
|
95
|
+
CtAccountNo: {
|
|
84
96
|
type: Sequelize.STRING(30),
|
|
85
97
|
allowNull: false,
|
|
86
98
|
references: {
|
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
async up(queryInterface, Sequelize) {
|
|
5
5
|
await queryInterface.createTable('finance_JournalEntry', {
|
|
6
|
+
CompanyId: {
|
|
7
|
+
type: Sequelize.STRING(30),
|
|
8
|
+
allowNull: false,
|
|
9
|
+
references: {
|
|
10
|
+
model: 'finance_Company',
|
|
11
|
+
key: 'CompanyId',
|
|
12
|
+
},
|
|
13
|
+
onUpdate: 'CASCADE',
|
|
14
|
+
onDelete: 'CASCADE',
|
|
15
|
+
},
|
|
6
16
|
JournalEntryId: {
|
|
7
17
|
type: Sequelize.STRING(30),
|
|
8
18
|
primaryKey: true,
|
|
@@ -20,14 +30,18 @@ module.exports = {
|
|
|
20
30
|
type: Sequelize.STRING(1000),
|
|
21
31
|
allowNull: true,
|
|
22
32
|
},
|
|
23
|
-
|
|
33
|
+
AccSystemRefId: {
|
|
24
34
|
type: Sequelize.STRING(30),
|
|
25
|
-
allowNull:
|
|
35
|
+
allowNull: true,
|
|
26
36
|
},
|
|
27
37
|
PostedToAccSystemYN: {
|
|
28
|
-
type: Sequelize.
|
|
38
|
+
type: Sequelize.ENUM(['Y', 'N']),
|
|
29
39
|
allowNull: false,
|
|
30
40
|
},
|
|
41
|
+
PostedById: {
|
|
42
|
+
type: Sequelize.STRING(30),
|
|
43
|
+
allowNull: true,
|
|
44
|
+
},
|
|
31
45
|
PostedDateTime: {
|
|
32
46
|
type: Sequelize.DATE,
|
|
33
47
|
allowNull: true,
|
package/package.json
CHANGED
package/src/account/account.ts
CHANGED
|
@@ -20,7 +20,6 @@ export class Account extends AccountSystemEntity {
|
|
|
20
20
|
private RelatedObjectType: string;
|
|
21
21
|
private ParentAccountNo: string;
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
SystemCode: string;
|
|
25
24
|
AccSystemCode: string;
|
|
26
25
|
Name: string;
|
|
@@ -28,8 +27,6 @@ export class Account extends AccountSystemEntity {
|
|
|
28
27
|
AccountType: string;
|
|
29
28
|
AccountSubtype: string;
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
30
|
CreatedAt: Date;
|
|
34
31
|
CreatedById: string;
|
|
35
32
|
|
|
@@ -57,7 +57,7 @@ export abstract class AccountSystemEntity extends ObjectBase {
|
|
|
57
57
|
try {
|
|
58
58
|
/*retrieve the finance company details from finance_Company to
|
|
59
59
|
* get details of the accounting system*/
|
|
60
|
-
const company = FinanceCompany.getFinanceCompany(this.CompanyId);
|
|
60
|
+
const company = await FinanceCompany.getFinanceCompany(this.CompanyId);
|
|
61
61
|
|
|
62
62
|
/*todo:instantiating the appropriate accounting system to perform the post*/
|
|
63
63
|
// if (this.TableName === 'finance_Customer') {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Model,
|
|
8
8
|
Table,
|
|
9
9
|
} from 'sequelize-typescript';
|
|
10
|
-
import { FinanceCompanyModel } from '../../finance-company
|
|
10
|
+
import { FinanceCompanyModel } from '../../finance-company';
|
|
11
11
|
|
|
12
12
|
@Table({ tableName: 'finance_Customer', createdAt: false, updatedAt: false })
|
|
13
13
|
export class FinanceCustomerModel extends Model {
|
|
@@ -10,10 +10,13 @@ export class DocumentItem {
|
|
|
10
10
|
ItemSerialNo?: string;
|
|
11
11
|
Currency: string;
|
|
12
12
|
UnitPrice?: number;
|
|
13
|
-
Quantity
|
|
13
|
+
Quantity?: number;
|
|
14
14
|
QuantityUOM?: string;
|
|
15
15
|
Amount: number;
|
|
16
16
|
TaxCode?: string;
|
|
17
|
+
TaxAmount?: number;
|
|
18
|
+
TaxRate?: number;
|
|
19
|
+
TaxInclusiveYN?: string;
|
|
17
20
|
DtAccountNo: string;
|
|
18
21
|
CtAccountNo: string;
|
|
19
22
|
}
|
|
@@ -81,7 +81,7 @@ export class DocumentItemModel extends Model {
|
|
|
81
81
|
|
|
82
82
|
@Column({
|
|
83
83
|
type: DataType.DECIMAL(10, 2),
|
|
84
|
-
allowNull:
|
|
84
|
+
allowNull: true,
|
|
85
85
|
})
|
|
86
86
|
Quantity: number;
|
|
87
87
|
|
|
@@ -103,6 +103,24 @@ export class DocumentItemModel extends Model {
|
|
|
103
103
|
})
|
|
104
104
|
TaxCode: string;
|
|
105
105
|
|
|
106
|
+
@Column({
|
|
107
|
+
type: DataType.DECIMAL(10, 2),
|
|
108
|
+
allowNull: true,
|
|
109
|
+
})
|
|
110
|
+
TaxAmount: number;
|
|
111
|
+
|
|
112
|
+
@Column({
|
|
113
|
+
type: DataType.DECIMAL(10, 2),
|
|
114
|
+
allowNull: true,
|
|
115
|
+
})
|
|
116
|
+
TaxRate: number;
|
|
117
|
+
|
|
118
|
+
@Column({
|
|
119
|
+
allowNull: true,
|
|
120
|
+
type: DataType.ENUM('Y', 'N'),
|
|
121
|
+
})
|
|
122
|
+
TaxInclusiveYN: string;
|
|
123
|
+
|
|
106
124
|
@ForeignKey(() => AccountModel)
|
|
107
125
|
@Column({
|
|
108
126
|
allowNull: false,
|
|
@@ -10,10 +10,13 @@ export class IDocumentItemAttr {
|
|
|
10
10
|
ItemSerialNo?: string;
|
|
11
11
|
Currency: string;
|
|
12
12
|
UnitPrice?: number;
|
|
13
|
-
Quantity
|
|
13
|
+
Quantity?: number;
|
|
14
14
|
QuantityUOM?: string;
|
|
15
15
|
Amount: number;
|
|
16
16
|
TaxCode?: string;
|
|
17
|
+
TaxAmount?: number;
|
|
18
|
+
TaxRate?: number;
|
|
19
|
+
TaxInclusiveYN?: string;
|
|
17
20
|
DtAccountNo: string;
|
|
18
21
|
CtAccountNo: string;
|
|
19
22
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { Column, DataType, HasMany, Model, Table } from 'sequelize-typescript';
|
|
3
|
+
import { FinanceCustomerModel } from '../customer';
|
|
4
|
+
|
|
5
|
+
@Table({ tableName: 'finance_Company', createdAt: false, updatedAt: false })
|
|
6
|
+
export class FinanceCompanyModel extends Model {
|
|
7
|
+
@ApiProperty({ example: 'cl6nzvo780000qcw38ihpd8w6' })
|
|
8
|
+
@Column({ primaryKey: true, allowNull: false, type: DataType.STRING(30) })
|
|
9
|
+
CompanyId: string;
|
|
10
|
+
|
|
11
|
+
@ApiProperty({ example: 'AB' })
|
|
12
|
+
@Column({ allowNull: false, type: DataType.STRING(10) })
|
|
13
|
+
CompSystemCode: string;
|
|
14
|
+
|
|
15
|
+
@ApiProperty({ example: 'cl6nzvo780000qcw38ihpd8w6' })
|
|
16
|
+
@Column({ allowNull: false, type: DataType.STRING(30) })
|
|
17
|
+
CompSystemRefId: string;
|
|
18
|
+
|
|
19
|
+
@ApiProperty({ example: 'AB' })
|
|
20
|
+
@Column({ allowNull: false, type: DataType.STRING(10) })
|
|
21
|
+
AccSystemCode: string;
|
|
22
|
+
|
|
23
|
+
@ApiProperty({ example: 'cl6nzvo780000qcw38ihpd8w6' })
|
|
24
|
+
@Column({ allowNull: false, type: DataType.STRING(30) })
|
|
25
|
+
AccSystemRefId: string;
|
|
26
|
+
|
|
27
|
+
@ApiProperty({ example: 'N' })
|
|
28
|
+
@Column({ defaultValue: 'N', type: DataType.ENUM('Y', 'N') })
|
|
29
|
+
PostedToAccSystemYN: string;
|
|
30
|
+
|
|
31
|
+
@ApiProperty({ example: 'cl6nzvo780000qcw38ihpd8w6' })
|
|
32
|
+
@Column({ type: DataType.STRING(30) })
|
|
33
|
+
PostedById: string;
|
|
34
|
+
|
|
35
|
+
@ApiProperty({ example: new Date() })
|
|
36
|
+
@Column({ type: DataType.DATE })
|
|
37
|
+
PostedDateTime: Date;
|
|
38
|
+
|
|
39
|
+
@HasMany(() => FinanceCustomerModel)
|
|
40
|
+
FinanceCustomers: FinanceCustomerModel[];
|
|
41
|
+
}
|
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BaseRepository } from '@tomei/general';
|
|
4
|
-
import { FinanceCompanyModel } from './entities/finance-company.entity';
|
|
5
|
-
import { IFinanceCompanyAttr } from './interfaces/finance-company-attr.interface';
|
|
6
|
-
import { IFinanceCompanyRepository } from './interfaces/finance-company.repository.interface';
|
|
1
|
+
import { BaseRepository, IBaseRepository } from '@tomei/general';
|
|
2
|
+
import { FinanceCompanyModel } from './finance-company.entity';
|
|
7
3
|
|
|
8
|
-
@Injectable()
|
|
9
4
|
export class FinanceCompanyRepository
|
|
10
5
|
extends BaseRepository<FinanceCompanyModel>
|
|
11
|
-
implements
|
|
6
|
+
implements IBaseRepository<FinanceCompanyModel>
|
|
12
7
|
{
|
|
13
|
-
constructor(
|
|
14
|
-
|
|
15
|
-
private readonly financeCompanyModel: typeof FinanceCompanyModel,
|
|
16
|
-
) {
|
|
8
|
+
constructor() {
|
|
9
|
+
const financeCompanyModel = new FinanceCompanyModel();
|
|
17
10
|
super(financeCompanyModel);
|
|
18
11
|
}
|
|
19
|
-
|
|
20
|
-
create(
|
|
21
|
-
data: IFinanceCompanyAttr | any,
|
|
22
|
-
options?: any,
|
|
23
|
-
): Promise<FinanceCompanyModel> | any {
|
|
24
|
-
return this.financeCompanyModel.create(data, options);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
findOne(options: any): Promise<FinanceCompanyModel> {
|
|
28
|
-
return this.financeCompanyModel.findOne(options);
|
|
29
|
-
}
|
|
30
12
|
}
|
|
@@ -8,14 +8,16 @@ import { Account } from '../account';
|
|
|
8
8
|
import { Customer, FinanceCustomerRepository } from '../customer';
|
|
9
9
|
import { AccountSystemEntity } from '../account-system-entity';
|
|
10
10
|
import cuid from 'cuid';
|
|
11
|
+
import { FinanceCompanyRepository } from './finance-company.repository';
|
|
11
12
|
|
|
12
13
|
export class FinanceCompany extends AccountSystemEntity {
|
|
13
14
|
private _CompSystemCode = '';
|
|
14
|
-
private
|
|
15
|
+
private _CompSystemRefId = '';
|
|
15
16
|
private _AccSystemCode = '';
|
|
16
17
|
protected BaseRepository: IBaseRepository;
|
|
17
18
|
private static _htFinanceCompanyIds = new HashTable();
|
|
18
19
|
private static _htFinanceCompanies = new HashTable();
|
|
20
|
+
private static financeCompanyRepository = new FinanceCompanyRepository();
|
|
19
21
|
journalEntryRepository: JournalEntryRepository;
|
|
20
22
|
financeCustomerRepository: FinanceCustomerRepository;
|
|
21
23
|
ledgerTransactionRepository: LedgerTransactionRepository;
|
|
@@ -29,12 +31,12 @@ export class FinanceCompany extends AccountSystemEntity {
|
|
|
29
31
|
this._CompSystemCode = code;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
get
|
|
33
|
-
return this.
|
|
34
|
+
get CompSystemRefId() {
|
|
35
|
+
return this._CompSystemRefId;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
set
|
|
37
|
-
this.
|
|
38
|
+
set CompSystemRefId(id: string) {
|
|
39
|
+
this._CompSystemRefId = id;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
get AccSystemCode() {
|
|
@@ -50,7 +52,7 @@ export class FinanceCompany extends AccountSystemEntity {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
get ObjectName() {
|
|
53
|
-
return `${this.CompSystemCode}-${this.
|
|
55
|
+
return `${this.CompSystemCode}-${this.CompSystemRefId}-${this.AccSystemCode}`;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
get TableName() {
|
|
@@ -59,37 +61,42 @@ export class FinanceCompany extends AccountSystemEntity {
|
|
|
59
61
|
|
|
60
62
|
private constructor(
|
|
61
63
|
compSystemCode: string,
|
|
62
|
-
|
|
64
|
+
compSystemRefId: string,
|
|
63
65
|
accSystemCode: string,
|
|
64
66
|
) {
|
|
65
67
|
super();
|
|
66
68
|
this.CompSystemCode = compSystemCode;
|
|
67
|
-
this.
|
|
69
|
+
this.CompSystemRefId = compSystemRefId;
|
|
68
70
|
this.AccSystemCode = accSystemCode;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
static getFinanceCompanyId(
|
|
73
|
+
static async getFinanceCompanyId(
|
|
72
74
|
compSystemCode: string,
|
|
73
|
-
|
|
75
|
+
compSystemRefId: string,
|
|
74
76
|
accSystemCode: string,
|
|
75
|
-
): string {
|
|
77
|
+
): Promise<string> {
|
|
76
78
|
let sCompanyId = '';
|
|
77
79
|
/*Assemble the hashtable key*/
|
|
78
|
-
const sKey = `${compSystemCode}-${
|
|
80
|
+
const sKey = `${compSystemCode}-${compSystemRefId}-${accSystemCode}`;
|
|
79
81
|
/*Check if the FinanceCompany has previously being loaded*/
|
|
80
82
|
if (!FinanceCompany._htFinanceCompanyIds.get(sKey)) {
|
|
81
83
|
/*Instantiate a new FinanceCompany*/
|
|
82
84
|
const financeCompany = new FinanceCompany(
|
|
83
85
|
compSystemCode,
|
|
84
|
-
|
|
86
|
+
compSystemRefId,
|
|
85
87
|
accSystemCode,
|
|
86
88
|
);
|
|
87
89
|
|
|
88
|
-
/*
|
|
89
|
-
*
|
|
90
|
+
/*Retrieve the finance company from finance_Company table using compSystemCode,
|
|
91
|
+
* CompSystemRefId and accSystemCode */
|
|
92
|
+
const company = await FinanceCompany.financeCompanyRepository.findOne({
|
|
93
|
+
CompSystemCode: compSystemCode,
|
|
94
|
+
CompSystemRefId: compSystemRefId,
|
|
95
|
+
AccSystemCode: accSystemCode,
|
|
96
|
+
});
|
|
90
97
|
|
|
91
|
-
/*
|
|
92
|
-
financeCompany.CompanyId =
|
|
98
|
+
/*Retrieve and store the companyId from the result*/
|
|
99
|
+
financeCompany.CompanyId = company.CompanyId;
|
|
93
100
|
sCompanyId = financeCompany.CompanyId;
|
|
94
101
|
|
|
95
102
|
/*Add the details into the hashtable*/
|
|
@@ -104,28 +111,31 @@ export class FinanceCompany extends AccountSystemEntity {
|
|
|
104
111
|
return sCompanyId;
|
|
105
112
|
}
|
|
106
113
|
|
|
107
|
-
static getFinanceCompany(companyId: string): FinanceCompany {
|
|
114
|
+
static async getFinanceCompany(companyId: string): Promise<FinanceCompany> {
|
|
108
115
|
/*Check if the finance company is previously be loaded*/
|
|
109
116
|
if (!FinanceCompany._htFinanceCompanies.get(companyId)) {
|
|
110
|
-
/*
|
|
111
|
-
*
|
|
117
|
+
/*Retrieve the finance company from finance_Company table using compSystemCode,
|
|
118
|
+
* CompSystemRefId and accSystemCode */
|
|
119
|
+
const company = await FinanceCompany.financeCompanyRepository.findOne({
|
|
120
|
+
CompanyId: companyId,
|
|
121
|
+
});
|
|
112
122
|
|
|
113
|
-
/*
|
|
114
|
-
const compSystemCode =
|
|
115
|
-
const
|
|
116
|
-
const accSystemCode =
|
|
123
|
+
/*Using the result returned, instantiate a new FinanceCompany*/
|
|
124
|
+
const compSystemCode = company.CompSystemCode;
|
|
125
|
+
const compSystemRefId = company.CompSystemRefId;
|
|
126
|
+
const accSystemCode = company.AccSystemCode;
|
|
117
127
|
|
|
118
128
|
const financeCompany = new FinanceCompany(
|
|
119
129
|
compSystemCode,
|
|
120
|
-
|
|
130
|
+
compSystemRefId,
|
|
121
131
|
accSystemCode,
|
|
122
132
|
);
|
|
123
133
|
|
|
124
|
-
/*
|
|
125
|
-
financeCompany.CompanyId =
|
|
134
|
+
/*Retrieve and store the CompanyId from the result*/
|
|
135
|
+
financeCompany.CompanyId = company.CompanyId;
|
|
126
136
|
|
|
127
137
|
/*Add the details into the hashtable*/
|
|
128
|
-
const sKey = `${compSystemCode}-${
|
|
138
|
+
const sKey = `${compSystemCode}-${compSystemRefId}-${accSystemCode}`;
|
|
129
139
|
FinanceCompany._htFinanceCompanyIds.add(sKey, financeCompany.CompanyId);
|
|
130
140
|
FinanceCompany._htFinanceCompanies.add(
|
|
131
141
|
financeCompany.CompanyId,
|
|
@@ -136,29 +146,43 @@ export class FinanceCompany extends AccountSystemEntity {
|
|
|
136
146
|
return FinanceCompany._htFinanceCompanies.get(companyId);
|
|
137
147
|
}
|
|
138
148
|
|
|
139
|
-
static createFinanceCompany(
|
|
149
|
+
static async createFinanceCompany(
|
|
140
150
|
dbTransaction: any,
|
|
141
151
|
loginUser: LoginUserBase,
|
|
142
152
|
compSystemCode: string,
|
|
143
|
-
|
|
153
|
+
compSystemRefId: string,
|
|
144
154
|
accSystemCode: string,
|
|
145
155
|
) {
|
|
146
156
|
/*Instantiate a new FinanceCompany*/
|
|
147
157
|
const financeCompany = new FinanceCompany(
|
|
148
158
|
compSystemCode,
|
|
149
|
-
|
|
159
|
+
compSystemRefId,
|
|
150
160
|
accSystemCode,
|
|
151
161
|
);
|
|
152
162
|
|
|
153
|
-
/*
|
|
163
|
+
/*Validating if the finance company already exists in finance_Company*/
|
|
164
|
+
const company = await FinanceCompany.financeCompanyRepository.findOne({
|
|
165
|
+
CompSystemCode: compSystemCode,
|
|
166
|
+
CompSystemRefId: compSystemRefId,
|
|
167
|
+
AccSystemCode: accSystemCode,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (company) {
|
|
171
|
+
throw Error(
|
|
172
|
+
'There is already another Finance Company with the compSystemCode, CompSystemRefId and accSystemCode specified.',
|
|
173
|
+
);
|
|
174
|
+
}
|
|
154
175
|
|
|
155
176
|
/*Generating the companyId*/
|
|
156
177
|
financeCompany.CompanyId = cuid();
|
|
157
178
|
|
|
158
|
-
/*
|
|
179
|
+
/*Save the FinanceCompany to the finance_Company table*/
|
|
180
|
+
await FinanceCompany.financeCompanyRepository.create(financeCompany, {
|
|
181
|
+
transaction: dbTransaction,
|
|
182
|
+
});
|
|
159
183
|
|
|
160
184
|
/*Add the details to hashtable*/
|
|
161
|
-
const sKey = `${compSystemCode}-${
|
|
185
|
+
const sKey = `${compSystemCode}-${compSystemRefId}-${accSystemCode}`;
|
|
162
186
|
FinanceCompany._htFinanceCompanyIds.add(sKey, financeCompany.CompanyId);
|
|
163
187
|
FinanceCompany._htFinanceCompanies.add(
|
|
164
188
|
financeCompany.CompanyId,
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { FinanceCompany } from './finance-company';
|
|
2
|
-
import { FinanceCompanyModel } from './
|
|
3
|
-
import { IFinanceCompanyAttr } from './interfaces/finance-company-attr.interface';
|
|
4
|
-
import { IFinanceCompanyRepository } from './interfaces/finance-company.repository.interface';
|
|
5
|
-
import { FinanceCompanyRepository } from './finance-company.repository';
|
|
2
|
+
import { FinanceCompanyModel } from './finance-company.entity';
|
|
6
3
|
|
|
7
|
-
export {
|
|
8
|
-
FinanceCompany,
|
|
9
|
-
FinanceCompanyModel,
|
|
10
|
-
IFinanceCompanyAttr,
|
|
11
|
-
IFinanceCompanyRepository,
|
|
12
|
-
FinanceCompanyRepository,
|
|
13
|
-
};
|
|
4
|
+
export { FinanceCompany, FinanceCompanyModel };
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ForeignKey,
|
|
4
|
+
BelongsTo,
|
|
5
|
+
Column,
|
|
6
|
+
Model,
|
|
7
|
+
Table,
|
|
8
|
+
DataType,
|
|
9
|
+
HasMany,
|
|
10
|
+
} from 'sequelize-typescript';
|
|
11
|
+
import { FinanceCompanyModel } from '../../finance-company';
|
|
3
12
|
import { LedgerTransactionModel } from '../../ledger-transaction/entities/ledger-transaction.entity';
|
|
4
13
|
|
|
5
14
|
@Table({
|
|
@@ -7,6 +16,17 @@ import { LedgerTransactionModel } from '../../ledger-transaction/entities/ledger
|
|
|
7
16
|
timestamps: false,
|
|
8
17
|
})
|
|
9
18
|
export class JournalEntryModel extends Model {
|
|
19
|
+
@ApiProperty({
|
|
20
|
+
example: 'cl6nzvo780000qcw38ihpd8w6',
|
|
21
|
+
description: 'CompanyId',
|
|
22
|
+
})
|
|
23
|
+
@ForeignKey(() => FinanceCompanyModel)
|
|
24
|
+
@Column({
|
|
25
|
+
allowNull: false,
|
|
26
|
+
type: DataType.STRING(30),
|
|
27
|
+
})
|
|
28
|
+
CompanyId: string;
|
|
29
|
+
|
|
10
30
|
@ApiProperty({ type: String, description: 'JournalEntryId' })
|
|
11
31
|
@Column({
|
|
12
32
|
primaryKey: true,
|
|
@@ -43,22 +63,35 @@ export class JournalEntryModel extends Model {
|
|
|
43
63
|
Description: string;
|
|
44
64
|
|
|
45
65
|
@ApiProperty({
|
|
46
|
-
|
|
47
|
-
description: '
|
|
66
|
+
type: String,
|
|
67
|
+
description: 'Account Customer Id in API',
|
|
48
68
|
})
|
|
49
|
-
@Column({
|
|
50
|
-
|
|
69
|
+
@Column({
|
|
70
|
+
allowNull: true,
|
|
71
|
+
type: DataType.STRING(30),
|
|
72
|
+
})
|
|
73
|
+
AccSystemRefId: string;
|
|
51
74
|
|
|
52
75
|
@ApiProperty({
|
|
53
|
-
|
|
76
|
+
example: 'N',
|
|
54
77
|
description: 'PostedToAccSystemYN',
|
|
55
78
|
})
|
|
56
79
|
@Column({
|
|
57
80
|
allowNull: false,
|
|
58
|
-
type: DataType.
|
|
81
|
+
type: DataType.ENUM('Y', 'N'),
|
|
59
82
|
})
|
|
60
83
|
PostedToAccSystemYN: string;
|
|
61
84
|
|
|
85
|
+
@ApiProperty({
|
|
86
|
+
example: '138140891dd211b288',
|
|
87
|
+
description: 'PostedById',
|
|
88
|
+
})
|
|
89
|
+
@Column({
|
|
90
|
+
allowNull: false,
|
|
91
|
+
type: DataType.STRING(30),
|
|
92
|
+
})
|
|
93
|
+
PostedById: string;
|
|
94
|
+
|
|
62
95
|
@ApiProperty({
|
|
63
96
|
example: new Date(),
|
|
64
97
|
description: 'PostedToAccSystem Date',
|
|
@@ -71,4 +104,7 @@ export class JournalEntryModel extends Model {
|
|
|
71
104
|
|
|
72
105
|
@HasMany(() => LedgerTransactionModel)
|
|
73
106
|
LedgerTransactions: LedgerTransactionModel[];
|
|
107
|
+
|
|
108
|
+
@BelongsTo(() => FinanceCompanyModel)
|
|
109
|
+
FinanceCompany: FinanceCompanyModel;
|
|
74
110
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export interface IJournalEntryAttr {
|
|
2
|
+
CompanyId: string;
|
|
2
3
|
JournalEntryId: string;
|
|
3
|
-
Date
|
|
4
|
+
Date?: Date;
|
|
4
5
|
Name: string;
|
|
5
6
|
Description?: string;
|
|
6
|
-
|
|
7
|
+
AccSystemRefId?: string;
|
|
7
8
|
PostedToAccSystemYN: string;
|
|
9
|
+
PostedById?: string;
|
|
8
10
|
PostedDateTime?: Date;
|
|
9
11
|
}
|