@nomalism-com/api 0.8.289 → 0.8.291

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/index.d.ts CHANGED
@@ -120,8 +120,8 @@ export * as StartDocumentHeaderLastUpdate from './modules/supply/startDocumentHe
120
120
  export * as ErrorHandler from './modules/integration/errorHandler';
121
121
  export * as Persona from './modules/user/persona';
122
122
  export * as ProjectInfo from './modules/integration/projectInfo';
123
- export * as Order from './modules/supply/order';
124
- export * as Purchase from './modules/supply/purchase';
125
- export * as MaterialEntrance from './modules/supply/materialEntrance';
123
+ export * as Order from './modules/document/order';
124
+ export * as Purchase from './modules/document/purchase';
125
+ export * as MaterialEntrance from './modules/document/materialEntrance';
126
126
  export default api;
127
127
  export { shared };
package/dist/index.js CHANGED
@@ -152,7 +152,7 @@ exports.StartDocumentHeaderLastUpdate = __importStar(require("./modules/supply/s
152
152
  exports.ErrorHandler = __importStar(require("./modules/integration/errorHandler"));
153
153
  exports.Persona = __importStar(require("./modules/user/persona"));
154
154
  exports.ProjectInfo = __importStar(require("./modules/integration/projectInfo"));
155
- exports.Order = __importStar(require("./modules/supply/order"));
156
- exports.Purchase = __importStar(require("./modules/supply/purchase"));
157
- exports.MaterialEntrance = __importStar(require("./modules/supply/materialEntrance"));
155
+ exports.Order = __importStar(require("./modules/document/order"));
156
+ exports.Purchase = __importStar(require("./modules/document/purchase"));
157
+ exports.MaterialEntrance = __importStar(require("./modules/document/materialEntrance"));
158
158
  exports.default = client_1.default;
@@ -1,4 +1,5 @@
1
1
  import { shared, Promotion as Entity } from '@nomalism-com/types';
2
+ import { IProductPromotionVirtuals } from './product';
2
3
  export import IFindRequest = Entity.IFindRequest;
3
4
  export import IFindResponse = Entity.IFindResponse;
4
5
  export import IFindPaginatedRequest = Entity.IFindPaginatedRequest;
@@ -10,4 +11,5 @@ export import IEntity = Entity.Entity;
10
11
  export import IUpdateRequest = Entity.IUpdateRequest;
11
12
  export type IPaginationResponse = shared.IPaginationResponse<Entity.IFindResponse>;
12
13
  export declare const route: string;
14
+ export declare const getBestDiscount: (promotions: IProductPromotionVirtuals[], discount?: number, location_id?: string, client_id?: string) => number;
13
15
  export declare const find: (selector: Entity.IFindRequest) => Promise<Entity.IFindResponse[]>, findPaginated: (selector: Entity.IFindPaginatedRequest) => Promise<Entity.IFindWithPaginationResponse>, findMinified: (params?: shared.IFindMinifiedRequest | undefined) => Promise<shared.IFindMinifiedResponse[]>, findByOwnerId: (params: shared.IFindByOwnerIdRequest) => Promise<Entity.IFindByOwnerIdResponse[]>, findById: (selector: shared.IFindByIdRequest) => Promise<Entity.IFindByIdResponse | null>, create: (data: Entity.ICreateRequest) => Promise<import("@nomalism-com/types/dist/shared/entities").Promotion>, update: (selector: shared.IFindByIdRequest, data: Entity.IUpdateRequest) => Promise<import("@nomalism-com/types/dist/shared/entities").Promotion | null>, deleteOne: (selector: shared.IFindByIdRequest) => Promise<import("@nomalism-com/types/dist/shared/entities").Promotion | null>;
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.deleteOne = exports.update = exports.create = exports.findById = exports.findByOwnerId = exports.findMinified = exports.findPaginated = exports.find = exports.route = void 0;
42
+ exports.deleteOne = exports.update = exports.create = exports.findById = exports.findByOwnerId = exports.findMinified = exports.findPaginated = exports.find = exports.getBestDiscount = exports.route = void 0;
43
43
  var client_1 = __importDefault(require("../../shared/client"));
44
44
  var _1 = require(".");
45
45
  exports.route = "".concat(_1.serviceHostname).concat(_1.serviceAuthPath, "promotion/");
@@ -137,4 +137,25 @@ var repository = {
137
137
  });
138
138
  }); },
139
139
  };
140
+ var getBestDiscount = function (promotions, discount, location_id, client_id) {
141
+ var highestPromoDiscount = promotions
142
+ .filter(function (promotion) {
143
+ return promotion.exclusive_to_location_id
144
+ ? promotion.exclusive_to_location_id === location_id
145
+ : true;
146
+ })
147
+ .filter(function (promotion) {
148
+ return promotion.exclusive_to_client_id
149
+ ? promotion.exclusive_to_client_id === client_id
150
+ : true;
151
+ })
152
+ .reduce(function (highest, promotion) {
153
+ return promotion.discount > highest ? promotion.discount : highest;
154
+ }, 0);
155
+ var clientDiscount = discount || 0;
156
+ return highestPromoDiscount > clientDiscount
157
+ ? highestPromoDiscount
158
+ : clientDiscount;
159
+ };
160
+ exports.getBestDiscount = getBestDiscount;
140
161
  exports.find = repository.find, exports.findPaginated = repository.findPaginated, exports.findMinified = repository.findMinified, exports.findByOwnerId = repository.findByOwnerId, exports.findById = repository.findById, exports.create = repository.create, exports.update = repository.update, exports.deleteOne = repository.deleteOne;
@@ -2,6 +2,7 @@ import { shared, PreSale as Entity } from '@nomalism-com/types';
2
2
  export import IFindResponse = Entity.IFindResponse;
3
3
  export import IFindResponseWithQuantityOfPlots = Entity.IFindResponseWithQuantityOfPlots;
4
4
  export import ICreateRequest = Entity.ICreateRequest;
5
+ export import IProductMinified = Entity.IProductMinified;
5
6
  export import IEntityExtended = Entity.IEntityExtended;
6
7
  export import IUpdateRequest = Entity.IUpdateRequest;
7
8
  export import IRemovePlotOrPreSaleProductRequest = Entity.IRemovePlotOrPreSaleProductRequest;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "typescript",
10
10
  "helper"
11
11
  ],
12
- "version": "0.8.289",
12
+ "version": "0.8.291",
13
13
  "main": "dist/index.js",
14
14
  "types": "./dist/index.d.ts",
15
15
  "files": [
@@ -47,7 +47,7 @@
47
47
  "typescript": "^5.0.4"
48
48
  },
49
49
  "dependencies": {
50
- "@nomalism-com/types": "^0.9.377",
50
+ "@nomalism-com/types": "^0.9.379",
51
51
  "axios": "^0.27.2"
52
52
  }
53
53
  }
File without changes
File without changes
File without changes
File without changes