Files
apskel-pos-backend/internal/repository
efrilmandClaude Opus 5 923c108690 fix(analytics): cost weighed lines by weight, not row count
A weight-based line is one weighing, so order_items.quantity is pinned to 1
while unit_price and unit_cost are per unit of weight. Analytics SQL was
multiplying and dividing per-unit rates by the raw quantity, costing a 4.2 ons
fish as a single ons: standard_hpp_total and moving_average_hpp_total came out
far too low across all four product reports, overstating gross profit, and
average_price and fifo_hpp_per_unit read per weighing while
standard_hpp_per_unit read per unit, so the three HPP figures in one row could
not be compared.

Adds billableQty and billableQtyNet as the single place that decides the
multiplier, mirroring entities.OrderItem.BillableQuantity.

quantity_sold and total_items stay as weighing counts; weight_sold already
carries the amount. revenue and fifo_hpp_total were already correct via
total_price/total_cost.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-06 23:06:31 +07:00
..
2025-09-18 13:39:37 +07:00
2026-08-13 14:38:28 +07:00
2025-09-12 16:37:16 +07:00
2025-09-18 01:32:01 +07:00
2025-09-18 12:42:07 +07:00
2025-09-18 13:39:37 +07:00
2025-09-18 12:29:27 +07:00
2026-05-10 10:57:38 +07:00
2025-09-18 12:01:20 +07:00
2025-08-13 23:14:26 +07:00
2026-08-11 20:47:38 +07:00
2026-08-11 22:41:10 +07:00
2025-09-17 23:55:11 +07:00
2026-05-10 14:52:02 +07:00
2025-09-17 19:30:17 +07:00
2025-08-08 00:22:28 +07:00
2026-05-10 10:42:09 +07:00
2026-05-10 23:36:22 +07:00