Skip to content

Cost of Goods Sold Report

Dr M H B Ariyaratne edited this page Jul 15, 2026 · 1 revision

Cost of Goods Sold (COGS) Report

Path: Pharmacy → Reports → Inventory Reports → Cost of Goods Sold Source: reports/inventoryReports/cost_of_goods_sold.xhtml

Overview

The Cost of Goods Sold report reconciles pharmacy stock movement against the closing stock balance for a selected period, showing a breakdown by transaction type (sale, BHT issue, transfer, disposal, etc.) with a variance figure that should read 0.00 when every stock-affecting transaction type is correctly accounted for.

The related BHT Issue row/report (reports/inventoryReports/bht_issue.xhtml) shows the cost value of medicines issued to inpatients (BHTs) specifically.

Recent Fixes (July 2026)

Three defects on this report and the related BHT Issue report were fixed together:

  1. BHT issue quantity-edit corrupted the bill and the report. Editing the quantity on the BHT Issue page (ward/ward_pharmacy_bht_issue.xhtml, used for partial issues against a ward request) left the pharmaceutical bill item's quantity positive instead of following the negative-unit-quantity convention used by every other issue row, and never recalculated the row's gross/margin/net values. A partial issue therefore settled the bill at the original requested-quantity value (patient overbilled) while stock moved by the edited quantity, producing a spurious COGS variance equal to roughly 2× the edited item's value. (Issue #22109, PR #22110)
  2. Ward receive/return legs were missing from the COGS BHT Issue row. ACCEPT_ISSUED_MEDICINE_INWARD (ward receiving issued medicine), RETURN_MEDICINE_INWARD (ward returning to pharmacy), and ACCEPT_RETURN_MEDICINE_INWARD (pharmacy accepting that return) moved stock into/out of closing stock but were never included in any COGS movement row — so every ward receive showed up as a spurious variance equal to its value, and every IP/ward drug return did not appear on the report at all. calculateBhtIssueValue() now nets issues + ward accepts + pharmacy accept-of-return in one query and deducts the RETURN_MEDICINE_INWARD leg (which stores a positive quantity even though ward stock decreases). (Issue #22109, PR #22110)
  3. Cosmetic: BHT Issue report "Cost Value" footer showed a minus sign even though the row values themselves display positive — display-only fix. (Issue #22109, PR #22110)

After the fix, a full local test cycle (direct issues, partial return, cancellation, ward requests with full/partial/later-fill issues via the fixed qty-edit path, ward receives, ward return, pharmacy accept-of-return) produced a COGS variance of 0.00 / 0.00 / 0.00, with Calculated Closing matching Closing Stock and the BHT Issue report rows matching the database.

Not covered by this fix (per the PR): discharge-medicine issues, theatre issues, ward-return cancellation, and substitution issues — these paths may still show variance and should be checked separately if reported.

Related Reports

  • Closing Stock Report — for current/point-in-time stock balances
  • Stock Ledger Report — for detailed transaction history
  • BHT Issue Report (reports/inventoryReports/bht_issue.xhtml) — cost of medicines issued to inpatients

Support

If you need help with this report:

Clone this wiki locally