hvp-shared 6.45.0 → 6.45.1

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.
@@ -234,6 +234,6 @@ function calculateRecommendedPricePVP(params) {
234
234
  return null;
235
235
  const priceBI = unitPurchasePriceBI * factor;
236
236
  const pricePVP = priceBI * (1 + vatSalePercent / 100);
237
- // Round to 2 decimals
238
- return Math.round(pricePVP * 100) / 100;
237
+ // Round to nearest multiple of 5
238
+ return Math.round(pricePVP / 5) * 5;
239
239
  }
@@ -198,45 +198,45 @@ describe('getDefaultPricePolicy', () => {
198
198
  // calculateRecommendedPricePVP
199
199
  // =============================================================================
200
200
  describe('calculateRecommendedPricePVP', () => {
201
- it('should calculate price for PHARM HIGH_MARGIN', () => {
202
- // $100 cost * 2.00 factor * 1.16 VAT = $232.00
201
+ it('should calculate price for PHARM HIGH_MARGIN (rounded to multiple of 5)', () => {
202
+ // $100 cost * 2.00 factor * 1.16 VAT = $232.00 → $230
203
203
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
204
204
  pricePolicy: pricing_constants_1.PricePolicy.PHARM,
205
205
  pricingTier: pricing_constants_1.PricingTier.HIGH_MARGIN,
206
206
  unitPurchasePriceBI: 100,
207
207
  vatSalePercent: 16,
208
208
  });
209
- expect(result).toBe(232.00);
209
+ expect(result).toBe(230);
210
210
  });
211
- it('should calculate price for COST_ML LOW_MARGIN', () => {
212
- // $60/ml cost * 3.00 factor * 1.16 VAT = $208.80
211
+ it('should calculate price for COST_ML LOW_MARGIN (rounded to multiple of 5)', () => {
212
+ // $60/ml cost * 3.00 factor * 1.16 VAT = $208.80 → $210
213
213
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
214
214
  pricePolicy: pricing_constants_1.PricePolicy.COST_ML,
215
215
  pricingTier: pricing_constants_1.PricingTier.LOW_MARGIN,
216
216
  unitPurchasePriceBI: 60,
217
217
  vatSalePercent: 16,
218
218
  });
219
- expect(result).toBe(208.80);
219
+ expect(result).toBe(210);
220
220
  });
221
221
  it('should calculate price for COST MID_MARGIN with 0% VAT', () => {
222
- // $50 cost * 3.00 factor * 1.00 = $150.00
222
+ // $50 cost * 3.00 factor * 1.00 = $150.00 → $150
223
223
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
224
224
  pricePolicy: pricing_constants_1.PricePolicy.COST,
225
225
  pricingTier: pricing_constants_1.PricingTier.MID_MARGIN,
226
226
  unitPurchasePriceBI: 50,
227
227
  vatSalePercent: 0,
228
228
  });
229
- expect(result).toBe(150.00);
229
+ expect(result).toBe(150);
230
230
  });
231
- it('should calculate price for EXT_COST MID_MARGIN', () => {
232
- // $1000 cost * 1.70 factor * 1.16 VAT = $1972.00
231
+ it('should calculate price for EXT_COST MID_MARGIN (rounded to multiple of 5)', () => {
232
+ // $1000 cost * 1.70 factor * 1.16 VAT = $1972.00 → $1970
233
233
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
234
234
  pricePolicy: pricing_constants_1.PricePolicy.EXT_COST,
235
235
  pricingTier: pricing_constants_1.PricingTier.MID_MARGIN,
236
236
  unitPurchasePriceBI: 1000,
237
237
  vatSalePercent: 16,
238
238
  });
239
- expect(result).toBe(1972.00);
239
+ expect(result).toBe(1970);
240
240
  });
241
241
  it('should return null for COMP_SVC (no formula)', () => {
242
242
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
@@ -301,14 +301,24 @@ describe('calculateRecommendedPricePVP', () => {
301
301
  });
302
302
  expect(result).toBeNull();
303
303
  });
304
- it('should round to 2 decimal places', () => {
305
- // $33.33 * 1.33 * 1.16 = $51.42152... → $51.42
304
+ it('should round to nearest multiple of 5', () => {
305
+ // $33.33 * 1.33 * 1.16 = $51.42... → $50
306
306
  const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
307
307
  pricePolicy: pricing_constants_1.PricePolicy.PHARM,
308
308
  pricingTier: pricing_constants_1.PricingTier.LOW_MARGIN,
309
309
  unitPurchasePriceBI: 33.33,
310
310
  vatSalePercent: 16,
311
311
  });
312
- expect(result).toBe(51.42);
312
+ expect(result).toBe(50);
313
+ });
314
+ it('should round up when closer to next multiple of 5', () => {
315
+ // $38 * 1.33 * 1.16 = $58.63... → $60
316
+ const result = (0, pricing_constants_1.calculateRecommendedPricePVP)({
317
+ pricePolicy: pricing_constants_1.PricePolicy.PHARM,
318
+ pricingTier: pricing_constants_1.PricingTier.LOW_MARGIN,
319
+ unitPurchasePriceBI: 38,
320
+ vatSalePercent: 16,
321
+ });
322
+ expect(result).toBe(60);
313
323
  });
314
324
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.45.0",
3
+ "version": "6.45.1",
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",