asv-hlps 1.4.34 → 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.
@@ -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 BuyItem from "./BuyItem";
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?: BuyItem[];
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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 BuyItem from "./BuyItem";
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?: BuyItem[];
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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.34",
3
+ "version": "1.4.35",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",