12 SUM(glamount) AS glamount,
13 SUM(stamount) AS stamount,
14 SUM(glamount + stamount) AS diff
19 gltrans_date::date AS transdate,
20 COALESCE(SUM(gltrans_amount),0) AS glamount,
25 gltrans_accnt_id = (SELECT costcat_asset_accnt_id FROM costcat LIMIT 1)
27 gltrans_doctype NOT IN ('PO', 'VO') -- ignore the PO
31 split_part(gltrans_docnumber, '-', 1) != 'COS'
33 strpos(gltrans_docnumber, 'JE-IR-LANDCOST') = 0
40 invhist_transdate::date AS transdate,
42 COALESCE( SUM(invfifo_landedunitcost * invdetail_qty), 0) AS stamount
48 invhist_transtype NOT IN ('RP', 'RL') -- ignore the PO
52 WHERE transdate::date >= fetchMetricText('invfifo_start_date')::date
54 ORDER BY transdate ASC