@tomei/finance 0.2.1 → 0.2.2
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 +22 -14
- package/dist/account/account.js +75 -94
- package/dist/account/account.js.map +1 -1
- package/dist/account/entities/account.entity.d.ts +8 -0
- package/dist/account/entities/account.entity.js +72 -5
- package/dist/account/entities/account.entity.js.map +1 -1
- package/dist/document/document-item.repository.d.ts +17 -0
- package/dist/document/document-item.repository.js +51 -0
- package/dist/document/document-item.repository.js.map +1 -0
- package/dist/document/document.repository.d.ts +16 -0
- package/dist/document/document.repository.js +47 -0
- package/dist/document/document.repository.js.map +1 -0
- package/dist/document/entities/document-item.entity.d.ts +24 -0
- package/dist/document/entities/document-item.entity.js +153 -0
- package/dist/document/entities/document-item.entity.js.map +1 -0
- package/dist/document/entities/document.entity.d.ts +22 -0
- package/dist/document/entities/document.entity.js +139 -0
- package/dist/document/entities/document.entity.js.map +1 -0
- package/dist/document/index.d.ts +9 -0
- package/dist/document/index.js +16 -0
- package/dist/document/index.js.map +1 -0
- package/dist/document/interfaces/document-attr.interface.d.ts +19 -0
- package/dist/document/interfaces/document-attr.interface.js +7 -0
- package/dist/document/interfaces/document-attr.interface.js.map +1 -0
- package/dist/document/interfaces/document-item-attr.interface.d.ts +19 -0
- package/dist/document/interfaces/document-item-attr.interface.js +7 -0
- package/dist/document/interfaces/document-item-attr.interface.js.map +1 -0
- package/dist/document/interfaces/document-item.repository.interface.d.ts +3 -0
- package/dist/document/interfaces/document-item.repository.interface.js +3 -0
- package/dist/document/interfaces/document-item.repository.interface.js.map +1 -0
- package/dist/document/interfaces/document.repository.interface.d.ts +3 -0
- package/dist/document/interfaces/document.repository.interface.js +3 -0
- package/dist/document/interfaces/document.repository.interface.js.map +1 -0
- package/dist/enum/document-status.enum.d.ts +4 -0
- package/dist/enum/document-status.enum.js +9 -0
- package/dist/enum/document-status.enum.js.map +1 -0
- package/dist/enum/document-type.enum.d.ts +7 -0
- package/dist/enum/document-type.enum.js +12 -0
- package/dist/enum/document-type.enum.js.map +1 -0
- package/dist/enum/index.d.ts +3 -1
- package/dist/enum/index.js +5 -1
- package/dist/enum/index.js.map +1 -1
- package/dist/finance-company/finance-company.d.ts +2 -0
- package/dist/finance-company/finance-company.js +32 -0
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/finance-account-migration.js +83 -59
- package/migrations/finance-document-item-migration.js +99 -0
- package/migrations/finance-document-migration.js +77 -0
- package/package.json +2 -2
- package/src/account/account.ts +98 -143
- package/src/account/entities/account.entity.ts +66 -6
- package/src/document/document-item.repository.ts +49 -0
- package/src/document/document.repository.ts +41 -0
- package/src/document/entities/document-item.entity.ts +125 -0
- package/src/document/entities/document.entity.ts +106 -0
- package/src/document/index.ts +19 -0
- package/src/document/interfaces/document-attr.interface.ts +20 -0
- package/src/document/interfaces/document-item-attr.interface.ts +19 -0
- package/src/document/interfaces/document-item.repository.interface.ts +4 -0
- package/src/document/interfaces/document.repository.interface.ts +4 -0
- package/src/enum/document-status.enum.ts +4 -0
- package/src/enum/document-type.enum.ts +7 -0
- package/src/enum/index.ts +10 -1
- package/src/finance-company/finance-company.ts +54 -0
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from 'sequelize-typescript';
|
|
11
11
|
import { LedgerTransactionModel } from 'src/ledger-transaction/entities/ledger-transaction.entity';
|
|
12
12
|
import { PaymentModel } from '../../payment/entities/payment.entity';
|
|
13
|
-
|
|
13
|
+
import { DocumentItemModel } from '../../document/entities/document-item.entity';
|
|
14
14
|
@Table({ tableName: 'finance_Account', createdAt: false, updatedAt: false })
|
|
15
15
|
export class AccountModel extends Model {
|
|
16
16
|
@ApiProperty({ type: String, description: 'AccountNo' })
|
|
@@ -21,6 +21,13 @@ export class AccountModel extends Model {
|
|
|
21
21
|
})
|
|
22
22
|
AccountNo: string;
|
|
23
23
|
|
|
24
|
+
//copy from finance account migration table
|
|
25
|
+
@ApiProperty({ type: String, description: 'Parent account of this object' })
|
|
26
|
+
@Column({
|
|
27
|
+
type: DataType.STRING(30),
|
|
28
|
+
})
|
|
29
|
+
ParentAccountNo: string;
|
|
30
|
+
|
|
24
31
|
@ApiProperty({
|
|
25
32
|
type: String,
|
|
26
33
|
description: 'System Code eg. "EZC", "CRM"',
|
|
@@ -31,6 +38,26 @@ export class AccountModel extends Model {
|
|
|
31
38
|
})
|
|
32
39
|
SystemCode: string;
|
|
33
40
|
|
|
41
|
+
@ApiProperty({
|
|
42
|
+
type: String,
|
|
43
|
+
description: 'Finance account system code eg. "quickbook"',
|
|
44
|
+
})
|
|
45
|
+
@Column({
|
|
46
|
+
allowNull: false,
|
|
47
|
+
type: DataType.STRING(10),
|
|
48
|
+
})
|
|
49
|
+
AccSystemCode: string;
|
|
50
|
+
|
|
51
|
+
@ApiProperty({
|
|
52
|
+
type: String,
|
|
53
|
+
description: 'Account id in finance system',
|
|
54
|
+
})
|
|
55
|
+
@Column({
|
|
56
|
+
allowNull: false,
|
|
57
|
+
type: DataType.STRING(10),
|
|
58
|
+
})
|
|
59
|
+
AccSystemAccountId: string;
|
|
60
|
+
|
|
34
61
|
@ApiProperty({
|
|
35
62
|
type: String,
|
|
36
63
|
description: 'Name of the account',
|
|
@@ -41,12 +68,42 @@ export class AccountModel extends Model {
|
|
|
41
68
|
})
|
|
42
69
|
Name: string;
|
|
43
70
|
|
|
71
|
+
@ApiProperty({
|
|
72
|
+
type: String,
|
|
73
|
+
description: 'Account description',
|
|
74
|
+
})
|
|
75
|
+
@Column({
|
|
76
|
+
allowNull: true,
|
|
77
|
+
type: DataType.TEXT,
|
|
78
|
+
})
|
|
79
|
+
Description: string;
|
|
80
|
+
|
|
81
|
+
@ApiProperty({
|
|
82
|
+
type: String,
|
|
83
|
+
description: 'Account Type',
|
|
84
|
+
})
|
|
85
|
+
@Column({
|
|
86
|
+
allowNull: true,
|
|
87
|
+
type: DataType.STRING(100),
|
|
88
|
+
})
|
|
89
|
+
AccountType: string;
|
|
90
|
+
|
|
91
|
+
@ApiProperty({
|
|
92
|
+
type: String,
|
|
93
|
+
description: 'Account Sub Type',
|
|
94
|
+
})
|
|
95
|
+
@Column({
|
|
96
|
+
allowNull: true,
|
|
97
|
+
type: DataType.STRING(100),
|
|
98
|
+
})
|
|
99
|
+
AccountSubType: string;
|
|
100
|
+
|
|
44
101
|
@ApiProperty({
|
|
45
102
|
type: String,
|
|
46
103
|
description: 'Owner id of the account',
|
|
47
104
|
})
|
|
48
105
|
@Column({
|
|
49
|
-
allowNull:
|
|
106
|
+
allowNull: true,
|
|
50
107
|
type: DataType.STRING(30),
|
|
51
108
|
})
|
|
52
109
|
OwnerId: string;
|
|
@@ -56,21 +113,21 @@ export class AccountModel extends Model {
|
|
|
56
113
|
description: 'Owner type',
|
|
57
114
|
})
|
|
58
115
|
@Column({
|
|
59
|
-
allowNull:
|
|
60
|
-
type: DataType.STRING(
|
|
116
|
+
allowNull: true,
|
|
117
|
+
type: DataType.STRING(200),
|
|
61
118
|
})
|
|
62
119
|
OwnerType: string;
|
|
63
120
|
|
|
64
121
|
@ApiProperty({ type: String, description: 'Associated Object id' })
|
|
65
122
|
@Column({
|
|
66
|
-
allowNull:
|
|
123
|
+
allowNull: true,
|
|
67
124
|
type: DataType.STRING(30),
|
|
68
125
|
})
|
|
69
126
|
RelatedObjectId: string;
|
|
70
127
|
|
|
71
128
|
@ApiProperty({ type: String, description: 'Associated Object type' })
|
|
72
129
|
@Column({
|
|
73
|
-
allowNull:
|
|
130
|
+
allowNull: true,
|
|
74
131
|
type: DataType.STRING(200),
|
|
75
132
|
})
|
|
76
133
|
RelatedObjectType: string;
|
|
@@ -106,6 +163,9 @@ export class AccountModel extends Model {
|
|
|
106
163
|
@HasMany(() => PaymentModel)
|
|
107
164
|
Payments: PaymentModel[];
|
|
108
165
|
|
|
166
|
+
@HasMany(() => DocumentItemModel)
|
|
167
|
+
DocumentItems: DocumentItemModel[];
|
|
168
|
+
|
|
109
169
|
@HasMany(() => LedgerTransactionModel)
|
|
110
170
|
LedgerTransactions: LedgerTransactionModel[];
|
|
111
171
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/sequelize';
|
|
3
|
+
import { BaseRepository } from '@tomei/general';
|
|
4
|
+
import { DocumentItemModel } from './entities/document-item.entity';
|
|
5
|
+
import { IDocumentItemAttr } from './interfaces/document-item-attr.interface';
|
|
6
|
+
import { IDocumentItemRepository } from './interfaces/document-item.repository.interface';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class DocumentItemRepository
|
|
10
|
+
extends BaseRepository<DocumentItemModel>
|
|
11
|
+
implements IDocumentItemRepository
|
|
12
|
+
{
|
|
13
|
+
constructor(
|
|
14
|
+
@InjectModel(DocumentItemModel)
|
|
15
|
+
private readonly documentItemModel: typeof DocumentItemModel,
|
|
16
|
+
) {
|
|
17
|
+
super(documentItemModel);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
create(
|
|
21
|
+
data: IDocumentItemAttr,
|
|
22
|
+
options?: any,
|
|
23
|
+
): Promise<DocumentItemModel> | any {
|
|
24
|
+
return this.documentItemModel.create({ ...data }, options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
bulkCreate(data: IDocumentItemAttr[], options?: any): any {
|
|
28
|
+
const payload: any = [...data];
|
|
29
|
+
return this.documentItemModel.bulkCreate(payload, options);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
findAll(options: any): Promise<DocumentItemModel[]> {
|
|
33
|
+
return this.documentItemModel.findAll(options);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
findAllWithPagination(
|
|
37
|
+
options: any,
|
|
38
|
+
): Promise<{ count: number; rows: DocumentItemModel[] }> {
|
|
39
|
+
return this.documentItemModel.findAndCountAll(options);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
findOne(options: any): Promise<DocumentItemModel> {
|
|
43
|
+
return this.documentItemModel.findOne(options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
update(data: IDocumentItemAttr, options?: any): any {
|
|
47
|
+
return this.documentItemModel.update({ ...data }, options);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/sequelize';
|
|
3
|
+
import { BaseRepository } from '@tomei/general';
|
|
4
|
+
import { DocumentModel } from './entities/document.entity';
|
|
5
|
+
import { IDocumentAttr } from './interfaces/document-attr.interface';
|
|
6
|
+
import { IDocumentRepository } from './interfaces/document.repository.interface';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class DocumentRepository
|
|
10
|
+
extends BaseRepository<DocumentModel>
|
|
11
|
+
implements IDocumentRepository
|
|
12
|
+
{
|
|
13
|
+
constructor(
|
|
14
|
+
@InjectModel(DocumentModel)
|
|
15
|
+
private readonly documentModel: typeof DocumentModel,
|
|
16
|
+
) {
|
|
17
|
+
super(documentModel);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
create(data: IDocumentAttr, options?: any): Promise<DocumentModel> | any {
|
|
21
|
+
return this.documentModel.create({ ...data }, options);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
findAll(options: any): Promise<DocumentModel[]> {
|
|
25
|
+
return this.documentModel.findAll(options);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
findAllWithPagination(
|
|
29
|
+
options: any,
|
|
30
|
+
): Promise<{ count: number; rows: DocumentModel[] }> {
|
|
31
|
+
return this.documentModel.findAndCountAll(options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
findOne(options: any): Promise<DocumentModel> {
|
|
35
|
+
return this.documentModel.findOne(options);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
update(data: IDocumentAttr, options?: any): any {
|
|
39
|
+
return this.documentModel.update({ ...data }, options);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BelongsTo,
|
|
3
|
+
Column,
|
|
4
|
+
DataType,
|
|
5
|
+
ForeignKey,
|
|
6
|
+
Model,
|
|
7
|
+
Table,
|
|
8
|
+
} from 'sequelize-typescript';
|
|
9
|
+
import { DocumentModel } from './document.entity';
|
|
10
|
+
import { AccountModel } from '../../account/entities/account.entity';
|
|
11
|
+
|
|
12
|
+
@Table({ tableName: 'finance_DocumentItem', timestamps: false })
|
|
13
|
+
export class DocumentItemModel extends Model {
|
|
14
|
+
@Column({
|
|
15
|
+
type: DataType.STRING(30),
|
|
16
|
+
allowNull: false,
|
|
17
|
+
primaryKey: true,
|
|
18
|
+
})
|
|
19
|
+
DocumentItemId: string;
|
|
20
|
+
|
|
21
|
+
@ForeignKey(() => DocumentModel)
|
|
22
|
+
@Column({
|
|
23
|
+
allowNull: false,
|
|
24
|
+
type: DataType.STRING(30),
|
|
25
|
+
})
|
|
26
|
+
DocNo: string;
|
|
27
|
+
|
|
28
|
+
@Column({
|
|
29
|
+
type: DataType.STRING(200),
|
|
30
|
+
allowNull: false,
|
|
31
|
+
})
|
|
32
|
+
Name: string;
|
|
33
|
+
|
|
34
|
+
@Column({
|
|
35
|
+
type: DataType.STRING(200),
|
|
36
|
+
allowNull: false,
|
|
37
|
+
})
|
|
38
|
+
NameBM: string;
|
|
39
|
+
|
|
40
|
+
@Column({
|
|
41
|
+
type: DataType.STRING(1000),
|
|
42
|
+
allowNull: true,
|
|
43
|
+
})
|
|
44
|
+
Description: string;
|
|
45
|
+
|
|
46
|
+
@Column({
|
|
47
|
+
type: DataType.STRING(30),
|
|
48
|
+
allowNull: true,
|
|
49
|
+
})
|
|
50
|
+
ItemId: string;
|
|
51
|
+
|
|
52
|
+
@Column({
|
|
53
|
+
type: DataType.STRING(200),
|
|
54
|
+
allowNull: true,
|
|
55
|
+
})
|
|
56
|
+
ItemType: string;
|
|
57
|
+
|
|
58
|
+
@Column({
|
|
59
|
+
type: DataType.STRING(30),
|
|
60
|
+
allowNull: true,
|
|
61
|
+
})
|
|
62
|
+
ItemSKU: string;
|
|
63
|
+
|
|
64
|
+
@Column({
|
|
65
|
+
type: DataType.STRING(30),
|
|
66
|
+
allowNull: true,
|
|
67
|
+
})
|
|
68
|
+
ItemSerialNo: string;
|
|
69
|
+
|
|
70
|
+
@Column({
|
|
71
|
+
type: DataType.CHAR(3),
|
|
72
|
+
allowNull: false,
|
|
73
|
+
})
|
|
74
|
+
Currency: string;
|
|
75
|
+
|
|
76
|
+
@Column({
|
|
77
|
+
type: DataType.DECIMAL(10, 2),
|
|
78
|
+
allowNull: true,
|
|
79
|
+
})
|
|
80
|
+
UnitPrice: number;
|
|
81
|
+
|
|
82
|
+
@Column({
|
|
83
|
+
type: DataType.DECIMAL(10, 2),
|
|
84
|
+
allowNull: false,
|
|
85
|
+
})
|
|
86
|
+
Quantity: number;
|
|
87
|
+
|
|
88
|
+
@Column({
|
|
89
|
+
type: DataType.STRING(20),
|
|
90
|
+
allowNull: true,
|
|
91
|
+
})
|
|
92
|
+
QuantityUOM: string;
|
|
93
|
+
|
|
94
|
+
@Column({
|
|
95
|
+
type: DataType.DECIMAL(10, 2),
|
|
96
|
+
allowNull: false,
|
|
97
|
+
})
|
|
98
|
+
Amount: number;
|
|
99
|
+
|
|
100
|
+
@Column({
|
|
101
|
+
allowNull: true,
|
|
102
|
+
type: DataType.STRING(30),
|
|
103
|
+
})
|
|
104
|
+
TaxCode: string;
|
|
105
|
+
|
|
106
|
+
@ForeignKey(() => AccountModel)
|
|
107
|
+
@Column({
|
|
108
|
+
allowNull: false,
|
|
109
|
+
type: DataType.STRING(30),
|
|
110
|
+
})
|
|
111
|
+
DtAccountNo: string;
|
|
112
|
+
|
|
113
|
+
@ForeignKey(() => AccountModel)
|
|
114
|
+
@Column({
|
|
115
|
+
allowNull: false,
|
|
116
|
+
type: DataType.STRING(30),
|
|
117
|
+
})
|
|
118
|
+
CtAccountNo: string;
|
|
119
|
+
|
|
120
|
+
@BelongsTo(() => DocumentModel)
|
|
121
|
+
Document: DocumentModel;
|
|
122
|
+
|
|
123
|
+
@BelongsTo(() => AccountModel)
|
|
124
|
+
Account: AccountModel;
|
|
125
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Column, DataType, HasMany, Model, Table } from 'sequelize-typescript';
|
|
2
|
+
import { DocumentType, DocumentStatus } from '../../enum';
|
|
3
|
+
import { DocumentItemModel } from './document-item.entity';
|
|
4
|
+
|
|
5
|
+
@Table({ tableName: 'finance_Document', timestamps: false })
|
|
6
|
+
export class DocumentModel extends Model {
|
|
7
|
+
@Column({
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
type: DataType.STRING(30),
|
|
11
|
+
})
|
|
12
|
+
DocNo: string;
|
|
13
|
+
|
|
14
|
+
@Column({
|
|
15
|
+
allowNull: false,
|
|
16
|
+
type: DataType.STRING(30),
|
|
17
|
+
})
|
|
18
|
+
DocType: DocumentType;
|
|
19
|
+
|
|
20
|
+
@Column({
|
|
21
|
+
allowNull: false,
|
|
22
|
+
type: DataType.DATE,
|
|
23
|
+
})
|
|
24
|
+
DocDate: Date;
|
|
25
|
+
|
|
26
|
+
@Column({
|
|
27
|
+
allowNull: false,
|
|
28
|
+
type: DataType.STRING(10),
|
|
29
|
+
})
|
|
30
|
+
SystemCode: string;
|
|
31
|
+
|
|
32
|
+
@Column({
|
|
33
|
+
allowNull: false,
|
|
34
|
+
type: DataType.CHAR(3),
|
|
35
|
+
})
|
|
36
|
+
Currency: string;
|
|
37
|
+
|
|
38
|
+
@Column({
|
|
39
|
+
allowNull: false,
|
|
40
|
+
type: DataType.DECIMAL(10, 2),
|
|
41
|
+
})
|
|
42
|
+
Amount: number;
|
|
43
|
+
|
|
44
|
+
@Column({
|
|
45
|
+
allowNull: false,
|
|
46
|
+
type: DataType.STRING(1000),
|
|
47
|
+
})
|
|
48
|
+
Description: string;
|
|
49
|
+
|
|
50
|
+
@Column({
|
|
51
|
+
allowNull: false,
|
|
52
|
+
type: DataType.STRING(30),
|
|
53
|
+
})
|
|
54
|
+
Status: DocumentStatus;
|
|
55
|
+
|
|
56
|
+
@Column({
|
|
57
|
+
allowNull: false,
|
|
58
|
+
type: DataType.STRING(30),
|
|
59
|
+
})
|
|
60
|
+
IssuedById: string;
|
|
61
|
+
|
|
62
|
+
@Column({
|
|
63
|
+
allowNull: false,
|
|
64
|
+
type: DataType.STRING(30),
|
|
65
|
+
})
|
|
66
|
+
IssuedToId: string;
|
|
67
|
+
|
|
68
|
+
@Column({
|
|
69
|
+
allowNull: false,
|
|
70
|
+
type: DataType.STRING(200),
|
|
71
|
+
})
|
|
72
|
+
IssuedToType: string;
|
|
73
|
+
|
|
74
|
+
@Column({
|
|
75
|
+
allowNull: false,
|
|
76
|
+
type: DataType.STRING(10),
|
|
77
|
+
})
|
|
78
|
+
AccSystemCode: string;
|
|
79
|
+
|
|
80
|
+
@Column({
|
|
81
|
+
allowNull: false,
|
|
82
|
+
type: DataType.CHAR(1),
|
|
83
|
+
})
|
|
84
|
+
PostedToAccYN: string;
|
|
85
|
+
|
|
86
|
+
@Column({
|
|
87
|
+
allowNull: false,
|
|
88
|
+
type: DataType.CHAR(1),
|
|
89
|
+
})
|
|
90
|
+
UseAccSystemDocYN: string;
|
|
91
|
+
|
|
92
|
+
@Column({
|
|
93
|
+
allowNull: false,
|
|
94
|
+
type: DataType.STRING(500),
|
|
95
|
+
})
|
|
96
|
+
DocPDFFilePath: string;
|
|
97
|
+
|
|
98
|
+
@Column({
|
|
99
|
+
allowNull: false,
|
|
100
|
+
type: DataType.STRING(500),
|
|
101
|
+
})
|
|
102
|
+
DocHTMLFilePath: string;
|
|
103
|
+
|
|
104
|
+
@HasMany(() => DocumentItemModel)
|
|
105
|
+
DocumentItems: DocumentItemModel[];
|
|
106
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DocumentModel } from './entities/document.entity';
|
|
2
|
+
import { IDocumentAttr } from './interfaces/document-attr.interface';
|
|
3
|
+
import { IDocumentRepository } from './interfaces/document.repository.interface';
|
|
4
|
+
import { DocumentItemModel } from './entities/document-item.entity';
|
|
5
|
+
import { IDocumentItemAttr } from './interfaces/document-item-attr.interface';
|
|
6
|
+
import { IDocumentItemRepository } from './interfaces/document-item.repository.interface';
|
|
7
|
+
import { DocumentRepository } from './document.repository';
|
|
8
|
+
import { DocumentItemRepository } from './document-item.repository';
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
DocumentModel,
|
|
12
|
+
DocumentItemModel,
|
|
13
|
+
DocumentRepository,
|
|
14
|
+
DocumentItemRepository,
|
|
15
|
+
IDocumentRepository,
|
|
16
|
+
IDocumentItemRepository,
|
|
17
|
+
IDocumentAttr,
|
|
18
|
+
IDocumentItemAttr,
|
|
19
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DocumentType, DocumentStatus } from '../../enum';
|
|
2
|
+
|
|
3
|
+
export class IDocumentAttr {
|
|
4
|
+
DocNo: string;
|
|
5
|
+
DocType: DocumentType;
|
|
6
|
+
DocDate: Date;
|
|
7
|
+
SystemCode: string;
|
|
8
|
+
Currency: string;
|
|
9
|
+
Amount: number;
|
|
10
|
+
Description: string;
|
|
11
|
+
Status: DocumentStatus;
|
|
12
|
+
IssuedById: string;
|
|
13
|
+
IssuedToId: string;
|
|
14
|
+
IssuedToType: string;
|
|
15
|
+
AccSystemCode: string;
|
|
16
|
+
PostedToAccYN: string;
|
|
17
|
+
UseAccSystemDocYN: string;
|
|
18
|
+
DocPDFFilePath: string;
|
|
19
|
+
DocHTMLFilePath: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class IDocumentItemAttr {
|
|
2
|
+
DocumentItemId: string;
|
|
3
|
+
DocNo: string;
|
|
4
|
+
Name: string;
|
|
5
|
+
NameBM: string;
|
|
6
|
+
Description?: string;
|
|
7
|
+
ItemId?: string;
|
|
8
|
+
ItemType?: string;
|
|
9
|
+
ItemSKU?: string;
|
|
10
|
+
ItemSerialNo?: string;
|
|
11
|
+
Currency: string;
|
|
12
|
+
UnitPrice?: number;
|
|
13
|
+
Quantity: number;
|
|
14
|
+
QuantityUOM?: string;
|
|
15
|
+
Amount: number;
|
|
16
|
+
TaxCode?: string;
|
|
17
|
+
DtAccountNo: string;
|
|
18
|
+
CtAccountNo: string;
|
|
19
|
+
}
|
package/src/enum/index.ts
CHANGED
|
@@ -2,5 +2,14 @@ import { ClientScopes } from './quick-book-client-scopes.enum';
|
|
|
2
2
|
import { PaymentType } from './payment-type.enum';
|
|
3
3
|
import { PaymentMethod } from './payment-method.enum';
|
|
4
4
|
import { TransactionTypeOptions } from './transaction-type.enum';
|
|
5
|
+
import { DocumentType } from './document-type.enum';
|
|
6
|
+
import { DocumentStatus } from './document-status.enum';
|
|
5
7
|
|
|
6
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
ClientScopes,
|
|
10
|
+
PaymentType,
|
|
11
|
+
PaymentMethod,
|
|
12
|
+
TransactionTypeOptions,
|
|
13
|
+
DocumentType,
|
|
14
|
+
DocumentStatus,
|
|
15
|
+
};
|
|
@@ -5,6 +5,7 @@ import { LedgerTransactionRepository } from 'src/ledger-transaction';
|
|
|
5
5
|
import * as uniqid from 'uniqid';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import { JournalEntryModel } from 'src/journal-entry';
|
|
8
|
+
import { Account } from 'src/account';
|
|
8
9
|
|
|
9
10
|
export class FinanceCompany {
|
|
10
11
|
journalEntryRepository: JournalEntryRepository;
|
|
@@ -92,4 +93,57 @@ export class FinanceCompany {
|
|
|
92
93
|
payload,
|
|
93
94
|
);
|
|
94
95
|
}
|
|
96
|
+
|
|
97
|
+
async createAccount(dbTransaction: any, account: Account) {
|
|
98
|
+
try {
|
|
99
|
+
account.validateAccountValue();
|
|
100
|
+
|
|
101
|
+
let createAccountPayload: any = {
|
|
102
|
+
Name: account.name,
|
|
103
|
+
AcctNum: account.AccountNo,
|
|
104
|
+
AccountType: account.accountType,
|
|
105
|
+
AccountSubType: account.accountSubType,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (account.isParentAccountExsits()) {
|
|
109
|
+
createAccountPayload = {
|
|
110
|
+
...createAccountPayload,
|
|
111
|
+
CurrencyRef: 'MYR',
|
|
112
|
+
ParentRef: account.parentAccountNo,
|
|
113
|
+
SubAccount: true,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const accSystemAccountId = await this.accountingSystem.createAccount(
|
|
118
|
+
createAccountPayload,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const newAccount = await account.save(
|
|
122
|
+
accSystemAccountId,
|
|
123
|
+
'test',
|
|
124
|
+
dbTransaction,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const payload = {
|
|
128
|
+
Action: 'Create',
|
|
129
|
+
Activity: 'Account Created',
|
|
130
|
+
Description: `Account (ID: ${newAccount.AccountNo}) has been created`,
|
|
131
|
+
EntityType: 'Account',
|
|
132
|
+
EntityValueBefore: JSON.stringify({}),
|
|
133
|
+
EntityValueAfter: JSON.stringify(newAccount),
|
|
134
|
+
PerformedById: 'test',
|
|
135
|
+
PerformedAt: new Date(),
|
|
136
|
+
EntityId: newAccount.AccountNo,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
await axios.post(
|
|
140
|
+
`${process.env.COMMON_API_URL}/activity-histories`,
|
|
141
|
+
payload,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return account;
|
|
145
|
+
} catch (error) {
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
95
149
|
}
|