Skip to content

TJK: Add AMC (Average Monthly Consumption) column to stock requests#19

Open
deeonwuli wants to merge 8 commits into
release/est/tjk/0.9.7from
feat/tjk/amc-in-requisition
Open

TJK: Add AMC (Average Monthly Consumption) column to stock requests#19
deeonwuli wants to merge 8 commits into
release/est/tjk/0.9.7from
feat/tjk/amc-in-requisition

Conversation

@deeonwuli

Copy link
Copy Markdown

📌 References

📝 Implementation

  • Adds a read-only AMC (Average Monthly Consumption) column beside Demand on the stock request create (Add Items) and edit (Fulfiller) screens
  • AMC is computed from Consumption transactions only, using the same total ÷ windowDays × 30 formula and rolling window as the Consumption Report, so the two reconcile 1:1
  • Surfaces a real usage signal for consumption-driven sites (wards/dispensaries) that record usage as Consumption rather than requisitions, where Demand reads 0
  • Demand and the Needed Qty autofill are untouched — AMC is display-only; value shown to one decimal place
  • New logic isolated under org.pih.warehouse.custom.consumptionDemand (backend) and src/js/custom/amcInRequisition (frontend); upstream edits are surgical and documented in the OpenSpec design.md

🧪 Testing

  • Seed Consumption transactions for a product at a requesting location (backdated into the AMC window) and confirm the AMC column displays Σqty ÷ windowDays × 30 on both the create and edit screens
  • Cross-check the displayed AMC against the Consumption Report's "Monthly" column for the same product/location/period — values reconcile
  • Confirm the Demand column values are unchanged, and the Needed Qty autofill still derives from Demand (not AMC)
  • Toggle showAmcInRequisition: false → AMC column hidden on both screens; set to true → column visible
  • Confirm a product with no consumption history shows AMC = 0 (not blank/error)

📸 Screenshots & Recordings (optional)

Screenshot 2026-06-19 at 14 17 14

#869ctkw25

deeonwuli and others added 2 commits June 17, 2026 13:50
…low spec files

- Introduced a read-only AMC column beside Demand on the Requisition create and edit pages.
- Computed AMC using consumption transactions only, scoped to the requesting location.
- Implemented feature flag `openboxes.custom.consumption.showAmcInRequisition` to control visibility.
- Ensured AMC calculation aligns with the Consumption Report formula.
- Updated relevant services and frontend components to support the new feature.
…Consumption (AMC) for product selection in requisition process

@gqcorneby gqcorneby left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @deeonwuli! Great job 👏 Tested with seeded values and everything works great.

One minor comment to add translations and to archive the specs. Thanks!

Also noting for @bhavananarayanan, the screens affected are

  1. create request > add item step
Image
  1. edit request after approval by fulfilling location
Image

An oubound created via Outbound > Create Oubound > Edit step is not included though it has a Demand column.

Image

dhis2auth.breakout.message=Redirecting to sign in…
dhis2auth.breakout.link=Continue to sign in

# amc-in-requisition (custom)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add the new keys and the corresponding translations to messages_ru.properties and messages_tg.properties? We mainly rely on AI for the translation 😅

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if we should use "AMC" and just translate the tooltip?

Move completed change to archive/2026-06-26-amc-in-requisition and
promote its delta spec to openspec/specs/amc-in-requisition.
Label kept as 'AMC' (recognized acronym); tooltip localized to ru/tg.
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.

2 participants