@tomei/finance 0.6.28 → 0.6.29
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/document/document.js +7 -4
- package/dist/document/document.js.map +1 -1
- package/dist/helpers/login-user.d.ts +11 -0
- package/dist/helpers/login-user.js +26 -0
- package/dist/helpers/login-user.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/document/document.ts +7 -5
- package/src/helpers/login-user.ts +33 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomei/finance",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.29",
|
|
4
4
|
"description": "NestJS package for finance module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"@nestjs/sequelize": "^9.0.0",
|
|
37
37
|
"@nestjs/swagger": "^6.1.4",
|
|
38
38
|
"@tomei/general": "^0.5.1",
|
|
39
|
-
"@tomei/media": "^0.6.
|
|
39
|
+
"@tomei/media": "^0.6.12",
|
|
40
40
|
"axios": "^1.6.0",
|
|
41
|
-
"@tomei/activity-history": "^0.2.
|
|
41
|
+
"@tomei/activity-history": "^0.2.6",
|
|
42
42
|
"@tomei/config": "^0.3.4",
|
|
43
|
-
"@tomei/sso": "^0.
|
|
43
|
+
"@tomei/sso": "^0.15.2",
|
|
44
44
|
"class-transformer": "^0.5.1",
|
|
45
45
|
"class-validator": "^0.14.0",
|
|
46
46
|
"cuid": "^3.0.0",
|
package/src/document/document.ts
CHANGED
|
@@ -24,6 +24,7 @@ import DocumentItemModel from '../models/document-item.entity';
|
|
|
24
24
|
import { ClassError, LoginUserBase } from '@tomei/general';
|
|
25
25
|
import { ApplicationConfig } from '@tomei/config';
|
|
26
26
|
import { Op } from 'sequelize';
|
|
27
|
+
import { LoginUser } from 'src/helpers/login-user';
|
|
27
28
|
|
|
28
29
|
export default class Document extends AccountSystemEntity {
|
|
29
30
|
DocNo = 'New';
|
|
@@ -829,12 +830,13 @@ export default class Document extends AccountSystemEntity {
|
|
|
829
830
|
Description: `HTML ${this.DocType}`,
|
|
830
831
|
IsEncryptedYN: 'N',
|
|
831
832
|
};
|
|
833
|
+
const user = new LoginUser(userId ?? 'System', null, null);
|
|
832
834
|
|
|
833
835
|
/* create HTML media of the generated HTML */
|
|
834
836
|
const HTMLInvoiceMedia = await media.postInternal(
|
|
835
837
|
await Document.DEFAULT_INVOICE_TEMPLATE_HTML(),
|
|
836
838
|
htmlPayload,
|
|
837
|
-
|
|
839
|
+
user as any,
|
|
838
840
|
dbTransaction,
|
|
839
841
|
);
|
|
840
842
|
|
|
@@ -855,7 +857,7 @@ export default class Document extends AccountSystemEntity {
|
|
|
855
857
|
const PDFInvoiceMedia = await media.postInternal(
|
|
856
858
|
await this.DEFAULT_INVOICE_TEMPLATE_PDF(customer),
|
|
857
859
|
pdfPayload,
|
|
858
|
-
|
|
860
|
+
user as any,
|
|
859
861
|
dbTransaction,
|
|
860
862
|
);
|
|
861
863
|
|
|
@@ -904,7 +906,7 @@ export default class Document extends AccountSystemEntity {
|
|
|
904
906
|
PDFMedia: MediasModel;
|
|
905
907
|
}> {
|
|
906
908
|
const media: Medias = new Medias(this.mediaCommonService);
|
|
907
|
-
|
|
909
|
+
const user = new LoginUser(userId ?? 'System', null, null);
|
|
908
910
|
/* insert FileStream on htmlPayload */
|
|
909
911
|
const htmlPayload: InternalMediaDto = {
|
|
910
912
|
ObjectId: this.DocNo,
|
|
@@ -922,7 +924,7 @@ export default class Document extends AccountSystemEntity {
|
|
|
922
924
|
const HTMLInvoiceMedia = await media.postInternal(
|
|
923
925
|
await Document.DEFAULT_INVOICE_TEMPLATE_HTML(),
|
|
924
926
|
htmlPayload,
|
|
925
|
-
|
|
927
|
+
user as any,
|
|
926
928
|
transaction,
|
|
927
929
|
);
|
|
928
930
|
|
|
@@ -943,7 +945,7 @@ export default class Document extends AccountSystemEntity {
|
|
|
943
945
|
const PDFInvoiceMedia = await media.postInternal(
|
|
944
946
|
await this.DEFAULT_RECEIPT_TEMPLATE_PDF(customer),
|
|
945
947
|
pdfPayload,
|
|
946
|
-
|
|
948
|
+
user as any,
|
|
947
949
|
transaction,
|
|
948
950
|
);
|
|
949
951
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LoginUserBase } from '@tomei/general';
|
|
2
|
+
|
|
3
|
+
export class LoginUser extends LoginUserBase {
|
|
4
|
+
ObjectId: string;
|
|
5
|
+
ObjectName: string;
|
|
6
|
+
TableName: string;
|
|
7
|
+
Roles: string[];
|
|
8
|
+
Privileges: string[];
|
|
9
|
+
|
|
10
|
+
checkPrivileges(
|
|
11
|
+
SystemCode: string,
|
|
12
|
+
PrivilegeName: string,
|
|
13
|
+
): boolean | Promise<boolean> {
|
|
14
|
+
if (this.Privileges.includes(PrivilegeName)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
CheckRole(SystemCode: string, RoleName: string): boolean | Promise<boolean> {
|
|
21
|
+
if (this.Roles.includes(RoleName)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
constructor(objectId: string, objectName: string, tableName: string) {
|
|
28
|
+
super();
|
|
29
|
+
this.ObjectId = objectId;
|
|
30
|
+
this.ObjectName = objectName;
|
|
31
|
+
this.TableName = tableName;
|
|
32
|
+
}
|
|
33
|
+
}
|