Skip to content

OLMIS-8244: Add packs-to-order preview hint#85

Open
michaldev0 wants to merge 1 commit into
masterfrom
OLMIS-8244
Open

OLMIS-8244: Add packs-to-order preview hint#85
michaldev0 wants to merge 1 commit into
masterfrom
OLMIS-8244

Conversation

@michaldev0

Copy link
Copy Markdown
Contributor

OLMIS-8244 — "Will be ordered as X pack(s)" preview hint

https://openlmis.atlassian.net/browse/OLMIS-8244

Companion to the backend fix OpenLMIS/openlmis-fulfillment#55,
which converts requisition-less order quantities from doses to packs at send. Because the entered
doses are rounded to whole packs on send, the user should see the result beforehand.

Change

openlmis-quantity-unit-input now renders a hint under the quantity input — e.g.
"Will be ordered as 2 pack(s) (168 doses)" — in both Doses and Packs input modes.

  • quantity-unit.service.js — adds packsToOrder(quantity, netContent, packRoundingThreshold, roundToZero), a JS port behaviourally identical to the backend OrderableDto.packsToOrder /
    canonical referencedata Orderable#packsToOrder, so the preview matches what the backend stores.
  • openlmis-quantity-unit-input.jsxshowPacksToOrderHint prop + memoised hint; hidden when
    netContent === 1 (nothing to round) or quantity is empty/zero.
  • New message key openlmisInputDosesPacks.willBeOrderedAsPacks and a small style for the hint.

Tests

  • quantity-unit.service.spec.js (new) — 7 cases mirroring the backend OrderableDtoTest
    one-for-one (exact, round-up, round-down within threshold, sub-pack min-1, roundToZero, zero net
    content, non-positive quantity).

E2E verified (live)

Hint correct across exact (252→3), round-up (130→2), round-down (100→1, 200→2, 90→1), sub-pack
min-1 (20→1); Packs mode (2 packs + 50 doses → 3); hidden for netContent=1 (Male Condom) and for
quantity 0/empty.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant