asv-hlps 1.4.33 → 1.4.35
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/lib/cjs/auth/auth.js +7 -7
- package/lib/cjs/auth/authService.d.ts +1 -0
- package/lib/cjs/auth/authService.js +3 -0
- package/lib/cjs/buys/models/Buy.d.ts +4 -2
- package/lib/cjs/buys/models/BuyProduct.d.ts +29 -0
- package/lib/cjs/buys/models/BuyProduct.js +2 -0
- package/lib/esm/auth/auth.js +7 -7
- package/lib/esm/auth/authService.d.ts +1 -0
- package/lib/esm/auth/authService.js +3 -0
- package/lib/esm/buys/hlpBuy.d.ts +9 -0
- package/lib/esm/buys/hlpBuy.js +23 -0
- package/lib/esm/buys/models/Buy.d.ts +4 -2
- package/lib/esm/buys/models/BuyProduct.d.ts +29 -0
- package/lib/esm/buys/models/BuyProduct.js +1 -0
- package/package.json +1 -1
package/lib/cjs/auth/auth.js
CHANGED
|
@@ -6,7 +6,7 @@ const arraySome = (arr1, arr2) => {
|
|
|
6
6
|
return arr1.some(x => arr2.includes(x));
|
|
7
7
|
};
|
|
8
8
|
const getAuth = (authUser, authSte, param) => {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
10
10
|
if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags.length)) {
|
|
11
11
|
const tags = [];
|
|
12
12
|
for (const tag of authUser.tags) {
|
|
@@ -28,14 +28,14 @@ const getAuth = (authUser, authSte, param) => {
|
|
|
28
28
|
// ------ staff ------
|
|
29
29
|
if (param === null || param === void 0 ? void 0 : param.staff) {
|
|
30
30
|
if (((_c = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _c === void 0 ? void 0 : _c.length) > 0 &&
|
|
31
|
-
(0, user_1.isStaffSte)(authSte, authUser.ste.name) &&
|
|
31
|
+
(0, user_1.isStaffSte)(authSte, (_d = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _d === void 0 ? void 0 : _d.name) &&
|
|
32
32
|
["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
// ------ client ------
|
|
37
37
|
if (param === null || param === void 0 ? void 0 : param.client) {
|
|
38
|
-
if (!(0, user_1.isStaffSte)(authSte, authUser.ste.name)) {
|
|
38
|
+
if (!(0, user_1.isStaffSte)(authSte, (_e = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _e === void 0 ? void 0 : _e.name)) {
|
|
39
39
|
if (param.client.roles &&
|
|
40
40
|
!param.client.steGrps &&
|
|
41
41
|
param.client.roles.length > 0 &&
|
|
@@ -48,7 +48,7 @@ const getAuth = (authUser, authSte, param) => {
|
|
|
48
48
|
param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
|
-
if (((
|
|
51
|
+
if (((_f = param === null || param === void 0 ? void 0 : param.client.roles) === null || _f === void 0 ? void 0 : _f.length) &&
|
|
52
52
|
(param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
|
|
53
53
|
["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
|
|
54
54
|
(param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())) {
|
|
@@ -57,13 +57,13 @@ const getAuth = (authUser, authSte, param) => {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
// ------ ste grps ------
|
|
60
|
-
if (((
|
|
60
|
+
if (((_g = param === null || param === void 0 ? void 0 : param.steGrps) === null || _g === void 0 ? void 0 : _g.length) > 0 && param.steGrps.includes((_h = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _h === void 0 ? void 0 : _h.grp.code.toLowerCase())) {
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
|
-
if (((
|
|
63
|
+
if (((_j = param === null || param === void 0 ? void 0 : param.grps) === null || _j === void 0 ? void 0 : _j.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
|
-
if (((
|
|
66
|
+
if (((_k = param === null || param === void 0 ? void 0 : param.steNames) === null || _k === void 0 ? void 0 : _k.length) > 0 && param.steNames.includes((_l = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _l === void 0 ? void 0 : _l.name.toLowerCase())) {
|
|
67
67
|
return true;
|
|
68
68
|
}
|
|
69
69
|
return false;
|
|
@@ -16,5 +16,6 @@ export declare class AuthService {
|
|
|
16
16
|
authUser: () => any;
|
|
17
17
|
getAuth: (param?: AuthParam) => boolean;
|
|
18
18
|
getAuthWithClient: ({ tag, roles, client }: AuthParam) => boolean;
|
|
19
|
+
getAuthRoles: (roles: string[], rolesClient: string[], tag?: string) => boolean;
|
|
19
20
|
}
|
|
20
21
|
export {};
|
|
@@ -75,6 +75,9 @@ class AuthService {
|
|
|
75
75
|
this.getAuthWithClient = ({ tag, roles, client }) => {
|
|
76
76
|
return this.getAuth({ tag, roles }) || this.getAuth({ tag, client });
|
|
77
77
|
};
|
|
78
|
+
this.getAuthRoles = (roles, rolesClient, tag) => {
|
|
79
|
+
return this.getAuth({ tag, roles: roles, client: { roles: rolesClient } });
|
|
80
|
+
};
|
|
78
81
|
this.tokenKey = tokenkey;
|
|
79
82
|
this.authStes = authStes;
|
|
80
83
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import User from "../../users/models/User";
|
|
2
|
-
import
|
|
2
|
+
import { BuyProduct } from "./BuyProduct";
|
|
3
3
|
export default interface Buy {
|
|
4
4
|
id: number;
|
|
5
5
|
author?: User;
|
|
6
6
|
buyDate: any;
|
|
7
|
-
buyProducts?:
|
|
7
|
+
buyProducts?: BuyProduct[];
|
|
8
8
|
comment: string;
|
|
9
9
|
createdAt: any;
|
|
10
10
|
isReceipt: boolean;
|
|
@@ -16,4 +16,6 @@ export default interface Buy {
|
|
|
16
16
|
totalAmountTva?: number;
|
|
17
17
|
totalQtity?: number;
|
|
18
18
|
get getQtity(): void;
|
|
19
|
+
shippingCosts?: number;
|
|
20
|
+
otherCosts?: number;
|
|
19
21
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ProductDepot from "../../markets/products/models/ProductDepot";
|
|
2
|
+
import Product from "../../products/models/Product";
|
|
3
|
+
import Buy from "./Buy";
|
|
4
|
+
export interface BuyProduct {
|
|
5
|
+
amountBuyPrice: number;
|
|
6
|
+
archiverBuyId: number;
|
|
7
|
+
buy: Buy;
|
|
8
|
+
buyPrice: number;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
depot: ProductDepot;
|
|
11
|
+
expirationDate: Date;
|
|
12
|
+
id: number;
|
|
13
|
+
isArchived: boolean;
|
|
14
|
+
lot: string;
|
|
15
|
+
product: Product;
|
|
16
|
+
productId: number;
|
|
17
|
+
qtityDlvr: number;
|
|
18
|
+
qtityFree: number;
|
|
19
|
+
qtityMiss: number;
|
|
20
|
+
qtityOdr: number;
|
|
21
|
+
qtityPackDlvr: number;
|
|
22
|
+
qtityPackOdr: number;
|
|
23
|
+
qtityUnit: number;
|
|
24
|
+
qtityUnitDlvr: number;
|
|
25
|
+
qtityUnitOdr: number;
|
|
26
|
+
unitCost: number;
|
|
27
|
+
unitCostPrice: number;
|
|
28
|
+
unitPrice: number;
|
|
29
|
+
}
|
package/lib/esm/auth/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ const arraySome = (arr1, arr2) => {
|
|
|
3
3
|
return arr1.some(x => arr2.includes(x));
|
|
4
4
|
};
|
|
5
5
|
const getAuth = (authUser, authSte, param) => {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
7
7
|
if ((param === null || param === void 0 ? void 0 : param.tag) && (authUser === null || authUser === void 0 ? void 0 : authUser.tags.length)) {
|
|
8
8
|
const tags = [];
|
|
9
9
|
for (const tag of authUser.tags) {
|
|
@@ -25,14 +25,14 @@ const getAuth = (authUser, authSte, param) => {
|
|
|
25
25
|
// ------ staff ------
|
|
26
26
|
if (param === null || param === void 0 ? void 0 : param.staff) {
|
|
27
27
|
if (((_c = param === null || param === void 0 ? void 0 : param.staff.roles) === null || _c === void 0 ? void 0 : _c.length) > 0 &&
|
|
28
|
-
isStaffSte(authSte, authUser.ste.name) &&
|
|
28
|
+
isStaffSte(authSte, (_d = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _d === void 0 ? void 0 : _d.name) &&
|
|
29
29
|
["sadm", ...param.roles].includes(authUser.role.code.toLowerCase())) {
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
// ------ client ------
|
|
34
34
|
if (param === null || param === void 0 ? void 0 : param.client) {
|
|
35
|
-
if (!isStaffSte(authSte, authUser.ste.name)) {
|
|
35
|
+
if (!isStaffSte(authSte, (_e = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _e === void 0 ? void 0 : _e.name)) {
|
|
36
36
|
if (param.client.roles &&
|
|
37
37
|
!param.client.steGrps &&
|
|
38
38
|
param.client.roles.length > 0 &&
|
|
@@ -45,7 +45,7 @@ const getAuth = (authUser, authSte, param) => {
|
|
|
45
45
|
param.client.steGrps.includes(authUser.ste.grp.code.toLowerCase())) {
|
|
46
46
|
return true;
|
|
47
47
|
}
|
|
48
|
-
if (((
|
|
48
|
+
if (((_f = param === null || param === void 0 ? void 0 : param.client.roles) === null || _f === void 0 ? void 0 : _f.length) &&
|
|
49
49
|
(param === null || param === void 0 ? void 0 : param.client.steGrps.length) &&
|
|
50
50
|
["ceo", ...param === null || param === void 0 ? void 0 : param.client.roles].includes(authUser.role.code.toLowerCase()) &&
|
|
51
51
|
(param === null || param === void 0 ? void 0 : param.client.steGrps).includes(authUser.ste.grp.code.toLowerCase())) {
|
|
@@ -54,13 +54,13 @@ const getAuth = (authUser, authSte, param) => {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
// ------ ste grps ------
|
|
57
|
-
if (((
|
|
57
|
+
if (((_g = param === null || param === void 0 ? void 0 : param.steGrps) === null || _g === void 0 ? void 0 : _g.length) > 0 && param.steGrps.includes((_h = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _h === void 0 ? void 0 : _h.grp.code.toLowerCase())) {
|
|
58
58
|
return true;
|
|
59
59
|
}
|
|
60
|
-
if (((
|
|
60
|
+
if (((_j = param === null || param === void 0 ? void 0 : param.grps) === null || _j === void 0 ? void 0 : _j.length) && param.grps.includes(authUser.grp.code.toLowerCase())) {
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
|
-
if (((
|
|
63
|
+
if (((_k = param === null || param === void 0 ? void 0 : param.steNames) === null || _k === void 0 ? void 0 : _k.length) > 0 && param.steNames.includes((_l = authUser === null || authUser === void 0 ? void 0 : authUser.ste) === null || _l === void 0 ? void 0 : _l.name.toLowerCase())) {
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
66
|
return false;
|
|
@@ -16,5 +16,6 @@ export declare class AuthService {
|
|
|
16
16
|
authUser: () => any;
|
|
17
17
|
getAuth: (param?: AuthParam) => boolean;
|
|
18
18
|
getAuthWithClient: ({ tag, roles, client }: AuthParam) => boolean;
|
|
19
|
+
getAuthRoles: (roles: string[], rolesClient: string[], tag?: string) => boolean;
|
|
19
20
|
}
|
|
20
21
|
export {};
|
|
@@ -69,6 +69,9 @@ export class AuthService {
|
|
|
69
69
|
this.getAuthWithClient = ({ tag, roles, client }) => {
|
|
70
70
|
return this.getAuth({ tag, roles }) || this.getAuth({ tag, client });
|
|
71
71
|
};
|
|
72
|
+
this.getAuthRoles = (roles, rolesClient, tag) => {
|
|
73
|
+
return this.getAuth({ tag, roles: roles, client: { roles: rolesClient } });
|
|
74
|
+
};
|
|
72
75
|
this.tokenKey = tokenkey;
|
|
73
76
|
this.authStes = authStes;
|
|
74
77
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Buy from "./models/Buy";
|
|
2
|
+
declare class HlpBuy {
|
|
3
|
+
getTotalCostPriceOnBuy: (buy: Buy | any) => void;
|
|
4
|
+
totalAmountOnBuy: (buy: Buy) => BuyProduct;
|
|
5
|
+
totalAmountAllIncludedOnBuy: (buy: Buy) => any;
|
|
6
|
+
totalAmountAllIncludedOnListBuy: (buys: Buy[]) => number;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: HlpBuy;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class HlpBuy {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.getTotalCostPriceOnBuy = (buy) => {
|
|
4
|
+
// return buy.buyProducts.reduce((prev, curr) => {
|
|
5
|
+
// return Math.round(prev + curr.qtityDlvr * curr.unitPrice);
|
|
6
|
+
// }, 0);
|
|
7
|
+
};
|
|
8
|
+
this.totalAmountOnBuy = (buy) => {
|
|
9
|
+
return ((buy === null || buy === void 0 ? void 0 : buy.buyProducts) || []).reduce((prev, curr) => {
|
|
10
|
+
return Math.round(prev + +curr.amountBuyPrice);
|
|
11
|
+
}, 0);
|
|
12
|
+
};
|
|
13
|
+
this.totalAmountAllIncludedOnBuy = (buy) => {
|
|
14
|
+
return this.totalAmountOnBuy(buy) + +(buy === null || buy === void 0 ? void 0 : buy.shippingCosts) || 0 + +(buy === null || buy === void 0 ? void 0 : buy.otherCosts) || 0;
|
|
15
|
+
};
|
|
16
|
+
this.totalAmountAllIncludedOnListBuy = (buys) => {
|
|
17
|
+
return (buys || []).reduce((prev, curr) => {
|
|
18
|
+
return Math.round(prev + this.totalAmountAllIncludedOnBuy(curr));
|
|
19
|
+
}, 0);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default new HlpBuy();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import User from "../../users/models/User";
|
|
2
|
-
import
|
|
2
|
+
import { BuyProduct } from "./BuyProduct";
|
|
3
3
|
export default interface Buy {
|
|
4
4
|
id: number;
|
|
5
5
|
author?: User;
|
|
6
6
|
buyDate: any;
|
|
7
|
-
buyProducts?:
|
|
7
|
+
buyProducts?: BuyProduct[];
|
|
8
8
|
comment: string;
|
|
9
9
|
createdAt: any;
|
|
10
10
|
isReceipt: boolean;
|
|
@@ -16,4 +16,6 @@ export default interface Buy {
|
|
|
16
16
|
totalAmountTva?: number;
|
|
17
17
|
totalQtity?: number;
|
|
18
18
|
get getQtity(): void;
|
|
19
|
+
shippingCosts?: number;
|
|
20
|
+
otherCosts?: number;
|
|
19
21
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ProductDepot from "../../markets/products/models/ProductDepot";
|
|
2
|
+
import Product from "../../products/models/Product";
|
|
3
|
+
import Buy from "./Buy";
|
|
4
|
+
export interface BuyProduct {
|
|
5
|
+
amountBuyPrice: number;
|
|
6
|
+
archiverBuyId: number;
|
|
7
|
+
buy: Buy;
|
|
8
|
+
buyPrice: number;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
depot: ProductDepot;
|
|
11
|
+
expirationDate: Date;
|
|
12
|
+
id: number;
|
|
13
|
+
isArchived: boolean;
|
|
14
|
+
lot: string;
|
|
15
|
+
product: Product;
|
|
16
|
+
productId: number;
|
|
17
|
+
qtityDlvr: number;
|
|
18
|
+
qtityFree: number;
|
|
19
|
+
qtityMiss: number;
|
|
20
|
+
qtityOdr: number;
|
|
21
|
+
qtityPackDlvr: number;
|
|
22
|
+
qtityPackOdr: number;
|
|
23
|
+
qtityUnit: number;
|
|
24
|
+
qtityUnitDlvr: number;
|
|
25
|
+
qtityUnitOdr: number;
|
|
26
|
+
unitCost: number;
|
|
27
|
+
unitCostPrice: number;
|
|
28
|
+
unitPrice: number;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|