@tomei/finance 0.2.4 → 0.2.6
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 +17 -10
- package/dist/account/account.js +6 -6
- package/dist/account/account.js.map +1 -1
- package/dist/account/entities/account.entity.d.ts +1 -1
- package/dist/account/entities/account.entity.js +1 -1
- package/dist/account/entities/account.entity.js.map +1 -1
- package/dist/customer/customer.d.ts +12 -12
- package/dist/customer/customer.js +29 -26
- package/dist/customer/customer.js.map +1 -1
- package/dist/customer/finance-customer.repository.d.ts +5 -3
- package/dist/customer/finance-customer.repository.js +9 -4
- package/dist/customer/finance-customer.repository.js.map +1 -1
- package/dist/customer/interfaces/finance-customer.repository.interface.d.ts +3 -3
- package/dist/document/document.d.ts +39 -0
- package/dist/document/document.js +119 -0
- package/dist/document/document.js.map +1 -0
- package/dist/document/entities/document.entity.d.ts +2 -2
- package/dist/document/entities/document.entity.js.map +1 -1
- package/dist/document/interfaces/document-attr.interface.d.ts +3 -3
- package/dist/enum/doc-type.enum.d.ts +7 -0
- package/dist/enum/doc-type.enum.js +12 -0
- package/dist/enum/doc-type.enum.js.map +1 -0
- package/dist/enum/index.d.ts +2 -2
- package/dist/enum/index.js +3 -3
- package/dist/enum/index.js.map +1 -1
- package/dist/finance-company/finance-company.d.ts +11 -3
- package/dist/finance-company/finance-company.js +87 -50
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/journal-entry/entities/journal-entry.entity.d.ts +1 -1
- package/dist/journal-entry/entities/journal-entry.entity.js +1 -1
- package/dist/journal-entry/entities/journal-entry.entity.js.map +1 -1
- package/dist/journal-entry/journal-entry.d.ts +8 -2
- package/dist/journal-entry/journal-entry.js +14 -0
- package/dist/journal-entry/journal-entry.js.map +1 -1
- package/dist/payment/payment.d.ts +7 -1
- package/dist/payment/payment.js +1 -0
- package/dist/payment/payment.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/invoice-template/assets/css/style.css +2630 -0
- package/invoice-template/assets/css/style.css.map +13 -0
- package/invoice-template/assets/css/style.min.css +1 -0
- package/invoice-template/assets/img/arrow_bg.svg +12 -0
- package/invoice-template/assets/img/coffy_shop_img.svg +19 -0
- package/invoice-template/assets/img/header_bg.jpeg +0 -0
- package/invoice-template/assets/img/header_bg_2.jpeg +0 -0
- package/invoice-template/assets/img/logo.svg +4 -0
- package/invoice-template/assets/img/logo_accent.svg +4 -0
- package/invoice-template/assets/img/logo_white.svg +4 -0
- package/invoice-template/assets/img/qbar.png +0 -0
- package/invoice-template/assets/img/shape_1.svg +1 -0
- package/invoice-template/assets/img/shape_2.svg +1 -0
- package/invoice-template/assets/img/sign.svg +12 -0
- package/invoice-template/assets/js/html2canvas.min.js +10379 -0
- package/invoice-template/assets/js/jquery.min.js +2 -0
- package/invoice-template/assets/js/jspdf.min.js +1 -0
- package/invoice-template/assets/js/main.js +48 -0
- package/invoice-template/assets/sass/common/_color_variable.scss +12 -0
- package/invoice-template/assets/sass/common/_invoice.scss +1802 -0
- package/invoice-template/assets/sass/common/_normalize.scss +350 -0
- package/invoice-template/assets/sass/common/_typography.scss +178 -0
- package/invoice-template/assets/sass/style.scss +12 -0
- package/invoice-template/index.html +156 -0
- package/invoice-template/sample-invoice.pdf +0 -0
- package/migrations/finance-account-migration.js +1 -1
- package/migrations/finance-journal-entry-migration.js +1 -1
- package/package.json +3 -1
- package/src/account/account.ts +22 -15
- package/src/account/entities/account.entity.ts +1 -1
- package/src/customer/customer.ts +49 -48
- package/src/customer/finance-customer.repository.ts +12 -4
- package/src/customer/interfaces/finance-customer.repository.interface.ts +4 -3
- package/src/document/document.ts +171 -0
- package/src/document/entities/document.entity.ts +2 -2
- package/src/document/interfaces/document-attr.interface.ts +3 -3
- package/src/enum/{document-type.enum.ts → doc-type.enum.ts} +2 -2
- package/src/enum/index.ts +2 -2
- package/src/finance-company/finance-company.ts +132 -70
- package/src/journal-entry/entities/journal-entry.entity.ts +1 -1
- package/src/journal-entry/journal-entry.ts +25 -4
- package/src/payment/payment.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomei/finance",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "NestJS package for finance module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@nestjs/platform-express": "^9.0.8",
|
|
36
36
|
"@nestjs/sequelize": "^9.0.0",
|
|
37
37
|
"@tomei/general": "^0.0.14",
|
|
38
|
+
"@tomei/media": "^0.4.0",
|
|
38
39
|
"axios": "^1.1.3",
|
|
39
40
|
"class-transformer": "^0.5.1",
|
|
40
41
|
"class-validator": "^0.13.2",
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@nestjs/swagger": "^6.0.4",
|
|
50
|
+
"@types/multer": "^1.4.7",
|
|
49
51
|
"@types/node": "^18.0.6",
|
|
50
52
|
"@types/sequelize": "^4.28.14",
|
|
51
53
|
"@types/uniqid": "^5.3.2",
|
package/src/account/account.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { IAccountRepository } from './interfaces/account.repository.interface';
|
|
|
2
2
|
import { AccountModel } from './entities/account.entity';
|
|
3
3
|
import { ObjectBase, PersonBase, RecordNotFoundError } from '@tomei/general';
|
|
4
4
|
import { IBaseRepository } from '@tomei/general/dist/interfaces/repository.base.interface';
|
|
5
|
-
|
|
5
|
+
import { IAccountSystemEntity } from 'src/interfaces/account-system-entity.interface';
|
|
6
|
+
export class Account implements IAccountSystemEntity {
|
|
6
7
|
accountRepository: IAccountRepository;
|
|
7
8
|
AccountNo: string;
|
|
8
9
|
Owner: PersonBase;
|
|
@@ -14,15 +15,21 @@ export class Account {
|
|
|
14
15
|
private RelatedObjectId: string;
|
|
15
16
|
private RelatedObjectType: string;
|
|
16
17
|
private ParentAccountNo: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
AccSystemRefId: string;
|
|
19
|
+
|
|
20
|
+
SystemCode: string;
|
|
21
|
+
AccSystemCode: string;
|
|
22
|
+
Name: string;
|
|
23
|
+
Description: string;
|
|
24
|
+
AccountType: string;
|
|
25
|
+
AccountSubtype: string;
|
|
26
|
+
PostedToAccSystemYN: 'N';
|
|
27
|
+
PostedById: string;
|
|
28
|
+
PostedDateTime: Date;
|
|
29
|
+
|
|
30
|
+
CreatedAt: Date;
|
|
31
|
+
CreatedById: string;
|
|
24
32
|
|
|
25
|
-
constructor();
|
|
26
33
|
constructor(
|
|
27
34
|
accountRepository?: IBaseRepository<AccountModel>,
|
|
28
35
|
accountNo?: string,
|
|
@@ -38,7 +45,7 @@ export class Account {
|
|
|
38
45
|
this.ParentAccountNo = accountData.ParentAccountNo;
|
|
39
46
|
this.SystemCode = accountData.SystemCode;
|
|
40
47
|
this.AccSystemCode = accountData.AccSystemCode;
|
|
41
|
-
this.
|
|
48
|
+
this.AccSystemRefId = accountData.AccSystemRefId;
|
|
42
49
|
this.Name = accountData.Name;
|
|
43
50
|
this.Description = accountData.Description;
|
|
44
51
|
this.AccountType = accountData.AccountType;
|
|
@@ -80,7 +87,7 @@ export class Account {
|
|
|
80
87
|
if (!this.AccSystemCode) {
|
|
81
88
|
throw new Error('AccSystemCode is required.');
|
|
82
89
|
}
|
|
83
|
-
if (!this.
|
|
90
|
+
if (!this.AccSystemRefId) {
|
|
84
91
|
throw new Error('AccSystemAccountId is required.');
|
|
85
92
|
}
|
|
86
93
|
if (!this.AccountType) {
|
|
@@ -94,17 +101,17 @@ export class Account {
|
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
async save(
|
|
97
|
-
|
|
104
|
+
AccSystemRefId: string,
|
|
98
105
|
userId: string,
|
|
99
106
|
dbTransaction?: any,
|
|
100
107
|
): Promise<AccountModel> {
|
|
101
|
-
this.
|
|
108
|
+
this.AccSystemRefId = AccSystemRefId;
|
|
102
109
|
const data = await this.accountRepository.create(
|
|
103
110
|
{
|
|
104
111
|
AccountNo: this.AccountNo,
|
|
105
112
|
SystemCode: this.SystemCode,
|
|
106
113
|
AccSystemCode: this.AccSystemCode,
|
|
107
|
-
|
|
114
|
+
AccSystemRefId: this.AccSystemRefId,
|
|
108
115
|
Name: this.Name,
|
|
109
116
|
Description: this.Description,
|
|
110
117
|
AccountType: this.AccountType,
|
|
@@ -132,7 +139,7 @@ export class Account {
|
|
|
132
139
|
try {
|
|
133
140
|
const account = await this.accountRepository.findOne({
|
|
134
141
|
OwnerId: this.OwnerId,
|
|
135
|
-
|
|
142
|
+
AccSystemRefId: this.AccSystemRefId,
|
|
136
143
|
});
|
|
137
144
|
|
|
138
145
|
if (account) {
|
package/src/customer/customer.ts
CHANGED
|
@@ -1,36 +1,50 @@
|
|
|
1
|
-
import { AddressBase, PersonBase } from '@tomei/general';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import * as cuid from 'cuid';
|
|
1
|
+
import { AddressBase, PersonBase, RecordNotFoundError } from '@tomei/general';
|
|
2
|
+
import { FinanceCustomerModel } from './entities/customer.entity';
|
|
3
|
+
import { IFinanceCustomerRepository } from './interfaces/finance-customer.repository.interface';
|
|
5
4
|
|
|
6
5
|
export abstract class Customer extends PersonBase {
|
|
7
|
-
ObjectId: string; // Finance_Customer.CustomerId
|
|
8
|
-
ObjectName: string;
|
|
9
|
-
|
|
10
|
-
AccSystemCustomerId: string; //customer id return from accounting system
|
|
11
|
-
CustomerRefId: string | undefined; //CRM customer CustomerId
|
|
12
|
-
SystemCode: string;
|
|
13
|
-
AccSystemCode: string;
|
|
14
|
-
|
|
15
6
|
FullName: string;
|
|
16
7
|
IDNo: string;
|
|
17
8
|
IDType: string;
|
|
18
|
-
public Email: string;
|
|
19
9
|
ContactNo: string;
|
|
10
|
+
Email: string;
|
|
20
11
|
DefaultAddress: AddressBase;
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
financeCustomerRepository: IFinanceCustomerRepository;
|
|
14
|
+
|
|
15
|
+
CustomerId: string;
|
|
16
|
+
|
|
17
|
+
SystemCode: string;
|
|
18
|
+
AccSystemCode: string;
|
|
19
|
+
AccSystemCustomerId: string; //customer id return from accounting system
|
|
20
|
+
CustSystemCode: string;
|
|
21
|
+
CustSystemRefId: string;
|
|
23
22
|
|
|
24
23
|
constructor(
|
|
25
|
-
accountingSystem: IAccountSystem,
|
|
26
24
|
systemCode: string,
|
|
27
|
-
|
|
25
|
+
accSystemCode: string,
|
|
26
|
+
custSystemCode: string,
|
|
27
|
+
custSystemRefId: string,
|
|
28
28
|
) {
|
|
29
29
|
super();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const financeCustomerData = this.financeCustomerRepository.findOne({
|
|
31
|
+
where: {
|
|
32
|
+
SystemCode: systemCode,
|
|
33
|
+
AccSystemCode: accSystemCode,
|
|
34
|
+
AccSystemCustomerId: custSystemCode,
|
|
35
|
+
CustomerRefId: custSystemRefId,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (financeCustomerData) {
|
|
39
|
+
this.CustomerId = financeCustomerData.CustomerId;
|
|
40
|
+
this.AccSystemCode = accSystemCode;
|
|
41
|
+
this.AccSystemCustomerId = financeCustomerData.AccSystemCustomerId;
|
|
42
|
+
this.CustSystemCode = custSystemCode;
|
|
43
|
+
this.CustSystemRefId = custSystemRefId;
|
|
44
|
+
} else {
|
|
45
|
+
const notFoundError = new RecordNotFoundError('No Record Found');
|
|
46
|
+
throw notFoundError;
|
|
47
|
+
}
|
|
34
48
|
}
|
|
35
49
|
|
|
36
50
|
/*
|
|
@@ -63,33 +77,20 @@ export abstract class Customer extends PersonBase {
|
|
|
63
77
|
this.DefaultAddress = person.DefaultAddress;
|
|
64
78
|
}
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
async create() {
|
|
82
|
-
try {
|
|
83
|
-
this.AccSystemCustomerId = await this.accountingSystem.createCustomer({
|
|
84
|
-
FullName: this.FullName,
|
|
85
|
-
Email: this.Email,
|
|
86
|
-
ContractNo: this.ContactNo,
|
|
87
|
-
DefaultAddress: this.DefaultAddress,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this.ObjectId = cuid();
|
|
91
|
-
} catch (error) {
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
80
|
+
async save(
|
|
81
|
+
customerId: string,
|
|
82
|
+
dbTransaction?: any,
|
|
83
|
+
): Promise<FinanceCustomerModel> {
|
|
84
|
+
const data = await this.financeCustomerRepository.create(
|
|
85
|
+
{
|
|
86
|
+
CustomerId: customerId,
|
|
87
|
+
SystemCode: this.SystemCode,
|
|
88
|
+
AccSystemCode: this.SystemCode,
|
|
89
|
+
AccSystemCustomerId: this.AccSystemCustomerId,
|
|
90
|
+
CustomerRefId: this.CustSystemRefId,
|
|
91
|
+
},
|
|
92
|
+
dbTransaction,
|
|
93
|
+
);
|
|
94
|
+
return data;
|
|
94
95
|
}
|
|
95
96
|
}
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { InjectModel } from '@nestjs/sequelize';
|
|
2
|
+
import { BaseRepository } from '@tomei/general';
|
|
2
3
|
import { FinanceCustomerModel } from './entities/customer.entity';
|
|
3
4
|
import { IFinanceCustomerAttr } from './interfaces/finance-customer-attr.interface';
|
|
4
5
|
import { IFinanceCustomerRepository } from './interfaces/finance-customer.repository.interface';
|
|
5
6
|
|
|
6
7
|
export class FinanceCustomerRepository
|
|
7
|
-
|
|
8
|
+
extends BaseRepository<FinanceCustomerModel>
|
|
9
|
+
implements IFinanceCustomerRepository
|
|
8
10
|
{
|
|
9
11
|
constructor(
|
|
10
12
|
@InjectModel(FinanceCustomerModel)
|
|
11
|
-
private readonly
|
|
12
|
-
) {
|
|
13
|
+
private readonly financeCustomerModel: typeof FinanceCustomerModel,
|
|
14
|
+
) {
|
|
15
|
+
super(financeCustomerModel);
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
create(
|
|
15
19
|
data: IFinanceCustomerAttr | any,
|
|
16
20
|
options?: any,
|
|
17
21
|
): Promise<FinanceCustomerModel> | any {
|
|
18
|
-
return this.
|
|
22
|
+
return this.financeCustomerModel.create(data, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
findOne(options: any): Promise<FinanceCustomerModel> {
|
|
26
|
+
return this.financeCustomerModel.findOne(options);
|
|
19
27
|
}
|
|
20
28
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { IBaseRepository } from '@tomei/general';
|
|
2
|
+
import { FinanceCustomerModel } from '../entities/customer.entity';
|
|
3
|
+
|
|
4
|
+
export type IFinanceCustomerRepository = IBaseRepository<FinanceCustomerModel>;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as util from 'util';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import { ObjectBase } from '@tomei/general';
|
|
4
|
+
import {
|
|
5
|
+
Medias,
|
|
6
|
+
InternalMediaDto,
|
|
7
|
+
IMediasRepository,
|
|
8
|
+
CommonService as MediaCommonService,
|
|
9
|
+
MediaType,
|
|
10
|
+
} from '@tomei/media';
|
|
11
|
+
import { DocumentStatus, DocType } from 'src/enum';
|
|
12
|
+
import { DocumentRepository } from './document.repository';
|
|
13
|
+
import { IDocumentAttr } from './interfaces/document-attr.interface';
|
|
14
|
+
import { IAccountSystemEntity } from 'src/interfaces/account-system-entity.interface';
|
|
15
|
+
|
|
16
|
+
export class Document extends ObjectBase implements IAccountSystemEntity {
|
|
17
|
+
ObjectId: string;
|
|
18
|
+
ObjectName: string;
|
|
19
|
+
|
|
20
|
+
DocNo: string;
|
|
21
|
+
DocType: DocType;
|
|
22
|
+
DocDate: Date;
|
|
23
|
+
SystemCode: string;
|
|
24
|
+
Currency: string;
|
|
25
|
+
Amount: number;
|
|
26
|
+
Description: string;
|
|
27
|
+
IssuedById: string;
|
|
28
|
+
IssuedToId: string;
|
|
29
|
+
IssuedToType: string;
|
|
30
|
+
AccSystemCode: string;
|
|
31
|
+
PostedToAccSystemYN = 'N';
|
|
32
|
+
PostedById: string;
|
|
33
|
+
PostedDateTime: Date;
|
|
34
|
+
AccSystemRefId: string;
|
|
35
|
+
UseAccSystemDocYN: string;
|
|
36
|
+
private DocHTMLFilePath: string;
|
|
37
|
+
private DocPDFFilePath: string;
|
|
38
|
+
private Status: DocumentStatus;
|
|
39
|
+
|
|
40
|
+
documentRepository: DocumentRepository;
|
|
41
|
+
mediaRepository: IMediasRepository;
|
|
42
|
+
mediaCommonService: MediaCommonService;
|
|
43
|
+
|
|
44
|
+
public get InvoiceInHTML() {
|
|
45
|
+
return (async () => {
|
|
46
|
+
this.DocHTMLFilePath = './invoice-template/index.html';
|
|
47
|
+
const readFileContent = util.promisify(fs.readFile);
|
|
48
|
+
const htmlBuffer = await readFileContent(this.DocHTMLFilePath);
|
|
49
|
+
|
|
50
|
+
const htmlStream: Express.Multer.File = {
|
|
51
|
+
buffer: htmlBuffer,
|
|
52
|
+
fieldname: 'FileStream',
|
|
53
|
+
originalname: 'index.html',
|
|
54
|
+
mimetype: 'text/html',
|
|
55
|
+
size: htmlBuffer.length,
|
|
56
|
+
encoding: '8bit',
|
|
57
|
+
filename: 'sample-invoice.html',
|
|
58
|
+
destination: '',
|
|
59
|
+
path: '',
|
|
60
|
+
stream: null,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return htmlStream;
|
|
64
|
+
})();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public get InvoiceInPDF() {
|
|
68
|
+
return (async () => {
|
|
69
|
+
this.DocPDFFilePath = './invoice-template/sample-invoice.pdf';
|
|
70
|
+
const readFileContent = util.promisify(fs.readFile);
|
|
71
|
+
const pdfBuffer = await readFileContent(this.DocPDFFilePath);
|
|
72
|
+
|
|
73
|
+
const pdfStream: Express.Multer.File = {
|
|
74
|
+
buffer: pdfBuffer,
|
|
75
|
+
fieldname: 'FileStream',
|
|
76
|
+
originalname: 'sample-invoice.[df]',
|
|
77
|
+
mimetype: 'application/pdf',
|
|
78
|
+
size: pdfBuffer.length,
|
|
79
|
+
encoding: '8bit',
|
|
80
|
+
filename: 'sample-invoice.pdf',
|
|
81
|
+
destination: '',
|
|
82
|
+
path: '',
|
|
83
|
+
stream: null,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return pdfStream;
|
|
87
|
+
})();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get objectId(): string {
|
|
91
|
+
return this.ObjectId;
|
|
92
|
+
}
|
|
93
|
+
get objectName(): string {
|
|
94
|
+
return this.ObjectName;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
init(params: IDocumentAttr) {
|
|
98
|
+
this.DocNo = params.DocNo;
|
|
99
|
+
this.DocType = params.DocType;
|
|
100
|
+
this.DocDate = params.DocDate;
|
|
101
|
+
this.SystemCode = params.SystemCode;
|
|
102
|
+
this.Currency = params.Currency;
|
|
103
|
+
this.Amount = params.Amount;
|
|
104
|
+
this.Description = params.Description;
|
|
105
|
+
this.Status = params.Status;
|
|
106
|
+
this.IssuedById = params.IssuedById;
|
|
107
|
+
this.IssuedToId = params.IssuedToId;
|
|
108
|
+
this.IssuedToType = params.IssuedToType;
|
|
109
|
+
this.AccSystemCode = params.AccSystemCode;
|
|
110
|
+
this.PostedToAccSystemYN = params.PostedToAccSystemYN;
|
|
111
|
+
this.UseAccSystemDocYN = params.UseAccSystemDocYN;
|
|
112
|
+
this.DocPDFFilePath = params.DocPDFFilePath;
|
|
113
|
+
this.DocHTMLFilePath = params.DocHTMLFilePath;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async generateInvoice(userId?: string): Promise<void> {
|
|
117
|
+
const media: Medias = new Medias(
|
|
118
|
+
this.mediaRepository,
|
|
119
|
+
this.mediaCommonService,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const htmlPayload: InternalMediaDto = {
|
|
123
|
+
ObjectId: this.DocNo,
|
|
124
|
+
ObjectType: this.DocType,
|
|
125
|
+
Type: MediaType.Document,
|
|
126
|
+
FileName: `${this.DocType}-${this.DocNo}`,
|
|
127
|
+
FileStream: '',
|
|
128
|
+
FileExtension: 'HTML',
|
|
129
|
+
Title: `${this.DocType}-${this.DocNo}.html`,
|
|
130
|
+
Description: `HTML ${this.DocType}`,
|
|
131
|
+
IsEncryptedYN: 'N',
|
|
132
|
+
};
|
|
133
|
+
await media.postInternal(
|
|
134
|
+
await this.InvoiceInHTML,
|
|
135
|
+
htmlPayload,
|
|
136
|
+
userId ?? 'System',
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const pdfPayload: InternalMediaDto = {
|
|
140
|
+
ObjectId: this.DocNo,
|
|
141
|
+
ObjectType: this.DocType,
|
|
142
|
+
Type: MediaType.Document,
|
|
143
|
+
FileName: `${this.DocType}-${this.DocNo}`,
|
|
144
|
+
FileStream: '',
|
|
145
|
+
FileExtension: 'PDF',
|
|
146
|
+
Title: `${this.DocType}-${this.DocNo}.pdf`,
|
|
147
|
+
Description: `PDF ${this.DocType}`,
|
|
148
|
+
IsEncryptedYN: 'N',
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
await media.postInternal(
|
|
152
|
+
await this.InvoiceInPDF,
|
|
153
|
+
pdfPayload,
|
|
154
|
+
userId ?? 'System',
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
const document = await this.documentRepository.findOne({
|
|
159
|
+
where: {
|
|
160
|
+
DocNo: this.DocNo,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
document.DocHTMLFilePath = this.DocHTMLFilePath;
|
|
165
|
+
document.DocPDFFilePath = this.DocPDFFilePath;
|
|
166
|
+
await document.save();
|
|
167
|
+
} catch (err) {
|
|
168
|
+
console.log(err);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Column, DataType, HasMany, Model, Table } from 'sequelize-typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { DocType, DocumentStatus } from '../../enum';
|
|
3
3
|
import { DocumentItemModel } from './document-item.entity';
|
|
4
4
|
|
|
5
5
|
@Table({ tableName: 'finance_Document', timestamps: false })
|
|
@@ -15,7 +15,7 @@ export class DocumentModel extends Model {
|
|
|
15
15
|
allowNull: false,
|
|
16
16
|
type: DataType.STRING(30),
|
|
17
17
|
})
|
|
18
|
-
DocType:
|
|
18
|
+
DocType: DocType;
|
|
19
19
|
|
|
20
20
|
@Column({
|
|
21
21
|
allowNull: false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocType, DocumentStatus } from '../../enum';
|
|
2
2
|
|
|
3
3
|
export class IDocumentAttr {
|
|
4
4
|
DocNo: string;
|
|
5
|
-
DocType:
|
|
5
|
+
DocType: DocType;
|
|
6
6
|
DocDate: Date;
|
|
7
7
|
SystemCode: string;
|
|
8
8
|
Currency: string;
|
|
@@ -13,7 +13,7 @@ export class IDocumentAttr {
|
|
|
13
13
|
IssuedToId: string;
|
|
14
14
|
IssuedToType: string;
|
|
15
15
|
AccSystemCode: string;
|
|
16
|
-
|
|
16
|
+
PostedToAccSystemYN: string;
|
|
17
17
|
UseAccSystemDocYN: string;
|
|
18
18
|
DocPDFFilePath: string;
|
|
19
19
|
DocHTMLFilePath: string;
|
package/src/enum/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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 {
|
|
5
|
+
import { DocType } from './doc-type.enum';
|
|
6
6
|
import { DocumentStatus } from './document-status.enum';
|
|
7
7
|
|
|
8
8
|
export {
|
|
@@ -10,6 +10,6 @@ export {
|
|
|
10
10
|
PaymentType,
|
|
11
11
|
PaymentMethod,
|
|
12
12
|
TransactionTypeOptions,
|
|
13
|
-
|
|
13
|
+
DocType,
|
|
14
14
|
DocumentStatus,
|
|
15
15
|
};
|