# `Fun_dReportQty` (function)


- **Type:** FUNCTION
- **Returns:** `decimal(18,6)`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sWorkOrderProcessTbGuid` | `varchar(100)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `Fun_dReportQty`'`._

## Narrative

**Business context:** Remaining-to-report quantity helper for one work-order process row. For a given `mftworkorderprocess.sId`, returns `dProcessInQty - SUM(dProcessQty)` — how much of the dispatched in-quantity still hasn't been reported as completed via the production-report screen.

**What it does:** joins `mftworkorderprocess` against an aggregate of `viw_mftproductionreport` (filtered to `bCheck=1 AND bInvalid=0`, grouped by `sWorkOrderProcessTbId`) and returns the difference, coalesced to 0 when no reports exist.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master sSqlStr, gdsmodule hooks, other routines, exhaustive xly-src grep, dynamic-dispatch search) — candidate for maintainer audit.
