hvp-shared 6.45.0 → 6.46.0

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.
@@ -25,8 +25,6 @@ export declare enum PricePolicy {
25
25
  EXT_COST = "EXT_COST",
26
26
  /** Internal services (priced by market study / competition) */
27
27
  COMP_SVC = "COMP_SVC",
28
- /** Diagnostic tests (TBD — no formula yet) */
29
- TEST = "TEST",
30
28
  /** Individual formula per item */
31
29
  SPECIAL = "SPECIAL",
32
30
  /** Fixed manual price (no formula) */
@@ -37,8 +37,6 @@ var PricePolicy;
37
37
  PricePolicy["EXT_COST"] = "EXT_COST";
38
38
  /** Internal services (priced by market study / competition) */
39
39
  PricePolicy["COMP_SVC"] = "COMP_SVC";
40
- /** Diagnostic tests (TBD — no formula yet) */
41
- PricePolicy["TEST"] = "TEST";
42
40
  /** Individual formula per item */
43
41
  PricePolicy["SPECIAL"] = "SPECIAL";
44
42
  /** Fixed manual price (no formula) */
@@ -65,7 +63,6 @@ exports.PRICE_POLICY_LABELS = {
65
63
  [PricePolicy.COST]: 'Insumos / Artículos (por costo)',
66
64
  [PricePolicy.EXT_COST]: 'Servicios externos',
67
65
  [PricePolicy.COMP_SVC]: 'Servicios internos (estudio de mercado)',
68
- [PricePolicy.TEST]: 'Pruebas diagnósticas',
69
66
  [PricePolicy.SPECIAL]: 'Fórmula individual',
70
67
  [PricePolicy.MANUAL]: 'Precio manual',
71
68
  [PricePolicy.NONE]: 'No se vende',
@@ -105,7 +102,6 @@ exports.AUTO_TIER_POLICIES = [
105
102
  /** Policies that have no formula (recommendedPrice = null) */
106
103
  exports.NO_FORMULA_POLICIES = [
107
104
  PricePolicy.COMP_SVC,
108
- PricePolicy.TEST,
109
105
  PricePolicy.SPECIAL,
110
106
  PricePolicy.MANUAL,
111
107
  PricePolicy.NONE,
@@ -139,7 +135,7 @@ exports.ALLOWED_POLICIES_BY_SECTION = {
139
135
  [qvet_catalog_1.QVET_SECTIONS.FARMACIA_INTERNA]: [PricePolicy.PHARM, PricePolicy.PHARM_FRAC, PricePolicy.COST_ML, PricePolicy.SPECIAL, PricePolicy.MANUAL],
140
136
  [qvet_catalog_1.QVET_SECTIONS.INSUMOS_MEDICOS]: [PricePolicy.COST, PricePolicy.SPECIAL, PricePolicy.MANUAL],
141
137
  [qvet_catalog_1.QVET_SECTIONS.OTROS_ARTICULOS]: [PricePolicy.COST, PricePolicy.SPECIAL, PricePolicy.MANUAL],
142
- [qvet_catalog_1.QVET_SECTIONS.SERVICIOS_MEDICOS]: [PricePolicy.COMP_SVC, PricePolicy.TEST, PricePolicy.SPECIAL, PricePolicy.MANUAL],
138
+ [qvet_catalog_1.QVET_SECTIONS.SERVICIOS_MEDICOS]: [PricePolicy.COMP_SVC, PricePolicy.SPECIAL, PricePolicy.MANUAL],
143
139
  [qvet_catalog_1.QVET_SECTIONS.OTROS_SERVICIOS]: [PricePolicy.COMP_SVC, PricePolicy.SPECIAL, PricePolicy.MANUAL],
144
140
  [qvet_catalog_1.QVET_SECTIONS.SERVICIOS_EXTERNOS]: [PricePolicy.EXT_COST, PricePolicy.SPECIAL, PricePolicy.MANUAL],
145
141
  };
@@ -234,6 +230,6 @@ function calculateRecommendedPricePVP(params) {
234
230
  return null;
235
231
  const priceBI = unitPurchasePriceBI * factor;
236
232
  const pricePVP = priceBI * (1 + vatSalePercent / 100);
237
- // Round to 2 decimals
238
- return Math.round(pricePVP * 100) / 100;
233
+ // Round to nearest multiple of 5
234
+ return Math.round(pricePVP / 5) * 5;
239
235
  }
@@ -100,7 +100,6 @@ describe('getMarkupFactor', () => {
100
100
  });
101
101
  it('should return null for policies without a formula', () => {
102
102
  expect((0, pricing_constants_1.getMarkupFactor)(pricing_constants_1.PricePolicy.COMP_SVC, pricing_constants_1.PricingTier.HIGH_MARGIN)).toBeNull();
103
- expect((0, pricing_constants_1.getMarkupFactor)(pricing_constants_1.PricePolicy.TEST, pricing_constants_1.PricingTier.HIGH_MARGIN)).toBeNull();
104
103
  expect((0, pricing_constants_1.getMarkupFactor)(pricing_constants_1.PricePolicy.SPECIAL, pricing_constants_1.PricingTier.HIGH_MARGIN)).toBeNull();
105
104
  expect((0, pricing_constants_1.getMarkupFactor)(pricing_constants_1.PricePolicy.MANUAL, pricing_constants_1.PricingTier.HIGH_MARGIN)).toBeNull();
106
105
  expect((0, pricing_constants_1.getMarkupFactor)(pricing_constants_1.PricePolicy.NONE, pricing_constants_1.PricingTier.HIGH_MARGIN)).toBeNull();
@@ -198,45 +197,45 @@ describe('getDefaultPricePolicy', () => {
198
197
  // calculateRecommendedPricePVP
199
198
  // =============================================================================
200
199
  describe('calculateRecommendedPricePVP', () => {
201
- it('should calculate price for PHARM HIGH_MARGIN', () => {
202
- // $100 cost * 2.00 factor * 1.16 VAT = $232.00
200
+ it('should calculate price for PHARM HIGH_MARGIN (rounded to multiple of 5)', () => {
201
+ // $100 cost * 2.00 factor * 1.16 VAT = $232.00 → $230
203
202
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
204
203
  pricePolicy: pricing_constants_1.PricePolicy.PHARM,
205
204
  pricingTier: pricing_constants_1.PricingTier.HIGH_MARGIN,
206
205
  unitPurchasePriceBI: 100,
207
206
  vatSalePercent: 16,
208
207
  });
209
- expect(result).toBe(232.00);
208
+ expect(result).toBe(230);
210
209
  });
211
- it('should calculate price for COST_ML LOW_MARGIN', () => {
212
- // $60/ml cost * 3.00 factor * 1.16 VAT = $208.80
210
+ it('should calculate price for COST_ML LOW_MARGIN (rounded to multiple of 5)', () => {
211
+ // $60/ml cost * 3.00 factor * 1.16 VAT = $208.80 → $210
213
212
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
214
213
  pricePolicy: pricing_constants_1.PricePolicy.COST_ML,
215
214
  pricingTier: pricing_constants_1.PricingTier.LOW_MARGIN,
216
215
  unitPurchasePriceBI: 60,
217
216
  vatSalePercent: 16,
218
217
  });
219
- expect(result).toBe(208.80);
218
+ expect(result).toBe(210);
220
219
  });
221
220
  it('should calculate price for COST MID_MARGIN with 0% VAT', () => {
222
- // $50 cost * 3.00 factor * 1.00 = $150.00
221
+ // $50 cost * 3.00 factor * 1.00 = $150.00 → $150
223
222
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
224
223
  pricePolicy: pricing_constants_1.PricePolicy.COST,
225
224
  pricingTier: pricing_constants_1.PricingTier.MID_MARGIN,
226
225
  unitPurchasePriceBI: 50,
227
226
  vatSalePercent: 0,
228
227
  });
229
- expect(result).toBe(150.00);
228
+ expect(result).toBe(150);
230
229
  });
231
- it('should calculate price for EXT_COST MID_MARGIN', () => {
232
- // $1000 cost * 1.70 factor * 1.16 VAT = $1972.00
230
+ it('should calculate price for EXT_COST MID_MARGIN (rounded to multiple of 5)', () => {
231
+ // $1000 cost * 1.70 factor * 1.16 VAT = $1972.00 → $1970
233
232
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
234
233
  pricePolicy: pricing_constants_1.PricePolicy.EXT_COST,
235
234
  pricingTier: pricing_constants_1.PricingTier.MID_MARGIN,
236
235
  unitPurchasePriceBI: 1000,
237
236
  vatSalePercent: 16,
238
237
  });
239
- expect(result).toBe(1972.00);
238
+ expect(result).toBe(1970);
240
239
  });
241
240
  it('should return null for COMP_SVC (no formula)', () => {
242
241
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
@@ -265,15 +264,6 @@ describe('calculateRecommendedPricePVP', () => {
265
264
  });
266
265
  expect(result).toBeNull();
267
266
  });
268
- it('should return null for TEST', () => {
269
- const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
270
- pricePolicy: pricing_constants_1.PricePolicy.TEST,
271
- pricingTier: pricing_constants_1.PricingTier.HIGH_MARGIN,
272
- unitPurchasePriceBI: 100,
273
- vatSalePercent: 16,
274
- });
275
- expect(result).toBeNull();
276
- });
277
267
  it('should return null for SPECIAL', () => {
278
268
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
279
269
  pricePolicy: pricing_constants_1.PricePolicy.SPECIAL,
@@ -301,14 +291,24 @@ describe('calculateRecommendedPricePVP', () => {
301
291
  });
302
292
  expect(result).toBeNull();
303
293
  });
304
- it('should round to 2 decimal places', () => {
305
- // $33.33 * 1.33 * 1.16 = $51.42152... → $51.42
294
+ it('should round to nearest multiple of 5', () => {
295
+ // $33.33 * 1.33 * 1.16 = $51.42... → $50
306
296
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
307
297
  pricePolicy: pricing_constants_1.PricePolicy.PHARM,
308
298
  pricingTier: pricing_constants_1.PricingTier.LOW_MARGIN,
309
299
  unitPurchasePriceBI: 33.33,
310
300
  vatSalePercent: 16,
311
301
  });
312
- expect(result).toBe(51.42);
302
+ expect(result).toBe(50);
303
+ });
304
+ it('should round up when closer to next multiple of 5', () => {
305
+ // $38 * 1.33 * 1.16 = $58.63... → $60
306
+ const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
307
+ pricePolicy: pricing_constants_1.PricePolicy.PHARM,
308
+ pricingTier: pricing_constants_1.PricingTier.LOW_MARGIN,
309
+ unitPurchasePriceBI: 38,
310
+ vatSalePercent: 16,
311
+ });
312
+ expect(result).toBe(60);
313
313
  });
314
314
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.45.0",
3
+ "version": "6.46.0",
4
4
  "description": "Shared types and utilities for HVP backend and frontend",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",