Fix #7123 - getting abra ready to test
[Pman.Xtuple] / pgsql.initdata / public.metasql.sql
1 --
2 -- PostgreSQL database dump
3 --
4
5 SET statement_timeout = 0;
6 SET client_encoding = 'UTF8';
7 SET standard_conforming_strings = on;
8 SET check_function_bodies = false;
9 SET client_min_messages = warning;
10
11 SET search_path = public, pg_catalog;
12
13 --
14 -- Data for Name: metasql; Type: TABLE DATA; Schema: public; Owner: admin
15 --
16
17 SET SESSION AUTHORIZATION DEFAULT;
18
19 ALTER TABLE metasql DISABLE TRIGGER ALL;
20
21 COPY metasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin;
22 2       enterPoReceipt  poItemReceivingsFillList                -- Group:enterPoReceipt\n-- Name:poItemReceivingsFillList\n-- Notes:\n\n<? if exists("pohead_id") ?>\nSELECT poitem_id, poitem_linenumber,\n       formatDate(poitem_duedate),\n       COALESCE(item_number, <? value("nonInventory") ?>),\n       COALESCE(uom_name, <? value("na") ?>),\n       warehous_code,\n       poitem_vend_item_number,\n       poitem_vend_uom,\n       formatQty(poitem_qty_ordered),\n       formatQty(poitem_qty_received),\n       formatQty(qtyToReceive(<? value("ordertype") ?>, poitem_id))\nFROM poitem \n  LEFT OUTER JOIN \n     ( itemsite \n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n       JOIN item ON (itemsite_item_id=item_id) \n       JOIN uom ON (item_inv_uom_id=uom_id)\n       JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n     ) ON (poitem_itemsite_id=itemsite_id) \nWHERE ( (poitem_status <> 'C')\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=current_user) \n<? endif ?>\n AND (poitem_pohead_id=<? value("pohead_id") ?>) )\nORDER BY poitem_linenumber;\n<? elseif exists("rahead_id") ?>\nSELECT raitem_id, raitem_linenumber,\n       formatDate(rahead_expiredate),\n       COALESCE(item_number, <? value("nonInventory") ?>),\n       COALESCE(iu.uom_name, <? value("na") ?>),\n       warehous_code,\n       '' AS vend_item_number,\n       ru.uom_name,\n       formatQty(raitem_qtyauthorized),\n       formatQty(raitem_qtyreceived),\n       formatQty(qtyToReceive(<? value("ordertype") ?>, raitem_id))\nFROM rahead, raitem \n  LEFT OUTER JOIN \n     ( itemsite \n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n       JOIN item ON (itemsite_item_id=item_id) \n       JOIN uom iu ON (item_inv_uom_id=uom_id)\n       JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n     ) ON (raitem_itemsite_id=itemsite_id), uom ru\nWHERE ( (raitem_status <> 'C')\n AND (raitem_qtyauthorized > 0)\n AND (raitem_disposition IN ('R','P','V'))\n AND (raitem_rahead_id=rahead_id)\n AND (raitem_qty_uom_id=ru.uom_id)\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=current_user) \n<? endif ?>\n AND (rahead_id=<? value("rahead_id") ?>) )\nORDER BY raitem_linenumber;\n<? elseif exists("tohead_id") ?>\nSELECT toitem_id, toitem_linenumber,\n       formatDate(toitem_duedate),\n       COALESCE(item_number, <? value("nonInventory") ?>),\n       COALESCE(uom_name, <? value("na") ?>),\n       warehous_code,\n       '',\n       toitem_uom,\n       formatQty(toitem_qty_ordered),\n       formatQty(toitem_qty_received),\n       formatQty(qtyToReceive(<? value("ordertype") ?>, toitem_id))\nFROM tohead, itemsite\n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n, whsinfo, toitem, item JOIN uom ON (item_inv_uom_id=uom_id)\nWHERE ((toitem_item_id=item_id)\n  AND  (tohead_id=toitem_tohead_id)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (tohead_dest_warehous_id=warehous_id)\n  AND  (toitem_item_id=itemsite_item_id)\n  AND  (toitem_status <> 'C')\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=current_user) \n<? endif ?>\n  AND  (toitem_tohead_id=<? value("tohead_id") ?>) )\nORDER BY toitem_linenumber;\n<? endif ?>\n     admin   2008-09-03      0
23 43      breederDistributionVariance     detail  used by dspBreederDistributionVarianceByItem, dspBreederDistributionVarianceByWarehouse -- Group: breederDistributionVariance\n-- Name: detail\n-- Notes: used by dspBreederDistributionVarianceByItem, dspBreederDistributionVarianceByWarehouse\n\nSELECT brdvar_id, brdvar_postdate,\n       pi.item_number AS pitem_number,\n       ci.item_number AS citem_number,\n       brdvar_stdqtyper,\n       brdvar_stdqtyper * brdvar_wo_qty AS stdqty,\n       brdvar_actqtyper,\n       brdvar_actqtyper * brdvar_wo_qty AS actqty,\n       brdvar_actqtyper-brdvar_stdqtyper AS qtypervariance,\n       (brdvar_actqtyper-brdvar_stdqtyper) / brdvar_stdqtyper AS percentvariance,\n       'qtyper'   AS brdvar_stdqtyper_xtnumericrole,\n       'qty'     AS stdqty_xtnumericrole,\n       'qtyper'  AS brdvar_actqtyper_xtnumericrole,\n       'qty'     AS actqty_xtnumericrole,\n       'qtyper'  AS qtypervariance_xtnumericrole,\n       'percent' AS percentvariance_xtnumericrole \nFROM brdvar, itemsite AS ps, itemsite AS cs, item AS ci, item AS pi\nWHERE ( (brdvar_parent_itemsite_id=ps.itemsite_id)\n    AND (brdvar_itemsite_id=cs.itemsite_id)\n<? if exists("item_id") ?>\n    AND (ps.itemsite_item_id=<? value("item_id") ?>)\n    AND (pi.item_id=ci.item_id)\n<? else ?>\n    AND (ps.itemsite_item_id=pi.item_id)\n<? endif ?>\n    AND (cs.itemsite_item_id=ci.item_id)\n    AND (brdvar_postdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n    AND (ps.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n) \nORDER BY brdvar_postdate, pitem_number\n<? if not exists("item_id") ?>\n     , citem_number \n<? endif ?>\n;\n   admin   2008-11-07      0
24 61      manufacture     laborvariance   shared by dspLaborVarianceBy*   -- Group: manufacture\n-- Name:  laborvariance\n-- Notes: shared by dspLaborVarianceBy*\n\nSELECT woopervar.*,\n       item_number, wrkcnt_code,\n       (woopervar_sutime - woopervar_stdsutime) AS suvar,\n       (woopervar_rntime - woopervar_stdrntime) AS rnvar,\n       'qty' AS woopervar_qtyord_xtnumericrole,\n       'qty' AS woopervar_qtyrcv_xtnumericrole,\n       '1'   AS woopervar_stdsutime_xtnumericrole,\n       '1'   AS woopervar_stdrntime_xtnumericrole,\n       '1'   AS woopervar_sutime_xtnumericrole,\n       '1'   AS woopervar_rntime_xtnumericrole,\n       '1'   AS suvar_xtnumericrole,\n       '1'   AS rnvar_xtnumericrole\nFROM woopervar\n<? if exists("wo_id") ?>\n     JOIN wo ON ((woopervar_number=wo_number)\n             AND (woopervar_subnumber=wo_subnumber))\n<? endif ?>\n     JOIN itemsite ON (woopervar_parent_itemsite_id=itemsite_id)\n     JOIN item ON (itemsite_item_id=item_id)\n     LEFT OUTER JOIN wrkcnt ON (woopervar_wrkcnt_id=wrkcnt_id)\nWHERE (true\n<? if exists("startDate") ?>\n   AND (woopervar_posted BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("booitem_id") ?>\n   AND (woopervar_booitem_id=<? value("booitem_id") ?>)\n<? endif ?>\n<? if exists("wrkcnt_id") ?>\n   AND (wrkcnt_id=<? value("wrkcnt_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n   AND (wo_id=<? value("wo_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY woopervar_posted DESC, woopervar_seqnumber;\n    admin   2008-11-07      0
25 445     bankrec clearedbalance  used by reconcileBankaccount Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: bankrec\n-- Name: clearedbalance\n-- Notes: used by reconcileBankaccount\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT (COALESCE(SUM(amount),0.0) + <? value("begBal") ?>) AS cleared_amount,\n       <? value("endBal") ?> AS end_amount,\n       (<? value("endBal") ?> - (<? value("begBal") ?> + (COALESCE(SUM(amount),0.0)))) AS diff_amount,\n       round(<? value("endBal") ?> - (<? value("begBal") ?> + COALESCE(SUM(amount),0.0)), 2) AS diff_value\n  FROM ( SELECT CASE WHEN (gltrans_amount > 0) THEN bankrecitem_amount * -1.0\n                     ELSE bankrecitem_amount END AS amount\n           FROM bankaccnt, gltrans, bankrecitem\n          WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n            AND (bankrecitem_source='GL')\n            AND (bankrecitem_source_id=gltrans_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (NOT gltrans_rec)\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) ) \n          UNION ALL\n         SELECT CASE WHEN (sltrans_amount > 0) THEN bankrecitem_amount * -1.0\n                     ELSE bankrecitem_amount END AS amount\n           FROM bankaccnt, sltrans, bankrecitem\n          WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n            AND (bankrecitem_source='SL')\n            AND (bankrecitem_source_id=sltrans_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (NOT sltrans_rec)\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n           FROM bankadj, bankadjtype, bankrecitem\n          WHERE ( (bankrecitem_source='AD')\n            AND (bankrecitem_source_id=bankadj_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (bankadj_bankadjtype_id=bankadjtype_id)\n            AND (NOT bankadj_posted)\n            AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>) ) ) AS data;\n    admin   2011-12-21      0
26 231     arOpenItems     f_detail        This version for printed reports that need a way to include formatted values since there is no good way to differentiate different printed parameters in display class.  Used to be printed version got an extra parameter. Formatted values slow things down considerably on screen version otherwise. This should go away if/when we get OpenRPT to do its own formatting. Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: arOpenItems\n-- Name:  f_detail\n-- Notes: This version for printed reports that need a way to include formatted values\n--        since there is no good way to differentiate different printed parameters in \n--        display class.  Used to be printed version got an extra parameter. Formatted\n--        values slow things down considerably on screen version otherwise. This\n--        should go away if/when we get OpenRPT to do its own formatting.\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("totalOnly") ?>\nSELECT SUM(CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n                    (aropen_amount - aropen_paid) / aropen_curr_rate * -1\n                ELSE (aropen_amount - aropen_paid) / aropen_curr_rate\n           END) AS total_balance\nFROM aropen JOIN custinfo ON (aropen_cust_id=cust_id)\n            LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n            LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (aropen_open)\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n      )\n;\n<? else ?>\n\n-- Get unposted invoices\n<? if exists("showUnposted") ?>\n<? if not exists("creditsOnly") ?>\nSELECT -1 AS id,\n       0 AS altId,\n       invchead_invcnumber AS docnumber,\n       invchead_id AS docnumber_xtidrole,\n       invchead_posted AS posted,\n       invchead_invcdate AS docdate,\n       NULL::date AS aropen_duedate,\n       invchead_ordernumber AS ordernumber,\n       cohead_id AS ordernumber_xtidrole,\n       <? value("invoice") ?>  AS doctype,\n       NULL AS doctype_qtforegroundrole,\n       invoicetotal(invchead_id) AS amount,\n       currtobase(invchead_curr_id, invoicetotal(invchead_id), invchead_invcdate) AS base_amount,\n       0 AS paid,\n       0 AS base_paid,\n       0 AS balance,\n       currConcat(invchead_curr_id) AS currAbbr,\n       0 AS base_balance,\n       formatDate(invchead_invcdate) AS f_docdate,\n       NULL::text AS f_duedate,\n       formatMoney(0) AS f_amount,\n       formatMoney(0) AS f_paid,\n       formatMoney(0) AS f_balance,\n       cust_id, cust_number, cust_name,\n       (invchead_recurring_invchead_id IS NOT NULL) AS recurring,\n       false AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL::text AS aropen_docnumber_qtdisplayrole,\n       NULL::text AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       '' AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_number_xtidrole,\n       firstLine(invchead_notes) AS notes\nFROM invchead\n           LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n           JOIN custinfo ON (invchead_cust_id=cust_id)\n           JOIN custtype ON (cust_custtype_id=custtype_id)\n\t   LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT invchead_posted)\n<? if exists("cust_id") ?>\n  AND   (invchead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (invchead_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,                  invchead_id,\n           invchead_invcdate,       invchead_posted,        invchead_curr_id,\n           invchead_recurring,      invchead_invcnumber,    invchead_posted,\n           invchead_ordernumber,    cohead_id,\n           cust_id,                 cust_number,            cust_name,\n           invchead_recurring_invchead_id, invchead_notes\n\nUNION\n<? endif ?>\n<? endif ?>\n\n-- Get unposted credit memos\n<? if exists("showUnposted") ?>\n<? if not exists("debitsOnly") ?>\nSELECT -1 AS id,\n       1 AS altId,\n       cmhead_number AS docnumber,\n       cmhead_id AS docnumber_xtidrole,\n       cmhead_posted AS posted,\n       cmhead_docdate AS docdate,\n       NULL::date AS aropen_duedate,\n       NULL::text AS ordernumber,\n       -1 AS ordernumber_xtidrole,\n       <? value("creditMemo") ?>  AS doctype,\n       CASE WHEN (NOT cmhead_posted) THEN 'emphasis'\n       END AS doctype_qtforegroundrole,\n       creditmemototal(cmhead_id) AS amount,\n       currtobase(cmhead_curr_id, creditmemototal(cmhead_id), cmhead_docdate) AS base_amount,\n       0 AS paid,\n       0 AS base_paid,\n       0 AS balance,\n       currConcat(cmhead_curr_id) AS currAbbr,\n       0  AS base_balance,\n       formatDate(cmhead_docdate) AS f_docdate,\n       NULL::text AS f_duedate,\n       formatMoney(creditmemototal(cmhead_id)) AS f_amount,\n       formatMoney(0) AS f_paid,\n       formatMoney(0) AS f_balance,\n       cust_id, cust_number, cust_name,\n       false AS recurring,\n       false AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL::text AS aropen_docnumber_qtdisplayrole,\n       NULL::text AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       '' AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_number_xtidrole,\n       firstLine(cmhead_comments) AS notes\nFROM cmhead\n            JOIN custinfo ON (cmhead_cust_id=cust_id)\n            JOIN custtype ON (cust_custtype_id=custtype_id)\n\t    LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n<? if exists("cust_id") ?>\n  AND   (cmhead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (cmhead_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,                  cmhead_id,\n           cmhead_docdate,          cmhead_posted,          cmhead_curr_id,\n           cmhead_number,           cmhead_posted,          cmhead_comments,\n           cust_id,                 cust_number,            cust_name\n\nUNION\n<? endif ?>\n<? endif ?>\n\n-- Get Posted AR Open\nSELECT aropen_id AS id,\n       CASE WHEN (aropen_doctype='I') THEN 0\n            WHEN (aropen_doctype='C') THEN 1\n            WHEN (aropen_doctype='D') THEN 2\n            WHEN (aropen_doctype='R') THEN 3\n            ELSE -1\n       END AS altId,\n       aropen_docnumber AS docnumber,\n       COALESCE(invchead_id,cmhead_id,-1) AS docnumber_xtidrole,\n       true AS posted,\n       aropen_docdate AS docdate,\n       aropen_duedate,\n       aropen_ordernumber AS ordernumber,\n       COALESCE(cohead_id,-1) AS ordernumber_xtidrole,\n       CASE WHEN (aropen_doctype='I') THEN <? value("invoice") ?>\n            WHEN (aropen_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (aropen_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (aropen_doctype='R') THEN <? value("cashdeposit") ?>\n            ELSE <? value("other") ?>\n       END AS doctype,\n       CASE WHEN (aropen_doctype='C') THEN 'emphasis' \n         ELSE CASE WHEN(aropen_doctype='R')THEN 'altemphasis'\n         END\n       END AS doctype_qtforegroundrole,\n       aropen_amount AS amount,\n       aropen_amount/aropen_curr_rate AS base_amount,\n       (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS paid,\n       (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))/aropen_curr_rate) AS base_paid,\n        (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) AS balance,\n       currConcat(aropen_curr_id) AS currAbbr,\n        (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0)))/aropen_curr_rate *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)  AS base_balance,\n       formatDate(aropen_docdate) AS f_docdate,\n       formatDate(aropen_duedate) AS f_duedate,\n       formatMoney(aropen_amount) AS f_amount,\n       formatMoney(aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS f_paid,\n       formatMoney((((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)) AS f_balance,\n       cust_id, cust_number, cust_name,\n       COALESCE(invchead_recurring_invchead_id IS NOT NULL, false) AS recurring,\n       aropen_open AS open,\n       formatccnumber(decrypt(setbytea(ccard_number),\n                              setbytea(<? value("key") ?>), 'bf')) AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr'AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL AS aropen_docnumber_qtdisplayrole,\n       NULL AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n       END AS aropen_duedate_qtforegroundrole,\n       ccpay_id AS ccard_number_xtidrole,\n       firstLine(aropen_notes) AS notes\nFROM aropen \n<? if exists("incidentsOnly") ?>\n            JOIN incdt ON (incdt_aropen_id=aropen_id)\n<? endif ?>\n            JOIN custinfo ON (aropen_cust_id=cust_id)\n            JOIN custtype ON (cust_custtype_id=custtype_id)\n\t    LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n            LEFT OUTER JOIN invchead ON ((aropen_docnumber=invchead_invcnumber)\n                                   AND (aropen_doctype='I'))\n            LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n            LEFT OUTER JOIN cmhead ON ((aropen_docnumber=cmhead_number)\n                                   AND (aropen_doctype='C'))\n            LEFT OUTER JOIN arapply ON (((aropen_id=arapply_source_aropen_id)\n                             OR (aropen_id=arapply_target_aropen_id))\n                             AND (arapply_distdate>COALESCE(<? value("asofDate") ?>,current_date)))\n            LEFT OUTER JOIN payaropen ON (payaropen_aropen_id=aropen_id)\n            LEFT OUTER JOIN ccpay     ON (payaropen_ccpay_id=ccpay_id)\n            LEFT OUTER JOIN ccard     ON (ccpay_ccard_id=ccard_id)\nWHERE ((true)\n<? if not exists("showClosed") ?>\n  AND (aropen_docdate <= COALESCE(<? value("asofDate") ?>, current_date))\n  AND (COALESCE(aropen_closedate, DATE(<? value("asofDate") ?>) + 1, current_date + 1) > COALESCE(<? value("asofDate") ?>, current_date)) \n<? endif ?>\n<? if exists("debitsOnly") ?>\n  AND   (aropen_doctype IN ('D','I'))\n<? elseif exists("creditsOnly") ?>\n  AND   (aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("startDueDate") ?>\n  AND   (aropen_duedate >= <? value("startDueDate") ?>)\n<? endif ?>\n<? if exists("endDueDate") ?>\n  AND   (aropen_duedate <= <? value("endDueDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,\t            invchead_id,\n           aropen_docdate,          aropen_duedate,         aropen_doctype,         \n           aropen_docnumber,        aropen_amount,          \n           aropen_notes,            aropen_posted,          aropen_ordernumber,\n           aropen_paid,             aropen_open,            aropen_curr_id,\n           aropen_closedate,        aropen_curr_rate,       cmhead_id,\n           cust_id, \t\t    cust_number,            cust_name,\n           cohead_id,               ccpay_id,               ccard_number,\n           invchead_recurring_invchead_id\nUNION\nSELECT -1,\n       4 AS altId,\n       aropen_docnumber AS docnumber,\n       -1 AS docnumber_xtidrole,\n       NULL AS posted, \n       aropen_docdate AS docdate,\n       NULL AS aropen_duedate,\n       CAST(incdt_number AS text) AS ordernumber,\n       incdt_id AS ordernumber_xtidrole,\n       NULL AS doctype,\n       NULL AS doctype_qtforegroundrole,\n       NULL AS amount,\n       NULL AS base_amount,\n       NULL AS paid,\n       NULL AS base_paid,\n       NULL AS balance,\n       NULL AS currAbbr,\n       NULL AS base_balance,\n       NULL AS f_docdate,\n       NULL AS f_duedate,\n       NULL AS f_amount,\n       NULL AS f_paid,\n       NULL AS f_balance,\n       NULL,incdt_assigned_username, incdt_summary,\n       NULL AS recurring, NULL AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       '' AS aropen_docnumber_qtdisplayrole,\n       '' AS aropen_docdate_qtdisplayrole,\n       1 AS xtindentrole,\n       CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n       END AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_xtidrole,\n       firstLine(incdt_descrip) AS notes\nFROM incdt JOIN aropen ON (aropen_id=incdt_aropen_id)\n           JOIN custinfo ON (aropen_cust_id=cust_id)\n           JOIN custtype ON (cust_custtype_id=custtype_id)\n\t   LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((true)\n<? if not exists("showClosed") ?>\n  AND (aropen_docdate <= COALESCE(<? value("asofDate") ?>, current_date))\n  AND (COALESCE(aropen_closedate, DATE(<? value("asofDate") ?>) + 1, current_date + 1) > COALESCE(<? value("asofDate") ?>, current_date)) \n<? endif ?>\n<? if exists("debitsOnly") ?>\n  AND   (NOT aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("creditsOnly") ?>\n  AND   (aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("startDueDate") ?>\n  AND   (aropen_duedate >= <? value("startDueDate") ?>)\n<? endif ?>\n<? if exists("endDueDate") ?>\n  AND   (aropen_duedate <= <? value("endDueDate") ?>)\n<? endif ?>\n      )\n\nORDER BY\n  docdate DESC, docnumber DESC, xtindentrole\n;\n<? endif ?>\n admin   2012-03-01      0
27 105     bankrecHistory  reconciled       Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: bankrecHistory\n-- Name: reconciled\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("treeView") ?>\nSELECT -1 AS gltrans_id, bankrec_opendate AS gltrans_date, formatDate(bankrec_opendate) AS f_date,\n       <? value("openingBalance") ?> AS gltrans_docnumber, <? value("openingBalance") ?> AS type, 0 AS sort, NULL AS gltrans_notes, \n       bankrec_openbal AS amount, formatMoney(bankrec_openbal) AS f_amount,\n       'curr' AS amount_xtnumericrole,\n       0 AS xtindentrole\n  FROM bankrec\n  WHERE (bankrec_id=<? value("bankrec_id") ?>)\n  \nUNION\n<? endif ?>\n\nSELECT gltrans_id, gltrans_date, formatDate(gltrans_date) AS f_date,\n       gltrans_docnumber,\n       CASE WHEN gltrans_doctype = 'CK' THEN <? value("Checks") ?>\n            WHEN gltrans_doctype = 'CR' THEN <? value("Deposits") ?>\n            ELSE <? value("Adjustments") ?> END AS type,\n       CASE WHEN gltrans_doctype = 'CK' THEN 1\n            WHEN gltrans_doctype = 'CR' THEN 2\n            ELSE '3' END AS sort,\n       gltrans_notes AS notes,\n       COALESCE( bankrecitem_amount,\n                 (currtolocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) AS amount,\n       formatMoney(COALESCE( bankrecitem_amount,\n                             (currtolocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) ) AS f_amount,\n       'curr' AS amount_xtnumericrole,\n       1 AS xtindentrole\n  FROM gltrans, bankrecitem \n    JOIN bankrec ON (bankrecitem_bankrec_id=bankrec_id)\n    JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id)\n WHERE ((bankrecitem_bankrec_id=<? value("bankrec_id") ?>)\n   AND (bankrecitem_source='GL')\n   AND (bankrecitem_source_id=gltrans_id) ) \n\nUNION\n\nSELECT sltrans_id, sltrans_date, formatDate(sltrans_date) AS f_date,\n       sltrans_docnumber,\n       CASE WHEN sltrans_doctype = 'CK' THEN <? value("Checks") ?>\n            WHEN sltrans_doctype = 'CR' THEN <? value("Deposits") ?>\n            ELSE <? value("Adjustments") ?> END AS type,\n       CASE WHEN sltrans_doctype = 'CK' THEN 1\n            WHEN sltrans_doctype = 'CR' THEN 2\n            ELSE '3' END AS sort,\n       sltrans_notes AS notes,\n       COALESCE( bankrecitem_amount,\n                 (currtolocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) AS amount,\n       formatMoney(COALESCE( bankrecitem_amount,\n                             (currtolocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) ) AS f_amount,\n       'curr' AS amount_xtnumericrole,\n       1 AS xtindentrole\n  FROM sltrans, bankrecitem \n    JOIN bankrec ON (bankrecitem_bankrec_id=bankrec_id)\n    JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id)\n WHERE ((bankrecitem_bankrec_id=<? value("bankrec_id") ?>)\n   AND (bankrecitem_source='SL')\n   AND (bankrecitem_source_id=sltrans_id) ) \n\n<? if exists("treeView") ?>\nUNION\n\nSELECT -1 AS gltrans_id, bankrec_enddate, formatDate(bankrec_enddate) AS f_date,\n       <? value("closingBalance") ?>, <? value("closingBalance") ?> AS type, 7 AS sort, NULL, \n       bankrec_endbal AS amount, formatMoney(bankrec_endbal) AS f_amount,\n       'curr' AS amount_xtnumericrole,\n       0 AS xtindentrole\n  FROM bankrec\n  WHERE (bankrec_id=<? value("bankrec_id") ?>)\n\nUNION\nSELECT -1, NULL, NULL, <? value("Checks") ?>, NULL, 1, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, <? value("Deposits") ?>, NULL, 2, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, <? value("Adjustments") ?>, NULL, 3, NULL, NULL, NULL, 'curr', 0 \n<? endif ?>\n\nORDER BY  sort, xtindentrole, type, f_date, gltrans_id\n        admin   2011-12-21      0
28 361     glseries        checkeditable    Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: glseries\n-- Name:  checkeditable\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id \nFROM accnt, gltrans \n  LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) \nWHERE ( (gltrans_accnt_id=accnt_id) \n  AND (gltrans_sequence=<? value("glSequence") ?>) \n  AND ( (gltrans_deleted) \n     OR (period_freeze) \n     OR (gltrans_rec) \n     OR (period_closed AND NOT accnt_closedpost) ) )\nLIMIT 1;\n        admin   2011-11-23      0
29 238     countTag        detail  used by dspCountTagEditList Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: countTag\n-- Name: detail\n-- Notes: used by dspCountTagEditList\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       CASE WHEN (xtindentrole = 1) THEN NULL\n     <? if exists("varianceValue") ?>\n            WHEN (ABS(variancecost) >  <? value("varianceValue") ?>) THEN 'error'\n     <? elseif exists("variancePercent") ?>\n            WHEN (ABS(varianceprcnt * 100.0) >  <? value("variancePercent") ?>) THEN 'error'\n     <? else ?>\n            ELSE NULL\n     <? endif ?>\n       END AS qtforegroundrole,\n       CASE WHEN (xtindentrole = 1) THEN NULL\n            WHEN (qohafter IS NOT NULL) THEN 'emphasis'\n       END AS qohafter_qtforegroundrole,\n       CASE WHEN (xtindentrole = 0) THEN NULL ELSE '' END AS invcnt_priority_qtdisplayrole,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS qohafter_xtnumericrole,\n       'qty' AS variance_xtnumericrole,\n       'percent' AS varianceprcnt_xtnumericrole,\n       'curr' AS variancecost_xtnumericrole\nFROM (\n      SELECT invcnt_id, -1 AS cntslip_id, invcnt_priority,\n             COALESCE(invcnt_tagnumber, 'Misc.') AS tagnumber,\n             invcnt_tagdate AS tagdate,\n             item_number, (item_descrip1 || item_descrip2) AS item_descrip, warehous_code,\n\t     CASE WHEN (location_id IS NOT NULL) THEN\n               location_name\n               ELSE <? value("all") ?> END AS loc_specific,\n             CASE WHEN (invcnt_location_id IS NOT NULL)\n               THEN (SELECT SUM(itemloc_qty)\n                     FROM itemloc JOIN location ON (location_id=itemloc_location_id)\n                     WHERE ((itemloc_itemsite_id=itemsite_id)\n                       AND  (itemloc_location_id=invcnt_location_id)\n                       AND  (location_netable)))\n               ELSE itemsite_qtyonhand\n             END AS qoh,\n             CASE WHEN (invcnt_location_id IS NOT NULL)\n               THEN (SELECT SUM(itemloc_qty)\n                     FROM itemloc JOIN location ON (location_id=itemloc_location_id)\n                     WHERE ((itemloc_itemsite_id=itemsite_id)\n                       AND  (itemloc_location_id=invcnt_location_id)\n                       AND  (NOT location_netable)))\n               ELSE itemsite_nnqoh\n             END AS nnqoh,\n             COALESCE(invcnt_qoh_after, (SELECT SUM(cntslip_qty)\n                                         FROM cntslip\n                                         WHERE (cntslip_cnttag_id=invcnt_id))\n                     ) AS qohafter,\n             (invcnt_qoh_after - (itemsite_qtyonhand + itemsite_nnqoh)) AS variance,\n             CASE WHEN (invcnt_qoh_after IS NULL) THEN NULL\n                  WHEN (((itemsite_qtyonhand + itemsite_nnqoh) = 0) AND (invcnt_qoh_after > 0)) THEN 1\n                  WHEN (((itemsite_qtyonhand + itemsite_nnqoh) = 0) AND (invcnt_qoh_after < 0)) THEN -1\n                  WHEN (((itemsite_qtyonhand + itemsite_nnqoh) = 0) AND (invcnt_qoh_after = 0)) THEN 0\n               ELSE ((1 - (invcnt_qoh_after / (itemsite_qtyonhand + itemsite_nnqoh))) * -1)\n             END AS varianceprcnt,\n             (itemCost(itemsite_id) * (invcnt_qoh_after - (itemsite_qtyonhand + itemsite_nnqoh))) AS variancecost,\n             item_number AS orderby,\n             0 AS xtindentrole\n      FROM invcnt LEFT OUTER JOIN location ON (invcnt_location_id=location_id),\n\t   item, warehous, itemsite\n      WHERE ((invcnt_itemsite_id=itemsite_id)\n         AND (itemsite_item_id=item_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (NOT invcnt_posted)\n      <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n      <? endif ?>\n      <? if exists("classcode_id") ?>\n         AND (item_classcode_id=<? value("classcode_id") ?>)\n      <? elseif exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n      <? elseif exists("plancode_id") ?>\n         AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n      <? elseif exists("plancode_pattern") ?>\n         AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n      <? endif ?>\n      <? if exists("showSlips") ?>\n            )\n      UNION\n      SELECT invcnt_id, cntslip_id, invcnt_priority,\n             cntslip_number AS tagnumber,\n             cntslip_entered AS tagdate,\n             CASE WHEN (cntslip_posted) THEN <? value("posted") ?>\n               ELSE <? value("unposted") ?>\n             END AS item_number,\n             '' AS item_descrip,\n             '' AS warehous_code,\n             '' AS loc_specific,\n             NULL AS qoh,\n             NULL AS nnqoh,\n             cntslip_qty AS qohafter,\n             NULL AS variance, NULL AS varianceprcnt, 0 AS variancecost,\n             item_number AS orderby,\n             1 AS xtindentrole\n      FROM cntslip, invcnt, itemsite, item\n      WHERE ((cntslip_cnttag_id=invcnt_id)\n         AND (invcnt_itemsite_id=itemsite_id)\n         AND (itemsite_item_id=item_id)\n         AND (NOT invcnt_posted)\n       <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n       <? endif ?>\n       <? if exists("classcode_id") ?>\n         AND (item_classcode_id=<? value("classcode_id") ?>)\n       <? elseif exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n       <? elseif exists("plancode_id") ?>\n         AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n       <? elseif exists("plancode_pattern") ?>\n         AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n       <? endif ?>\n       <? endif ?>\n            )\n) AS dummy\nORDER BY invcnt_priority DESC, orderby, invcnt_id, cntslip_id;\n   admin   2011-12-21      0
30 47      countTags       detail  used by dspCountTagsByClassCode, dspCountTagsByItem, dspCountTagsByWarehouse Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: countTags\n-- Name: detail\n-- Notes: used by dspCountTagsByClassCode, dspCountTagsByItem, dspCountTagsByWarehouse\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invcnt_id, invcnt_tagnumber, warehous_code,\n       item_number, (item_descrip1 || item_descrip2) AS item_descrip,\n       invcnt_tagdate,\n       CASE WHEN invcnt_tagdate IS NOT NULL THEN invcnt_tag_username\n       END AS creator,\n       invcnt_cntdate,\n       CASE WHEN invcnt_cntdate IS NOT NULL THEN invcnt_cnt_username\n       END AS counter,\n       invcnt_postdate,\n       CASE WHEN invcnt_postdate IS NOT NULL THEN invcnt_post_username\n       END AS poster,\n       CASE WHEN (NOT invcnt_posted) THEN NULL\n            ELSE invcnt_qoh_before\n       END AS qohbefore,\n       invcnt_qoh_after,\n       CASE WHEN (NOT invcnt_posted) THEN NULL\n            ELSE (invcnt_qoh_after - invcnt_qoh_before)\n       END AS variance,\n       CASE WHEN (NOT invcnt_posted) THEN NULL\n            WHEN ((invcnt_qoh_before = 0) AND (invcnt_qoh_after = 0)) THEN 0\n            WHEN (invcnt_qoh_before = 0) THEN 1\n            ELSE ((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n       END AS percent,\n      'qty' AS qohbefore_xtnumericrole,\n      'qty' AS invcnt_qoh_after_xtnumericrole,\n      'qty' AS variance_xtnumericrole,\n      'percent' AS percent_xtnumericrole \nFROM invcnt, itemsite, item, warehous \nWHERE ((invcnt_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (itemsite_warehous_id=warehous_id)\n  AND  (DATE(invcnt_tagdate) BETWEEN <? value("startDate") ?>\n                                 AND <? value("endDate") ?>)\n<? if not exists("showUnposted") ?>\n  AND  invcnt_posted\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND  (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n                             FROM classcode\n                             WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("item_id") ?>\n  AND  (item_id=<? value("item_id") ?>)\n<? endif ?>\n)\nORDER BY invcnt_tagdate;\n admin   2011-12-21      0
31 448     crmaccountmerge wip     show an indented list of crm account merges that have data to purge. this includes those that have been started but not completed as well as those that have been completed but neither purged nor undone. Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: crmaccountmerge\n-- Name:  wip\n-- Notes: show an indented list of crm account merges that have\n--        data to purge. this includes those that have been started\n--        but not completed as well as those that have been completed\n--        but neither purged nor undone.\n--        Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       d.crmacct_id,     d.crmacct_id,\n       d.crmacct_number, d.crmacct_name,\n       d.crmacct_number AS destnumber,\n       <? value('mergedKey') ?>    AS status,\n       <? value('mergedParent') ?> AS status_qtdisplayrole,\n       0 AS xtindentrole\n  FROM crmacct d\n  JOIN mrgundo ON (d.crmacct_id=mrgundo_base_id\n               AND mrgundo_base_schema='public'\n               AND mrgundo_base_table='crmacct')\n<? if exists('destid') ?>\n WHERE d.crmacct_id = <? value("destid") ?>\n<? endif ?>\nUNION ALL\nSELECT s.crmacct_id,     d.crmacct_id,\n       s.crmacct_number, s.crmacct_name,\n       d.crmacct_number AS destnumber,\n       <? value('mergedKey') ?> AS status,\n       <? value('merged') ?>    AS status_qtdisplayrole,\n<? if exists('sourceAccountOnly') ?>\n       0\n<? else ?>\n       1\n<? endif ?>\n  FROM crmacct s\n  JOIN mrgundo ON (mrgundo_schema='public'\n               AND mrgundo_table='crmacct'\n               AND mrgundo_pkey_col='crmacct_id'\n               AND mrgundo_pkey_id=s.crmacct_id\n               AND mrgundo_col IS NULL)\n  JOIN crmacct d ON (mrgundo_base_id=d.crmacct_id\n                 AND mrgundo_base_schema='public')\n<? if exists('destid') ?>\n WHERE d.crmacct_id = <? value("destid") ?>\n<? endif ?>\nUNION\nSELECT s.crmacct_id,     d.crmacct_id,\n       s.crmacct_number, s.crmacct_name,\n       d.crmacct_number AS destnumber, \n       <? value('selectedKey') ?> AS status,\n       <? value('selected') ?>    AS status_qtdisplayrole,\n       CASE WHEN s.crmacct_id=d.crmacct_id THEN 0\n            ELSE 1\n       END\n  FROM crmacct d\n  JOIN crmacctsel ON (d.crmacct_id=crmacctsel_dest_crmacct_id)\n  JOIN crmacct s  ON (crmacctsel_src_crmacct_id=s.crmacct_id)\n<? if exists('destid') ?>\n WHERE d.crmacct_id = <? value("destid") ?>\n<? endif ?>\n\nORDER BY destnumber, xtindentrole, crmacct_number;\n       admin   2011-12-21      0
32 256     invoiceRegister detail  used by dspInvoiceRegister Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: invoiceRegister\n-- Name: detail\n-- Notes: used by dspInvoiceRegister\n--        Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       -1 AS gltrans_id, -1 AS altId,\n       gltrans_date,  '' AS gltrans_source,\n       '' AS doctype, '' AS gltrans_docnumber,\n       '' AS notes,   '' AS account,\n       CAST(NULL AS NUMERIC) AS debit,\n       CAST(NULL AS NUMERIC) AS credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       0 AS xtindentrole,\n       gltrans_date AS transdate\nFROM gltrans\nWHERE ((gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n   AND (gltrans_source = 'A/R')\n   AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n      )\n\nUNION\n-- G/L Transactions\nSELECT gltrans_id,\n       CASE WHEN(gltrans_doctype='IN') THEN 1\n            WHEN(gltrans_doctype='CM') THEN 2\n            WHEN(gltrans_doctype='DM') THEN 3\n            WHEN(gltrans_doctype='CD') THEN 4\n         ELSE -1\n       END AS altId,\n       gltrans_date, gltrans_source,\n       CASE WHEN(gltrans_doctype='IN') THEN <? value("invoice") ?>\n            WHEN(gltrans_doctype='CM') THEN <? value("creditmemo") ?>\n            WHEN(gltrans_doctype='DM') THEN <? value("debitmemo") ?>\n            WHEN(gltrans_doctype='CD') THEN <? value("cashdeposit") ?>\n         ELSE gltrans_doctype\n       END AS doctype,\n       gltrans_docnumber,\n       CASE WHEN(gltrans_doctype='IN') THEN\n                 (SELECT invchead_shipto_name\n                  FROM aropen LEFT OUTER JOIN\n                       invchead\n                       ON (invchead_id=aropen_cobmisc_id\n                       AND invchead_cust_id=aropen_cust_id)\n                  WHERE ((aropen_docnumber=gltrans_docnumber)\n                     AND (aropen_doctype='I')))\n         ELSE firstLine(gltrans_notes)\n       END AS f_notes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n       CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n         ELSE 0\n       END AS debit,\n       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n         ELSE 0\n       END AS credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       1 AS xtindentrole,\n       NULL AS transdate\nFROM gltrans, accnt\nWHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n   AND (gltrans_source = 'A/R')\n   AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n   )\n\nUNION\n-- Journals\nSELECT sltrans_id,\n       CASE WHEN(sltrans_doctype='IN') THEN 1\n            WHEN(sltrans_doctype='CM') THEN 2\n            WHEN(sltrans_doctype='DM') THEN 3\n            WHEN(sltrans_doctype='CD') THEN 4\n         ELSE -1\n       END AS altId,\n       sltrans_date, sltrans_source,\n       CASE WHEN(sltrans_doctype='IN') THEN <? value("invoice") ?>\n            WHEN(sltrans_doctype='CM') THEN <? value("creditmemo") ?>\n            WHEN(sltrans_doctype='DM') THEN <? value("debitmemo") ?>\n            WHEN(sltrans_doctype='CD') THEN <? value("cashdeposit") ?>\n         ELSE sltrans_doctype\n       END AS doctype,\n       sltrans_docnumber,\n       CASE WHEN(sltrans_doctype='IN') THEN\n                 (SELECT invchead_shipto_name\n                  FROM aropen LEFT OUTER JOIN\n                       invchead\n                       ON (invchead_id=aropen_cobmisc_id\n                       AND invchead_cust_id=aropen_cust_id)\n                  WHERE ((aropen_docnumber=sltrans_docnumber)\n                     AND (aropen_doctype='I')))\n         ELSE firstLine(sltrans_notes)\n       END AS f_notes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n       CASE WHEN (sltrans_amount < 0) THEN ABS(sltrans_amount)\n         ELSE 0\n       END AS debit,\n       CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n         ELSE 0\n       END AS credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       1 AS xtindentrole,\n       NULL AS transdate\nFROM sltrans, accnt\nWHERE ((sltrans_accnt_id=accnt_id)\n   AND (sltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n   AND (sltrans_source = 'A/R')\n   AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n   AND (sltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n      )\nORDER BY gltrans_date, gltrans_docnumber, xtindentrole;\n   admin   2011-12-21      0
33 277     projects        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: projects\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT prj_id AS id, prj_number, prj_name,\n  prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, \n  CASE WHEN(prj_status='P') THEN <? value("planning") ?>\n       WHEN(prj_status='O') THEN <? value("open") ?>\n       WHEN(prj_status='C') THEN <? value("complete") ?>\n       ELSE <? value("undefined") ?>\n  END AS prj_status, \n  prj_username, prj_owner_username,\n  COALESCE(SUM(prjtask_hours_budget), 0.0) AS budget_hrs,\n  COALESCE(SUM(prjtask_hours_actual), 0.0) AS actual_hrs,\n  COALESCE(SUM(prjtask_hours_budget - prjtask_hours_actual), 0.0) AS balance_hrs, \n  CASE WHEN COALESCE(SUM(prjtask_hours_budget - prjtask_hours_actual), 0.0) < 0 THEN \n  'error' END AS balance_hrs_qtforegroundrole, \n  'qty' AS budget_hrs_xtnumericrole, \n  'qty' AS actual_hrs_xtnumericrole, \n  'qty' AS balance_hrs_xtnumericrole \nFROM prj()\nLEFT OUTER JOIN prjtask ON (prj_id=prjtask_prj_id)\nWHERE (true)\n<? if exists("search_pattern") ?>\n   AND ( (prj_number ~* <? value("search_pattern") ?>)\n     OR  (prj_name ~* <? value("search_pattern") ?>) )\n<? endif ?>\n<? if exists("username") ?>\n  AND (prj_username=<? value("username") ?> OR prj_owner_username=<? value("username") ?>)\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (prj_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (prj_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (prj_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (prj_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if not exists("showComplete") ?>\n  AND (prj_status <> 'C')\n<? endif ?>\n<? if exists("id") ?>\n  AND (prj_id=<? value("id") ?>)\n<? endif ?>\nGROUP BY prj_id, prj_number, prj_name, prj_status, prj_username, prj_owner_username,\n  prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date\nORDER BY prj_number;\n     admin   2011-12-21      0
34 428     contactmerge    select  Processes contact selections Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: contactmerge\n-- Name: select\n-- Notes: Processes contact selections\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctselect(\n  <? value("cntct_id") ?>, \n  <? value("target") ?>) AS result;\n     admin   2011-11-23      0
35 427     contactmerge    selectcol       Selects a specific column Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: contactmerge\n-- Name: selectcol\n-- Notes: Selects a specific column\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctselectcol(<? value("cntct_id") ?>, <? value("col_number") ?>);\n        admin   2011-11-23      0
36 248     gleries checkeditable           -- Group: gleries\n-- Name:  checkeditable\n-- Notes: \nSELECT gltrans_id \nFROM accnt, gltrans \n  LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) \nWHERE ( (gltrans_accnt_id=accnt_id) \n  AND (gltrans_sequence=<? value("glSequence") ?>) \n  AND ( (gltrans_deleted) \n     OR (period_freeze) \n     OR (gltrans_rec) \n     OR (period_closed AND NOT accnt_closedpost) ) )\nLIMIT 1;      admin   2010-09-10      0
37 266     orderActivityByProject  detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: orderActivityByProject\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, \n  formatQty(qty) AS f_qty,\n  formatMoney(value) AS f_value,\n  'curr' AS qty_xtnumericrole,\n  'curr' AS value_xtnumericrole\nFROM (\n<? if exists("showSo") ?>\n----- QUOTES -----\nSELECT DISTINCT -1 AS id, \n       10 AS type,\n       '0' AS subtype,\n       1 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("quotes") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       0 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\n\nUNION ALL\n\nSELECT quhead_id AS id, \n       15 AS type,\n       quhead_number AS subtype,\n       1 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       quhead_number AS name,\n       CASE WHEN (quhead_status = 'C') THEN \n         <? value("converted") ?>\n            WHEN (quhead_status = 'X') THEN\n         <? value("canceled") ?>\n            WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n         <? value("open") ?>\n            ELSE\n         <? value("expired") ?>\n       END AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       1 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\nGROUP BY quhead_id, quhead_number, quhead_status, quhead_expire, quhead_freight, quhead_misc\n\nUNION ALL\n\nSELECT quitem_id AS id, \n       17 AS type,\n       quhead_number AS subtype,\n       1 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       quitem_linenumber::text AS name, \n       CASE WHEN (quhead_status = 'C') THEN \n         <? value("converted") ?>\n            WHEN (quhead_status = 'X') THEN\n         <? value("canceled") ?>\n            WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n         <? value("open") ?>\n            ELSE\n         <? value("Expired") ?>\n       END AS status,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       quitem_qtyord,\n       uom_name AS uom,\n       (quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio) AS value,\n       2 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n    JOIN uom ON (quitem_qty_uom_id = uom_id)\n    JOIN itemsite ON (quitem_itemsite_id = itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\n\nUNION ALL\n\nSELECT quhead_id AS id, \n       18 AS type,\n       quhead_number AS subtype,\n       1 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n       1 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\nGROUP BY quhead_id, quhead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n       19 AS type,\n       MAX(quhead_number) AS subtype,\n       1 AS section,\n       <? value("quotes") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("quotes") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n       1 AS xtindentrole\n  FROM quhead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=quhead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n<? if exists("owner_username") ?>\n   AND (quhead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\n\nUNION ALL\n\n------ SALES ORDERS ------\nSELECT DISTINCT -1 AS id, \n       20 AS type,\n       '0' AS subtype,\n       2 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("sos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       0 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT cohead_id AS id, \n       25 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       cohead_number::text AS name,\n      COALESCE((SELECT \n                  CASE WHEN (coitem_status = 'O') THEN\n                    <? value("open") ?>\n                       WHEN (coitem_status = 'C') THEN\n                    <? value("closed" ?>\n                      ELSE\n                    <? value("canceled") ?>\n                  END\n                FROM \n               (SELECT coitem_status,\n                   CASE \n                     WHEN (coitem_status = 'O') THEN 1\n                     WHEN (coitem_status = 'C') then 2\n                     ELSE  3\n                  END AS type\n                  FROM coitem\n                 WHERE (coitem_cohead_id=cohead_id)\n                 ORDER BY type\n                 LIMIT 1) AS sts) ,'O')\n        AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       1 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\nGROUP BY cohead_id, cohead_number\n\nUNION ALL\n\nSELECT coitem_id AS id, \n       27 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       coitem_linenumber::text AS name, \n       CASE WHEN (coitem_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (coitem_status = 'C') THEN\n         <? value("closed") ?>\n            WHEN (coitem_status = 'X') THEN\n         <? value("canceled") ?>\n       END AS status,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       coitem_qtyord,\n       uom_name AS uom,\n       (coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) AS value,\n       2 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n    JOIN uom ON (coitem_qty_uom_id = uom_id)\n    JOIN itemsite ON (coitem_itemsite_id = itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT cohead_id AS id, \n       28 AS type,\n       cohead_number::text AS subtype,\n       2 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n       1 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\nGROUP BY cohead_id, cohead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n       29 AS type,\n       MAX(cohead_number::text) AS subtype,\n       2 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("sos") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n       1 AS xtindentrole\n  FROM cohead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=cohead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\n------ INVOICES -------\nSELECT DISTINCT -1 AS id, \n       30 AS type,\n       '0' AS subtype,\n       3 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("invoices") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       0 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT invchead_id AS id,\n       35 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       invchead_invcnumber::text AS name,\n       CASE WHEN (invchead_posted) THEN\n         <? value("posted") ?>\n       ELSE <? value("unposted") ?>\n       END AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       NULL AS value,\n       1 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\nGROUP BY invchead_id, invchead_invcnumber, invchead_freight, invchead_misc_amount, invchead_posted\n\nUNION ALL\n\nSELECT invcitem_id AS id, \n       37 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       invcitem_linenumber::text AS name, \n       CASE WHEN (invchead_posted) THEN\n         <? value("posted") ?>\n       ELSE <? value("unposted") ?>\n       END AS status,\n       COALESCE(item_number,invcitem_number) AS item,\n       COALESCE(item_descrip1 || ' ' || item_descrip2,invcitem_descrip) AS descrip,\n       invcitem_billed AS qty,\n       uom_name AS uom,\n       (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) AS value,\n       2 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n    LEFT OUTER JOIN item ON (invcitem_item_id = item_id)\n    LEFT OUTER JOIN uom ON (invcitem_qty_uom_id = uom_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT invchead_id AS id, \n       38 AS type,\n       invchead_invcnumber::text AS subtype,\n       3 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n       1 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\nGROUP BY invchead_id, invchead_invcnumber\n\nUNION ALL\n\nSELECT -1 AS id, \n       39 AS type,\n       MAX(invchead_invcnumber::text) AS subtype,\n       3 AS section,\n       <? value("invoices") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("invoices") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n       1 AS xtindentrole\n  FROM invchead\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=invchead_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\n\n<? endif ?>\n\n\n<? if exists("showWo") ?>\n\n<?   if exists("showSo") ?>\n\nUNION ALL\n\n<?   endif ?>\n\n------ WORK ORDERS -------\nSELECT DISTINCT -1 AS id, \n       40 AS type,\n       '0' AS subtype,\n       4 AS section,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       <? value("wos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       0 AS xtindentrole\n  FROM wo\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=wo_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (wo_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT wo_id AS id, \n       45 AS type,\n       formatWoNumber(wo_id) AS subtype,\n       4 AS section,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       formatWoNumber(wo_id) AS name,\n       CASE WHEN (wo_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (wo_status = 'E') THEN\n         <? value("exploded") ?>\n            WHEN (wo_status = 'R') THEN\n         <? value("released") ?>\n            WHEN (wo_status = 'I') THEN\n         <? value("inprocess") ?>\n            WHEN (wo_status = 'C') THEN\n         <? value("closed") ?>\n       END AS status,\n       item_number AS item,\n       item_descrip1 || ' ' || item_descrip2 AS descrip,\n       wo_qtyord AS qty,\n       uom_name AS uom,\n       wo_postedvalue AS value,\n       1 AS xtindentrole\n  FROM wo\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=wo_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n    JOIN item ON (itemsite_item_id=item_id)\n    JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (wo_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT -1 AS id, \n       49 AS type,\n       MAX(formatWoNumber(wo_id)) AS subtype,\n       4 AS section,\n       <? value("wos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("wos") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(wo_postedvalue) AS value,\n       1 AS xtindentrole\n  FROM wo\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=wo_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (wo_prj_id = <? value("prj_id") ?>)\n\n<? endif ?>\n\n\n<? if exists("showPo") ?>\n<?   if exists("showSo") ?>\n UNION ALL\n<? elseif exists("showWo") ?>\n UNION ALL\n\n<? endif ?>\n------ PURCHASE REQUESTS ------\nSELECT DISTINCT -1 AS id, \n       50 AS type,\n       '0' AS subtype,\n       5 AS section,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       <? value("prs") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       0 AS xtindentrole\n  FROM pr\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=pr_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (pr_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT pr_id AS id, \n       55 AS type,\n       pr_number::text || '-' || pr_subnumber::text AS subtype,\n       5 AS section,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       pr_number::text || '-' || pr_subnumber::text AS name,\n       <? value("open") ?> AS status, \n       item_number AS item,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       pr_qtyreq AS qty,\n       uom_name AS uom,\n       stdcost(item_id) * pr_qtyreq AS value,\n       1 AS xtindentrole\n  FROM pr\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=pr_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n    JOIN uom ON (item_inv_uom_id = uom_id)\n WHERE (pr_prj_id=<? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT -1 AS id, \n       59 AS type,\n       MAX(pr_number::text || '-' || pr_subnumber::text) AS subtype,\n       5 AS section,\n       <? value("prs") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("prs") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(stdcost(item_id) * pr_qtyreq) AS value,\n       1 AS xtindentrole\n  FROM pr\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=pr_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n    JOIN item ON (itemsite_item_id = item_id)\n WHERE (pr_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\n------ PURCHASE ORDERS ------\nSELECT DISTINCT -1 AS id, \n       60 AS type,\n       '0' AS subtype,\n       6 AS section,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       <? value("pos") ?> AS name,\n       NULL::text AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL::numeric AS qty,\n       NULL::text AS uom,\n       NULL::numeric AS value,\n       0 AS xtindentrole\n  FROM poitem\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT pohead_id AS id,\n       65 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       pohead_number::text AS name,\n       CASE WHEN (pohead_status = 'U') THEN\n         <? value("unreleased") ?>\n            WHEN (pohead_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (pohead_status = 'C') THEN\n         <? value("closed") ?>\n       END AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL AS uom,\n       NULL AS value,\n       1 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\nGROUP BY pohead_id, pohead_number, pohead_freight, pohead_status\n\nUNION ALL\n\nSELECT poitem_id AS id, \n       67 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       poitem_linenumber::text AS name, \n       CASE WHEN (poitem_status = 'U') THEN\n         <? value("unreleased") ?>\n            WHEN (poitem_status = 'O') THEN\n         <? value("open") ?>\n            WHEN (poitem_status = 'C') THEN\n         <? value("closed") ?>\n       END AS status,\n       COALESCE(item_number,poitem_vend_item_number) AS item,\n       COALESCE((item_descrip1 || ' ' || item_descrip2),poitem_vend_item_descrip) AS descrip,\n       poitem_qty_ordered,\n       poitem_vend_uom AS uom,\n       (poitem_qty_ordered * poitem_unitprice) AS value,\n       2 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n    LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n    LEFT OUTER JOIN item ON (itemsite_item_id = item_id)\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT pohead_id AS id, \n       68 AS type,\n       pohead_number::text AS subtype,\n       6 AS section,\n       <? value("pos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n       1 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\nGROUP BY pohead_id, pohead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n       69 AS type,\n       MAX(pohead_number::text) AS subtype,\n       6 AS section,\n       <? value("sos") ?> AS section_qtdisplayrole,\n       <? value("total") ?> || ' ' || <? value("pos") ?> AS name,\n       NULL AS status,\n       NULL::text AS item,\n       NULL::text AS descrip,\n       NULL AS qty,\n       NULL::text AS uom,\n       SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n       1 AS xtindentrole\n  FROM pohead\n    JOIN poitem ON (poitem_pohead_id = pohead_id)\n<? if exists("owner_username") ?>\n    JOIN prj ON (prj_id=poitem_prj_id\n            AND ((prj_owner_username=<? value("owner_username") ?>) OR (prj_username=<? value("owner_username") ?>)))\n<? endif ?>\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\n\n<? endif ?>\n\n) data\nORDER BY section, subtype, type, id;\n    admin   2011-11-23      0
38 429     invoices        print   used by printInvoices Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: invoices\n-- Name: print\n-- Notes: used by printInvoices\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * FROM\n  (\n  SELECT invchead_id, invchead_invcnumber, invchead_ordernumber,\n         findCustomerForm(invchead_cust_id, 'I') AS reportname\n  FROM invchead\n  WHERE (NOT invchead_printed)\n  AND   (NOT invchead_posted)\n<? if exists("shipvia") ?>\n  AND   (invchead_shipvia=<? value("shipvia") ?>) \n<? endif ?>\n  ) AS data\nWHERE   (checkInvoiceSitePrivs(invchead_id))\nORDER BY invchead_ordernumber;\n  admin   2011-11-23      0
39 419     contactmerge    delete  Delete a contact Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: contactmerge\n-- Name: delete\n-- Notes: Delete a contact\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntct WHERE (cntct_id=<? value("cntct_id") ?>);\n   admin   2011-11-23      0
40 434     accountNumbers  detail  used by accountNumbers Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: accountNumbers\n-- Name: detail\n-- Notes: used by accountNumbers\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, *,\n       CASE WHEN(accnt_type='A') THEN <? value("asset") ?>\n            WHEN(accnt_type='E') THEN <? value("expense") ?>\n            WHEN(accnt_type='L') THEN <? value("liability") ?>\n            WHEN(accnt_type='Q') THEN <? value("equity") ?>\n            WHEN(accnt_type='R') THEN <? value("revenue") ?>\n            ELSE accnt_type\n       END AS accnt_type_qtdisplayrole,\n       accnt_active \n  FROM (ONLY accnt LEFT OUTER JOIN\n             company ON (accnt_company=company_number)) \n       LEFT OUTER JOIN subaccnttype ON (accnt_type=subaccnttype_accnt_type AND accnt_subaccnttype_code=subaccnttype_code)\n WHERE true\n<? if not exists("showExternal") ?>\n  AND (NOT COALESCE(company_external, false)) \n<? endif ?>\n<? if not exists("showInactive") ?>\n  AND COALESCE(accnt_active, false)\n<? endif ?>\nORDER BY accnt_number, accnt_sub, accnt_profit;\n\n        admin   2011-11-23      0
41 230     addresses       detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: addresses\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (addr_country, addr_state, addr_city, addr_line1, addr_number) \n  addr_id, addr_line1, addr_line2, addr_line3, \n  addr_city, addr_state, addr_country, addr_postalcode \n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM addr \n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='ADDR') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=addr_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if not exists("showInactive") ?> \n AND addr_active \n<? endif ?>\n<? literal("charClause") ?>\nORDER BY addr_country, addr_state, addr_city, addr_line1, addr_number;\n        admin   2011-11-23      0
42 35      allocations     detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: allocations\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, type, order_number, item_number, totalqty, relievedqty, balanceqty, duedate,\n       balanceqty AS runningbal,\n       'qty' AS totalqty_xtnumericrole,\n       'qty' AS relievedqty_xtnumericrole,\n       'qty' AS balanceqty_xtnumericrole,\n       0 AS runningbal_xtrunningrole,\n       'qty' AS runningbal_xtnumericrole,\n       CASE WHEN (duedate < CURRENT_DATE) THEN 'error'\n       END AS duedate_qtforegroundrole\nFROM\n(\nSELECT womatl_id AS source_id, TEXT('W/O') AS type,\n       formatWoNumber(wo_id) AS order_number,\n       paritem.item_number,\n       itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq)  AS totalqty,\n       itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss) AS relievedqty,\n       itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, noNeg(womatl_qtyreq - womatl_qtyiss)) AS balanceqty,\n       womatl_duedate AS duedate\n\nFROM womatl, wo, itemsite AS parent, itemsite AS component, item AS paritem, item AS compitem\nWHERE ((womatl_wo_id=wo_id)\n  AND (wo_status<>'C')\n  AND (wo_itemsite_id=parent.itemsite_id)\n  AND (womatl_itemsite_id=component.itemsite_id)\n  AND (parent.itemsite_item_id=paritem.item_id)\n  AND (component.itemsite_item_id=compitem.item_id)\n  AND (compitem.item_type != 'T')\n  AND (component.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND (component.itemsite_item_id=<? value("item_id") ?>)\n<? if exists("leadTime") ?>\n  AND (womatl_duedate <= (CURRENT_DATE + component.itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND (womatl_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND (womatl_duedate <= <? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND (womatl_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n)\n\nUNION \n\n-- Special handling for tools\nSELECT womatl_id AS source_id, TEXT('W/O') AS type,\n       formatWoNumber(wo_id) AS order_number,\n       paritem.item_number,\n       itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq)  AS totalqty,\n       COALESCE(sum(invhist_invqty),0) AS relievedqty,\n       noNeg(itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) - COALESCE(sum(invhist_invqty),0)) AS balanceqty,\n       womatl_duedate AS duedate\n\nFROM itemsite AS parent, itemsite AS component, item paritem, item AS compitem, wo, womatl\n  LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n  LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n                          AND (invhist_invqty > 0))\nWHERE ((womatl_wo_id=wo_id)\n  AND (wo_status<>'C')\n  AND (wo_itemsite_id=parent.itemsite_id)\n  AND (womatl_itemsite_id=component.itemsite_id)\n  AND (parent.itemsite_item_id=paritem.item_id)\n  AND (component.itemsite_item_id=compitem.item_id)\n  AND (compitem.item_type='T')\n  AND (component.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND (component.itemsite_item_id=<? value("item_id") ?>)\n<? if exists("leadTime") ?>\n  AND (womatl_duedate <= (CURRENT_DATE + component.itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND (womatl_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND (womatl_duedate <= <? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND (womatl_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n)\nGROUP BY womatl_id, wo_id, paritem.item_number, womatl_uom_id, womatl_qtyreq, womatl_duedate, component.itemsite_item_id\n\nUNION \nSELECT coitem_id AS source_id, TEXT('S/O') AS type,\n       formatSoNumber(coitem_id) AS order_number,\n       item_number,\n       itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, coitem_qtyord) AS totalqty,\n       itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, (coitem_qtyshipped + qtyAtShipping(coitem_id)) - coitem_qtyreturned) as relievedqty,\n       itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, noNeg(coitem_qtyord - (coitem_qtyshipped + qtyAtShipping(coitem_id)) + coitem_qtyreturned)) AS balanceqty,\n       coitem_scheddate as duedate\nFROM cohead, coitem, itemsite, item \nWHERE ( (coitem_cohead_id=cohead_id)\n  AND  (coitem_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_sold)\n  AND  (coitem_status NOT IN ('C','X'))\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? if exists("leadTime") ?>\n  AND  (coitem_scheddate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (coitem_scheddate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (coitem_scheddate <= <? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n)\n\n<? if exists("MultiWhs") ?>\nUNION \nSELECT toitem_id AS source_id, TEXT('T/O') AS type,\n       TEXT(tohead_number) AS order_number,\n       item_number,\n       toitem_qty_ordered AS totalqty,\n       (toitem_qty_shipped + qtyAtShipping(toitem_id)) as relievedqty,\n       noNeg(toitem_qty_ordered - (toitem_qty_shipped + qtyAtShipping(toitem_id))) AS balanceqty,\n       toitem_schedshipdate as duedate\nFROM tohead, toitem, itemsite, item \nWHERE ((toitem_tohead_id=tohead_id)\n  AND  (toitem_item_id=itemsite_item_id)\n  AND  (tohead_src_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=item_id)\n  AND  (toitem_status NOT IN ('C','X'))\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? if exists("leadTime") ?>\n  AND  (toitem_schedshipdate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (toitem_schedshipdate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (toitem_schedshipdate <= <? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (toitem_schedshipdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n)\n<? endif ?>\n) AS dummy\n\nORDER BY duedate;\n   admin   2011-11-23      0
43 36      apAging detail  used by dspTimePhasedOpenAPItems Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: apAging\n-- Name: detail\n-- Notes: used by dspTimePhasedOpenAPItems\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apaging_vend_id, apaging_vend_number, apaging_vend_name,\n       SUM(apaging_total_val) AS apaging_total_val_sum,\n       SUM(apaging_cur_val) AS apaging_cur_val_sum,\n       SUM(apaging_thirty_val) AS apaging_thirty_val_sum,\n       SUM(apaging_sixty_val) AS apaging_sixty_val_sum,\n       SUM(apaging_ninety_val) AS apaging_ninety_val_sum,\n       SUM(apaging_plus_val) AS apaging_plus_val_sum,\n       'curr' AS apaging_total_val_sum_xtnumericrole,\n       'curr' AS apaging_cur_val_sum_xtnumericrole,\n       'curr' AS apaging_thirty_val_sum_xtnumericrole,\n       'curr' AS apaging_sixty_val_sum_xtnumericrole,\n       'curr' AS apaging_ninety_val_sum_xtnumericrole,\n       'curr' AS apaging_plus_val_sum_xtnumericrole,\n       0 AS apaging_total_val_sum_xttotalrole,\n       0 AS apaging_cur_val_sum_xttotalrole,\n       0 AS apaging_thirty_val_sum_xttotalrole,\n       0 AS apaging_sixty_val_sum_xttotalrole,\n       0 AS apaging_ninety_val_sum_xttotalrole,\n       0 AS apaging_plus_val_sum_xttotalrole\n\nFROM apaging(<? value("relDate") ?>, <? value("useDocDate") ?>)\n<? if exists("vend_id") ?>\nWHERE (apaging_vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\nWHERE (apaging_vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\nWHERE (apaging_vendtype_code ~ <? value("vendtype_pattern") ?>)\n<? endif ?>\nGROUP BY apaging_vend_number,apaging_vend_id,apaging_vend_name\nORDER BY apaging_vend_number;\n   admin   2011-11-23      0
44 94      apApplications  detail  used by dspAPApplications Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: apApplications\n-- Name: detail\n-- Notes: used by dspAPApplications\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apapply.*,\n       vend_number, vend_name,\n       CASE \n         WHEN apapply_source_doctype = 'K' THEN\n            apapply_checkhead_id\n         ELSE\n            apapply_source_apopen_id \n       END AS apapply_source_docnumber_xtidrole,\n       CASE WHEN (apapply_source_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (apapply_source_doctype='K') THEN <? value("check") ?>\n            ELSE apapply_source_doctype\n       END AS apapply_source_doctype_qtdisplayrole,\n       CASE WHEN (apapply_target_doctype='D') THEN apapply_target_apopen_id\n            WHEN (apapply_target_doctype='V') THEN (SELECT vohead_id\n                                                    FROM vohead\n                                                    WHERE (vohead_number=apapply_target_docnumber))\n       END AS apapply_target_docnumber_xtidrole,\n       CASE WHEN (apapply_target_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (apapply_target_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (apapply_target_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apapply_target_doctype='K') THEN <? value("check") ?>\n            ELSE apapply_target_doctype\n       END AS apapply_target_doctype_qtdisplayrole,\n       formatDate(apapply_postdate) AS f_postdate,-- for openrpt\n       formatMoney(apapply_amount) AS f_amount,   -- for openrpt\n       currConcat(apapply_curr_id) AS currAbbr,\n       currtobase(apapply_curr_id,apapply_amount,apapply_postdate) AS base_applied,\n       'curr' AS apapply_amount_xtnumericrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole\nFROM apapply, vendinfo\nWHERE ( (apapply_vend_id=vend_id)\n  AND   (apapply_postdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("doctypeList") ?>\n  AND   (apapply_source_doctype IN (<? literal("doctypeList") ?>))\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND   (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n  AND   (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND   (vend_vendtype_id IN (SELECT vendtype_id FROM vendtype\n                              WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n      )\nORDER BY apapply_postdate, apapply_source_docnumber;\n   admin   2011-11-23      0
45 129     apOpenItems     detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: apOpenItems\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apopen_id, apopen_ponumber, apopen_docnumber,\n                    CASE WHEN (apopen_doctype='C') THEN <? value("creditMemo") ?>\n                         WHEN (apopen_doctype='D') THEN <? value("debitMemo") ?>\n                         WHEN (apopen_doctype='V') THEN <? value("voucher") ?>\n                         ELSE <? value("other") ?>\n                    END AS f_doctype,\n                    vend_number, vend_name,\n                    apopen_invcnumber AS invoicenumber,\n                    apopen_docdate, apopen_duedate, apopen_amount, apopen_status, \n<? if exists("includeFormatted") ?>\n                    formatDate(apopen_docdate) AS f_docdate, \n                    formatDate(apopen_duedate) AS f_duedate, \n                    formatMoney(apopen_amount) AS f_amount,\n                    formatMoney(apopen_paid - COALESCE(SUM(apapply_target_paid),0)) AS f_paid,\n                    formatMoney((apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0)) * \n                    CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1 \n                    END) AS f_balance,\n                    formatMoney((apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0)) \n                    / apopen_curr_rate * (CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1 \n                         END)) AS f_base_balance,\n<? endif ?>\n                    apopen_paid - COALESCE(SUM(apapply_target_paid),0) AS paid,\n                    (apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0)) * \n                    CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1 \n                    END AS balance,\n                    currConcat(apopen_curr_id) AS currAbbr,\n                    (apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0)) \n                    / apopen_curr_rate * (CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1 \n                         END) AS base_balance,\n                    'curr' AS apopen_amount_xtnumericrole,\n                    'curr' AS paid_xtnumericrole,\n                    'curr' AS balance_xtnumericrole,\n                    'curr' AS base_balance_xtnumericrole,\n                    0 AS base_balance_xttotalrole \n             FROM apopen \n               JOIN vendinfo ON (vend_id=apopen_vend_id)\n               JOIN vendtype ON (vendtype_id=vend_vendtype_id)\n               LEFT OUTER JOIN apapply ON (((apopen_id=apapply_target_apopen_id) \n                                       OR (apopen_id=apapply_source_apopen_id)) \n                                       AND (apapply_postdate > <? value("asofDate") ?>)) \n              WHERE ( (COALESCE(apopen_closedate,date <? value("asofDate") ?> + integer '1')><? value("asofDate") ?>) \n                AND   (apopen_docdate<=<? value("asofDate") ?>)\n<? if exists("vend_id") ?>\n                AND   (apopen_vend_id=<? value("vend_id") ?>)\n<? endif ?>\n<? if exists("vendtype_id") ?>\n                AND   (vendtype_id=<? value("vendtype_id") ?>)\n<? endif ?>\n<? if exists("vendtype_pattern") ?>\n                AND   (vendtype_code~<? value("vendtype_pattern") ?>)\n<? endif ?>\n                AND   (apopen_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) ) \n              GROUP BY apopen_id, apopen_ponumber, apopen_docnumber,apopen_doctype, apopen_invcnumber, apopen_docdate, \n                apopen_duedate, apopen_docdate, apopen_amount, apopen_paid, apopen_curr_id, apopen_curr_rate,\n                apopen.apopen_status, vend_number, vend_name\n              ORDER BY apopen_docdate;\n    admin   2011-11-23      0
46 308     apOpenItems     selectedpayments         Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: apOpenItems\n-- Name:  selectedpayments\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apopen_id, apselect_id,\n       (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bank,\n       (vend_number || '-' || vend_name) AS f_vendor,\n       CASE WHEN (apopen_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apopen_doctype='D') THEN <? value("debitmemo") ?>\n       END AS doctype,\n       apopen_docnumber, apopen_ponumber, apselect_amount,\n       apopen_invcnumber,\n       currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) AS apselect_amount_base,\n       currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) AS apselect_running_base,\n       currConcat(apselect_curr_id) AS currAbbr,\n       'curr' AS apselect_amount_xtnumericrole,\n       'curr' AS apselect_amount_base_xtnumericrole,\n       'curr' AS apselect_running_base_xtnumericrole,\n       0 AS apselect_running_base_xtrunninginit,\n       1 AS apselect_running_base_xtrunningrole\nFROM apopen, apselect, vend, bankaccnt\nWHERE ( (apopen_vend_id=vend_id)\n  AND   (apselect_apopen_id=apopen_id)\n  AND   (apselect_bankaccnt_id=bankaccnt_id) \n<? if exists("bankaccntid") ?>\n  AND   (bankaccnt_id=<? value("bankaccntid") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n  AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND (vend_vendtype_id IN (SELECT vendtype_id\n                            FROM vendtype\n                            WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n )\nORDER BY bankaccnt_name, vend_number, apopen_docnumber;\n       admin   2011-11-23      0
47 309     apOpenItems     selectpayments   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: apOpenItems\n-- Name:  selectpayments\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * FROM (\nSELECT apopen_id, COALESCE(apselect_id, -1) AS apselectid,\n       (vend_number || '-' || vend_name) AS vendor,\n       CASE WHEN (apopen_doctype='V') THEN <? value("voucher") ?>\n            When (apopen_doctype='D') THEN <? value("debitMemo") ?>\n       END AS doctype,\n       apopen_docnumber, apopen_ponumber,\n       apopen_duedate,\n       apopen_docdate, apopen_status,\n       CASE WHEN (apopen_status = 'H') THEN 'error' END AS qtforegroundrole,\n       (apopen_amount - apopen_paid - apCheckPending(apopen_id)) AS amount,\n       ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) AS base_amount,\n       ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) AS running_amount,\n       COALESCE(apselect_amount, 0.0) AS selected,\n       (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) AS base_selected,\n       (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) AS running_selected,\n       COALESCE(apselect_discount,0.0) AS discount,\n       (COALESCE(apselect_discount,0.0) / apopen_curr_rate)AS base_discount,\n       CASE WHEN (apopen_duedate < CURRENT_DATE) THEN 'error'\n            WHEN(apopen_duedate > CURRENT_DATE) THEN 'emphasis'\n            WHEN(CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate)) THEN 'altemphasis'\n       END AS apopen_duedate_qtforegroundrole, \n       apopen_invcnumber,\n       currConcat(apopen_curr_id) AS curr_concat,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS selected_xtnumericrole,\n       'curr' AS running_selected_xtnumericrole,\n       'curr' AS running_amount_xtnumericrole,\n       'curr' AS discount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS base_selected_xtnumericrole,\n       'curr' AS base_discount_xtnumericrole,\n       0      AS base_amount_xttotalrole,\n       0      AS base_selected_xttotalrole,\n       0      AS base_discount_xttotalrole,\n       0      AS running_selected_xtrunninginit,\n       0      AS running_amount_xtrunninginit,\n       1      AS running_selected_xtrunningrole,\n       1      AS running_amount_xtrunningrole\nFROM vendinfo JOIN apopen ON (apopen_vend_id=vend_id)\n              LEFT OUTER JOIN apselect ON (apselect_apopen_id=apopen_id)\nWHERE ( (apopen_open)\n AND (apopen_doctype IN ('V', 'D'))\n<? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n AND (vend_vendtype_id IN (SELECT vendtype_id\n                           FROM vendtype\n                           WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n<? if exists("olderDate") ?>\n AND (apopen_duedate <= <? value("olderDate") ?>)\n<? elseif exists("startDate") ?>\n AND (apopen_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("curr_id") ?>\n AND (apopen_curr_id=<? value("curr_id") ?>)\n<? endif ?>\n)\nORDER BY apopen_duedate, (apopen_amount - apopen_paid) DESC) AS data\nWHERE (amount != 0);\n       admin   2011-11-23      0
48 37      arAging detail  used by dspTimePhasedOpenARItems Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: arAging\n-- Name: detail\n-- Notes: used by dspTimePhasedOpenARItems\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT araging_cust_id, araging_cust_number, araging_cust_name,\n       SUM(araging_total_val) AS araging_total_val_sum,\n       SUM(araging_cur_val) AS araging_cur_val_sum,\n       SUM(araging_thirty_val) AS araging_thirty_val_sum,\n       SUM(araging_sixty_val) AS araging_sixty_val_sum,\n       SUM(araging_ninety_val) AS araging_ninety_val_sum,\n       SUM(araging_plus_val) AS araging_plus_val_sum,\n       'curr' AS araging_total_val_sum_xtnumericrole,\n       'curr' AS araging_cur_val_sum_xtnumericrole,\n       'curr' AS araging_thirty_val_sum_xtnumericrole,\n       'curr' AS araging_sixty_val_sum_xtnumericrole,\n       'curr' AS araging_ninety_val_sum_xtnumericrole,\n       'curr' AS araging_plus_val_sum_xtnumericrole,\n       0 AS araging_total_val_sum_xttotalrole,\n       0 AS araging_cur_val_sum_xttotalrole,\n       0 AS araging_thirty_val_sum_xttotalrole,\n       0 AS araging_sixty_val_sum_xttotalrole,\n       0 AS araging_ninety_val_sum_xttotalrole,\n       0 AS araging_plus_val_sum_xttotalrole\n\nFROM araging(<? value("relDate") ?>, <? value("useDocDate") ?>) \n<? if exists("cust_id") ?>\nWHERE (araging_cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\nWHERE (araging_cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\nLEFT OUTER JOIN custgrpitem ON (araging_cust_id = custgrpitem_cust_id)\nWHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\nWHERE (araging_custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?>\nGROUP BY araging_cust_number,araging_cust_id,araging_cust_name\nORDER BY araging_cust_number;\n     admin   2011-11-23      0
49 38      arApplications  detail  used by dspARApplications Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: arApplications\n-- Name: detail\n-- Notes: used by dspARApplications\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT arapply.*,\n       cust_number, cust_name,\n       CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n            WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n            WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n            WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n            WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n            WHEN (arapply_fundstype='A') THEN <? value("americanExpress") ?>\n            WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n            WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n            WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n            WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n            WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n       END AS doctype,\n       CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n            WHEN (arapply_source_doctype='K') THEN <? value("apcheck") ?>\n            ELSE <? value("other") ?>\n       END AS sourcedoctype,\n       CASE WHEN (arapply_target_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (arapply_target_doctype='I') THEN <? value("invoice") ?>\n            WHEN (arapply_target_doctype='K') THEN <? value("apcheck") ?>\n            ELSE <? value("other") ?>\n       END AS targetdoctype,\n       CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)\n            ELSE arapply_refnumber\n       END AS source,\n       TEXT(arapply_target_docnumber) AS target,\n       currConcat(arapply_curr_id) AS currAbbr,\n       currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied,\n       'curr' AS arapply_applied_xtnumericrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole\nFROM arapply, custinfo\nWHERE ( (arapply_cust_id=cust_id)\n  AND   (arapply_postdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  AND   (arapply_source_doctype IN (\n<? if exists("includeCreditMemos") ?>\n  <? if exists("includeCashReceipts") ?>\n            'K', 'C', 'R'\n  <? else ?>\n            'C', 'R'\n  <? endif ?>\n<? else ?>\n            'K'\n<? endif ?> ))\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype\n                              WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\nORDER BY arapply_postdate, source;\n   admin   2011-11-23      0
50 40      arOpenApplications      detail  used by applyARCreditMemo, cashReceipt Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: arOpenApplications\n-- Name: detail\n-- Notes: used by applyARCreditMemo, cashReceipt\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS applied_xtnumericrole,\n       'curr' AS pending_xtnumericrole,\n       currConcat(balance_curr) AS balance_curr_qtdisplayrole,\n       CASE WHEN (doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (doctype='I') THEN <? value("invoice") ?>\n            WHEN (doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (doctype='R') THEN <? value("cashdeposit") ?>\n       END AS doctype_qtdisplayrole,\n       CASE WHEN (doctype='C') THEN 'emphasis'\n            WHEN (doctype='R') THEN 'altemphasis'\n       END AS doctype_qtforegroundrole,\n<? if exists("cashrcpt_id") ?>\n    CASE WHEN (pending - currtobase(cashrcpt_curr_id, applied, cashrcpt_distdate) - discount > balance) \n    AND doctype IN ('I','D')\n    AND NOT cashrcpt_posted\n<? else ?>\n    CASE WHEN (pending - applied - discount > balance)\n<? endif ?>  \n       THEN 'error' END AS qtforegroundrole\nFROM (SELECT\n      aropen_id,\n<? if exists("cashrcpt_id") ?>\n       COALESCE(s.cashrcptitem_id, -1) AS alt_id,\n       COALESCE(cashrcpt_posted,FALSE) AS cashrcpt_posted,\n       cashrcpt_curr_id,\n       cashrcpt_distdate,\n<? endif ?>\n       aropen_doctype AS doctype,\n       aropen_docnumber, aropen_ordernumber,\n       aropen_docdate, aropen_duedate,\n       (aropen_amount - aropen_paid - calcpendingarapplications(aropen_id)) *\n       (CASE WHEN aropen_doctype IN ('C','R') THEN -1 ELSE 1 END ) AS balance,\n       aropen_curr_id AS balance_curr,\n<? if exists("cashrcpt_id") ?>\n       (SELECT COALESCE(SUM(p.cashrcptitem_amount), 0)\n                      FROM cashrcptitem p\n                     WHERE (p.cashrcptitem_aropen_id=aropen_id)\n                     AND (p.cashrcptitem_cashrcpt_id=<? value("cashrcpt_id") ?>))\n                   AS applied,\n       (SELECT COALESCE(SUM(p.cashrcptitem_discount), 0)\n                      FROM cashrcptitem p\n                     WHERE (p.cashrcptitem_aropen_id=aropen_id)\n                     AND (p.cashrcptitem_cashrcpt_id=<? value("cashrcpt_id") ?>))\n                   AS discount,\n       currConcat(cashrcpt_curr_id) AS applied_curr,\n<? elseif exists("source_aropen_id") ?>\n       COALESCE(arcreditapply_amount, 0) AS applied,\n       0 AS discount,\n       currConcat(arcreditapply_curr_id) AS applied_curr,\n<? endif ?>\n       calcpendingarapplications(aropen_id) AS pending,\n       currConcat(aropen_curr_id) AS pending_curr\n FROM aropen LEFT OUTER JOIN\n <? if exists("cashrcpt_id") ?>\n      cashrcptitem s ON (s.cashrcptitem_aropen_id=aropen_id\n                     AND cashrcptitem_cashrcpt_id=<? value("cashrcpt_id") ?>)\n        LEFT OUTER JOIN\n      cashrcpt ON (cashrcptitem_cashrcpt_id = cashrcpt_id\n               AND cashrcpt_id=<? value("cashrcpt_id") ?>)\n<? elseif exists("source_aropen_id") ?>\n      arcreditapply ON ((arcreditapply_source_aropen_id=<? value("source_aropen_id") ?>)\n                    AND (arcreditapply_target_aropen_id=aropen_id) )\n<? endif ?>\n WHERE (\n<? if exists("posted") ?> \n   (s.cashrcptitem_aropen_id=aropen_id)\n<? else ?>\n   (aropen_open)\n<? endif ?>\n<? if exists("noCredits") ?>\n   AND (aropen_doctype IN ('D', 'I'))\n<? elseif exists("cashrcpt_id") ?>\n<? else ?>\n   AND (aropen_doctype IN ('D', 'I'))\n<? endif ?>\n   AND (aropen_cust_id=<? value("cust_id") ?>) )\n ) AS dummy\n ORDER BY aropen_duedate, balance;\n     admin   2011-11-23      0
51 435     backlog detail   Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: backlog\n-- Name: detail\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n       cohead_id, coitem_id, *, currconcat(cohead_curr_id) AS currAbbr,\n       CASE WHEN xtindentrole = 0 THEN cohead_number\n       END AS coitem_linenumber_qtdisplayrole,\n       CASE WHEN xtindentrole = 0 THEN cust_name\n       END AS item_number_qtdisplayrole,\n       CASE WHEN (coitem_scheddate <= current_date AND qtybalance > 0) THEN 'error' \n            WHEN (qtybalance > 0) THEN 'emphasis' \n       END AS coitem_scheddate_qtforegroundrole,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS coitem_qtyshipped_xtnumericrole,\n       'qty' AS coitem_qtyreturned_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'qty' AS qtybalance_xtnumericrole,\n       'qty' AS qtyavailable_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'salesprice' AS baseunitprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS baseextprice_xtnumericrole,\n       'curr' AS extpricebalance_xtnumericrole,\n       'curr' AS baseextpricebalance_xtnumericrole,\n       0 AS coitem_qtyord_xttotalrole,\n       0 AS coitem_qtyshipped_xttotalrole,\n       0 AS coitem_qtyreturned_xttotalrole,\n       0 AS qtybalance_xttotalrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS baseextpricebalance_xttotalrole\nFROM (\n  SELECT\n         0 AS xtindentrole,\n         -- dummy coitem record\n         -1            AS coitem_id,        NULL::INTEGER AS coitem_cohead_id,\n         -1            AS coitem_linenumber,NULL::INTEGER AS coitem_itemsite_id,\n         NULL::TEXT    AS coitem_status,    NULL::DATE AS coitem_scheddate,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         NULL::DATE    AS coitem_promdate,  NULL::NUMERIC AS coitem_qtyord,\n         NULL::NUMERIC AS coitem_unitcost,  NULL::NUMERIC AS coitem_price,\n         NULL::NUMERIC AS coitem_custprice, NULL::NUMERIC AS coitem_qtyshipped,\n         NULL::INTEGER AS coitem_order_id,  NULL::TEXT    AS coitem_memo,\n         NULL::BOOLEAN AS coitem_imported,  NULL::NUMERIC AS coitem_qtyreturned,\n         NULL::TIMESTAMP AS coitem_closedate, NULL::BOOLEAN AS coitem_firm,\n         NULL::TEXT    AS coitem_custpn,    NULL::TEXT    AS coitem_order_type,\n         NULL::TEXT    AS coitem_close_username,\n         NULL::TIMESTAMP AS coitem_lastupdated,\n         NULL::INTEGER AS coitem_substitute_item_id,\n         NULL::TIMESTAMP AS coitem_created, NULL::TEXT    AS coitem_creator,\n         NULL::NUMERIC AS coitem_prcost,\n         NULL::INTEGER AS coitem_qty_uom_id,\n         NULL::NUMERIC AS coitem_qty_invuomratio,\n         NULL::INTEGER AS coitem_price_uom_id,\n         NULL::NUMERIC AS coitem_price_invuomratio,\n         NULL::BOOLEAN AS coitem_warranty,\n         NULL::INTEGER AS coitem_cos_accnt_id,\n         NULL::NUMERIC AS coitem_qtyreserved,\n         NULL::INTEGER AS coitem_subnumber,\n         cohead.*,\n         cust_number, cust_name,\n         NULL::TEXT AS item_number, NULL::TEXT AS item_descrip1,\n         NULL::TEXT AS itemdescription,\n         NULL::TEXT AS uom_name,\n         NULL::TEXT AS warehous_code,\n         NULL::NUMERIC AS qtybalance,\n         NULL::NUMERIC AS baseunitprice,\n         NULL::NUMERIC AS extprice,\n         NULL::NUMERIC AS baseextprice,\n         NULL::NUMERIC AS extpricebalance,\n         NULL::NUMERIC AS baseextpricebalance\n\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN cust ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n  WHERE ( (coitem_status='O')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("startDate") ?>\n    AND  (cohead_orderdate >= <? value("startDate") ?>)\n  <? endif ?>\n  <? if exists("endDate") ?>\n    AND  (cohead_orderdate <= <? value("endDate") ?>)\n  <? endif ?>\n  <? if exists("startDateSched") ?>\n    AND  (coitem_scheddate >= <? value("startDateSched") ?>)\n  <? endif ?>\n  <? if exists("endDateSched") ?>\n    AND  (coitem_scheddate <= <? value("endDateSched") ?>)\n  <? endif ?>\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? endif ?>\n  <? if exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? endif ?>\n  <? if exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? endif ?>\n  <? if exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? endif ?>\n  <? if exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? endif ?>\n  <? if exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? endif ?>\n  <? if exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? endif ?>\n  <? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n        )\n\n  UNION\n\n  SELECT \n         1 AS xtindentrole,\n         coitem_id,        coitem_cohead_id,\n         coitem_linenumber,coitem_itemsite_id,\n         coitem_status,    coitem_scheddate,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         coitem_promdate,  coitem_qtyord,\n         coitem_unitcost,  coitem_price,\n         coitem_custprice, coitem_qtyshipped,\n         coitem_order_id,  coitem_memo,\n         coitem_imported,  coitem_qtyreturned,\n         coitem_closedate, coitem_firm,\n         coitem_custpn,    coitem_order_type,\n         coitem_close_username,\n         coitem_lastupdated,\n         coitem_substitute_item_id,\n         coitem_created,   coitem_creator,\n         coitem_prcost,\n         coitem_qty_uom_id,\n         coitem_qty_invuomratio,\n         coitem_price_uom_id,\n         coitem_price_invuomratio,\n         coitem_warranty,\n         coitem_cos_accnt_id,\n         coitem_qtyreserved,\n         coitem_subnumber,\n         cohead.*,\n         cust_number, cust_name,\n         item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n         uom_name,\n         warehous_code,\n         noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n         currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance\n\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN cust ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n  WHERE ( (coitem_status='O')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("startDate") ?>\n    AND  (cohead_orderdate >= <? value("startDate") ?>)\n  <? endif ?>\n  <? if exists("endDate") ?>\n    AND  (cohead_orderdate <= <? value("endDate") ?>)\n  <? endif ?>\n  <? if exists("startDateSched") ?>\n    AND  (coitem_scheddate >= <? value("startDateSched") ?>)\n  <? endif ?>\n  <? if exists("endDateSched") ?>\n    AND  (coitem_scheddate <= <? value("endDateSched") ?>)\n  <? endif ?>\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? endif ?>\n  <? if exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? endif ?>\n  <? if exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? endif ?>\n  <? if exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? endif ?>\n  <? if exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? endif ?>\n  <? if exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? endif ?>\n  <? if exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? endif ?>\n  <? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n        )\n\n) AS dummy\nORDER BY cohead_number, xtindentrole, coitem_linenumber;\n        admin   2011-11-23      0
52 235     briefSalesHistory       detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: briefSalesHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n       COALESCE(cohead_id,-1) AS cohead_id, cust_id, cohist_ponumber,\n       cust_custtype_id, custtype_code,\n       cohist_cust_id, SUM(extcost) AS extcost,\n       'curr' AS extcost_xtnumericrole,\n       0 AS extcost_xttotalrole,\n       cohist_ordernumber,\n       cust_number, cust_name, invoicenumber,\n       cohist_orderdate, cohist_invcdate,\n       SUM(baseextprice) AS extended,\n       'curr' AS extended_xtnumericrole,\n       0 AS extended_xttotalrole\nFROM saleshistory\n  LEFT OUTER JOIN cohead ON (cohead_number=cohist_ordernumber)\nWHERE ((cohist_invcdate BETWEEN <? value("startDate") ?> AND  <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n   AND (cohist_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("shipto_id") ?>\n   AND (cohist_shipto_id=<? value("shipto_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n   AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n   AND (custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrpitem\n                   WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n<? endif ?>\n<? if exists("custgrp_pattern") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrp, custgrpitem\n                   WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                     AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("prodcat_id") ?>\n   AND (item_prodcat_id=<? value("prodcat_id") ?>)\n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n   AND (item_prodcat_id IN (SELECT prodcat_id\n                            FROM prodcat\n                            WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("salesrep_id") ?>\n   AND (cohist_salesrep_id=<? value("salesrep_id") ?>)\n<? endif ?>\n      )\nGROUP BY cohead_id, cust_id,cust_number,cust_custtype_id,cohist_cust_id,custtype_code,\n         cust_name,cohist_ordernumber, cohist_ponumber,\n         invoicenumber,cohist_orderdate, cohist_invcdate\nORDER BY cohist_invcdate, cohist_orderdate;\n      admin   2011-11-23      0
53 425     contactmerge    restore Restore a contact that was previously merged Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: contactmerge\n-- Name: restore\n-- Notes: Restore a contact that was previously merged\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctrestore(cntctmrgd_cntct_id) AS result\nFROM cntctmrgd\n<? if exists("cntct_id") ?>\nWHERE (cntctmrgd_cntct_id=<? value("cntct_id") ?>)\n<? endif ?>\n;\n       admin   2011-11-23      0
54 232     billingSelections       detail  used by dspBillingSelections Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: billingSelections\n-- Name: detail\n-- Notes: used by dspBillingSelections\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cobmisc_id, cohead_id,\n       cohead_number, cust_number, cust_name,\n       sum(round(coitem_price*cobill_qty,2)) AS subtotal,\n       cobmisc_misc, cobmisc_freight, calcCobmiscTax(cobmisc_id) AS cobmisc_tax, cobmisc_payment,\n       (sum(round(coitem_price * cobill_qty, 2)) +\n                  cobmisc_misc + cobmisc_freight +\n                  calcCobmiscTax(cobmisc_id)) AS total,\n       'curr' AS subtotal_xtnumericrole,\n       'curr' AS total_xtnumericrole,\n       'curr' AS cobmisc_misc_xtnumericrole,\n       'curr' AS cobmisc_freight_xtnumericrole,\n       'curr' AS cobmisc_tax_xtnumericrole,\n       'curr' AS cobmisc_payment_xtnumericrole\nFROM cobmisc, cohead, cust, coitem, cobill\nWHERE ((cobmisc_cohead_id=cohead_id)\n   AND (cohead_cust_id=cust_id)\n   AND (coitem_cohead_id=cohead_id)\n   AND (cobill_coitem_id=coitem_id)\n   AND (NOT cobmisc_posted))\nGROUP BY cobmisc_id, cohead_id, cohead_number, cust_number,\n         cust_name, cobmisc_misc, cobmisc_freight, cobmisc_tax, cobmisc_payment\nORDER BY cohead_number;\n   admin   2011-11-23      0
55 233     bom     detail  used by dspIndentedBOM, dspSingleLevelBOM, dspSummarizedBOM Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: bom\n-- Name: detail\n-- Notes: used by dspIndentedBOM, dspSingleLevelBOM, dspSummarizedBOM\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT <? if exists("bySingleLvl") ?>\n         bomitem_item_id AS itemid, bomitem.*, item_number,\n         invuom.uom_name AS invuomname, issueuom.uom_name AS issueuomname,\n         (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n         itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd) AS invqtyfxd,\n         itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper) AS invqtyper,\n         'qty' AS bomitem_qtyfxd_xtnumericrole,\n         'qty' AS invqtyfxd_xtnumericrole,\n         'qtyper' AS bomitem_qtyper_xtnumericrole,\n         'qtyper' AS invqtyper_xtnumericrole,\n         'percent' AS bomitem_scrap_xtnumericrole,\n         CASE WHEN COALESCE(bomitem_effective, startOfTime()) = startOfTime() \n           THEN <? value("always") ?>\n         END AS bomitem_effective_qtdisplayrole,\n         CASE WHEN COALESCE(bomitem_expires, endOfTime()) = endOfTime() \n           THEN <? value("never") ?>\n         END AS bomitem_expires_qtdisplayrole,\n         CASE WHEN (bomitem_expires < CURRENT_DATE) THEN 'expired'\n              WHEN (bomitem_effective >= CURRENT_DATE) THEN 'future'\n              WHEN (item_type='M') THEN 'altemphasis'\n         END AS qtforegroundrole\n       <? else ?>\n         <? if exists("bySummarized") ?>\n           item_id AS itemid,\n         <? else ?>\n           bomdata_item_id AS itemid,\n         <? endif ?>\n         *,'percent' AS bomdata_scrap_xtnumericrole,\n         'qtyper' AS bomdata_qtyreq_xtnumericrole,\n         CASE WHEN COALESCE(bomdata_effective, startOfTime()) <=\n                   startOfTime() THEN <? value("always") ?>\n         END AS bomdata_effective_qtdisplayrole,\n         CASE WHEN COALESCE(bomdata_expires, endOfTime()) >=\n                   endOfTime() THEN <? value("never") ?>\n         END AS bomdata_expires_qtdisplayrole,\n         CASE WHEN (bomdata_expired) THEN 'expired'\n              WHEN (bomdata_future) THEN 'future'\n         END AS qtforegroundrole\n         <? if not exists("bySummarized") ?>\n           , bomdata_bomwork_level - 1 AS xtindentrole\n         <? endif ?>\n       <? endif ?>\nFROM <? if exists("bySingleLvl") ?>\n       bomitem(<? value("item_id") ?>,<? value("revision_id") ?>),\n       item, uom AS issueuom, uom AS invuom\n     <? elseif exists("byIndented") ?>\n       indentedBOM(<? value("item_id") ?>,\n                   <? value("revision_id") ?>,\n                   <? value("expiredDays") ?>,\n                   <? value("futureDays") ?>)\n     <? elseif exists("bySummarized") ?>\n       summarizedBOM(<? value("item_id") ?>,\n                     <? value("revision_id") ?>,\n                     <? value("expiredDays") ?>,\n                     <? value("futureDays") ?>)\n       JOIN item ON (bomdata_item_number=item_number)\n     <? endif ?>\nWHERE ((TRUE)\n<? if exists("byIndented") ?>\n   AND (bomdata_item_id > 0)\n<? elseif exists("bySingleLvl") ?>\n   AND (bomitem_item_id=item_id)\n   AND (item_inv_uom_id=invuom.uom_id)\n   AND (bomitem_uom_id=issueuom.uom_id)\n  <? if exists("expiredDays") ?>\n   AND (bomitem_expires > (CURRENT_DATE - <? value("expiredDays") ?>))\n  <? else ?>\n   AND (bomitem_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if exists("effectiveDays") ?>\n   AND (bomitem_effective <= (CURRENT_DATE + <? value("effectiveDays") ?>))\n  <? else ?>\n   AND (bomitem_effective <= CURRENT_DATE)\n  <? endif ?>\n<? endif ?>\n      )\n<? if exists("bySingleLvl") ?>\n ORDER BY bomitem_seqnumber, bomitem_effective\n<? endif ?>\n;\n   admin   2011-11-23      0
56 117     bomItems        detail  used by bom, booItem Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: bomItems\n-- Name: detail\n-- Notes: used by bom, booItem\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT bomitem_id, item_id, *,\n       (item_descrip1 || ' ' || item_descrip2) AS item_description,\n       CASE WHEN (item_type='P') THEN text(<? value("purchased") ?>)\n            WHEN (item_type='M') THEN text(<? value("manufactured") ?>)\n            WHEN (item_type='J') THEN text(<? value("job") ?>)\n            WHEN (item_type='F') THEN text(<? value("phantom") ?>)\n            WHEN (item_type='B') THEN text(<? value("breeder") ?>)\n            WHEN (item_type='C') THEN text(<? value("coProduct") ?>)\n            WHEN (item_type='Y') THEN text(<? value("byProduct") ?>)\n            WHEN (item_type='R') THEN text(<? value("reference") ?>)\n            WHEN (item_type='S') THEN text(<? value("costing") ?>)\n            WHEN (item_type='T') THEN text(<? value("tooling") ?>)\n            WHEN (item_type='A') THEN text(<? value("assortment") ?>)\n            WHEN (item_type='O') THEN text(<? value("outside") ?>)\n            WHEN (item_type='L') THEN text(<? value("planning") ?>)\n            WHEN (item_type='K') THEN text(<? value("kit") ?>)\n            ELSE text(<? value("error") ?>)\n       END AS itemtype,\n       uom_name AS issueuom,\n       CASE WHEN (bomitem_issuemethod = 'S') THEN <? value("push") ?>\n            WHEN (bomitem_issuemethod = 'L') THEN <? value("pull") ?>\n            WHEN (bomitem_issuemethod = 'M') THEN <? value("mixed") ?>\n            ELSE <? value("error") ?>\n       END AS issuemethod,\n       'qty' AS bomitem_qtyfxd_xtnumericrole,\n       'qtyper' AS bomitem_qtyper_xtnumericrole,\n       'percent' AS bomitem_scrap_xtnumericrole,\n       CASE WHEN (bomitem_effective = startOfTime()) THEN NULL\n            ELSE bomitem_effective END AS effective,\n       CASE WHEN (bomitem_expires = endOfTime()) THEN NULL\n            ELSE bomitem_expires END AS expires,\n       <? value("always") ?> AS effective_xtnullrole,\n       <? value("never") ?>  AS expires_xtnullrole,\n       CASE WHEN (bomitem_expires < CURRENT_DATE) THEN 'expired'\n            WHEN (bomitem_effective >= CURRENT_DATE) THEN 'future'\n            WHEN (item_type='M') THEN 'altemphasis'\n       END AS qtforegroundrole\n<? if exists("booitem_id") ?>\nFROM bomitem(<? value("item_id") ?>), item, uom, xtmfg.booitem\n<? else ?>\nFROM bomitem(<? value("item_id") ?>, <? value("revision_id") ?>), item, uom\n<? endif ?>\nWHERE ((bomitem_item_id=item_id)\n  AND (bomitem_uom_id=uom_id)\n<? if not exists("showExpired") ?>\n  AND (bomitem_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n  AND (bomitem_effective <= CURRENT_DATE)\n<? endif ?>\n<? if exists("booitem_id") ?>\n  AND (booitem_id = <? value("booitem_id") ?>)\n  AND (bomitem_booitem_seq_id = booitem_seq_id)\n<? endif ?>\n  )\nORDER BY bomitem_seqnumber, bomitem_effective;\n   admin   2011-11-23      0
57 417     bookings        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: bookings\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT   coitem_id AS id, coitem_cohead_id AS altId,\n         formatSoLineNumber(coitem_id) AS f_linenumber,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         coitem.*, cohead.*,\n         cust_number, cust_name,\n         item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n         uom_name,\n         warehous_code,\n         qtyAtShipping(coitem_id) AS qtyatshipping,\n-- TODO - not needed, remove? (very slow)\n--         qtyAvailable(itemsite_id, coitem_scheddate) AS qtyavailable,\n--         (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) AS stockout,\n--         CASE WHEN (itemsite_useparams) THEN (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel)\n--              ELSE (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0)\n--         END AS reorder,\n         noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n         currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance,\n         curr_abbr AS currAbbr,\n-- TODO - not needed, remove? (very slow)\n--         CASE WHEN (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) THEN 'error'\n--              WHEN itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel) THEN 'warning'\n--              WHEN NOT itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0) THEN 'warning'\n--         END AS qtyavailable_qtforegroundrole,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS coitem_qtyshipped_xtnumericrole,\n       'qty' AS coitem_qtyreturned_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'qty' AS qtybalance_xtnumericrole,\n       'qty' AS qtyavailable_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'salesprice' AS baseunitprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS baseextprice_xtnumericrole,\n       'curr' AS extpricebalance_xtnumericrole,\n       'curr' AS baseextpricebalance_xtnumericrole,\n       0 AS coitem_qtyord_xttotalrole,\n       0 AS coitem_qtyshipped_xttotalrole,\n       0 AS coitem_qtyreturned_xttotalrole,\n       0 AS qtybalance_xttotalrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS baseextpricebalance_xttotalrole\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN cust ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n              JOIN curr_symbol ON (curr_id=cohead_curr_id)\n  WHERE ( (coitem_status<>'X')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("openOnly") ?>\n    AND  (coitem_status<>'C')\n  <? endif ?>\n  <? if exists("startDate") ?>\n    AND  (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  <? endif ?>\n\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? elseif exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? elseif exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? elseif exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? elseif exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? elseif exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? elseif exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n        )\n\n<? if exists("orderByScheddate") ?>\n  ORDER BY sort_scheddate, cohead_number, coitem_linenumber, coitem_subnumber\n<? elseif exists("orderByOrderdate") ?>\n  ORDER BY cohead_orderdate, cohead_number, coitem_linenumber, coitem_subnumber\n<? else ?>\n  ORDER BY cohead_number, coitem_linenumber, coitem_subnumber\n<? endif ?>\n;\n      admin   2011-11-23      0
58 234     briefEarnedCommission   detail  used by dspBriefEarnedCommissions Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: briefEarnedCommission\n-- Name: detail\n-- Notes: used by dspBriefEarnedCommissions\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohist_salesrep_id, salesrep_number, salesrep_name, cust_number, cust_name,\n       cohist_ordernumber, cohist_invcnumber, cohist_invcdate, currAbbr,\n       SUM(extprice) AS sumextprice,\n       SUM(cohist_commission) AS sumcommission,\n       SUM(baseextprice) AS sumbaseextprice,\n       SUM(basecommission) AS sumbasecommission,\n       'curr' AS sumextprice_xtnumericrole,\n       'curr' AS sumcommission_xtnumericrole,\n       'curr' AS sumbaseextprice_xtnumericrole,\n       'curr' AS sumbasecommission_xtnumericrole,\n       0 AS sumbaseextprice_xttotalrole,\n       0 AS sumbasecommission_xttotalrole\n<? if exists("includeMisc") ?>\nFROM saleshistorymisc\n<? else ?>\nFROM saleshistory\n<? endif ?>\nWHERE ((cohist_commission <> 0)\n    AND(cohist_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? if exists("includeMisc") ?>\n    AND (COALESCE(cohist_misc_type, '') <> 'T')\n    AND (COALESCE(cohist_misc_type, '') <> 'F')\n    <? endif ?>\n    <? if exists("salesrep_id") ?>\n    AND (cohist_salesrep_id=<? value("salesrep_id") ?>)\n    <? endif ?>\n      )\nGROUP BY cohist_salesrep_id, salesrep_number, salesrep_name, cust_number, cust_name,\n         cohist_ordernumber, cohist_invcnumber, cohist_invcdate, currAbbr\nORDER BY salesrep_number, cust_number, cohist_invcdate;\n  admin   2011-11-23      0
59 44      capacityUOMs    detail  used by dspCapacityUOMsByClassCode, dspCapacityUOMsByProductCategory Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: capacityUOMs\n-- Name: detail\n-- Notes: used by dspCapacityUOMsByClassCode, dspCapacityUOMsByProductCategory\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, item_number,\n<? if exists("getclasscode") ?>\n       classcode_code,\n<? endif ?>\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       uom_name,\n       itemcapuom(item_id)       AS capuom,\n       itemcapinvrat(item_id)    AS capinvrat,\n       itemaltcapuom(item_id)    AS altcapuom,\n       itemaltcapinvrat(item_id) AS altcapinvrat,\n       'uomratio' AS capinvrat_xtnumericrole,\n       'uomratio' AS altcapinvrat_xtnumericrole\nFROM item\n     JOIN uom ON (item_inv_uom_id=uom_id)\n<? if exists("getclasscode") ?>\n     LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\n<? endif ?>\nWHERE (\n<? if exists("getclasscode") ?> true <? else ?> item_sold <? endif ?>\n<? if exists("prodcat_id") ?>\n   AND (item_prodcat_id=<? value("prodcat_id") ?>)\n<? elseif exists("prodcat_pattern") ?>\n   AND (item_prodcat_id IN (SELECT prodcat_id\n                            FROM prodcat\n                            WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? elseif exists("classcode_id") ?>\n   AND (classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n   AND (classcode_code ~ <? value("classcode_pattern") ?>)\n<? endif ?>\n)\nORDER BY <? if exists("getclasscode") ?> classcode_code, <? endif ?>\n         item_number;\n      admin   2011-11-23      0
60 45      cashReceipts    detail  used by dspCashReceipts There are 2 display modes for this query: 1) Legacy mode which uses A/R Application information 2) Version 3.3.0 upgrade mode which uses Cash Receipt information Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: cashReceipts\n-- Name: detail\n-- Notes: used by dspCashReceipts\n-- There are 2 display modes for this query:\n-- 1) Legacy mode which uses A/R Application information\n-- 2) Version 3.3.0 upgrade mode which uses Cash Receipt information\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("LegacyDisplayMode") ?>\n\n-- Posted cash receipts\nSELECT arapply_id, 1 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n       false AS voided, true AS posted, arapply_postdate AS postdate,\n       ( CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n              WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n              WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n              WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n              WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n              WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n              WHEN (arapply_fundstype='A') THEN <? value("americanExpress") ?>\n              WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n              WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n              WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n              WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n              WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n         END || ' ' ||\n         CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)\n              ELSE arapply_refnumber\n         END ) AS source,\n       COALESCE(cashrcptitem_cashrcpt_id,cashrcptmisc_cashrcpt_id,-1) AS source_xtidrole,\n       ( CASE WHEN (arapply_target_doctype='D') THEN <? value("debitMemo") ?>\n              WHEN (arapply_target_doctype='I') THEN <? value("invoice") ?>\n              ELSE <? value("other") ?>\n         END || ' ' || TEXT(arapply_target_docnumber) ) AS target,\n       COALESCE(arapply_target_aropen_id,-1) AS target_xtidrole,\n       arapply_applied AS applied,\n       'curr' AS applied_xtnumericrole,\n       currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied,\n<? if exists("includeFormatted") ?>\n       formatDate(arapply_postdate) AS f_postdate,\n       formatMoney(arapply_applied) AS f_applied,\n       formatMoney(currtobase(arapply_curr_id,arapply_applied,arapply_postdate)) AS f_base_applied,\n<? endif ?>\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       currConcat(arapply_curr_id) AS currAbbr,\n       arapply_postdate AS sortdate\nFROM cust LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), arapply\n  LEFT OUTER JOIN cashrcptitem ON ((arapply_reftype='CRA')\n                               AND (arapply_ref_id=cashrcptitem_id))\n  LEFT OUTER JOIN cashrcptmisc ON ((arapply_reftype='CRD')\n                               AND (arapply_ref_id=cashrcptmisc_id))\nWHERE ( (arapply_cust_id=cust_id)\n  AND   (arapply_postdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  AND   (arapply_source_doctype ='K')\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\n\n-- Unposted cash receipts\nUNION\nSELECT cashrcpt_id, 2 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n       false AS voided, false AS posted, cashrcpt_distdate AS postdate,\n       ( CASE WHEN (cashrcpt_fundstype='C') THEN <? value("check") ?>\n              WHEN (cashrcpt_fundstype='T') THEN <? value("certifiedCheck") ?>\n              WHEN (cashrcpt_fundstype='M') THEN <? value("masterCard") ?>\n              WHEN (cashrcpt_fundstype='V') THEN <? value("visa") ?>\n              WHEN (cashrcpt_fundstype='A') THEN <? value("americanExpress") ?>\n              WHEN (cashrcpt_fundstype='D') THEN <? value("discoverCard") ?>\n              WHEN (cashrcpt_fundstype='R') THEN <? value("otherCreditCard") ?>\n              WHEN (cashrcpt_fundstype='K') THEN <? value("cash") ?>\n              WHEN (cashrcpt_fundstype='W') THEN <? value("wireTransfer") ?>\n              WHEN (cashrcpt_fundstype='O') THEN <? value("other") ?>\n         END || ' ' || cashrcpt_docnumber ) AS source,\n      cashrcpt_id AS source_xtidrole,\n       <? value("unposted") ?> AS target,\n       -1 AS target_xtidrole,\n       cashrcpt_amount AS applied,\n       'curr' AS applied_xtnumericrole,\n       (cashrcpt_amount / cashrcpt_curr_rate) AS base_applied,\n<? if exists("includeFormatted") ?>\n       formatDate(cashrcpt_distdate) AS f_postdate,\n       formatMoney(cashrcpt_amount) AS f_applied,\n       formatMoney(cashrcpt_amount / cashrcpt_curr_rate) AS f_base_applied,\n<? endif ?>\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       currConcat(cashrcpt_curr_id) AS currAbbr,\n       cashrcpt_distdate AS sortdate\nFROM cashrcpt, cust LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (NOT cashrcpt_posted)\n  AND   (cashrcpt_cust_id=cust_id)\n  AND   (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\n\n-- Cash Advance\nUNION\nSELECT aropen_id, 3 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n       false AS voided, true AS posted, aropen_docdate AS postdate,\n       ( CASE WHEN (substr(aropen_notes, 16, 1)='C') THEN <? value("check") ?>\n              WHEN (substr(aropen_notes, 16, 1)='T') THEN <? value("certifiedCheck") ?>\n              WHEN (substr(aropen_notes, 16, 1)='M') THEN <? value("masterCard") ?>\n              WHEN (substr(aropen_notes, 16, 1)='V') THEN <? value("visa") ?>\n              WHEN (substr(aropen_notes, 16, 1)='A') THEN <? value("americanExpress") ?>\n              WHEN (substr(aropen_notes, 16, 1)='D') THEN <? value("discoverCard") ?>\n              WHEN (substr(aropen_notes, 16, 1)='R') THEN <? value("otherCreditCard") ?>\n              WHEN (substr(aropen_notes, 16, 1)='K') THEN <? value("cash") ?>\n              WHEN (substr(aropen_notes, 16, 1)='W') THEN <? value("wireTransfer") ?>\n              WHEN (substr(aropen_notes, 16, 1)='O') THEN <? value("other") ?>\n         END || ' ' ||\n         substr(aropen_notes, 18) ) AS source,\n       cashrcptitem_cashrcpt_id AS source_xtidrole,\n       CASE WHEN aropen_doctype = 'R' THEN\n         <? value("cashdeposit") ?> \n       ELSE <? value("creditMemo") ?> \n       END AS target,\n       aropen_id AS target_xtidrole,\n       aropen_amount AS applied,\n       'curr' AS applied_xtnumericrole,\n       aropen_amount / aropen_curr_rate AS base_applied,\n<? if exists("includeFormatted") ?>\n       formatDate(aropen_docdate) AS f_postdate,\n       formatMoney(aropen_amount) AS f_applied,\n       formatMoney(aropen_amount / aropen_curr_rate) AS f_base_applied,\n<? endif ?>\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       currConcat(aropen_curr_id) AS currAbbr,\n       aropen_duedate AS sortdate\nFROM cust LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), aropen\n  JOIN cashrcptitem ON (aropen_id=cashrcptitem_aropen_id)\nWHERE ( (aropen_cust_id=cust_id)\n  AND   (aropen_doctype IN ('R','C'))\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\nORDER BY sortdate, source;\n\n<? else ?>\n\n--  New Display Mode\n\nSELECT id, type, cashrcpt_number, cust_number, cust_name,\n       postdate, posted, voided,\n       source, source_xtidrole,\n       posted,\n       target, target_xtidrole,\n       applied,\n       base_applied,\n<? if exists("includeFormatted") ?>\n       formatDate(postdate) AS f_postdate,\n       formatMoney(applied) AS f_applied,\n       formatMoney(base_applied) AS f_base_applied,\n<? endif ?>\n       currAbbr,\n       sortdate,\n       'curr' AS applied_xtnumericrole,\n       'curr' AS base_applied_xtnumericrole,\n       base_applied_xttotalrole,\n       type AS xtindentrole\nFROM (\n\n--  Cash Receipt headers\nSELECT cashrcpt_id AS id, 0 AS type, cashrcpt_number, cust_number, cust_name,\n       cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n       ( CASE WHEN (cashrcpt_fundstype='C') THEN <? value("check") ?>\n              WHEN (cashrcpt_fundstype='T') THEN <? value("certifiedCheck") ?>\n              WHEN (cashrcpt_fundstype='M') THEN <? value("masterCard") ?>\n              WHEN (cashrcpt_fundstype='V') THEN <? value("visa") ?>\n              WHEN (cashrcpt_fundstype='A') THEN <? value("americanExpress") ?>\n              WHEN (cashrcpt_fundstype='D') THEN <? value("discoverCard") ?>\n              WHEN (cashrcpt_fundstype='R') THEN <? value("otherCreditCard") ?>\n              WHEN (cashrcpt_fundstype='K') THEN <? value("cash") ?>\n              WHEN (cashrcpt_fundstype='W') THEN <? value("wireTransfer") ?>\n              WHEN (cashrcpt_fundstype='O') THEN <? value("other") ?>\n         END || ' ' || cashrcpt_docnumber ) AS source,\n       cashrcpt_id AS source_xtidrole,\n       CASE WHEN (cashrcpt_void) THEN <? value("voided") ?>\n            WHEN (NOT cashrcpt_posted) THEN <? value("unposted") ?>\n            ELSE                           ''\n       END AS target,\n       -1 AS target_xtidrole,\n       cashrcpt_amount AS applied,\n       (cashrcpt_amount / cashrcpt_curr_rate) AS base_applied,\n       currConcat(cashrcpt_curr_id) AS currAbbr,\n       cashrcpt_distdate AS sortdate,\n       0 AS base_applied_xttotalrole,\n       -1 AS arapply_id\nFROM cashrcpt JOIN cust ON (cust_id=cashrcpt_cust_id) LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\n\n--  Cash Receipt items\nUNION\nSELECT cashrcpt_id AS id, 1 AS type, '', '', '',\n       cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n       '' AS source,\n       cashrcpt_id AS source_xtidrole,\n       ( CASE WHEN (aropen_doctype='D') THEN <? value("debitMemo") ?>\n              WHEN (aropen_doctype='I') THEN <? value("invoice") ?>\n              WHEN (aropen_doctype='C') THEN <? value("creditMemo") ?>\n              WHEN (aropen_doctype='R') THEN <? value("cashdeposit") ?>\n              ELSE <? value("other") ?>\n         END || ' ' || TEXT(aropen_docnumber) ) AS target,\n       aropen_id AS target_xtidrole,\n       COALESCE(arapply_applied, cashrcptitem_amount) AS applied,\n       (COALESCE(arapply_applied,cashrcptitem_amount) / cashrcpt_curr_rate) AS base_applied,\n       currConcat(cashrcpt_curr_id) AS currAbbr,\n       cashrcpt_distdate AS sortdate,\n       -1 AS base_applied_xttotalrole,\n       arapply_id\nFROM cashrcpt JOIN cust ON (cust_id=cashrcpt_cust_id)\n              LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n              JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)\n              JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)\n              LEFT OUTER JOIN arapply ON ((arapply_target_aropen_id=aropen_id OR\n                                          arapply_source_aropen_id=aropen_id) AND\n                                          arapply_reftype='CRA' AND\n                                          arapply_ref_id=cashrcptitem_id)\nWHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\n\n--  Cash Receipt misc\nUNION\nSELECT cashrcpt_id AS id, 1 AS type, '', '', '',\n       cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n       '' AS source,\n       cashrcpt_id AS source_xtidrole,\n       formatGLAccount(cashrcptmisc_accnt_id) AS target,\n       -1 AS target_xtidrole,\n       COALESCE(arapply_applied, cashrcptmisc_amount) AS applied,\n       (COALESCE(arapply_applied, cashrcptmisc_amount) / cashrcpt_curr_rate) AS base_applied,\n       currConcat(cashrcpt_curr_id) AS currAbbr,\n       cashrcpt_distdate AS sortdate,\n       -1 AS base_applied_xttotalrole,\n       arapply_id\nFROM cashrcpt JOIN cust ON (cust_id=cashrcpt_cust_id)\n              LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n              JOIN cashrcptmisc ON (cashrcptmisc_cashrcpt_id=cashrcpt_id)\n              LEFT OUTER JOIN arapply ON (arapply_reftype='CRD' AND\n                                          arapply_ref_id=cashrcptmisc_id)\nWHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n  AND   (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n  AND   (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n      )\n  ) AS data\nORDER BY sortdate, id, type, target;\n\n<? endif ?>\n\n admin   2011-11-23      0
61 69      packingList     shipment        used by printPackingList Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: packingList\n-- Name: shipment\n-- Notes: used by printPackingList\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT shiphead_order_id, shiphead_order_type, shiphead_shipform_id, cohead_number AS number\nFROM shiphead, cohead\nWHERE ((shiphead_id=<? value("shiphead_id") ?>)\n  AND  (cohead_id=shiphead_order_id)\n  AND  (shiphead_order_type='SO'))\n<? if exists("MultiWhs") ?>\nUNION\nSELECT shiphead_order_id, shiphead_order_type, shiphead_shipform_id, tohead_number AS number\nFROM shiphead, tohead\nWHERE ((shiphead_id=<? value("shiphead_id") ?>)\n  AND  (tohead_id=shiphead_order_id)\n  AND  (shiphead_order_type='TO'))\n<? endif ?>\n;\n   admin   2011-11-23      0
62 236     costedBOM       detail  used by dspCostedIndentedBOM, dspCostedSingleLevelBOM, dspCostedSummarizedBOM Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: costedBOM\n-- Name: detail\n-- Notes: used by dspCostedIndentedBOM, dspCostedSingleLevelBOM, dspCostedSummarizedBOM\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("indentedBOM") ?>\n       bomdata_bomwork_id AS id,\n<? elseif exists("singleLevelBOM") ?>\n       bomdata_bomitem_id AS id,\n<? elseif exists("summarizedBOM") ?>\n       -1,\n<? endif ?>\n       \n<? if exists("indentedBOM") ?>\n       CASE WHEN bomdata_bomwork_parent_id = -1 AND bomdata_bomwork_id = -1 THEN -1\n         ELSE bomdata_item_id\n       END AS altid,\n<? elseif exists("singleLevelBOM") ?>\n       CASE WHEN (bomdata_bomitem_id = -1) THEN -1\n         ELSE bomdata_item_id\n       END AS altid,\n<? endif ?>\n       *,\n\n<? if exists("useStandardCosts") ?>\n       bomdata_stdunitcost AS unitcost,\n       bomdata_stdextendedcost AS extendedcost,\n<? elseif exists("useActualCosts") ?>\n       bomdata_actunitcost AS unitcost,\n       bomdata_actextendedcost AS extendedcost,\n<? endif ?>\n\n<? if exists("singleLevelBOM") ?>\n       'qty' AS bomdata_batchsize_xtnumericrole,\n       'qty' AS bomdata_qtyfxd_xtnumericrole,\n       'qtyper' AS bomdata_qtyper_xtnumericrole,\n       'percent' AS bomdata_scrap_xtnumericrole,\n<? else ?>\n       'qtyper' AS bomdata_qtyreq_xtnumericrole,\n<? endif ?>\n\n<? if exists("indentedBOM") ?>\n       'percent' AS bomdata_scrap_xtnumericrole,\n<? endif ?>\n\n       'cost' AS unitcost_xtnumericrole,\n       'cost' AS extendedcost_xtnumericrole,\n       CASE WHEN COALESCE(bomdata_effective, startOfTime()) <= startOfTime() THEN <? value("always") ?>\n         END AS bomdata_effective_qtdisplayrole,\n       CASE WHEN COALESCE(bomdata_expires, endOfTime()) <= endOfTime() THEN <? value("never") ?>\n         END AS bomdata_expires_qtdisplayrole,\n       CASE WHEN bomdata_expired THEN 'expired'\n            WHEN bomdata_future  THEN 'future'\n       END AS qtforegroundrole\n<? if exists("indentedBOM") ?>\n       , bomdata_bomwork_level - 1 AS xtindentrole\n<? elseif exists("singleLevelBOM") ?>\n       , 0 AS extendedcost_xttotalrole\n<? endif ?>\nFROM\n<? if exists("indentedBOM") ?>\n     indentedbom(<? value("item_id") ?>, <? value("revision_id") ?>, 0, 0);\n<? elseif exists("singleLevelBOM") ?>\n     singlelevelbom(<? value("item_id") ?>, <? value("revision_id") ?>, 0, 0);\n<? elseif exists("summarizedBOM") ?>\n     summarizedBOM(<? value("item_id") ?>, <? value("revision_id") ?>, <? value("expiredDays") ?>, <? value("futureDays") ?>);\n<? endif ?>\n       admin   2011-11-23      0
63 96      ccpayments      list    list credit card payments, optionally by customer Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: ccpayments\n-- Name:  list\n-- Notes: list credit card payments, optionally by customer\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ccpay_id AS id, \n       CASE WHEN ((ccpay_status = 'A') AND \n                 (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) < COALESCE(<? value("ccValidDays") ?>,0))) THEN\n         1\n       ELSE 0\n       END AS altid, cohead_id,\n       ccpay.*,\n       cust_number, cust_name,       \n       ccpay_type AS type,       \n       CASE WHEN (ccpay_type='A') THEN <? value("preauth") ?>\n            WHEN (ccpay_type='C') THEN <? value("charge") ?>\n            WHEN (ccpay_type='R') THEN <? value("refund") ?>\n            ELSE ccpay_type\n       END AS type_qtdisplayrole,\n       ccpay_status AS status,\n       CASE WHEN (ccpay_status='A') THEN <? value("authorized") ?>\n            WHEN (ccpay_status='C') THEN <? value("approved") ?>\n            WHEN (ccpay_status='D') THEN <? value("declined") ?>\n            WHEN (ccpay_status='V') THEN <? value("voided") ?>\n            WHEN (ccpay_status='X') THEN <? value("noapproval") ?>\n            ELSE ccpay_status\n       END AS status_qtdisplayrole,\n       currConcat(ccpay_curr_id) AS currAbbr,\n       COALESCE(cohead_number, ccpay_order_number) AS docnumber,\n       ABS(COALESCE(payco_amount, ccpay_amount)) AS allocated,\n       currConcat(COALESCE(payco_curr_id, ccpay_curr_id)) AS payco_currAbbr,\n       cust_number, cust_name,\n       'curr' AS ccpay_amount_xtnumericrole,\n       'curr' AS allocated_xtnumericrole,\n        CASE WHEN ((ccpay_status = 'A')\n              AND (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) >= COALESCE(<? value("ccValidDays") ?>,0))) THEN\n          'error'\n        END AS qtforegroundrole\n  FROM ccpay LEFT OUTER JOIN \n       (payco JOIN cohead ON (payco_cohead_id=cohead_id))\n         ON (payco_ccpay_id=ccpay_id)\n      JOIN cust ON (ccpay_cust_id=cust_id)\n      JOIN custtype ON (cust_custtype_id=custtype_id)\n      LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n  WHERE ((true)\n<? if exists("processed") ?>\n  AND (ccpay_status != 'A')\n<? elseif exists("authorizations") ?>\n  AND (ccpay_status = 'A')\n<? endif ?>\n<? if exists("validOnly") ?>\n  AND ((ccpay_status != 'A')\n  OR (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) < <? value("ccValidDays") ?>))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (ccpay_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>)\n ORDER BY ccpay_transaction_datetime;\n    admin   2011-11-23      0
64 46      checkRegister   detail  used by dspCheckRegister and viewCheckRun; shows all the checks for a given date range, bank account, check number(optional), and recipient(optional), optionally restricted to 'new' (un-posted/replaced/deleted) checks for viewing check runs. fills in the check item detail if showDetail is passed. Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: checkRegister\n-- Name: detail\n-- Notes: used by dspCheckRegister and viewCheckRun;\n--        shows all the checks for a given date range, bank account, \n--        check number(optional), and recipient(optional), optionally restricted\n--        to 'new' (un-posted/replaced/deleted) checks for viewing check runs.\n--        fills in the check item detail if showDetail is passed.\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT checkhead_id AS checkid,\n       CASE WHEN(checkhead_void) THEN -1\n            WHEN(checkhead_posted) THEN 1\n            ELSE 0\n       END AS extra,\n       -1 AS checkitem_id,\n       checkhead_void, checkhead_misc,\n       checkhead_printed, checkhead_posted,\n       CASE when checkhead_number = -1 THEN\n         'Unspecified'\n       ELSE TEXT(checkhead_number) END AS number,\n       COALESCE((SELECT checkrecip_number || '-' || checkrecip_name\n                 FROM checkrecip\n                 WHERE ((checkhead_recip_id=checkrecip_id)\n\t\t   AND  (checkhead_recip_type=checkrecip_type)))\n                ,\n\t\tcheckhead_recip_type || '-' || checkhead_recip_id ) AS description,\n       checkhead_checkdate AS checkdate,\n       checkhead_amount AS amount, \n       checkhead_amount / checkhead_curr_rate AS base_amount, \n       currConcat(checkhead_curr_id) AS currAbbr,\n       checkhead_number,\n       checkhead_ach_batch,\n       1 AS orderby,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       NULL AS checkhead_void_qtdisplayrole,    NULL AS checkhead_misc_qtdisplayrole,\n       NULL AS checkhead_printed_qtdisplayrole, NULL AS checkhead_posted_qtdisplayrole,\n       0 AS xtindentrole\n  FROM checkhead\n WHERE ((checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n   <? if exists("startDate") ?>\n     AND (checkhead_checkdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n   <? elseif exists("newOnly") ?>\n     AND (NOT checkhead_posted)\n     AND (NOT checkhead_replaced)\n     AND (NOT checkhead_deleted)\n   <? endif ?>\n   <? if exists("check_number") ?>\n      AND   (CAST(checkhead_number AS text) ~ <? value("check_number") ?>)\n   <? endif ?>\n   <? if exists("recip") ?>\n      <? if exists("recip_type_v") ?>\n         AND   (checkhead_recip_type = 'V' )\n      <? endif ?>\n      <? if exists("recip_type_c") ?>\n         AND   (checkhead_recip_type = 'C' )\n      <? endif ?>\n      <? if exists("recip_type_t") ?>\n         AND   (checkhead_recip_type = 'T' )\n      <? endif ?>\n      <? if exists("recip_id") ?>\n         AND   (checkhead_recip_id = <? value("recip_id") ?> )\n      <? endif ?>\n   <? endif ?>\n   <? if exists("vend_id") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id = <? value("vend_id") ?>)\n   <? elseif exists("vendtype_id") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id IN (SELECT vend_id\n                                 FROM vend\n                                 WHERE (vend_vendtype_id=<? value("vendtype_id") ?>)))\n   <? elseif exists("vendtype_pattern") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id IN (SELECT vend_id\n                                 FROM vend, vendtype\n                                 WHERE  (vend_vendtype_id=vendtype_id)\n                                   AND  (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n   <? endif ?>\n)\n<? if exists("showDetail") ?>\nUNION\nSELECT checkitem_checkhead_id AS checkid, 0 AS extra, checkitem_id,\n       checkhead_void, checkhead_misc,\n       checkhead_printed, checkhead_posted,\n       CAST(COALESCE(checkitem_ranumber, checkitem_vouchernumber) AS TEXT) AS number,\n       CAST(COALESCE(checkitem_invcnumber, checkitem_cmnumber) AS TEXT) AS description,\n       CAST(NULL AS DATE) AS checkdate,\n       checkitem_amount AS amount,\n       currtobase(checkhead_curr_id,checkitem_amount,checkhead_checkdate) AS base_amount, \n       currConcat(checkitem_curr_id) AS currAbbr, \n       checkhead_number, \n       NULL AS checkhead_ach_batch,\n       2 AS orderby,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       '' AS checkhead_void_qtdisplayrole,    '' AS checkhead_misc_qtdisplayrole,\n       '' AS checkhead_printed_qtdisplayrole, '' AS checkhead_posted_qtdisplayrole,\n       1 AS xtindentrole\n  FROM checkitem, checkhead \n WHERE ((checkitem_checkhead_id=checkhead_id)\n   AND   (checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n   <? if exists("startDate") ?>\n     AND   (checkhead_checkdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n   <? elseif exists("newOnly") ?>\n     AND (NOT checkhead_posted)\n     AND (NOT checkhead_replaced)\n     AND (NOT checkhead_deleted)\n   <? endif ?>\n   <? if exists("check_number") ?>\n      AND   (CAST(checkhead_number AS text) ~ <? value("check_number") ?>)\n   <? endif ?>\n   <? if exists("recip") ?>\n      <? if exists("recip_type_v") ?>\n         AND   (checkhead_recip_type = 'V' )\n      <? endif ?>\n      <? if exists("recip_type_c") ?>\n         AND   (checkhead_recip_type = 'C' )\n      <? endif ?>\n      <? if exists("recip_type_t") ?>\n         AND   (checkhead_recip_type = 'T' )\n      <? endif ?>\n      <? if exists("recip_id") ?>\n         AND   (checkhead_recip_id = <? value("recip_id") ?> )\n      <? endif ?>\n   <? endif ?>\n   <? if exists("vend_id") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id = <? value("vend_id") ?>)\n   <? elseif exists("vendtype_id") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id IN (SELECT vend_id\n                                 FROM vend\n                                 WHERE (vend_vendtype_id=<? value("vendtype_id") ?>)))\n   <? elseif exists("vendtype_pattern") ?>\n     AND (checkhead_recip_type = 'V')\n     AND (checkhead_recip_id IN (SELECT vend_id\n                                 FROM vend, vendtype\n                                 WHERE  (vend_vendtype_id=vendtype_id)\n                                   AND  (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n   <? endif ?>\n   )\n<? endif ?>\n ORDER BY checkhead_number, checkid, orderby;\n      admin   2011-11-23      0
65 97      checks  detail  used by printChecks Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: checks\n-- Name: detail\n-- Notes: used by printChecks\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT checkhead.*, form_report_name AS report_name\nFROM checkhead\nLEFT OUTER JOIN vendinfo ON((checkhead_recip_id = vend_id)\n                        AND (checkhead_recip_type = 'V'))\nLEFT OUTER JOIN custinfo ON((checkhead_recip_id = cust_id)\n                        AND (checkhead_recip_type = 'C'))\nLEFT OUTER JOIN taxauth ON((checkhead_recip_id = taxauth_id)\n                       AND (checkhead_recip_type = 'T')),\n     bankaccnt, form\nWHERE ( (checkhead_bankaccnt_id=bankaccnt_id)\n  AND   (bankaccnt_check_form_id=form_id)\n<? if exists("toPrintOnly") ?>\n  AND   (NOT checkhead_printed)\n  AND   (NOT checkhead_void)\n<? endif ?>\n<? if exists("bankaccnt_id") ?>\n  AND   (bankaccnt_id=<? value("bankaccnt_id" ?>)\n<? endif ?>\n      )\n<? if exists("orderByName") ?>\nORDER BY checkhead_recip_type DESC, COALESCE(vend_name, cust_name, taxauth_name)\n<? else ?>\nORDER BY checkhead_recip_type DESC, COALESCE(vend_number, cust_number, taxauth_code)\n<? endif ?>\n<? if exists("numtoprint") ?>\nLIMIT <? value("numtoprint") ?>\n<? endif ?>\n;\n        admin   2011-11-23      0
66 426     contactmerge    search  Search for contacts Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: contactmerge\n-- Name: search\n-- Notes: Search for contacts\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct_id,\n  CASE\n    WHEN (cntctsel_cntct_id IS NOT NULL AND cntctsel_target) THEN\n      1 -- Selected as target contact\n    WHEN (cntctsel_cntct_id IS NOT NULL AND NOT cntctsel_target) THEN\n      2 -- Selected as contact to merge\n    WHEN (cntctmrgd_cntct_id IS NOT NULL AND cntctUsed(cntctmrgd_cntct_id)=false) THEN\n      3 -- Already merged contact\n    WHEN (cntctmrgd_cntct_id IS NOT NULL) THEN\n      4 -- Already merged contact, but still has relationships\n    ELSE\n      0 -- No status\n  END AS status,\n  cntctdups.*, \n  cntctdup_level AS xtindentrole,\n  CASE\n    WHEN (cntctsel_cntct_id IS NOT NULL AND cntctsel_target) THEN\n      'altemphasis' -- Selected as target contact\n    WHEN (cntctsel_cntct_id IS NOT NULL AND NOT cntctsel_target) THEN\n      'emphasis' -- Selected as contact to merge\n    WHEN (cntctmrgd_cntct_id IS NOT NULL AND cntctUsed(cntctmrgd_cntct_id)=false) THEN\n      'warning' -- Already merged contact\n    WHEN (cntctmrgd_cntct_id IS NOT NULL) THEN\n      'error' -- Already merged contact, but still has relationships\n  END AS qtforegroundrole\nFROM cntctdups(\n  <? value("searchText") ?>, \n  <? value("searchContactName") ?>, \n  <? value("searchPhone") ?>, \n  <? value("searchEmail") ?>, \n  <? value("searchNumber") ?>, \n  <? value("searchName") ?>, \n  <? value("showInactive") ?>, \n  <? value("ignoreBlanks") ?>,\n  <? value("IndentedDups") ?>, \n  <? value("CheckHnfc") ?>, \n  <? value("CheckFirst") ?>, \n  <? value("CheckMiddle") ?>, \n  <? value("CheckLast") ?>, \n  <? value("CheckSuffix") ?>, \n  <? value("CheckPhone") ?>, \n  <? value("CheckEmail") ?>)\n  LEFT OUTER JOIN cntctsel ON (cntct_id=cntctsel_cntct_id)\n  LEFT OUTER JOIN cntctmrgd ON (cntct_id=cntctmrgd_cntct_id);\n  admin   2011-11-23      0
67 450     contact muststayactive  This query determines whether a given contact should be kept active because other active records depend on it. Todo - should this be moved to the cntctAfterTrigger? Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: contact\n-- Name:  muststayactive\n-- Notes: This query determines whether a given contact should be kept\n--        active because other active records depend on it.\n--        Todo - should this be moved to the cntctAfterTrigger?\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT EXISTS(\n SELECT 1\n   FROM crmacct\n  WHERE(crmacct_active\n    AND (<? value("id") ?> IN (crmacct_cntct_id_1, crmacct_cntct_id_2)))\n UNION SELECT 3\n   FROM custinfo\n  WHERE (cust_active\n    AND (<? value("id") ?> IN (cust_cntct_id, cust_corrcntct_id)))\n UNION SELECT 5\n   FROM vendinfo\n  WHERE (vend_active\n    AND (<? value("id") ?> IN (vend_cntct1_id, vend_cntct2_id)))\n UNION SELECT 7\n   FROM prospect\n  WHERE (prospect_active AND (prospect_cntct_id=<? value("id") ?>))\n UNION SELECT 8\n   FROM shiptoinfo\n  WHERE (shipto_active AND (shipto_cntct_id=<? value("id") ?>))\n UNION SELECT 9\n   FROM vendaddrinfo\n   JOIN vendinfo ON (vendaddrinfo_vend_id=vend_id)\n  WHERE (vend_active AND (vendaddr_cntct_id=<? value("id") ?>))\n UNION SELECT 10\n   FROM whsinfo\n  WHERE (warehous_active AND (warehous_cntct_id=<? value("id") ?>))\n UNION SELECT 11\n   FROM emp\n  WHERE (emp_active AND (emp_cntct_id=<? value("id") ?>))\n UNION SELECT 21\n   FROM todoitem\n  WHERE (todoitem_completed_date IS NOT NULL\n    AND (todoitem_cntct_id=<? value("id") ?>))\n) AS inuse;\n admin   2011-11-23      0
68 276     prices  detail  used by dspPricesByCustomerType, dspPricesByCustomer, dspPricesByItem Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: prices\n-- Name: detail\n-- Notes: used by dspPricesByCustomerType, dspPricesByCustomer, dspPricesByItem\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemid, sourcetype, schedulename, type,\n<? if not exists("byItem") ?>\n       itemnumber, itemdescrip, priceuom,\n<? else ?>\n       typename,\n<? endif ?>\n       CASE WHEN (qtybreak <> -1) THEN qtybreak END AS f_qtybreak,\n       price,\n       currConcat(curr_id) AS currConcat,\n       'qty' AS f_qtybreak_xtnumericrole,\n       <? value("na") ?> AS f_qtybreak_xtnullrole,\n       'salesprice' AS price_xtnumericrole\n<? if exists("showCosts") ?>\n  <? if exists("byItem") ?>\n       , CASE WHEN (<? value("cost") ?> <> 0) THEN <? value("cost") ?> END AS f_cost,\n       CASE WHEN ((price <> 0) AND (<? value("cost") ?> <> 0)) THEN ((price - <? value("cost") ?>) /  price) END AS f_margin,\n  <? else ?>\n       , CASE WHEN (cost IS NOT NULL) THEN cost END AS f_cost,\n      CASE WHEN ((price <> 0) AND (cost <>0)) THEN ((price - cost) / price) END AS f_margin,\n  <? endif ?>\n       'cost' AS f_cost_xtnumericrole,\n       <? value("costna") ?> AS f_cost_xtnullrole,\n       'percent' AS f_margin_xtnumericrole,\n       <? value("na") ?> AS f_margin_xtnullrole,\n  <? if exists("byItem") ?>\n       CASE WHEN (<? value("cost") ?> > price) THEN 'error' END AS f_margin_qtforegroundrole\n  <? else ?>\n       CASE WHEN (cost > price) THEN 'error' END AS f_margin_qtforegroundrole\n  <? endif ?>\n<? endif ?>\nFROM (\n<? if not exists("byCustomerType") ?>\n      SELECT\n  <? if exists("byCustomer") ?>\n             ipsprice_id AS itemid, 1 AS sourcetype,\n             ipshead_name AS schedulename, <? value("customer") ?> AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             ipsprice_qtybreak AS qtybreak,\n             ipsprice_price AS price, ipshead_curr_id AS curr_id,\n             ipshead_updated AS effective\n    <? if exists("useStandardCosts") ?>\n             , (stdcost(item_id) * iteminvpricerat(item_id)) AS cost\n    <? elseif exists("useActualCosts") ?>\n             , (actcost(item_id) * iteminvpricerat(item_id)) AS cost\n    <? endif ?>\n  <? else ?>\n             ipsprice_id AS itemid, 1 AS sourcetype,\n             ipshead_name AS schedulename, <? value("customer") ?> AS type,\n             cust_name AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n  <? endif ?>\n      FROM ipsass, ipshead, ipsprice, item,\n  <? if exists("byCustomer") ?>\n           uom\n  <? else ?>\n          cust\n  <? endif ?>\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (ipsprice_item_id=item_id)\n  <? if exists("byCustomer") ?>\n         AND (item_price_uom_id=uom_id)\n         AND (ipsass_cust_id=<? value("cust_id") ?>)\n  <? else ?>\n         AND (ipsass_cust_id=cust_id)\n         AND (item_id=<? value("item_id") ?>)\n  <? endif ?>\n         AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n  <? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? endif ?>\n            )\n\n      UNION\n<? endif ?>\n\n      SELECT\n<? if exists("byItem") ?>\n             ipsprice_id AS itemid, 2 AS sourcetype,\n             ipshead_name AS schedulename, <? value("custType") ?> AS type,\n             (custtype_code || '-' || custtype_descrip) AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n<? else ?>\n             ipsprice_id AS itemid,\n  <? if exists("byCustomerType") ?>\n             1 AS sourcetype,\n  <? elseif exists("byCustomer") ?>\n             2 AS sourcetype,\n  <? endif ?>\n             ipshead_name AS schedulename, <? value("custType") ?> AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             ipsprice_qtybreak AS qtybreak,\n             ipsprice_price AS price, ipshead_curr_id AS curr_id,\n             ipshead_updated AS effective\n  <? if exists("showCosts") ?>\n    <? if exists("useStandardCosts") ?>\n             , (stdcost(\n      <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n      <? elseif exists("byCustomer") ?>\n                item_id\n      <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? elseif exists("useActualCosts") ?>\n             , (actcost(\n      <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n      <? elseif exists("byCustomer") ?>\n                item_id\n      <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? endif ?>\n  <? endif ?>\n<? endif ?>\n      FROM ipsass, ipshead, ipsprice, item,\n<? if exists("byItem") ?>\n           custtype\n<? else ?>\n           uom\n<? endif ?>\n<? if exists("byCustomer") ?>\n           , cust\n<? endif ?>\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (ipsprice_item_id=item_id)\n<? if not exists("byItem") ?>\n         AND (item_price_uom_id=uom_id)\n<? endif ?>\n<? if exists("byCustomerType") ?>\n         AND (ipsass_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("byCustomer") ?>\n         AND (ipsass_custtype_id=cust_custtype_id)\n         AND (cust_id=<? value("cust_id") ?>)\n<? else ?>\n         AND (ipsass_custtype_id=custtype_id)\n         AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n            )\n\n      UNION\n\n      SELECT\n<? if exists("byItem") ?>\n             ipsprice_id AS itemid, 3 AS sourcetype,\n             ipshead_name AS schedulename, <? value("custTypePattern") ?> AS type,\n             (custtype_code || '-' || custtype_descrip) AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n<? else ?>\n             ipsprice_id AS itemid,\n  <? if exists("byCustomerType") ?>\n             2 AS sourcetype,\n  <? elseif exists("byCustomer") ?>\n             3 AS sourcetype,\n  <? endif ?>\n             ipshead_name AS schedulename, <? value("custTypePattern") ?> AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             ipsprice_qtybreak AS qtybreak,\n             ipsprice_price AS price, ipshead_curr_id AS curr_id,\n             ipshead_updated AS effective\n  <? if exists("showCosts") ?>\n    <? if exists("useStandardCosts") ?>\n             , (stdcost(\n      <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n      <? elseif exists("byCustomer") ?>\n                item_id\n      <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? elseif exists("useActualCosts") ?>\n             , (actcost(\n      <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n      <? elseif exists("byCustomer") ?>\n                item_id\n      <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? endif ?>\n  <? endif ?>\n<? endif ?>\n      FROM ipsass, ipshead, ipsprice, item, custtype\n<? if not exists("byItem") ?>\n           , uom\n<? endif ?>\n<? if exists("byCustomer") ?>\n           , cust\n<? endif ?>\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (ipsprice_item_id=item_id)\n<? if not exists("byItem") ?>\n         AND (item_price_uom_id=uom_id)\n<? endif ?>\n         AND (coalesce(length(ipsass_custtype_pattern), 0) > 0)\n         AND (custtype_code ~ ipsass_custtype_pattern)\n<? if exists("byCustomerType") ?>\n         AND (custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("byCustomer") ?>\n         AND (cust_id=<? value("cust_id") ?>)\n<? else ?>\n         AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n            )\n\n      UNION\n\n      SELECT\n<? if exists("byItem") ?>\n             ipsprice_id AS itemid, 4 AS sourcetype,\n             ipshead_name AS schedulename, <? value("sale") ?> AS type,\n             sale_name AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n<? else ?>\n             ipsprice_id AS itemid,\n<? if exists("byCustomerType") ?>\n             3\n<? elseif exists("byCustomer") ?>\n             4\n<? endif ?> AS sourcetype,\n             ipshead_name AS schedulename, (<? value("sale") ?> || '-' || sale_name) AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             ipsprice_qtybreak AS qtybreak,\n             ipsprice_price AS price, ipshead_curr_id AS curr_id,\n             ipshead_updated AS effective\n<? if exists("showCosts") ?>\n  <? if exists("useStandardCosts") ?>\n             , (stdcost(\n    <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n    <? elseif exists("byCustomer") ?>\n                item_id\n    <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? elseif exists("useActualCosts") ?>\n             , (actcost(\n    <? if exists("byCustomerType") ?>\n                ipsprice_item_id\n    <? elseif exists("byCustomer") ?>\n                item_id\n    <? endif ?>\n                     ) * iteminvpricerat(item_id)) AS cost\n    <? endif ?>\n  <? endif ?>\n<? endif ?>\n      FROM sale, ipshead, ipsprice, item\n<? if not exists("byItem") ?>\n           , uom\n<? endif ?>\n      WHERE ((sale_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n<? if not exists("byItem") ?>\n         AND (item_price_uom_id=uom_id)\n<? endif ?>\n<? if exists("byItem") ?>\n         AND (ipsprice_item_id=<? value("item_id") ?>)\n  <? if not exists("showExpired") ?>\n         AND (sale_enddate > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (sale_startdate <= CURRENT_DATE)\n  <? endif ?>\n<? else ?>\n         AND (ipsprice_item_id=item_id)\n  <? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? endif ?>\n<? endif ?>\n            )\n\n<? if exists("byItem") ?>\n\n      UNION\n\n      SELECT ipsprice_id AS itemid, 5 AS sourcetype,\n             ipshead_name AS schedulename, <? value("shipTo") ?> AS type,\n             (cust_name || '-' || shipto_num) AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n      FROM ipsass, ipshead, ipsprice, cust, shipto, item\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (ipsass_shipto_id=shipto_id)\n         AND (shipto_cust_id=cust_id)\n         AND (ipsprice_item_id=item_id)\n         AND (item_id=<? value("item_id") ?>)\n  <? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? endif ?>\n            )\n\n      UNION\n\n      SELECT ipsprice_id AS itemid, 6 AS sourcetype,\n             ipshead_name AS schedulename, <? value("shipToPattern") ?> AS type,\n             (cust_name || '-' || shipto_num) AS typename,\n             ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n      FROM ipsass, ipshead, ipsprice, cust, shipto, item\n      WHERE ((ipsass_ipshead_id=ipshead_id)\n         AND (ipsprice_ipshead_id=ipshead_id)\n         AND (COALESCE(LENGTH(ipsass_shipto_pattern),0) > 0)\n         AND (shipto_num ~ ipsass_shipto_pattern)\n         AND (ipsass_cust_id=cust_id)\n         AND (shipto_cust_id=cust_id)\n         AND (ipsprice_item_id=item_id)\n         AND (item_id=:item_id)\n  <? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? endif ?>\n            )\n<? endif ?>\n\n      UNION\n\n      SELECT\n<? if exists("byItem") ?>\n             item_id AS itemid, 0 AS sourcetype,\n             <? value("listPrice") ?> AS schedulename, <? value("na") ?> AS type,\n             '' AS typename,\n             -1 AS qtybreak, item_listprice AS price, baseCurrId() AS curr_id\n<? else ?>\n             item_id AS itemid, 0 AS sourcetype,\n             '' AS schedulename, <? value("listPrice") ?> AS type,\n             item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n             -1 AS qtybreak,\n  <? if exists("byCustomerType") ?>\n             item_listprice AS price,\n  <? elseif exists("byCustomer") ?>\n             (item_listprice - (item_listprice * cust_discntprcnt)) AS price,\n  <? endif ?>\n             baseCurrId() AS curr_id,\n             CURRENT_DATE AS effective\n  <? if exists("useStandardCosts") ?>\n             , (stdcost(item_id) * iteminvpricerat(item_id)) AS cost\n  <? elseif exists("useActualCosts") ?>\n             , (actcost(item_id) * iteminvpricerat(item_id)) AS cost\n  <? endif ?>\n<? endif ?>\n<? if exists("byCustomerType") ?>\n      FROM item JOIN uom ON (item_price_uom_id=uom_id)\n<? elseif exists("byCustomer") ?>\n      FROM cust, item JOIN uom ON (item_price_uom_id=uom_id)\n<? else ?>\n      FROM item\n<? endif ?>\n      WHERE (\n<? if not exists("byItem") ?>\n             (item_sold)\n         AND (item_active)\n<? else ?>\n             (item_id=<? value("item_id") ?>)\n<? endif ?>\n         AND (NOT item_exclusive)\n<? if exists("byCustomer") ?>\n         AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n            )\n     ) AS data\nORDER BY\n<? if not exists("byItem") ?>\n         itemnumber,\n<? endif ?>\n         price;\n      admin   2011-11-23      0
69 438     contact uses    Find and report uses of the contact Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: contact\n-- Name:  uses\n-- Notes: Find and report uses of the contact\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if not exists('core') ?>\nSELECT <? value("id") ?>::text || '.' || type_id::text || '.' || type_code::text,\n       <? value("id") ?> AS contact,\n       *\nFROM (\n<? endif ?>\n  SELECT crmacct_id AS type_id, 1 AS type_code, <? value("crmacct") ?> AS type,\n         crmacct_number AS number,\n         crmacct_name AS name, <? value("primary") ?> AS role,\n         (crmacct_active) AS active,\n         crmacct_owner_username AS owner\n    FROM crmacct WHERE (crmacct_cntct_id_1=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT crmacct_id AS type_id, 2 AS type_code, <? value("crmacct") ?> AS type,\n         crmacct_number AS number,\n         crmacct_name AS name, <? value("secondary") ?> AS role,\n         (crmacct_active) AS active,\n         crmacct_owner_username AS owner\n    FROM crmacct WHERE (crmacct_cntct_id_2=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT cust_id AS type_id, 3 AS type_code, <? value("cust") ?> AS type,\n         cust_number AS number,\n         cust_name AS name, <? value("billing") ?> AS role,\n         (cust_active) AS active,\n         '' AS owner\n    FROM custinfo WHERE (cust_cntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT cust_id AS type_id, 4 AS type_code, <? value("cust") ?> AS type,\n         cust_number AS number,\n         cust_name AS name, <? value("correspond") ?> AS role,\n         (cust_active) AS active,\n         '' AS owner\n    FROM custinfo WHERE (cust_corrcntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT vend_id AS type_id, 5 AS type_code, <? value("vend") ?> AS type,\n         vend_number AS number,\n         vend_name AS name, <? value("primary") ?> AS role,\n         (vend_active) AS active,\n         '' AS owner\n    FROM vendinfo WHERE (vend_cntct1_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT vend_id AS type_id, 6 AS type_code, <? value("vend") ?> AS type,\n         vend_number AS number,\n         vend_name AS name, <? value("secondary") ?> AS role,\n         (vend_active) AS active,\n         '' AS owner\n    FROM vendinfo WHERE (vend_cntct2_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT prospect_id AS type_id, 7 AS type_code, <? value("prospect") ?> AS type,\n         prospect_number AS number,\n         prospect_name AS name, '' AS role,\n         (prospect_active) AS active,\n         '' AS owner\n    FROM prospect WHERE (prospect_cntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT shipto_id AS type_id, 8 AS type_code, <? value("shipto") ?> AS type,\n         shipto_num AS number,\n         shipto_name AS name, <? value("shipto") ?> AS role,\n         (shipto_active) AS active,\n         '' AS owner\n    FROM shiptoinfo WHERE (shipto_cntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT vendaddr_id AS type_id, 9 AS type_code, <? value("vendaddr") ?> AS type,\n         vendaddr_code AS number,\n         vendaddr_name AS name, '' AS role,\n         (true) AS active,\n         '' AS owner\n    FROM vendaddrinfo WHERE (vendaddr_cntct_id=<? value("id") ?>)\n   \n  UNION ALL\n  SELECT warehous_id AS type_id, 10 AS type_code, <? value("whs") ?> AS type,\n         warehous_code AS number,\n         warehous_descrip AS name, '' AS role,\n         (warehous_active) AS active,\n         '' AS owner\n    FROM whsinfo WHERE (warehous_cntct_id=<? value("id") ?>)\n  \n  UNION ALL\n  SELECT emp_id AS type_id, 11 AS type_code, <? value("emp") ?> AS type,\n         emp_code AS number,\n         emp_number AS name, '' AS role,\n         (emp_active) AS active,\n         '' AS owner\n    FROM emp WHERE (emp_cntct_id=<? value("id") ?>)\n\n<? if exists("showOrders") ?>\n  UNION ALL\n  SELECT cohead_id AS id, 12 AS altId, <? value("cohead") ?> AS type,\n         cohead_number AS number,\n         cust_number AS name, <? value("billing") ?> AS role,\n         (cohead_status = 'O') AS active,\n         '' AS owner\n    FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n   WHERE (<? value("id") ?>=cohead_billto_cntct_id)\n\n  UNION ALL\n  SELECT cohead_id AS id, 13 AS altId, <? value("cohead") ?> AS type,\n         cohead_number AS number,\n         cust_number AS name,  <? value("shipto") ?> AS role,\n         (cohead_status = 'O') AS active,\n         '' AS owner\n    FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n   WHERE (<? value("id") ?>=cohead_shipto_cntct_id)\n<? endif ?>\n\n  UNION ALL\n  SELECT incdt_id AS id, 14 AS altId, <? value("incdt") ?> AS type,\n         incdt_number::TEXT AS number,\n         incdt_summary AS name, '' AS role,\n         (incdt_status NOT IN ('R', 'L')) AS active,\n         incdt_owner_username AS owner\n    FROM incdt\n   WHERE (incdt_cntct_id=<? value("id") ?>)\n\n<? if exists("lsreg") ?>\n  UNION ALL\n  SELECT lsreg_id AS id, 15 AS altId, <? value("lsreg") ?> AS type,\n         ls_number AS number,\n         item_number AS name, '' AS role,\n         (lsreg_expiredate > current_date) AS active,\n         '' AS owner\n    FROM lsreg JOIN ls ON (lsreg_ls_id=ls_id) JOIN item ON (ls_item_id=item_id)\n   WHERE (lsreg_cntct_id=<? value("id") ?>)\n<? endif ?>\n\n  UNION ALL\n  SELECT ophead_id AS id, 16 AS altId, <? value("ophead") ?> AS type,\n         ophead_number AS number,\n         ophead_name AS name, '' AS role,\n         ophead_active AS active,\n         ophead_owner_username AS owner\n    FROM ophead\n   WHERE (ophead_cntct_id=<? value("id") ?>)\n\n<? if exists("showOrders") ?>\n  UNION ALL\n  SELECT pohead_id AS id, 17 AS altId, <? value("pohead") ?> AS type,\n         pohead_number AS number,\n         vend_number AS name, <? value("vendcntct") ?> AS role,\n         (pohead_status != 'C') AS active,\n         '' AS owner\n    FROM pohead JOIN vendinfo ON (pohead_vend_id=vend_id)\n   WHERE (<? value("id") ?>=pohead_vend_cntct_id)\n\n  UNION ALL\n  SELECT pohead_id AS id, 18 AS altId, <? value("pohead") ?> AS type,\n         pohead_number AS number,\n         vend_number AS name, <? value("shipto") ?> AS role,\n         (pohead_status != 'C') AS active,\n         '' AS owner\n    FROM pohead JOIN vendinfo ON (pohead_vend_id=vend_id)\n   WHERE (<? value("id") ?>=pohead_shipto_cntct_id)\n\n  UNION ALL\n  SELECT quhead_id AS id, 19 AS altId, <? value("quhead") ?> AS type,\n         quhead_number AS number,\n         COALESCE(cust_number, prospect_number) AS name,\n         <? value("billing") ?> AS role,\n         (quhead_status = 'O') AS active,\n         '' AS owner\n    FROM quhead LEFT OUTER JOIN custinfo ON (quhead_cust_id=cust_id)\n                LEFT OUTER JOIN prospect ON (quhead_cust_id=prospect_id)\n   WHERE (<? value("id") ?>=quhead_billto_cntct_id)\n\n  UNION ALL\n  SELECT quhead_id AS id, 20 AS altId, <? value("quhead") ?> AS type,\n         quhead_number AS number,\n         COALESCE(cust_number, prospect_number) AS name,\n         <? value("shipto") ?> AS role,\n         (quhead_status = 'O') AS active,\n         '' AS owner\n    FROM quhead LEFT OUTER JOIN custinfo ON (quhead_cust_id=cust_id)\n                LEFT OUTER JOIN prospect ON (quhead_cust_id=prospect_id)\n   WHERE (<? value("id") ?>=quhead_shipto_cntct_id)\n<? endif ?>\n\n  UNION ALL\n  SELECT todoitem_id, 21 AS altId, <? value("todo") ?> AS type,\n         todoitem_seq::TEXT AS number,\n         todoitem_name AS name, '' AS role,\n         (todoitem_completed_date IS NULL) AS active,\n         todoitem_owner_username AS owner\n    FROM todoitem\n   WHERE todoitem_cntct_id=<? value("id") ?>\n\n<? if exists("showOrders") ?>\n  <? if exists("tohead") ?>\n  UNION ALL\n  SELECT tohead_id, 22 AS altId, <? value("tohead") ?> AS type,\n         tohead_number AS number,\n         tohead_srcname || ' -> ' || tohead_destname AS name,\n         <? value("from") ?>  AS role,\n         (tohead_status = 'O') AS active,\n         '' AS owner\n    FROM tohead\n   WHERE (<? value("id") ?>=tohead_srccntct_id)\n  UNION ALL\n  SELECT tohead_id, 23 AS altId, <? value("tohead") ?> AS type,\n         tohead_number AS number,\n         tohead_srcname || ' -> ' || tohead_destname AS name,\n         <? value("dest") ?> AS role,\n         (tohead_status = 'O') AS active,\n         '' AS owner\n    FROM tohead\n   WHERE (<? value("id") ?>=tohead_destcntct_id)\n  <? endif ?>\n<? endif ?>\n\n<? if not exists('core') ?>\n) AS innerq\n<? endif ?>\n  ORDER BY type, number;\n      admin   2011-11-23      0
70 418     contactmerge    contactused     Checks to see if this contact is used anywhere Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: contactmerge\n-- Name: contactused\n-- Notes: Checks to see if this contact is used anywhere\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctused(<? value("cntct_id") ?>) AS used;\n admin   2011-11-23      0
71 420     contactmerge    deselect        Removes contact selection Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: contactmerge\n-- Name: deselect\n-- Notes: Removes contact selection\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntctsel\nWHERE (cntctsel_cntct_id=<? value("cntct_id") ?>);\n   admin   2011-11-23      0
72 422     contactmerge    merge   Merge contact selections Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: contactmerge\n-- Name: merge\n-- Notes: Merge contact selections\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctmerge(\n  src.cntctsel_cntct_id, \n  trgt.cntctsel_cntct_id,\n  <? value("purge") ?>::boolean) AS result\nFROM cntctsel src, cntctsel trgt\nWHERE ((trgt.cntctsel_target)\nAND (NOT src.cntctsel_target));\n admin   2011-11-23      0
73 421     contactmerge    merged  Lists all merged contacts Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: contactmerge\n-- Name: merged\n-- Notes:  Lists all merged contacts\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct_id,\n  CASE\n    WHEN (cntctUsed(cntctmrgd_cntct_id)=false) THEN\n      3 -- Already merged contact\n    ELSE\n      4 -- Already merged contact, but still has relationships\n  END AS status,\n  cntct.*,crmacct_number,crmacct_name,addr.*, \n 0 AS xtindentrole,\n  CASE\n    WHEN (cntctUsed(cntctmrgd_cntct_id)=false) THEN\n      'warning' -- Already merged contact\n    ELSE\n      'error'  -- Already merged contact, but still has relationships\n  END AS qtforegroundrole\nFROM cntct\n  JOIN cntctmrgd ON (cntct_id=cntctmrgd_cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n  LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id);\n        admin   2011-11-23      0
74 423     contactmerge    populate        Queries selected contact info Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: contactmerge\n-- Name: populate\n-- Notes: Queries selected contact info\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct.*,\n  crmacct_number,\n  crmacct_name,\n  addr.*,\n  CASE WHEN cntctsel_mrg_first_name THEN 'emphasis' END AS cntct_first_name_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_last_name THEN 'emphasis' END AS cntct_last_name_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_honorific THEN 'emphasis' END AS cntct_honorific_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_initials THEN 'emphasis' END AS cntct_initials_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_phone THEN 'emphasis' END AS cntct_phone_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_phone2 THEN 'emphasis' END AS cntct_phone2_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_fax THEN 'emphasis' END AS cntct_fax_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_email THEN 'emphasis' END AS cntct_email_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_webaddr THEN 'emphasis' END AS cntct_webaddr_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_notes THEN 'emphasis' END AS cntct_notes_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_title THEN 'emphasis' END AS cntct_title_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_middle THEN 'emphasis' END AS cntct_middle_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_suffix THEN 'emphasis' END AS cntct_suffix_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_owner_username THEN 'emphasis' END AS cntct_owner_username_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_crmacct_id THEN 'emphasis' END AS crmacct_number_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_crmacct_id THEN 'emphasis' END AS crmacct_name_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line1_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line2_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line3_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_city_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_state_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_postalcode_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_country_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_notes_qtforegroundrole,\n  CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_number_qtforegroundrole\nFROM cntctsel\n  JOIN cntct ON (cntctsel_cntct_id=cntct_id)\n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n  LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id)\nWHERE (cntctsel_target=<? value("target") ?>);\n   admin   2011-11-23      0
75 424     contactmerge    purge   Purge contact(s) that was/were previously merged Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: contactmerge\n-- Name: purge\n-- Notes: Purge contact(s) that was/were previously merged\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntct WHERE cntct_id IN\n(SELECT cntctmrgd_cntct_id\n  FROM cntctmrgd\n  WHERE (NOT cntctmrgd_error)\n<? if exists("cntct_id") ?>\nAND (cntctmrgd_cntct_id=<? value("cntct_id") ?>)\n<? endif ?>)\nAND (NOT cntctUsed(cntct_id));\n  admin   2011-11-23      0
76 99      contacts        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: contacts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (length(cntct_last_name)=0, length(cntct_first_name)=0, cntct_last_name, cntct_first_name, cntct_number) \n  cntct_id AS id\n<? if not exists("idOnly") ?> \n, addr_id AS altId, addr.*,\n  crmacct_id, crmacct_number, crmacct_name,\n  cntct.* \n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\n<? endif ?>\n<? if exists("hasContext") ?>\nFROM cntct\n<? else ?>\nFROM cntct()\n<? endif ?>\n  LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) \n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \n  LEFT OUTER JOIN cntcteml ON (cntcteml_cntct_id=cntct_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='CNTCT') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cntct_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='CNTCT') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cntct_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='CNTCT') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cntct_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if exists("owner_username") ?> \n  AND (cntct_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (cntct_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if exists("activeOnly") ?> \n  AND cntct_active\n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND (\n (crmacct_number ~* <? value("search_pattern") ?>)\n  OR (crmacct_name ~* <? value("search_pattern") ?>)\n  OR (cntct_first_name || ' ' || cntct_last_name ~* <? value("search_pattern") ?>)\n  OR (cntct_phone || ' ' || cntct_phone2 || ' ' || cntct_fax ~* <? value("search_pattern") ?>)\n  OR (cntcteml_email ~* <? value("search_pattern") ?>)\n  OR (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("search_pattern") ?>)\n  OR (addr_city ~* <? value("search_pattern") ?>)\n  OR (addr_state ~* <? value("search_pattern") ?>)\n  OR (addr_postalcode ~* <? value("search_pattern") ?>)\n  OR (addr_country ~* <? value("search_pattern") ?>)\n)\n<? endif ?>\n<? if exists("cntct_id") ?>\n  AND (cntct_id=<? value("cntct_id")?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (crmacct_id=<? value("crmacct_id")?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (cntct_first_name || ' ' || cntct_last_name ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (cntct_phone || ' ' || cntct_phone2 || ' ' || cntct_fax ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (cntcteml_email ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (addr_city ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (addr_state ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (addr_postalcode ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (addr_country ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? if exists("id") ?>\n  AND (cntct_id=<? literal("id") ?>)\n<? endif ?>\n<? if exists("addr_id") ?>\n  AND (addr_id=<? value("addr_id") ?>)\n<? endif ?>\n<? literal("charClause") ?>\nORDER BY length(cntct_last_name)=0, length(cntct_first_name)=0, cntct_last_name, cntct_first_name, cntct_number, cntcteml_primary desc;\n       admin   2011-11-23      0
77 112     costelem        unusedbyitem    list the cost elements that can be applied to an item that have not already been applied to that item. takes an item_id and type. Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: costelem\n-- Name:  unusedbyitem\n-- Notes: list the cost elements that can be applied to an item that have\n--        not already been applied to that item. takes an item_id and type.\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT costelem_id, costelem_type\nFROM costelem\nWHERE ((costelem_active)\n   AND (NOT costelem_sys\n        OR (CASE WHEN fetchMetricBool('Routings') AND\n                     (<? value("itemtype") ?> IN ('M', 'F', 'B', 'C', 'T')) THEN\n               costelem_type IN ('Direct Labor', 'Overhead', 'Machine Overhead')\n                 WHEN (<? value("itemtype") ?> IN ('O', 'P')) THEN\n                                                   costelem_type IN ('Material')\n            END))\n   AND (costelem_id NOT IN (SELECT itemcost_costelem_id\n                            FROM itemcost\n                            WHERE ((NOT itemcost_lowlevel)\n                               AND (itemcost_item_id=<? value("item_id") ?>))))\n      )\nORDER BY costelem_type;\n    admin   2011-11-23      0
78 237     countSlip       detail  used by dspCountSlipEditList, dspCountSlipsByWarehouse Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: countSlip\n-- Name: detail\n-- Notes: used by dspCountSlipEditList, dspCountSlipsByWarehouse\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntslip_id,\n       CASE WHEN (cntslip_posted) THEN 1\n         ELSE 0\n       END,\n       cntslip_username AS user,\n<? if exists("numericSlips") ?>\n       toNumeric(cntslip_number, 0) AS cntslip_number,\n       cntslip_number AS cntslip_number_qtdisplayrole,\n<? else ?>\n       cntslip_number,\n<? endif ?>\n       CASE WHEN (cntslip_location_id=-1) THEN ''\n         ELSE formatLocationName(cntslip_location_id)\n       END AS locname,\n       invcnt_tagnumber,\n<? if exists("byWarehouse") ?>\n       warehous_code,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS descrip,\n<? endif ?>\n       cntslip_lotserial, cntslip_posted,\n       cntslip_entered, cntslip_qty,\n       'qty' AS cntslip_qty_xtnumericrole,\n       cntslip_posted AS posted\nFROM cntslip, invcnt\n<? if exists("byWarehouse") ?>\n     JOIN itemsite ON (invcnt_itemsite_id=itemsite_id)\n     JOIN item ON (itemsite_item_id=item_id)\n     JOIN warehous ON (itemsite_warehous_id=warehous_id)\n<? endif ?>\nWHERE ((cntslip_cnttag_id=invcnt_id)\n<? if exists("byWarehouse") ?>\n   AND (cntslip_entered BETWEEN <? value("startDate") ?> AND  (<? value("endDate") ?>::DATE + 1))\n  <? if not exists("showUnposted") ?>\n    AND (cntslip_posted)\n  <? endif ?>\n  <? if exists("warehous_id") ?>\n    AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n<? else ?>\n    AND (NOT invcnt_posted)\n    AND (invcnt_id=<? value("cnttag_id") ?>)\n<? endif ?>\n      )\nORDER BY cntslip_number;\n       admin   2011-11-23      0
79 436     countTags       create  used by createCountTagsByParameterList Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: countTags\n-- Name: create\n-- Notes: used by createCountTagsByParameterList\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT createCountTag(itemsite_id, <? value("comments") ?>, <? value("priority") ?>, <? value("freeze") ?>, <? value("location_id") ?>)\nFROM ( SELECT itemsite_id\n       FROM itemsite JOIN item ON (item_id=itemsite_item_id)\n<? if exists("location_id") ?>\n                     JOIN itemloc ON ( (itemloc_location_id=<? value("location_id") ?>)\n                                   AND (itemloc_itemsite_id = itemsite_id)\n                                   AND (validLocation(<? value("location_id") ?>, itemsite_id)) )\n<? endif ?>\n       WHERE (itemsite_active)\n         AND (item_active)\n<? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n         AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id\n                                    FROM classcode\n                                    WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n                                FROM plancode\n                                WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("ignoreZeroBalance") ?>\n         AND (itemsite_qtyonhand <> 0.0)\n<? endif ?>\n       ORDER BY item_number ) AS data;\n       admin   2011-11-23      0
80 264     openpurchaseorders      detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: openpurchaseorders\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, COALESCE(pohead_cohead_id, -1) AS pohead_cohead_id,\n                      pohead_number, vend_name,\n                      MIN(poitem_duedate) AS min_duedate, \n                      pohead_status, pohead_printed,\n                      vend_number, vendtype_code, pohead_agent_username\n               FROM pohead \n                 JOIN vend ON (pohead_vend_id=vend_id)\n                 JOIN vendtype ON (vend_vendtype_id=vendtype_id)\n               <? if exists("pohead_agent_usr_id") ?>\n                 JOIN usr ON (pohead_agent_username=usr_username)\n               <? endif ?> \n               <? if exists("warehous_id") ?>\n                 JOIN poitem ON (poitem_pohead_id=pohead_id) \n                 JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n               <? else ?>\n                 LEFT OUTER JOIN poitem ON (poitem_pohead_id=pohead_id) \n               <? endif ?> \n               WHERE ( true\n               <? if exists("search_pattern") ?> \n                 AND ((pohead_number::text ~* <? value("search_pattern") ?>) \n                   OR (vend_number ~* <? value("search_pattern") ?>)\n                   OR (vend_name ~* <? value("search_pattern") ?>)\n\n                   OR (pohead_agent_username ~* <? value("search_pattern") ?>)\n                   OR (vendtype_code ~* <? value("search_pattern") ?>)\n\n                   OR (pohead_vend_cntct_first_name || ' ' || pohead_vend_cntct_last_name ~* <? value("search_pattern") ?>)\n                   OR (pohead_vend_cntct_phone ||' ' || pohead_vend_cntct_fax ~* <? value("search_pattern") ?>)\n                   OR (pohead_vend_cntct_email ~* <? value("search_pattern") ?>)\n                   OR (pohead_vendaddress1 || ' ' || pohead_vendaddress2 || ' ' || pohead_vendaddress3 ~* <? value("search_pattern") ?>)\n                   OR (pohead_vendcity ~* <? value("search_pattern") ?>)\n                   OR (pohead_vendstate ~* <? value("search_pattern") ?>)\n                   OR (pohead_vendzipcode ~* <? value("search_pattern") ?>)\n                   OR (pohead_vendcountry ~* <? value("search_pattern") ?>)\n\n                   OR (pohead_shipto_cntct_first_name || ' ' || pohead_shipto_cntct_last_name ~* <? value("search_pattern") ?>)\n                   OR (pohead_shipto_cntct_phone || ' ' || pohead_shipto_cntct_fax ~* <? value("search_pattern") ?>)\n                   OR (pohead_shipto_cntct_email ~* <? value("search_pattern") ?>)\n                   OR (pohead_shiptoaddress1 || ' ' || pohead_vendaddress2 || ' ' || pohead_vendaddress3 ~* <? value("search_pattern") ?>)\n                   OR (pohead_shiptocity ~* <? value("search_pattern") ?>)\n                   OR (pohead_shiptostate ~* <? value("search_pattern") ?>)\n                   OR (pohead_shiptozipcode ~* <? value("search_pattern") ?>)\n                   OR (pohead_shiptocountry ~* <? value("search_pattern") ?>)\n               )\n               <? endif ?> \n               <? if exists("showUnreleased") ?> \n                 AND (pohead_status ='U') \n               <? endif ?> \n               <? if exists("showOpen") ?>\n                 AND (pohead_status='O' )\n               <? endif ?> \n               <? if exists("showBoth") ?> \n                 AND (pohead_status IN ('U', 'O') ) \n               <? endif ?> \n               <? if exists("shownothing") ?> \n                 AND (pohead_status NOT IN ('U', 'O', 'C')) \n               <? endif ?> \n               <? if exists("vend_id") ?>\n                 AND (vend_id=<? value("vend_id") ?>)\n               <? endif ?> \n               <? if exists("vendtype_id") ?>\n                 AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n               <? endif ?> \n               <? if exists("vendtype_pattern") ?>\n                 AND (vendtype_code ~* <? value("vendtype_pattern") ?>)\n               <? endif ?> \n               <? if exists("pohead_agent_usr_id") ?>\n                 AND (usr_id  = <? value("pohead_agent_usr_id") ?>)\n               <? endif ?> \n               <? if exists("warehous_id") ?>\n                 AND (itemsite_warehous_id = <? value("warehous_id") ?>)\n               <? endif ?> \n               ) \n               GROUP BY pohead_number, pohead_id, pohead_cohead_id,\n\t\t vend_name, pohead_status, pohead_printed,\n                        vendtype_code, pohead_agent_username, vend_number\n               ORDER BY pohead_number;\n admin   2011-11-23      0
81 246     freightPrices   detail  used by dspFreightPricesByCustomer, dspFreightPricesByCustomerType Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: freightPrices\n-- Name: detail\n-- Notes: used by dspFreightPricesByCustomer, dspFreightPricesByCustomerType\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemid, sourcetype, ipshead_name, source, ipsfreight_qtybreak, ipsfreight_price,\n       CASE WHEN (ipsfreight_type = 'F') THEN <? value("flatrate") ?>\n         ELSE <? value("peruom") ?>\n       END AS method,\n       currConcat(ipshead_curr_id) AS currConcat,\n       warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia,\n       'qty' AS ipsfreight_qtybreak_xtnumericrole,\n       <? value("na") ?> AS ipsfreight_qtybreak_xtnullrole,\n       'salesprice' AS ipsfreight_price_xtnumericrole,\n       <? value("any") ?> AS warehous_code_xtnullrole,\n       <? value("any") ?> AS shipzone_name_xtnullrole,\n       <? value("any") ?> AS freightclass_code_xtnullrole,\n       <? value("any") ?> AS ipsfreight_shipvia_xtnullrole\nFROM (SELECT ipsfreight_id AS itemid, 1 AS sourcetype,\n             ipshead_name,\n<? if exists("byCust") ?>\n             <? value("customer") ?> AS source,\n<? elseif exists("byCustType") ?>\n             <? value("custType") ?> AS source,\n<? endif ?>\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n      FROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n           JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n           LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n           LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n           LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n      WHERE ((true)\n<? if exists("byCust") ?>\n         AND (ipsass_cust_id=<? value("cust_id") ?>)\n         AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n<? elseif exists("byCustType") ?>\n         AND (ipsass_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n            )\n\n      UNION\n\n      SELECT ipsfreight_id AS itemid, 2 AS sourcetype,\n             ipshead_name,\n<? if exists("byCust") ?>\n             <? value("custType") ?> AS source,\n<? elseif exists("byCustType") ?>\n             <? value("custTypePattern") ?> AS source,\n<? endif ?>\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n      FROM ipsass\n<? if exists("byCustType") ?>\n           JOIN custtype ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n                                         (custtype_code ~ ipsass_custtype_pattern))\n<? endif ?>\n           JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n           JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n<? if exists("byCust") ?>\n           JOIN cust ON (cust_custtype_id=ipsass_custtype_id)\n<? endif ?>\n           LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n           LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n           LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n      WHERE ((true)\n<? if exists("byCust") ?>\n         AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("byCustType") ?>\n         AND (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if not exists("showExpired") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n            )\n\n      UNION\n\n      SELECT ipsfreight_id AS itemid, 3 AS sourcetype,\n             ipshead_name,\n<? if exists("byCust") ?>\n             <? value("custTypePattern") ?> AS source,\n<? elseif exists("byCustType") ?>\n             (<? value("sale") ?> || '-' || sale_name) AS source,\n<? endif ?>\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n      FROM\n<? if exists("byCust") ?>\n           cust JOIN custtype ON (custtype_id=cust_custtype_id)\n                JOIN ipsass ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n                                (custtype_code ~ ipsass_custtype_pattern))\n                JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n<? elseif exists("byCustType") ?>\n           sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n<? endif ?>\n                JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n                LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n                LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n                LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n      WHERE ((true)\n<? if exists("byCust") ?>\n         AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("byCustType") ?>\n         AND (true)\n<? endif ?>\n<? if not exists("showExpired") ?>\n  <? if exists("byCust") ?>\n         AND (ipshead_expires > CURRENT_DATE)\n  <? elseif exists("byCustType") ?>\n         AND (sale_enddate > CURRENT_DATE)\n  <? endif ?>\n<? endif ?>\n<? if not exists("showFuture") ?>\n  <? if exists("byCust") ?>\n         AND (ipshead_effective <= CURRENT_DATE)\n  <? elseif exists("byCustType") ?>\n         AND (sale_startdate <= CURRENT_DATE)\n  <? endif ?>\n<? endif ?>\n            )\n\n<? if exists("byCust") ?>\n      UNION\n\n      SELECT ipsfreight_id AS itemid, 4 AS sourcetype,\n             ipshead_name, (<? value("sale") ?> || '-' || sale_name) AS source,\n             ipsfreight_qtybreak, ipsfreight_price,\n             ipsfreight_type, ipshead_curr_id,\n             warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n      FROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n                JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n                LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n                LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n                LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n      WHERE ((true)\n  <? if not exists("showExpired") ?>\n         AND (sale_enddate > CURRENT_DATE)\n  <? endif ?>\n  <? if not exists("showFuture") ?>\n         AND (sale_startdate <= CURRENT_DATE)\n  <? endif ?>\n            )\n<? endif ?>\n     ) AS data\nORDER BY ipsfreight_qtybreak, ipsfreight_price;\n  admin   2011-11-23      0
82 48      creditCards     detail  used by cashReceipt, customer, salesOrder Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: creditCards\n-- Name: detail\n-- Notes: used by cashReceipt, customer, salesOrder\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ccard_id, ccard_seq,\n       CASE WHEN (ccard_type='M') THEN <? value("masterCard") ?>\n            WHEN (ccard_type='V') THEN <? value("visa") ?>\n            WHEN (ccard_type='A') THEN <? value("americanExpress") ?>\n            WHEN (ccard_type='D') THEN <? value("discover") ?>\n            ELSE <? value("other") ?>\n       END AS type,\n       formatccnumber(decrypt(setbytea(ccard_number),\n                              setbytea(<? value("key") ?>), 'bf')) AS f_number,\n       ccard_active,\n       formatbytea(decrypt(setbytea(ccard_name),\n                           setbytea(<? value("key") ?>), 'bf')) AS ccard_name,\n       formatbytea(decrypt(setbytea(ccard_month_expired),\n                           setbytea(<? value("key") ?>), 'bf')) ||\n                   '-' ||\n                   formatbytea(decrypt(setbytea(ccard_year_expired),\n                                       setbytea(<? value("key") ?>),\n                                       'bf')) AS expiration \nFROM ccard \nWHERE ((ccard_cust_id=<? value("cust_id") ?>) \n<? if exists("ccard_type") ?>\n AND   (ccard_type=<? value("ccard_type") ?>)\n<? endif ?>\n<? if exists("activeonly") ?>\n AND   (ccard_active)\n<? endif ?>\n)\nORDER BY ccard_seq;\n   admin   2011-11-23      0
83 263     mrpDetail       item    used by dspMRPDetail Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: mrpDetail\n-- Name: item\n-- Notes: used by dspMRPDetail\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, item_type, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       warehous_code\nFROM itemsite, item, warehous\nWHERE ( (itemsite_active)\n    AND (itemsite_item_id=item_id)\n    AND (itemsite_warehous_id=warehous_id)\n    AND (itemsite_planning_type='M')\n<? if exists("plancode_id") ?>\n    AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n    AND (itemsite_plancode_id IN (SELECT plancode_id \n                                  FROM plancode \n                                  WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?>\n    AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY item_number, warehous_code;\n     admin   2011-11-23      0
84 310     creditMemo      editlist        used by creditMemoEditList Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: creditMemo\n-- Name: editlist\n-- Notes: used by creditMemoEditList\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       ('C/M-' || formatCreditMemoNumber(cmhead_id)) AS docnumber,\n       currConcat(curr_id) AS currabbr,\n       CASE WHEN seq != 0 THEN ''\n       END AS docnumber_qtdisplayrole,\n       'qty' AS qtytobill_xtnumericrole,\n       'price' AS price_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       CASE WHEN namedescrip = <? value("notassigned") ?> THEN 'error' END AS qtforegroundrole\nFROM (\n\nSELECT cmhead_id, -1 AS altid,\n       cmhead_number AS ordernumber,\n       cust_number AS custitemnumber,\n       cmhead_billtoname AS namedescrip,\n       CAST(NULL AS TEXT) AS uom_name,\n       CAST(NULL AS NUMERIC) AS qtytobill,\n       CAST(NULL AS NUMERIC) AS price,\n       CAST(NULL AS NUMERIC) AS extprice,\n       cmhead_curr_id AS curr_id,\n       0 AS cmitem_linenumber, 0 AS xtindentrole, 0 AS seq\nFROM cmhead JOIN custinfo ON (cmhead_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold))\n\nUNION\nSELECT cmhead_id, cmitem_id,\n       NULL, item_number,\n       item_descrip1,\n       uom_name, cmitem_qtycredit * cmitem_qty_invuomratio,\n       cmitem_unitprice / cmitem_price_invuomratio,\n       cmitem_qtycredit * cmitem_qty_invuomratio * cmitem_unitprice / cmitem_price_invuomratio,\n       cmhead_curr_id AS curr_id,\n       cmitem_linenumber, 1 AS xtindentrole, 1 AS seq\nFROM cmhead, cmitem, itemsite, item, uom\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold)\n  AND  (cmhead_id=cmitem_cmhead_id)\n  AND  (cmitem_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_inv_uom_id=uom_id))\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       COALESCE((SELECT formatGLAccountLong(accnt_id)\n                 FROM accnt, salesaccnt\n                 WHERE ((salesaccnt_sales_accnt_id=accnt_id)\n                    AND (salesaccnt_id=findSalesAccnt(itemsite_id,\n                               cmhead_cust_id)))), <? value("notassigned") ?>),\n       NULL, NULL, NULL,\n       cmitem_qtycredit * cmitem_qty_invuomratio * cmitem_unitprice / cmitem_price_invuomratio,\n       cmhead_curr_id AS curr_id,\n       cmitem_linenumber, 2 AS xtindentrole, 2 AS seq\nFROM cmhead, cmitem, itemsite, item, uom\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold)\n  AND  (cmhead_id=cmitem_cmhead_id)\n  AND  (cmitem_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_inv_uom_id=uom_id))\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       CASE WHEN (accnt_id IS NULL) THEN <? value("notassigned") ?>\n            ELSE formatGLAccountLong(accnt_id)\n       END,\n       NULL, NULL, cmhead_freight,\n       cmhead_freight,\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 3 AS seq\nFROM cmhead LEFT OUTER JOIN accnt ON (accnt_id=findFreightAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold)\n  AND  (cmhead_freight <> 0))\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       formatGLAccountLong(cmhead_misc_accnt_id),\n       NULL, NULL, cmhead_misc,\n       cmhead_misc,\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 4 AS seq\nFROM cmhead LEFT OUTER JOIN accnt ON (accnt_id=findFreightAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold)\n  AND  (cmhead_misc <> 0))\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       CASE WHEN (tax_sales_accnt_id IS NULL) THEN <? value("taxes") ?>\n            ELSE formatGLAccountLong(tax_sales_accnt_id)\n       END,\n       NULL, NULL, SUM(taxhist_tax * -1.0),\n       SUM(taxhist_tax * -1.0),\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 5 AS seq\nFROM cmhead JOIN cmheadtax ON ((taxhist_parent_id=cmhead_id) AND (taxhist_tax <> 0.0))\n            JOIN tax ON (tax_id=taxhist_tax_id)\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold))\nGROUP BY cmhead_id, tax_sales_accnt_id, cmhead_curr_id\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("debit") ?>,\n       CASE WHEN (tax_sales_accnt_id IS NULL) THEN <? value("taxes") ?>\n            ELSE formatGLAccountLong(tax_sales_accnt_id)\n       END,\n       NULL, NULL, SUM(taxhist_tax * -1.0),\n       SUM(taxhist_tax * -1.0),\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 5 AS seq\nFROM cmhead JOIN cmitem ON (cmitem_cmhead_id=cmhead_id)\n            JOIN cmitemtax ON ((taxhist_parent_id=cmitem_id) AND (taxhist_tax <> 0.0))\n            JOIN tax ON (tax_id=taxhist_tax_id)\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold))\nGROUP BY cmhead_id, tax_sales_accnt_id, cmhead_curr_id\n\nUNION\nSELECT cmhead_id, -1,\n       NULL, <? value("credit") ?>,\n       CASE WHEN (accnt_id IS NULL) THEN <? value("notassigned") ?>\n            ELSE formatGLAccountLong(accnt_id)\n       END,\n       NULL, NULL, NULL,\n       SUM((cmitem_qtycredit * cmitem_qty_invuomratio) *\n           (cmitem_unitprice / cmitem_price_invuomratio)) +\n           cmhead_freight + cmhead_misc +\n           (SELECT COALESCE(SUM(taxhist_tax * -1.0), 0.0) FROM cmheadtax WHERE (taxhist_parent_id=cmhead_id)) +\n           (SELECT COALESCE(SUM(taxhist_tax * -1.0), 0.0) FROM cmitem JOIN cmitemtax ON (taxhist_parent_id=cmitem_id)\n                                    WHERE (cmitem_cmhead_id=cmhead_id))\n            AS extprice,\n       cmhead_curr_id AS curr_id,\n       99999, 1 AS xtindentrole, 6 AS seq\nFROM cmhead LEFT OUTER JOIN cmitem ON (cmhead_id=cmitem_cmhead_id)\n            LEFT OUTER JOIN accnt ON (accnt_id=findARAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n  AND  (NOT cmhead_hold))\nGROUP BY cmhead_id, cmhead_cust_id, cmhead_freight, cmhead_misc, accnt_id, cmhead_curr_id\n\n) AS dummy\nORDER BY docnumber, cmitem_linenumber, seq;\n   admin   2011-11-23      0
85 49      creditMemoCreditCards   detail  used by arWorkBench, returnAuthorization, returnAuthorizationWorkbench Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: creditMemoCreditCards\n-- Name: detail\n-- Notes: used by arWorkBench, returnAuthorization, returnAuthorizationWorkbench\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cmhead_number, cmhead_freight, cmhead_curr_id,\n       SUM(ROUND((cmitem_qtycredit * cmitem_qty_invuomratio) * \n                 (cmitem_unitprice / cmitem_price_invuomratio), 2)) +\n       cmhead_freight + cmhead_misc +\n       COALESCE( (SELECT SUM(tax) * -1 AS tax FROM\n                 (SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n                  FROM tax\n                   JOIN calculateTaxDetailSummary('CM', <? value("cmhead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n                  GROUP BY tax_id) AS data), 0) AS total,\n       COALESCE( (SELECT SUM(tax) * -1 AS tax FROM\n                 (SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n                  FROM tax\n                   JOIN calculateTaxDetailSummary('CM', <? value("cmhead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n                  GROUP BY tax_id) AS data), 0) AS tax_in_cmcurr,\n       ccard_id, ccard_seq, ccpay_id,\n       cohead_number\nFROM ccard, cmitem, cmhead LEFT OUTER JOIN\n     rahead ON (cmhead_rahead_id=rahead_id) LEFT OUTER JOIN\n     cohead ON (rahead_orig_cohead_id=cohead_id) LEFT OUTER JOIN\n     ccpay  ON (ccpay_order_number=cohead_number AND ccpay_type='C')\nWHERE ((cmitem_cmhead_id=cmhead_id)\n  AND  (cmhead_cust_id=ccard_cust_id)\n  AND  (ccard_active)\n  AND  (ccpay_ccard_id=ccard_id OR ccpay_ccard_id IS NULL)\n  AND  (cmhead_id=<? value("cmhead_id") ?>))\nGROUP BY cmhead_number, cmhead_curr_id, cmhead_freight,\n         cmhead_misc, ccard_id, ccard_seq, ccpay_id,\n\t cohead_number\nORDER BY ccpay_id DESC, ccard_seq \nLIMIT 1;\n     admin   2011-11-23      0
86 114     crm     strictcountrycheck      select details about countries used throughout the database that do not match country.country_name  Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: crm\n-- Name:  strictcountrycheck\n-- Notes: select details about countries used throughout the database\n--        that do not match country.country_name\n--\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("count") ?>\nSELECT SUM(counter) AS counter FROM (\n<? endif ?>\n  SELECT <? if exists("count") ?> COUNT(*) AS counter\n         <? else ?> addr_id, 'Address' AS type, addr_number AS number, addr_country AS country, '' AS detail\n         <? endif ?>\n    FROM addr\n   WHERE addr_country != ''\n     AND addr_country NOT IN (SELECT country_name\n                                FROM country\n                               WHERE country_name IS NOT NULL)\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM cmhead\n   WHERE cmhead_billtocountry != ''\n     AND cmhead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT cmhead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Ship-To'\n         <? endif ?>\n    FROM cmhead\n    WHERE cmhead_shipto_country != ''\n      AND cmhead_shipto_country NOT IN (SELECT country_name\n                                          FROM country\n                                         WHERE country_name IS NOT NULL)\n      <? if not exists("showAll") ?> AND (NOT cmhead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> invchead_id, 'Invoice', invchead_invcnumber, invchead_billto_country, 'Bill-To'\n         <? endif ?>\n    FROM invchead\n   WHERE invchead_billto_country != ''\n     AND invchead_billto_country NOT IN (SELECT country_name\n                                           FROM country\n                                          WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT invchead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> invchead_id, 'Invoice', invchead_invcnumber, invchead_shipto_country, 'Ship-To'\n         <? endif ?>\n    FROM invchead\n   WHERE invchead_shipto_country != ''\n     AND invchead_shipto_country NOT IN (SELECT country_name\n                                           FROM country\n                                          WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (NOT invchead_posted) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> quhead_id, 'Quote', quhead_number, quhead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM quhead\n   WHERE quhead_billtocountry != ''\n     AND quhead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (quhead_expire>=CURRENT_DATE) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> quhead_id, 'Quote', quhead_number, quhead_shiptocountry, 'Ship-To'\n         <? endif ?>\n    FROM quhead\n   WHERE quhead_shiptocountry != ''\n     AND quhead_shiptocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n     <? if not exists("showAll") ?> AND (quhead_expire>=CURRENT_DATE) <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cohead_id, 'Sales Order', cohead_number, cohead_billtocountry, 'Bill-To'\n         <? endif ?>\n    FROM cohead\n   WHERE cohead_billtocountry != ''\n     AND cohead_billtocountry NOT IN (SELECT country_name\n                                        FROM country\n                                       WHERE country_name IS NOT NULL)\n    <? if not exists("showAll") ?>\n     AND cohead_id IN (SELECT coitem_cohead_id\n                         FROM coitem\n                        WHERE COALESCE(coitem_status, 'O')='O')\n    <? endif ?>\n  UNION ALL\n  SELECT <? if exists("count") ?> COUNT(*)\n         <? else ?> cohead_id, 'Sales Order', cohead_number, cohead_shiptocountry, 'Ship-To'\n         <? endif ?>\n    FROM cohead\n   WHERE cohead_shiptocountry != ''\n     AND cohead_shiptocountry NOT IN (SELECT country_name\n                                       FROM country\n                                      WHERE country_name IS NOT NULL)\n    <? if not exists("showAll") ?>\n     AND cohead_id IN (SELECT coitem_cohead_id\n                         FROM coitem\n                        WHERE COALESCE(coitem_status, 'O')='O')\n    <? endif ?>\n\n<? if exists("count") ?>\n) AS dummy;\n<? endif ?>\n    admin   2011-11-23      0
87 280     reorderExceptionsByPlannerCode  detail  used by dspReorderExceptionsByPlannerCode Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: reorderExceptionsByPlannerCode\n-- Name: detail\n-- Notes: used by dspReorderExceptionsByPlannerCode\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemtype, warehous_code, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       reorderdate, reorderlevel,\n       (itemsite_qtyonhand - qtyAllocated(itemsite_id, reorderdate) +\n         qtyOrdered(itemsite_id, reorderdate)) AS projavail,\n       'qty' AS reorderlevel_xtnumericrole,\n       'qty' AS projavail_xtnumericrole\nFROM (SELECT itemsite_id,\n             CASE WHEN (item_type IN ('M', 'B', 'T')) THEN 1\n                  WHEN (item_type IN ('P', 'O')) THEN 2\n               ELSE 3\n             END AS itemtype,\n             warehous_code, item_number, item_descrip1,\n             item_descrip2,\n             reorderDate(itemsite_id,\n                         <? value("lookAheadDays") ?>,\n                         <? value("includePlannedOrders") ?>)\n             AS reorderdate,\n             itemsite_qtyonhand, reorderlevel\n      FROM (SELECT itemsite_id, itemsite_item_id,\n                   itemsite_warehous_id, itemsite_qtyonhand,\n                   CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n                     ELSE 0.0\n                   END AS reorderlevel\n            FROM itemsite\n            WHERE ((true)\n            <? if exists("warehous_id") ?>\n               AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n            <? endif ?>\n            <? if exists("plancode_id") ?>\n               AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n            <? elseif exists("plancode_pattern") ?>\n               AND (itemsite_plancode_id IN (SELECT plancode_id\n                                             FROM plancode\n                                             WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n            <? endif ?>\n                  )\n           ) AS itemsitedata, item, warehous\n      WHERE ((itemsite_item_id=item_id)\n         AND (itemsite_warehous_id=warehous_id))\n     ) AS data\nWHERE (reorderdate IS NOT NULL)\nORDER BY reorderdate, item_number;\n     admin   2011-11-23      0
88 239     crmaccounts     detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: crmaccounts\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (crmacct_number)\n  crmacct_id AS id, crmacct_number, crmacct_name, crmacct_owner_username,\n  cntct.*, addr.*,\n  (crmacct_cust_id       IS NOT NULL) AS cust,\n  (crmacct_prospect_id   IS NOT NULL) AS prospect,\n  (crmacct_vend_id       IS NOT NULL) AS vend,\n  (crmacct_competitor_id IS NOT NULL) AS competitor,\n  (crmacct_partner_id    IS NOT NULL) AS partner,\n  (crmacct_taxauth_id    IS NOT NULL) AS taxauth,\n  (crmacct_usr_username  IS NOT NULL) AS usr,\n  (crmacct_emp_id        IS NOT NULL) AS emp,\n  (crmacct_salesrep_id   IS NOT NULL) AS salesrep\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM crmacct() LEFT OUTER JOIN\n  cntct ON (crmacct_cntct_id_1=cntct_id) LEFT OUTER JOIN\n  addr ON (cntct_addr_id=addr_id) \n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='CRMACCT') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=crmacct_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='CRMACCT') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=crmacct_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='CRMACCT') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=crmacct_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if exists("owner_username") ?> \n  AND (crmacct_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (crmacct_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if not exists("showInactive") ?> \n  AND crmacct_active \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((crmacct_number ~* <? value("search_pattern") ?>)\n       OR (crmacct_name ~* <? value("search_pattern") ?>)\n       OR (cntct_first_name || ' ' || cntct_last_name ~* <? value("search_pattern") ?>)\n       OR (cntct_phone || ' ' || cntct_phone2 || ' ' || cntct_fax ~* <? value("search_pattern") ?>)\n       OR (cntct_email ~* <? value("search_pattern") ?>)\n       OR (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("search_pattern") ?>)\n       OR (addr_city ~* <? value("search_pattern") ?>)\n       OR (addr_state ~* <? value("search_pattern") ?>)\n       OR (addr_postalcode ~* <? value("search_pattern") ?>)\n       OR (addr_country ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("crmacct_number_pattern") ?>\n  AND (crmacct_number ~* <? value("crmacct_number_pattern") ?>)\n<? endif ?>\n<? if exists("crmacct_name_pattern") ?>\n  AND (crmacct_name ~* <? value("crmacct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (cntct_first_name || ' ' || cntct_last_name ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (cntct_phone || ' ' || cntct_phone2 || ' ' || cntct_fax ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (cntct_email ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (addr_city ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (addr_state ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (addr_postalcode ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (addr_country ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? if exists("id") ?>\n  AND (crmacct_id=<? value("id") ?>)\n<? endif ?>\n<? literal("charClause") ?>\n\n<? if exists("excludeMergeWIP") ?>\n  AND (crmacct_id NOT IN (SELECT mrgundo_base_id\n                            FROM mrgundo\n                           WHERE (mrgundo_base_schema='public')\n                             AND (mrgundo_base_table='crmacct')\n                          UNION\n                          SELECT crmacctsel_src_crmacct_id\n                            FROM crmacctsel\n                          UNION\n                          SELECT crmacctsel_dest_crmacct_id\n                            FROM crmacctsel))\n<? endif ?>\nORDER BY crmacct_number; \n      admin   2011-11-23      0
89 95      currencyConversions     detail  used by currencyConversions the N in round(curr_rate, N) has to be SCALE - 1 of curr_rates NUMERIC(p, SCALE) type definition Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: currencyConversions\n-- Name: detail\n-- Notes: used by currencyConversions\n--        the N in round(curr_rate, N) has to be SCALE - 1 of curr_rates\n--        NUMERIC(p, SCALE) type definition\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT curr_rate_id, currConcat(curr_id) AS f_curr,\n<? if exists("invert") ?>\n       round((1.0 / curr_rate),5) AS rate,\n<? else ?>\n       round(curr_rate,5) AS rate,\n<? endif ?>\n       'uomratio' AS rate_xtnumericrole,\n       curr_effective, curr_expires\nFROM curr_symbol NATURAL JOIN curr_rate\nWHERE ( (curr_base = FALSE)\n  AND   (curr_expires >= <? value("startDate") ?>)\n  AND   (curr_effective <= <? value("endDate") ?>)\n<? if exists("curr_id") ?>\n  AND   (curr_id = <? value("curr_id") ?>)\n<? endif ?>\n<? if exists("currConcat_pattern") ?>\n  AND   (currConcat(curr_id) ~ <? value("currConcat_pattern") ?>)\n<? endif ?>\n      )\nORDER BY f_curr, curr_effective, curr_expires;\n    admin   2011-11-23      0
90 240     customer        detail  used by dspCustomersByCharacteristic, dspCustomersByCustomerType Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: customer\n-- Name: detail\n-- Notes: used by dspCustomersByCharacteristic, dspCustomersByCustomerType\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("hasCharacteristic") ?>\n  SELECT cust_id, charass_id, cust_active,\n         cust_number, cust_name, char_name, charass_value\n  FROM cust, charass, char\n  WHERE ((charass_target_type='C')\n     AND (charass_target_id=cust_id)\n     AND (charass_char_id=char_id)\n     AND (char_id=<? value("char_id") ?>)\n   <? if exists("emptyValue") ?>\n     AND (charass_value IS NULL OR LENGTH(TRIM(charass_value)) = 0)\n   <? else ?>\n     AND (charass_value ~* <? value("value") ?>)\n   <? endif ?>\n<? elseif exists("byCustType") ?>\n  SELECT cust_id, cust_custtype_id,custtype_code,\n         cust_active, cust_number, cust_name, cust_address1\n  FROM cust, custtype\n  WHERE ((cust_custtype_id=custtype_id)\n   <? if exists("custtype_id") ?>\n     AND (custtype_id=<? value("custtype_id") ?>)\n   <? elseif exists("custtype_pattern") ?>\n     AND (custtype_code ~ <? value("custtype_pattern") ?>)\n   <? endif ?>\n<? else ?>\n  SELECT cust_id, -1, cust_active,\n         cust_number, cust_name, char_name, '' AS charass_value\n  FROM cust, char\n  WHERE ((cust_id NOT IN (SELECT charass_target_id\n                          FROM charass\n                          WHERE ((charass_target_type='C')\n                             AND (charass_char_id=char_id))\n                         )\n         )\n     AND (char_id=<? value("char_id") ?>)\n<? endif ?>\n\n<? if not exists("showInactive") ?>\n    AND (cust_active)\n<? endif ?>\n        )\nORDER BY cust_number;\n   admin   2011-11-23      0
91 242     customers       detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: customers\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON ( cust_number ) \n  cust_id, cust_custtype_id, \n  cust_active, cust_number, cust_name,\n  custtype_code,\n  bill_cntct.cntct_first_name AS bill_first_name,\n  bill_cntct.cntct_last_name AS bill_last_name,\n  bill_cntct.cntct_phone AS bill_phone,\n  bill_cntct.cntct_fax AS bill_fax,\n  bill_cntct.cntct_email AS bill_email,\n  bill_addr.addr_line1 AS bill_line1,\n  bill_addr.addr_line2 AS bill_line2,\n  bill_addr.addr_line3 AS bill_line3,\n  bill_addr.addr_city AS bill_city,\n  bill_addr.addr_state AS bill_state,\n  bill_addr.addr_postalcode AS bill_postalcode,\n  bill_addr.addr_country AS bill_country,\n  corr_cntct.cntct_first_name AS corr_first_name,\n  corr_cntct.cntct_last_name AS corr_last_name,\n  corr_cntct.cntct_phone AS corr_phone,\n  corr_cntct.cntct_fax AS corr_fax,\n  corr_cntct.cntct_email AS corr_email,\n  corr_addr.addr_line1 AS corr_line1,\n  corr_addr.addr_line2 AS corr_line2,\n  corr_addr.addr_line3 AS corr_line3,\n  corr_addr.addr_city AS corr_city,\n  corr_addr.addr_state AS corr_state,\n  corr_addr.addr_postalcode AS corr_postalcode,\n  corr_addr.addr_country AS corr_country\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM custinfo\n  JOIN custtype ON (cust_custtype_id=custtype_id)\n  LEFT OUTER JOIN cntct bill_cntct ON (cust_cntct_id=bill_cntct.cntct_id) \n  LEFT OUTER JOIN addr bill_addr ON (bill_cntct.cntct_addr_id=bill_addr.addr_id)\n  LEFT OUTER JOIN cntct corr_cntct ON (cust_corrcntct_id=corr_cntct.cntct_id) \n  LEFT OUTER JOIN addr corr_addr ON (corr_cntct.cntct_addr_id=corr_addr.addr_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='C') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cust_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if not exists("showInactive") ?> \n  AND cust_active \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((cust_number ~* <? value("search_pattern") ?>)\n       OR (cust_name ~* <? value("search_pattern") ?>)\n       OR (custtype_code ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_first_name || ' ' || bill_cntct.cntct_last_name,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_phone || ' ' || bill_cntct.cntct_phone2 || ' ' || bill_cntct.cntct_fax, '') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_cntct.cntct_email, '') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_line1 || ' ' || bill_addr.addr_line2 || ' ' || bill_addr.addr_line3,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_city,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_state,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_postalcode,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(bill_addr.addr_country,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_first_name || ' ' || corr_cntct.cntct_last_name,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_phone || ' ' || corr_cntct.cntct_phone2 || ' ' || corr_cntct.cntct_fax, '') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_cntct.cntct_email, '') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_line1 || ' ' || corr_addr.addr_line2 || ' ' || corr_addr.addr_line3,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_city,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_state,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_postalcode,'') ~* <? value("search_pattern") ?>)\n       OR (COALESCE(corr_addr.addr_country,'') ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("cust_number_pattern") ?>\n  AND (cust_number ~* <? value("cust_number_pattern") ?>)\n<? endif ?>\n<? if exists("cust_name_pattern") ?>\n  AND (cust_name ~* <? value("cust_name_pattern") ?>)\n<? endif ?>\n<? if exists("custtype_code_pattern") ?>\n  AND (custtype_code ~* <? value("custtype_code_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_first_name || ' ' || bill_cntct.cntct_last_name, '') ~* <? value("cntct_name_pattern") ?> \n   OR  COALESCE(corr_cntct.cntct_first_name || ' ' || corr_cntct.cntct_last_name, '') ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_phone || ' ' || bill_cntct.cntct_phone2 || ' ' || bill_cntct.cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>\n   OR  COALESCE(corr_cntct.cntct_phone || ' ' || corr_cntct.cntct_phone2 || ' ' || corr_cntct.cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (COALESCE(bill_cntct.cntct_email,'') ~* <? value("cntct_email_pattern") ?>\n   OR  COALESCE(corr_cntct.cntct_email,'') ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (COALESCE(bill_addr.addr_line1 || ' ' || bill_addr.addr_line2 || ' ' || bill_addr.addr_line3,'') ~* <? value("addr_street_pattern") ?>\n   OR  COALESCE(corr_addr.addr_line1 || ' ' || corr_addr.addr_line2 || ' ' || corr_addr.addr_line3,'') ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (COALESCE(bill_addr.addr_city,'') ~* <? value("addr_city_pattern") ?>\n   OR  COALESCE(corr_addr.addr_city,'') ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (COALESCE(bill_addr.addr_state,'') ~* <? value("addr_state_pattern") ?>\n   OR  COALESCE(corr_addr.addr_state,'') ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (COALESCE(bill_addr.addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>\n   OR  COALESCE(corr_addr.addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (COALESCE(bill_addr.addr_country,'') ~* <? value("addr_country_pattern") ?>\n   OR  COALESCE(corr_addr.addr_country,'') ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? literal("charClause") ?>\nORDER BY cust_number; \n admin   2011-11-23      0
92 412     journals        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: journals\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT sltrans.*,\n       CASE WHEN(sltrans_docnumber='Misc.' AND\n              invhist_docnumber IS NOT NULL) THEN\n              (sltrans_docnumber || ' - ' || invhist_docnumber)\n            ELSE sltrans_docnumber\n       END AS docnumber,\n       firstLine(sltrans_notes) AS notes,\n       sltrans_journalnumber,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (sltrans_amount < 0) THEN ABS(sltrans_amount)\n            ELSE NULL\n       END AS debit,\n       CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n            ELSE NULL\n       END AS credit,\n       sltrans_gltrans_journalnumber,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole\nFROM sltrans JOIN accnt ON (sltrans_accnt_id=accnt_id) \n     LEFT OUTER JOIN invhist ON (sltrans_misc_id=invhist_id\n                            AND sltrans_docnumber='Misc.') \n<? if exists("company_id") ?>\n     JOIN company ON (accnt_company=company_number) \n<? endif ?>\n<? if exists("prfcntr_id") ?>\n     JOIN prftcntr ON (accnt_profit=prftcntr_number) \n<? endif ?>\n<? if exists("subaccnt_id") ?>\n     JOIN subaccnt ON (accnt_sub=subaccnt_number) \n<? endif ?>\n<? if exists("subType") ?>\n     JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n<? endif ?>\nWHERE (\n<? if exists("startDate") ?>\n  <? if exists("endDate") ?>\n       (sltrans_date BETWEEN <? value("startDate") ?>\n                         AND <? value("endDate") ?>)\n  <? else ?>\n       (sltrans_date BETWEEN <? value("startDate") ?>\n                         AND endoftime())\n  <? endif ?>\n<? else ?>\n  <? if exists("endDate") ?>\n       (sltrans_date BETWEEN startoftime()\n                         AND <? value("endDate") ?>)\n  <? else ?>\n       (sltrans_date BETWEEN startoftime()\n                         AND endoftime())\n  <? endif ?>\n<? endif ?>\n<? if exists("company_id") ?>\n   AND (company_id=<? value("company_id") ?>)\n<? endif ?>\n<? if exists("prfcntr_id") ?>\n   AND (prftcntr_id=<? value("prfcntr_id") ?>)\n<? endif ?>\n<? if exists("accnt_number") ?>\n   AND (accnt_number=<? value("accnt_number") ?>)\n<? endif ?>\n<? if exists("subaccnt_id") ?>\n   AND (subaccnt_id=<? value("subaccnt_id") ?>)\n<? endif ?>\n<? if exists("subType") ?>\n   AND (subaccnttype_id=<? value("subType") ?>)\n<? endif ?>\n<? if exists("accntType") ?>\n   AND (accnt_type= <? value("accntType") ?>)\n<? endif ?>\n<? if exists("accnt_id") ?>\n   AND (sltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("docnum") ?>\n   AND (sltrans_docnumber = case when <? value("docnum") ?> = '' then \n sltrans_docnumber else \n<? value("docnum") ?> end ) \n<? endif ?>\n<? if exists("source") ?>\n   AND (sltrans_source=<? value("source") ?>)\n<? endif ?>\n<? if exists("source_pattern") ?>\n   AND (sltrans_source ~* <? value("source_pattern") ?>)\n<? endif ?>\n<? if exists("posted") ?>\n   AND (sltrans_posted=<? value("posted") ?>)\n<? endif ?>\n<? if exists("journalnumber") ?>\n   AND (sltrans_gltrans_journalnumber::text=<? value("journalnumber") ?>)\n<? endif ?>\n) \nORDER BY sltrans_created,\n   sltrans_sequence, sltrans_amount;\n admin   2011-11-23      0
93 439     customers       statement       used by printStatementsByCustomerType SELECT cust_id, (cust_number || '-' || cust_name) AS customer, findCustomerForm(cust_id, 'S') AS reportname FROM <? if exists("asofDate") ?> (SELECT araging_cust_id FROM araging(<? value ("asofDate") ?>, true))AS data, <? endif ?> custinfo, custtype, aropen WHERE (cust_custtype_id=custtype_id) AND (aropen_cust_id=cust_id) AND (aropen_open) <? if exists("graceDays") ?> AND (aropen_duedate < (CURRENT_DATE - <? value ("graceDays") ?>)) <? endif ?> <? if exists("custtype_id") ?> AND (custtype_id=<? value ("custtype_id") ?>) <? elseif exists("custtype_pattern") ?> AND (custtype_code ~ <? value ("custtype_pattern") ?>) <? endif ?> <? if exists("asofDate") ?> AND (cust_id = araging_cust_id) <? endif ?> GROUP BY cust_id, cust_number, cust_name HAVING (SUM((aropen_amount - aropen_paid) * CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) > 0) ORDER BY cust_number; Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: customers\n-- Name:  statement\n-- Notes: used by printStatementsByCustomerType\n--SELECT cust_id, (cust_number || '-' || cust_name) AS customer,\n--       findCustomerForm(cust_id, 'S') AS reportname\n--FROM\n--<? if exists("asofDate") ?>\n--  (SELECT araging_cust_id FROM araging(<? value ("asofDate") ?>, true))AS data,\n--<? endif ?>\n--  custinfo, custtype, aropen\n--WHERE (cust_custtype_id=custtype_id)\n-- AND (aropen_cust_id=cust_id)\n-- AND (aropen_open)\n--<? if exists("graceDays") ?>\n-- AND (aropen_duedate < (CURRENT_DATE - <? value ("graceDays") ?>))\n--<? endif ?>\n--<? if exists("custtype_id") ?>\n-- AND (custtype_id=<? value ("custtype_id") ?>)\n--<? elseif exists("custtype_pattern") ?>\n-- AND (custtype_code ~ <? value ("custtype_pattern") ?>)\n--<? endif ?>\n--<? if exists("asofDate") ?>\n-- AND (cust_id = araging_cust_id)\n--<? endif ?>\n--GROUP BY cust_id, cust_number, cust_name\n--HAVING (SUM((aropen_amount - aropen_paid) *\n--             CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1\n--                  ELSE 1 END) > 0)\n--ORDER BY cust_number;\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT araging_cust_id AS cust_id,\n       (araging_cust_number || '-' || araging_cust_name) AS customer,\n       findCustomerForm(araging_cust_id, 'S') AS reportname\nFROM araging(<? value ("asofDate") ?>, true)\nWHERE (true)\n<? if exists("graceDays") ?>\n AND (COALESCE(araging_duedate, startOfTime()) < (CURRENT_DATE - <? value ("graceDays") ?>))\n<? endif ?>\n<? if exists("custtype_id") ?>\n AND (araging_cust_custtype_id=<? value ("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (araging_custtype_code ~ <? value ("custtype_pattern") ?>)\n<? endif ?>\nGROUP BY araging_cust_id, araging_cust_number, araging_cust_name\nORDER BY araging_cust_number;\n    admin   2011-11-23      0
94 265     opensalesorders detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: opensalesorders\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT cohead.*,\n                      COALESCE(cust_number, :error) AS cust_number,\n                      getSoSchedDate(cohead_id) AS scheddate, \n                      getSoStatus(cohead_id) AS status,\n                      firstline(cohead_ordercomments) AS notes \n                 FROM cohead \n                   JOIN custinfo ON (cohead_cust_id=cust_id) \n                   JOIN custtype ON (cust_custtype_id=custtype_id)\n               <? if exists("selectedSites") ?> \n                   JOIN coitem ON (coitem_cohead_id=cohead_id) \n                   JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n                   JOIN site() ON (itemsite_warehous_id=warehous_id) \n               <? else ?> \n                   LEFT OUTER JOIN coitem ON (coitem_cohead_id=cohead_id) \n                   LEFT OUTER JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n                   LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id) \n                <? endif ?> \n                WHERE((true) \n               <? if exists("cust_id") ?>\n                 AND (cust_id=<? value("cust_id") ?> )\n               <? endif ?>\n               <? if exists("custtype_id") ?>\n                 AND (cust_custtype_id=<? value("custtype_id") ?>)\n              <? endif ?>\n              <? if exists("custtype_pattern") ?>\n                 AND (custtype_code ~* <? value("custtype_pattern") ?>)\n              <? endif ?>\n              <? if exists("poNumber") ?>\n                 AND  (cohead_custponumber~*<? value("poNumber") ?>)\n               <? endif ?>\n               <? if not exists("showClosed") ?> \n                 AND ((coitem_status = 'O') OR (coitem_status IS NULL)) \n               <? endif ?>\n               <? if  exists("warehous_id") ?>\n                 AND (warehous_id=<? value("warehous_id") ?>)\n               <? endif ?>\n               <? if  exists("salesrep_id") ?>\n                 AND (cohead_salesrep_id=<? value("salesrep_id") ?>)\n               <? endif ?>\n                ) \n               ORDER BY cohead_number;\n  admin   2011-11-23      0
95 244     detailedInventoryHistory        detail  used by dspDetailedInventoryHistoryByLocation, dspDetailedInventoryHistoryByLotSerial Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: detailedInventoryHistory\n-- Name: detail\n-- Notes: used by dspDetailedInventoryHistoryByLocation, dspDetailedInventoryHistoryByLotSerial\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("byLocation") ?>\n       invhist_id, invhist_transdate, invhist_transtype,\n       (invhist_ordtype || '-' || invhist_ordnumber) AS ordernumber,\n       invhist_invuom,\n       item_number, formatlotserialnumber(invdetail_ls_id) AS lotserial,\n       CASE WHEN invhist_posted THEN invdetail_qty\n       END AS transqty,\n       CASE WHEN invhist_posted THEN invdetail_qty_before\n       END AS qohbefore,\n       CASE WHEN invhist_posted THEN invdetail_qty_after\n       END AS qohafter,\n       invhist_posted,\n       'qty' AS transqty_xtnumericrole,\n       'qty' AS qohbefore_xtnumericrole,\n       'qty' AS qohafter_xtnumericrole,\n       CASE WHEN NOT invhist_posted THEN 'warning'\n       END AS qtforegroundrole\n<? else ?>\n       *\n<? endif ?>\nFROM <? if exists("byLocation") ?>\n       invdetail, invhist, itemsite, item\n     <? else ?>\n       lshist (<? value("itemid") ?>,<? value("warehouseid") ?>,<? value("lotSerial") ?>,\n               <? value("pattern") ?>,<? value("transType") ?>,<? value("startDate") ?>,\n               <? value("endDate") ?>,<? value("trace") ?>,1)\n     <? endif ?>\nWHERE (\n<? if exists("byLocation") ?>\n        (invdetail_invhist_id=invhist_id)\n    AND (invhist_itemsite_id=itemsite_id)\n    AND (itemsite_item_id=item_id)\n    AND (invdetail_location_id=<? value("location_id") ?>)\n    AND (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    AND (transType(invhist_transtype, <? value("transType") ?>))\n<? else ?>\n        (TRUE)\n<? endif ?>\n      )\n<? if exists("byLocation") ?>\nORDER BY invhist_transdate DESC, invhist_transtype\n<? endif ?>\n;\n    admin   2011-11-23      0
96 118     distributeInventory     locations        Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: distributeInventory\n-- Name: locations\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, type, locationname, defaultlocation,\n\t\t        location_netable, lotserial, f_expiration, expired,\n                        qty, qtytagged, (qty + qtytagged) AS balance,\n                        'qty' AS qty_xtnumericrole,\n                        'qty' AS qtytagged_xtnumericrole,\n                        'qty' AS balance_xtnumericrole,\n                        CASE WHEN expired THEN 'error' END AS qtforegroundrole, \n                        CASE WHEN expired THEN 'error' \n                             WHEN defaultlocation AND expired = false THEN 'altemphasis' \n                        ELSE null END AS defaultlocation_qtforegroundrole, \n                        CASE WHEN expired THEN 'error' \n                             WHEN qty > 0 AND expired = false THEN 'altemphasis' \n                        ELSE null END AS qty_qtforegroundrole \n                 FROM ( \n\t\t <? if exists("cNoIncludeLotSerial") ?>\n\t\t SELECT location_id AS id, <? value("locationType") ?> AS type,\n\t\t        formatLocationName(location_id) AS locationname,\n\t\t        (location_id=itemsite_location_id) AS defaultlocation,\n\t\t        location_netable,\n\t\t        TEXT('') AS lotserial,\n\t\t        TEXT(<? value("na") ?>) AS f_expiration, FALSE AS expired,\n\t\t        qtyLocation(location_id, NULL, NULL, NULL, itemsite_id, itemlocdist_order_type, itemlocdist_order_id, itemlocdist_id) AS qty,\n\t\t        itemlocdistQty(location_id, itemlocdist_id) AS qtytagged \n\t\t FROM itemlocdist, location, itemsite \n\t\t WHERE ( (itemlocdist_itemsite_id=itemsite_id)\n\t\t  AND (itemsite_loccntrl)\n\t\t  AND (itemsite_warehous_id=location_warehous_id)\n\t\t  AND (validLocation(location_id, itemsite_id))\n\t\t  AND (itemlocdist_id=<? value("itemlocdist_id") ?>) ) \n\t\t <? elseif exists("cIncludeLotSerial") ?>\n\t\t SELECT itemloc_id AS id, <? value("itemlocType") ?> AS type,\n\t\t        COALESCE(formatLocationName(location_id),\n\t\t                 <? value("undefined") ?>) AS locationname,\n\t\t        (location_id IS NOT NULL\n\t\t         AND location_id=itemsite_location_id) AS defaultlocation,\n\t\t        COALESCE(location_netable, false) AS location_netable,\n\t\t        ls_number AS lotserial,\n\t\t        CASE WHEN (itemsite_perishable) THEN formatDate(itemloc_expiration)\n\t\t             ELSE <? value("na") ?>\n\t\t        END AS f_expiration,\n\t\t        CASE WHEN (itemsite_perishable) THEN (itemloc_expiration < CURRENT_DATE)\n\t\t             ELSE FALSE \n\t\t        END AS expired,\n\t\t        qtyLocation(itemloc_location_id, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc, itemsite_id, itemlocdist_order_type, itemlocdist_order_id, itemlocdist_id) AS qty,\n\t\t        ( SELECT COALESCE(SUM(target.itemlocdist_qty), 0)\n\t\t          FROM itemlocdist AS target\n\t\t          WHERE ( (target.itemlocdist_source_type='I')\n\t\t           AND (target.itemlocdist_source_id=itemloc_id)\n\t\t           AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_id)) ) AS qtytagged \n\t\t FROM itemlocdist AS source, itemsite, itemloc \n                   LEFT OUTER JOIN location ON (itemloc_location_id=location_id) \n                   LEFT OUTER JOIN ls ON (itemloc_ls_id=ls_id) \n\t\t WHERE ( (source.itemlocdist_itemsite_id=itemsite_id)\n\t\t  AND (itemloc_itemsite_id=itemsite_id)\n\t\t  AND (source.itemlocdist_id=<? value("itemlocdist_id") ?>) ) \n\t\t  UNION \n\t\t SELECT location_id AS id, <? value("locationType") ?> AS type,\n\t\t        formatLocationName(location_id) AS locationname,\n\t\t        (location_id=itemsite_location_id) AS defaultlocation,\n\t\t        location_netable,\n\t\t        TEXT('') AS lotserial,\n\t\t        TEXT(<? value("na") ?>) AS f_expiration, FALSE AS expired,\n\t\t        qtyLocation(location_id, NULL, NULL, NULL, itemsite_id, itemlocdist_order_type, itemlocdist_order_id, itemlocdist_id) AS qty,\n\t\t        itemlocdistQty(location_id, itemlocdist_id) AS qtytagged \n\t\t FROM itemlocdist, location, itemsite \n\t\t WHERE ( (itemlocdist_itemsite_id=itemsite_id)\n\t\t  AND (itemsite_loccntrl)\n\t\t  AND (itemsite_warehous_id=location_warehous_id)\n\t\t  AND (validLocation(location_id, itemsite_id))\n                  AND (itemsite_id=<? value("itemsite_id") ?> ) \n\t\t  AND (location_id NOT IN (SELECT DISTINCT itemloc_location_id FROM itemloc WHERE (itemloc_itemsite_id=itemsite_id)))\n\t\t  AND (itemlocdist_id=<? value("itemlocdist_id") ?>) ) \n\t\t <? endif ?>\n\t\t ) AS data \n                 WHERE ((TRUE) \n\t\t <? if exists("showOnlyTagged") ?>\n\t\t AND (qtytagged != 0) \n\t\t <? endif ?>\n                 <? if exists("showQtyOnly") ?>\n                 AND (qty > 0) \n                 <? endif ?>\n\t\t ) ORDER BY locationname;\n       admin   2011-11-23      0
97 50      events  detail  used by eventManager Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: events\n-- Name: detail\n-- Notes: used by eventManager\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT evntlog_id, evntlog_ord_id, evntlog_newdate,\n       evntlog_newvalue, warehous_code,\n       evntlog_evnttime,\n       evntlog_dispatched,\n       evnttype_name, evntlog_number \n  FROM evnttype, evntlog LEFT OUTER JOIN warehous ON (evntlog_warehous_id=warehous_id)\nWHERE ( (evntlog_evnttype_id=evnttype_id)\n AND (evntlog_username=<? value("username") ?>)\n<? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if not exists("showAcknowledged") ?>\n AND (evntlog_dispatched IS NULL)\n<? endif ?>\n) \nORDER BY evntlog_evnttime;\n      admin   2011-11-23      0
98 245     expiredInventory        detail  used by dspExpiredInventoryByClassCode Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: expiredInventory\n-- Name: detail\n-- Notes: used by dspExpiredInventoryByClassCode\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemloc_id, warehous_code, item_number, uom_name,\n       ls_number, itemloc_expiration,\n       itemloc_qty, costmethod, cost,\n       noNeg(cost * itemloc_qty) AS value,\n       'qty' AS itemloc_qty_xtnumericrole,\n       'cost' AS cost_xtnumericrole,\n       'curr' AS value_xtnumericrole,\n       'red' AS qtforegroundrole \nFROM ( SELECT itemsite_id, itemloc_id, warehous_code, item_number,\n              uom_name, ls_number,\n              CASE WHEN <? value("expiretype") ?>='Perishability' THEN \n                   itemloc_expiration\n                ELSE itemloc_warrpurc\n              END AS itemloc_expiration,\n              itemloc_qty,\n              CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n                   WHEN(itemsite_costmethod='S') THEN 'Standard'\n                   WHEN(itemsite_costmethod='J') THEN 'Job'\n                   WHEN(itemsite_costmethod='N') THEN 'None'\n                ELSE 'UNKNOWN'\n              END AS costmethod,\n            <? if exists("useStandardCosts") ?>\n              stdcost(itemsite_item_id) AS cost\n            <? elseif exists("useActualCosts") ?>\n              actcost(itemsite_item_id) AS cost\n            <? else ?>\n              (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1 ELSE itemsite_qtyonhand END) AS cost\n            <? endif ?>\n       FROM itemloc, itemsite, item, warehous, uom, ls\n       WHERE ((itemloc_itemsite_id=itemsite_id)\n          AND (itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (itemsite_warehous_id=warehous_id)\n          AND (itemloc_ls_id=ls_id)\n        <? if exists("perishability") ?>\n          AND (itemsite_perishable)\n          AND (itemloc_expiration < (CURRENT_DATE + <? value("thresholdDays") ?>))\n        <? else ?>\n          AND (itemsite_warrpurc)\n          AND (itemloc_warrpurc < (CURRENT_DATE + <? value("thresholdDays") ?>))\n        <? endif ?>\n        <? if exists("warehous_id") ?>\n          AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n        <? endif ?>\n        <? if exists("classcode_id") ?>\n          AND (item_classcode_id=<? value("classcode_id") ?>)\n        <? elseif exists("classcode_pattern") ?>\n          AND (item_classcode_id IN (SELECT classcode_id\n                                     FROM classcode\n                                     WHERE classcode_code ~ <? value("classcode_pattern") ?>))\n        <? endif ?>\n             )\n     ) AS data\nORDER BY warehous_code, item_number;\n   admin   2011-11-23      0
99 247     frozenItemSites detail  used by dspFrozenItemSites Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: frozenItemSites\n-- Name: detail\n-- Notes: used by dspFrozenItemSites\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n        (item_descrip1 || ' ' || item_descrip2) AS descrip,\n        COALESCE((SELECT invcnt_tagnumber\n                  FROM invcnt\n                  WHERE ((NOT invcnt_posted)\n                          AND (invcnt_itemsite_id=itemsite_id)) LIMIT 1), '') AS cnttag\nFROM itemsite, item, warehous\nWHERE ( (itemsite_item_id=item_id)\n    AND (itemsite_warehous_id=warehous_id)\n    AND (itemsite_freeze)\n<? if exists("warehous_id") ?>\n    AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY warehous_code, item_number;\n   admin   2011-11-23      0
100 249     glseries        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: glseries\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, \n                          CASE WHEN <? literal("table") ?>_id = -1 THEN 0\n                          ELSE 1 END AS xtindentrole,\n                          CASE WHEN <? literal("table") ?>_id = -1 THEN <? literal("table") ?>_date\n                          END AS transdate,   \n                          'curr' AS debit_xtnumericrole,\n                          'curr' AS credit_xtnumericrole \n                   FROM (SELECT DISTINCT \n                          <? literal("table") ?>_sequence AS sequence, \n                          -1 AS <? literal("table") ?>_id, \n                          <? literal("table") ?>_date, \n                          <? literal("table") ?>_source AS source, \n                          <? literal("table") ?>_journalnumber AS journalnumber,\n                          <? literal("table") ?>_doctype AS doctype, '' AS docnumber,\n                          -1 AS accnt_id, firstLine(<? literal("table") ?>_notes) AS accnt_id_qtdisplayrole,\n                          0.0 AS amount,\n                          CAST(NULL AS NUMERIC) AS debit,\n                          CAST(NULL AS NUMERIC) AS credit,\n                          <? literal("table") ?>_posted AS posted \n                   FROM <? literal("table") ?> \n                   WHERE ( (true) \n                   <? if exists("gltrans") ?>\n                    AND (NOT gltrans_deleted) \n                   <? endif ?>\n                    AND (<? literal("table") ?>_date BETWEEN <? value("startDate") ?>\n                                            AND <? value("endDate") ?>)\n                   <? if exists("source") ?>\n                      AND (<? literal("table") ?>_source=<? value("source") ?>)\n                   <? endif ?>\n                   <? if exists("startJrnlnum") ?>\n                      AND (<? literal("table") ?>_journalnumber BETWEEN <? value("startJrnlnum") ?>\n                                                     AND <? value("endJrnlnum") ?>)\n                   <? endif ?>\n                   ) \n                   UNION ALL \n                   SELECT <? literal("table") ?>_sequence AS sequence, \n                          <? literal("table") ?>_id, \n                          <? literal("table") ?>_date, \n                          NULL, NULL,\n                          NULL, <? literal("table") ?>_docnumber AS docnumber,\n                          accnt_id, (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS accnt_id_qtdisplayrole,\n                          <? literal("table") ?>_amount,\n                          CASE WHEN (<? literal("table") ?>_amount < 0) THEN (<? literal("table") ?>_amount * -1)\n                          END AS debit,\n                          CASE WHEN (<? literal("table") ?>_amount > 0) THEN <? literal("table") ?>_amount \n                          END AS credit,\n                          NULL AS posted \n                   FROM <? literal("table") ?> JOIN accnt ON (<? literal("table") ?>_accnt_id=accnt_id) \n                   WHERE ( (true) \n                   <? if exists("gltrans") ?>\n                    AND (NOT gltrans_deleted) \n                   <? endif ?>\n                     AND (<? literal("table") ?>_date BETWEEN <? value("startDate") ?>\n                                            AND <? value("endDate") ?>)\n                   <? if exists("source") ?>\n                      AND (<? literal("table") ?>_source=<? value("source") ?>)\n                   <? endif ?>\n                   <? if exists("startJrnlnum") ?>\n                      AND (<? literal("table") ?>_journalnumber BETWEEN <? value("startJrnlnum") ?>\n                                                     AND <? value("endJrnlnum") ?>)\n                   <? endif ?>\n                    ) \n                   ) AS dummy \n                   ORDER BY sequence,\n                            xtindentrole, amount;\n      admin   2011-11-23      0
101 415     glseries        postjournal      Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: glseries\n-- Name:  postjournal\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT postJournals(<? value("sequence") ?>) AS result;\n     admin   2011-11-23      0
102 100     incidents       detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: incidents \n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (incdt_number) incdt_id AS id,\nincdt_number, DATE(incdt_timestamp) AS incdt_timestamp,\ncrmacct_name,\nincdtcat_name, incdtseverity_name,  \nincdtpriority_name, crmacct_name, \nCASE WHEN(incdt_status='N') THEN <? value("new") ?>\nWHEN(incdt_status='F') THEN <? value("feedback") ?>\nWHEN(incdt_status='C') THEN <? value("confirmed") ?>\nWHEN(incdt_status='A') THEN <? value("assigned") ?>\nWHEN(incdt_status='R') THEN <? value("resolved") ?>\nWHEN(incdt_status='L') THEN <? value("closed") ?>\nELSE incdt_status\nEND,\nincdt_assigned_username, incdt_owner_username,\nincdt_summary, cntct_name, incdt_updated::date AS incdt_updated,\nprj_number, incdt_public,\nstatus_color AS qtbackgroundrole \n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM crmacct, status, incdt()\n  JOIN cntct ON (incdt_cntct_id=cntct_id)\n  LEFT OUTER JOIN incdtcat ON (incdtcat_id=incdt_incdtcat_id) \n  LEFT OUTER JOIN incdtseverity ON (incdtseverity_id=incdt_incdtseverity_id) \n  LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) \n  LEFT OUTER JOIN prj ON (incdt_prj_id=prj_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='INCDT') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=incdt_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='INCDT') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=incdt_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='INCDT') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=incdt_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE ((incdt_crmacct_id=crmacct_id)\nAND (status_type='INCDT')\nAND (incdt_status=status_code)\n<? if exists("statuslist") ?>\nAND (status_seq IN (-1\n  <? foreach("statuslist") ?> , <? value("statuslist") ?> <? endforeach ?>\n  ))\n<? endif ?>\n<? if exists("status_equal") ?> \nAND (status_seq = <? value("status_equal") ?>) \n<? endif ?>\n<? if exists("status_above") ?> \nAND (status_seq < <? value("status_above") ?>) \n<? endif ?>\n<? if exists("cntct_id") ?> \nAND (incdt_cntct_id = <? value("cntct_id") ?>) \n<? endif ?>\n<? if exists("username") ?>\nAND (<? value("username") ?> IN (incdt_assigned_username, incdt_owner_username))\n<? endif ?>\n<? if exists("owner_username") ?> \nAND (incdt_owner_username=<? value("owner_username") ?>) \n<? endif ?>\n<? if exists("owner_usr_pattern" ?>\nAND (incdt_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if exists("assigned_username") ?> \nAND (incdt_assigned_username=<? value("assigned_username") ?>) \n<? endif ?>\n<? if exists("assigned_usr_pattern" ?>\nAND (incdt_assigned_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("incdtpriority_id_list") ?>\nAND (incdt_incdtpriority_id IN (-1\n  <? foreach("incdtpriority_id_list") ?> , <? value("incdtpriority_id_list") ?> <? endforeach ?>\n  ))\n<? endif ?>\n<? if exists("categorylist") ?>\nAND (incdt_incdtcat_id IN (-1\n  <? foreach("categorylist") ?> , <? value("categorylist") ?> <? endforeach ?>\n  ))\n<? endif ?>\n<? if exists("category_id") ?> \nAND (incdt_incdtcat_id=<? value("category_id") ?>) \n<? endif ?> \n<? if exists("severity_id") ?> \nAND (incdt_incdtseverity_id=<? value("severity_id") ?>) \n<? endif ?>\n<? if exists("crmAccountId") ?> \nAND (incdt_crmacct_id=<? value("crmAccountId") ?>) \n<? endif ?> \n<? if exists("prj_id") ?> \nAND (incdt_prj_id=<? value("prj_id") ?>) \n<? endif ?> \n<? if exists("public") ?> \nAND (incdt_public=<? value("public") ?>) \n<? endif ?> \n)\n \n<? if exists("search_pattern") ?> \nAND ((incdt_number::text ~* <? value("search_pattern") ?>)\nOR (incdt_summary ~* <? value("search_pattern") ?>)\nOR (incdt_descrip ~* <? value("search_pattern") ?>)\nOR (incdt_id IN (SELECT comment_source_id\nFROM comment\nWHERE((comment_source='INCDT')\nAND (comment_text ~* <? value("search_pattern") ?>)))))\n<? endif ?>\n<? if exists("id") ?>\nAND (incdt_id=<? value("id") ?>)\n<? endif ?>\nAND (incdt_timestamp BETWEEN COALESCE(<? value("startDate") ?>, startOfTime()) AND COALESCE(<? value("endDate") ?>, endOfTime())+1) \n<? literal("charClause") ?>\nORDER BY incdt_number;\n  admin   2011-11-23      0
103 252     invalidBillsofMaterials detail  used by dspInvalidBillsOfMaterials Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: invalidBillsofMaterials\n-- Name: detail\n-- Notes: used by dspInvalidBillsOfMaterials\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, parent.item_id AS pitem_id,\n       component.item_id AS citem_id,\n       warehous_id, warehous_code,\n       parent.item_number AS parentitem,\n       component.item_number AS componentitem,\n       (component.item_descrip1 || ' ' || component.item_descrip2) AS descrip\nFROM bomitem, itemsite, item AS parent, item AS component, warehous\nWHERE ((bomitem_parent_item_id=parent.item_id)\n   AND (bomitem_item_id=component.item_id)\n   AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))\n   AND (itemsite_item_id=parent.item_id)\n   AND (itemsite_warehous_id=warehous_id)\n   AND (parent.item_type='M')\n   AND (itemsite_wosupply)\n   AND (itemsite_active)\n   AND (component.item_id NOT IN ( SELECT itemsite_item_id\n                                   FROM itemsite\n                                   WHERE ((itemsite_warehous_id=warehous_id)\n                                      AND (itemsite_active)) ) ) \n<? if exists("warehous_id") ?>\n   AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY warehous_code, parentitem, componentitem;\n      admin   2011-11-23      0
104 51      inventoryAvailability   byCustOrSO      query to get item availability by either customer id/type/pattern or by cohead_id Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: inventoryAvailability\n-- Name:  byCustOrSO\n-- Notes: query to get item availability by either customer id/type/pattern\n--        or by cohead_id\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, altid, cohead_id,\n       item_number, descrip, uom_name,\n       qoh, sobalance, allocated, ordered,\n       atshipping,\n       CASE WHEN (xtindentrole=1) THEN\n<? if exists("useReservationNetting") ?>\n                  coitem_qtyreserved\n<? else ?>\n                  (qoh + ordered - sobalance)\n<? endif ?>\n            WHEN (xtindentrole=2) THEN (qoh + ordered - sobalance)\n       END AS orderavail,\n       (qoh + ordered - allocated) AS totalavail,\n       orderdate, duedate,\n       reorderlevel,\n<? if exists("sohead_id") ?> (xtindentrole - 1) AS <? endif ?> xtindentrole, \n       'qty' AS qoh_xtnumericrole,\n       'qty' AS sobalance_xtnumericrole,\n       'qty' AS allocated_xtnumericrole,\n       'qty' AS ordered_xtnumericrole,\n       'qty' AS orderavail_xtnumericrole,\n       'qty' AS totalavail_xtnumericrole,\n       'qty' AS atshipping_xtnumericrole,\n       CASE WHEN (pack_id IS NOT NULL) THEN 'altemphasis'\n       END AS qtforegroundrole,\n       CASE WHEN (qoh < 0) THEN 'error'\n            WHEN (qoh < reorderlevel) THEN 'warning'\n       END AS qoh_qtforegroundrole,\n       CASE WHEN (\n<? if exists("useReservationNetting") ?>\n                  coitem_qtyreserved < 0\n<? else ?>\n                  (qoh + ordered - sobalance) < 0\n<? endif ?>\n                 ) THEN 'error'\n            WHEN ((qoh + ordered - sobalance) <= reorderlevel) THEN 'warning'\n       END AS orderavail_qtforegroundrole,\n       CASE WHEN ((qoh + ordered - allocated) < 0) THEN 'error'\n            WHEN ((qoh + ordered - allocated) <= reorderlevel) THEN 'warning'\n       END AS totalavail_qtforegroundrole,\n       CASE WHEN (xtindentrole = 2 AND (orderdate <= CURRENT_DATE)\n              AND (descrip IN ('O','E','S','R'))) THEN 'error'\n       END AS atshipping_qtforegroundrole,\n       CASE WHEN (xtindentrole = 2 AND duedate<=CURRENT_DATE) THEN 'error'\n       END AS orderdate_qtforegroundrole,\n       CASE WHEN (xtindentrole = 2 AND duedate<=CURRENT_DATE) THEN 'error'\n       END AS duedate_qtforegroundrole,\n<? if exists("useReservationNetting") ?>\n       CASE WHEN (coitem_qtyreserved > 0\n              AND sobalance > coitem_qtyreserved) THEN 'emphasis'\n            WHEN ((sobalance <> 0)\n              AND ((sobalance - coitem_qtyreserved) = 0)) THEN 'altemphasis'\n       END AS qtforegroundrole,\n<? endif ?>\n       CASE WHEN (xtindentrole = 2) THEN ''\n       END AS sobalance_qtdisplayrole\nFROM (\n<? if not exists("sohead_id") ?>\n    SELECT cohead_id AS id, -2 AS altid, cohead_id, cohead_number,\n           cohead_number AS item_number,\n           '' AS trueitem_number,\n           (cust_number||'-'||cust_name) AS descrip,\n           '' AS uom_name, CAST(NULL AS NUMERIC) AS qoh,\n           CAST(NULL AS NUMERIC) AS sobalance,\n           CAST(NULL AS NUMERIC) AS allocated,\n           CAST(NULL AS NUMERIC) AS ordered,\n           CAST(NULL AS NUMERIC) AS atshipping,\n           CAST(NULL AS NUMERIC) AS coitem_qtyreserved,\n           cohead_orderdate AS orderdate, MIN(coitem_scheddate) AS duedate,\n           pack_id,\n           CAST(NULL AS NUMERIC) AS reorderlevel,\n           0 AS xtindentrole\n     FROM cohead\n          LEFT OUTER JOIN pack\n            ON (pack_head_type='SO' AND pack_head_id=cohead_id),\n          cust, coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n     WHERE ((coitem_cohead_id=cohead_id)\n        AND (cohead_cust_id=cust_id)\n        AND (coitem_status NOT IN ('C', 'X'))\n  <? if exists("custtype_id") ?>\n        AND (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n        AND (cust_custtype_id IN (SELECT custtype_id\n                                  FROM custtype\n                                  WHERE(custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? endif ?>\n      )\n      GROUP BY cohead_id, item_number, cust_number,\n               cust_name, cohead_orderdate, pack_id\n  <? if exists("onlyShowShortages") ?>\n      HAVING (MIN(noNeg(itemsite_qtyonhand) +\n                  qtyOrdered(itemsite_id, coitem_scheddate) -\n                  qtyAllocated(itemsite_id, coitem_scheddate)) < 0\n              OR MIN(noNeg(itemsite_qtyonhand) +\n                  qtyOrdered(itemsite_id, coitem_scheddate) -\n                  noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) < 0\n           )\n  <? endif ?>\n    UNION\n<? endif ?>\n    SELECT itemsite_id AS id, coitem_id AS altid, cohead_id, cohead_number,\n            item_number,\n            item_number AS trueitem_number,\n            (item_descrip1 || ' ' || item_descrip2) AS descrip,\n            uom_name, noNeg(itemsite_qtyonhand) AS qoh,\n            noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n            qtyAllocated(itemsite_id, coitem_scheddate) AS allocated,\n            qtyOrdered(itemsite_id, coitem_scheddate) AS ordered,\n            qtyatshipping(coitem_id) AS atshipping,\n            itemuomtouom(item_id, coitem_qty_uom_id, null, coitem_qtyreserved) AS coitem_qtyreserved,\n            CAST(NULL AS DATE) AS orderdate, coitem_scheddate AS duedate,\n            CAST(NULL AS INTEGER) AS pack_id,\n            CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n                 ELSE 0.0 END AS reorderlevel,\n            1 AS xtindentrole\n     FROM cohead\n<? if not exists("sohead_id") ?> JOIN cust ON (cohead_cust_id=cust_id)<? endif ?>\n          , itemsite, item, uom, site(), coitem\n     WHERE ((coitem_cohead_id=cohead_id)\n        AND (coitem_itemsite_id=itemsite_id)\n        AND (itemsite_warehous_id=warehous_id)\n        AND (itemsite_item_id=item_id)\n        AND (item_inv_uom_id=uom_id)\n        AND (coitem_status NOT IN ('C', 'X'))\n<? if exists("sohead_id") ?>\n        AND (cohead_id=<? value("sohead_id") ?>)\n<? elseif exists("custtype_id") ?>\n        AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n        AND (cust_custtype_id IN (SELECT custtype_id\n                                  FROM custtype\n                                  WHERE(custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("onlyShowShortages") ?>\n        AND ((noNeg(itemsite_qtyonhand) + qtyOrdered(itemsite_id, coitem_scheddate) - qtyAllocated(itemsite_id, coitem_scheddate) < 0)\n          OR (noNeg(itemsite_qtyonhand) + qtyOrdered(itemsite_id, coitem_scheddate) - noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) < 0))\n<? endif ?>\n    )\n<? if exists("showWoSupply") ?>\n    UNION\n    SELECT  itemsite_id, -1, cohead_id, cohead_number,\n            formatwonumber(wo_id),\n            item_number AS trueitem_number,\n            wo_status,\n            NULL, NULL,\n            noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n            NULL,\n            noNeg((wo_qtyord-wo_qtyrcv)) AS ordered,\n            NULL,\n            NULL,\n            wo_startdate, wo_duedate,\n            NULL AS pack_id,\n            CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n                 ELSE 0.0 END AS reorderlevel,\n            2 AS xtindentrole\n     FROM cohead\n<? if not exists("sohead_id") ?> JOIN cust ON (cohead_cust_id=cust_id)<? endif ?>\n          , itemsite, item, uom, site(), coitem\n          LEFT OUTER JOIN wo\n           ON ((coitem_itemsite_id=wo_itemsite_id)\n           AND (wo_status IN ('E','R','I'))\n           AND (wo_qtyord-wo_qtyrcv > 0)\n           AND (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned-qtyatshipping(coitem_id)) >\n            (SELECT itemsite_qtyonhand FROM itemsite WHERE (itemsite_id=coitem_itemsite_id))))\n     WHERE ((coitem_cohead_id=cohead_id)\n        AND (coitem_itemsite_id=itemsite_id)\n        AND (itemsite_warehous_id=warehous_id)\n        AND (itemsite_item_id=item_id)\n        AND (item_inv_uom_id=uom_id)\n        AND (coitem_status NOT IN ('C', 'X'))\n  <? if exists("sohead_id") ?>\n        AND (cohead_id=<? value("sohead_id") ?>)\n  <? elseif exists("custtype_id") ?>\n        AND (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n        AND (cust_custtype_id IN (SELECT custtype_id\n                                  FROM custtype\n                                  WHERE(custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? endif ?>\n  <? if exists("onlyShowShortages") ?>\n        AND ((noNeg(itemsite_qtyonhand) + qtyOrdered(itemsite_id, coitem_scheddate) - qtyAllocated(itemsite_id, coitem_scheddate) < 0)\n          OR (noNeg(itemsite_qtyonhand) + qtyOrdered(itemsite_id, coitem_scheddate) - noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) < 0))\n  <? endif ?>\n  )\n<? endif ?>\n) AS data\nORDER BY cohead_number, trueitem_number,\n         xtindentrole;\n        admin   2011-11-23      0
105 55      invoices        detail  used by reprintInvoices, unpostedInvoices, dspRecurringInvoices Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: invoices\n-- Name: detail\n-- Notes: used by reprintInvoices, unpostedInvoices, dspRecurringInvoices\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invchead_id, cust_id,\n       invchead.*,\n       cust_number, cust_name,\n       (TEXT(cust_number) || ' - ' || cust_name) AS customer,\n       COALESCE(invchead_gldistdate, invchead_invcdate) AS gldistdate,\n       invoicetotal(invchead_id) AS extprice,\n       CASE WHEN (aropen_open) THEN (aropen_amount - aropen_paid)\n            ELSE 0\n       END AS balance,\n       (invchead_recurring_invchead_id IS NOT NULL) AS isRecurring,\n       recur_freq,\n       recur_period,\n       CASE WHEN (recur_period='D') THEN <? value("day") ?>\n            WHEN (recur_period='W') THEN <? value("week") ?>\n            WHEN (recur_period='M') THEN <? value("month") ?>\n            WHEN (recur_period='Y') THEN <? value("year") ?>\n            WHEN (recur_period='m') THEN <? value("minute") ?>\n            WHEN (recur_period='H') THEN <? value("hour") ?>\n            ELSE <? value("none") ?>\n       END AS recur_period_qtdisplayrole,\n       recur_end,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS balance_xtnumericrole,\n       CASE WHEN (aropen_id IS NULL) THEN 'Unposted' END AS balance_qtdisplayrole\nFROM invchead JOIN custinfo ON (cust_id=invchead_cust_id)\n              LEFT OUTER JOIN aropen ON ( (aropen_doctype='I') AND (aropen_docnumber=invchead_invcnumber) )\n              LEFT OUTER JOIN recur ON (invchead_recurring_invchead_id=recur_parent_id AND recur_parent_type='I')\nWHERE ( (true)\n<? if exists("unpostedOnly") ?>\n  AND   (NOT invchead_posted)\n<? endif ?>\n<? if exists("postedOnly") ?>\n  AND   (invchead_posted)\n<? endif ?>\n<? if exists("recurringOnly") ?>\n  AND   (invchead_recurring_invchead_id IS NOT NULL)\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (invchead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (invchead_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("invc_pattern") ?>\n  AND   (invchead_invcnumber ~ <? value("invc_pattern") ?>)\n<? endif ?>\n<? if exists("balanceOnly") ?>\n  AND   (aropen_open AND (aropen_amount - aropen_paid > 0))\n<? endif ?>\n  AND   (checkInvoiceSitePrivs(invchead_id)) )\nORDER BY invchead_invcnumber\n;\n     admin   2011-11-23      0
106 52      inventoryAvailability   general  Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: inventoryAvailability\n-- Name:  general\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, altId,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       uom_name,\n       warehous_id, warehous_code, itemsite_leadtime,\n       qoh, allocated, noNeg(qoh - allocated) AS unallocated, \n       ordered, requests, reorderlevel, outlevel,\n       (qoh - allocated + ordered) AS available,\n       vend_number,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS allocated_xtnumericrole,\n       'qty' AS unallocated_xtnumericrole,       \n       'qty' AS ordered_xtnumericrole,\n       'qty' AS requests_xtnumericrole,\n       'qty' AS reorderlevel_xtnumericrole,\n       'qty' AS outlevel_xtnumericrole,\n       'qty' AS available_xtnumericrole,\n       <? if exists("byDates") ?>\n         'grey' AS qoh_qtforegroundrole,\n       <? endif ?>\n       CASE WHEN ((qoh - allocated + ordered) < 0) THEN 'error'\n            WHEN ((qoh - allocated + ordered) <= reorderlevel) THEN 'warning'\n       END AS available_qtforegroundrole\nFROM (SELECT \n           <? if reExists("[vV]end") ?>\n             DISTINCT\n           <? endif ?>\n             itemsite_id,\n             CASE WHEN (item_type IN ('P', 'O')) THEN 1\n                  WHEN (item_type IN ('M')) THEN 2\n                  ELSE 0\n             END AS altId,\n             item_number, item_descrip1, item_descrip2, item_inv_uom_id,\n             warehous_id, warehous_code, itemsite_leadtime,\n             itemsite_qtyonhand AS qoh,\n             CASE WHEN itemsite_useparams THEN itemsite_reorderlevel\n                  ELSE 0.0\n             END AS reorderlevel,\n             CASE WHEN itemsite_useparams THEN itemsite_ordertoqty\n                  ELSE 0.0\n             END AS outlevel,\n             <? if exists("byVend") ?>\n               vend_number,\n             <? else ?>\n               NULL AS vend_number,\n             <? endif ?>\n             <? if exists("byLeadTime") ?>\n               qtyAllocated(itemsite_id, itemsite_leadtime) AS allocated,\n               qtyOrdered(itemsite_id,   itemsite_leadtime) AS ordered, \n               qtypr(itemsite_id,   itemsite_leadtime) AS requests\n             <? elseif exists("byDays") ?>\n               qtyAllocated(itemsite_id, CAST(<? value("byDays") ?> AS INTEGER)) AS allocated,\n               qtyOrdered(itemsite_id,   CAST(<? value("byDays") ?> AS INTEGER)) AS ordered,\n               qtypr(itemsite_id,   CAST(<? value("byDays") ?> AS INTEGER)) AS requests  \n             <? elseif exists("byDate") ?>\n               qtyAllocated(itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) AS allocated,\n               qtyOrdered(itemsite_id,   (<? value("byDate") ?> - CURRENT_DATE)) AS ordered,\n               qtypr(itemsite_id,   (<? value("byDate") ?> - CURRENT_DATE)) AS requests \n             <? elseif exists("byDates") ?>\n               qtyAllocated(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS allocated,\n               qtyOrdered(itemsite_id,   <? value("startDate") ?>, <? value("endDate") ?>) AS ordered,\n               qtypr(itemsite_id,   <? value("startDate") ?>, <? value("endDate") ?>) AS requests\n             <? endif ?>\n      FROM item, itemsite, warehous \n           <? if reExists("[vV]end") ?>\n             , vend JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n           <? endif ?>\n      WHERE ( (itemsite_active)\n          AND (itemsite_item_id=item_id)\n          AND (itemsite_warehous_id=warehous_id)\n          <? if exists("warehous_id") ?>\n            AND (warehous_id=<? value("warehous_id") ?>)\n          <? endif ?>\n          <? if exists("item_id") ?>\n            AND (item_id=<? value("item_id") ?>)\n          <? elseif exists("classcode_id") ?>\n            AND (item_classcode_id=<? value("classcode_id") ?>)\n          <? elseif exists("classcode_pattern") ?>\n            AND (item_classcode_id IN (SELECT classcode_id\n                                       FROM classcode\n                                       WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n          <? elseif exists("plancode_id") ?>\n            AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n          <? elseif exists("plancode_pattern") ?>\n            AND (itemsite_plancode_id IN (SELECT plancode_id\n                                          FROM plancode\n                                          WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n          <? elseif exists("itemgrp_id") ?>\n            AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem\n                             WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n          <? elseif exists("itemgrp_pattern") ?>\n            AND (item_id IN (SELECT itemgrpitem_item_id\n                             FROM itemgrpitem, itemgrp\n                             WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n                                    AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n          <? elseif exists("itemgrp") ?>\n            AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n          <? endif ?>\n          <? if reExists("[vV]end") ?>\n            AND (itemsrc_item_id=item_id)\n          <? endif ?>\n          <? if exists("vend_id") ?>\n            AND (vend_id=<? value("vend_id") ?>)\n          <? elseif exists("vendtype_id") ?>\n            AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n          <? elseif exists("vendtype_pattern") ?>\n            AND (vend_vendtype_id IN (SELECT vendtype_id\n                                      FROM vendtype\n                                      WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n          <? endif ?>\n      ) ) AS data, uom\nWHERE ((item_inv_uom_id=uom_id)\n<? if exists("showReorder") ?>\n  AND ((qoh - allocated + ordered) <= reorderlevel) \n  <? if exists("ignoreReorderAtZero") ?>\n    AND NOT ( ((qoh - allocated + ordered) = 0) AND (reorderlevel = 0))\n  <? endif ?>\n<? elseif exists("showShortages") ?>\n  AND ((qoh - allocated + ordered) < 0) \n<? endif ?>\n)\n\nORDER BY\n<? if exists("ListNumericItemNumbersFirst") ?>\n  toNumeric(item_number, 999999999999999),\n<? elseif exists("byVend") ?>\n  vend_number,\n<? endif ?>\n  item_number, warehous_code DESC;\n  admin   2011-11-23      0
107 253     inventoryAvailabilitybyWorkorder        detail  used by dspInventoryAvailabilityByWorkOrder Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: inventoryAvailabilitybyWorkorder\n-- Name: detail\n-- Notes: used by dspInventoryAvailabilityByWorkOrder\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, 'qty' AS woinvav_qoh_xtnumericrole,\n       'qty' AS woinvav_balance_xtnumericrole,\n       'qty' AS woinvav_allocated_xtnumericrole,\n       'qty' AS woinvav_ordered_xtnumericrole,\n       'qty' AS woinvav_woavail_xtnumericrole,\n       'qty' AS woinvav_totalavail_xtnumericrole,\n       CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n            WHEN (woinvav_qoh < 0) THEN 'error'\n            WHEN (woinvav_qoh < woinvav_reorderlevel) THEN 'warning'\n            WHEN ((woinvav_qoh - woinvav_balance) < 0) THEN 'altemphasis'\n            WHEN ((woinvav_qoh - woinvav_allocated) < 0) THEN 'altemphasis'\n       END AS woinvav_qoh_qtforegroundrole,\n       CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n            WHEN ((woinvav_qoh + woinvav_ordered - woinvav_balance) < 0) THEN 'error'\n            WHEN ((woinvav_qoh + woinvav_ordered - woinvav_balance) < woinvav_reorderlevel) THEN 'warning'\n       END AS woinvav_woavail_qtforegroundrole,\n       CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n            WHEN ((woinvav_qoh + woinvav_ordered - woinvav_allocated) < 0) THEN 'error'\n            WHEN ((woinvav_qoh + woinvav_ordered - woinvav_allocated) < woinvav_reorderlevel) THEN 'warning'\n       END AS woinvav_totalavail_qtforegroundrole,\n       CASE WHEN (woinvav_womatl_id = -1) THEN 'altemphasis'\n         ELSE null\n       END AS qtforegroundrole,\n       woinvav_level AS xtindentrole\nFROM woinvavail(<? value("wo_id") ?>,\n<? if exists("IndentedParentChild") ?>\n                true,\n<? else ?>\n                false,\n<? endif ?>\n<? if exists("summarizedParentChild") ?>\n                true,\n<? else ?>\n                false,\n<? endif ?>\n<? if exists("onlyShowShortages") ?>\n                true,\n<? else ?>\n                false,\n<? endif ?>\n<? if exists("onlyShowInsufficientInventory") ?>\n                true\n<? else ?>\n                false\n<? endif ?>\n               ) AS data;\n     admin   2011-11-23      0
108 54      inventoryHistory        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: inventoryHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invhist_id, invdetail_id, invhist_transdate AS sortdate,\n       formatDateTime(invhist_transdate) AS transdate,\n       CASE WHEN (level=0) THEN invhist_transdate END AS invhist_transdate,\n       CASE WHEN (level=0) THEN invhist_created END AS invhist_created,\n       CASE WHEN (level=0) THEN invhist_user END AS invhist_user,\n       CASE WHEN (level=0) THEN invhist_transtype END AS invhist_transtype,\n       CASE WHEN (level=0) THEN warehous_code END AS warehous_code,\n       CASE WHEN (level=0) THEN ordernumber\n            ELSE locationname\n       END AS orderlocation,\n       CASE WHEN (level=0) THEN item_number END AS item_number,\n       CASE WHEN (level=0) THEN invhist_invuom END AS invhist_invuom,\n       CASE WHEN (level=0 AND invhist_transtype IN ('EX','IM','SH','SI')) THEN (invhist_invqty * -1.0)\n            WHEN (level=0) THEN invhist_invqty\n            ELSE invdetail_qty\n       END AS transqty,\n       CASE WHEN (level=0) THEN invhist_value_after - invhist_value_before\n       END AS transvalue,\n       CASE WHEN (level=0) THEN locfrom END AS locfrom,\n       CASE WHEN (level=0) THEN invhist_qoh_before\n            ELSE invdetail_qty_before\n       END AS qohbefore,\n       CASE WHEN (level=0) THEN locto END AS locto,\n       CASE WHEN (level=0) THEN invhist_qoh_after\n            ELSE invdetail_qty_after\n       END AS qohafter,\n       CASE WHEN (level=0) THEN costmethod END AS costmethod,\n       CASE WHEN (level=0) THEN invhist_value_before END AS invhist_value_before,\n       CASE WHEN (level=0) THEN invhist_value_after END AS invhist_value_after,\n       'qty' AS transqty_xtnumericrole,\n       'curr' AS transvalue_xtnumericrole,\n       0 AS transvalue_xttotalrole,\n       'qty' AS qohbefore_xtnumericrole,\n       'qty' AS qohafter_xtnumericrole,\n       'curr' AS invhist_value_before_xtnumericrole,\n       'curr' AS invhist_value_after_xtnumericrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS qohbefore_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS qohafter_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS invhist_value_before_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS invhist_value_after_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS costmethod_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS locto_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN NULL END AS locfrom_qtdisplayrole,\n       CASE WHEN (NOT invhist_posted) THEN 'warning' END AS qtforegroundrole,\n       level AS xtindentrole\nFROM (\nSELECT invhist.*, 0 AS level,\n       whs1.warehous_code AS warehous_code, item_number,\n       CASE WHEN (invhist_ordtype NOT LIKE '') THEN (invhist_ordtype || '-' || invhist_ordnumber)\n            ELSE invhist_ordnumber\n       END AS ordernumber,\n       CASE WHEN (invhist_costmethod='A') THEN <? value("average") ?>\n            WHEN (invhist_costmethod='S') THEN <? value("standard") ?>\n            WHEN (invhist_costmethod='J') THEN <? value("job") ?>\n            WHEN (invhist_costmethod='N') THEN <? value("none") ?>\n            ELSE <? value("unknown") ?>\n       END AS costmethod,\n       0 AS invdetail_id, '' AS locationname,\n       0 AS invdetail_qty, 0 AS invdetail_qty_before, 0 AS invdetail_qty_after,\n       CASE WHEN (invhist_transtype='TW' AND invhist_invqty < 0) THEN whs1.warehous_code\n            WHEN (invhist_transtype='TW') THEN whs2.warehous_code\n            WHEN (invhist_transtype='AD' AND invhist_invqty < 0) THEN whs1.warehous_code\n            WHEN (invhist_transtype='AD') THEN 'ADJ'\n            WHEN (invhist_transtype='EX') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IB') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IM' AND invhist_invqty < 0) THEN 'WIP'\n            WHEN (invhist_transtype='IM') THEN whs1.warehous_code\n            WHEN (invhist_transtype='IT') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RB') THEN 'WIP'\n            WHEN (invhist_transtype='RM') THEN 'WIP'\n            WHEN (invhist_transtype='RP') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RR') THEN 'CUST'\n            WHEN (invhist_transtype='RS') THEN 'SHIP'\n            WHEN (invhist_transtype='SH') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SI') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SV') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='TR') THEN whs2.warehous_code\n\t WHEN (invhist_transtype='TS') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='RI') THEN whs1.warehous_code\n            ELSE ''\n       END AS locfrom,\n       CASE WHEN (invhist_transtype='TW' AND invhist_invqty < 0) THEN whs2.warehous_code\n            WHEN (invhist_transtype='TW') THEN whs1.warehous_code\n            WHEN (invhist_transtype='AD' AND invhist_invqty < 0) THEN 'ADJ'\n            WHEN (invhist_transtype='AD') THEN whs1.warehous_code\n            WHEN (invhist_transtype='CC') THEN whs1.warehous_code\n            WHEN (invhist_transtype='EX') THEN 'EXPENSE'\n            WHEN (invhist_transtype='IB') THEN 'WIP'\n            WHEN (invhist_transtype='IM' AND invhist_invqty < 0) THEN whs1.warehous_code\n            WHEN (invhist_transtype='IM') THEN 'WIP'\n            WHEN (invhist_transtype='NN') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RB') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RM') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RP') THEN 'PURCH'\n            WHEN (invhist_transtype='RR') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RS') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RT') THEN whs1.warehous_code\n            WHEN (invhist_transtype='RX') THEN whs1.warehous_code\n            WHEN (invhist_transtype='SH') THEN 'SHIP'\n            WHEN (invhist_transtype='SI') THEN 'SCRAP'\n            WHEN (invhist_transtype='SV') THEN 'SHIP'\n            WHEN (invhist_transtype='TR') THEN whs1.warehous_code\n            WHEN (invhist_transtype='TS') THEN whs2.warehous_code\n            WHEN (invhist_transtype='RI') THEN 'WIP'\n            ELSE ''\n       END AS locto \nFROM itemsite, item, warehous AS whs1, invhist \n  LEFT OUTER JOIN warehous AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id) \nWHERE ( (invhist_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id) \n  AND  (itemsite_warehous_id=whs1.warehous_id)\n  AND  (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?> )\n  AND  (transType(invhist_transtype, <? value("transType") ?>))\n<? if exists("orderNumber") ?>\n  AND  (invhist_ordnumber ~ <? value("orderNumber") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n  AND  (invhist_ordtype='SO')\n  AND  (invhist_ordnumber ~ (\n    SELECT cohead_number \n    FROM cohead \n    WHERE cohead_id=<? value("cohead_id") ?>))\n<? endif ?>\n<? if exists("pohead_id") ?>\n  AND  (invhist_ordtype='PO')\n  AND  (invhist_ordnumber ~ (\n    SELECT pohead_number \n    FROM pohead \n    WHERE pohead_id=<? value("pohead_id") ?>))\n<? endif ?>\n<? if exists("tohead_id") ?>\n  AND  (invhist_ordtype='TO')\n  AND  (invhist_ordnumber ~ (\n    SELECT tohead_number \n    FROM tohead \n    WHERE tohead_id=<? value("tohead_id") ?>))\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND  (invhist_ordtype='WO')\n  AND  (invhist_ordnumber ~ formatWoNumber(<? value("wo_id") ?>))\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND  (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n  AND  (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n\t\t\t      FROM classcode\n\t\t\t      WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? endif ?>\n<? if exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp") ?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n) \nUNION SELECT invhist.*, 1 AS level,\n             '' AS warehous_code, '' AS item_number,\n             '' AS ordernumber,\n             '' AS costmethod,\n             invdetail_id,\n             CASE WHEN (invdetail_location_id=-1) THEN formatlotserialnumber(invdetail_ls_id)\n                  WHEN (invdetail_ls_id IS NULL) THEN formatLocationName(invdetail_location_id)\n                  ELSE (formatLocationName(invdetail_location_id) || '-' || formatlotserialnumber(invdetail_ls_id))\n             END AS locationname,\n             invdetail_qty, invdetail_qty_before, invdetail_qty_after,\n             '' AS locfrom,\n             '' AS locto \nFROM itemsite, item, warehous AS whs1, invdetail, invhist LEFT OUTER JOIN\n     warehous AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id) \nWHERE ((invhist_hasdetail)\n  AND (invhist_itemsite_id=itemsite_id)\n  AND (itemsite_item_id=item_id)\n  AND (itemsite_warehous_id=whs1.warehous_id)\n  AND (invdetail_invhist_id=invhist_id)\n  AND  (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?> )\n  AND (transType(invhist_transtype, <? value("transType") ?>))\n<? if exists("orderType") ?>\n  AND  (invhist_ordtype=<? value("orderType") ?>)\n<? endif ?>\n<? if exists("orderNumber") ?>\n  AND  (invhist_ordnumber ~ <? value("orderNumber") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n  AND  (invhist_ordtype='SO')\n  AND  (invhist_ordnumber ~ (\n    SELECT cohead_number \n    FROM cohead \n    WHERE cohead_id=<? value("cohead_id") ?>))\n<? endif ?>\n<? if exists("pohead_id") ?>\n  AND  (invhist_ordtype='PO')\n  AND  (invhist_ordnumber ~ (\n    SELECT pohead_number \n    FROM pohead \n    WHERE pohead_id=<? value("pohead_id") ?>))\n<? endif ?>\n<? if exists("tohead_id") ?>\n  AND  (invhist_ordtype='TO')\n  AND  (invhist_ordnumber ~ (\n    SELECT tohead_number \n    FROM tohead \n    WHERE tohead_id=<? value("tohead_id") ?>))\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND  (invhist_ordtype='WO')\n  AND  (invhist_ordnumber ~ formatWoNumber(<? value("wo_id") ?>))\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND  (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n  AND  (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n  AND  (item_classcode_id IN (SELECT classcode_id\n\t\t\t      FROM classcode\n\t\t\t      WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? endif ?>\n<? if exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp") ?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n)\n\n   ) AS data\nORDER BY sortdate DESC, invhist_id, level;\n       admin   2011-11-23      0
109 254     inventoryLocator        detail  used by dspInventoryLocator Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: inventoryLocator\n-- Name: detail\n-- Notes: used by dspInventoryLocator\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       <? value("na") ?> AS locationname_xtnullrole,\n       <? value("na") ?> AS netable_xtnullrole,\n       <? value("na") ?> AS lotserial_xtnullrole,\n       <? value("na") ?> AS expiration_xtnullrole,\n       <? value("na") ?> AS warranty_xtnullrole,\n       CASE WHEN (itemsite_perishable\n                  AND itemloc_expiration <= CURRENT_DATE) THEN 'error'\n            WHEN (itemsite_warrpurc\n                  AND itemloc_warrpurc <= CURRENT_DATE) THEN 'error'\n       END AS qtforegroundrole,\n       'qty' AS qoh_xtnumericrole\nFROM (SELECT itemloc_id, 1 AS type, warehous_code,\n             itemsite_perishable, itemloc_expiration,\n             itemsite_warrpurc, itemloc_warrpurc,\n             CASE WHEN (location_id IS NOT NULL) THEN\n                        (formatLocationName(location_id) || '-' || firstLine(location_descrip))\n             END AS locationname,\n             CASE WHEN (location_id IS NOT NULL) THEN location_netable\n             END AS netable,\n             CASE WHEN (itemsite_controlmethod IN ('L', 'S')) THEN\n                        formatlotserialnumber(itemloc_ls_id)\n             END AS lotserial,\n             CASE WHEN (itemsite_perishable) THEN itemloc_expiration\n             END AS expiration,\n             CASE WHEN (itemsite_warrpurc) THEN itemloc_warrpurc\n             END AS warranty,\n             itemloc_qty AS qoh\n      FROM itemsite, warehous,\n           itemloc LEFT OUTER JOIN location ON (itemloc_location_id=location_id)\n      WHERE ((itemsite_loccntrl OR (itemsite_controlmethod IN ('L', 'S')))\n         AND (itemloc_itemsite_id=itemsite_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemsite_item_id=<? value("item_id") ?>)\n      <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n      <? endif ?>\n            )\n      UNION\n      SELECT itemsite_id, 2 AS type, warehous_code,\n             itemsite_perishable, NULL AS itemloc_expiration,\n             itemsite_warrpurc, NULL AS itemloc_warrpurc,\n             NULL AS locationname,\n             NULL AS netable,\n             NULL AS lotserial,\n             NULL AS expiration,\n             NULL AS warranty,\n             itemsite_qtyonhand AS qoh\n      FROM itemsite, warehous\n      WHERE ((NOT itemsite_loccntrl)\n         AND (itemsite_controlmethod NOT IN ('L', 'S'))\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemsite_item_id=<? value("item_id") ?>)\n      <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n      <? endif ?>\n            )\n     ) AS dummy\nORDER BY warehous_code, locationname, lotserial;\n   admin   2011-11-23      0
110 255     invoiceInformation      detail  used by dspInvoiceInformation Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: invoiceInformation\n-- Name: detail\n-- Notes: used by dspInvoiceInformation\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT arapply_id,\n       CASE WHEN (arapply_source_doctype = 'C') THEN <? value("creditMemo") ?>\n            WHEN (arapply_source_doctype = 'R') THEN <? value("cashdeposit") ?>\n            WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n            WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n            WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n            WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n            WHEN (arapply_fundstype='A') THEN <? value("americanExpress") ?>\n            WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n            WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n            WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n            WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n            WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n       END AS doctype,\n       CASE WHEN (arapply_source_doctype IN ('C','R')) THEN arapply_source_docnumber\n            WHEN (arapply_source_doctype = 'K') THEN arapply_refnumber\n         ELSE <? value("error") ?>\n       END AS docnumber,\n       arapply_postdate, arapply_applied,\n       currConcat(arapply_curr_id) AS currabbr,\n       currToBase(arapply_curr_id, arapply_applied, arapply_postdate) AS baseapplied,\n       'curr' AS arapply_applied_xtnumericrole,\n       'curr' AS baseapplied_xtnumericrole\nFROM arapply\nWHERE ((arapply_target_doctype='I')\n   AND (arapply_target_docnumber=<? value("aropen_docnumber") ?>))\nORDER BY arapply_postdate;\n   admin   2011-11-23      0
111 257     itemCost        detail  used by dspItemCostSummary, dspItemCostsByClassCode, dspItemCostHistory Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: itemCost\n-- Name: detail\n-- Notes: used by dspItemCostSummary, dspItemCostsByClassCode, dspItemCostHistory\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n      <? if exists("byHistory") ?>\n        costhist_id, costelem_type,\n        formatBoolYN(costhist_lowlevel) AS lowlevel,\n        CASE WHEN costhist_type='A' THEN <? value("actual") ?>\n             WHEN costhist_type='S' THEN <? value("standard") ?>\n             WHEN costhist_type='D' THEN <? value("delete") ?>\n             WHEN costhist_type='N' THEN <? value("new") ?>\n        END AS type,\n        costhist_date,\n        costhist_username AS username,\n        costhist_oldcost,\n        currConcat(costhist_oldcurr_id) AS oldcurr, \n\tcosthist_newcost,\n        currConcat(costhist_newcurr_id) AS newcurr,\n        'cost' AS costhist_oldcost_xtnumericrole,\n        'cost' AS costhist_newcost_xtnumericrole\n      <? elseif exists("byClassCode") ?>\n        item_id, item_number, description, \n        uom_name, scost, acost, \n        CASE WHEN (scost = 0) THEN NULL  \n          ELSE ((acost - scost) / scost)      \n        END AS percent_variance,\n        'percent' AS percent_variance_xtnumericrole, \n        CASE WHEN (scost = 0) THEN NULL \n             WHEN (((acost - scost) / scost) < 0) THEN 'error' \n          ELSE NULL \n        END AS percent_variance_qtforegroundrole, \n        <? if exists("onlyShowDiffCosts") ?>\n          CASE WHEN (scost != acost\n                     AND ABS(scost - acost) < 10 ^ (-1 * <? value("costscale") ?>))\n               THEN 'altemphasis' \n          END AS qtforegroundrole,\n        <? endif ?> \n        'cost' AS scost_xtnumericrole,\n        'cost' AS acost_xtnumericrole \n      <? elseif exists("bySummrey") ?>\n        itemcost_id,\n        CASE WHEN (costelem_sys) THEN 1\n          ELSE 0\n        END,\n        costelem_type, formatBoolYN(itemcost_lowlevel) AS lowlevel,\n        itemcost_stdcost,\n        currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS itemcost_actcost,\n        itemcost_updated, itemcost_posted,\n        'cost' AS itemcost_stdcost_xtnumericrole,\n        'cost' AS itemcost_actcost_xtnumericrole,\n        0 AS itemcost_stdcost_xttotalrole,\n        0 AS itemcost_actcost_xttotalrole,\n        CASE WHEN COALESCE(itemcost_posted, endOfTime()) >= endOfTime() \n             THEN <? value("never") ?>\n        END AS itemcost_posted_qtdisplayrole,\n        CASE WHEN COALESCE(itemcost_updated, endOfTime()) >= endOfTime()\n             THEN <? value("never") ?>\n        END AS itemcost_updated_qtdisplayrole\n      <? endif ?>\nFROM <? if exists("byClassCode") ?>\n       (SELECT item_id, item_number, \n               (item_descrip1 || ' ' || item_descrip2) AS description,\n               uom_name, stdcost(item_id) AS scost, actcost(item_id) AS acost\n        FROM item, classcode, uom\n        WHERE ((item_classcode_id=classcode_id)\n          AND  (item_inv_uom_id=uom_id)\n          <? if exists("classcode_id") ?>\n            AND (classcode_id=<? value("classcode_id") ?>)\n          <? elseif exists("classcode_pattern") ?>\n            AND (classcode_code ~ <? value("classcode_pattern") ?>)\n          <? endif ?> \n              ) ) AS data \n     <? elseif exists("byHistory") ?>\n       costhist,costelem\n     <? elseif exists("bySummrey") ?>\n       itemcost, costelem\n     <? endif ?>   \nWHERE ( <? if exists("byHistory") ?>\n         (costhist_costelem_id=costelem_id)\n     AND (costhist_item_id=<? value("item_id") ?>)\n        <? elseif exists("byClassCode") ?> \n          true \n          <? if exists("onlyShowZeroCosts") ?>\n            AND ((scost=0) OR (acost=0)) \n          <? endif ?> \n          <? if exists("onlyShowDiffCosts") ?>\n            AND (scost != acost) \n          <? endif ?>\n        <? elseif exists("bySummrey") ?>\n          (itemcost_costelem_id=costelem_id)\n      AND (itemcost_item_id=<? value("item_id") ?>)\n        <? endif ?>\n      ) \nORDER BY <? if exists("byHistory") ?>\n           costhist_date, costelem_type;\n         <? elseif exists("byClassCode") ?> \n           item_number;\n         <? elseif exists("bySummrey") ?>\n           itemcost_lowlevel, costelem_type;\n         <? endif ?>\n      admin   2011-11-23      0
112 113     itemcostdetail  detail  dspItemCostDetail Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: itemcostdetail\n-- Name:  detail\n-- Notes: dspItemCostDetail\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, item.item_id, seqnumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n       qtyper,       'qtyper' AS qtyper_xtnumericrole,\n       scrap,        'scrap' AS scrap_xtnumericrole,\n       cost,         'cost' AS cost_xtnumericrole,\n       extendedcost, 'cost' AS extendedcost_xtnumericrole,\n       0 AS extendedcost_xttotalrole \nFROM uom, item, (\n<? if exists("useBOM") ?>\n     SELECT bomitem_id AS id, bomitem_seqnumber AS seqnumber,\n            itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper) AS qtyper,\n            bomitem_scrap AS scrap,\n            bomitem_item_id AS item_id,\n  <? if exists("standardCost") ?>\n            itemcost_stdcost AS cost,\n            (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n                          bomitem_qtyper * (1 + bomitem_scrap)) *\n             itemcost_stdcost) AS extendedcost \n  <? elseif exists("actualCost") ?>\n            currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n            (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n                          bomitem_qtyper * (1 + bomitem_scrap)) *\n             currToBase(itemcost_curr_id, itemcost_actcost, NULL)) AS extendedcost \n  <? endif ?>\n    FROM bomitem\n         JOIN itemcost ON (itemcost_item_id=bomitem_item_id)\n         JOIN costelem ON (itemcost_costelem_id=costelem_id)\n  <? if exists("includeRevisionControl") ?>\n    LEFT OUTER JOIN rev ON ((bomitem_rev_id=rev_id) AND (COALESCE(rev_status, 'A')='A')) \n  <? endif ?>\n    WHERE ((CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1))\n     AND (bomitem_parent_item_id=<? value("item_id") ?>)\n     AND (costelem_id=<? value("costelem_id") ?>) ) \n<? elseif exists("useBBOM") ?>\n     SELECT bbomitem_id AS id, bbomitem_seqnumber AS seqnumber,\n            bbomitem_qtyper AS qtyper,\n            bbomitem_costabsorb AS scrap,\n            bbomitem_parent_item_id AS item_id,\n  <? if exists("standardCost") ?>\n            itemcost_stdcost AS cost,\n            (itemcost_stdcost / bbomitem_qtyper *\n             bbomitem_costabsorb) AS extendedcost \n  <? elseif exists("actualCost") ?>\n            currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n            (currToBase(itemcost_curr_id, itemcost_actcost, NULL) / bbomitem_qtyper *\n             bbomitem_costabsorb) AS extendedcost \n  <? endif ?>\n    FROM xtmfg.bbomitem\n         JOIN itemcost ON (itemcost_item_id=bbomitem_parent_item_id)\n    WHERE ((CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires-1))\n     AND (itemcost_costelem_id=<? value("costelem_id") ?>)\n     AND (bbomitem_item_id=<? value("item_id") ?>) )\n    UNION\n    SELECT source.bbomitem_id, source.bbomitem_seqnumber AS seqnumber,\n           source.bbomitem_qtyper, target.bbomitem_costabsorb,\n           item_id,\n  <? if exists("standardCost") ?>\n           itemcost_stdcost AS cost,\n           (itemcost_stdcost * source.bbomitem_qtyper /\n            target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost \n  <? elseif exists("actualCost") ?>\n           currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n           (currToBase(itemcost_curr_id, itemcost_actcost, NULL) * source.bbomitem_qtyper /\n            target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost \n  <? endif ?>\n    FROM xtmfg.bbomitem AS source\n         JOIN item     ON (source.bbomitem_item_id=item_id)\n         JOIN itemcost ON (source.bbomitem_item_id=itemcost_item_id)\n         JOIN xtmfg.bbomitem AS target\n              ON (source.bbomitem_parent_item_id=target.bbomitem_parent_item_id)\n    WHERE ((CURRENT_DATE BETWEEN source.bbomitem_effective\n                            AND (source.bbomitem_expires-1))\n     AND (CURRENT_DATE BETWEEN target.bbomitem_effective\n                          AND (target.bbomitem_expires-1))\n     AND (item_type='Y')\n     AND (target.bbomitem_item_id=<? value("item_id") ?>)\n     AND (itemcost_costelem_id=<? value("costelem_id") ?>) )\n<? endif ?>\n) AS data \nWHERE ((data.item_id=item.item_id)\n   AND (item_inv_uom_id=uom_id)) \nORDER BY seqnumber;\n      admin   2011-11-23      0
113 430     itemPricingSchedule     detail  used by itemPricingSchedule Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: itemPricingSchedule\n-- Name: detail\n-- Notes: used by itemPricingSchedule\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT ipsitem_id AS id, 1 AS altid, <? value("item") ?> AS type, item_number AS number,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       qty.uom_name AS qtyuom, ipsitem_qtybreak AS qtybreak,\n       price.uom_name AS priceuom,\n       ((COALESCE(ipsitem_discntprcnt, 0.0) * 100) + ipsitem_price) AS price,\n       (COALESCE(ipsitem_fixedamtdiscount, 0.0) + 0.00) AS fixedAmtDiscount,\n       noNeg(CASE WHEN ((COALESCE(ipsitem_discntprcnt, 0.0)=0.0)\n                    AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)=0.0))\n               THEN ipsitem_price\n               ELSE CASE WHEN ((COALESCE(ipsitem_discntprcnt, 0.0)=0.0)\n                           AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)<>0.0))\n                 THEN (item_listprice - ipsitem_fixedamtdiscount)\n                 ELSE CASE WHEN ((COALESCE(ipsitem_discntprcnt, 0.0)<>0.0)\n                             AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)=0.0))\n                   THEN ROUND((item_listprice - (item_listprice * ipsitem_discntprcnt)),4)\n                   ELSE ROUND((item_listprice - (item_listprice * ipsitem_discntprcnt)\n                               - ipsitem_fixedamtdiscount), 4)\n                 END\n               END\n             END) AS discounted_prc,\n       CASE WHEN ((COALESCE(ipsitem_discntprcnt, 0.0)=0.0)\n              AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)=0.0))\n         THEN 'Price'\n         ELSE CASE WHEN ((COALESCE(ipsitem_discntprcnt, 0.0)=0.0)\n                     AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)<>0.0))\n           THEN 'Fixed'\n           ELSE CASE WHEN ((COALESCE(ipsitem_discntprcnt, 0.0)<>0.0)\n                       AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)=0.0))\n             THEN 'Percent'\n             ELSE 'Mixed'\n           END\n         END\n       END AS method,\n       'qty' AS qtybreak_xtnumericrole,\n       'salesprice' AS price_xtnumericrole\nFROM ipsiteminfo, item, uom AS qty, uom AS price\nWHERE ( (ipsitem_item_id=item_id)\n   AND  (ipsitem_qty_uom_id=qty.uom_id)\n   AND  (ipsitem_price_uom_id=price.uom_id)\n   AND  (ipsitem_ipshead_id=<? value("ipshead_id") ?>) )\n\nUNION\n\nSELECT ipsprodcat_id AS id, 2 AS altid,\n       <? value("prodcat") ?> AS type,\n       prodcat_code AS number,\n       prodcat_descrip AS descrip,\n       '' AS qtyuom,\n       ipsprodcat_qtybreak AS qtybreak,\n       '' AS priceuom,\n       ipsprodcat_discntprcnt AS price,\n       ipsprodcat_fixedamtdiscount AS fixedAmtDiscount,\n       NULL AS discounted_prc,\n       NULL AS method,\n       'qty' AS qtybreak_xtnumericrole,\n       'percent' AS price_xtnumericrole\nFROM ipsprodcat, prodcat\nWHERE ( (ipsprodcat_prodcat_id=prodcat_id)\n   AND  (ipsprodcat_ipshead_id=<? value("ipshead_id") ?>) )\n\nUNION\n\nSELECT ipsfreight_id AS id, 3 AS altid, <? value("freight") ?> AS type,\n       CASE WHEN (ipsfreight_type='F') THEN <? value("flatrate") ?>\n         ELSE <? value("peruom") ?>\n       END AS number,\n       ('From ' || COALESCE(warehous_code, 'All Sites') || ' To ' ||\n         COALESCE(shipzone_name, 'All Shipping Zones')) AS descrip,\n       CASE WHEN (ipsfreight_type='P') THEN uom_name END AS qtyuom,\n       CASE WHEN (ipsfreight_type='P') THEN ipsfreight_qtybreak END AS qtybreak,\n       uom_name AS priceuom, ipsfreight_price AS price,\n       0.00 AS fixedAmtDiscount,\n       NULL AS discounted_prc,\n       NULL AS method,\n       'qty' AS qtybreak_xtnumericrole,\n       'curr' AS price_xtnumericrole\nFROM ipsfreight LEFT OUTER JOIN uom ON (uom_item_weight)\n                LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n                LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\nWHERE ( (ipsfreight_ipshead_id=<? value("ipshead_id") ?>) )\nORDER BY altid, number, qtybreak;\n      admin   2011-11-23      0
114 56      itemReceipt     populateEdit    used by enterPoitemReceipt, splitReceipt ----PURCHASE ORDER---------- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: itemReceipt\n-- Name: populateEdit\n-- Notes: used by enterPoitemReceipt, splitReceipt\n------PURCHASE ORDER----------\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number AS order_number, poitem_linenumber AS orderitem_linenumber,\n       (poitem_itemsite_id > 0) AS inventoryitem,\n       COALESCE(poitem_itemsite_id, -1) AS itemsiteid,\n       COALESCE(poitem_vend_item_number, '') AS vend_item_number,\n       COALESCE(poitem_vend_uom, '') AS vend_uom,\n       COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip,\n       poitem_invvenduomratio AS orderitem_qty_invuomratio,\n       poitem_duedate AS duedate,\n       poitem_qty_ordered AS orderitem_qty_ordered,\n       recv_qty AS qtyreceived,\n       poitem_qty_returned AS qtyreturned,\n       qtyToReceive('PO', poitem_id) AS qtytoreceive,\n       (poitem_qty_ordered) AS receivable,\n       recv_notes AS notes, recv_freight, recv_order_type,\n       recv_freight_curr_id AS curr_id, recv_date AS effective,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole \nFROM recv \n  JOIN  poitem ON ((recv_orderitem_id=poitem_id)\n               AND (recv_order_type='PO'))\n  JOIN  pohead ON (poitem_pohead_id=pohead_id)\nWHERE (recv_id=<? value("recv_id") ?>)\n<? if exists ("EnableReturnAuth") ?>\nUNION\n-------RETURN AUTHORIZATIONS-----------\nSELECT rahead_number AS order_number, raitem_linenumber AS orderitem_linenumber,\n       (raitem_itemsite_id > 0) AS inventoryitem,\n       COALESCE(raitem_itemsite_id, -1) AS itemsiteid,\n       '' AS vend_item_number,\n       '' AS vend_uom,\n       '' AS vend_item_descrip,\n       raitem_qty_invuomratio AS orderitem_qty_invuomratio,\n       raitem_scheddate AS duedate,\n       raitem_qtyauthorized AS orderitem_qty_ordered,\n       recv_qty AS qtyreceived,\n       0 AS qtyreturned,\n       qtyToReceive('RA', raitem_id) AS qtytoreceive,\n       (raitem_qtyauthorized) AS receivable,\n       recv_notes AS notes, recv_freight, recv_order_type,\n       recv_freight_curr_id AS curr_id, recv_date AS effective,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole \nFROM recv\n  JOIN  raitem ON ((recv_orderitem_id=raitem_id)\n               AND (recv_order_type='RA'))\n  JOIN  rahead ON (raitem_rahead_id=rahead_id)\nWHERE (recv_id=<? value("recv_id") ?>)\n<? endif ?>\n<? if exists ("MultiWhs") ?>\nUNION\n----------TRANSFER ORDERS---------\nSELECT tohead_number AS order_number, toitem_linenumber AS orderitem_linenumber,\n       (itemsite_id > 0) AS inventoryitem,\n       itemsite_id AS itemsiteid,\n       '' AS vend_item_number,\n       '' AS vend_uom,\n       '' AS vend_item_descrip,\n       1 AS orderitem_qty_invuomratio,\n       toitem_duedate AS duedate,\n       toitem_qty_ordered AS orderitem_qty_ordered,\n       recv_qty AS qtyreceived,\n       0 AS qtyreturned,\n       qtyToReceive('TO', toitem_id) AS qtytoreceive,\n       (toitem_qty_ordered) AS receivable,\n       recv_notes AS notes, recv_freight, recv_order_type,\n       recv_freight_curr_id AS curr_id, recv_date AS effective,\n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole \nFROM itemsite, recv\n  JOIN  toitem ON ((recv_orderitem_id=toitem_id)\n               AND (recv_order_type='TO'))\n  JOIN  tohead ON (toitem_tohead_id=tohead_id)\nWHERE ((recv_id=<? value("recv_id") ?>)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (toitem_item_id=itemsite_item_id))\n<? endif ?>;\n  admin   2011-11-23      0
115 57      itemReceipt     populateNew     used by enterPoitemReceipt -------PURCHASE ORDERS------------- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: itemReceipt\n-- Name: populateNew\n-- Notes: used by enterPoitemReceipt\n---------PURCHASE ORDERS-------------\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number AS order_number, poitem_linenumber AS orderitem_linenumber,\n       (poitem_itemsite_id > 0) AS inventoryitem,\n       COALESCE(poitem_itemsite_id, -1) AS itemsiteid,\n       COALESCE(poitem_vend_item_number, '') AS vend_item_number,\n       COALESCE(poitem_vend_uom, '') AS vend_uom,\n       COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip,\n       poitem_invvenduomratio AS orderitem_qty_invuomratio,\n       poitem_duedate AS duedate,\n       poitem_qty_ordered AS orderitem_qty_ordered,\n       poitem_qty_received AS qtyreceived,\n       poitem_qty_returned AS qtyreturned,\n       qtyToReceive('PO', poitem_id) AS qtytoreceive,\n       (poitem_qty_ordered - poitem_qty_received) AS receivable,\n       ( SELECT recv_notes\n           FROM recv\n          WHERE ((recv_orderitem_id=poitem_id)\n\t    AND  (recv_order_type='PO')\n            AND  (NOT recv_posted))\n\t  LIMIT 1 ) AS notes,\n       COALESCE(freightForRecv('PO', poitem_id, false),\n\t\tpoitem_freight - freightForRecv('PO', poitem_id, true),\n\t\tfreightForRecv('PO', poitem_id, true)) AS recv_freight,\n       pohead_curr_id AS curr_id, CURRENT_DATE AS effective, \n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole \nFROM pohead\n  JOIN poitem ON (pohead_id=poitem_pohead_id)\nWHERE ((poitem_status <> 'C')\n  AND  (poitem_id=<? value("orderitem_id") ?>)\n  AND  ('PO'=<? value("ordertype") ?>) )\n<? if exists ("EnableReturnAuth") ?>\nUNION\n---------RETURN AUTHORIZATIONS-------------\nSELECT rahead_number AS order_number, raitem_linenumber AS orderitem_linenumber,\n       (raitem_itemsite_id > 0) AS inventoryitem,\n       COALESCE(raitem_itemsite_id, -1) AS itemsiteid,\n       '' AS vend_item_number,\n       '' AS vend_uom,\n       '' AS vend_item_descrip,\n       raitem_qty_invuomratio AS orderitem_qty_invuomratio,\n       raitem_scheddate AS duedate,\n       raitem_qtyauthorized AS orderitem_qty_ordered,\n       raitem_qtyreceived AS qtyreceived,\n       0 AS qtyreturned,\n       qtyToReceive('RA', raitem_id) AS qtytoreceive,\n       (raitem_qtyauthorized - raitem_qtyreceived) AS receivable,\n       ( SELECT recv_notes\n           FROM recv\n          WHERE ((recv_orderitem_id=raitem_id)\n\t    AND  (recv_order_type='RA')\n            AND  (NOT recv_posted))\n\t  LIMIT 1 ) AS notes,\n       COALESCE(freightForRecv('RA', raitem_id, false),\n\t\tfreightForRecv('RA', raitem_id, true)) AS recv_freight,\n       rahead_curr_id AS curr_id, CURRENT_DATE AS effective, \n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole \nFROM rahead\n  JOIN raitem ON (rahead_id=raitem_rahead_id)\nWHERE ((raitem_status <> 'C')\n  AND  (raitem_id=<? value("orderitem_id") ?>)\n  AND  ('RA'=<? value("ordertype") ?>) )\n<? endif ?>\n<? if exists ("MultiWhs") ?>\nUNION\n-------------TRANSFER ORDERS--------------\nSELECT tohead_number AS order_number, toitem_linenumber AS orderitem_linenumber,\n       (itemsite_id > 0) AS inventoryitem,\n       COALESCE(itemsite_id, -1) AS itemsiteid,\n       '' AS vend_item_number,\n       '' AS vend_uom,\n       '' AS vend_item_descrip,\n       1 AS orderitem_qty_invuomratio,\n       toitem_duedate AS duedate,\n       toitem_qty_ordered AS orderitem_qty_ordered,\n       toitem_qty_received AS qtyreceived,\n       toitem_qty_shipped AS qtyreturned,\n       qtyToReceive('TO', toitem_id) AS qtytoreceive,\n       (toitem_qty_ordered - toitem_qty_received) AS receivable,\n       ( SELECT recv_notes\n           FROM recv\n          WHERE ((recv_orderitem_id=toitem_id)\n\t    AND  (recv_order_type='TO')\n            AND  (NOT recv_posted))\n\t  LIMIT 1 ) AS notes,\n       COALESCE(freightForRecv('TO', toitem_id, false),\n\t\tfreightForRecv('TO', toitem_id, true)) AS recv_freight,\n       baseCurrId() AS curr_id, CURRENT_DATE AS effective, \n       'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n       'qty' AS orderitem_qty_ordered_xtnumericrole, \n       'qty' AS qtyreceived_xtnumericrole, \n       'qty' AS qtyreturned_xtnumericrole, \n       'qty' AS qtytoreceive_xtnumericrole, \n       'qty' AS receivable_xtnumericrole \nFROM itemsite, tohead\n  JOIN toitem ON (tohead_id=toitem_tohead_id) \nWHERE ((toitem_status NOT IN ('C', 'X'))\n  AND  (toitem_id=<? value("orderitem_id") ?>)\n  AND  ('TO'=<? value("ordertype") ?>)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (toitem_item_id=itemsite_item_id))\n<? endif ?>;\n      admin   2011-11-23      0
116 58      itemReceipt     sourceItemSite  used by enterPoitemReceipt Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: itemReceipt\n-- Name: sourceItemSite\n-- Notes: used by enterPoitemReceipt\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("poitem_id") ?>\t\t\t-- this should never be called\n  SELECT -1 AS itemsite_id, -1 AS warehous_id;\n<? elseif exists("toitem_id") ?>\n  SELECT itemsite_id, tohead_dest_warehous_id AS warehous_id\n  FROM tohead, toitem, itemsite \n  WHERE ((itemsite_item_id=toitem_item_id)\n    AND  (itemsite_warehous_id=tohead_src_warehous_id)\n    AND  (toitem_tohead_id=tohead_id)\n    AND  (toitem_id=<? value("toitem_id") ?>));\n<? elseif exists("recv_id") ?>\t\t\t-- this should never be called\n  SELECT itemsite_id, tohead_dest_warehous_id AS warehous_id\n  FROM tohead, toitem, itemsite, recv\n  WHERE ((itemsite_item_id=toitem_item_id)\n    AND  (itemsite_warehous_id=tohead_src_warehous_id)\n    AND  (toitem_tohead_id=tohead_id)\n    AND  (toitem_id=recv_orderitem_id)\n    AND  (recv_id=<? value("recv_id") ?>));\n<? endif ?>\n admin   2011-11-23      0
117 258     items   detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: items\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n SELECT\n        <? if exists("ListNumericItemNumbersFirst") ?>\n         DISTINCT ON ( toNumeric(item_number, 999999999999999), item_number )\n        <? else ?>\n         DISTINCT ON ( item_number )\n        <? endif ?>\n               item.*, classcode.*, uom.*, prodcat.*, freightclass.*,\n               <? foreach("char_id_text_list") ?>\n                      charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>,\n               <? endforeach ?>\n               <? foreach("char_id_list_list") ?>\n                      charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>,\n               <? endforeach ?>\n               <? foreach("char_id_date_list") ?>\n                      charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>,\n               <? endforeach ?>\n                      (item_descrip1 || ' ' || item_descrip2) as item_descrip,\n                      CASE WHEN (item_type='P') THEN text(<? value("purchased") ?>)\n                           WHEN (item_type='M') THEN text(<? value("manufactured") ?>)\n                           WHEN (item_type='F') THEN text(<? value("phantom") ?>)\n                           WHEN (item_type='B') THEN text(<? value("breeder") ?>)\n                           WHEN (item_type='C') THEN text(<? value("coProduct") ?>)\n                           WHEN (item_type='Y') THEN text(<? value("byProduct") ?>)\n                           WHEN (item_type='R') THEN text(<? value("reference") ?>)\n                           WHEN (item_type='S') THEN text(<? value("costing") ?>)\n                           WHEN (item_type='T') THEN text(<? value("tooling") ?>)\n                           WHEN (item_type='A') THEN text(<? value("assortment") ?>)\n                           WHEN (item_type='O') THEN text(<? value("outside") ?>)\n                           WHEN (item_type='L') THEN text(<? value("planning") ?>)\n                           WHEN (item_type='K') THEN text(<? value("kit") ?>)\n                           ELSE text(<? value("error") ?>)\n                      END AS item_type_qtdisplayrole\n               FROM item\n                 JOIN classcode ON (item_classcode_id=classcode_id)\n                 JOIN uom ON (item_inv_uom_id=uom_id)\n                 LEFT OUTER JOIN prodcat ON (item_prodcat_id=prodcat_id)\n                 LEFT OUTER JOIN freightclass ON (item_freightclass_id=freightclass_id)\n               <? if exists("itemgrp_id") ?>\n                 JOIN itemgrpitem ON (item_id=itemgrpitem_item_id)\n                 JOIN itemgrp ON (itemgrp_id=itemgrpitem_itemgrp_id)\n               <? endif ?>\n               <? foreach("char_id_text_list") ?>\n                 LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n                   ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='I') \n                   AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=item_id)\n                   AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n                 LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n                   ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n               <? endforeach ?>\n               <? foreach("char_id_list_list") ?>\n                 LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n                   ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='I') \n                   AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=item_id)\n                   AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n                 LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n                   ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n               <? endforeach ?>\n               <? foreach("char_id_date_list") ?>\n                 LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n                   ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='I') \n                   AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=item_id)\n                   AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n                 LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n                   ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n               <? endforeach ?>\n               WHERE ( true\n               <? if exists("search_pattern") ?>\n                AND ( (item_number ~* <? value("search_pattern") ?>)\n                      OR  (item_descrip1 || item_descrip2 ~* <? value("search_pattern") ?>) )\n               <? endif ?>\n               <? if exists("showPurchased") ?>\n                AND (item_type IN ('P', 'O'))\n               <? elseif exists("showManufactured") ?>\n                AND (item_type IN ('M', 'F', 'B','K'))\n               <? elseif exists("showSold") ?>\n                AND (item_sold)\n               <? endif ?>\n               <? if exists("item_type") ?>\n                AND (item_type=<? value("item_type") ?>)\n               <? endif ?>\n               <? if not exists("showInactive") ?>\n                AND (item_active)\n               <? endif ?>\n               <? if exists("classcode_id") ?>\n                AND (item_classcode_id=<? value("classcode_id") ?>)\n               <? endif ?>\n               <? if exists("prodcat_id") ?>\n                AND (item_prodcat_id=<? value("prodcat_id") ?>)\n               <? endif ?>\n               <? if exists("freightclass_id") ?>\n                AND (item_freightclass_id=<? value("freightclass_id") ?>)\n               <? endif ?>\n               <? if exists("itemgrp_id") ?>\n                AND (itemgrp_id=<? value("itemgrp_id") ?>)\n               <? endif ?>\n               <? if exists("item_number_pattern") ?>\n                AND (item_number ~* <? value("item_number_pattern") ?>)\n               <? endif ?>\n               <? if exists("item_descrip_pattern") ?>\n                AND (item_descrip1 || item_descrip2 ~* <? value("item_descrip_pattern") ?>)\n               <? endif ?>\n               <? if exists("classcode_pattern") ?>\n                AND (classcode_code ~* <? value("classcode_pattern") ?>)\n               <? endif ?>\n               <? if exists("prodcat_pattern") ?>\n                AND (prodcat_code  ~* <? value("prodcat_pattern") ?>)\n               <? endif ?>\n               <? if exists("freightclass_pattern") ?>\n                AND (freightclass_code ~* <? value("freightclass_pattern") ?>)\n               <? endif ?>\n               <? literal("charClause") ?>\n               ) ORDER BY\n               <? if exists("ListNumericItemNumbersFirst") ?>\n                toNumeric(item_number, 999999999999999),\n               <? endif ?>\n                item_number;\n   admin   2011-11-23      0
118 259     itemSites       detail   Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: itemSites\n-- Name: detail\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id,warehous_code,itemsite_qtyonhand, itemsite_active, \n       CASE WHEN ( (itemsite_loccntrl) OR\n                   (itemsite_controlmethod IN ('L', 'S')) ) THEN 1\n            ELSE 0\n       END AS altId,\n       CASE WHEN itemsite_controlmethod='R' THEN <? value("regular") ?>\n                           WHEN itemsite_controlmethod='N' THEN <? value("none") ?>\n                           WHEN itemsite_controlmethod='L' THEN <? value("lot") ?>\n                           WHEN itemsite_controlmethod='S' THEN <? value("serial") ?>\n                      END AS controlmethod,\n         itemsite_loccntrl,\n         item_number,\n         (item_descrip1 || ' ' || item_descrip2) AS description, \n         uom_name,\n         CASE WHEN (itemsite_sold) THEN TEXT(itemsite_soldranking)\n         END AS soldranking,\n         CASE WHEN (itemsite_datelastcount=startOfTime()) THEN NULL\n           ELSE itemsite_datelastcount\n         END AS datelastcount,\n         CASE WHEN (itemsite_datelastused=startOfTime()) THEN NULL\n           ELSE itemsite_datelastused\n         END AS datelastused,\n         itemsite_abcclass, itemsite_cyclecountfreq,\n         'qty' AS itemsite_qtyonhand_xtnumericrole,\n        <? value("na") ?> AS soldranking_xtnullrole,\n        <? value("never") ?> AS datelastused_xtnullrole,\n        <? value("never") ?> AS datelastcount_xtnullrole             \nFROM item, uom, itemsite, warehous \nWHERE ((itemsite_warehous_id=warehous_id)\n         AND (itemsite_item_id=item_id)\n         AND(item_inv_uom_id=uom_id)\n       <? if exists("search_pattern") ?>\n         AND ((item_number ~* <? value("search_pattern") ?>)\n           OR (item_descrip1 || ' ' || item_descrip2 ~* <? value("search_pattern") ?>)\n           OR (warehous_code ~* <? value("search_pattern") ?>))\n       <? endif ?>\n       <? if exists("item_id") ?>\n         AND (item_id=<? value("item_id") ?>)\n       <? endif ?>\n       <? if exists("classcode_id") ?>\n         AND (item_classcode_id=<? value("classcode_id") ?>)\n       <? endif ?>\n       <? if exists("itemgrp_id") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id \n                          FROM itemgrpitem \n                          WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n       <? endif ?>\n       <? if exists("plancode_id") ?>\n         AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n       <? endif ?>\n       <? if exists("costcat_id") ?>\n         AND (itemsite_costcat_id=<? value("costcat_id") ?>)\n       <? endif ?>\n       <? if exists("classcode_pattern") ?>\n         AND (item_classcode_id IN (SELECT classcode_id \n                                    FROM classcode \n                                    WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n       <? endif ?>\n       <? if exists("itemgrp_pattern") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id \n                          FROM itemgrpitem, itemgrp \n                          WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) \n                              AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n       <? endif ?>\n       <? if exists("plancode_pattern") ?>\n         AND (itemsite_plancode_id IN (SELECT plancode_id \n                                       FROM plancode \n                                       WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n       <? endif ?>\n       <? if exists("costcat_pattern") ?>\n         AND (itemsite_costcat_id IN (SELECT costcat_id \n                                      FROM costcat \n                                      WHERE (costcat_code ~ <? value("costcat_pattern") ?>)))\n       <? endif ?>\n     <? if exists("warehous_id") ?>\n       AND (warehous_id=<? value("warehous_id") ?>)\n     <? endif ?>\n   <? if not exists("showInactive") ?>\n     AND (itemsite_active)\n   <? endif ?>\n       )\nORDER BY item_number, warehous_code;\n  admin   2011-11-23      0
119 260     itemSources     detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: itemSources\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsrc_id, \n       vend_name, \n       item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n       uom_name,\n       itemsrc.*, 'qty' AS itemsrc_invvendoruomratio_xtnumericrole \nFROM itemsrc JOIN vendinfo ON (vend_id=itemsrc_vend_id AND vend_active)\n             JOIN item ON (item_id=itemsrc_item_id)\n             JOIN uom ON (uom_id=item_inv_uom_id) \nWHERE ((true)\n<? if exists("onlyShowActive") ?>\n  AND (itemsrc_active)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsrc_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND (itemsrc_vend_id=<? value("vend_id") ?>)\n<? endif ?>\n)\n<? if exists("item_id") ?>\nORDER BY itemsrc_ranking, vend_name,\n         itemsrc_vend_item_number, itemsrc_manuf_name,\n         itemsrc_manuf_item_number\n<? else ?>\nORDER By item_number, vend_name\n<? endif ?>\n;\n  admin   2011-11-23      0
120 261     itemsWithoutItemSources detail  used by dspItemsWithoutItemSources Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: itemsWithoutItemSources\n-- Name: detail\n-- Notes: used by dspItemsWithoutItemSources\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       CASE WHEN (item_type = 'P') THEN <? value("purchased") ?>\n            WHEN (item_type = 'O') THEN <? value("outside") ?>\n       END AS type \nFROM item \nWHERE ( (item_type IN ('P', 'O'))\n    AND (item_active)\n    AND (item_id NOT IN (SELECT DISTINCT itemsrc_item_id\n                         FROM itemsrc \n                         WHERE (itemsrc_active))) ) \nORDER BY item_number;\n     admin   2011-11-23      0
121 59      maintainShipping        detail  used by maintainShipping order header info Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: maintainShipping\n-- Name: detail\n-- Notes: used by maintainShipping\n-- order header info\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT shiphead_id AS parent_id, cohead_id AS child_id,\n       shiphead_number, cohead_number AS linenumber,\n       'SO' AS ordertype,\n       CASE WHEN (shiphead_sfstatus='N') THEN <? value("notPrinted") ?>\n            WHEN (shiphead_sfstatus='D') THEN <? value("dirty") ?>\n            WHEN (shiphead_sfstatus='P') THEN <? value("printed") ?>\n            ELSE <? value("error") ?>\n       END AS sfstatus,\n       cust_number AS dest, cust_name AS description,\n       shiphead_shipvia, NULL AS uom_name,\n       NULL AS shipqty, NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       NULL AS f_shipqty, NULL AS f_shipvalue,\n<? endif ?>\n       cohead_holdtype AS holdtype,\n       shiphead_number AS shiphead_number_qtdisplayrole,\n       'SO' AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       0 AS xtindentrole,\n       CAST(shiphead_id AS TEXT) AS sort\nFROM shiphead, cust, cohead\n <? if exists("warehous_id") ?>\n      JOIN coitem ON (coitem_cohead_id=cohead_id)\n      JOIN itemsite ON ((coitem_itemsite_id=itemsite_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n AND (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n) \n-- order line info\nUNION ALL\nSELECT cohead_id AS parent_id, coitem_id AS child_id,\n       '' AS shiphead_number, CAST(coitem_linenumber AS TEXT) AS linenumber,\n       'SO' AS ordertype,\n       NULL AS sfstatus,\n       item_number AS dest, (item_descrip1 || ' ' || item_descrip2) AS description,\n       NULL AS shiphead_shipvia, uom_name,\n       qtyAtShipping('SO', coitem_id) AS shipqty,\n       valueAtShipping('SO', coitem_id) AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(qtyAtShipping('SO', coitem_id)) AS f_shipqty,\n       formatCost(valueAtShipping('SO', coitem_id)) AS f_shipvalue,\n<? endif ?>\n       cohead_holdtype AS holdtype,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       1 AS xtindentrole,\n       CAST(shiphead_id AS TEXT) || CAST(shiphead_order_id AS TEXT) || \n         TO_CHAR(coitem_id, '0000000') || '1' AS sort\nFROM shiphead, cohead, coitem, uom, itemsite, item\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n AND (shiphead_order_id=cohead_id)\n AND (cohead_id=coitem_cohead_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n <? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n) \n-- shipitem info\nUNION ALL\nSELECT shiphead_id AS parent_id, shipitem_id AS child_id,\n       '' AS shiphead_number, '' AS linenumber,\n       'SO' AS ordertype,\n       NULL AS sfstatus,\n       '' AS dest,\n       formatDate(shipitem_transdate) || ' by ' || shipitem_trans_username AS description,\n       '' AS shiphead_shipvia, '' AS uom_name,\n       shipitem_qty AS shipqty,\n       NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(shipitem_qty) AS f_shipqty,\n       NULL AS f_shipvalue,\n<? endif ?>\n       '' AS holdtype,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       2 AS xtindentrole,\n       CAST(shiphead_id AS TEXT) || CAST(shiphead_order_id AS TEXT) ||\n         TO_CHAR(shipitem_orderitem_id, '0000000') || '2' AS sort\nFROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n <? if exists("warehous_id") ?>\n      JOIN coitem ON ((shipitem_orderitem_id=coitem_id)\n                  AND (shiphead_order_type='SO'))\n      JOIN itemsite ON ((coitem_itemsite_id=itemsite_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n) \n\n<? if exists("MultiWhs") ?>\nUNION ALL\n-- order header info\nSELECT shiphead_id AS parent_id, tohead_id AS child_id,\n       shiphead_number, tohead_number AS linenumber,\n       'TO' AS ordertype,\n       CASE WHEN (shiphead_sfstatus='N') THEN <? value("notPrinted") ?>\n            WHEN (shiphead_sfstatus='D') THEN <? value("dirty") ?>\n            WHEN (shiphead_sfstatus='P') THEN <? value("printed") ?>\n            ELSE <? value("error") ?>\n       END AS sfstatus,\n       tohead_destname AS dest, tohead_destcntct_name AS description,\n       shiphead_shipvia, NULL AS uom_name,\n       NULL AS shipqty, NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       NULL AS f_shipqty, NULL AS f_shipvalue,\n<? endif ?>\n       'TO' AS holdtype,\n       shiphead_number AS shiphead_number_qtdisplayrole,\n       'TO' AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       0 AS xtindentrole,\n       CAST(shiphead_id AS TEXT) AS sort\nFROM shiphead, tohead\n <? if exists("warehous_id") ?>\n      JOIN toitem ON (toitem_tohead_id=tohead_id)\n      JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n AND (shiphead_order_id=tohead_id)\n) \n-- order line info\nUNION ALL\nSELECT tohead_id AS parent_id, toitem_id AS child_id,\n       '' AS shiphead_number, CAST(toitem_linenumber AS TEXT) AS linenumber,\n       'TO' AS ordertype,\n       NULL AS sfstatus,\n       item_number AS dest, (item_descrip1 || ' ' || item_descrip2) AS description,\n       NULL AS shiphead_shipvia, toitem_uom AS uom_name,\n       qtyAtShipping('TO', toitem_id) AS shipqty,\n       valueAtShipping('TO', toitem_id) AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(qtyAtShipping('TO', toitem_id)) AS f_shipqty,\n       formatCost(valueAtShipping('TO', toitem_id)) AS f_shipvalue,\n<? endif ?>\n       'TO' AS holdtype,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       1 AS xtindentrole,\n       CAST(shiphead_id AS TEXT) || CAST(shiphead_order_id AS TEXT) ||\n         TO_CHAR(toitem_id, '0000000') || '1' AS sort\nFROM shiphead, tohead, item, toitem\n <? if exists("warehous_id") ?>\n      JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n AND (shiphead_order_id=tohead_id)\n AND (tohead_id=toitem_tohead_id)\n AND (toitem_item_id=item_id)\n) \n-- shipitem info\nUNION\nSELECT shiphead_id AS parent_id, shipitem_id AS child_id,\n       '' AS shiphead_number, '' AS linenumber,\n       'TO' AS ordertype,\n       NULL AS sfstatus,\n       '' AS dest,\n       formatDate(shipitem_transdate) || ' by ' || shipitem_trans_username AS description,\n       '' AS shiphead_shipvia, '' AS uom_name,\n       shipitem_qty AS shipqty,\n       NULL AS shipvalue,\n<? if exists("includeFormatted") ?>\n       formatQty(shipitem_qty) AS f_shipqty,\n       NULL AS f_shipvalue,\n<? endif ?>\n       '' AS holdtype,\n       NULL AS shiphead_number_qtdisplayrole,\n       NULL AS ordertype_qtdisplayrole,\n       'qty' AS shipqty_xtnumericrole,\n       'cost' AS shipvalue_xtnumericrole,\n       0 AS shipvalue_xttotalrole,\n       2 AS xtindentrole,\n       CAST(shiphead_id AS TEXT) || CAST(shiphead_order_id AS TEXT) ||\n         TO_CHAR(shipitem_orderitem_id, '0000000') || '2' AS sort\nFROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n <? if exists("warehous_id") ?>\n      JOIN toitem ON ((shipitem_orderitem_id=toitem_id)\n                  AND (shiphead_order_type='TO'))\n      JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n                    AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n <? endif ?>\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n) \n\n<? endif ?>\nORDER BY sort;\n   admin   2011-11-23      0
122 60      manufacture     jobcosting      used by dspJobCosting Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: manufacture\n-- Name: jobcosting\n-- Notes: used by dspJobCosting\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, 0 AS cost_xttotalrole,\n       'qty' AS qty_xtnumericrole,\n       'cost' AS cost_xtnumericrole\nFROM (\n  SELECT womatl_id AS id, 3 AS sort,\n         <? value("material") ?> AS type, item_number AS code,\n         item_descrip1 AS descrip,\n         (SUM(COALESCE(invhist_invqty,0))) AS qty,\n         uom_name AS uom,\n         SUM(COALESCE(invhist_invqty * invhist_unitcost,0)) AS cost,\n         NULL as wooper_seqnumber\n  FROM womatl\n    LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n    LEFT OUTER JOIN invhist ON (womatlpost_invhist_id=invhist_id),\n    itemsite, item, uom\n  WHERE ((womatl_wo_id=<? value("wo_id") ?>)\n     AND (womatl_itemsite_id=itemsite_id)\n     AND (itemsite_item_id=item_id)\n     AND (item_inv_uom_id=uom_id))\n  GROUP BY womatl_id, item_number, item_descrip1, uom_name\n  ) AS data\nORDER BY sort, code;\n  admin   2011-11-23      0
123 451     metasqls        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: metasqls\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('byPackage') ?>\nSELECT metasql_id, metasql_group, metasql_name,\n       firstline(metasql_notes) AS metasql_notes, metasql_grade,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       CASE nspname WHEN 'public' THEN 0\n                                  ELSE 1 END AS xtindentrole,\n       metasql_notes AS metasql_notes_qttooltiprole \n  FROM metasql\n  JOIN pg_class     ON (metasql.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n UNION \nSELECT -1, pkghead_name, NULL,\n       firstline(pkghead_descrip), NULL,\n       pkghead_name, 0, pkghead_descrip\n  FROM metasql, pg_class, pg_namespace\n       RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n WHERE ((metasql.tableoid=pg_class.oid)\n    AND (relnamespace=pg_namespace.oid))\nORDER BY pkgname, xtindentrole, metasql_group, metasql_name,\n         metasql_grade DESC, metasql_id;\n<? else ?>\nSELECT metasql_id, metasql_group, metasql_name,\n       firstline(metasql_notes) AS metasql_notes,\n       metasql_grade,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       metasql_notes AS metasql_notes_qttooltiprole \n  FROM metasql\n  JOIN pg_class     ON (metasql.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY metasql_group, metasql_name,\n         metasql_grade DESC, metasql_id;\n <? endif ?>\n     admin   2011-11-23      0
124 262     mrpDetail       detail  used by dspMRPDetail Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: mrpDetail\n-- Name: detail\n-- Notes: used by dspMRPDetail\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT formatQty(itemsite_qtyonhand) AS f_qoh,itemsite_qtyonhand\n       , qtyAllocated(itemsite_id, findPeriodStart(<? value("cursorId") ?>),\n                       findPeriodEnd(<? value("cursorId") ?>)) AS allocations<? value("counter") ?>,\n       qtyOrdered(itemsite_id, findPeriodStart(<? value("cursorId") ?>),\n                       findPeriodEnd(<? value("cursorId") ?>)) AS orders<? value("counter") ?>,\n       qtyFirmedAllocated(itemsite_id, findPeriodStart(<? value("cursorId") ?>),\n                       findPeriodEnd(<? value("cursorId") ?>)) AS firmedallocations<? value("counter") ?>,\n       qtyFirmed(itemsite_id, findPeriodStart(<? value("cursorId") ?>),\n                       findPeriodEnd(<? value("cursorId") ?>)) AS firmedorders<? value("counter") ?>\nFROM itemsite\nWHERE (itemsite_id=<? value("itemsite_id") ?>);\n admin   2011-11-23      0
125 440     openVouchers    populate        used by openVouchers Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: openVouchers\n-- Name: populate\n-- Notes: used by openVouchers\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT vohead_id, COALESCE(pohead_id, -1), vohead_number,\n       COALESCE(TEXT(pohead_number), TEXT(<? value("misc") ?>)) AS ponumber,\n       (vend_number || '-' || vend_name) AS vendor, vendtype_code, vohead_invcnumber,\n       vohead_distdate, COALESCE(vohead_gldistdate, vohead_distdate) AS postdate,\n       vohead_amount, 'curr' AS vohead_amount_xtnumericrole,\n       formatDate(vohead_distdate) AS f_distdate,\n       formatDate(COALESCE(vohead_gldistdate, vohead_distdate)) AS f_postdate,\n       formatMoney(vohead_amount) AS f_amount\n  FROM vendinfo JOIN vendtype ON (vendtype_id=vend_vendtype_id)\n                JOIN vohead ON (vohead_vend_id=vend_id)\n                LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id) \n WHERE (NOT vohead_posted)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n AND (vendtype_code ~ <? value("vendtype_pattern") ?>)\n<? endif ?>\n ORDER BY vohead_number;\n \n  admin   2011-11-23      0
126 63      opportunities   detail  used by opportunityList Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: opportunities\n-- Name: detail\n-- Notes: used by opportunityList\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (incdtpriority_order, ophead_target_date, ophead_name, ophead_id) \n       ophead_id AS id,\n       ophead_number,\n       CASE WHEN (ophead_active) THEN 0 ELSE 1 END,\n       ophead_name,\n       ophead_active,\n       crmacct_number,\n       ophead_owner_username,\n       ophead_username,\n       opstage_name,\n       incdtpriority_name,\n       opsource_name,\n       optype_name,\n       (ophead_probability_prcnt * .01) AS ophead_probability_prcnt,\n       ophead_amount,\n       currConcat(ophead_curr_id) As f_currency,\n       ophead_target_date,\n       ophead_actual_date,\n       formatMoney(ophead_amount) AS f_amount,\n       formatDate(ophead_target_date) AS f_targetdate,\n       formatDate(ophead_actual_date) AS f_actualdate,\n       'extprice' AS ophead_amount_xtnumericrole,\n       'percent' AS ophead_probability_prcnt_xtnumericrole\n<? foreach("char_id_text_list") ?>\n  , charass_alias<? literal("char_id_text_list") ?>.charass_value AS char<? literal("char_id_text_list") ?>\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  , charass_alias<? literal("char_id_list_list") ?>.charass_value AS char<? literal("char_id_list_list") ?>\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  , charass_alias<? literal("char_id_date_list") ?>.charass_value::date AS char<? literal("char_id_date_list") ?>\n<? endforeach ?>\nFROM ophead()\n  LEFT OUTER JOIN incdtpriority ON (ophead_priority_id=incdtpriority_id)\n  LEFT OUTER JOIN crmacct ON (ophead_crmacct_id=crmacct_id)\n  LEFT OUTER JOIN opstage ON (ophead_opstage_id=opstage_id)\n  LEFT OUTER JOIN opsource ON (ophead_opsource_id=opsource_id)\n  LEFT OUTER JOIN optype ON (ophead_optype_id=optype_id)\n<? foreach("char_id_text_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='OPP') \n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=ophead_id)\n                                                                    AND  (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='OPP') \n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=ophead_id)\n                                                                    AND  (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n  LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='OPP') \n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=ophead_id)\n                                                                    AND  (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n  LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE((true)\n<? if exists("startDate") ?>\n   AND ((ophead_target_date >= <? value("startDate") ?>)\n    OR (<? value("startDate") ?> <= startOfTime()) AND (ophead_target_date IS NULL))\n<? endif ?>\n<? if exists("endDate") ?>\n   AND ((ophead_target_date <= <? value("endDate") ?>)\n    OR (<? value("endDate") ?> >= endOfTime()) AND (ophead_target_date IS NULL))\n<? endif ?>\n<? if exists("opsource_id") ?>\n   AND (ophead_opsource_id=<? value("opsource_id") ?>)\n<? endif ?>\n<? if exists("opsource_pattern") ?>\n   AND (opsource_name ~ <? value("opsource_pattern") ?>)\n<? endif ?>\n<? if exists("opstage_id") ?>\n   AND (ophead_opstage_id=<? value("opstage_id") ?>)\n<? endif ?>\n<? if exists("opstage_pattern") ?>\n   AND (opstage_name ~ <? value("opstage_pattern") ?>)\n<? endif ?>\n<? if exists("optype_id") ?>\n   AND (ophead_optype_id=<? value("optype_id") ?>)\n<? endif ?>\n<? if exists("optype_pattern") ?>\n   AND (optype_name ~ <? value("optype_pattern") ?>)\n<? endif ?>\n<? if exists("username") ?>\n   AND (<? value("username") ?> IN (ophead_username, ophead_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?>\n   AND (ophead_username=<? value("assigned_username") ?>)\n<? endif ?>\n<? if exists("assigned_usr_pattern") ?>\n   AND (ophead_username ~ <? value("assigned_usr_pattern") ?>)\n<? endif ?>\n<? if exists("owner_username") ?>\n   AND (ophead_owner_username=<? value("owner_username") ?>)\n<? endif ?>\n<? if exists("owner_usr_pattern") ?>\n   AND (ophead_owner_username ~ <? value("owner_usr_pattern") ?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n   AND (ophead_crmacct_id = <? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("search_pattern") ?> \n   AND (ophead_name ~* <? value("search_pattern") ?>)\n<? endif ?>\n<? if exists("activeOnly") ?> \n   AND (ophead_active)\n<? endif ?>\n<? if exists("id") ?>\n   AND (ophead_id=<? value("id") ?>\n<? endif ?>\n<? literal("charClause") ?>\n )\nORDER BY incdtpriority_order, ophead_target_date, ophead_name, ophead_id;\n        admin   2011-11-23      0
127 62      opportunitiesByCRM      detail  used by crmaccount Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: opportunitiesByCRM\n-- Name: detail\n-- Notes: used by crmaccount\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ophead_id, *,\n       currConcat(ophead_curr_id) AS ophead_currabbr,\n       'currval' AS ophead_amount_xtnumericrole\n  FROM ophead\n       LEFT OUTER JOIN crmacct ON (ophead_crmacct_id=crmacct_id)\n       LEFT OUTER JOIN opstage ON (ophead_opstage_id=opstage_id)\n       LEFT OUTER JOIN opsource ON (ophead_opsource_id=opsource_id)\n       LEFT OUTER JOIN optype ON (ophead_optype_id=optype_id)\n WHERE((crmacct_id=<? value("crmacct_id") ?>)\n<? if exists("username") ?>\n   AND (ophead_owner_username=<? value("username") ?>)\n<? elseif exists("usr_pattern") ?>\n   AND (ophead_owner_username ~ <? value("username_pattern") ?>)\n<? endif ?>\n )\n ORDER BY ophead_target_date;\n admin   2011-11-23      0
128 270     poDeliveryDateVariances detail  used by dspPoDeliveryDateVariancesByItem, dspPoDeliveryDateVariancesByVendor Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: poDeliveryDateVariances\n-- Name: detail\n-- Notes: used by dspPoDeliveryDateVariancesByItem, dspPoDeliveryDateVariancesByVendor\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT <? if exists("byItem") ?>\n         recv.*, vend_name,\n         firstLine(recv_vend_item_number) AS itemnumber,\n         firstLine(recv_vend_item_descrip) AS itemdescrip,\n         DATE(recv_rlsd_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS req_leadtime,\n         DATE(recv_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS agrd_leadtime,\n         DATE(recv_date) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS real_leadtime,\n         DATE(recv_date) - DATE(recv_rlsd_duedate) AS req_diff,\n\t DATE(recv_date) - DATE(recv_duedate) AS argd_diff,\n         DATE(recv_date) AS receivedate,\n         recv_rlsd_duedate AS release_duedate,  \n\t recv_duedate AS argd_duedate,\n         CASE WHEN (DATE(recv_date) - DATE(recv_rlsd_duedate) > 0) THEN 'error'\n              END AS req_diff_qtforegroundrole,\n         CASE WHEN (DATE(recv_date) - DATE(recv_duedate) > 0) THEN 'error'\n              END AS argd_diff_qtforegroundrole, \n\t CASE WHEN (DATE(recv_date) > DATE(recv_duedate)) THEN 'error'\t\t\t   \n              END AS receivedate_qtforegroundrole,\t\t\t  \n         'qty' AS recv_qty_xtnumericrole\n       <? elseif exists("byVendor") ?>\n         porecv_id, porecv_ponumber, vend_name,\n         DATE(porecv_date) AS receivedate,\n         firstLine(porecv_vend_item_number) AS venditemnumber,\n         firstLine(porecv_vend_item_descrip) AS venditemdescrip,\n         porecv_qty, porecv_duedate, porecv_date,\n         DATE(porecv_rlsd_duedate) - DATE(COALESCE(porecv_released, porecv_orderdate)) AS req_leadtime,  \n         DATE(porecv_duedate) - DATE(COALESCE(porecv_released, porecv_orderdate)) AS agrd_leadtime,\n\t DATE(porecv_date) - DATE(COALESCE(porecv_released, porecv_orderdate)) AS real_leadtime, \n\t DATE(porecv_date) - DATE(porecv_rlsd_duedate) AS req_diff, \n         DATE(porecv_date) - DATE(porecv_duedate) AS argd_diff, \n         porecv_rlsd_duedate AS release_duedate,  \n\t porecv_duedate AS argd_duedate,\n\t CASE WHEN (DATE(porecv_date) - DATE(porecv_rlsd_duedate) > 0) THEN 'error'\n              END AS req_diff_qtforegroundrole,\n\t CASE WHEN (DATE(porecv_date) - DATE(porecv_duedate) > 0) THEN 'error'\n              END AS argd_diff_qtforegroundrole,\n\t CASE WHEN (DATE(porecv_date) > DATE(porecv_duedate)) THEN 'error'\n              END AS receivedate_qtforegroundrole,\n         'qty' AS porecv_qty_xtnumericrole\n       <? endif ?>\n\nFROM vend,\n    <? if exists("byItem") ?>\n      itemsite, recv LEFT OUTER JOIN pohead ON (recv_order_number = pohead_number)\n    <? elseif exists("byVendor") ?>\n      porecv\n    <? endif ?>\nWHERE (\n<? if exists("byItem") ?>\n       (recv_vend_id=vend_id)\n  AND  (recv_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (recv_order_type='PO')\n  AND  (DATE(recv_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  <? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n  <? if exists("agentUsername") ?>\n    AND (recv_agent_username=<? value("agentUsername") ?>)\n  <? endif ?>\n<? elseif exists("byVendor") ?>\n      (porecv_vend_id=vend_id)\n  AND (vend_id=<? value("vend_id") ?>)\n  AND (DATE(porecv_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  <? if exists("warehous_id") ?>\n   AND (porecv_itemsite_id in (SELECT itemsite_id\n                               FROM itemsite\n                               WHERE (itemsite_warehous_id=<? value("warehous_id") ?>)))\n  <? endif ?>\n  <? if exists("selectedPurchasingAgent") ?>\n   AND (porecv_agent_username=<? value("username") ?>)\n  <? endif ?>\n<? endif ?>\n      )\nORDER BY\n<? if exists("byItem") ?>\n  recv_date DESC;\n<? elseif exists("byVendor") ?>\n  porecv_date DESC;\n<? endif ?>\n admin   2011-11-23      0
129 64      orders  detail  used by dspOrders Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: orders\n-- Name: detail\n-- Notes: used by dspOrders\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, type, order_type, order_number, duedate,\n       totalqty, relievedqty, balanceqty, balanceqty AS runningbalanceqty,\n       'qty' AS totalqty_xtnumericrole,\n       'qty' AS relievedqty_xtnumericrole,\n       'qty' AS balanceqty_xtnumericrole,\n       0 AS runningbalanceqty_xtrunningrole,\n       CASE WHEN (late) THEN 'error' END AS duedate_qtforegroundrole\nFROM\n(\nSELECT poitem_id AS source_id, 1 AS type, TEXT('P/O') AS order_type,\n       TEXT(pohead_number) AS order_number,\n       poitem_qty_ordered AS totalqty,\n       poitem_qty_received AS relievedqty,\n       noNeg(poitem_qty_ordered - poitem_qty_received) AS balanceqty,\n       poitem_duedate AS duedate,\n       (poitem_duedate < CURRENT_DATE) AS late\nFROM pohead, poitem, itemsite\nWHERE ((poitem_pohead_id=pohead_id)\n  AND  (poitem_status IN ('O','U'))\n  AND  (poitem_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? if exists("useLeadTime") ?>\n  AND  (poitem_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (poitem_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (poitem_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (poitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n       formatWONumber(wo_id) AS order_number,\n       wo_qtyord AS totalqty,\n       wo_qtyrcv AS relievedqty,\n       noNeg(wo_qtyord - wo_qtyrcv) AS balanceqty,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late \nFROM wo, itemsite\nWHERE ((wo_status<>'C')\n  AND  (wo_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (<? value("itemType") ?> NOT IN ('C', 'Y'))\n<? if exists("useLeadTime") ?>\n  AND  (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (wo_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (wo_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n\n-- Tooling is also supply on Work Orders\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n       formatWONumber(wo_id) AS order_number,\n       womatl_qtyreq AS totalqty,\n       COALESCE(sum(abs(invhist_invqty)),0) AS relievedqty,\n       noNeg(womatl_qtyreq - COALESCE(sum(abs(invhist_invqty)),0)) AS balanceqty,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late \nFROM womatl\n  JOIN wo ON (wo_id=womatl_wo_id)\n  JOIN itemsite ON (itemsite_id=womatl_itemsite_id)\n  JOIN item ON (item_id=itemsite_item_id)\n  LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n  LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n                          AND (invhist_invqty < 0))\nWHERE ((wo_status<>'C')\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (item_type = 'T')\n<? if exists("useLeadTime") ?>\n  AND  (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (wo_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (wo_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\nGROUP BY wo_id, womatl_qtyreq, wo_duedate\n\n<? if exists("Manufacturing") ?>\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n       formatWONumber(wo_id) AS order_number,\n       wo_qtyord AS totalqty,\n       wo_qtyrcv AS relievedqty,\n       noNeg(wo_qtyord - wo_qtyrcv) AS balanceqty,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late\nFROM wo, xtmfg.brddist, itemsite\nWHERE ((brddist_wo_id=wo_id)\n  AND  (wo_status<>'C')\n  AND  (brddist_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (<? value("itemType") ?> IN ('C', 'Y'))\n<? if exists("useLeadTime") ?>\n  AND (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND (wo_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND (wo_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n     )\n<? endif ?>\n\n<? if exists("Standard") ?>\nUNION\nSELECT toitem_id AS source_id, 3 AS type, TEXT('T/O') AS order_type,\n       TEXT(tohead_number) AS order_number,\n       toitem_qty_ordered AS totalqty,\n       toitem_qty_received AS relievedqty,\n       noNeg(toitem_qty_ordered - toitem_qty_received) AS balanceqty,\n       toitem_duedate AS duedate,\n       (toitem_duedate < CURRENT_DATE) AS late\nFROM tohead, toitem, itemsite\nWHERE ((toitem_tohead_id=tohead_id)\n  AND  (toitem_status='O')\n  AND  (toitem_item_id=itemsite_item_id)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? if exists("useLeadTime") ?>\n  AND  (toitem_duedate <= (CURRENT_DATE + itemsite_leadtime))\n<? elseif exists("days") ?>\n  AND  (toitem_duedate <= (CURRENT_DATE + <? value("days") ?>))\n<? elseif exists("date") ?>\n  AND  (toitem_duedate<=<? value("date") ?>)\n<? elseif exists("startDate") ?>\n  AND  (toitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n<? endif ?>\n\n) AS data\n\nORDER BY duedate;\n        admin   2011-11-23      0
130 111     package items   replace the not-so-old pkgitem table with direct query of catalogs and tables so we never miss anything and do not have to maintain the data TODO: is there a better sort order? Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: package\n-- Name:  items\n-- Notes: replace the not-so-old pkgitem table with direct query of catalogs\n--        and tables so we never miss anything and do not have to maintain the\n--        data\n-- TODO: is there a better sort order?\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n       CASE WHEN pkgitem_type='C' THEN <? value("script") ?>\n            WHEN pkgitem_type='D' THEN <? value("cmd") ?>\n            WHEN pkgitem_type='F' THEN <? value("function") ?>\n            WHEN pkgitem_type='G' THEN <? value("trigger") ?>\n            WHEN pkgitem_type='I' THEN <? value("image") ?>\n            WHEN pkgitem_type='M' THEN <? value("metasql") ?>\n            WHEN pkgitem_type='P' THEN <? value("priv") ?>\n            WHEN pkgitem_type='R' THEN <? value("report") ?>\n            WHEN pkgitem_type='S' THEN <? value("schema") ?>\n            WHEN pkgitem_type='T' THEN <? value("table") ?>\n            WHEN pkgitem_type='U' THEN <? value("uiform") ?>\n            WHEN pkgitem_type='V' THEN <? value("view") ?>\n            WHEN pkgitem_type='sequence' THEN <? value("sequence") ?>\n            WHEN pkgitem_type='index'    THEN <? value("index") ?>\n       ELSE pkgitem_type END AS pkgitem_type_qtdisplayrole\nFROM (\nSELECT script_id AS pkgitem_id, 'C' AS pkgitem_type,\n       script_id AS pkgitem_item_id,\n       script_name AS pkgitem_name,\n       script_notes AS pkgitem_descrip\n  FROM <? literal("pkgname") ?>.pkgscript \nUNION \nSELECT cmd_id AS pkgitem_id, 'D' AS pkgitem_type,\n       cmd_id AS pkgitem_item_id,\n       cmd_name AS pkgitem_name,\n       cmd_descrip AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgcmd \nUNION \nSELECT pg_proc.oid AS pkgitem_id, 'F' AS pkgitem_type,\n       pg_proc.oid AS pkgitem_item_id,\n       proname || '(' || oidvectortypes(proargtypes)\n               || ')' AS pkgitem_name,\n       pg_catalog.obj_description(pg_proc.oid, 'pg_proc') AS pkgitem_descrip \n  FROM pg_proc\n       JOIN pg_namespace ON (pronamespace=pg_namespace.oid)\n WHERE (nspname=<? value("pkgname") ?>) \nUNION \nSELECT t.oid AS pkgitem_id, 'G' AS pkgitem_type,\n       t.oid AS pkgitem_item_id,\n       tgname AS pkgitem_name,\n       pg_catalog.obj_description(t.oid, 'pg_trigger') AS pkgitem_descrip \n  FROM pg_trigger t\n       JOIN pg_class ON (tgrelid=pg_class.oid)\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>) \n<? if not exists("showsystemdetails") ?>\n    AND (tgconstraint = 0)\n   AND  (tgname !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)')\n<? endif ?>\n    )\nUNION \nSELECT image_id AS pkgitem_id, 'I' AS pkgitem_type,\n       image_id AS pkgitem_item_id,\n       image_name AS pkgitem_name,\n       image_descrip AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgimage \nUNION \nSELECT metasql_id AS pkgitem_id, 'M' AS pkgitem_type,\n       metasql_id AS pkgitem_item_id,\n       metasql_group || '-' || metasql_name AS pkgitem_name,\n       metasql_notes AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgmetasql \nUNION \nSELECT priv_id AS pkgitem_id, 'P' AS pkgitem_type,\n       priv_id AS pkgitem_item_id,\n       priv_module || '.' || priv_name AS pkgitem_name,\n       priv_descrip AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgpriv \nUNION \nSELECT report_id AS pkgitem_id, 'R' AS pkgitem_type,\n       report_id AS pkgitem_item_id,\n       report_name AS pkgitem_name,\n       report_descrip AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkgreport \nUNION \nSELECT n.oid AS pkgitem_id, 'S' AS pkgitem_type,\n       n.oid AS pkgitem_item_id,\n       nspname AS pkgitem_name,\n       pg_catalog.obj_description(n.oid, 'pg_namespace') AS pkgitem_descrip \n  FROM pg_namespace n\n WHERE (nspname=<? value("pkgname") ?>) \nUNION \nSELECT c.oid AS pkgitem_id, 'T' AS pkgitem_type,\n       c.oid AS pkgitem_item_id,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>)\n   AND  (relkind='r')\n<? if not exists("showsystemdetails") ?>\n   AND  (relname !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)$')\n<? endif ?>\n   )\nUNION \nSELECT uiform_id AS pkgitem_id, 'U' AS pkgitem_type,\n       uiform_id AS pkgitem_item_id,\n       uiform_name AS pkgitem_name,\n       uiform_notes AS pkgitem_descrip \n  FROM <? literal("pkgname") ?>.pkguiform \nUNION \nSELECT c.oid AS pkgitem_id, 'V' AS pkgitem_type,\n       c.oid AS pkgitem_item_id,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>)\n   AND  (relkind='v'))\n<? if exists("showsystemdetails") ?>\nUNION\nSELECT c.oid AS pkgitem_id, 'sequence' AS pkgitem_type,\n       c.oid AS pkgitem_item_id,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>)\n   AND  (relkind='S'))\nUNION\nSELECT c.oid AS pkgitem_id, 'index' AS pkgitem_type,\n       c.oid AS pkgitem_item_id,\n       relname AS pkgitem_name,\n       pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n  FROM pg_class c\n       JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=<? value("pkgname") ?>)\n   AND  (relkind='i'))\n<? endif ?>\n) AS pkgitem \nORDER BY pkgitem_type_qtdisplayrole, pkgitem_name;\n  admin   2011-11-23      0
131 67      packingListBatch        detail  used by packingListBatch Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: packingListBatch\n-- Name: detail\n-- Notes: used by packingListBatch\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, pack_shiphead_id, \n       cohead_number AS order_number, pack_head_type,\n       cohead_shipvia AS shipvia,\n       formatShipmentNumber(pack_shiphead_id) AS shipment_number, \n       cust_number AS number, cohead_billtoname AS name,\n       CASE WHEN (cohead_holdtype='N') THEN <? value("none") ?>\n            WHEN (cohead_holdtype='C') THEN <? value("credit") ?>\n            WHEN (cohead_holdtype='S') THEN <? value("ship") ?>\n            WHEN (cohead_holdtype='P') THEN <? value("pack") ?>\n            WHEN (cohead_holdtype='R') THEN <? value("return") ?>\n            ELSE <? value("other") ?>\n       END AS f_holdtype,\n       pack_printed\nFROM pack, cohead, cust \nWHERE pack_head_id=cohead_id \n  AND  cohead_cust_id=cust_id \n  AND  pack_head_type='SO' \n<? if exists("MultiWhs") ?>\n  AND  checkSOSitePrivs(cohead_id)\nUNION \nSELECT tohead_id, pack_shiphead_id, \n       tohead_number AS order_number, pack_head_type,\n       tohead_shipvia AS shipvia,\n       formatShipmentNumber(pack_shiphead_id) AS shipment_number, \n       tohead_destname AS number, tohead_destcntct_name AS name,\n       '' AS f_holdtype,\n       pack_printed\nFROM pack, tohead \nWHERE ((pack_head_id=tohead_id)\n  AND  (pack_head_type='TO')) \n<? endif ?>\nORDER BY 3;\n   admin   2011-11-23      0
132 68      packingListBatch        print   used by packingListBatch Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: packingListBatch\n-- Name: print\n-- Notes: used by packingListBatch\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pack_id, pack_head_id, pack_head_type, pack_shiphead_id,\n       COALESCE(shipform_report_name, findCustomerForm(cohead_cust_id, 'P')) AS packform,\n       findCustomerForm(cohead_cust_id, 'L') AS pickform \nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n          LEFT OUTER JOIN shipform ON (shipform_id=cohead_shipform_id)\nWHERE ((checkSOSitePrivs(cohead_id))\n  AND  (pack_head_type='SO')\n  AND  (NOT pack_printed) ) \n<? if exists("MultiWhs") ?>\nUNION \nSELECT pack_id, pack_head_id, pack_head_type, pack_shiphead_id,\n       COALESCE(shipform_report_name, findTOForm(tohead_id, 'P')) AS packform,\n       findTOForm(tohead_id, 'L') AS pickform \nFROM pack JOIN tohead ON (tohead_id=pack_head_id)\n          LEFT OUTER JOIN shipform ON (shipform_id=tohead_shipform_id)\nWHERE ((pack_head_type='TO')\n  AND  (NOT pack_printed))\n<? endif ?>\n;\n      admin   2011-11-23      0
133 65      packingListBatchByShipVia       print   used by printPackingListBatchByShipVia Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: packingListBatchByShipVia\n-- Name: print\n-- Notes: used by printPackingListBatchByShipVia\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT pack_head_id, pack_head_type, pack_shiphead_id, getSoStatus(cohead_id) AS orderhead_status,\n       COALESCE(shipform_report_name, findCustomerForm(cohead_cust_id, 'P')) AS packform,\n       findCustomerForm(cohead_cust_id, 'L') AS pickform\nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n          JOIN coitem ON (coitem_cohead_id = cohead_id) \n          LEFT OUTER JOIN shipform ON (shipform_id=cohead_shipform_id)\nWHERE ( (NOT pack_printed)\n  AND   (pack_head_type='SO')\n  AND   (getSoStatus(cohead_id) <> 'C') \n  AND   (cohead_shipvia=<? value("shipvia") ?>)\n  AND   (checkSOSitePrivs(cohead_id))\n  AND\t(coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n\n<? if exists("MultiWhs") ?>\nUNION ALL\nSELECT DISTINCT pack_head_id, pack_head_type, pack_shiphead_id, tohead_status AS orderhead_status,\n       COALESCE(shipform_report_name, findTOForm(tohead_id, 'P')) AS packform,\n       findTOForm(tohead_id, 'L') AS pickform\nFROM pack JOIN tohead ON (tohead_id=pack_head_id)\n          JOIN toitem ON (toitem_tohead_id = tohead_id) \n          LEFT OUTER JOIN shipform ON (shipform_id=tohead_shipform_id)\nWHERE ( (NOT pack_printed)\n  AND   (pack_head_type='TO')\n  AND   (tohead_status <> 'C') \n  AND   (tohead_shipvia=<? value("shipvia") ?>)\n  AND\t(toitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n<? endif ?>\n\n;\n admin   2011-11-23      0
134 66      packingListBatchByShipVia       shipVia used by printPackingListBatchByShipVia Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: packingListBatchByShipVia\n-- Name: shipVia\n-- Notes: used by printPackingListBatchByShipVia\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT max(id), shipvia\nFROM (\nSELECT max(cohead_id) AS id, cohead_shipvia AS shipvia\nFROM pack, cohead, coitem\nWHERE ( (NOT pack_printed)\n  AND   (cohead_id=pack_head_id)\n  AND   (pack_head_type='SO')\n  AND   (coitem_cohead_id=cohead_id)\n  AND   (coitem_status='O') )\nGROUP BY cohead_shipvia\n<? if exists("MultiWhs") ?>\nUNION\nSELECT max(tohead_id) AS id, tohead_shipvia AS shipvia\nFROM pack, tohead\nWHERE ( (NOT pack_printed)\n  AND   (tohead_status = 'O')\n  AND   (tohead_id=pack_head_id)\n  AND   (pack_head_type='TO') )\nGROUP BY tohead_shipvia\n<? endif ?>\n) data\nGROUP BY shipvia\nORDER BY shipvia\n    admin   2011-11-23      0
135 267     partiallyShippedOrders  detail  used by dspPartiallyShippedOrders Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: partiallyShippedOrders\n-- Name: detail\n-- Notes: used by dspPartiallyShippedOrders\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT CASE WHEN (cohead_holdtype IN ('P', 'C', 'R')) THEN -1\n         ELSE cohead_id\n       END AS _coheadid, cohead_id,\n       cohead_holdtype, cohead_number, cust_name,\n       CASE WHEN (cohead_holdtype='N') THEN <? value("none") ?>\n            WHEN (cohead_holdtype='C') THEN <? value("credit") ?>\n            WHEN (cohead_holdtype='S') THEN <? value("ship") ?>\n            WHEN (cohead_holdtype='P') THEN <? value("pack") ?>\n            WHEN (cohead_holdtype='R') THEN <? value("return") ?>\n         ELSE <? value("other") ?>\n       END AS f_holdtype,\n       cohead_orderdate,\n       (MIN(coitem_scheddate)) AS minscheddate,\n       cohead_packdate,\n       SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                  (coitem_price / coitem_price_invuomratio) ) AS extprice,\n       currConcat(cohead_curr_id) AS currAbbr,\n       SUM(currToBase(cohead_curr_id,\n          (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n          (coitem_price / coitem_price_invuomratio),\n          CURRENT_DATE)) AS extprice_base,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS extprice_base_xtnumericrole,\n       <? if exists("singlecurrency") ?>\n         0 AS extprice_xttotalrole \n       <? else ?>\n         0 AS extprice_base_xttotalrole \n       <? endif ?>\nFROM cohead, itemsite, item, cust, coitem \nWHERE ( (coitem_cohead_id=cohead_id)\n    AND (cohead_cust_id=cust_id)\n    AND (coitem_itemsite_id=itemsite_id)\n    AND (itemsite_item_id=item_id)\n    AND (coitem_status='O')\n    AND (cohead_id IN ( SELECT DISTINCT coitem_cohead_id\n                        FROM coitem\n                        WHERE (coitem_qtyshipped > 0) ))\n    AND (coitem_qtyshipped < coitem_qtyord)\n    AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n                              AND <? value("endDate") ?>)\n    <? if exists("warehous_id") ?>\n      AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n    <? endif ?>\n      ) \nGROUP BY cohead_id, cohead_number, cust_name,\n         cohead_holdtype, cohead_orderdate, cohead_packdate,\n         cohead_curr_id \nORDER BY minscheddate, cohead_number;\n       admin   2011-11-23      0
136 286     summarizedBankrecHistory        detail  used by dspSummarizedBankrecHistory Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: summarizedBankrecHistory\n-- Name: detail\n-- Notes: used by dspSummarizedBankrecHistory\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT bankrec_posted, bankrec_postdate,\n       bankrec_username, bankrec_opendate,\n       bankrec_enddate, bankrec_openbal, bankrec_endbal,\n       'curr' AS bankrec_openbal_xtnumericrole,\n       'curr' AS bankrec_endbal_xtnumericrole\nFROM bankrec\nWHERE (bankrec_bankaccnt_id=<? value("bankaccntid") ?>)\nORDER BY bankrec_created;\n       admin   2011-11-23      0
137 269     pendingBOMChanges       detail  used by dspPendingBOMChanges Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: pendingBOMChanges\n-- Name: detail\n-- Notes: used by dspPendingBOMChanges\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT bomitem_id, actiondate, action,\n       bomitem_seqnumber, item_number, description,\n       uom_name, qtyfxd, qtyper,\n       bomitem_scrap, actiondate,\n       'qty' AS qtyfxd_xtnumericrole,\n       'qtyper' AS qtyper_xtnumericrole,\n       'percent' AS bomitem_scrap_xtnumericrole \nFROM (SELECT bomitem_id, <? value("effective") ?> AS action,\n             bomitem_seqnumber, item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n             uom_name,\n             itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd) AS qtyfxd,\n             itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper) AS qtyper,\n             bomitem_scrap, bomitem_effective AS actiondate \n      FROM bomitem(<? value("item_id") ?>,<? value("revision_id") ?>), item, uom \n      WHERE ((bomitem_item_id=item_id)\n         AND (item_inv_uom_id=uom_id)\n         AND (bomitem_effective BETWEEN CURRENT_DATE AND <? value("cutOffDate") ?>)) \n      UNION \n      SELECT bomitem_id, <? value("expires") ?> AS action, \n             bomitem_seqnumber, item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n             uom_name,\n             itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd) AS qtyfxd,\n             itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper) AS qtyper,\n             bomitem_scrap, bomitem_expires AS actiondate \n      FROM bomitem(<? value("item_id") ?>,<? value("revision_id") ?>), item, uom \n      WHERE ((bomitem_item_id=item_id)\n         AND (item_inv_uom_id=uom_id)\n       <? if exists("cutOffDate") ?>\n         AND (bomitem_expires BETWEEN CURRENT_DATE AND <? value("cutOffDate") ?>) )\n       <? endif ?> \n     ) AS data \nORDER BY action, actiondate, bomitem_seqnumber;\n  admin   2011-11-23      0
138 271     poHistory       detail  used by dspPoHistory Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: poHistory\n-- Name: detail\n-- Notes: used by dspPoHistory\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poitem_id, poitem.*,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS itemnumber,\n       COALESCE(uom_name, <? value("na") ?>) AS uomname,\n       CASE WHEN (LENGTH(TRIM(BOTH '    ' FROM poitem_vend_item_descrip)) <= 0)\n            THEN(item_descrip1 || ' ' || item_descrip2)\n         ELSE poitem_vend_item_descrip\n       END AS itemdescription,\n       'qty' AS poitem_qty_ordered_xtnumericrole,\n       'qty' AS poitem_qty_received_xtnumericrole,\n       'qty' AS poitem_qty_returned_xtnumericrole\nFROM poitem LEFT OUTER JOIN\n     ( itemsite JOIN item\n       ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id))\n       ON (poitem_itemsite_id=itemsite_id)\nWHERE (poitem_pohead_id=<? value("pohead_id") ?>)\nORDER BY poitem_linenumber;\n  admin   2011-11-23      0
139 272     poItems detail  used by dspPoItemsByVendor, dspPoItemsByItem, dspPoItemsByDate Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: poItems\n-- Name: detail\n-- Notes: used by dspPoItemsByVendor, dspPoItemsByItem, dspPoItemsByDate\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, poitem_id, pohead_number, poitem_status,\n       CASE WHEN(poitem_status='C') THEN <? value("closed") ?>\n            WHEN(poitem_status='U') THEN <? value("unposted") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) \n                                   AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) \n            THEN <? value("partial") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) \n                                   AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) \n            THEN <? value("received") ?>\n            WHEN(poitem_status='O') THEN <? value("open") ?>\n         ELSE poitem_status\n       END AS f_poitem_status,\n       vend_name,\n       (SELECT warehous_code\n          FROM whsinfo\n         WHERE (COALESCE(itemsite_warehous_id, pohead_warehous_id)=warehous_id)) AS warehous_code,\n       COALESCE(item_number, <? value("nonInv") ?>) AS itemnumber,\n       poitem_vend_item_number, poitem_vend_uom,\n       COALESCE(item_descrip1, firstLine(poitem_vend_item_descrip)) AS itemdescrip,\n       COALESCE(uom_name, poitem_vend_uom) AS itemuom,\n       poitem_duedate, poitem_qty_ordered, poitem_qty_received, poitem_qty_returned,\n       CASE WHEN (poitem_duedate < CURRENT_DATE) THEN 'error' END AS poitem_duedate_qtforegroundrole,\n       'qty' AS poitem_qty_ordered_xtnumericrole,\n       'qty' AS poitem_qty_received_xtnumericrole,\n       'qty' AS poitem_qty_returned_xtnumericrole \n  FROM pohead\n  JOIN poitem   ON (pohead_id=poitem_pohead_id)\n  JOIN vendinfo ON (pohead_vend_id=vend_id)\n  LEFT OUTER JOIN (itemsite\n                   JOIN item ON (itemsite_item_id=item_id)\n                   JOIN uom ON (item_inv_uom_id=uom_id))\n         ON (poitem_itemsite_id=itemsite_id)\nWHERE (TRUE\n<? if exists("byDate") ?>\n   AND (poitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND (((itemsite_id IS NULL) AND\n        (pohead_warehous_id=<? value("warehous_id") ?>) )\n       OR\n       ((itemsite_id IS NOT NULL) AND\n        (itemsite_warehous_id=<? value("warehous_id") ?>) ) )\n<? endif ?>\n<? if exists("agentUsername") ?>\n   AND (pohead_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if exists("openItems") ?>\n   AND (poitem_status='O')\n<? endif ?>\n<? if exists("closedItems") ?>\n   AND (poitem_status='C')\n<? endif ?>\n<? if exists("poNumber") ?>\n  AND (pohead_number=<? value("poNumber") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n  AND (pohead_vend_id=<? value("vend_id") ?>) \n<? elseif exists("vendtype_id") ?>\n  AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND (vend_vendtype_id IN (SELECT vendtype_id\n                              FROM vendtype\n                             WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsite_item_id=<? value("item_id") ?>) \n<? endif ?>\n      )\nORDER BY poitem_duedate, pohead_number, poitem_linenumber\n;\n   admin   2011-11-23      0
140 432     poItems list    used by purchaseOrder Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: poItems\n-- Name: list\n-- Notes: used by purchaseOrder\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poitem.*,\n       CASE WHEN(poitem_status='C') THEN <? value("closed") ?>\n            WHEN(poitem_status='U') THEN <? value("unposted") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN <? value("partial") ?>\n            WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) THEN <? value("received") ?>\n            WHEN(poitem_status='O') THEN <? value("open") ?>\n            ELSE poitem_status\n       END AS poitemstatus,\n       CASE WHEN (COALESCE(pohead_cohead_id, -1) != -1) THEN <? value("so") ?>\n            WHEN (COALESCE(poitem_wohead_id, -1) != -1) THEN <? value("wo") ?>\n            ELSE ''\n       END AS demand_type,\n       CASE WHEN (COALESCE(pohead_cohead_id, -1) != -1) THEN cohead_number || '-' || coitem_linenumber\n            WHEN (COALESCE(poitem_wohead_id, -1) != -1) THEN formatwonumber(poitem_wohead_id)\n            ELSE ''\n       END AS order_number,\n       CASE WHEN (itemsite_id IS NULL) THEN poitem_vend_item_number\n            ELSE item_number\n       END AS item_number,\n       CASE WHEN (itemsite_id IS NULL) THEN firstLine(poitem_vend_item_descrip)\n            ELSE (item_descrip1 || ' ' || item_descrip2)\n       END AS item_descrip,\n       poitem_rlsd_duedate AS orgl_duedate,\n       (poitem_unitprice * poitem_qty_ordered) AS extprice,\n       'qty' AS poitem_qty_ordered_xtnumericrole,\n       'qty' AS poitem_qty_received_xtnumericrole,\n       'qty' AS poitem_qty_returned_xtnumericrole,\n       'qty' AS poitem_qty_vouchered_xtnumericrole,\n       'purchprice' AS poitem_unitprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS poitem_freight_xtnumericrole,\n       'curr' AS poitem_freight_received_xtnumericrole,\n       'curr' AS poitem_freight_vouchered_xtnumericrole,\n       'curr' AS poitem_stdcost_xtnumericrole\nFROM pohead JOIN poitem  ON (poitem_pohead_id=pohead_id)\n            LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n            LEFT OUTER JOIN item     ON (itemsite_item_id=item_id)\n            LEFT OUTER JOIN coitem   ON (poitem_soitem_id = coitem_id)\n            LEFT OUTER JOIN cohead   ON (cohead_id = coitem_cohead_id)\nWHERE (poitem_pohead_id=<? value("pohead_id") ?>)\nORDER BY poitem_linenumber;\n  admin   2011-11-23      0
141 130     poPriceVariances        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: poPriceVariances\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\n<? if exists("includeFormatted") ?>,\n  formatDate(distdate)        AS f_date,\n  formatQty(porecv_qty)       AS f_qty,\n  formatCost(porecv_recvcost) AS f_porecv_recvcost,\n  formatMoney(porecv_value)   AS f_porecv_value,\n  formatPrice(vouchercost)    AS f_vouchercost,\n  formatMoney(voucher_value)  AS f_voucher_value,\n  formatMoney(variance)       AS f_variance, \n  formatPrcnt(varprcnt/100)       AS f_varprcnt\n<? endif ?>\n FROM (\nSELECT porecv_id, porecv_ponumber, porecv_date,\n  DATE(porecv_date) AS receivedate,\n  vohead_distdate AS distdate,\n  vend_number, vend_name,\n  COALESCE(item_number, (<? value("nonInv") ?> || porecv_vend_item_number)) AS itemnumber,\n  firstLine(COALESCE(item_descrip1, porecv_vend_item_descrip)) AS itemdescrip,\n  porecv_qty, \n  porecv_purchcost, \n  currConcat(porecv_curr_id) AS poCurrAbbr,\n<? if exists("baseCurr") ?>\n  COALESCE((porecv_value / CASE WHEN (porecv_qty <> 0.0) THEN porecv_qty ELSE 1.0 END), 0.0) AS porecv_recvcost,\n  COALESCE(porecv_value, 0.0) AS porecv_value,\n  COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate), 0.0) AS vouchercost,\n  COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) * porecv_qty, 0.0) AS voucher_value,\n  COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) * porecv_qty - porecv_value, 0.0) AS variance, \n  CASE WHEN (COALESCE(porecv_value, 0.0) <> 0.0) THEN\n    ((currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) *\n     porecv_qty / porecv_value) -1.0) * 100.0\n       ELSE 100.0 END AS varprcnt,     \n  currConcat(baseCurrId()) AS currAbbr,\n  '0' AS porecv_value_xttotalrole,\n  '0' AS voucher_value_xttotalrole,\n  '0' AS variance_xttotalrole,\n<? else ?> -- local Currency\n  COALESCE(currToLocal(vohead_curr_id, (porecv_value / CASE WHEN (porecv_qty <> 0.0) THEN porecv_qty ELSE 1.0 END), vohead_distdate), 0.0) AS porecv_recvcost,\n  COALESCE(currToLocal(vohead_curr_id, porecv_value, vohead_distdate), 0.0) AS porecv_value, \n  COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, 0.0)  AS vouchercost,\n  COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END * porecv_qty, 0.0) AS voucher_value,\n  COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END * porecv_qty - currToLocal(vohead_curr_id, porecv_value, vohead_distdate), 0.0) AS variance, \n  CASE WHEN (COALESCE(porecv_value, 0.0) <> 0.0) THEN\n    ((SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END *\n     porecv_qty / currToLocal(vohead_curr_id, porecv_value, vohead_distdate)) -1.0) * 100.0\n       ELSE 100.0 END AS varprcnt,       \n  currConcat(vohead_curr_id) AS currAbbr,\n<? endif ?>\n  'qty' AS porecv_qty_xtnumericrole,\n  'purchprice' AS porecv_purchcost_xtnumericrole,\n  'curr' AS porecv_value_xtnumericrole,\n  'purchprice' AS vouchercost_xtnumericrole,\n  'curr' AS  voucher_value_xtnumericrole,\n  'cost' AS porecv_recvcost_xtnumericrole,\n  'curr' AS variance_xtnumericrole,\n  'prcnt' AS varprcnt_xtnumericrole\nFROM vendinfo\n  JOIN vendtype ON (vend_vendtype_id=vendtype_id), porecv\n  LEFT OUTER JOIN (\n    itemsite JOIN item ON (itemsite_item_id=item_id) )\n    ON (porecv_itemsite_id=itemsite_id)\n  JOIN vodist ON ((vodist_poitem_id=porecv_poitem_id) \n              AND (vodist_vohead_id=porecv_vohead_id))\n  JOIN vohead ON ((vodist_vohead_id=vohead_id) \n              AND (vohead_posted))\nWHERE ( (porecv_vend_id=vend_id)\n<? if exists("vend_id") ?>\n  AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n  AND (vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n  AND (vendtype_code ~ <? value("vendtype_pattern") ?>)\n<? endif ?>\n  AND (DATE(vohead_distdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) \n<? if exists("MultiWhs") ?>\n  AND (itemsite_warehous_id=<? value("MultiWhs") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n  AND (porecv_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n )\nGROUP BY porecv_id, porecv_ponumber, porecv_date, item_number, porecv_vend_item_number,\n         item_descrip1, porecv_vend_item_descrip, porecv_qty, porecv_purchcost, porecv_recvcost,\n         vohead_curr_id, porecv_curr_id, vohead_docdate, vend_number, vend_name,\n         porecv_value, vohead_distdate\n) data\n<? if exists("notZero") ?>\nWHERE (variance != 0)\n<? endif ?>\nORDER BY distdate, porecv_ponumber DESC;\n     admin   2011-11-23      0
142 273     poReturns       detail  used by dspPoReturnsByVendor Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: poReturns\n-- Name: detail\n-- Notes: used by dspPoReturnsByVendor\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poreject_id, poreject_ponumber, vend_name,\n       poreject_date, poreject_qty,\n       poreject_vend_item_number, poreject_vend_item_descrip,\n       rjctcode_code,\n       'qty' AS poreject_qty_xtnumericrole \nFROM poreject, vend, itemsite, rjctcode\nWHERE ((poreject_posted)\n   AND (poreject_vend_id=vend_id)\n   AND (poreject_rjctcode_id=rjctcode_id)\n   AND (poreject_itemsite_id=itemsite_id)\n   AND (vend_id=<? value("vend_id") ?>)\n   AND (DATE(poreject_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("username") ?>\n   AND (poreject_agent_username=<? value("username") ?>)\n<? endif ?>\n      ) \nORDER BY poreject_date DESC;\n  admin   2011-11-23      0
143 441     postCountTags   post     Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: postCountTags\n-- Name:  post\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT MIN(postCountTag(invcnt_id, <? value('thaw') ?>)) AS result\n  FROM invcnt, itemsite, item\n WHERE ((invcnt_itemsite_id=itemsite_id)\n    AND (invcnt_qoh_after IS NOT NULL)\n    AND (NOT invcnt_posted)\n    AND (itemsite_item_id=item_id)\n<? if exists('warehous_id') ?>\n    AND (itemsite_warehous_id=<? value('warehous_id') ?>)\n<? endif ?>\n\n<? if exists('classcode_id') ?>\n    AND (item_classcode_id=<? value('classcode_id') ?>)\n<? elseif exists('classcode_pattern') ?>\n    AND (item_classcode_id IN (SELECT classcode_id\n                                 FROM classcode\n                                WHERE (classcode_code ~ <? value('classcode_pattern') ?>)))\n<? elseif exists('plancode_id') ?>\n    AND (itemsite_plancode_id=<? value('plancode_id') ?>)\n<? elseif exists('plancode_pattern') ?>\n    AND (itemsite_plancode_id IN (SELECT plancode_id\n                                    FROM plancode\n                                   WHERE (plancode_code ~ <? value('plancode_pattern') ?>)))\n<? endif ?>\n);\n  admin   2011-11-23      0
144 79      reservations    detail  used by dspReservations Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: reservations\n-- Name: detail\n-- Notes: used by dspReservations\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, order_number, scheddate,\n       totalqty, relievedqty, reservedqty, balanceqty,\n       CASE WHEN (scheddate < CURRENT_DATE) THEN 'error' END AS scheddate_qtforegroundrold,\n       'qty' AS totalqty_xtnumericrole,\n       'qty' AS relievedqty_xtnumericrole,\n       'qty' AS reservedqty_xtnumericrole,\n       'qty' AS balanceqty_xtnumericrole,\n       0 AS balanceqty_xtrunningrole,\n       level AS xtindentrole\nFROM (\nSELECT coitem_scheddate AS sortkey, 0 AS level, coitem_id AS source_id,\n       formatSoNumber(coitem_id) AS order_number,\n       (coitem_qtyord * coitem_qty_invuomratio) AS totalqty,\n       ((coitem_qtyshipped + qtyAtShipping(coitem_id) - coitem_qtyreturned) * coitem_qty_invuomratio) as relievedqty,\n       (coitem_qtyreserved * coitem_qty_invuomratio) AS reservedqty,\n       (coitem_qtyreserved * coitem_qty_invuomratio) AS balanceqty,\n       coitem_scheddate AS scheddate\nFROM cohead, coitem, itemsite, item \nWHERE((coitem_cohead_id=cohead_id)\n  AND (coitem_itemsite_id=itemsite_id)\n  AND (coitem_qtyreserved > 0)\n  AND (itemsite_item_id=item_id)\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND (itemsite_item_id=<? value("item_id") ?>))\nUNION\nSELECT coitem_scheddate AS sortkey, 1 AS level, coitem_id AS source_id,\n      (formatLocationName(itemloc_location_id) || ' ' || formatLotSerialNumber(itemloc_ls_id)) AS order_number,\n       NULL AS totalqty, NULL AS relievedqty,\n       (itemlocrsrv_qty * coitem_qty_invuomratio) AS reservedqty,\n       NULL AS balanceqty, NULL AS scheddate\nFROM itemlocrsrv, itemloc, coitem, itemsite\nWHERE ( (itemloc_id=itemlocrsrv_itemloc_id)\n  AND (coitem_id=itemlocrsrv_source_id)\n  AND (itemsite_id=coitem_itemsite_id)\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND (itemsite_item_id=<? value("item_id") ?>) )\n    ) AS data\nORDER BY sortkey, source_id, level;\n  admin   2011-11-23      0
145 89      unpostedReceipts        detail  used by unpostedPoReceipts -------PURCHASE ORDERS---------- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: unpostedReceipts\n-- Name: detail\n-- Notes: used by unpostedPoReceipts\n---------PURCHASE ORDERS----------\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n       vend_name AS orderhead_from,\n       poitem_linenumber AS orderitem_linenumber,\n       formatDate(recv_duedate) AS recv_duedate,\n       warehous_code,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       COALESCE(uom_name, <? value("na") ?>) AS uom_name,\n       recv_vend_item_number,\n       recv_vend_uom,\n       poitem_qty_ordered AS orderitem_qty_ordered, \n       poitem_qty_received AS orderitem_qty_received,\n       recv_qty, recv_date,\n       COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n       'qty' AS orderitem_qty_ordered_xtnumericrole,\n       'qty' AS orderitem_qty_received_xtnumericrole,\n       'qty' AS recv_qty_xtnumericrole\nFROM pohead JOIN\n     poitem ON (poitem_pohead_id=pohead_id) JOIN \n     recv  ON ((recv_orderitem_id=poitem_id)\n\t   AND (recv_order_type='PO')) LEFT OUTER JOIN\n     (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t       JOIN uom ON (item_inv_uom_id=uom_id)\n               JOIN site() ON (itemsite_warehous_id=warehous_id)\n       )\n      ON (recv_itemsite_id=itemsite_id) JOIN\n     vendinfo ON (pohead_vend_id=vend_id)\nWHERE (NOT recv_posted)\n<? if exists ("EnableReturnAuth") ?>\n-------RETURN AUTHORIZATIONS--------------\nUNION\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n       cust_name AS orderhead_from,\n       raitem_linenumber AS orderitem_linenumber,\n       formatDate(recv_duedate) AS recv_duedate,\n       warehous_code,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       COALESCE(uom_name, <? value("na") ?>) AS uom_name,\n       recv_vend_item_number,\n       recv_vend_uom,\n       raitem_qtyauthorized AS orderitem_qty_ordered, \n       raitem_qtyreceived AS orderitem_qty_received,\n       recv_qty, recv_date,\n       COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n       'qty' AS orderitem_qty_ordered_xtnumericrole,\n       'qty' AS orderitem_qty_received_xtnumericrole,\n       'qty' AS recv_qty_xtnumericrole\nFROM rahead JOIN\n     raitem ON (raitem_rahead_id=rahead_id) JOIN \n     recv  ON ((recv_orderitem_id=raitem_id)\n\t   AND (recv_order_type='RA')) LEFT OUTER JOIN\n     (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t       JOIN uom ON (item_inv_uom_id=uom_id)\n               JOIN site() ON (itemsite_warehous_id=warehous_id)\n       )\n      ON (recv_itemsite_id=itemsite_id) LEFT OUTER JOIN\n     custinfo ON (rahead_cust_id=cust_id)\nWHERE (NOT recv_posted)\n<? endif ?>\n<? if exists ("MultiWhs") ?>\n------TRANSFER ORDERS---------\nUNION\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n       tohead_srcname AS orderhead_from,\n       toitem_linenumber AS orderitem_linenumber,\n       formatDate(recv_duedate) AS recv_duedate,\n       warehous_code,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       COALESCE(uom_name, <? value("na") ?>) AS uom_name,\n       recv_vend_item_number,\n       recv_vend_uom,\n       toitem_qty_ordered AS orderitem_qty_ordered, \n       toitem_qty_received AS orderitem_qty_received,\n       recv_qty, recv_date,\n       COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n       'qty' AS orderitem_qty_ordered_xtnumericrole,\n       'qty' AS orderitem_qty_received_xtnumericrole,\n       'qty' AS recv_qty_xtnumericrole\nFROM tohead JOIN\n     toitem ON (toitem_tohead_id=tohead_id) JOIN \n     recv  ON ((recv_orderitem_id=toitem_id)\n\t   AND (recv_order_type='TO')) LEFT OUTER JOIN\n     (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t       JOIN uom ON (item_inv_uom_id=uom_id)\n               JOIN site() ON (itemsite_warehous_id=warehous_id)\n       )\n      ON (recv_itemsite_id=itemsite_id) \nWHERE (NOT recv_posted)\n<? endif ?>\nORDER BY recv_order_number, orderitem_linenumber;\n    admin   2011-11-23      0
146 414     postJournals    detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: postJournals\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\nFROM (\n  SELECT 0 AS id,\n  sltrans_source,\n  0 AS xtindentrole,\n  CASE WHEN sltrans_source = 'A/P' THEN <? value("AP") ?>\n       WHEN sltrans_source = 'A/R' THEN <? value("AR") ?>\n       WHEN sltrans_source = 'G/L' THEN <? value("GL") ?>\n       WHEN sltrans_source = 'I/M' THEN <? value("IM") ?>\n       WHEN sltrans_source = 'P/D' THEN <? value("PD") ?>\n       WHEN sltrans_source = 'S/O' THEN <? value("SO") ?>\n       WHEN sltrans_source = 'S/R' THEN <? value("SR") ?>\n       WHEN sltrans_source = 'W/O' THEN <? value("WO") ?>\n       ELSE <? value("Other" ?>\n  END AS description, \n  NULL AS debit, \n  NULL AS credit, \n  count(sltrans_id) AS journals\n  FROM sltrans\n  WHERE ((NOT sltrans_posted)\n   AND (sltrans_amount > 0)\n   AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>))\n  GROUP BY sltrans_source\n<? if exists("preview") ?>\nUNION ALL\n  SELECT \n    sltrans_accnt_id AS id,\n    sltrans_source,\n    1 AS xtindentrole,\n    formatGLAccountLong(sltrans_accnt_id) AS description,\n    CASE WHEN SUM(sltrans_amount) < 0 THEN ABS(SUM(sltrans_amount))\n    END AS debit,\n    CASE WHEN SUM(sltrans_amount) > 0 THEN SUM(sltrans_amount)\n    END AS credit,\n    NULL AS journals\n    FROM sltrans\n    WHERE ((NOT sltrans_posted)\n     AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>))\n  GROUP BY sltrans_accnt_id, sltrans_source\n<? endif ?>\n) data\nORDER BY sltrans_source, xtindentrole\n  admin   2011-11-23      0
147 413     postJournals    post     Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: postJournals\n-- Name:  post\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * \nFROM postJournals(\nARRAY[\n<? foreach("source_list") ?>\n  <? if not isfirst("source_list") ?>\n,\n  <? endif ?>\n  <? value("source_list") ?>\n<? endforeach ?>\n],  \n<? value("startDate") ?>, \n<? value("endDate") ?>, \n<? value("distDate") ?>) AS result;\n  admin   2011-11-23      0
148 229     pricelist       detail  This query displays price lists and the data used to perform price calculations. It avoids price calculations where possible. The UNION sets the sourcecode column to show how the price list entry was derived:  customer vs customer type vs customer type regex ..., etc. Then the outer query modifies the sourcecode to indicate item vs product category. TODO: possible improvements include removing OUTER JOINs with uom table Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: pricelist\n-- Name:  detail\n-- Notes: This query displays price lists and the data used to perform\n--        price calculations. It avoids price calculations where possible.\n--        The UNION sets the sourcecode column to show how the price list entry\n--        was derived:  customer vs customer type vs customer type regex ..., etc.\n--        Then the outer query modifies the sourcecode to indicate\n--        item vs product category.\n--        TODO: possible improvements include removing OUTER JOINs with uom table\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT sourcecode + CASE WHEN ipsprice_source='P' THEN 10 ELSE 0 END AS source,\n       sourceid, schedulename, type,\n       invqty AS qty_break,\n       CASE WHEN (qtybreak = -1) THEN <? value('na') ?>\n       END             AS qty_break_qtdisplayrole,\n       invuom.uom_name AS qty_uom,\n       price,\n       currConcat(curr_id) AS currency,\n       priceuom.uom_name   AS price_uom,\n       currToCurr(curr_id, <? value('curr_id') ?>,\n                  price,   <? value('effective') ?>) AS base_price,\n       discountpercent,\n       discountfixed,\n       'qty'        AS qty_break_xtnumericrole,\n       'salesprice' AS price_xtnumericrole,\n       'salesprice' AS base_price_xtnumericrole,\n       'percent'    AS discountpercent_xtnumericrole,\n       'salesprice' AS discountfixed_xtnumericrole\nFROM ( SELECT 1 AS sourcecode,\n              ipsprice_id AS sourceid,\n              ipsprice_source,\n              ipshead_id,\n              ipshead_name AS schedulename,\n              <? value('customer') ?> AS type,\n              ipsprice_qtybreak AS invqty,\n              ipsprice_uomqtybreak AS qtybreak,\n              ipsprice_uomprice AS price,\n              ipsprice_uomqtybreak_uom_id AS qtybreak_uom_id,\n              ipsprice_uomprice_uom_id AS price_uom_id,\n              ipsprice_discountpercent AS discountpercent,\n              ipsprice_discountfixed AS discountfixed,\n              ipshead_curr_id AS curr_id\n       FROM ipsass, ipshead, ipsprice\n       WHERE ((ipsass_ipshead_id=ipshead_id)\n          AND (ipsprice_ipshead_id=ipshead_id)\n          AND (ipsprice_item_id=<? value('item_id') ?>)\n          AND (ipsass_cust_id=<? value('cust_id') ?>)\n          AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n          AND (<? value('asof') ?> BETWEEN ipshead_effective AND\n                                           (ipshead_expires - 1))\n          )\n\n       UNION SELECT 2 AS sourcecode,\n                    ipsprice_id AS sourceid,\n                    ipsprice_source,\n                    ipshead_id,\n                    ipshead_name AS schedulename,\n                    <? value('custType') ?> AS type,\n                    ipsprice_qtybreak AS invqty,\n                    ipsprice_uomqtybreak AS qtybreak,\n                    ipsprice_uomprice AS price,\n                    ipsprice_uomqtybreak_uom_id AS qtybreak_uom_id,\n                    ipsprice_uomprice_uom_id AS price_uom_id,\n                    ipsprice_discountpercent AS discountpercent,\n                    ipsprice_discountfixed AS discountfixed,\n                    ipshead_curr_id AS curr_id\n       FROM ipsass, ipshead, cust, ipsprice\n       WHERE ((ipsass_ipshead_id=ipshead_id)\n          AND (ipsprice_ipshead_id=ipshead_id)\n          AND (ipsprice_item_id=<? value('item_id') ?>)\n          AND (ipsass_custtype_id=cust_custtype_id)\n          AND (cust_id=<? value('cust_id') ?>)\n          AND (<? value('asof') ?> BETWEEN ipshead_effective AND\n                                           (ipshead_expires - 1))\n          )\n\n       UNION SELECT 3 AS sourcecode,\n                    ipsprice_id AS sourceid,\n                    ipsprice_source,\n                    ipshead_id,\n                    ipshead_name AS schedulename,\n                    <? value('custTypePattern') ?> AS type,\n                    ipsprice_qtybreak AS invqty,\n                    ipsprice_uomqtybreak AS qtybreak,\n                    ipsprice_uomprice AS price,\n                    ipsprice_uomqtybreak_uom_id AS qtybreak_uom_id,\n                    ipsprice_uomprice_uom_id AS price_uom_id,\n                    ipsprice_discountpercent AS discountpercent,\n                    ipsprice_discountfixed AS discountfixed,\n                    ipshead_curr_id AS curr_id\n       FROM ipsass, ipshead, custtype, cust, ipsprice\n       WHERE ((ipsass_ipshead_id=ipshead_id)\n          AND (ipsprice_ipshead_id=ipshead_id)\n          AND (ipsprice_item_id=<? value('item_id') ?>)\n          AND (coalesce(length(ipsass_custtype_pattern), 0) > 0)\n          AND (custtype_code ~ ipsass_custtype_pattern)\n          AND (cust_custtype_id=custtype_id)\n          AND (cust_id=<? value('cust_id') ?>)\n          AND (<? value('asof') ?> BETWEEN ipshead_effective AND\n                                           (ipshead_expires - 1))\n          )\n\n       UNION SELECT 6 AS sourcecode,\n                    ipsprice_id AS sourceid,\n                    ipsprice_source,\n                    ipshead_id,\n                    ipshead_name AS schedulename,\n                    <? value('shipTo') ?> AS type,\n                    ipsprice_qtybreak AS invqty,\n                    ipsprice_uomqtybreak AS qtybreak,\n                    ipsprice_uomprice AS price,\n                    ipsprice_uomqtybreak_uom_id AS qtybreak_uom_id,\n                    ipsprice_uomprice_uom_id AS price_uom_id,\n                    ipsprice_discountpercent AS discountpercent,\n                    ipsprice_discountfixed AS discountfixed,\n                    ipshead_curr_id AS curr_id\n       FROM ipsass, ipshead, ipsprice\n       WHERE ((ipsass_ipshead_id=ipshead_id)\n          AND (ipsprice_ipshead_id=ipshead_id)\n          AND (ipsprice_item_id=<? value('item_id') ?>)\n          AND (ipsass_shipto_id=<? value('shipto_id') ?>)\n          AND (ipsass_shipto_id != -1)\n          AND (<? value('asof') ?> BETWEEN ipshead_effective AND\n                                           (ipshead_expires - 1))\n          )\n\n       UNION SELECT 7 AS sourcecode,\n                    ipsprice_id AS sourceid,\n                    ipsprice_source,\n                    ipshead_id,\n                    ipshead_name AS schedulename,\n                    <? value('shipToPattern') ?> AS type,\n                    ipsprice_qtybreak AS invqty,\n                    ipsprice_uomqtybreak AS qtybreak,\n                    ipsprice_uomprice AS price,\n                    ipsprice_uomqtybreak_uom_id AS qtybreak_uom_id,\n                    ipsprice_uomprice_uom_id AS price_uom_id,\n                    ipsprice_discountpercent AS discountpercent,\n                    ipsprice_discountfixed AS discountfixed,\n                    ipshead_curr_id AS curr_id\n       FROM ipsass, ipshead, shipto, ipsprice\n       WHERE ( (ipsass_ipshead_id=ipshead_id)\n        AND (ipsprice_ipshead_id=ipshead_id)\n        AND (ipsprice_item_id=<? value('item_id') ?>)\n        AND (shipto_id=<? value('shipto_id') ?>)\n        AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0)\n        AND (shipto_num ~ ipsass_shipto_pattern)\n        AND (ipsass_cust_id=<? value('cust_id') ?>)\n        AND (<? value('asof') ?> BETWEEN ipshead_effective AND\n                                         (ipshead_expires - 1))\n        )\n\n       UNION SELECT 4 AS sourcecode,\n                    ipsprice_id AS sourceid,\n                    ipsprice_source,\n                    ipshead_id,\n                    ipshead_name AS schedulename,\n                    (<? value('sale') ?> || '-' || sale_name) AS type,\n                    ipsprice_qtybreak AS invqty,\n                    ipsprice_uomqtybreak AS qtybreak,\n                    ipsprice_uomprice AS price,\n                    ipsprice_uomqtybreak_uom_id AS qtybreak_uom_id,\n                    ipsprice_uomprice_uom_id AS price_uom_id,\n                    ipsprice_discountpercent AS discountpercent,\n                    ipsprice_discountfixed AS discountfixed,\n                    ipshead_curr_id AS curr_id\n       FROM sale, ipshead, ipsprice\n       WHERE ((sale_ipshead_id=ipshead_id)\n          AND (ipsprice_ipshead_id=ipshead_id)\n          AND (ipsprice_item_id=<? value('item_id') ?>)\n          AND (<? value('asof') ?> BETWEEN sale_startdate AND (sale_enddate - 1)) )\n\n       UNION SELECT 5 AS sourcecode,\n               item_id AS sourceid,\n               NULL AS ipsprice_source,\n               NULL AS ipshead_id,\n               '' AS schedulename,\n               <? value('listPrice') ?> AS type,\n               -1 AS invqty,\n               -1 AS qtybreak,\n              (item_listprice - (item_listprice * cust_discntprcnt)) AS price,\n              item_inv_uom_id   AS qtybreak_uom_id,\n              item_price_uom_id AS price_uom_id,\n              cust_discntprcnt  AS discountpercent,\n              NULL              AS discountfixed,\n              baseCurrId() AS curr_id\n       FROM item, cust\n       WHERE (item_sold\n          AND (NOT item_exclusive)\n          AND (item_id=<? value('item_id') ?>)\n          AND (cust_id=<? value('cust_id') ?>) ) ) AS data\n  LEFT OUTER JOIN uom AS invuom ON (invuom.uom_id=qtybreak_uom_id)\n  LEFT OUTER JOIN uom AS priceuom ON (priceuom.uom_id=price_uom_id)\n\n ORDER BY price_uom_id, price;\n     admin   2011-11-23      0
149 442     pricingFreight  detail  used by itemPricingScheduleItem Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: pricingFreight\n-- Name: detail\n-- Notes: used by itemPricingScheduleItem\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ipsfreight.*\n  FROM ipsfreight\n WHERE ( (true)\n<? if exists("checkDup") ?>\n <? if exists("ipshead_id") ?>\n   AND (ipsfreight_ipshead_id=<? value("ipshead_id") ?>)\n <? endif ?>\n <? if exists("warehous_id") ?>\n   AND (ipsfreight_warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n   AND (ipsfreight_warehous_id IS NULL)\n <? endif ?>\n <? if exists("shipzone_id") ?>\n   AND (ipsfreight_shipzone_id=<? value("shipzone_id") ?>)\n <? else ?>\n   AND (ipsfreight_shipzone_id IS NULL)\n <? endif ?>\n <? if exists("freightclass_id") ?>\n   AND (ipsfreight_freightclass_id=<? value("freightclass_id") ?>)\n <? else ?>\n   AND (ipsfreight_freightclass_id IS NULL)\n <? endif ?>\n <? if exists("shipvia") ?>\n   AND (ipsfreight_shipvia=<? value("shipvia") ?>)\n <? else ?>\n   AND (ipsfreight_shipvia IS NULL)\n <? endif ?>\n <? if exists("qtybreak") ?>\n   AND (ipsfreight_qtybreak=<? value("qtybreak") ?>)\n <? endif ?>\n   AND (ipsfreight_id <> <? value("ipsfreight_id") ?>)\n<? elseif exists("ipsfreight_id") ?>\n   AND (ipsfreight_id=<? value("ipsfreight_id") ?>)\n<? endif ?>\n      );\n admin   2011-11-23      0
150 278     prospects       detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: prospects\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  prospect.*,\n  cntct.*, addr.*\nFROM prospect \n  LEFT OUTER JOIN cntct ON (prospect_cntct_id=cntct_id) \n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \nWHERE true\n<? if not exists("showInactive") ?> \n  AND prospect_active \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (prospect_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (prospect_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((prospect_number ~* <? value("search_pattern") ?>)\n       OR (prospect_name ~* <? value("search_pattern") ?>)\n       OR (cntct_first_name || ' ' || cntct_last_name ~* <? value("search_pattern") ?>)\n       OR (cntct_phone || ' ' || cntct_phone2 || ' ' || cntct_fax ~* <? value("search_pattern") ?>)\n       OR (cntct_email ~* <? value("search_pattern") ?>)\n       OR (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("search_pattern") ?>)\n       OR (addr_city ~* <? value("search_pattern") ?>)\n       OR (addr_state ~* <? value("search_pattern") ?>)\n       OR (addr_postalcode ~* <? value("search_pattern") ?>)\n       OR (addr_country ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("prospect_number_pattern") ?>\n  AND (prospect_number ~* <? value("prospect_number_pattern") ?>)\n<? endif ?>\n<? if exists("prospect_name_pattern") ?>\n  AND (prospect_name ~* <? value("prospect_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (cntct_first_name || ' ' || cntct_last_name ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (cntct_phone || ' ' || cntct_phone2 || ' ' || cntct_fax ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (cntct_email ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (addr_city ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (addr_state ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (addr_postalcode ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (addr_country ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? if exists("id") ?>\n  AND (prospect_id=<? value("id") ?>\n<? endif ?>\nORDER BY prospect_number; \n      admin   2011-11-23      0
151 101     returnAuthorizations    detail   Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: returnAuthorizations\n-- Name: detail\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT rahead_id, rahead_number, rahead_billtoname,\n       rahead_authdate,rahead_expiredate,\n       COALESCE(cust_number, 'Undefined') AS custnumber,\n       CASE\n       WHEN rahead_disposition = 'C' THEN\n         <? value("credit") ?>\n       WHEN rahead_disposition = 'R' THEN\n         <? value("return") ?>\n       WHEN rahead_disposition = 'P' THEN\n         <? value("replace") ?>\n       WHEN rahead_disposition = 'V' THEN\n         <? value("service") ?>\n       WHEN rahead_disposition = 'M' THEN\n         <? value("substitute") ?>\n       END AS disposition,\n       formatDate(rahead_authdate) AS f_authorized,\n       formatDate(rahead_expiredate) AS f_expires,\n       CASE WHEN (rahead_expiredate < current_date) THEN\n         'error'\n       END AS rahead_expiredate_qtforegroundrole\n  FROM rahead LEFT OUTER JOIN custinfo ON (rahead_cust_id=cust_id)\n               <? if exists("selectedSites") ?> \n                   JOIN raitem ON (raitem_rahead_id=rahead_id) \n                   JOIN itemsite ON (raitem_itemsite_id=itemsite_id) \n                   JOIN site() ON (itemsite_warehous_id=warehous_id) \n               <? else ?> \n                   LEFT OUTER JOIN raitem ON (raitem_rahead_id=rahead_id) \n                   LEFT OUTER JOIN itemsite ON (raitem_itemsite_id=itemsite_id) \n                   LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id) \n               <? endif ?> \n WHERE ((true)\n<? if not exists("showClosed") ?> \n   AND ((raitem_status = 'O') OR (raitem_status IS NULL)) \n<? endif ?>\n<? if not exists("showUnauthorized") ?> \n   AND (raitem_qtyauthorized > 0) \n<? endif ?>\n<? if not exists("showExpired") ?>\n   AND (COALESCE(rahead_expiredate,CURRENT_DATE) >= CURRENT_DATE)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?>\n   AND (rahead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n      )\n GROUP BY cust_number,rahead_id,rahead_number,rahead_authdate,rahead_expiredate,\n   rahead_billtoname,rahead_disposition\n ORDER BY rahead_number\n      admin   2011-11-23      0
152 73      purchase        purchaserequests         Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: purchase\n-- Name:  purchaserequests\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pr_id, itemsite_id, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS description,\n       pr.*,\n       CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n                                                       FROM womatl\n                                                       WHERE (womatl_id=pr_order_id) ) )\n            WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n            WHEN (pr_order_type='F') THEN ('Planned Order')\n            WHEN (pr_order_type='M') THEN <? value("manual") ?>\n            ELSE <? value("other") ?>\n       END AS parent,\n       'qty' AS pr_qtyreq_xtnumericrole \nFROM pr, itemsite, item \nWHERE ((pr_itemsite_id=itemsite_id)\n   AND (itemsite_item_id=item_id)\n<? if exists("startDate") ?>\n   AND (pr_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? elseif exists("plancode_id") ?>\n   AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n   AND (itemsite_plancode_id IN (SELECT plancode_id FROM\n                                 plancode\n                                 WHERE (plancode_code ~ <? value("plancode_pattern") ?>) ) )\n<? endif ?>\n) \nORDER BY pr_duedate;\n   admin   2011-11-23      0
153 443     purchaseOrderItems      detail  used by purchaseOrderItem Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: purchaseOrderItems\n-- Name: detail\n-- Notes: used by purchaseOrderItem\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number, pohead_taxzone_id,\n       pohead_curr_id, pohead_orderdate,\n       COALESCE(pohead_cohead_id, -1) AS pohead_cohead_id,\n       poitem_linenumber, poitem_vend_item_number,\n       poitem_vend_item_descrip, poitem_vend_uom,\n       poitem_invvenduomratio, poitem_status,\n       poitem_duedate, poitem_qty_ordered,\n       poitem_qty_received, poitem_unitprice,\n       poitem_freight, poitem_taxtype_id,\n       poitem_tax_recoverable, poitem_comments,\n       poitem_prj_id, poitem_bom_rev_id,\n       poitem_boo_rev_id, poitem_manuf_name,\n       poitem_manuf_item_number, poitem_manuf_item_descrip,\n       COALESCE(poitem_itemsite_id, -1) AS poitem_itemsite_id,\n       COALESCE(poitem_itemsrc_id, -1) AS poitem_itemsrc_id,\n       COALESCE(poitem_expcat_id, -1) AS poitem_expcat_id,\n       COALESCE(poitem_wohead_id, -1) AS poitem_wohead_id,\n       CASE WHEN (COALESCE(pohead_cohead_id, -1) != -1) THEN TEXT(<? value("sonum") ?>)\n            WHEN (COALESCE(poitem_wohead_id, -1) != -1) THEN TEXT(<? value("wonum") ?>)\n            ELSE ''\n       END AS demand_type,\n       CASE WHEN (COALESCE(pohead_cohead_id, -1) != -1) THEN cohead_number\n            WHEN (COALESCE(poitem_wohead_id, -1) != -1) THEN CAST(wo_number AS text)\n            ELSE ''\n       END AS order_number,\n       CASE WHEN pohead_cohead_id IS NOT NULL THEN CAST(coitem_linenumber AS text)\n            WHEN poitem_wohead_id IS NOT NULL THEN CAST(wo_subnumber AS text)\n            ELSE ''\n       END AS orderline_number,\n       poitem_unitprice * poitem_qty_ordered AS extended_price,\n       COALESCE(coitem_prcost, 0.0) AS override_cost,\n       itemsrc.*\n  FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)\n              LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id)\n              LEFT OUTER JOIN coitem  ON (coitem_id=poitem_soitem_id)\n              LEFT OUTER JOIN cohead  ON (cohead_id=coitem_cohead_id)\n              LEFT OUTER JOIN wo      ON (wo_id=poitem_wohead_id)\n WHERE ( (TRUE)\n<? if exists("poitem_id") ?>\n   AND (poitem_id=<? value("poitem_id") ?>)\n<? endif ?>\n);\n     admin   2011-11-23      0
154 72      purchaseOrders  detail  used by dspPosByVendor, dspPOsByDate Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: purchaseOrders\n-- Name: detail\n-- Notes: used by dspPosByVendor, dspPOsByDate\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, pohead_number,\n       warehous_code AS warehousecode,\n       poitem_status, pohead_orderdate,\n       CASE WHEN(poitem_status='C') THEN TEXT(<? value("closed") ?>)\n            WHEN(poitem_status='U') THEN TEXT(<? value("unposted") ?>)\n            WHEN(poitem_status='O'\n                AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n                AND (SUM(poitem_qty_ordered)>SUM(poitem_qty_received-poitem_qty_returned))) \n              THEN TEXT(<? value("partial") ?>)\n            WHEN(poitem_status='O'\n                AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n                AND (SUM(poitem_qty_ordered)<=SUM(poitem_qty_received-poitem_qty_returned))) \n              THEN TEXT(<? value("received") ?>)\n            WHEN(poitem_status='O') THEN TEXT(<? value("open") ?>)\n            ELSE poitem_status\n       END AS poitem_status_qtdisplayrole,\n<? if exists("byDate") ?>\n       vend_name,\n       MIN(poitem_duedate) AS minDueDate,\n       CASE WHEN (MIN(poitem_duedate) < CURRENT_DATE) THEN 'error'\n       END AS minDueDate_qtforegroundrole,\n<? else ?>\n       vend_number,\n<? endif ?>\n<? if exists("byReceiptDate") ?>\n       MIN(date(porecv_date)) AS sortDate,\n<? elseif exists("byDueDate") ?>\n       MIN(poitem_duedate) AS sortDate,\n<? else ?>\n       pohead_orderdate AS sortDate,\n<? endif ?>\n       CASE WHEN (MIN(poitem_duedate) < CURRENT_DATE) THEN 'error' END AS sortDate_qtforegroundrole,\n-- Report formatting\n  formatDate(pohead_orderdate) AS f_orderdate,\n  formatDate(MIN(poitem_duedate)) AS f_duedate, \n       CASE WHEN(poitem_status='C') THEN TEXT(<? value("closed") ?>)\n            WHEN(poitem_status='U') THEN TEXT(<? value("unposted") ?>)\n            WHEN(poitem_status='O'\n                AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n                AND (SUM(poitem_qty_ordered)>SUM(poitem_qty_received-poitem_qty_returned))) \n              THEN TEXT(<? value("partial") ?>)\n            WHEN(poitem_status='O'\n                AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n                AND (SUM(poitem_qty_ordered)<=SUM(poitem_qty_received-poitem_qty_returned))) \n              THEN TEXT(<? value("received") ?>)\n            WHEN(poitem_status='O') THEN TEXT(<? value("open") ?>)\n            ELSE poitem_status\n       END AS f_status\n-- End Report formatting\n  FROM vend, poitem,\n<? if exists("byReceiptDate") ?>\n       porecv,\n<? endif ?>\n       pohead LEFT OUTER JOIN warehous ON (pohead_warehous_id=warehous_id)\n WHERE ((poitem_pohead_id=pohead_id)\n   AND  (pohead_vend_id=vend_id)\n<? if exists("byReceiptDate") ?>\n   AND  (porecv_itemsite_id=poitem_itemsite_id)\n   AND  (porecv_ponumber=pohead_number)\n   AND  (date(porecv_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? elseif exists("byDueDate") ?>\n   AND  (poitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? else ?>\n   AND  (pohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n   AND  (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n   AND  (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n   AND (vend_vendtype_id IN (SELECT vendtype_id\n                               FROM vendtype\n                              WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (pohead_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if not exists("showClosed") ?>\n   AND (poitem_status!='C')\n<? endif ?>\n<? if exists("agentUsername") ?>\n   AND (pohead_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if exists("descrip_pattern") ?>\n  AND ((poitem_vend_item_descrip ~* <? value("descrip_pattern") ?>)\n    OR (poitem_itemsite_id IN (\n      SELECT itemsite_id\n        FROM itemsite, item\n       WHERE ((itemsite_item_id=item_id)\n         AND  ((item_descrip1 ~* <? value("descrip_pattern") ?>)\n            OR (item_descrip2 ~* <? value("descrip_pattern") ?>)))\n                              )))\n<? endif ?>\n\n)\nGROUP BY pohead_id, pohead_number, warehous_code,\n         poitem_status, pohead_orderdate,\n<? if exists("byDate") ?>\n         vend_name \n<? else ?>\n         vend_number\n<? endif ?>\nORDER BY\n<? if exists("byDate") ?>\n  minDueDate\n<? else ?>\n  sortDate\n<? endif ?>;\n    admin   2011-11-23      0
155 74      quoteItems      detail  used by dspQuotesByItem Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: quoteItems\n-- Name: detail\n-- Notes: used by dspQuotesByItem\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT quitem_id, quhead_id,\n       quitem.*, quhead.*,\n       COALESCE(cust_number, prospect_number) AS cust_number,\n       COALESCE(cust_name, prospect_name) AS cust_name,\n       'qty' AS quitem_qtyord_xtnumericrole\nFROM quitem JOIN quhead ON (quhead_id=quitem_quhead_id)\n            LEFT OUTER JOIN cust ON (cust_id=quhead_cust_id)\n            LEFT OUTER JOIN prospect ON (prospect_id=quhead_cust_id)\n            JOIN itemsite ON (itemsite_id=quitem_itemsite_id)\n            JOIN site() ON (warehous_id=itemsite_warehous_id)\nWHERE ( (1=1)\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("showConverted") ?>\n  AND (quhead_status IN ('C','O'))\n<? else ?>\n  AND (quhead_status NOT IN ('C','X'))\n<? endif ?>\n<? if exists("startDate") ?>\n  AND  (quhead_quotedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\nORDER BY quhead_number;\n\n  admin   2011-11-23      0
156 75      quotes  detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: quotes\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT quhead.*, firstline(quhead_ordercomments) AS notes, quhead_id AS id,\n  CASE WHEN quhead_status = 'O' THEN <? value("open") ?>\n       WHEN quhead_status = 'C' THEN <? value("converted") ?>\n  ELSE <? value("undefined") ?> END AS quhead_status_qtdisplayrole,\n<? if exists("customersOnly") ?>\n       cust_id, cust_number, cust_name,\n<? endif ?>\n       ( SELECT MIN(quitem_scheddate)\n           FROM quitem\n          WHERE (quitem_quhead_id=quhead_id) ) AS min_scheddate,\n  CASE WHEN (quhead_expire < current_date) THEN\n    'error'\n   END AS quhead_expire_qtforegroundrole\nFROM quhead\n<? if not exists("customersOnly") ?>\n  LEFT OUTER \n<? endif ?>\n  JOIN custinfo ON (quhead_cust_id=cust_id)\nWHERE (checkQuoteSitePrivs(quhead_id, <? value("warehous_id") ?>))\n<? if exists("owner_username") ?> \n  AND (quhead_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (quhead_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n<? if exists("showConverted") ?>\n  AND (quhead_status IN ('C','O'))\n<? else ?>\n  AND (quhead_status NOT IN ('C','X'))\n<? endif ?>\n<? if not exists("showExpired") ?>\n  AND ((quhead_expire IS NULL) OR (quhead_expire >= CURRENT_DATE))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND  (quhead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND  (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND  (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("poNumber") ?>\n  AND  (quhead_custponumber=<? value("poNumber") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND  (quhead_quotedate >= <? value("startDate") ?> )\n<? endif ?>\n<? if exists("endDate") ?>\n  AND  (quhead_quotedate <= <? value("endDate") ?>)\n<? endif ?>\n<? if exists("salesrep_id") ?>\n  AND  (quhead_salesrep_id = <? value("salesrep_id") ?>\n<? endif ?>\n<? if exists("id") ?>\n  AND  (quhead_id = <? value("id") ?>)\n<? endif ?>\n<? if exists("orderByCust") ?>\nORDER BY cust_number, quhead_number;\n<? else ?>\nORDER BY quhead_number;\n<? endif ?>\n\n      admin   2011-11-23      0
157 80      runningAvailability     detail  used by dspRunningAvailability, itemAvailabilityWorkbench Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: runningAvailability\n-- Name: detail\n-- Notes: used by dspRunningAvailability, itemAvailabilityWorkbench\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT orderid, altorderid, ordertype, ordernumber, sequence, item_number,\n       duedate, qtyordered,  qtyreceived, balance,\n       balance AS runningavail,\n<? if exists("includeFormatted") ?>\n       formatDate(duedate) AS f_duedate,\n       formatQty(qtyordered) AS f_qtyordered,\n       formatQty(qtyreceived) AS f_qtyreceived,\n       formatQty(balance) AS f_balance,\n<? endif ?>\n       1 AS runningavail_xtrunningrole,\n       <? value("qoh") ?> AS runningavail_xtrunninginit,\n       CASE WHEN late THEN 'error' END AS duedate_qtforegroundrole,\n       CASE WHEN ordertype ~ <? value("plannedPo") ?> OR\n                 ordertype ~ <? value("plannedWo") ?> OR\n                 ordertype ~ <? value("plannedTo") ?> THEN\n          'emphasis' END AS qtforegroundrole,\n      'qty' AS qtyordered_xtnumericrole,\n      'qty' AS qtyreceived_xtnumericrole,\n      'qty' AS balance_xtnumericrole\nFROM (\n<? if exists("MultiWhs") ?>\nSELECT tohead_id AS orderid, toitem_id AS altorderid, 'T/O' AS ordertype,\n       TEXT(tohead_number) AS ordernumber,\n       1 AS sequence,\n       tohead_srcname || '/' || tohead_destname AS item_number,\n       toitem_duedate AS duedate,\n       (toitem_duedate < CURRENT_DATE) AS late,\n       toitem_qty_ordered AS qtyordered,\n       toitem_qty_received AS qtyreceived,\n       noNeg(toitem_qty_ordered - toitem_qty_received) AS balance\nFROM tohead, toitem\nWHERE ((toitem_tohead_id=tohead_id)\n  AND  (toitem_status NOT IN ('C', 'X'))\n  AND  (toitem_item_id=<? value("item_id") ?>)\n  AND  (tohead_dest_warehous_id=<? value("warehous_id") ?>)\n  AND  (toitem_qty_ordered > toitem_qty_received) )\n\nUNION\nSELECT tohead_id AS orderid, toitem_id AS altorderid, 'T/O' AS ordertype,\n       TEXT(tohead_number) AS ordernumber,\n       1 AS sequence,\n       tohead_srcname || '/' || tohead_destname AS item_number,\n       toitem_duedate AS duedate,\n       (toitem_duedate < CURRENT_DATE) AS late,\n       toitem_qty_ordered AS qtyordered,\n       toitem_qty_received AS qtyreceived,\n       -1 * noNeg(toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id)) AS balance\n       -- TODO: old code had ^^^^ for formatted balance and vvvv used to calc running avail! which is right?\n       -- -1 * noNeg(toitem_qty_ordered - toitem_qty_received) AS balance\nFROM tohead, toitem\nWHERE ((toitem_tohead_id=tohead_id)\n  AND  (toitem_status NOT IN ('C', 'X'))\n  AND  (toitem_item_id=<? value("item_id") ?>)\n  AND  (tohead_src_warehous_id=<? value("warehous_id") ?>)\n  AND  (toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id)) > 0 )\n\nUNION\n<? endif ?>\nSELECT wo_id AS orderid, -1 AS altorderid,\n       'W/O' AS ordertype,\n       formatWoNumber(wo_id) AS ordernumber,\n       1 AS sequence,\n       item_number,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late,\n       wo_qtyord AS qtyordered,\n       wo_qtyrcv AS qtyreceived,\n       noNeg(wo_qtyord - wo_qtyrcv) AS balance\nFROM wo, itemsite, item\nWHERE ((wo_status<>'C')\n  AND  (wo_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (item_type NOT IN ('C', 'Y')))\n\nUNION\n\n-- Tools on work orders to be returned\nSELECT wo_id AS orderid, -1 AS altorderid,\n       'W/O' AS ordertype,\n       formatWoNumber(wo_id) AS ordernumber,\n       1 AS sequence,\n       item_number,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late,\n       womatl_qtyreq AS qtyordered,\n       COALESCE(SUM(abs(invhist_invqty)),0) AS qtyreceived,\n       noNeg(womatl_qtyreq - COALESCE(SUM(abs(invhist_invqty)),0)) AS balance\nFROM womatl\n  JOIN wo ON (wo_id=womatl_wo_id)\n  JOIN itemsite ON (womatl_itemsite_id=itemsite_id)\n  JOIN item ON (itemsite_item_id=item_id)\n  LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n  LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n                          AND (invhist_invqty < 0))\nWHERE ((wo_status<>'C')\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (item_type = 'T'))\nGROUP BY wo_id, wo_duedate, item_number, womatl_qtyreq\n\n<? if exists("Manufacturing") ?>\nUNION\nSELECT wo_id AS orderid, -1 AS altorderid,\n       'W/O' AS ordertype,\n       formatWoNumber(wo_id) AS ordernumber,\n       1 AS sequence,\n       item_number,\n       wo_duedate AS duedate,\n       (wo_duedate < CURRENT_DATE) AS late,\n       (wo_qtyord * brddist_stdqtyper) AS qtyordered,\n       (wo_qtyrcv * brddist_stdqtyper) AS qtyreceived,\n       noNeg((wo_qtyord - wo_qtyrcv) * brddist_stdqtyper) AS balance\nFROM xtmfg.brddist, wo, itemsite, item\nWHERE ((wo_status<>'C')\n  AND  (brddist_wo_id=wo_id)\n  AND  (wo_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (brddist_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (item_type IN ('C', 'Y')) )\n<? endif ?>\n\nUNION\nSELECT wo_id AS orderid, womatl_id AS altorderid,\n      'W/O' AS ordertype,\n      formatWoNumber(wo_id) AS ordernumber,\n      2 AS sequence,\n      woi.item_number,\n      womatl_duedate AS duedate,\n      FALSE AS late,\n      itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qtyordered,\n      itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss) AS qtyreceived,\n      itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, (noNeg(womatl_qtyreq - womatl_qtyiss) * -1)) AS balance\nFROM womatl, wo, itemsite AS wois, item AS woi, itemsite AS womatlis, item AS womatli\nWHERE ((wo_status<>'C')\n  AND  (wo_itemsite_id=wois.itemsite_id)\n  AND  (wois.itemsite_item_id=woi.item_id)\n  AND  (womatlis.itemsite_item_id=womatli.item_id)\n  AND  (womatli.item_type != 'T')\n  AND  (womatl_wo_id=wo_id)\n  AND  (womatlis.itemsite_item_id=<? value("item_id") ?>)\n  AND  (womatlis.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (womatl_itemsite_id=womatlis.itemsite_id) )\n\nUNION\n-- Special handling for tools\nSELECT wo_id AS orderid, womatl_id AS altorderid,\n      'W/O' AS ordertype,\n      formatWoNumber(wo_id) AS ordernumber,\n      2 AS sequence,\n      woi.item_number,\n      womatl_duedate AS duedate,\n      FALSE AS late,\n      itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qtyordered,\n      COALESCE(SUM(invhist_invqty),0) AS qtyreceived,\n      (itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, (noNeg(womatl_qtyreq))) - COALESCE(SUM(invhist_invqty),0)) * -1 AS balance\nFROM itemsite AS wois, item AS woi, itemsite AS womatlis, item AS womatli, wo, womatl\n  LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n  LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n                          AND (invhist_invqty > 0))\nWHERE ((wo_status<>'C')\n  AND  (wo_itemsite_id=wois.itemsite_id)\n  AND  (wois.itemsite_item_id=woi.item_id)\n  AND  (womatlis.itemsite_item_id=womatli.item_id)\n  AND  (womatli.item_type = 'T')\n  AND  (womatl_wo_id=wo_id)\n  AND  (womatlis.itemsite_item_id=<? value("item_id") ?>)\n  AND  (womatlis.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (womatl_itemsite_id=womatlis.itemsite_id) )\nGROUP BY wo_id, woi.item_number, womatl_id, womatl_duedate, womatlis.itemsite_item_id, womatl_uom_id, womatl_qtyreq\n\nUNION\nSELECT pohead_id AS orderid, poitem_id AS altorderid,\n      'P/O' AS ordertype,\n      TEXT(pohead_number) AS ordernumber,\n      1 AS sequence,\n      '' AS item_number,\n      poitem_duedate AS duedate,\n      (poitem_duedate < CURRENT_DATE) AS late,\n      (poitem_qty_ordered * poitem_invvenduomratio) AS qtyordered,\n      (poitem_qty_received * poitem_invvenduomratio) AS qtyreceived,\n      (noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio) AS balance\nFROM pohead, poitem, itemsite, item\nWHERE ((poitem_pohead_id=pohead_id)\n  AND  (poitem_status <> 'C')\n  AND  (poitem_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_id=<? value("item_id") ?>) )\n\nUNION\nSELECT cohead_id AS orderid, coitem_id AS altorderid,\n       'S/O' AS ordertype,\n       TEXT(cohead_number) AS ordernumber,\n       2 AS sequence,\n       cust_name AS item_number,\n       coitem_scheddate AS duedate,\n       (coitem_scheddate < CURRENT_DATE) AS late,\n       (coitem_qtyord * coitem_qty_invuomratio) AS qtyordered,\n       (coitem_qty_invuomratio * (coitem_qtyshipped - coitem_qtyreturned + qtyAtShipping(coitem_id))) AS qtyreceived,\n       (coitem_qty_invuomratio * noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(coitem_id)) * -1) AS balance\nFROM coitem, cohead, cust, itemsite, item\nWHERE ((coitem_status='O')\n  AND  (cohead_cust_id=cust_id)\n  AND  (coitem_cohead_id=cohead_id)\n  AND  (coitem_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=item_id)\n  AND  (item_id=<? value("item_id") ?>)\n  AND  item_sold )\n\n<? if exists("showPlanned") ?>\n<? if exists("showMRPplan") ?>\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmPo") ?> \n \t   ELSE <? value("plannedPo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       '' AS item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       planord_qty AS qtyordered,\n       NULL AS qtyreceived,\n       planord_qty AS balance\nFROM planord, itemsite\nWHERE ((planord_type='P')\n  AND  (planord_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>) )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmWo") ?> \n\t    ELSE <? value("plannedWo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       '' AS item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       planord_qty AS qtyordered,\n       NULL AS qtyreceived,\n       planord_qty AS balance\nFROM planord, itemsite\nWHERE ((planord_type='W')\n  AND  (planord_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>) )\n\nUNION\n-- Tools on Planned Work Orders\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmWo") ?> \n\t    ELSE <? value("plannedWo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       planreq_qty AS qtyordered,\n       NULL AS qtyreceived,\n       planreq_qty AS balance\nFROM planreq\n  JOIN itemsite ON (itemsite_id=planreq_itemsite_id)\n  JOIN item ON (item_id=itemsite_item_id)\n  JOIN planord ON ((planreq_source_id=planord_id)\n              AND (planreq_source='P'))\nWHERE ((itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n  AND  (item_type='T') )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmTo") ?> \n\t    ELSE <? value("plannedTo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       srcwhsinfo.warehous_code || '/' || whsinfo.warehous_code AS item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       planord_qty AS qtyordered,\n       NULL AS qtyreceived,\n       planord_qty AS balance\nFROM planord JOIN itemsite ON (itemsite.itemsite_id=planord_itemsite_id)\n             JOIN whsinfo ON (whsinfo.warehous_id=itemsite.itemsite_warehous_id)\n             JOIN itemsite srcitemsite ON (srcitemsite.itemsite_id=planord_supply_itemsite_id)\n             JOIN whsinfo srcwhsinfo ON (srcwhsinfo.warehous_id=srcitemsite.itemsite_warehous_id)\nWHERE ((planord_type='T')\n  AND  (itemsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite.itemsite_item_id=<? value("item_id") ?>) )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmTo") ?> \n\t    ELSE <? value("plannedTo") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n       srcwhsinfo.warehous_code || '/' || whsinfo.warehous_code AS item_number,\n       planord_duedate AS duedate,\n       FALSE AS late,\n       planord_qty AS qtyordered,\n       NULL AS qtyreceived,\n       (planord_qty * -1) AS balance\nFROM planord JOIN itemsite ON (itemsite.itemsite_id=planord_itemsite_id)\n             JOIN whsinfo ON (whsinfo.warehous_id=itemsite.itemsite_warehous_id)\n             JOIN itemsite srcitemsite ON (srcitemsite.itemsite_id=planord_supply_itemsite_id)\n             JOIN whsinfo srcwhsinfo ON (srcwhsinfo.warehous_id=srcitemsite.itemsite_warehous_id)\nWHERE ((planord_type='T')\n  AND  (srcitemsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (srcitemsite.itemsite_item_id=<? value("item_id") ?>) )\n\nUNION\nSELECT planreq_id AS orderid, -1 AS altorderid,\n       CASE WHEN (planord_firm) THEN <? value("firmWoReq") ?> \n\t    ELSE <? value("plannedWoReq") ?> \n       END AS ordertype,\n       CAST(planord_number AS text) AS ordernumber,\n       1 AS sequence,\n--get the planned order number for the higher level demand\n             (SELECT item_number\n                FROM item, itemsite\n               WHERE((itemsite_item_id=item_id)\n                 AND (itemsite_id=planord_itemsite_id))\n             ) AS item_number,\n       planord_startdate AS duedate,\n       FALSE AS late,\n       planreq_qty AS f_qtyordered,\n       NULL AS qtyreceived,\n       (planreq_qty * -1) AS balance\nFROM planreq, planord, itemsite, item\nWHERE ((planreq_source='P')\n  AND  (planreq_source_id=planord_id)\n  AND  (planreq_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>) )\n<? endif ?>\n\nUNION\nSELECT pr_id AS orderid, -1 AS altorderid,\n       <? value("pr") ?> AS ordertype,\n       CAST(pr_number AS text) AS ordernumber,       \n       1 AS sequence,\n       '' AS item_number,\n       pr_duedate AS duedate,\n       FALSE AS late,\n       pr_qtyreq AS qtyordered,\n       NULL AS qtyreceived,\n       pr_qtyreq AS balance\nFROM pr, itemsite, item\nWHERE ((pr_itemsite_id=itemsite_id)\n  AND  (itemsite_item_id=item_id)\n  AND  (pr_itemsite_id=itemsite_id)\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  AND  (itemsite_item_id=<? value("item_id") ?>) )\n<? endif ?>\n) AS dummy\n\nORDER BY duedate, sequence;\n\n admin   2011-11-23      0
158 76      receipt detail  used by enterPoReceipt Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: receipt\n-- Name: detail\n-- Notes: used by enterPoReceipt\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("pohead_id") ?>\nSELECT poitem_id AS orderitem_id, COALESCE(poitem_itemsite_id,-1) AS itemsite_id, poitem_linenumber AS linenumber,\n       poitem_duedate AS duedate,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       CASE WHEN (LENGTH(TRIM(BOTH '    ' FROM poitem_vend_item_descrip)) <= 0) THEN\n                 (item_descrip1 || ' ' || item_descrip2)\n            ELSE poitem_vend_item_descrip\n       END AS itemdescription,\n       COALESCE(uom_name, <? value("na") ?>) AS inv_uom,\n       warehous_code,\n       poitem_vend_item_number AS vend_item_number,\n       poitem_vend_uom AS vend_uom,\n       poitem_manuf_name AS manuf_name,\n       poitem_manuf_item_number AS manuf_item_number,\n       poitem_qty_ordered AS qty_ordered,\n       poitem_qty_received AS qty_received,\n       poitem_qty_returned AS qty_returned,\n       qtyToReceive(<? value("ordertype") ?>, poitem_id) AS qty_toreceive,\n       'qty' AS qty_ordered_xtnumericrole,\n       'qty' AS qty_received_xtnumericrole,\n       'qty' AS qty_returned_xtnumericrole,\n       'qty' AS qty_toreceive_xtnumericrole\nFROM poitem \n  LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) \n<? if exists("selectedOnly") ?>\n  LEFT OUTER JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n  LEFT OUTER JOIN item ON (itemsite_item_id=item_id) \n  LEFT OUTER JOIN uom ON (item_inv_uom_id=uom_id)\n  LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n  LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id)\nWHERE ( (poitem_status <> 'C')\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=getEffectiveXtUser()) \n<? endif ?>\n<? if exists("bc") ?>\n AND ( (item_number=<? value("bc") ?>) OR\n       (item_upccode=<? value("bc") ?>) OR \n       (poitem_vend_item_number=<? value("bc") ?>) OR \n       (poitem_manuf_item_number=<? value("bc") ?>) OR \n       (COALESCE(itemsrc_upccode, '')=<? value("bc") ?>) ) \n<? endif ?>\n AND (poitem_pohead_id=<? value("pohead_id") ?>) )\nORDER BY poitem_linenumber;\n<? elseif exists("rahead_id") ?>\nSELECT raitem_id AS orderitem_id, itemsite_id, raitem_linenumber AS linenumber,\n       rahead_expiredate AS duedate,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       COALESCE(iu.uom_name, <? value("na") ?>) AS inv_uom,\n       warehous_code,\n       '' AS vend_item_number,\n       ru.uom_name AS vend_uom,\n       '' AS manuf_name,\n       '' AS manuf_item_number,\n       raitem_qtyauthorized AS qty_ordered,\n       raitem_qtyreceived AS qty_received,\n       0 AS qty_returned,\n       qtyToReceive(<? value("ordertype") ?>, raitem_id) AS qty_toreceive,\n       'qty' AS qty_ordered_xtnumericrole,\n       'qty' AS qty_received_xtnumericrole,\n       'qty' AS qty_returned_xtnumericrole,\n       'qty' AS qty_toreceive_xtnumericrole\n\nFROM rahead, raitem \n  LEFT OUTER JOIN \n     ( itemsite \n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n       JOIN item ON (itemsite_item_id=item_id) \n       JOIN uom iu ON (item_inv_uom_id=uom_id)\n       JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n     ) ON (raitem_itemsite_id=itemsite_id), uom ru\nWHERE ( (raitem_status <> 'C')\n AND (item_type <> 'K')\n AND (raitem_qtyauthorized > 0)\n AND (raitem_disposition IN ('R','P','V'))\n AND (raitem_rahead_id=rahead_id)\n AND (raitem_qty_uom_id=ru.uom_id)\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=getEffectiveXtUser()) \n<? endif ?>\n<? if exists("bc") ?>\n AND ( (item_number=<? value("bc") ?>) OR\n       (item_upccode=<? value("bc") ?>) )\n<? endif ?>\n AND (rahead_id=<? value("rahead_id") ?>) )\nORDER BY raitem_linenumber;\n<? elseif exists("tohead_id") ?>\nSELECT toitem_id AS orderitem_id, itemsite_id, toitem_linenumber AS linenumber,\n       toitem_duedate AS duedate,\n       COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       COALESCE(uom_name, <? value("na") ?>) AS inv_uom,\n       warehous_code,\n       ''  AS vend_item_number,\n       toitem_uom AS vend_uom,\n       '' AS manuf_name,\n       '' AS manuf_item_number,\n       toitem_qty_ordered AS qty_ordered,\n       toitem_qty_received AS qty_received,\n       0 AS qty_returned,\n       qtyToReceive(<? value("ordertype") ?>, toitem_id) AS qty_toreceive,\n       'qty' AS qty_ordered_xtnumericrole,\n       'qty' AS qty_received_xtnumericrole,\n       'qty' AS qty_returned_xtnumericrole,\n       'qty' AS qty_toreceive_xtnumericrole\nFROM tohead, itemsite\n<? if exists("selectedOnly") ?>\n       JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n<? endif ?>\n, whsinfo, toitem, item JOIN uom ON (item_inv_uom_id=uom_id)\nWHERE ((toitem_item_id=item_id)\n  AND  (tohead_id=toitem_tohead_id)\n  AND  (tohead_dest_warehous_id=itemsite_warehous_id)\n  AND  (tohead_dest_warehous_id=warehous_id)\n  AND  (toitem_item_id=itemsite_item_id)\n  AND  (toitem_status NOT IN ('C','X'))\n  AND  (toitem_qty_shipped > toitem_qty_received)\n<? if exists("selectedOnly") ?>\n AND (usrsite_username=getEffectiveXtUser()) \n<? endif ?>\n<? if exists("bc") ?>\n AND ( (item_number=<? value("bc") ?>) OR\n       (item_upccode=<? value("bc") ?>) )\n<? endif ?>\n  AND  (toitem_tohead_id=<? value("tohead_id") ?>) )\nORDER BY toitem_linenumber;\n<? endif ?>\n  admin   2011-11-23      0
159 77      receipt receiveAll      used by enterPoReceipt, returnAuthorization, shipOrder Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: receipt\n-- Name: receiveAll\n-- Notes: used by enterPoReceipt, returnAuthorization, shipOrder\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists ("shiphead_id") ?>\n  SELECT enterReceipt(<? value("ordertype") ?>,\n                      shipitem_orderitem_id,\n                      shipitem_qty,\n                      (orderitem_freight - orderitem_freight_received),\n                      '',\n                      orderitem_freight_curr_id,\n                      CURRENT_DATE) AS result\n  FROM shipitem, orderitemData(<? value("ordertype") ?>,\n                               <? value("orderid") ?>,\n                               NULL) AS orderitem\n       LEFT OUTER JOIN recv ON ((recv_orderitem_id=orderitem_id)\n                            AND (recv_order_type=orderitem_orderhead_type))\n  <? if exists("EnableReturnAuth") ?>\n       LEFT OUTER JOIN raitem ON ((raitem_id=orderitem_id)\n                              AND ('RA' = orderitem_orderhead_type))\n  <? endif ?>\n  WHERE ( (shipitem_shiphead_id=<? value("shiphead_id") ?>)\n    AND   (shipitem_orderitem_id=orderitem_id)\n  <? if exists("EnableReturnAuth") ?>\n    AND   ((orderitem_orderhead_type != 'RA') OR (raitem_disposition IN (NULL,'R','V','P')))\n  <? endif?>\n        )\n\n<? else ?>\n  SELECT enterReceipt(orderitem_orderhead_type,\n                      orderitem_id,\n<? if exists("tohead_id") ?>\n                      (orderitem_qty_shipped - orderitem_qty_received),\n<? else ?>\n                      (orderitem_qty_ordered - orderitem_qty_received),\n<? endif ?>\n                      (orderitem_freight - orderitem_freight_received),\n                      '',\n                      orderitem_freight_curr_id,\n                      CURRENT_DATE) AS result\n  FROM orderitemData(<? value("ordertype") ?>,\n                     <? value("orderid") ?>,\n                     NULL) AS orderitem\n       LEFT OUTER JOIN recv ON ((recv_orderitem_id=orderitem_id)\n                            AND (recv_order_type=orderitem_orderhead_type))\n<? if exists("EnableReturnAuth") ?>\n       LEFT OUTER JOIN raitem ON ((raitem_id=orderitem_id)\n                              AND ('RA' = orderitem_orderhead_type))\n<? endif ?>\n  WHERE (orderitem_status NOT IN ('C', 'X'))\n<? if exists("tohead_id") ?>\n    AND (orderitem_qty_shipped > orderitem_qty_received)\n<? endif ?>\n<? if exists("EnableReturnAuth") ?>\n    AND (((orderitem_orderhead_type != 'RA') OR (raitem_disposition IN (NULL,'R','V','P'))))\n<? endif ?>\n<? endif ?>\n      admin   2011-11-23      0
160 78      receivings      detail  used by dspPoItemReceivingsByDate, dspPoItemReceivingsByItem, dspPoItemReceivingsByVendor Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: receivings\n-- Name: detail\n-- Notes: used by dspPoItemReceivingsByDate, dspPoItemReceivingsByItem, dspPoItemReceivingsByVendor\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id, 1 AS altid, recv_order_number AS ponumber,\n       vend_name,\n       recv_duedate           AS duedate,\n       recv_date              AS recvdate,\n       recv_vend_item_number  AS itemnumber,\n       recv_vend_item_descrip AS itemdescrip,\n       COALESCE(item_number,\n                (<? value("nonInv") ?> || recv_vend_item_number)) AS venditemnumber,\n       COALESCE(item_descrip1, recv_vend_item_descrip) AS venditemdescrip,\n       CASE WHEN (recv_vohead_id IS NOT NULL) THEN\n         <? value("received") ?>  \n       ELSE <? value("unvouchered") ?>\n       END AS sense,\n       recv_qty               AS qty,\n       currToBase(recv_purchcost_curr_id, recv_purchcost, CAST(recv_date AS DATE)) AS purchcost,\n       CASE WHEN (recv_qty > 0) THEN\n         COALESCE(recv_value,0) / recv_qty\n       ELSE 0 END  AS recvcost,\n       recv_value             AS value,\n       recv_invoiced          AS invoiced,\n       recv_date              AS sortdate,\n<? if exists("includeFormatted") ?>\n       formatDate(recv_duedate)       AS f_duedate,\n       formatDate(recv_date)          AS f_recvdate,\n       formatQty(recv_qty)            AS f_qty,\n  <? if exists("showVariances") ?>\n       formatCost(currToBase(recv_purchcost_curr_id, recv_purchcost, CAST(recv_date AS DATE))) AS f_purchcost,\n       formatCost(CASE WHEN (recv_qty > 0) THEN COALESCE(recv_value,0) / recv_qty\n                       ELSE 0\n                  END)                AS f_recvcost,\n       formatMoney(recv_value)        AS f_value,\n  <? else ?>\n       NULL                           AS f_purchcost,\n       NULL                           AS f_recvcost,\n       NULL                           AS f_value,\n  <? endif ?>\n<? endif ?>\n       'qty'                  AS qty_xtnumericrole,\n       'cost'                 AS purchcost_xtnumericrole,\n       'cost'                 AS recvcost_xtnumericrole,\n       'curr'                 AS value_xtnumericrole,\n        <? value("na") ?>     AS duedate_xtnullrole,\n        <? value("na") ?>     AS purchcost_xtnullrole,\n        <? value("na") ?>     AS recvcost_xtnullrole\nFROM vend, recv LEFT OUTER JOIN\n    (itemsite JOIN\n     item ON (itemsite_item_id=item_id)) ON (recv_itemsite_id=itemsite_id)\nWHERE ( (recv_vend_id=vend_id)\n AND (recv_order_type='PO')\n AND (recv_posted)\n AND (DATE(recv_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value ("vend_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (recv_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if not exists("showUnvouchered") ?>\n AND (recv_vohead_id IS NOT NULL)\n AND (recv_invoiced)\n<? endif ?>\n)\nUNION\nSELECT poreject_id, 2, poreject_ponumber,\n       vend_name,\n       NULL,\n       poreject_date,\n       poreject_vend_item_number,\n       poreject_vend_item_descrip,\n       COALESCE(item_number,\n                (<? value("nonInv") ?> || poreject_vend_item_number)),\n       COALESCE(item_descrip1, poreject_vend_item_descrip),\n       <? value("returned") ?>,\n       poreject_qty,\n       NULL,\n       NULL,\n       poreject_value,\n       poreject_invoiced,\n       poreject_date,\n<? if exists("includeFormatted") ?>\n       NULL                           AS f_duedate,\n       formatDate(poreject_date)      AS f_recvdate,\n       formatQty(poreject_qty)        AS f_qty,\n       NULL                           AS f_purchcost,\n       NULL                           AS f_recvcost,\n       formatMoney(poreject_value)    AS f_value,\n<? endif ?>\n       'qty',\n       'cost',\n       'cost',\n       'curr',\n        <? value("na") ?>     AS duedate_xtnullrole,\n        <? value("na") ?>     AS purchcost_xtnullrole,\n        <? value("na") ?>     AS recvcost_xtnullrole\nFROM vend, poreject LEFT OUTER JOIN\n    (itemsite JOIN\n     item ON (itemsite_item_id=item_id)) ON (poreject_itemsite_id=itemsite_id)\nWHERE ( (poreject_vend_id=vend_id)\n AND (poreject_posted)\n AND (DATE(poreject_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value ("vend_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (poreject_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if not exists("showUnvouchered") ?>\n AND (poreject_vohead_id IS NOT NULL)\n AND (poreject_invoiced)\n<? endif ?>\n)\nORDER BY sortdate DESC;\n  admin   2011-11-23      0
161 123     updateprices    dropselsched     Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: updateprices\n-- Name: dropselsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDROP TABLE selsched;\n  admin   2011-11-23      0
162 124     updateprices    remove   Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: updateprices\n-- Name: remove\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM selsched\n<? if exists("ipshead_id") ?>\nWHERE (selsched_ipshead_id=<? value("ipshead_id") ?>)\n<? endif ?>\n;\n  admin   2011-11-23      0
163 283     standardJournalHistory  detail  used by dspStandardJournalHistory Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: standardJournalHistory\n-- Name: detail\n-- Notes: used by dspStandardJournalHistory\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_sequence, gltrans_id,\n       sortdate, sortdoc, level, gltrans_amount,\n       gltrans_date, gltrans_journalnumber, gltrans_posted,\n       gltrans_docnumber, account,\n       debit, credit,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       CASE WHEN (debit = 0) THEN '' END AS debit_qtdisplayrole,\n       CASE WHEN (credit = 0) THEN '' END AS credit_qtdisplayrole,\n       level AS xtindentrole \nFROM (SELECT DISTINCT gltrans_sequence, -1 AS gltrans_id,\n             gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 0 AS level, 0 AS gltrans_amount,\n             gltrans_date, gltrans_journalnumber, gltrans_posted,\n             NULL AS gltrans_docnumber,\n             NULL AS account,\n             0 AS debit, 0 AS credit\n      FROM gltrans, accnt \n      WHERE ( (gltrans_accnt_id=accnt_id)\n          AND (NOT gltrans_deleted) \n          AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n          AND (gltrans_doctype='ST') ) \n      UNION \n      SELECT DISTINCT gltrans_sequence, -1 AS gltrans_id,\n             gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 1 AS level, 0 AS gltrans_amount,\n             CAST(NULL AS DATE) AS gltrans_date, CAST(NULL AS INTEGER) AS gltrans_journalnumber, \n             CAST(NULL AS BOOLEAN) AS gltrans_posted,\n             CASE WHEN (COALESCE(gltrans_docnumber, '') = '') THEN 'Unnamed'\n               ELSE gltrans_docnumber\n             END AS gltrans_docnumber,\n             NULL AS account,\n             0 AS debit, 0 AS credit \n      FROM gltrans, accnt \n      WHERE ( (gltrans_accnt_id=accnt_id)\n          AND (NOT gltrans_deleted)\n          AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n          AND (gltrans_doctype='ST') ) \n      UNION \n      SELECT gltrans_sequence, gltrans_id,\n             gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 2 AS level, gltrans_amount,\n             CAST(NULL AS DATE) AS gltrans_date, CAST(NULL AS INTEGER) AS gltrans_journalnumber,\n             CAST(NULL AS BOOLEAN) AS gltrans_posted,\n             NULL AS gltrans_docnumber,\n             (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n             CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n             END AS debit,\n             CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n             END AS credit \n      FROM gltrans, accnt \n      WHERE ( (gltrans_accnt_id=accnt_id)\n          AND (NOT gltrans_deleted) \n          AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n          AND (gltrans_doctype='ST') ) \n      ) AS data \nORDER BY sortdate, gltrans_sequence, sortdoc, level, gltrans_amount;\n  admin   2011-11-23      0
164 452     reports detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: reports\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('byPackage') ?>\n  SELECT report_id, report_name,\n         firstline(report_descrip) AS report_descrip, report_grade,\n         CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n         CASE nspname WHEN 'public' THEN 0\n                      ELSE 1        END AS xtindentrole,\n         report_descrip AS report_descrip_qttooltiprole\n    FROM report\n    JOIN pg_class     ON (report.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n  UNION\n  SELECT -1, pkghead_name,\n         firstline(pkghead_descrip), NULL,\n         pkghead_name, 0, pkghead_descrip\n    FROM report, pg_class, pg_namespace\n    RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n   WHERE ((report.tableoid=pg_class.oid)\n      AND (relnamespace=pg_namespace.oid))\n  ORDER BY pkgname, xtindentrole, report_name,\n           report_grade DESC, report_id;\n<? else ?>\n  SELECT report_id, report_name,\n         firstline(report_descrip) AS report_descrip,\n         report_grade,\n         CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n         report_descrip AS report_descrip_qttooltiprole\n    FROM report\n    JOIN pg_class     ON (report.tableoid=pg_class.oid)\n    JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n  ORDER BY report_name,\n           report_grade DESC, report_id;\n<? endif ?>\n admin   2011-11-23      0
165 131     selectPayments  applyallcredits used by selectPayments Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: selectPayments\n-- Name: applyallcredits\n-- Notes: used by selectPayments\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT applyapcredits(vend_id) AS result\nFROM vend\nWHERE ((TRUE)\n<? if exists("vend_id") ?>\n   AND (vend_id = <? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n   AND (vend_vendtype_id = <? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n   AND (vend_vendtype_id IN (SELECT vendtype_id\n                             FROM vendtype\n                             WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n      );\n admin   2011-11-23      0
166 81      salesHistory    detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: salesHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohist.*,\n       CASE WHEN (cohist_invcnumber='-1') THEN  <? value("credit") ?>\n            ELSE cohist_invcnumber\n       END AS invoicenumber,\n       cust_number, cust_name, salesrep_name,\n       item_id, COALESCE(item_number, cohist_misc_descrip) AS item_number,\n       item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       warehous_code,\n       currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate) AS baseunitprice,\n       round((cohist_qtyshipped * cohist_unitprice), 2) AS extprice,\n       round((cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate)), 2) AS baseextprice,\n       round((cohist_qtyshipped * cohist_unitcost), 4) AS extcost,\n       currtobase(cohist_curr_id, cohist_commission, cohist_invcdate) AS basecommission,\n<? if exists("includeFormatted") ?>\n       formatDate(cohist_invcdate) AS f_invcdate,\n       formatQty(cohist_qtyshipped) AS f_qtyshipped,\n       formatBoolYN(cohist_commissionpaid) AS f_commissionpaid,\n       formatSalesPrice(currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate)) AS f_baseunitprice,\n       formatMoney(round((cohist_qtyshipped * cohist_unitprice), 2)) AS f_extprice,\n       formatMoney(round((cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate)), 2)) AS f_baseextprice,\n       formatMoney(round((cohist_qtyshipped * cohist_unitcost), 4)) AS f_extcost,\n       formatMoney(currtobase(cohist_curr_id, cohist_commission, cohist_invcdate)) AS f_basecommission,\n<? endif ?>\n       currConcat(cohist_curr_id) AS currAbbr,\n       <? value("return") ?> AS cohist_invcdate_xtnullrole,\n       'qty' AS cohist_qtyshipped_xtnumericrole,\n       'salesprice' AS cohist_unitprice_xtnumericrole,\n       'salesprice' AS baseunitprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS baseextprice_xtnumericrole,\n       'cost' AS cohist_unitcost_xtnumericrole,\n       'curr' AS extcost_xtnumericrole,\n       'curr' AS cohist_commission_xtnumericrole,\n       'curr' AS basecommission_xtnumericrole,\n       0 AS cohist_qtyshipped_xttotalrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS extcost_xttotalrole,\n       0 AS basecommission_xttotalrole\n  FROM cohist JOIN cust ON (cust_id=cohist_cust_id)\n              JOIN salesrep ON (salesrep_id=cohist_salesrep_id)\n<? if exists("includeMisc") ?>\n              LEFT OUTER JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n              LEFT OUTER JOIN site() ON (warehous_id=itemsite_warehous_id)\n              LEFT OUTER JOIN item ON (item_id=itemsite_item_id)\n<? else ?>\n              JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n<? endif ?>\n<? if exists("shipzone_id") ?>\n              JOIN shiptoinfo ON (shipto_id=cohist_shipto_id)\n              JOIN shipzone ON (shipzone_id=shipto_shipzone_id)\n<? endif ?>\n<? if exists("cohead_id") ?>\n              JOIN cohead ON (cohead_number=cohist_ordernumber)\n<? endif ?>\nWHERE ( (true)\n<? if exists("includeMisc") ?>\n  AND  (COALESCE(cohist_misc_type, '') <> 'F')\n  AND  (COALESCE(cohist_misc_type, '') <> 'T')\n<? endif ?>\n<? if exists("startDate") ?>\n  AND  (cohist_invcdate >= <? value("startDate") ?>)\n<? endif ?>\n<? if exists("endDate") ?>\n  AND  (cohist_invcdate <= <? value("endDate") ?>)\n<? endif ?>\n<? if exists("shipStartDate") ?>\n  AND  (cohist_shipdate >= <? value("shipStartDate") ?>)\n<? endif ?>\n<? if exists("shipEndDate") ?>\n  AND  (cohist_shipdate <= <? value("shipEndDate") ?>)\n<? endif ?>\n<? if exists("salesrep_id") ?>\n  AND  (cohist_salesrep_id=<? value("salesrep_id") ?>)\n<? endif ?>\n<? if exists("shipto_id") ?>\n  AND  (cohist_shipto_id=<? value("shipto_id") ?>)\n<? endif ?>\n<? if exists("billToName") ?>\n  AND  (UPPER(cohist_billtoname) ~ UPPER(<? value("billToName") ?>))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND  (cohist_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND  (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n  AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                             FROM custtype\n                             WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("by_custgrp" ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrpitem))\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrpitem\n                   WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n<? endif ?>\n<? if exists("custgrp_pattern") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrp, custgrpitem\n                   WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                     AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n<? endif ?>\n\n<? if exists("item_id") ?>\n  AND  (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("prodcat_id") ?>\n  AND (item_prodcat_id=<? value("prodcat_id") ?>)\n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n  AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                           FROM prodcat\n                           WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n\n<? if exists("warehous_id") ?>\n  AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("shipzone_id") ?>\n  AND (shipzone_id=<? value("shipzone_id") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n  AND (cohead_id=<? value("cohead_id") ?>)\n<? endif ?>\n      )\nORDER BY cohist_invcdate, item_number;\n\n        admin   2011-11-23      0
167 82      salesOrderItems detail  used by dspBacklogByCustomer, dspBacklogByItem, dspBacklogByParameterList, dspBacklogBySalesOrder, dspBookingsByCustomer, dspBookingsByCustomerGroup, dspBookingsByItem, dspBookingsByProductCategory, dspBookingsBySalesRep, dspBookingsByShipTo, dspSalesOrdersByItem Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: salesOrderItems\n-- Name: detail\n-- Notes: used by dspBacklogByCustomer, dspBacklogByItem, dspBacklogByParameterList, dspBacklogBySalesOrder, dspBookingsByCustomer, dspBookingsByCustomerGroup, dspBookingsByItem, dspBookingsByProductCategory, dspBookingsBySalesRep, dspBookingsByShipTo, dspSalesOrdersByItem\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n       cohead_id, coitem_id, *, currconcat(cohead_curr_id) AS currAbbr,\n<? if exists("item_id") ?>\n       CASE WHEN xtindentrole = 0 THEN cust_name\n       END AS item_number_qtdisplayrole,\n<? elseif exists("salesrep_id") ?>\n-- no alterations to displayroles\n<? elseif not exists("cohead_id") ?>\n       CASE WHEN xtindentrole = 0 THEN cohead_number\n       END AS coitem_linenumber_qtdisplayrole,\n       CASE WHEN xtindentrole = 0 THEN cust_name\n       END AS item_number_qtdisplayrole,\n <? endif ?>\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS coitem_qtyshipped_xtnumericrole,\n       'qty' AS coitem_qtyreturned_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'qty' AS qtybalance_xtnumericrole,\n       'qty' AS qtyavailable_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'salesprice' AS baseunitprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS baseextprice_xtnumericrole,\n       'curr' AS extpricebalance_xtnumericrole,\n       'curr' AS baseextpricebalance_xtnumericrole,\n       0 AS coitem_qtyord_xttotalrole,\n       0 AS coitem_qtyshipped_xttotalrole,\n       0 AS coitem_qtyreturned_xttotalrole,\n       0 AS qtybalance_xttotalrole,\n       0 AS baseextprice_xttotalrole,\n       0 AS baseextpricebalance_xttotalrole\nFROM (\n  <? if not exists("cohead_id") ?> -- get cohead info\n  <? if not exists("item_id") ?>\n  <? if not exists("salesrep_id") ?>\n  SELECT \n         0 AS xtindentrole,\n         -- dummy coitem record\n         -1            AS coitem_id,        NULL::INTEGER AS coitem_cohead_id,\n         -1            AS coitem_linenumber,NULL::INTEGER AS coitem_itemsite_id,\n         NULL::TEXT    AS coitem_status,    NULL::DATE AS coitem_scheddate,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         NULL::DATE    AS coitem_promdate,  NULL::NUMERIC AS coitem_qtyord,\n         NULL::NUMERIC AS coitem_unitcost,  NULL::NUMERIC AS coitem_price,\n         NULL::NUMERIC AS coitem_custprice, NULL::NUMERIC AS coitem_qtyshipped,\n         NULL::INTEGER AS coitem_order_id,  NULL::TEXT    AS coitem_memo,\n         NULL::BOOLEAN AS coitem_imported,  NULL::NUMERIC AS coitem_qtyreturned,\n         NULL::TIMESTAMP AS coitem_closedate,\n         NULL::TEXT    AS coitem_custpn,    NULL::TEXT    AS coitem_order_type,\n         NULL::TEXT    AS coitem_close_username,\n         NULL::TIMESTAMP AS coitem_lastupdated,\n         NULL::INTEGER AS coitem_substitute_item_id,\n         NULL::TIMESTAMP AS coitem_created, NULL::TEXT    AS coitem_creator,\n         NULL::NUMERIC AS coitem_prcost,\n         NULL::INTEGER AS coitem_qty_uom_id,\n         NULL::NUMERIC AS coitem_qty_invuomratio,\n         NULL::INTEGER AS coitem_price_uom_id,\n         NULL::NUMERIC AS coitem_price_invuomratio,\n         NULL::BOOLEAN AS coitem_warranty,\n         NULL::INTEGER AS coitem_cos_accnt_id,\n         NULL::NUMERIC AS coitem_qtyreserved,\n         NULL::INTEGER AS coitem_subnumber,\n         cohead.*,\n         cust_number, cust_name,\n         NULL::TEXT AS item_number, NULL::TEXT AS item_descrip1,\n         NULL::TEXT AS itemdescription,\n         NULL::TEXT AS uom_name,\n         NULL::TEXT AS warehous_code,\n         NULL::NUMERIC AS qtyatshipping,\n         NULL::NUMERIC AS qtyavailable,\n         NULL::BOOLEAN AS stockout,\n         NULL::BOOLEAN AS reorder,\n         NULL::NUMERIC AS qtybalance,\n         NULL::NUMERIC AS baseunitprice,\n         NULL::NUMERIC AS extprice,\n         NULL::NUMERIC AS baseextprice,\n         NULL::NUMERIC AS extpricebalance,\n         NULL::NUMERIC AS baseextpricebalance,\n         NULL::TEXT    AS qtyavailable_qtforegroundrole\n\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN cust ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n  WHERE ( (coitem_status<>'X')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("openOnly") ?>\n    AND  (coitem_status<>'C')\n  <? endif ?>\n  <? if exists("startDate") ?>\n    <? if exists("orderByOrderdate") ?>\n    AND  (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? else ?>\n    AND  (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?>\n  <? endif ?>\n\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? elseif exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? elseif exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? elseif exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? elseif exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? elseif exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? elseif exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n        )\n\n  UNION\n  <? endif ?> -- endif not exists "salesrep_id"\n  <? endif ?> -- endif not exists "item_id"\n  <? endif ?> -- endif not exists "cohead_id"\n\n  SELECT \n         <? if exists("cohead_id") ?> 0\n         <? elseif exists("item_id") ?> 0\n         <? elseif exists("salesrep_id") ?> 0\n         <? else ?> 1 <? endif ?> AS xtindentrole,\n         coitem_id,        coitem_cohead_id,\n         coitem_linenumber,coitem_itemsite_id,\n         coitem_status,    coitem_scheddate,\n         getSoSchedDate(cohead_id) AS sort_scheddate,\n         coitem_promdate,  coitem_qtyord,\n         coitem_unitcost,  coitem_price,\n         coitem_custprice, coitem_qtyshipped,\n         coitem_order_id,  coitem_memo,\n         coitem_imported,  coitem_qtyreturned,\n         coitem_closedate,\n         coitem_custpn,    coitem_order_type,\n         coitem_close_username,\n         coitem_lastupdated,\n         coitem_substitute_item_id,\n         coitem_created,   coitem_creator,\n         coitem_prcost,\n         coitem_qty_uom_id,\n         coitem_qty_invuomratio,\n         coitem_price_uom_id,\n         coitem_price_invuomratio,\n         coitem_warranty,\n         coitem_cos_accnt_id,\n         coitem_qtyreserved,\n         coitem_subnumber,\n         cohead.*,\n         cust_number, cust_name,\n         item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n         uom_name,\n         warehous_code,\n         ( SELECT SUM(coship_qty)\n             FROM coship JOIN cosmisc ON ( (coship_cosmisc_id=cosmisc_id) AND (NOT cosmisc_shipped) )\n            WHERE (coship_coitem_id=coitem_id) ) AS qtyatshipping,\n         qtyAvailable(itemsite_id, coitem_scheddate) AS qtyavailable,\n         (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) AS stockout,\n         CASE WHEN (itemsite_useparams) THEN (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel)\n              ELSE (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0)\n         END AS reorder,\n         noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n         currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n         round((coitem_qtyord * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n         round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n                     (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance,\n         CASE WHEN (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) THEN 'error'\n              WHEN itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel) THEN 'warning'\n              WHEN NOT itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0) THEN 'warning'\n         END AS qtyavailable_qtforegroundrole\n\n  FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n              JOIN cust ON (cust_id=cohead_cust_id)\n              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n              JOIN site() ON (warehous_id=itemsite_warehous_id)\n              JOIN item ON (item_id=itemsite_item_id)\n              JOIN uom ON (uom_id=coitem_qty_uom_id)\n  WHERE ( (coitem_status<>'X')\n  <? if exists("cohead_id") ?>\n    AND  (coitem_cohead_id=<? value("cohead_id") ?>)\n  <? endif ?>\n  <? if exists("openOnly") ?>\n    AND  (coitem_status<>'C')\n  <? endif ?>\n  <? if exists("startDate") ?>\n    <? if exists("orderByOrderdate") ?>\n    AND  (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? else ?>\n    AND  (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?>\n  <? endif ?>\n\n  <? if exists("salesrep_id") ?>\n    AND  (cohead_salesrep_id=<? value("salesrep_id") ?>)\n  <? endif ?>\n  <? if exists("shipto_id") ?>\n    AND  (cohead_shipto_id=<? value("shipto_id") ?>)\n  <? endif ?>\n  <? if exists("cust_id") ?>\n    AND  (cohead_cust_id=<? value("cust_id") ?>)\n  <? elseif exists("custtype_id") ?>\n    AND  (cust_custtype_id=<? value("custtype_id") ?>)\n  <? elseif exists("custtype_pattern") ?>\n    AND  (cust_custtype_id IN (SELECT DISTINCT custtype_id\n                               FROM custtype\n                               WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n  <? elseif exists("custgrp") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem))\n  <? elseif exists("custgrp_id") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrpitem\n                     WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n  <? elseif exists("custgrp_pattern") ?>\n    AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                     FROM custgrp, custgrpitem\n                     WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                       AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n  <? endif ?>\n\n  <? if exists("item_id") ?>\n    AND  (itemsite_item_id=<? value("item_id") ?>)\n  <? elseif exists("prodcat_id") ?>\n    AND (item_prodcat_id=<? value("prodcat_id") ?>)\n  <? elseif exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n                             FROM prodcat\n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n  <? endif ?>\n\n  <? if exists("warehous_id") ?>\n    AND  (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n        )\n\n) AS dummy\n\n<? if exists("orderByScheddate") ?>\n  ORDER BY sort_scheddate, cohead_number, coitem_linenumber\n<? elseif exists("orderByOrderdate") ?>\n  ORDER BY cohead_orderdate, cohead_number, coitem_linenumber\n<? else ?>\n  ORDER BY cohead_number, coitem_linenumber\n<? endif ?>\n;\n  admin   2011-11-23      0
168 433     salesOrderItems list    used by salesOrder Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: salesOrderItems\n-- Name: list\n-- Notes: used by salesOrder\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT coitem_id, coitem_altid, groupby,\n       coitem_linenumber, coitem_subnumber, f_linenumber,\n       warehous_code, item_number, item_type, description,\n       item_number_cust, item_descrip1_cust, item_descrip2_cust, item_barcode,\n       enhanced_status, coitem_firm,\n       qty_uom, price_uom, ship_uom,\n       coitem_memo,\n-- always create formatted columns for scheduled reports\n       formatDate(coitem_scheddate) AS f_scheddate,\n       formatSalesPrice(coitem_price) AS f_price,\n       formatSalesPrice(coitem_custprice) AS f_custprice,\n       formatPrcnt(discountfromcust / 100) AS f_discountfromcust,\n       formatQty(coitem_qtyord) AS f_qtyord, \n       CASE WHEN (qtyshipped > 0.0) THEN formatQty(qtyshipped) ELSE NULL END AS f_qtyshipped,\n       CASE WHEN (qtyshipped > 0.0) THEN formatQty(balance) ELSE NULL END AS f_balance,\n       CASE WHEN (qtyatshipping > 0.0) THEN formatQty(qtyatshipping) ELSE NULL END AS f_qtyatshipping,\n       formatMoney(extprice) AS f_extprice,\n       CASE WHEN (extprice_shipped > 0.0) THEN formatMoney(extprice_shipped) ELSE NULL END AS f_extprice_shipped,\n-- end formatted columns\n       coitem_scheddate, coitem_price, coitem_custprice, discountfromcust,\n       coitem_qtyord, qtyshipped, balance, qtyatshipping,\n       extprice, extprice_shipped,\n       CASE WHEN (discountfromcust=100.0) THEN 'N/A' END AS discountfromcust_qtdisplayrole,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS qtyshipped_xtnumericrole,\n       'qty' AS balance_xtnumericrole,\n       'qty' AS qtyatshipping_xtnumericrole,\n       'salesprice' AS coitem_price_xtnumericrole,\n       'salesprice' AS coitem_custprice_xtnumericrole,\n       'curr' AS extprice_xtnumericrole,\n       'curr' AS extprice_shipped_xtnumericrole,\n       CASE WHEN fetchMetricBool('EnableSOShipping') AND\n                 coitem_scheddate > CURRENT_DATE AND\n                 (noNeg(coitem_qtyord) <> qtyAtShipping('SO', coitem_id)) THEN 'future'\n            WHEN fetchMetricBool('EnableSOShipping') AND\n                 (noNeg(coitem_qtyord) <> qtyAtShipping('SO', coitem_id)) THEN 'expired'\n            WHEN (coitem_status NOT IN ('C', 'X') AND\n                  EXISTS(SELECT coitem_id\n                         FROM coitem\n                         WHERE ((coitem_status='C')\n                           AND  (coitem_cohead_id=<? value("cohead_id") ?>)))) THEN 'error'\n       END AS coitem_scheddate_qtforegroundrole,\n       CASE WHEN coitem_subnumber = 0 THEN 0\n            ELSE 1\n       END AS xtindentrole,\n       spplytype, ordrnumbr\nFROM (\nSELECT coitem_id,\n       CASE WHEN (coitem_status='C') THEN 1\n            WHEN (coitem_status='X') THEN 4\n            WHEN ( (coitem_status='O') AND ( (qtyAtShipping('SO', coitem_id) > 0) OR (coitem_qtyshipped > 0) ) ) THEN 2\n            ELSE 3\n       END AS coitem_altid, 1 AS groupby,\n       coitem_linenumber, coitem_subnumber, formatSoLineNumber(coitem_id) AS f_linenumber,\n       warehous_code, item_number, item_type,\n       (item_descrip1 || ' ' || item_descrip2) AS description,\n       CASE WHEN (coitem_custpn != '') THEN coitem_custpn\n            ELSE item_number\n       END AS item_number_cust,\n       CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n            ELSE item_descrip1\n       END AS item_descrip1_cust,\n       CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n            ELSE item_descrip2\n       END AS item_descrip2_cust,\n       formatitemsitebarcode(itemsite_id) AS item_barcode,\n       coitem_status, coitem_firm,\n      (CASE WHEN (coitem_status='O' AND (SELECT cust_creditstatus FROM custinfo WHERE cust_id=cohead_cust_id)='H') THEN 'H'\n            WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed)\n                                            FROM cohead, invchead, invcitem\n                                           WHERE ((CAST(invchead_ordernumber AS text)=cohead_number)\n                                             AND  (invcitem_invchead_id=invchead_id)\n                                             AND  (invcitem_item_id=item_id)\n                                             AND  (invcitem_warehous_id=warehous_id)\n                                             AND  (invcitem_linenumber=coitem_linenumber)\n                                             AND  (cohead_id=coitem_cohead_id))) >= coitem_qtyord)) THEN 'I'\n            WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed)\n                                            FROM cohead, invchead, invcitem\n                                           WHERE ((CAST(invchead_ordernumber AS text)=cohead_number)\n                                             AND  (invcitem_invchead_id=invchead_id)\n                                             AND  (invcitem_item_id=item_id)\n                                             AND  (invcitem_warehous_id=warehous_id)\n                                             AND  (invcitem_linenumber=coitem_linenumber)\n                                             AND  (cohead_id=coitem_cohead_id))) > 0)) THEN 'P'\n            WHEN (coitem_status='O' AND (itemsite_qtyonhand - qtyAllocated(itemsite_id, CURRENT_DATE)\n                                         + qtyOrdered(itemsite_id, CURRENT_DATE))\n                                          >= ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)) THEN 'R'\n            ELSE coitem_status END\n       || CASE WHEN (coitem_firm) THEN 'F' ELSE '' END\n       ) AS enhanced_status,\n       quom.uom_name AS qty_uom, puom.uom_name AS price_uom,\n       itemSellingUOM(item_id) AS ship_uom,\n       coitem_memo,\n       coitem_scheddate, coitem_price, coitem_custprice, coitem_qtyord,\n       CASE WHEN (coitem_custprice = 0.0) THEN 100.0\n            ELSE ((1.0 - (coitem_price / coitem_custprice)) * 100.0)\n       END AS discountfromcust,\n       noNeg(coitem_qtyshipped - coitem_qtyreturned) AS qtyshipped,\n       noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS balance,\n       qtyAtShipping('SO', coitem_id) AS qtyatshipping,\n       ROUND((coitem_qtyord * coitem_qty_invuomratio) *\n             (coitem_price / coitem_price_invuomratio),2) AS extprice,\n       ROUND(((coitem_qtyshipped - coitem_qtyreturned) * coitem_qty_invuomratio) *\n              (coitem_price / coitem_price_invuomratio),2) AS extprice_shipped,\n       CASE WHEN coitem_order_type='W' THEN TEXT( 'WO')\n            WHEN coitem_order_type='P' THEN TEXT('PO' )\n            WHEN coitem_order_type='R' THEN TEXT('PR')\n            ELSE TEXT (' ')\n       END AS spplytype,\n       CASE WHEN coitem_order_type='W' THEN (wo_number || '-' || wo_subnumber)\n            WHEN coitem_order_type='P' THEN (pohead_number || '-' || poitem_linenumber)\n            WHEN coitem_order_type='R' THEN (pr_number || '-' || pr_subnumber)\n            ELSE TEXT (' ')\n       END AS ordrnumbr\n  FROM cohead\n       JOIN coitem ON (coitem_cohead_id=cohead_id)\n       JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n       JOIN item ON (item_id=itemsite_item_id)\n       JOIN whsinfo ON (warehous_id=itemsite_warehous_id)\n       JOIN uom AS quom ON (quom.uom_id=coitem_qty_uom_id)\n       JOIN uom AS puom ON (puom.uom_id=coitem_price_uom_id)\n       LEFT OUTER JOIN itemalias ON ((itemalias_item_id=item_id) AND (itemalias_number=coitem_custpn))\n       LEFT OUTER JOIN wo ON (coitem_order_id = wo_id)\n       LEFT OUTER JOIN pr ON (coitem_order_id = pr_id)\n       LEFT OUTER JOIN (pohead JOIN poitem ON (pohead_id = poitem_pohead_id))\n         ON (coitem_order_id = poitem_id)\n WHERE (cohead_id=<? value("sohead_id") ?>)\n\n<? if exists("excludeCancelled") ?>\n AND (coitem_status != 'X')\n<? endif?>\n\n<? if exists("excludeClosed") ?>\n AND (coitem_status != 'C')\n<? endif?>\n\n<? if exists("excludeKits") ?>\n AND (item_type != 'K')\n<? endif?>\n\n) AS data\nORDER BY coitem_linenumber, coitem_subnumber;\n   admin   2011-11-23      0
169 83      salesOrders     detail  used by dspSalesOrdersByCustomer, dspSalesOrdersByCustomerPO, dspSalesOrdersByParameterList Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: salesOrders\n-- Name: detail\n-- Notes: used by dspSalesOrdersByCustomer, dspSalesOrdersByCustomerPO, dspSalesOrdersByParameterList\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, cust_id,\n       cohead.*,\n       cust_number, cust_name,\n       getSoSchedDate(cohead_id) AS min_scheddate,\n       CASE\n         WHEN ( (SELECT COUNT(*)\n                   FROM coitem\n                  WHERE ((coitem_status<>'X') AND (coitem_cohead_id=cohead_id))) = 0) THEN <? value("noLines") ?>\n         WHEN ( ( (SELECT COUNT(*)\n                     FROM coitem\n                    WHERE ((coitem_status='C')\n                      AND (coitem_cohead_id=cohead_id))) > 0)\n                      AND ( (SELECT COUNT(*)\n                               FROM coitem\n                              WHERE ((coitem_status NOT IN ('C','X'))\n                                AND (coitem_cohead_id=cohead_id))) = 0) ) THEN <? value("closed") ?>\n         WHEN ( ( (SELECT COUNT(*)\n                     FROM coitem\n                    WHERE ((coitem_status='C')\n                      AND (coitem_cohead_id=cohead_id))) = 0)\n                      AND ( (SELECT COUNT(*)\n                               FROM coitem\n                              WHERE ((coitem_status NOT IN ('C','X'))\n                                AND (coitem_cohead_id=cohead_id))) > 0) ) THEN <? value("open") ?>\n         ELSE <? value("partial") ?>\n       END AS order_status\nFROM cohead JOIN cust ON (cust_id=cohead_cust_id)\nWHERE ( (1=1)\n<? if exists("cust_id") ?>\n  AND  (cohead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND  (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND  (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("poNumber") ?>\n  AND  (cohead_custponumber~*<? value("poNumber") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND  (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n  AND   ((SELECT COUNT(*)\n         FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n                     JOIN site() ON (warehous_id=itemsite_warehous_id)\n        WHERE (coitem_cohead_id=cohead_id)) > 0) )\n<? if exists("orderByCust") ?>\n  ORDER BY cust_number, cohead_number;\n<? else ?>\nORDER BY cohead_number;\n<? endif ?>\n\n   admin   2011-11-23      0
170 281     salesOrderStatus        detail  used by dspSalesOrderStatus Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: salesOrderStatus\n-- Name: detail\n-- Notes: used by dspSalesOrderStatus\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT coitem_id, coitem_linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       warehous_code,\n       coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned,\n       SUM(COALESCE(cobill_qty, 0)) AS invoiced,\n       noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS balance,\n       CASE WHEN (coitem_status='C') THEN coitem_closedate END AS closedate,\n       CASE WHEN (coitem_status='C') THEN coitem_close_username END AS closeuser,\n       CASE WHEN (coitem_order_id=-1) THEN ''\n            WHEN (coitem_order_type='W') THEN ( SELECT (formatWoNumber(wo_id) || '/' || wo_status)\n                                                FROM wo\n                                                WHERE (wo_id=coitem_order_id) )\n         ELSE ''\n       END AS childinfo,\n       'qty' AS coitem_qtyord_xtnumericrole,\n       'qty' AS coitem_qtyshipped_xtnumericrole,\n       'qty' AS coitem_qtyreturned_xtnumericrole,\n       'qty' AS invoiced_xtnumericrole,\n       'qty' AS balance_xtnumericrole \nFROM itemsite, item, warehous, coitem LEFT OUTER JOIN\n     cobill ON (coitem_id=cobill_coitem_id AND\n                cobill_invcitem_id IS NOT NULL)\nWHERE ( (coitem_itemsite_id=itemsite_id)\n    AND (coitem_status <> 'X')\n    AND (itemsite_item_id=item_id)\n    AND (itemsite_warehous_id=warehous_id)\n    AND (coitem_cohead_id=<? value("sohead_id") ?>) ) \nGROUP BY coitem_id, coitem_linenumber, item_number, \n         item_descrip1, item_descrip2, warehous_code, \n         coitem_qtyord, coitem_qtyshipped, coitem_status, \n         coitem_closedate, coitem_close_username, \n         coitem_qtyreturned, coitem_order_id, \n         coitem_order_type \nORDER BY coitem_linenumber;\n     admin   2011-11-23      0
171 125     updateprices    selsched         Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: updateprices\n-- Name: selsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT selsched_ipshead_id, ipshead_name, ipshead_descrip\nFROM selsched\n JOIN ipshead ON (selsched_ipshead_id=ipshead_id)\nORDER BY ipshead_name\n        admin   2011-11-23      0
172 84      schedule        plannedorders   used by dpsPlannedOrdersByItem, dspPlannedOrdersByPlannerCode, dspPlannedRevenueExpensesByPlannerCode   -- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n -- Group: schedule\n -- Name:  plannedorders\n -- Notes: used by dpsPlannedOrdersByItem, dspPlannedOrdersByPlannerCode, dspPlannedRevenueExpensesByPlannerCode\n SELECT *,\n        plorevenue - plocost AS profit,\n        formatMoney(plorevenue - plocost) AS f_profit,\n        CASE WHEN plocost > plorevenue THEN 'error'\n        END AS plorevenue_xtforegroundrole,\n        CASE WHEN (planord_firm) THEN 'emphasis'\n        END AS qtforegroundrole,\n        'qty' AS planord_qty_xtnumericrole,\n        'curr' AS plocost_xtnumericrole,\n        'curr' AS plorevenue_xtnumericrole,\n        'curr' AS profit_xtnumericrole,\n        0 AS plocost_xttotalrole,\n        0 AS plorevenue_xttotalrole,\n        0 AS profit_xttotalrole\n FROM (\n SELECT planord_id, planord_itemsite_id,\n        planord.*,\n        formatPloNumber(planord_id) AS ordernum,\n        CASE WHEN (planord_type='P') THEN 'P/O'\n             WHEN (planord_type='W') THEN 'W/O'\n             WHEN (planord_type='T') THEN 'T/O'\n             ELSE '?'\n        END AS ordtype,\n        formatDate(planord_duedate) AS f_duedate,\n        formatDate(planord_startdate) AS f_startdate,\n        formatQty(planord_qty) AS f_qty,\n        formatboolYN(planord_firm) AS f_firm,\n        whsinfo.warehous_code AS warehous_code,\n        supplywhsinfo.warehous_code AS supply_warehous_code,\n        item_number,\n        (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n        firstline(planord_comments) AS comments,\n        uom_name,\n <? if exists("useActualCost") ?>\n        (actcost(item_id) * planord_qty)\n <? elseif exists("useStandardCost") ?>\n        (stdcost(item_id) * planord_qty)\n <? else ?>\n        0\n <? endif ?> AS plocost,\n <? if exists("useListPrice") ?>\n        (item_listprice * planord_qty)\n <? elseif exists("useAveragePrice") ?>\n        (CASE WHEN(averageSalesPrice(itemsite.itemsite_id,\n                                <? value("startEvalDate") ?>,\n                                <? value("endEvalDate") ?>)=0)\n                                THEN item_listprice\n              ELSE averageSalesPrice(itemsite.itemsite_id,\n                                <? value("startEvalDate") ?>,\n                                <? value("endEvalDate") ?>)\n              END * planord_qty)\n <? else ?>\n         0\n <? endif ?> AS plorevenue,\n <? if exists("useActualCost") ?>\n        formatMoney(actcost(item_id) * planord_qty)\n <? elseif exists("useStandardCost") ?>\n        formatMoney(stdcost(item_id) * planord_qty)\n <? else ?>\n        formatMoney(0)\n <? endif ?> AS f_plocost,\n <? if exists("useListPrice") ?>\n        formatMoney(item_listprice * planord_qty)\n <? elseif exists("useAveragePrice") ?>\n        formatMoney(CASE WHEN(averageSalesPrice(itemsite.itemsite_id,\n                                                <? value("startEvalDate") ?>,\n                                                <? value("endEvalDate") ?>)=0)\n                                 THEN item_listprice\n                         ELSE averageSalesPrice(itemsite.itemsite_id,\n                                                <? value("startEvalDate") ?>,\n                                                <? value("endEvalDate") ?>)\n                    END * planord_qty)\n <? else ?>\n         formatMoney(0)\n <? endif ?> AS f_plorevenue\n FROM planord JOIN itemsite ON (planord_itemsite_id=itemsite.itemsite_id)\n              JOIN whsinfo ON (itemsite.itemsite_warehous_id=whsinfo.warehous_id)\n              JOIN item ON (itemsite.itemsite_item_id=item_id)\n              JOIN uom ON (item_inv_uom_id=uom_id)\n              LEFT OUTER JOIN itemsite supplyitemsite ON (planord_supply_itemsite_id=supplyitemsite.itemsite_id)\n              LEFT OUTER JOIN whsinfo supplywhsinfo ON (supplyitemsite.itemsite_warehous_id=supplywhsinfo.warehous_id)\n WHERE (TRUE\n <? if exists("item_id") ?>\n    AND (itemsite.itemsite_item_id=<? value("item_id") ?>)\n <? endif ?>\n <? if exists("plancode_id") ?>\n    AND (itemsite.itemsite_plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n    AND (itemsite.itemsite_plancode_id IN (SELECT plancode_id\n                                           FROM plancode\n                                           WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n <? endif ?>\n <? if exists("warehous_id") ?>\n    AND (itemsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n <? if exists("startDate") ?>\n    AND (planord_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n <? endif ?>\n <? if exists("soldOnly") ?>\n    AND (item_sold)\n <? endif ?>\n  ) ) AS data\n ORDER BY planord_duedate, item_number;\n  admin   2011-11-23      0
173 453     scripts detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: scripts\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('byPackage') ?>\nSELECT script_id, script_name, script_enabled,\n       firstline(script_notes) AS script_notes, script_order,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       CASE nspname WHEN 'public' THEN 0\n                                  ELSE 1 END AS xtindentrole,\n       script_notes AS script_notes_qttooltiprole\n  FROM script\n  JOIN pg_class     ON (script.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n UNION \nSELECT -1, pkghead_name, NULL,\n       firstline(pkghead_descrip), NULL,\n       pkghead_name, 0, pkghead_descrip \n  FROM script, pg_class, pg_namespace\n     RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n   WHERE ((script.tableoid=pg_class.oid)\n     AND  (relnamespace=pg_namespace.oid))\n   ORDER BY pkgname, xtindentrole, script_name, script_order, script_id;\n<? else ?>\nSELECT script_id, script_name, script_enabled,\n       firstline(script_notes) AS script_notes, script_order,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       script_notes AS script_notes_qttooltiprole\n  FROM script\n  JOIN pg_class     ON (script.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY script_name, script_order, script_id;\n<? endif ?>\n       admin   2011-11-23      0
174 85      shipments       detail  used by dspShipmentsByDate, dspShipmentsBySalesOrder, dspShipmentsByShipment Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: shipments\n-- Name: detail\n-- Notes: used by dspShipmentsByDate, dspShipmentsBySalesOrder, dspShipmentsByShipment\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT shiphead_id, lineitem_id,\n       CASE WHEN (level=0) THEN order_number\n            ELSE item_number\n       END AS order_item,\n       CASE WHEN (level=0) THEN customer\n            ELSE itemdescription\n       END AS cust_desc,\n       shiphead_order_type,\n       shiphead_number, \n       order_number, \n       customer,\n       shiphead_shipdate,\n       formatDate(shiphead_shipdate) AS f_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       freight_curr_abbr,\n       linenumber,\n       item_number,\n       itemdescription,\n       warehous_code,\n       qtyord,\n       formatQty(qtyord) AS f_qtyord,\n       qtyshipped,\n       formatQty(qtyshipped) AS f_qtyshipped,\n       'qty' AS qtyord_xtnumericrole,\n       'qty' AS qtyshipped_xtnumericrole,\n       'curr' AS shiphead_freight_xtnumericrole,\n       CASE WHEN (COALESCE(linenumber, 0) = 0) THEN '' END AS linenumber_qtdisplayrole,\n       CASE WHEN (COALESCE(qtyord, 0) = 0) THEN '' END AS qtyord_qtdisplayrole,\n       CASE WHEN (COALESCE(qtyshipped, 0) = 0) THEN '' END AS qtyshipped_qtdisplayrole,\n       CASE WHEN (COALESCE(shiphead_freight, 0) = 0) THEN '' END AS shiphead_freight_qtdisplayrole,\n       level AS xtindentrole\nFROM (\nSELECT shiphead_id, -1 AS lineitem_id, cohead_number AS sortkey1, shiphead_number AS sortkey2, 0 AS level,\n       shiphead_order_type,\n       shiphead_number,\n       cohead_number AS order_number, \n       (cust_number || '-' || cust_name) AS customer,\n       shiphead_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n       0 AS linenumber, '' AS item_number,\n       '' AS itemdescription,\n       '' AS warehous_code,\n       0 AS qtyord,\n       0 AS qtyshipped\nFROM shiphead, cohead, cust \nWHERE ( (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='SO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("sohead_id") ?>\n AND (cohead_id = <? value("sohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n      ) \nUNION\nSELECT shiphead_id, coitem_id AS lineitem_id, cohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n       '' AS shiphead_order_type,\n       '' AS shiphead_number,\n       '' AS order_number, \n       '' AS customer,\n       CAST(NULL AS DATE) AS shiphead_shipdate,\n       '' AS shiphead_tracknum,\n       0 AS shiphead_freight,\n       '' AS freight_curr_abbr, \n       coitem_linenumber AS linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       warehous_code,\n       coitem_qtyord AS qtyord,\n       SUM(shipitem_qty) AS qtyshipped\nFROM shipitem, shiphead, coitem, cohead, cust, itemsite, item, warehous \nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_status <> 'X')\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='SO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("sohead_id") ?>\n AND (cohead_id = <? value("sohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n      ) \nGROUP BY shiphead_id, coitem_id, shiphead_order_type, shiphead_number,\n         cohead_number, cust_number, cust_name, shiphead_shipdate,\n         coitem_linenumber, item_number, item_descrip1, item_descrip2,\n         warehous_code, shiphead_tracknum, coitem_qtyord, \n         shiphead_freight, shiphead_freight_curr_id \n<? if exists("MultiWhs") ?>\nUNION\nSELECT shiphead_id, -1 AS lineitem_id, tohead_number AS sortkey1, shiphead_number AS sortkey2, 0 AS level,\n       shiphead_order_type,\n       shiphead_number,\n       tohead_number AS order_number, \n       tohead_destname AS customer,\n       shiphead_shipdate,\n       shiphead_tracknum,\n       shiphead_freight,\n       currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n       0 AS linenumber, '' AS item_number,\n       '' AS itemdescription,\n       '' AS warehous_code,\n       0 AS qtyord,\n       0 AS qtyshipped\nFROM shiphead, tohead \nWHERE ( (shiphead_order_id=tohead_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='TO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tohead_id") ?>\n AND (tohead_id = <? value("tohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n      ) \nUNION\nSELECT shiphead_id, toitem_id AS lineitem_id, tohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n       '' AS shiphead_order_type,\n       '' AS shiphead_number,\n       '' AS order_number, \n       '' AS customer,\n       CAST(NULL AS DATE) AS shiphead_shipdate,\n       '' AS shiphead_tracknum,\n       0 AS shiphead_freight,\n       '' AS freight_curr_abbr, \n       toitem_linenumber AS linenumber, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n       tohead_srcname AS warehous_code,\n       toitem_qty_ordered AS qtyord,\n       SUM(shipitem_qty) AS qtyshipped\nFROM shipitem, shiphead, toitem, tohead, item \nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=toitem_id)\n AND (toitem_status <> 'X')\n AND (toitem_item_id=item_id)\n AND (shiphead_order_id=tohead_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='TO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tohead_id") ?>\n AND (tohead_id = <? value("tohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n      ) \nGROUP BY shiphead_id, toitem_id, shiphead_order_type, shiphead_number,\n         tohead_number, shiphead_shipdate,\n         toitem_linenumber, item_number, item_descrip1, item_descrip2,\n         tohead_srcname, shiphead_tracknum, toitem_qty_ordered, \n         shiphead_freight, shiphead_freight_curr_id \n<? endif ?>\n   ) AS data\nORDER BY sortkey1, sortkey2, level, linenumber DESC;\n     admin   2011-11-23      0
175 86      shippingForm    shipment        used by printShippingForm Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: shippingForm\n-- Name: shipment\n-- Notes: used by printShippingForm\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id AS order_id, cohead_shiptoname AS shipto, \n       cohead_shiptoaddress1 AS addr1, shiphead_order_type, \n       shiphead_id, shiphead_shipchrg_id, shiphead_shipped, \n\tCOALESCE(shiphead_shipform_id, cohead_shipform_id) AS shipform_id \nFROM cohead, shiphead \nWHERE ((cohead_id=shiphead_order_id)\n  AND  (shiphead_order_type='SO')\n  AND  (shiphead_id=<? value("shiphead_id") ?> )\n<? if exists("sohead_id") ?>\n  AND  (cohead_id=<? value("sohead_id") ?> )\n<? endif ?>\n) \n<? if exists("MultiWhs") ?>\nUNION \nSELECT tohead_id AS order_id, tohead_destname AS shipto, \n       tohead_destaddress1 AS addr1, shiphead_order_type, \n       shiphead_id, shiphead_shipchrg_id, shiphead_shipped, \n\tCOALESCE(shiphead_shipform_id, tohead_shipform_id) AS shipform_id \nFROM tohead, shiphead \nWHERE ((tohead_id=shiphead_order_id)\n  AND  (shiphead_order_type='TO')\n  AND  (shiphead_id=<? value("shiphead_id") ?> )\n<? if exists("tohead_id") ?>\n  AND  (tohead_id=<? value("tohead_id") ?> )\n<? endif ?>\n) \nORDER BY shiphead_shipped \n<? endif ?>\nLIMIT 1;\n   admin   2011-11-23      0
176 282     slowMovingInventoryByClassCode  detail  used by dspSlowMovingInventoryByClassCode Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: slowMovingInventoryByClassCode\n-- Name: detail\n-- Notes: used by dspSlowMovingInventoryByClassCode\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n       itemsite_qtyonhand, itemsite_datelastused, cost,\n       noNeg(cost * itemsite_qtyonhand) AS value,\n       CASE WHEN (COALESCE(itemsite_datelastused, startOfTime()) <= startOfTime()) THEN 'N/A'\n       END AS itemsite_datelastused_qtdisplayrole,\n       'qty' AS itemsite_qtyonhand_xtnumericrole,\n       'cost' AS cost_xtnumericrole,\n       'curr' AS value_xtnumericrole,\n       0 AS itemsite_qtyonhand_xttotalrole,\n       0 AS value_xttotalrole\nFROM ( SELECT itemsite_id, warehous_code, item_number,\n              item_descrip1, item_descrip2, uom_name,\n              itemsite_qtyonhand, itemsite_datelastused,\n            <? if exists("useActualCosts") ?>\n              actcost(itemsite_item_id) \n            <? else ?>\n              stdcost(itemsite_item_id) \n            <? endif ?> AS cost \n       FROM itemsite, item, warehous, uom \n       WHERE ((itemsite_item_id=item_id)\n          AND (item_inv_uom_id=uom_id)\n          AND (itemsite_warehous_id=warehous_id)\n          AND (itemsite_active)\n          AND (itemsite_datelastused < <? value("cutoffDate") ?>)\n        <? if exists("warehous_id") ?>\n          AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n        <? endif ?>\n        <? if exists("classcode_id") ?>\n          AND (item_classcode_id=<? value("classcode_id") ?>)\n        <? elseif exists("classcode_pattern") ?>\n          AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE classcode_code ~ <? value("classcode_pattern") ?>))\n        <? endif ?>\n              )\n     ) AS data \nORDER BY warehous_code, \n     <? if exists("sortByItem") ?>\n       item_number\n     <? elseif exists("sortByDate") ?>\n       itemsite_datelastused\n     <? else ?>\n       noNeg(cost * itemsite_qtyonhand) DESC\n     <? endif ?>\n;\n       admin   2011-11-23      0
177 42      arOpenItems     detail  used by arWorkBench, dspAROpenItems Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: arOpenItems\n-- Name: detail\n-- Notes: used by arWorkBench, dspAROpenItems\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("totalOnly") ?>\nSELECT SUM(CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n                    (aropen_amount - aropen_paid) / aropen_curr_rate * -1\n                ELSE (aropen_amount - aropen_paid) / aropen_curr_rate\n           END) AS total_balance\nFROM aropen JOIN custinfo ON (aropen_cust_id=cust_id)\n            LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n            LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (aropen_open)\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n      )\n;\n<? else ?>\n\n-- Get unposted invoices\n<? if exists("showUnposted") ?>\n<? if not exists("creditsOnly") ?>\nSELECT -1 AS id,\n       0 AS altId,\n       invchead_invcnumber AS docnumber,\n       invchead_id AS docnumber_xtidrole,\n       invchead_posted AS posted,\n       invchead_invcdate AS docdate,\n       NULL::date AS aropen_duedate,\n       invchead_ordernumber AS ordernumber,\n       cohead_id AS ordernumber_xtidrole,\n       <? value("invoice") ?>  AS doctype,\n       NULL AS doctype_qtforegroundrole,\n       invoicetotal(invchead_id) AS amount,\n       currtobase(invchead_curr_id, invoicetotal(invchead_id), invchead_invcdate) AS base_amount,\n       0 AS paid,\n       0 AS base_paid,\n       0 AS balance,\n       currConcat(invchead_curr_id) AS currAbbr,\n       0 AS base_balance,\n<? if exists("includeFormatted") ?>\n       formatDate(invchead_invcdate) AS f_docdate,\n       NULL::text AS f_duedate,\n       formatMoney(0) AS f_amount,\n       formatMoney(0) AS f_paid,\n       formatMoney(0) AS f_balance,\n<? endif ?>\n       cust_id, cust_number, cust_name,\n       (invchead_recurring_invchead_id IS NOT NULL) AS recurring,\n       false AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL::text AS aropen_docnumber_qtdisplayrole,\n       NULL::text AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       '' AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_number_xtidrole,\n       firstLine(invchead_notes) AS notes\nFROM invchead\n           LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n           JOIN custinfo ON (invchead_cust_id=cust_id)\n           JOIN custtype ON (cust_custtype_id=custtype_id)\n\t   LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT invchead_posted)\n<? if exists("cust_id") ?>\n  AND   (invchead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (invchead_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,                  invchead_id,\n           invchead_invcdate,       invchead_posted,        invchead_curr_id,\n           invchead_recurring,      invchead_invcnumber,    invchead_posted,\n           invchead_ordernumber,    cohead_id,\n           cust_id,                 cust_number,            cust_name,\n           invchead_recurring_invchead_id, invchead_notes\n\nUNION\n<? endif ?>\n<? endif ?>\n\n-- Get unposted credit memos\n<? if exists("showUnposted") ?>\n<? if not exists("debitsOnly") ?>\nSELECT -1 AS id,\n       1 AS altId,\n       cmhead_number AS docnumber,\n       cmhead_id AS docnumber_xtidrole,\n       cmhead_posted AS posted,\n       cmhead_docdate AS docdate,\n       NULL::date AS aropen_duedate,\n       NULL::text AS ordernumber,\n       -1 AS ordernumber_xtidrole,\n       <? value("creditMemo") ?>  AS doctype,\n       CASE WHEN (NOT cmhead_posted) THEN 'emphasis'\n       END AS doctype_qtforegroundrole,\n       creditmemototal(cmhead_id) AS amount,\n       currtobase(cmhead_curr_id, creditmemototal(cmhead_id), cmhead_docdate) AS base_amount,\n       0 AS paid,\n       0 AS base_paid,\n       0 AS balance,\n       currConcat(cmhead_curr_id) AS currAbbr,\n       0  AS base_balance,\n<? if exists("includeFormatted") ?>\n       formatDate(cmhead_docdate) AS f_docdate,\n       NULL::text AS f_duedate,\n       formatMoney(creditmemototal(cmhead_id)) AS f_amount,\n       formatMoney(0) AS f_paid,\n       formatMoney(0) AS f_balance,\n<? endif ?>\n       cust_id, cust_number, cust_name,\n       false AS recurring,\n       false AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL::text AS aropen_docnumber_qtdisplayrole,\n       NULL::text AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       '' AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_number_xtidrole,\n       firstLine(cmhead_comments) AS notes\nFROM cmhead\n            JOIN custinfo ON (cmhead_cust_id=cust_id)\n            JOIN custtype ON (cust_custtype_id=custtype_id)\n\t    LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n<? if exists("cust_id") ?>\n  AND   (cmhead_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (cmhead_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,                  cmhead_id,\n           cmhead_docdate,          cmhead_posted,          cmhead_curr_id,\n           cmhead_number,           cmhead_posted,          cmhead_comments,\n           cust_id,                 cust_number,            cust_name\n\nUNION\n<? endif ?>\n<? endif ?>\n\n-- Get Posted AR Open\nSELECT aropen_id AS id,\n       CASE WHEN (aropen_doctype='I') THEN 0\n            WHEN (aropen_doctype='C') THEN 1\n            WHEN (aropen_doctype='D') THEN 2\n            WHEN (aropen_doctype='R') THEN 3\n            ELSE -1\n       END AS altId,\n       aropen_docnumber AS docnumber,\n       COALESCE(invchead_id,cmhead_id,-1) AS docnumber_xtidrole,\n       true AS posted,\n       aropen_docdate AS docdate,\n       aropen_duedate,\n       aropen_ordernumber AS ordernumber,\n       COALESCE(cohead_id,-1) AS ordernumber_xtidrole,\n       CASE WHEN (aropen_doctype='I') THEN <? value("invoice") ?>\n            WHEN (aropen_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (aropen_doctype='D') THEN <? value("debitMemo") ?>\n            WHEN (aropen_doctype='R') THEN <? value("cashdeposit") ?>\n            ELSE <? value("other") ?>\n       END AS doctype,\n       CASE WHEN (aropen_doctype='C') THEN 'emphasis' \n         ELSE CASE WHEN(aropen_doctype='R')THEN 'altemphasis'\n         END\n       END AS doctype_qtforegroundrole,\n       aropen_amount AS amount,\n       aropen_amount/aropen_curr_rate AS base_amount,\n       (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS paid,\n       (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))/aropen_curr_rate) AS base_paid,\n        (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) AS balance,\n       currConcat(aropen_curr_id) AS currAbbr,\n        (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0)))/aropen_curr_rate *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)  AS base_balance,\n<? if exists("includeFormatted") ?>\n       formatDate(aropen_docdate) AS f_docdate,\n       formatDate(aropen_duedate) AS f_duedate,\n       formatMoney(aropen_amount) AS f_amount,\n       formatMoney(aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS f_paid,\n       formatMoney((((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n        CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)) AS f_balance,\n<? endif ?>\n       cust_id, cust_number, cust_name,\n       COALESCE(invchead_recurring_invchead_id IS NOT NULL, false) AS recurring,\n       aropen_open AS open,\n       formatccnumber(decrypt(setbytea(ccard_number),\n                              setbytea(<? value("key") ?>), 'bf')) AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr'AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       NULL AS aropen_docnumber_qtdisplayrole,\n       NULL AS aropen_docdate_qtdisplayrole,\n       0 AS xtindentrole,\n       CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n       END AS aropen_duedate_qtforegroundrole,\n       ccpay_id AS ccard_number_xtidrole,\n       firstLine(aropen_notes) AS notes\nFROM aropen \n<? if exists("incidentsOnly") ?>\n            JOIN incdt ON (incdt_aropen_id=aropen_id)\n<? endif ?>\n            JOIN custinfo ON (aropen_cust_id=cust_id)\n            JOIN custtype ON (cust_custtype_id=custtype_id)\n\t    LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n            LEFT OUTER JOIN invchead ON ((aropen_docnumber=invchead_invcnumber)\n                                   AND (aropen_doctype='I'))\n            LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n            LEFT OUTER JOIN cmhead ON ((aropen_docnumber=cmhead_number)\n                                   AND (aropen_doctype='C'))\n            LEFT OUTER JOIN arapply ON (((aropen_id=arapply_source_aropen_id)\n                             OR (aropen_id=arapply_target_aropen_id))\n                             AND (arapply_distdate>COALESCE(<? value("asofDate") ?>,current_date)))\n            LEFT OUTER JOIN payaropen ON (payaropen_aropen_id=aropen_id)\n            LEFT OUTER JOIN ccpay     ON (payaropen_ccpay_id=ccpay_id)\n            LEFT OUTER JOIN ccard     ON (ccpay_ccard_id=ccard_id)\nWHERE ((true)\n<? if not exists("showClosed") ?>\n  AND (aropen_docdate <= COALESCE(<? value("asofDate") ?>, current_date))\n  AND (COALESCE(aropen_closedate, DATE(<? value("asofDate") ?>) + 1, current_date + 1) > COALESCE(<? value("asofDate") ?>, current_date)) \n<? endif ?>\n<? if exists("debitsOnly") ?>\n  AND   (aropen_doctype IN ('D','I'))\n<? elseif exists("creditsOnly") ?>\n  AND   (aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("startDueDate") ?>\n  AND   (aropen_duedate >= <? value("startDueDate") ?>)\n<? endif ?>\n<? if exists("endDueDate") ?>\n  AND   (aropen_duedate <= <? value("endDueDate") ?>)\n<? endif ?>\n      )\n  GROUP BY id,                      altId,\t            invchead_id,\n           aropen_docdate,          aropen_duedate,         aropen_doctype,         \n           aropen_docnumber,        aropen_amount,          \n           aropen_notes,            aropen_posted,          aropen_ordernumber,\n           aropen_paid,             aropen_open,            aropen_curr_id,\n           aropen_closedate,        aropen_curr_rate,       cmhead_id,\n           cust_id, \t\t    cust_number,            cust_name,\n           cohead_id,               ccpay_id,               ccard_number,\n           invchead_recurring_invchead_id\nUNION\nSELECT -1,\n       4 AS altId,\n       aropen_docnumber AS docnumber,\n       -1 AS docnumber_xtidrole,\n       NULL AS posted, \n       aropen_docdate AS docdate,\n       NULL AS aropen_duedate,\n       CAST(incdt_number AS text) AS ordernumber,\n       incdt_id AS ordernumber_xtidrole,\n       NULL AS doctype,\n       NULL AS doctype_qtforegroundrole,\n       NULL AS amount,\n       NULL AS base_amount,\n       NULL AS paid,\n       NULL AS base_paid,\n       NULL AS balance,\n       NULL AS currAbbr,\n       NULL AS base_balance,\n<? if exists("includeFormatted") ?>\n       NULL AS f_docdate,\n       NULL AS f_duedate,\n       NULL AS f_amount,\n       NULL AS f_paid,\n       NULL AS f_balance,\n<? endif ?>\n       NULL,incdt_assigned_username, incdt_summary,\n       NULL AS recurring, NULL AS open,\n       NULL AS ccard_number,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS paid_xtnumericrole,\n       'curr' AS base_paid_xtnumericrole,\n       0 AS base_paid_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       '' AS aropen_docnumber_qtdisplayrole,\n       '' AS aropen_docdate_qtdisplayrole,\n       1 AS xtindentrole,\n       CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n       END AS aropen_duedate_qtforegroundrole,\n       NULL::integer AS ccard_xtidrole,\n       firstLine(incdt_descrip) AS notes\nFROM incdt JOIN aropen ON (aropen_id=incdt_aropen_id)\n           JOIN custinfo ON (aropen_cust_id=cust_id)\n           JOIN custtype ON (cust_custtype_id=custtype_id)\n\t   LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((true)\n<? if not exists("showClosed") ?>\n  AND (aropen_docdate <= COALESCE(<? value("asofDate") ?>, current_date))\n  AND (COALESCE(aropen_closedate, DATE(<? value("asofDate") ?>) + 1, current_date + 1) > COALESCE(<? value("asofDate") ?>, current_date)) \n<? endif ?>\n<? if exists("debitsOnly") ?>\n  AND   (NOT aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("creditsOnly") ?>\n  AND   (aropen_doctype IN ('C', 'R'))\n<? endif ?>\n<? if exists("cust_id") ?>\n  AND   (aropen_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("startDueDate") ?>\n  AND   (aropen_duedate >= <? value("startDueDate") ?>)\n<? endif ?>\n<? if exists("endDueDate") ?>\n  AND   (aropen_duedate <= <? value("endDueDate") ?>)\n<? endif ?>\n      )\n\nORDER BY\n  docdate DESC, docnumber DESC, xtindentrole\n;\n<? endif ?>\n  admin   2012-03-01      0
178 285     substituteAvailability  detail  used by dspSubstituteAvailabilityByItem Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: substituteAvailability\n-- Name: detail\n-- Notes: used by dspSubstituteAvailabilityByItem\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT s_itemsite_id, warehous_code, item_number, itemdescrip,\n       qtyonhand, reorderlevel, leadtime, itemsub_rank,\n       allocated, ordered, available,\n       'qty' AS qtyonhand_xtnumericrole,\n       'qty' AS allocated_xtnumericrole,\n       'qty' AS ordered_xtnumericrole,\n       'qty' AS reorderlevel_xtnumericrole,\n       'qty' AS available_xtnumericrole,\n       CASE WHEN (reorderlevel >= available) THEN 'error' END AS available_qtforegroundrole\nFROM (SELECT sub.itemsite_id AS s_itemsite_id,\n             warehous_code, item_number,\n             (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n<? if exists("normalize") ?>\n             (sub.itemsite_qtyonhand * itemsub_uomratio) AS qtyonhand,\n             (CASE WHEN(sub.itemsite_useparams)\n                   THEN sub.itemsite_reorderlevel\n                ELSE 0.0\n             END * itemsub_uomratio) AS reorderlevel,\n             sub.itemsite_leadtime AS leadtime, itemsub_rank,\n<? else ?>\n             (sub.itemsite_qtyonhand) AS qtyonhand,\n             CASE WHEN(sub.itemsite_useparams) THEN sub.itemsite_reorderlevel\n               ELSE 0.0\n             END AS reorderlevel,\n             sub.itemsite_leadtime AS leadtime, itemsub_rank,\n<? endif ?>\n<? if exists("leadTime") ?>\n  <? if exists("normalize") ?>\n             (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio) AS allocated,\n             (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio) AS ordered,\n             ((sub.itemsite_qtyonhand * itemsub_uomratio)\n              + (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio)\n              - (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio)) AS available\n  <? else ?>\n             (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) AS allocated,\n             (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime)) AS ordered,\n             (sub.itemsite_qtyonhand + qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime)\n              - qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) AS available\n  <? endif ?>\n<? elseif exists("byDays") ?>\n  <? if exists("normalize") ?>\n             (qtyAllocated(sub.itemsite_id, <? value("days") ?>) * itemsub_uomratio) AS allocated,\n             (qtyOrdered(sub.itemsite_id, <? value("days") ?>) * itemsub_uomratio) AS ordered,\n             ((sub.itemsite_qtyonhand * itemsub_uomratio) + (qtyOrdered(sub.itemsite_id, <? value("days") ?>) * itemsub_uomratio)\n              - (qtyAllocated(sub.itemsite_id, <? value("days") ?>) * itemsub_uomratio)) AS available\n  <? else ?>\n             (qtyAllocated(sub.itemsite_id, <? value("days") ?>)) AS allocated,\n             (qtyOrdered(sub.itemsite_id, <? value("days") ?>)) AS ordered,\n             (sub.itemsite_qtyonhand + qtyOrdered(sub.itemsite_id, <? value("days") ?>)\n              - qtyAllocated(sub.itemsite_id, <? value("days") ?>)) AS available\n  <? endif ?>\n<? elseif exists("byDate") ?>\n  <? if exists("normalize") ?>\n             (qtyAllocated(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE)) * itemsub_uomratio) AS allocated,\n             (qtyOrdered(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE)) * itemsub_uomratio) AS ordered,\n             ((sub.itemsite_qtyonhand * itemsub_uomratio) + (qtyOrdered(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE)) * itemsub_uomratio)\n              - (qtyAllocated(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE)) * itemsub_uomratio)) AS available\n  <? else ?>\n             (qtyAllocated(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE))) AS allocated,\n             (qtyOrdered(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE))) AS ordered,\n             (sub.itemsite_qtyonhand + qtyOrdered(sub.itemsite_id,\n             (<? value("date") ?> - CURRENT_DATE)) - qtyAllocated(sub.itemsite_id, (<? value("date") ?> - CURRENT_DATE))) AS available\n  <? endif ?>\n<? endif ?>\n      FROM item, itemsite AS sub, itemsite AS root, warehous, itemsub\n      WHERE ((sub.itemsite_item_id=item_id)\n         AND (root.itemsite_item_id=itemsub_parent_item_id)\n         AND (sub.itemsite_item_id=itemsub_sub_item_id)\n         AND (root.itemsite_warehous_id=sub.itemsite_warehous_id)\n         AND (sub.itemsite_warehous_id=warehous_id)\n         AND (root.itemsite_item_id=<? value("item_id") ?>)\n<? if exists("warehous_id") ?>\n         AND (root.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n            )\n     ) AS data\nORDER BY itemsub_rank;\n   admin   2011-11-23      0
179 107     summarizedBacklogByWarehouse    counts   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: summarizedBacklogByWarehouse\n-- Name: counts\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COUNT(coitem.*) AS totalitems \n\t\t     FROM cohead, coitem, itemsite, cust \n\t\t     WHERE ( (coitem_cohead_id=cohead_id)\n\t\t      AND (coitem_itemsite_id=itemsite_id)\n\t\t      AND (cohead_cust_id=cust_id)\n\t\t      AND (coitem_status NOT IN ('C','X'))\n\t\t      AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n\t\t                                AND <? value("endDate") ?>)\n\t\t     <? if exists("warehous_id") ?>\n\t\t      AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n\t\t     <? endif ?>\n\t\t     <? if exists("custtype_id") ?>\n\t\t      AND (cust_custtype_id=<? value("custtype_id") ?>)\n\t\t     <? elseif exists("custtype_pattern") ?>\n\t\t      AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t       WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n\t\t     <? endif ?>\n\t\t     );\n admin   2011-11-23      0
180 108     summarizedBacklogByWarehouse    detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: summarizedBacklogByWarehouse\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * FROM (\n(SELECT cohead_id, 0 AS xtindentrole, salesrep_name, cohead_holdtype, cohead_number, \n   coheadstatecolor(cohead_id) AS qtforegroundrole, \n   cust_name,       \n   cohead_created, cohead_orderdate, cohead_packdate, pack_head_id,       \n          CASE WHEN (cohead_holdtype='N') THEN <? value("none") ?>\n               WHEN (cohead_holdtype='C') THEN <? value("credit") ?>\n               WHEN (cohead_holdtype='S') THEN <? value("ship") ?>\n               WHEN (cohead_holdtype='P') THEN <? value("pack") ?>\n               WHEN (cohead_holdtype='R') THEN <? value("return") ?>\n               ELSE <? value("other") ?>\n   END AS f_holdtype,       \n   MIN(coitem_scheddate) AS scheddate,       \n   SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *            \n               (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio) ) AS sales, \n   SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) AS cost,\n   SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n               ((currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio) - stdcost(item_id)) ) AS margin,\n   'curr' AS sales_xtnumericrole,\n   'curr' AS cost_xtnumericrole,\n   'curr' AS margin_xtnumericrole,\n    NULL AS cosmisc_id, \n    NULL AS cosmisc_number, \n    NULL AS shipstatus,\n    NULL AS shipvia,\n    CASE WHEN (pack_head_id IS NOT NULL) THEN TRUE\n    ELSE FALSE\n    END AS packed \n   <? if exists("showPrices") ?> \n    , 0 AS sales_xttotalrole, 0 AS cost_xttotalrole, 0 AS margin_xttotalrole \n   <? endif ?>,\n   cohead_number AS seq\n   FROM coitem, itemsite, item, cust, cohead \n     LEFT OUTER JOIN pack ON (cohead_id = pack_head_id), salesrep \n   WHERE ( (coitem_cohead_id=cohead_id)\n    AND (salesrep_id = cohead_salesrep_id) \n    AND (cohead_cust_id=cust_id)\n    AND (coitem_itemsite_id=itemsite_id)\n    AND (itemsite_item_id=item_id)\n    AND (coitem_status NOT IN ('C','X'))\n    AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n                              AND <? value("endDate") ?>)\n   <? if exists("warehous_id") ?>\n    AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n   <? endif ?>\n   <? if exists("custtype_id") ?>\n    AND (cust_custtype_id=<? value("custtype_id") ?>)\n   <? elseif exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n     WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n   <? endif ?>\n   ) \n   GROUP BY cohead_id, salesrep_number, salesrep_name, cohead_number, cust_name,\n            cohead_holdtype, cohead_orderdate, cohead_packdate,\n            cohead_created, pack_head_id )\n   UNION \n   (SELECT cohead_id, 1 AS xtindentrole, NULL, NULL, \n   shiphead_number AS cohead_number, \n   CASE WHEN (shiphead_shipped IS NULL) THEN ''           \n   WHEN (shiphead_shipped) THEN 'altemphasis'            \n   WHEN (NOT shiphead_shipped) THEN 'emphasis' \n   WHEN ( (COALESCE(cobmisc_cohead_id,0) > 0)       \n   AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) > 0)       \n   ) THEN 'error'       \n   END AS qtforegroundrole, \n   COALESCE(shiphead_shipvia, ''), NULL, shiphead_shipdate AS cohead_orderdate, \n   NULL, NULL,\n   CASE WHEN (shiphead_shipped) THEN <? value("yes") ?>         \n   ELSE <? value("no") ?>       \n   END AS f_holdtype,  MIN(coitem_scheddate), NULL, NULL, NULL, NULL, NULL, NULL, NULL,        \n   formatShipmentNumber(shiphead_id) AS cosmisc_number,        \n   NULL,       \n   COALESCE(shiphead_shipvia, '') AS shipvia           \n   <? if exists("showPrices") ?> \n    , NULL, NULL, NULL \n   <? endif ?>\n   , NULL,\n   cohead_number AS seq \n   FROM coitem, itemsite, item, cust, cohead   \n   LEFT OUTER JOIN shiphead ON ((shiphead_order_id=cohead_id)   \n                            AND (shiphead_order_type='SO'))\n   LEFT OUTER JOIN (SELECT DISTINCT cobmisc_cohead_id FROM cobmisc) AS cobmisc ON (cobmisc_cohead_id=cohead_id)   \n   LEFT OUTER JOIN pack ON (cohead_id = pack_head_id), salesrep \n   WHERE ( (coitem_cohead_id=cohead_id)\n    AND (salesrep_id = cohead_salesrep_id) \n    AND (cohead_cust_id=cust_id)\n    AND (coitem_itemsite_id=itemsite_id)\n    AND (itemsite_item_id=item_id)\n    AND (coitem_status NOT IN ('C','X'))\n    AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n                              AND <? value("endDate") ?>)\n   <? if exists("warehous_id") ?>\n    AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n   <? endif ?>\n   <? if exists("custtype_id") ?>\n    AND (cust_custtype_id=<? value("custtype_id") ?>)\n   <? elseif exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n     WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n   <? endif ?>\n   AND ((SELECT (count(*)>0) FROM shipitem WHERE ((shipitem_shiphead_id=shiphead_id) AND (NOT shipitem_invoiced))))) \n   GROUP BY cohead_id, salesrep_number, salesrep_name, cohead_number, cust_name,         \n   cohead_holdtype, cohead_orderdate, cohead_packdate,         \n   shiphead_shipped, shiphead_shipvia, shiphead_shipdate,         \n   shiphead_id, cobmisc_cohead_id, cohead_created, pack_head_id,\n   shiphead_number )) AS data\n  ORDER BY seq, cohead_number;\n\n\n admin   2011-11-23      0
181 109     summarizedBacklogByWarehouse    qtys     Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: summarizedBacklogByWarehouse\n-- Name: qtys\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT formatQty(COALESCE(SUM(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned), 0)) AS f_totalqty \n\t\t     FROM cohead, coitem, itemsite, item, cust \n\t\t     WHERE ( (coitem_cohead_id=cohead_id)\n\t\t      AND (coitem_itemsite_id=itemsite_id)\n\t\t      AND (itemsite_item_id=item_id)\n\t\t      AND (cohead_cust_id=cust_id)\n\t\t      AND (coitem_status NOT IN ('C','X'))\n\t\t      AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n\t\t                                AND <? value("endDate") ?>)\n\t\t     <? if exists("warehous_id") ?>\n\t\t      AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n\t\t     <? endif ?>\n\t\t     <? if exists("custtype_id") ?>\n\t\t      AND (cust_custtype_id=<? value("custtype_id") ?>)\n\t\t     <? elseif exists("custtype_pattern") ?>\n\t\t      AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t       WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n\t\t     <? endif ?>\n\t\t     );\n       admin   2011-11-23      0
182 110     summarizedBacklogByWarehouse    totals   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: summarizedBacklogByWarehouse\n-- Name: totals\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COUNT(cohead_id) AS totalorders \n\t\t     FROM ( SELECT DISTINCT cohead_id \n\t\t            FROM cohead, coitem, itemsite, cust \n\t\t            WHERE ( (coitem_cohead_id=cohead_id)\n\t\t             AND (coitem_itemsite_id=itemsite_id)\n\t\t             AND (cohead_cust_id=cust_id)\n\t\t             AND (coitem_status NOT IN ('C','X'))\n\t\t      AND (coitem_scheddate BETWEEN <? value("startDate") ?>\n\t\t                                AND <? value("endDate") ?>)\n\t\t     <? if exists("warehous_id") ?>\n\t\t      AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n\t\t     <? endif ?>\n\t\t     <? if exists("custtype_id") ?>\n\t\t      AND (cust_custtype_id=<? value("custtype_id") ?>)\n\t\t     <? elseif exists("custtype_pattern") ?>\n\t\t      AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t       WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n\t\t     <? endif ?>\n\t\t     ) ) AS data;\n      admin   2011-11-23      0
183 287     summarizedGLTransactions        detail  used by dspSummarizedGLTransactions Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: summarizedGLTransactions\n-- Name: detail\n-- Notes: used by dspSummarizedGLTransactions\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, gltrans_id,\n       account, accnt_descrip,\n       gltrans_date, gltrans_source, gltrans_doctype, gltrans_docnumber,\n       f_notes,\n       debit, credit,\n       gltrans_username, gltrans_created,\n       CASE WHEN (level=0) THEN accnt_descrip\n            ELSE f_notes \n       END AS descrip_notes, \n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       0 AS debit_xtnumericrole,\n       0 AS credit_xtnumericrole,\n       CASE WHEN (debit=0) THEN '' END AS debit_qtdisplayrole,\n       CASE WHEN (credit=0) THEN '' END AS credit_qtdisplayrole,\n       level AS xtindentrole \nFROM ( \nSELECT DISTINCT accnt_id, -1 AS gltrans_id, 0 AS level,\n       accnt_number, accnt_profit, accnt_sub, \n      formatGLAccount(accnt_id) AS account, accnt_descrip,\n       CAST(NULL AS DATE) AS gltrans_date, '' AS gltrans_source, '' AS gltrans_doctype, '' AS gltrans_docnumber,\n         '' AS f_notes,\n       SUM( CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1) \n                        ELSE 0 \n                   END ) AS debit, \n       SUM( CASE WHEN (gltrans_amount > 0) THEN gltrans_amount \n                       ELSE 0 \n                  END ) AS credit, \n       '' AS gltrans_username, CAST(NULL AS TIMESTAMP) AS gltrans_created \nFROM gltrans, accnt \nWHERE ( (gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted) \n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) \n\n  \n<? if exists("source") ?>\n     AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n  \n<? if exists("unpostedTransactions") ?>\n     AND (NOT gltrans_posted)\n<? elseif exists("postedTransactions") ?>\n       AND (gltrans_posted)\n<? endif ?>\n  ) GROUP BY accnt_id, accnt_number, accnt_profit, accnt_sub, accnt_descrip \n               UNION \n               SELECT accnt_id, gltrans_id, 1 AS level,\n                      accnt_number, accnt_profit, accnt_sub, \n                      '' AS account, '' AS accnt_descrip,\n                      gltrans_date, gltrans_source, gltrans_doctype, gltrans_docnumber,\n                      firstLine(gltrans_notes) AS f_notes,\n                      CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n                           ELSE 0\n                      END AS debit,\n                      CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n                           ELSE 0\n                      END AS credit,\n                      gltrans_username, gltrans_created \n               FROM gltrans, accnt \n               WHERE ((gltrans_accnt_id=accnt_id)\n                AND (NOT gltrans_deleted) \n                AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) \n\n<? if exists("source") ?>\n     AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n\n<? if exists("unpostedTransactions") ?>\n     AND (NOT gltrans_posted)\n<? elseif exists("postedTransactions") ?>\n       AND (gltrans_posted)\n<? endif ?>\n\n)) AS data \n ORDER BY accnt_number, accnt_profit, accnt_sub, level, gltrans_date DESC, gltrans_created;\n       admin   2011-11-23      0
184 300     uninvoicedReceivings    detail  used by dspUninvoicedReceivings Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: uninvoicedReceivings\n-- Name: detail\n-- Notes: used by dspUninvoicedReceivings\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id AS id,\n       CASE WHEN(poitem_status='C') THEN 2\n            ELSE 1\n       END AS doctype,\n       recv_date AS thedate,\n       recv_trans_usr_name AS f_user,\n       recv_order_number AS ponumber, poitem_linenumber,\n       vend_name,\n       COALESCE(item_number,\n       ('Misc. - ' || recv_vend_item_number)) AS itemnumber,\n       recv_qty AS qty, 'qty' AS qty_xtnumericrole,\n       'Receipt' AS type,\n       recv_value AS value,\n       'curr' AS value_xtnumericrole, 0 AS value_xttotalrole\nFROM recv, vend,\n     poitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id))\n            ON (poitem_itemsite_id=itemsite_id)\nWHERE ((recv_orderitem_id=poitem_id)\n   AND (recv_order_type='PO')\n   AND (recv_vend_id=vend_id)\n   AND (recv_posted)\n   AND (recv_vohead_id IS NULL)\n   AND (NOT recv_invoiced)\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n   AND (recv_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n      )\n\nUNION\n\nSELECT poreject_id AS id,\n       3 AS doctype,\n       poreject_date AS thedate,\n       poreject_trans_username AS f_user,\n       poreject_ponumber AS ponumber, poitem_linenumber,\n       vend_name,\n       COALESCE(item_number,\n       ('Misc. - ' || poreject_vend_item_number)) AS itemnumber,\n       poreject_qty, 'qty' AS qty_xtnumericrole,\n       'Return' AS type,\n       poreject_value * -1 AS value,\n       'curr' AS value_xtnumericrole, 0 AS value_xtotalrole\nFROM poreject, vend,\n     poitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id))\n            ON (poitem_itemsite_id=itemsite_id)\nWHERE ((poreject_poitem_id=poitem_id)\n   AND (poreject_vend_id=vend_id)\n   AND (poreject_posted)\n   AND (NOT poreject_invoiced)\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n   AND (poreject_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n      )\nORDER BY ponumber, poitem_linenumber;\n        admin   2011-11-23      0
185 288     summarizedSalesHistory  detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: summarizedSalesHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT 1 AS dummy,\n       <? if exists("byCustomer") ?>\n         cust_number, cohist_cust_id AS cust_number_xtidrole, cust_name,\n       <? endif ?> \n       <? if exists("byCustomerType") ?>\n         custtype_code, cust_custtype_id AS custtype_code_xtidrole, \n       <? endif ?>  \n       <? if exists("byItem") ?>\n         item_number, item_id AS item_number_xtidrole, itemdescription, \n       <? endif ?> \n       <? if exists("bySalesRep") ?>\n         salesrep_number, cohist_salesrep_id AS salesrep_number_xtidrole, salesrep_name, \n       <? endif ?> \n       <? if exists("byShippingZone") ?>\n         shipzone_name, shipzone_id AS shipzone_name_xtidrole,\n       <? endif ?> \n       <? if exists("bySite") ?>\n         warehous_code, itemsite_warehous_id AS warehous_code_xtidrole,\n       <? endif ?>  \n       <? if exists("byCurrency") ?>\n         currAbbr,\n         MIN(custunitprice) AS minprice, MAX(custunitprice) AS maxprice, \n         AVG(custunitprice) AS avgprice,\n         SUM(custextprice) AS totalsales, \n         CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0 \n         ELSE SUM(custextprice) / SUM(cohist_qtyshipped) \n         END AS wtavgprice,\n       <? else ?>\n         currConcat(baseCurrId()) AS currAbbr, \n         MIN(baseunitprice) AS minprice, MAX(baseunitprice) AS maxprice, \n         AVG(baseunitprice) AS avgprice, \n         SUM(baseextprice) AS totalsales, \n         CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0 \n         ELSE SUM(baseextprice) / SUM(cohist_qtyshipped) \n         END AS wtavgprice,\n       <? endif ?>\n         SUM(cohist_qtyshipped) AS totalunits, \n         MIN(cohist_invcdate) AS firstdate, \n         MAX(cohist_invcdate) AS lastdate, \n         SUM(cohist_qtyshipped) AS qtyshipped, \n         'salesprice' AS minprice_xtnumericrole, \n         'salesprice' AS maxprice_xtnumericrole, \n         'salesprice' AS avgprice_xtnumericrole, \n         'salesprice' AS wtavgprice_xtnumericrole, \n         'qty' AS qtyshipped_xtnumericrole, \n         'curr' AS extprice_xtnumericrole,\n         'qty' AS totalunits_xtnumericrole, \n         'curr' AS totalsales_xtnumericrole, \n         'qty' AS totalunits_xtnumericrole, \n         'curr' AS totalsales_xtnumericrole, \n         0 AS totalunits_xttotalrole, \n         0 AS totalsales_xttotalrole \nFROM saleshistory \nWHERE (true\n<? if exists("startDate") ?>\n AND (cohist_invcdate >= <? value("startDate") ?>)\n<? endif ?>\n\n<? if exists("endDate") ?>\n AND (cohist_invcdate <= <? value("endDate") ?>)\n<? endif ?>\n\n<? if exists("shipStartDate") ?>\n AND (cohist_shipdate >= <? value("shipStartDate") ?>)\n<? endif ?>\n\n<? if exists("shipEndDate") ?>\n AND (cohist_shipdate <= <? value("shipEndDate") ?>)\n<? endif ?>\n\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n\n<? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n\n<? if exists("cust_id") ?>\n AND (cohist_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n\n<? if exists("shipto_id") ?>\n AND (cohist_shipto_id=<? value("shipto_id") ?>)\n<? endif ?>\n\n<? if exists("salesrep_id") ?>\n AND (cohist_salesrep_id=<? value("salesrep_id") ?>)\n<? endif ?>\n\n<? if exists("prodcat_id") ?>\n AND (item_prodcat_id=<? value("prodcat_id") ?>)\n<? endif ?>\n\n<? if exists("prodcat_pattern") ?>\n AND (prodcat_code ~ <? value("prodcat_pattern") ?>) \n<? endif ?>\n\n<? if exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n\n<? if exists("custtype_pattern") ?>\n   AND (custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?> \n\n<? if exists("custgrp_id") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrpitem\n                   WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n<? endif ?>\n\n<? if exists("custgrp_pattern") ?>\n  AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n                   FROM custgrp, custgrpitem\n                   WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n                     AND   (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n<? endif ?>\n\n<? if exists("shipzone_id") ?>\n AND (shipzone_id=<? value("shipzone_id") ?>)\n<? endif ?>\n\n<? if exists("curr_id") ?>\n AND cust_curr_id = <? value("curr_id") ?>\n<? endif ?>\n\n<? if exists("currConcat_pattern") ?>\n AND (currAbbr ~ <? value("currConcat_pattern") ?>) \n<? endif ?>\n) \nGROUP BY dummy\n<? if exists("bySalesRep") ?>\n , cohist_salesrep_id, salesrep_number, salesrep_name\n<? endif ?>\n<? if exists("byShippingZone") ?>\n , shipzone_id, shipzone_name\n<? endif ?>\n<? if exists("byCustomer") ?>\n , cohist_cust_id, cust_number, cust_name\n<? endif ?>\n<? if exists("byCustomerType") ?>\n , cust_custtype_id, custtype_code\n<? endif ?>\n<? if exists("byItem") ?>\n , item_id, item_number, itemdescription\n<? endif ?>\n<? if exists("bySite") ?>\n , itemsite_warehous_id, warehous_code\n<? endif ?>\n<? if exists("byCurrency") ?>\n , cust_curr_id, currAbbr\n<? endif ?>\n ORDER BY dummy\n<? if exists("bySalesRep") ?>\n , salesrep_number\n<? endif ?>\n<? if exists("byShippingZone") ?>\n , shipzone_name\n<? endif ?>\n<? if exists("byCustomer") ?>\n , cust_number\n<? endif ?>\n<? if exists("byCustomerType") ?>\n , custtype_code\n<? endif ?>\n<? if exists("byItem") ?>\n , item_number\n<? endif ?>\n<? if exists("bySite") ?>\n , warehous_code\n<? endif ?>\n;\n        admin   2011-11-23      0
186 289     taxAuthorities  detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: taxAuthorities\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  taxauth_id, taxauth_code, taxauth_name,\n  addr.*\nFROM taxauth\n  LEFT OUTER JOIN addr ON (taxauth_addr_id=addr_id) \nWHERE true\n<? if exists("search_pattern") ?>\n  AND ((taxauth_code ~* <? value("search_pattern") ?>)\n       OR (taxauth_name ~* <? value("search_pattern") ?>)\n       OR (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("search_pattern") ?>)\n       OR (addr_city ~* <? value("search_pattern") ?>)\n       OR (addr_state ~* <? value("search_pattern") ?>)\n       OR (addr_postalcode ~* <? value("search_pattern") ?>)\n       OR (addr_country ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("taxauth_code_pattern") ?>\n  AND (taxauth_code ~* <? value("taxauth_code_pattern") ?>)\n<? endif ?>\n<? if exists("taxauth_name_pattern") ?>\n  AND (taxauth_name ~* <? value("taxauth_name_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (addr_city ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (addr_state ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (addr_postalcode ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (addr_country ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\nORDER BY taxauth_code; \n        admin   2011-11-23      0
187 103     taxBreakdown    detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: taxBreakdown\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("invchead_id") ?>\n  SELECT head.*, linetax.*, freighttax.*, adjtax.* \n  FROM\n  (SELECT \n      invchead_invcnumber AS number, invchead_taxzone_id AS taxzone_id, \n      invchead_curr_id AS curr_id, invchead_curr_id AS tax_curr_id, invchead_invcdate AS date, \n      SUM(ROUND(((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price) / \n      (CASE WHEN(item_id IS NULL) THEN 1 ELSE invcitem_price_invuomratio END)), 2)) AS line, \n      invchead_freight AS freight, \n      getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \n  FROM invchead\n      LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id)  \n      LEFT OUTER JOIN item ON (invcitem_item_id=item_id) \n  WHERE (invchead_id=<? value("invchead_id") ?>) \n  GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, freight, freightTax, adjTax) head, \n  (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n    (SELECT ROUND(SUM(invcitemtax.taxhist_tax),2) AS group_tax \n     FROM invcitemtax \n     LEFT OUTER JOIN invcitem ON (taxhist_parent_id = invcitem_id) \n     WHERE (invcitem_invchead_id=<? value("invchead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) linetax,\n  (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n    (SELECT ROUND(SUM(taxhist_tax),2) AS group_tax \n     FROM invchead \n     LEFT OUTER JOIN invcheadtax ON (taxhist_parent_id = invchead_id \n     AND taxhist_taxtype_id = getfreighttaxtypeid()) \n     WHERE (invchead_id=<? value("invchead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) freighttax,  \n  (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n    (SELECT  ROUND(SUM(taxhist_tax),2) AS group_tax \n     FROM invchead \n     LEFT OUTER JOIN invcheadtax ON (taxhist_parent_id = invchead_id \n                                 AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n     WHERE (invchead_id=<? value("invchead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) adjtax;\n<? elseif exists("cmhead_id") ?>\n  SELECT head.*, linetax.*, freighttax.*, adjtax.* \n  FROM\n  (SELECT \n      cmhead_number AS number, cmhead_taxzone_id AS taxzone_id, \n      cmhead_curr_id AS curr_id, cmhead_curr_id AS tax_curr_id, cmhead_docdate AS date, \n      SUM(ROUND(((cmitem_qtycredit * cmitem_qty_invuomratio) * (cmitem_unitprice) / \n      cmitem_price_invuomratio), 2)) AS line, \n      cmhead_freight AS freight, \n      getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \n  FROM cmhead \n      LEFT OUTER JOIN cmitem ON (cmitem_cmhead_id=cmhead_id) \n  WHERE (cmhead_id=<? value("cmhead_id") ?>) \n  GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, freight, freightTax, adjTax) head, \n  (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n    (SELECT ROUND(SUM(cmitemtax.taxhist_tax * -1),2) AS group_tax \n     FROM cmitemtax \n     LEFT OUTER JOIN cmitem ON (taxhist_parent_id = cmitem_id) \n     WHERE (cmitem_cmhead_id=<? value("cmhead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) linetax,\n  (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n    (SELECT ROUND(SUM(taxhist_tax * -1),2) AS group_tax \n     FROM cmhead \n     LEFT OUTER JOIN cmheadtax ON (taxhist_parent_id = cmhead_id \n                               AND taxhist_taxtype_id = getfreighttaxtypeid()) \n     WHERE (cmhead_id=<? value("cmhead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) freighttax, \n  (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n    (SELECT  ROUND(SUM(taxhist_tax * -1),2) AS group_tax \n     FROM cmhead \n     LEFT OUTER JOIN cmheadtax ON (taxhist_parent_id = cmhead_id \n                               AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n     WHERE (cmhead_id=<? value("cmhead_id") ?>)\n     GROUP BY taxhist_tax_id) AS data\n  ) adjtax;\n<? elseif exists("cobmisc_id") ?>\n SELECT head.*, linetax.*, frighttax.*, adjtax.*   \n FROM \n   (SELECT cohead_number AS number, cobmisc_taxzone_id AS taxzone_id, \n      cobmisc_curr_id AS curr_id, cobmisc_curr_id AS tax_curr_id, \n     cobmisc_invcdate AS date, SUM(ROUND((cobill_qty * coitem_price) / \n     (CASE WHEN(item_id IS NULL) THEN 1 ELSE coitem_price_invuomratio END), 2)) AS line, \n     cobmisc_freight AS freight, \n     getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \t         \n    FROM cobmisc\n     JOIN cohead  ON (cobmisc_cohead_id=cohead_id) \n     LEFT OUTER JOIN cobill ON (cobill_cobmisc_id=cobmisc_id) \n     LEFT OUTER JOIN coitem ON (cobill_coitem_id=coitem_id) \n     LEFT OUTER JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n     LEFT OUTER JOIN item ON (itemsite_item_id=item_id) \n    WHERE (cobmisc_id=<? value("cobmisc_id") ?>) \n    GROUP BY number, cobmisc_taxzone_id, curr_id, tax_curr_id, \n      date, freight, freightTax,adjTax) head, \n   (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n     (SELECT ROUND(SUM(cobilltax.taxhist_tax),2) AS group_tax\n      FROM cobilltax\n      LEFT OUTER JOIN cobill ON (cobill_id=taxhist_parent_id) \n      WHERE (cobill_cobmisc_id=<? value("cobmisc_id") ?>)\n      GROUP BY taxhist_tax_id) AS data\n   ) linetax, \n   (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n     (SELECT ROUND(SUM(taxhist_tax),2) AS group_tax\n      FROM cobmisctax\n      LEFT OUTER JOIN cobmisc ON (taxhist_parent_id = cobmisc_id AND taxhist_taxtype_id = getfreighttaxtypeid()) \n      WHERE (cobmisc_id=<? value("cobmisc_id") ?>)\n      GROUP BY taxhist_tax_id) AS data\n   ) frighttax, \n   (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n     (SELECT  ROUND(SUM(taxhist_tax),2) AS group_tax\n      FROM cobmisctax\n      LEFT OUTER JOIN cobmisc ON (taxhist_parent_id = cobmisc_id AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n      WHERE (cobmisc_id=<? value("cobmisc_id") ?>)\n      GROUP BY taxhist_tax_id) AS data\n   ) adjtax;\n<? elseif exists("cohead_id") ?>\n  SELECT cohead_number AS number,\n         cohead_taxzone_id AS taxzone_id,\n         cohead_curr_id AS curr_id,\n         cohead_curr_id AS tax_curr_id,\n         cohead_orderdate AS date,\n         SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio),\n                    2)) AS line,\n         ROUND(SUM(calculateTax(cohead_taxzone_id, coitem_taxtype_id, cohead_orderdate, cohead_curr_id, ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price /\n                        coitem_price_invuomratio), 2))),2) as total_tax,   \n         cohead_freight AS freight,\n         getFreightTaxTypeId() AS freightTax, \n         ROUND(calculateTax(cohead_taxzone_id, getfreighttaxtypeid(), cohead_orderdate, cohead_curr_id, cohead_freight), 2) AS freighttaxamt\n  FROM coitem, item, itemsite, cohead \n  LEFT OUTER JOIN taxzone ON (cohead_taxzone_id=taxzone_id) \n  LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n  WHERE ((coitem_cohead_id=<? value("cohead_id") ?>)\n    AND  (coitem_cohead_id=cohead_id)\n    AND  (coitem_status != 'X')\n    AND  (coitem_itemsite_id=itemsite_id)\n    AND  (itemsite_item_id=item_id))\n  GROUP BY number, cohead_taxzone_id, curr_id, tax_curr_id,\n         date, freight, freightTax,freighttaxamt;\n<? elseif exists("quhead_id") ?>\n  SELECT quhead_number AS number,\n         quhead_taxzone_id AS taxzone_id,\n         quhead_curr_id AS curr_id,\n         quhead_curr_id AS tax_curr_id,\n         quhead_quotedate AS date,\n         SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio),\n                    2)) AS line,\n         ROUND(SUM(calculateTax(quhead_taxzone_id, quitem_taxtype_id, quhead_quotedate, quhead_curr_id, ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price /\n                        quitem_price_invuomratio), 2))),2) as total_tax,  \n         quhead_freight AS freight,\n         taxtype_id AS freightTax,\n         ROUND(calculateTax(quhead_taxzone_id, getfreighttaxtypeid(), quhead_quotedate, quhead_curr_id, quhead_freight), 2) AS freighttaxamt\n  FROM quitem, item, quhead \n    LEFT OUTER JOIN taxzone ON (quhead_taxzone_id=taxzone_id) \n    LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n  WHERE ((quitem_quhead_id=<? value("quhead_id") ?>)\n    AND  (quitem_quhead_id=quhead_id)\n    AND  (quitem_item_id=item_id))\n  GROUP BY number, quhead_taxzone_id, curr_id, tax_curr_id,\n         date, freight, freightTax,freighttaxamt;\n<? elseif exists("rahead_id") ?>\n  SELECT rahead_number AS number,\n         rahead_taxzone_id AS taxzone_id,\n         rahead_curr_id AS curr_id,\n         rahead_curr_id AS tax_curr_id,\n         rahead_authdate AS date,\n         COALESCE(SUM(ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice / raitem_price_invuomratio),\n                    2)),0) AS line,\n         COALESCE(ROUND(SUM(calculateTax(rahead_taxzone_id, raitem_taxtype_id, rahead_authdate, rahead_curr_id, ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice /\n                        raitem_price_invuomratio), 2))),2),0) as total_tax,   \n         rahead_freight AS freight,\n         taxtype_id AS freightTax,\n         ROUND(calculateTax(rahead_taxzone_id, getfreighttaxtypeid(), rahead_authdate, rahead_curr_id, rahead_freight), 2) AS freighttaxamt\n  FROM rahead \n    LEFT OUTER JOIN raitem ON (raitem_rahead_id=rahead_id)\n    LEFT OUTER JOIN taxzone ON (rahead_taxzone_id=taxzone_id) \n    LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n  WHERE (raitem_rahead_id=<? value("rahead_id") ?>)\n  GROUP BY number, rahead_taxzone_id, curr_id, tax_curr_id,\n         date, freight, freightTax;\n<? elseif exists("tohead_id") ?>\n  SELECT tohead_number AS number,\n         tohead_taxzone_id AS taxzone_id,\n         tohead_freight_curr_id AS curr_id,\n         tohead_freight_curr_id AS tax_curr_id,\n         tohead_orderdate AS date,\n-------- SUM(ROUND(toitem_freight, 2)) AS line,\n-------- COALESCE(ROUND(SUM(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), toitem_freight)),2),0) as total_tax,\n         0.0 AS line, 0.0 AS total_tax,  \n         tohead_freight +  SUM(ROUND(toitem_freight, 2)) AS freight,\n         getFreightTaxTypeId() AS freightTax,\n         COALESCE(ROUND(SUM(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), toitem_freight)),2),0) +\n         COALESCE(ROUND(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), tohead_freight),2),0) AS freighttaxamt \n  FROM toitem, tohead \n  WHERE ((toitem_tohead_id=<? value("tohead_id") ?>)\n    AND  (toitem_tohead_id=tohead_id)\n    AND  (toitem_status!='X')) \n  GROUP BY number, taxzone_id, curr_id, tax_curr_id,\n         date,\t\ttohead_freight,\tfreightTax\n<? elseif exists("pohead_id") ?>\n  SELECT pohead_number AS number,\n         pohead_taxzone_id AS taxzone_id,\n         pohead_curr_id AS curr_id,\n         pohead_curr_id AS tax_curr_id,\n         pohead_orderdate AS date,\n         COALESCE(SUM(ROUND(poitem_unitprice * poitem_qty_ordered, 2)),0) AS line,\n         (SELECT SUM(tax) AS tax \n          FROM (\n            SELECT ROUND(SUM(taxdetail_tax),2) AS tax \n            FROM tax \n              JOIN calculateTaxDetailSummary('PO', <? value("pohead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n            GROUP BY tax_id) data\n         ) as total_tax,\n         (COALESCE(SUM(poitem_freight),0)+COALESCE(pohead_freight,0)) AS freight,\n         taxtype_id AS freightTax,\n         0 AS freighttaxamt\n  FROM pohead \n    LEFT OUTER JOIN poitem ON (poitem_pohead_id=pohead_id)\n    LEFT OUTER JOIN taxzone ON (pohead_taxzone_id=taxzone_id) \n    LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n  WHERE (poitem_pohead_id=<? value("pohead_id") ?>)\n  GROUP BY number, pohead_taxzone_id, curr_id, tax_curr_id,\n         date, pohead_freight, freightTax;\n<? elseif exists("vohead_id") ?>\n  SELECT head.*, linetax.*, adjtax.* \n  FROM\n  (SELECT \n      vohead_number AS number, vohead_taxzone_id AS taxzone_id, \n      vohead_curr_id AS curr_id, vohead_curr_id AS tax_curr_id, vohead_docdate AS date, \n      COALESCE(SUM(ROUND(voitem_qty * poitem_unitprice, 2)), 0) AS line, \n      COALESCE(SUM(voitem_freight), 0) AS freight,  \n      getAdjustmentTaxTypeId() AS adjTax \n  FROM voitem \n      LEFT OUTER JOIN poitem ON (voitem_poitem_id=poitem_id) \n      LEFT OUTER JOIN vohead ON (voitem_vohead_id=vohead_id) \n  WHERE (voitem_vohead_id=<? value("vohead_id") ?>) \n  GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, adjTax) head, \n  (SELECT SUM(voitemtax.taxhist_tax * -1) AS total_tax \n   FROM voitemtax \n    LEFT OUTER JOIN voitem ON (taxhist_parent_id = voitem_id) \n   WHERE (voitem_vohead_id=<? value("vohead_id") ?>)) linetax,\n  (SELECT  SUM(taxhist_tax * -1) AS adjtaxamt \n   FROM vohead \n    LEFT OUTER JOIN voheadtax ON (taxhist_parent_id = vohead_id \n                                AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n   WHERE vohead_id=<? value("vohead_id") ?>) adjtax;\n<? endif ?>;      admin   2011-11-23      0
188 104     taxHistory      detail   ---------BEGIN SUMMARY---------- Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: taxHistory\n-- Name: detail\n-- Notes:\n-----------BEGIN SUMMARY----------\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("summary") ?>\nSELECT <? literal("groupBy") ?>, \n  <? literal("groupBy") ?>_descrip AS description, \n  SUM(salesbase) AS salesbase,\n  SUM(freightbase) AS freightbase, \n  CASE WHEN (SUM(freighttax) > 0) THEN true ELSE false END AS freighttax, \n  SUM(salestaxbase) AS salestaxbase,\n  SUM(purchasebase) AS purchasebase,\n  SUM(purchasetaxbase) * -1 AS purchasetaxbase, \n  SUM(salestaxbase) + SUM(purchasetaxbase) AS nettaxbase,\n  'curr' AS salesbase_xtnumericrole,\n  'curr' AS freightbase_xtnumericrole,\n  'curr' AS salestaxbase_xtnumericrole,\n  'curr' AS purchasebase_xtnumericrole,\n  'curr' AS purchasetaxbase_xtnumericrole,\n  'curr' AS nettaxbase_xtnumericrole,\n  0 AS salestaxbase_xttotalrole,\n  0 AS purchasetaxbase_xttotalrole,\n  0 AS nettaxbase_xttotalrole\nFROM (\n<? endif ?>\n------------END SUMMARY--------------\n<? if exists("showSales") ?>\n------------BEGIN SALES--------------\n-- All sales tax history including memos \nSELECT \n  taxhist_distdate, taxhist_journalnumber,\n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  CASE\n    WHEN (cohist_doctype != 'C') THEN\n      cohist_invcnumber\n    ELSE\n      cohist_ordernumber\n  END AS docnumber, \n  <? value("sales") ?> AS source,\n  CASE\n    WHEN (cohist_doctype='I') THEN\n      <? value("invoice") ?>\n    WHEN (cohist_doctype='C') THEN\n      <? value("creditmemo") ?> \n    WHEN (cohist_doctype='D') THEN\n      <? value("debitmemo") ?>\n    ELSE\n      <? value("other") ?>\n  END AS doctype,\n  item_number, COALESCE(item_descrip1,cohist_misc_descrip) AS description,\n  CASE\n    WHEN (cohist_doctype != 'C') THEN\n      cohist_ordernumber \n  END AS ordernumber, cohist_invcdate AS docdate,\n  cohist_billtoname AS name, \n  cohist_qtyshipped AS qty, \n  cohist_unitprice AS unitprice, (cohist_qtyshipped * cohist_unitprice) AS amount,\n  CASE\n    WHEN (cohist_misc_type IS NULL OR cohist_misc_type IN ('M','F')) THEN\n      currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n    ELSE 0\n  END AS salesbase,\n  CASE\n    WHEN (cohist_misc_type = 'F') THEN\n      currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n    ELSE 0\n  END AS freightbase,\n  CASE\n    WHEN (cohist_misc_type = 'F') THEN\n      taxhist_tax / taxhist_curr_rate\n    ELSE 0\n  END AS freighttax,\n  0 AS purchasebase,\n  taxhist_tax AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  taxhist_tax / taxhist_curr_rate AS salestaxbase,\n  0 AS purchasetaxbase,\n  'qty' AS qty_xtnumericrole,\n  'saleprice' AS unitprice_xtnumericrole,\n  'extprice' AS amount_xtnumericrole,\n  'curr' AS taxhist_tax_xtnumericrole,\n  'curr' AS taxbase_xtnumericrole,\n   0 AS taxbase_xttotalrole\nFROM cohisttax\n JOIN cohist ON (cohist_id=taxhist_parent_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (cohist_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (cohist_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n)\n<? endif ?>\n--------------END SALES--------------------\n<? if exists("showPurchases") ?>\n<? if exists("showSales") ?>\n-- Union because sales and purchase shown together\nUNION ALL\n<? endif ?>\n<? endif ?>\n------------BEGIN PURCHASE----------------\n<? if exists("showPurchases") ?>\n-- A/P Memo history\nSELECT \n  taxhist_distdate, taxhist_journalnumber,\n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  <? value("none") ?> AS taxzone,'' AS taxzone_descrip, curr_abbr, \n  apopen_docnumber AS docnumber, \n  <? value("purchase") ?> AS source,\n  CASE\n    WHEN (apopen_doctype='C') THEN\n      <? value("creditmemo") ?> \n    WHEN (apopen_doctype='D') THEN\n      <? value("debitmemo") ?>\n    ELSE\n      <? value("other") ?>\n  END AS doctype,\n  '' AS item_number, apopen_notes AS description,\n  apopen_ponumber AS ordernumber, apopen_docdate AS docdate,\n  vend_name AS name, \n  1 AS qty, \n  apopen_amount AS unitprice, apopen_amount AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  apopen_amount / apopen_curr_rate AS purchasebase,\n  taxhist_tax AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  taxhist_tax / taxhist_curr_rate AS purchasetaxbase,\n  'qty' AS qty_xtnumericrole,\n  'purchaseprice' AS unitprice_xtnumericrole,\n  'extprice' AS extension_xtnumericrole,\n  'curr' AS taxhist_tax_xtnumericrole,\n  'curr' AS taxbase_xtnumericrole,\n   0 AS taxbase_xttotalrole\nFROM apopentax\n JOIN apopen ON (apopen_id=taxhist_parent_id)\n JOIN vendinfo ON (apopen_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (false)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Header History\nSELECT \n  taxhist_distdate, taxhist_journalnumber,\n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  vohead_number AS docnumber, \n  <? value("purchase") ?> AS source,\n  <? value("voucher") ?>  AS doctype,\n  '', vohead_notes AS description,\n  pohead_number AS ordernumber, vohead_docdate AS docdate,\n  vend_name AS name, \n  1 AS qty, \n  0 AS unitprice, 0 AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  0 AS purchasebase,\n  taxhist_tax AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  taxhist_tax / taxhist_curr_rate AS purchasetaxbase,\n  'qty' AS qty_xtnumericrole,\n  'purchaseprice' AS unitprice_xtnumericrole,\n  'extprice' AS amount_xtnumericrole,\n  'curr' AS taxhist_tax_xtnumericrole,\n  'curr' AS taxbase_xtnumericrole,\n   0 AS taxbase_xttotalrole\nFROM voheadtax\n JOIN vohead ON (vohead_id=taxhist_parent_id)\n LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Line Item\nSELECT \n  taxhist_distdate, taxhist_journalnumber,\n  tax_code AS tax, tax_descrip,\n  COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n  COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n  COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n  COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n  vohead_number AS docnumber, \n  <? value("purchase") ?> AS source,\n  <? value("voucher") ?>  AS doctype,\n  COALESCE(item_number,expcat_code), COALESCE(item_descrip1,expcat_descrip) AS description,\n  pohead_number AS ordernumber, vohead_docdate AS docdate,\n  vend_name AS name, \n  voitem_qty AS qty, \n  COALESCE(SUM(vodist_amount),0)/voitem_qty AS unitprice, COALESCE(SUM(vodist_amount),0) AS amount,\n  0 AS salesbase,\n  0 AS freightbase,\n  0 AS freighttax,\n  currToBase(vohead_curr_id, COALESCE(SUM(vodist_amount),0), vohead_distdate)  AS purchasebase,\n  taxhist_tax AS taxlocal,\n  taxhist_tax / taxhist_curr_rate AS taxbase,\n  0 AS salestaxbase,\n  taxhist_tax / taxhist_curr_rate AS purchasetaxbase,\n  'qty' AS qty_xtnumericrole,\n  'purchaseprice' AS unitprice_xtnumericrole,\n  'extprice' AS amount_xtnumericrole,\n  'curr' AS taxhist_tax_xtnumericrole,\n  'curr' AS taxbase_xtnumericrole,\n   0 AS taxbase_xttotalrole\nFROM voitemtax\n JOIN voitem ON (voitem_id=taxhist_parent_id)\n JOIN vohead ON (vohead_id=voitem_vohead_id)\n JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN poitem ON (voitem_poitem_id=poitem_id)\n JOIN vodist ON ((vodist_poitem_id=poitem_id)\n            AND  (vodist_vohead_id=vohead_id))\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN expcat ON (expcat_id=poitem_expcat_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n                             AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nGROUP BY taxhist_id,taxhist_distdate,tax_code,tax_descrip,\n  taxtype_name,taxtype_descrip,taxclass_code,taxclass_descrip,\n  taxauth_code,taxauth_descrip,taxzone,taxzone_descrip,curr_abbr,\n  vohead_number,pohead_number,item_number,item_descrip1,\n  vohead_curr_id,vohead_distdate,vohead_docdate,vend_name,\n  expcat_code,expcat_descrip,taxhist_tax,taxhist_curr_rate,\n  voitem_qty, taxhist_journalnumber\n<? endif ?>\n-------------END PURCHASE--------------\nORDER BY docdate DESC, docnumber DESC\n\n<? if exists("summary") ?>\n) AS data\nGROUP BY <? literal("groupBy") ?>, <? literal("groupBy") ?>_descrip\nORDER BY <? literal("groupBy") ?>\n<? endif ?>\n\n   admin   2011-11-23      0
189 290     timePhasedAvailability  detail  used by dspTimePhasedAvailability Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: timePhasedAvailability\n-- Name: detail\n-- Notes: used by dspTimePhasedAvailability\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemtype,\n       item_number, uom_name, warehous_code,\n       reorderlevel \n       <? foreach("period_id_list") ?>\n         , bucket_<? literal("period_id_list") ?>,\n         'qty' AS bucket_<? literal("period_id_list") ?>_xtnumericrole,\n         CASE WHEN (bucket_<? literal("period_id_list") ?> < reorderlevel) THEN 'error' END AS   bucket_<? literal("period_id_list") ?>_qtforegroundrole \n       <? endforeach ?>\n FROM (SELECT itemsite_id,\n       CASE WHEN (item_type IN ('F', 'B', 'C', 'Y', 'R')) THEN 0\n            WHEN (item_type IN ('M')) THEN 1\n            WHEN (item_type IN ('P', 'O')) THEN 2\n            ELSE 0\n            END AS itemtype,\n            item_number, uom_name, warehous_code,\n            CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel \n\n       <? foreach("period_id_list") ?>\n       , qtyAvailable(itemsite_id, findPeriodStart(<? value("period_id_list") ?>)) AS bucket_<?  literal("period_id_list") ?> \n       <? endforeach ?>\n FROM itemsite, item, warehous, uom \n  WHERE ((itemsite_item_id=item_id)\n   AND (item_inv_uom_id=uom_id) \n   AND (itemsite_warehous_id=warehous_id) \n  <? if exists("warehous_id") ?>\n     AND (itemsite_warehous_id=<? value("warehous_id") ?>) \n  <? endif ?>\n  <? if exists("plancode_id") ?> \n     AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n   <? elseif exists("plancode_pattern") ?>\n     AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~         <?value("plancode_pattern") ?>)))\n <? endif ?>  \n )) AS data\n  ORDER BY item_number;\n        admin   2011-11-23      0
190 291     timePhasedBookings      detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timePhasedBookings\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("byCust") ?>\n  cust_id, cust_number, cust_name, \n<? elseif exists("byProdcat") ?>\n  prodcat_id, prodcat_code, prodcat_descrip,\n<? elseif exists("byItem") ?>\n  item_id, item_number, item_descrip1,\n<? endif ?>\n  uom, warehous_code\n-- Loop through each period bucket to find bookings for period\n<? foreach("period_id_list") ?>\n             , SUM(CASE WHEN (cohead_orderdate BETWEEN findPeriodStart(<? value("period_id_list") ?>) AND findPeriodEnd(<? value("period_id_list") ?>)) THEN\n                 amount ELSE 0 END) AS bucket_<? literal("period_id_list") ?>,\n  <? if exists("salesDollars") ?>\n             'curr' AS bucket_<? literal("period_id_list") ?>_xtnumericrole, \n             0 AS bucket_<? literal("period_id_list") ?>_xttotalrole\n  <? else ?>\n             'qty' AS bucket_<? literal("period_id_list") ?>_xtnumericrole, \n             0 AS bucket_<? literal("period_id_list") ?>_xttotalrole \n  <? endif ?>\n<? endforeach ?>\nFROM ( \n  SELECT cohead_orderdate,\n<? if exists("byCust") ?>\n         cust_id, cust_number, cust_name\n<? elseif exists("byProdcat") ?>\n         prodcat_id, prodcat_code, prodcat_descrip\n<? elseif exists("byItem") ?>\n         item_id, item_number, item_descrip1\n<? endif ?>\n       , warehous_code\n<? if exists("salesDollars") ?>\n       , round((coitem_qtyord * coitem_qty_invuomratio) * (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS amount\n       , <? value("baseCurrAbbr") ?>::text AS uom\n<? else ?>\n       , coitem_qtyord\n  <? if exists("capacityUnits") ?>\n       * itemcapinvrat(itemsite_item_id)\n  <? elseif exists("altCapacityUnits") ?>\n       * itemaltcapinvrat(itemsite_item_id)\n  <? endif ?>\n         AS amount\n  <? if exists("inventoryUnits") ?>\n       , uom_name AS uom\n  <? elseif exists("capacityUnits") ?>\n       , itemcapuom(item_id) AS uom\n  <? elseif exists("altCapacityUnits") ?>\n       , itemaltcapuom(item_id) AS uom\n  <? endif ?>\n<? endif ?>\n  FROM coitem\n   JOIN cohead ON (coitem_cohead_id=cohead_id)\n   JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n   JOIN item ON (itemsite_item_id=item_id)\n<? if exists("inventoryUnits") ?>\n   JOIN uom ON (item_inv_uom_id=uom_id)\n<? endif ?>\n   JOIN site() ON (itemsite_warehous_id=warehous_id)\n<? if reExists("[cC]ust") ?>\n   JOIN custinfo ON (cohead_cust_id=cust_id)\n<? endif ?> \n<? if reExists("[pP]rodcat") ?>\n   JOIN prodcat ON (item_prodcat_id=prodcat_id)\n<? endif ?>\n  WHERE ((coitem_status != 'X')\n    AND (cohead_orderdate BETWEEN \n<? foreach("period_id_list") ?>\n  <? if isFirst("period_id_list") ?>\n    findPeriodStart(<? value("period_id_list") ?>)\n  <? endif ?>\n  <? if isLast("period_id_list") ?>\n    AND findPeriodEnd(<? value("period_id_list") ?>)\n  <? endif ?>\n<? endforeach ?>)\n<? if exists("item_id") ?> \n    AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?> \n    AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?> \n    AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id \n                              FROM custtype \n                              WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("prodcat_id") ?> \n    AND (item_prodcat_id=<? value("prodcat_id") ?>) \n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT prodcat_id  \n                             FROM prodcat \n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?> \n    AND(itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n      )) data\nGROUP BY\n<? if exists("byCust") ?>\n  cust_id, cust_number, cust_name, \n<? elseif exists("byProdcat") ?>\n  prodcat_id, prodcat_code, prodcat_descrip,\n<? elseif exists("byItem") ?>\n  item_id, item_number, item_descrip1,\n<? endif ?>\n  uom, warehous_code\nORDER BY \n<? if exists("byCust") ?>\n  cust_number,\n<? elseif exists("byProdcat") ?>\n  prodcat_code,\n<? elseif exists("byItem") ?>\n  item_number,\n<? endif ?>\n  uom, warehous_code;\n        admin   2011-11-23      0
191 88      unpostedCashReceipts    detail  Used by arWorkBench, cashReceiptsEditList Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: unpostedCashReceipts\n-- Name: detail\n-- Notes: Used by arWorkBench, cashReceiptsEditList\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n       cashrcpt_id, \n       cashrcpt_number,\n       cust_number,\n       cust_name,\n       cashrcpt_docnumber, \n       bankaccnt_name,\n       cashrcpt_distdate,\n       cashrcpt_amount, \n       currConcat(cashrcpt_curr_id) AS currabbr,\n       CASE\n              WHEN (cashrcpt_fundstype ='C') THEN <? value("check") ?>\n              WHEN (cashrcpt_fundstype ='T') THEN <? value("certifiedCheck") ?>\n              WHEN (cashrcpt_fundstype ='M') THEN <? value("masterCard") ?>\n              WHEN (cashrcpt_fundstype ='V') THEN <? value("visa") ?>\n              WHEN (cashrcpt_fundstype ='A') THEN <? value("americanExpress") ?>\n              WHEN (cashrcpt_fundstype ='D') THEN <? value("discoverCard") ?>\n              WHEN (cashrcpt_fundstype ='R') THEN <? value("otherCreditCard") ?>\n              WHEN (cashrcpt_fundstype ='K') THEN <? value("cash") ?>\n              WHEN (cashrcpt_fundstype ='W') THEN <? value("wireTransfer") ?>\n              WHEN (cashrcpt_fundstype ='O') THEN <? value("other") ?>\n         END AS cashrcpt_fundstype,\n       'curr' AS cashrcpt_amount_xtnumericrole \nFROM cashrcpt, bankaccnt, custinfo\n<? if exists("custgrp_id") ?>\n  JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n  JOIN custgrp ON (custgrp_id=custgrpitem_custgrp_id)\n<? endif ?>\n, custtype\nWHERE ( (NOT cashrcpt_posted)\n  AND   (NOT cashrcpt_void)\n  AND   (cashrcpt_bankaccnt_id=bankaccnt_id)\n  AND   (cashrcpt_cust_id=cust_id)\n  AND   (cust_custtype_id=custtype_id)\n<? if exists("cust_id") ?>\n  AND   (cashrcpt_cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custgrp_id") ?>\n  AND  (custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?>\n  AND   (custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n  AND   (custtype_code~<? value("custtype_pattern") ?>)\n<? endif ?>\n)\nORDER BY cashrcpt_distdate;\n\n admin   2011-11-23      0
192 294     timePhasedSales detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: timePhasedSales\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("byCust") ?>\n  cust_id, cust_number, cust_name, \n<? elseif exists("byProdcat") ?>\n  prodcat_id, prodcat_code, prodcat_descrip,\n<? elseif exists("byItem") ?>\n  item_id, item_number, item_descrip1,\n<? endif ?>\n  uom, warehous_code\n-- Loop through each period bucket to find bookings for period\n<? foreach("period_id_list") ?>\n             , SUM(CASE WHEN (cohist_invcdate BETWEEN findPeriodStart(<? value("period_id_list") ?>) AND findPeriodEnd(<? value("period_id_list") ?>)) THEN\n                 amount ELSE 0 END) AS bucket_<? literal("period_id_list") ?>,\n  <? if exists("salesDollars") ?>\n             'curr' AS bucket_<? literal("period_id_list") ?>_xtnumericrole, \n             0 AS bucket_<? literal("period_id_list") ?>_xttotalrole\n  <? else ?>\n             'qty' AS bucket_<? literal("period_id_list") ?>_xtnumericrole, \n             0 AS bucket_<? literal("period_id_list") ?>_xttotalrole \n  <? endif ?>\n<? endforeach ?>\nFROM ( \n  SELECT cohist_invcdate,\n<? if exists("byCust") ?>\n         cust_id, cust_number, cust_name\n<? elseif exists("byProdcat") ?>\n         prodcat_id, prodcat_code, prodcat_descrip\n<? elseif exists("byItem") ?>\n         item_id, item_number, item_descrip1\n<? endif ?>\n       , warehous_code\n<? if exists("salesDollars") ?>\n       , round((cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate)), 2) AS amount\n       , <? value("baseCurrAbbr") ?>::text AS uom\n<? else ?>\n       , cohist_qtyshipped\n  <? if exists("capacityUnits") ?>\n       * itemcapinvrat(itemsite_item_id)\n  <? elseif exists("altCapacityUnits") ?>\n       * itemaltcapinvrat(itemsite_item_id)\n  <? endif ?>\n         AS amount\n  <? if exists("inventoryUnits") ?>\n       , uom_name AS uom\n  <? elseif exists("capacityUnits") ?>\n       , itemcapuom(item_id) AS uom\n  <? elseif exists("altCapacityUnits") ?>\n       , itemaltcapuom(item_id) AS uom\n  <? endif ?>\n<? endif ?>\n  FROM cohist JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n              JOIN item ON (item_id=itemsite_item_id)\n<? if exists("inventoryUnits") ?>\n   JOIN uom ON (item_inv_uom_id=uom_id)\n<? endif ?>\n   JOIN site() ON (itemsite_warehous_id=warehous_id)\n<? if reExists("[cC]ust") ?>\n   JOIN custinfo ON (cohist_cust_id=cust_id)\n<? endif ?> \n<? if reExists("custgrp") ?>\n   JOIN custgrpitem ON (cohist_cust_id=custgrpitem_cust_id)\n   JOIN custgrp ON (custgrp_id=custgrpitem_custgrp_id)\n<? endif ?> \n<? if reExists("[pP]rodcat") ?>\n   JOIN prodcat ON (item_prodcat_id=prodcat_id)\n<? endif ?>\n  WHERE ((cohist_invcdate BETWEEN \n<? foreach("period_id_list") ?>\n  <? if isFirst("period_id_list") ?>\n    findPeriodStart(<? value("period_id_list") ?>)\n  <? endif ?>\n  <? if isLast("period_id_list") ?>\n    AND findPeriodEnd(<? value("period_id_list") ?>)\n  <? endif ?>\n<? endforeach ?>)\n<? if exists("item_id") ?> \n    AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?> \n    AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?> \n    AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n    AND (cust_custtype_id IN (SELECT custtype_id \n                              FROM custtype \n                              WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("prodcat_id") ?> \n    AND (item_prodcat_id=<? value("prodcat_id") ?>) \n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n    AND (item_prodcat_id IN (SELECT prodcat_id  \n                             FROM prodcat \n                             WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("custgrp_id") ?> \n    AND (custgrp_id=<? value("custgrp_id") ?>) \n<? endif ?>\n<? if exists("custgrp_pattern") ?>\n    AND (custgrp_name  ~ <? value("custgrp_pattern") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?> \n    AND(itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n      )) data\nGROUP BY\n<? if exists("byCust") ?>\n  cust_id, cust_number, cust_name, \n<? elseif exists("byProdcat") ?>\n  prodcat_id, prodcat_code, prodcat_descrip,\n<? elseif exists("byItem") ?>\n  item_id, item_number, item_descrip1,\n<? endif ?>\n  uom, warehous_code\nORDER BY \n<? if exists("byCust") ?>\n  cust_number,\n<? elseif exists("byProdcat") ?>\n  prodcat_code,\n<? elseif exists("byItem") ?>\n  item_number,\n<? endif ?>\n  uom, warehous_code;\n        admin   2011-11-23      0
193 295     timePhasedUsageStatisticsByItem detail  used by dspTimePhasedUsageStatisticsByItem Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: timePhasedUsageStatisticsByItem\n-- Name: detail\n-- Notes: used by dspTimePhasedUsageStatisticsByItem\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT itemsite_id, <? value("received") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransR(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, warehous\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nUNION ALL\nSELECT itemsite_id, <? value("issued") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransI(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, warehous\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nUNION ALL\nSELECT itemsite_id, <? value("sold") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransS(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, warehous\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nUNION ALL\nSELECT itemsite_id, <? value("scrap") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransC(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, warehous\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nUNION ALL\nSELECT itemsite_id, <? value("adjustments") ?> AS label, warehous_code\n     <? foreach("period_id_list") ?>\n       , summTransA(itemsite_id, <? value("period_id_list") ?>) AS bucket_<? literal("period_id_list") ?>\n     <? endforeach ?>\nFROM itemsite, warehous\nWHERE ((itemsite_warehous_id=warehous_id)\n<? if exists("item_id") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY warehous_code;\n      admin   2011-11-23      0
194 297     trialBalances   detail  used by dspTrialBalances Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: trialBalances\n-- Name: detail\n-- Notes: used by dspTrialBalances\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, period_id, accnt_descrip, trialbal_dirty,\n      period_start, period_end,\n       formatGLAccount(accnt_id) AS account,\n      (trialbal_debits) AS debits,\n       (trialbal_credits) AS credits,\n       trialbal_beginning AS beginning,\n       trialbal_ending AS ending,\n       (trialbal_debits - trialbal_credits) AS diff,\n       CASE WHEN ((trialbal_beginning*-1.0)<0.0) THEN 'CR' END AS beginningsense,\n       CASE WHEN ((trialbal_ending*-1.0)<0.0) THEN 'CR' END AS endingsense,\n       CASE WHEN ((trialbal_debits - trialbal_credits)<0.0) THEN 'CR' END AS diffsense,\n       'curr' AS beginning_xtnumericrole,\n       'curr' AS debits_xtnumericrole,\n       'curr' AS credits_xtnumericrole,\n       'curr' AS ending_xtnumericrole,\n       'curr' AS diff_xtnumericrole,\n       0 AS beginning_xttotalrole,\n       0 AS debits_xttotalrole,\n       0 AS credits_xttotalrole,\n       0 AS ending_xttotalrole,\n       0 AS diff_xttotalrole,\n       CASE WHEN (trialbal_beginning < 0.0) THEN ABS(trialbal_beginning) END AS beginning_qtdisplayrole,\n       CASE WHEN (trialbal_ending < 0.0) THEN ABS(trialbal_ending) END AS ending_qtdisplayrole,\n       CASE WHEN ((trialbal_debits - trialbal_credits) < 0.0) THEN ABS(trialbal_debits - trialbal_credits) END AS diff_qtdisplayrole,\n       CASE WHEN (trialbal_dirty) THEN 'warning' END AS ending_qtforegroundrole\nFROM trialbal, accnt, period\n<? if exists("company_id") ?>\n   ,company\n<? endif ?>\nWHERE ((trialbal_accnt_id=accnt_id)\n   AND (trialbal_period_id=period_id)\n<? if exists("accnt_id") ?>\n   AND (trialbal_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("company_id") ?>\n   AND (accnt_company=company_number)\n   AND (company_id=<? value("company_id") ?>)\n<? endif ?>\n<? if exists("period_id") ?>\n   AND (period_id=<? value("period_id") ?>)\n<? endif ?>\n<? if not exists("showZero") ?>\n   AND (abs(trialbal_beginning)+abs(trialbal_ending)+abs(trialbal_debits)+abs(trialbal_credits) > 0)\n<? endif ?>\n      )\nORDER BY period_start, formatGLAccount(accnt_id);\n       admin   2011-11-23      0
195 454     uiforms detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: uiforms\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists('byPackage') ?>\nSELECT uiform_id, uiform_name, uiform_enabled,\n       firstline(uiform_notes) AS uiform_notes, uiform_order,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       CASE nspname WHEN 'public' THEN 0\n                                  ELSE 1 END AS xtindentrole,\n       uiform_notes AS uiform_notes_qttooltiprole\n  FROM uiform\n  JOIN pg_class     ON (uiform.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION \nSELECT -1, pkghead_name, NULL,\n       firstline(pkghead_descrip), NULL,\n       pkghead_name, 0, pkghead_descrip\n  FROM uiform, pg_class, pg_namespace\n  RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name) \n WHERE ((uiform.tableoid=pg_class.oid)\n    AND (relnamespace=pg_namespace.oid))\n ORDER BY pkgname, xtindentrole, uiform_name,\n          uiform_order, uiform_id;\n<? else ?>\nSELECT uiform_id, uiform_name, uiform_enabled,\n       firstline(uiform_notes) AS uiform_notes,\n       uiform_order,\n       CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n       uiform_notes AS uiform_notes_qttooltiprole\n  FROM uiform\n  JOIN pg_class     ON (uiform.tableoid=pg_class.oid)\n  JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY uiform_name, uiform_order, uiform_id;\n<? endif ?>\n      admin   2011-11-23      0
196 298     unbalancedQOHByClassCode        detail  used by dspUnbalancedQOHByClassCode Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: unbalancedQOHByClassCode\n-- Name: detail\n-- Notes: used by dspUnbalancedQOHByClassCode\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n       itemsite_qtyonhand,\n       detailedQOH(itemsite_id, FALSE) AS detailedqoh,\n       itemsite_nnqoh,\n       detailedNNQOH(itemsite_id, FALSE) AS detailednnqoh,\n       'qty' AS itemsite_qtyonhand_xtnumericrole,\n       'qty' AS detailedqoh_xtnumericrole,\n       'qty' AS itemsite_nnqoh_xtnumericrole,\n       'qty' AS detailednnqoh_xtnumericrole\nFROM warehous, item, itemsite, uom\nWHERE ( (itemsite_item_id=item_id)\n    AND (item_inv_uom_id=uom_id)\n    AND (itemsite_warehous_id=warehous_id)\n    AND ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')))\n    AND ((itemsite_qtyonhand <> detailedQOH(itemsite_id, FALSE))\n      OR (itemsite_nnqoh <> detailedNNQOH(itemsite_id, FALSE)))\n<? if exists("classcode_id") ?>\n    AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n    AND (item_classcode_id IN (SELECT classcode_id\n                               FROM classcode\n                               WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?>\n    AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY item_number;\n  admin   2011-11-23      0
197 299     undefinedManufacturedItems      detail  used by dspUndefinedManufacturedItems Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: undefinedManufacturedItems\n-- Name: detail\n-- Notes: used by dspUndefinedManufacturedItems\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, 2, item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       item_type, item_active, <? value("noBom") ?> AS exception\nFROM item\nWHERE ((item_type IN ('M', 'F'))\n   AND (item_id NOT IN (SELECT DISTINCT bomitem_parent_item_id\n                        FROM bomitem))\n<? if exists("notshowInactive") ?>\n   AND (item_active)\n<? endif ?>\n      )\nORDER BY item_number;\n      admin   2011-11-23      0
198 301     unusedPurchasedItems    detail  used by dspUnusedPurchasedItems.cpp Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: unusedPurchasedItems\n-- Name: detail\n-- Notes: used by dspUnusedPurchasedItems.cpp\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT item_id, item_number,\n                (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n                SUM(itemsite_qtyonhand) AS qoh,\n                MAX(itemsite_datelastcount) AS lastcount,\n                MAX(itemsite_datelastused) AS lastused,\n                'qty' AS qoh_xtnumericrole,\n                CASE WHEN (COALESCE(MAX(itemsite_datelastcount), startOfTime()) = startOfTime()) THEN 'Never' END AS lastcount_qtdisplayrole,\n                CASE WHEN (COALESCE(MAX(itemsite_datelastused), startOfTime()) = startOfTime()) THEN 'Never' END AS lastused_qtdisplayrole \nFROM item, itemsite, uom \nWHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (item_id NOT IN (SELECT DISTINCT bomitem_item_id FROM bomitem))\n AND (NOT item_sold)\n AND (item_type IN ('P', 'O')) \n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>) \n<? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ <? value("classcode_pattern") ?>))) \n<? endif ?>\n<? if exists("includeUncontrolled") ?>\n AND (itemsite_controlmethod <> 'N')\n<? endif ?>\n) \nGROUP BY item_id, item_number, uom_name, item_descrip1, item_descrip2 \nORDER BY item_number;\n admin   2011-11-23      0
199 119     updateListPrices        update  Calculates and immediately updates list prices to the database Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: updateListPrices\n-- Name:  update\n-- Notes: Calculates and immediately updates list prices to the database\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE item SET item_listprice=\n<? if exists("byValue") ?>\n       item_listprice + <? value("updateBy") ?>\n<? else ?>\n       item_listprice * (1.0 + (<? value("updateBy") ?> / 100.0))\n<? endif ?>\nWHERE (item_sold)\n<? if exists("prodcat_id") ?>\n  AND (item_prodcat_id=<? value("prodcat_id") ?>)\n<? elseif exists("prodcat_pattern") ?>\n  AND (item_prodcat_id IN (SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ <? value("prodcat_pattern" ?>)))\n<? endif ?>\n       admin   2011-11-23      0
200 120     updateprices    add      Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: updateprices\n-- Name: add\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n  INSERT INTO selsched\n<? if exists("ipshead_id") ?>\n  VALUES (<? value("ipshead_id") ?>);\n<? else ?>\n  SELECT ipshead_id\n  FROM ipshead\n  WHERE ( (ipshead_id NOT IN (\n  \tSELECT selsched_ipshead_id\n  \tFROM selsched\n  \tWHERE (selsched_ipshead_id=ipshead_id)))\n<? if not exists("showEffective") ?>\n  AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n<? if not exists("showExpired") ?>\n  AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showCurrent") ?>\n  AND (CURRENT_DATE NOT BETWEEN ipshead_effective AND ipshead_expires -1)\n<? endif ?>\n );\n\n       admin   2011-11-23      0
201 121     updateprices    availsched       Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: updateprices\n-- Name: availsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ipshead_id, ipshead_name, ipshead_descrip,\n  ipshead_effective, ipshead_expires,\n  CASE WHEN COALESCE(ipshead_effective, startOfTime()) <= startOfTime() THEN \n\t'Always' END AS ipshead_effective_qtdisplayrole,\n  CASE WHEN COALESCE(ipshead_expires, endOfTime()) >= endOfTime() THEN \n\t'Never' END AS ipshead_expires_qtdisplayrole\nFROM ipshead\nWHERE ( (ipshead_id NOT IN (\n  \tSELECT selsched_ipshead_id\n  \tFROM selsched\n  \tWHERE (selsched_ipshead_id=ipshead_id)))\n<? if not exists("showEffective") ?>\n  AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n<? if not exists("showExpired") ?>\n  AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showCurrent") ?>\n  AND (CURRENT_DATE NOT BETWEEN ipshead_effective AND ipshead_expires -1)\n<? endif ?>\n )\nORDER BY ipshead_effective, ipshead_name;\n     admin   2011-11-23      0
202 122     updateprices    createselsched   Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: updateprices\n-- Name: createselsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nCREATE TEMPORARY TABLE selsched (\n  selsched_ipshead_id INTEGER PRIMARY KEY );\n     admin   2011-11-23      0
203 127     updateprices    update   Notes: Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: updateprices\n-- Name: update\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE ipsiteminfo SET\n  ipsitem_price=\n<? if exists("updateByValue") ?>\n  ipsitem_price + <? value("updateBy") ?>\n<? else ?>\n  roundSale(ipsitem_price * (1.0 + (<? value("updateBy") ?> / 100.0)))\n<? endif ?>\nFROM selsched, item\n<? if reExists("itemgrp") ?>\n  JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n  JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n<? elseif reExists("prodcat") ?>\n  JOIN prodcat ON (prodcat_id=item_prodcat_id)\n<? endif ?>\nWHERE ( ipsitem_item_id=item_id\n  AND selsched_ipshead_id=ipsitem_ipshead_id\n<? if exists("item_id") ?>\n  AND item_id=<? value("item_id") ?>\n<? elseif exists("itemgrp_id") ?>\n  AND itemgrp_id=<? value("itemgrp_id") ?>\n<? elseif exists("itemgrp_pattern") ?>\n  AND itemgrp_name ~ <? value("itemgrp_pattern") ?>\n<? elseif exists("prodcat_id") ?>\n  AND prodcat_id=<? value("prodcat_id") ?>\n<? elseif exists("prodcat_pattern") ?>\n  AND prodcat_code ~ <? value("prodcat_pattern") ?>\n<? endif ?>\n);\n      admin   2011-11-23      0
204 126     updateprices    updatechar      used by updatePrices Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: updateprices\n-- Name: updatechar\n-- Notes: used by updatePrices\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE ipsitemchar SET\n  ipsitemchar_price=\n<? if exists("updateByValue") ?>\n  ipsitemchar_price + <? value("updateBy") ?>\n<? else ?>\n  roundSale(ipsitemchar_price * (1.0 + (<? value("updateBy") ?> / 100.0)))\n<? endif ?>\nFROM selsched, ipsitem, item\n<? if reExists("itemgrp") ?>\n  JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n  JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n<? elseif reExists("prodcat") ?>\n  JOIN prodcat ON (prodcat_id=item_prodcat_id)\n<? endif ?>\nWHERE ( ipsitemchar_ipsitem_id=ipsitem_id\n  AND ipsitem_item_id=item_id\n  AND selsched_ipshead_id=ipsitem_ipshead_id\n<? if exists("item_id") ?>\n  AND item_id=<? value("item_id") ?>\n<? elseif exists("itemgrp_id") ?>\n  AND itemgrp_id=<? value("itemgrp_id") ?>\n<? elseif exists("itemgrp_pattern") ?>\n  AND itemgrp_name ~ <? value("itemgrp_pattern") ?>\n<? elseif exists("prodcat_id") ?>\n  AND prodcat_id=<? value("prodcat_id") ?>\n<? elseif exists("prodcat_pattern") ?>\n  AND prodcat_code ~ <? value("prodcat_pattern") ?>\n<? endif ?>\n);\n  admin   2011-11-23      0
205 90      updateReorderLevels     post    itemsite with new reorder level Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: updateReorderLevels\n-- Name:  post\n-- Notes: itemsite with new reorder level\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE itemsite SET\n  itemsite_reorderlevel=<? value("itemsite_reorderlevel") ?>,\n  itemsite_stocked=CASE WHEN (<? value("itemsite_reorderlevel") ?> = 0) THEN false\n                        ELSE itemsite_stocked END,\n  itemsite_useparams=CASE WHEN (<? value("itemsite_reorderlevel") ?> = 0) THEN false\n                          ELSE itemsite_useparams END\nWHERE (itemsite_id=<? value("itemsite_id") ?>)\n  admin   2011-11-23      0
206 91      updateReorderLevels     query   Calculates reorder point levels and returns a proposed result set Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: updateReorderLevels\n-- Name:  query\n-- Notes: Calculates reorder point levels and returns a proposed result set\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n  'qty' AS reordlvl_curr_level_xtnumericrole,\n  'qty' AS reordlvl_calc_level_xtnumericrole,\n  'qty' AS reordlvl_total_usage_xtnumericrole\nFROM updateReorderLevel((\n  SELECT array(\n    SELECT itemsite_id\n    FROM itemsite\n    JOIN item ON (itemsite_item_id=item_id)\n    LEFT OUTER JOIN plancode ON (itemsite_plancode_id=plancode_id)\n    LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\n    WHERE ( (itemsite_active)\n<? if exists("warehous_id") ?>\n     AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n     AND (item_id=<? value("item_id") ?>)\n<? elseif exists("classcode_id") ?>\n     AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n     AND (classcode_code ~ <? value("classcode_pattern") ?>)\n<? elseif exists("plancode_id") ?>\n     AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n     AND (plancode_code ~ <? value("plancode_pattern") ?>)\n<? endif ?>\n     )\n  )\n),\n<? value("daysOfStock") ?>, \n<? if exists("addLeadtime") ?>\n  true,\n<? else ?>\n  false,\n<? endif ?>\n\nARRAY[\n   <? foreach("period_id_list") ?>\n     <? if not isfirst("period_id_list") ?>\n      ,\n     <? endif ?>\n    <? value("period_id_list") ?>\n   <? endforeach ?> ]\n)\nORDER BY reordlvl_warehous_code, reordlvl_item_number;\n       admin   2011-11-23      0
207 92      updateReorderLevels     update  Calculates and immediatly updates reorder point levels to the database Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: updateReorderLevels\n-- Name:  update\n-- Notes: Calculates and immediatly updates reorder point levels to the database\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT updateReorderLevel(itemsite_id,<? value("daysOfStock") ?>, \nARRAY[\n   <? foreach("period_id_list") ?>\n     <? if not isfirst("period_id_list") ?>\n      ,\n     <? endif ?>\n    <? value("period_id_list") ?>\n   <? endforeach ?> ]\n) AS result\nFROM itemsite\n  JOIN item ON (itemsite_item_id=item_id)\n  LEFT OUTER JOIN plancode ON (itemsite_plancode_id=plancode_id)\n  LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\nWHERE ( (itemsite_active)\n  AND (itemsite_useparams)\n<? if exists("warehous_id") ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (item_id=<? value("item_id") ?>)\n<? elseif exists("classcode_id") ?>\n  AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n  AND (classcode_code ~ <? value("classcode_pattern") ?>)\n<? elseif exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n  AND (plancode_code ~ <? value("plancode_pattern") ?>)\n<? endif ?>\n)\n     admin   2011-11-23      0
208 134     usageStatistics detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: usageStatistics\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n  <? if exists("MultiWhs") ?>\n       formatQty(transfer) AS f_transfer,\n  <? endif ?>\n       formatQty(received) AS f_received,\n       formatQty(issued) AS f_issued,\n       formatQty(sold) AS f_sold,\n       formatQty(scrap) AS f_scrap,\n       formatQty(adjust) AS f_adjust,\n       'qty' AS received_xtnumericrole,\n       'qty' AS issued_xtnumericrole,\n       'qty' AS sold_xtnumericrole,\n       'qty' AS scrap_xtnumericrole,\n       'qty' AS adjust_xtnumericrole,\n       'qty' AS transfer_xtnumericrole\nFROM (\nSELECT itemsite_id, item_id, warehous_code,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n  <? if exists("MultiWhs") ?>\n       summTransT(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS transfer,\n  <? endif ?>\n       summTransR(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS received,\n       summTransI(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS issued,\n       summTransS(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS sold,\n       summTransC(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS scrap,\n       summTransA(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS adjust\nFROM item JOIN itemsite ON (itemsite_item_id=item_id)\n          JOIN warehous ON (warehous_id=itemsite_warehous_id)\nWHERE (1=1)\n\n<? if exists("item_id") ?>\n  AND  (item_id=<? value("item_id") ?>)\n<? endif ?>\n\n<? if exists("warehous_id")  ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n\n<? if exists("classcode_id") ?>\n  AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem\n\t\t   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? elseif exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n  AND (item_classcode_id IN (SELECT classcode_id\n\t\t\t     FROM classcode\n\t\t\t     WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? elseif exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t   FROM itemgrpitem, itemgrp\n\t\t   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t     AND  (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? elseif exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? elseif exists("itemgrp")?>\n  AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n) AS data\n\nORDER BY warehous_code, item_number;\n      admin   2011-11-23      0
209 302     validLocationsByItem    detail  used by dspValidLocationsByItem.cpp Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: validLocationsByItem\n-- Name: detail\n-- Notes: used by dspValidLocationsByItem.cpp\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT location_id, warehous_code,\n       formatLocationName(location_id) AS locationname,\n       firstLine(location_descrip) AS locationdescrip,\n       location_restrict, location_netable\nFROM itemsite, location, warehous\nWHERE ((validLocation(location_id, itemsite_id))\n   AND ((itemsite_loccntrl) OR (itemsite_location_id=location_id))\n   AND (itemsite_item_id=<? value("item_id") ?>)\n   AND (itemsite_warehous_id=warehous_id)\n<? if exists("warehous_id") ?>\n   AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n      )\nORDER BY warehous_code, locationname;\n        admin   2011-11-23      0
210 304     vendors detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: vendors\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n  vend_id, vend_vendtype_id, \n  vend_active, vend_number, vend_name,\n  vendtype_code,\n  cntct.*, addr.*\nFROM vendinfo \n  JOIN vendtype ON (vend_vendtype_id=vendtype_id)\n  LEFT OUTER JOIN cntct ON (vend_cntct1_id=cntct_id) \n  LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \nWHERE true\n<? if not exists("showInactive") ?> \n  AND vend_active \n<? endif ?>\n<? if exists("search_pattern") ?>\n  AND ((vend_number ~* <? value("search_pattern") ?>)\n       OR (vend_name ~* <? value("search_pattern") ?>)\n       OR (vendtype_code ~* <? value("search_pattern") ?>)\n       OR (cntct_first_name || ' ' || cntct_last_name ~* <? value("search_pattern") ?>)\n       OR (cntct_phone || ' ' || cntct_phone2 || ' ' || cntct_fax ~* <? value("search_pattern") ?>)\n       OR (cntct_email ~* <? value("search_pattern") ?>)\n       OR (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("search_pattern") ?>)\n       OR (addr_city ~* <? value("search_pattern") ?>)\n       OR (addr_state ~* <? value("search_pattern") ?>)\n       OR (addr_postalcode ~* <? value("search_pattern") ?>)\n       OR (addr_country ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("vend_number_pattern") ?>\n  AND (vend_number ~* <? value("vend_number_pattern") ?>)\n<? endif ?>\n<? if exists("vend_name_pattern") ?>\n  AND (vend_name ~* <? value("vend_name_pattern") ?>)\n<? endif ?>\n<? if exists("vendtype_code_pattern") ?>\n  AND (vendtype_code ~* <? value("vendtype_code_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n  AND (cntct_first_name || ' ' || cntct_last_name ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n  AND (cntct_phone || ' ' || cntct_phone2 || ' ' || cntct_fax ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n  AND (cntct_email ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n  AND (addr_line1 || ' ' || addr_line2 || ' ' || addr_line3 ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n  AND (addr_city ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n  AND (addr_state ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n  AND (addr_postalcode ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n  AND (addr_country ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\nORDER BY vend_number; \n      admin   2011-11-23      0
211 455     voucher editlist        used by voucheringEditList indent: order line item credit account line item credit account debit account for entire order Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: voucher\n-- Name: editlist\n-- Notes: used by voucheringEditList\n-- indent: order\n--            line item\n--              credit account\n--            line item\n--              credit account\n--            debit account for entire order\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT orderid, seq,\n       CASE WHEN seq = 0 THEN vouchernumber\n            ELSE ''\n       END AS vouchernumber, ponumber, itemnumber,\n       vendnumber, description, itemtype, iteminvuom, f_qty, cost,\n       'curr' AS cost_xtnumericrole,\n       0 AS cost_xttotalrole,\n       CASE WHEN seq = 3 THEN 1\n            ELSE seq END AS xtindentrole,\n       CASE WHEN findAPAccount(vendid) < 0 THEN 'error'\n       END AS qtforegroundrole\nFROM (SELECT orderid,\n       CASE WHEN length(ponumber) > 0 THEN 0 ELSE 1 END AS seq,\n       vouchernumber, ponumber,\n       CASE WHEN (itemid = 1) THEN invoicenumber\n            ELSE itemnumber END AS itemnumber,\n       CASE WHEN (itemid = 1) THEN itemnumber\n            ELSE ''         END AS vendnumber,\n       vendid, description,\n       itemtype, iteminvuom, f_qty, cost\nFROM voucheringEditList\nUNION\n-- pull out the credits\nSELECT DISTINCT orderid, 2 AS seq, vouchernumber, '' AS ponumber,\n       <? value("credit") ?> AS itemnumber, '' AS vendnumber, vendid,\n       account AS description,\n       '' AS itemtype, '' AS iteminvuom, NULL as f_qty, cost\nFROM voucheringEditList\nWHERE itemid = 2\nUNION\n-- calculate the debits\nSELECT orderid, 3 AS seq, vouchernumber, '' AS ponumber,\n       <? value("debit") ?> AS itemnumber, '' AS vendnumber, vendid,\n       CASE WHEN findAPAccount(vendid) < 0 THEN <? value("notassigned") ?>\n            ELSE formatGLAccountLong(findAPAccount(vendid))\n       END AS description,\n       '' AS itemtype, '' AS iteminvuom, NULL as f_qty,\n       SUM(cost) AS cost\nFROM voucheringEditList\nWHERE itemid = 2\nGROUP BY orderid, vouchernumber, vendid\nORDER BY vouchernumber, ponumber desc, seq) AS sub;\n       admin   2011-11-23      0
212 305     voucherRegister detail  used by dspVoucherRegister Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: voucherRegister\n-- Name: detail\n-- Notes: used by dspVoucherRegister\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_date,\n       vend_number, vend_name,\n       gltrans_doctype, gltrans_docnumber, firstLine(gltrans_notes) AS reference,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n         ELSE 0\n       END AS debit,\n       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n         ELSE 0\n       END AS credit,\n       gltrans_username,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole\nFROM accnt, gltrans LEFT OUTER JOIN vohead JOIN vend\n                               ON (vohead_vend_id=vend_id)\n                    ON (gltrans_doctype='VO' and gltrans_docnumber=vohead_number)\nWHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n   AND (gltrans_source='A/P')\n<? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n      )\nORDER BY gltrans_created DESC, gltrans_sequence, gltrans_amount;\n       admin   2011-11-23      0
213 306     whereUsed       detail  used by dspSingleLevelWhereUsed, dspIndentedWhereUsed Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.  -- Group: whereUsed\n-- Name: detail\n-- Notes: used by dspSingleLevelWhereUsed, dspIndentedWhereUsed\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT <? if exists("byIndented") ?>\n         bomwork_id, item_id, bomwork_parent_id,\n         bomworkitemsequence(bomwork_id) AS seqord, \n         bomwork_seqnumber, item_number,\n         bomwork_qtyfxd ,bomwork_qtyper,\n         'qty' AS bomwork_qtyfxd_xtnumericrole,\n         'qtyper' AS bomwork_qtyper_xtnumericrole,\n         'scrap' AS bomwork_scrap_xtnumericrole,\n         bomwork_scrap,\n         bomwork_effective,\n         bomwork_expires,\n         CASE WHEN COALESCE(bomwork_effective,startOfTime())=startOfTime() \n              THEN 'Always' \n         END AS bomwork_effective_qtdisplayrole,\n         CASE WHEN COALESCE(bomwork_expires,endOfTime())=endOfTime() \n              THEN 'Never' \n         END AS bomwork_expires_qtdisplayrole,\n         bomwork_level - 1 AS xtindentrole, \n       <? else ?>\n         bomitem_parent_item_id, item_id, bomitem_seqnumber,\n         item_number,\n         itemuomtouom(bomitem_item_id, bomitem_uom_id,\n                      NULL, bomitem_qtyfxd) AS qtyfxd,\n         itemuomtouom(bomitem_item_id, bomitem_uom_id,\n                      NULL, bomitem_qtyper) AS qtyper,\n         'qty' AS qtyfxd_xtnumericrole,\n         'qtyper' AS qtyper_xtnumericrole,\n         'scrap' AS bomitem_scrap_xtnumericrole,\n         bomitem_scrap,\n         bomitem_effective, bomitem_expires,\n         CASE WHEN (COALESCE(bomitem_effective, startoftime()) = startoftime()) \n              THEN 'Always' \n         END AS bomitem_effective_qtdisplayrole,\n         CASE WHEN (COALESCE(bomitem_expires, endoftime()) = endoftime()) \n              THEN 'Never' \n         END AS bomitem_expires_qtdisplayrole,\n-- formatted for report\n         item_descrip1, item_descrip2,\n         formatQty(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd)) AS f_qtyfxd,\n         formatQtyper(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper)) AS f_qtyper,\n         formatScrap(bomitem_scrap) AS f_scrap,\n         formatDate(bomitem_effective, <? value("Always") ?>) AS f_effective,\n         formatDate(bomitem_expires, <? value("Never") ?>) AS f_expires,\n         formatBoolYN(bomitem_createwo) AS f_createwo,\n         CASE WHEN (bomitem_issuemethod='S') THEN <? value("Push") ?>\n              WHEN (bomitem_issuemethod='L') THEN <? value("Pull") ?>\n              WHEN (bomitem_issuemethod='M') THEN <? value("Mixed") ?>\n              ELSE <? value("Special") ?>\n         END AS f_issuemethod,\n         formatQtyper(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap))) as f_qtyreq,\n       <? endif ?>\n       (item_descrip1 || ' ' || item_descrip2) AS descrip,\n       uom_name\nFROM item, uom, \n     <? if exists("byIndented") ?>\n       bomwork\n     <? else ?> \n       bomitem\n     <? endif ?>\nWHERE ((item_inv_uom_id=uom_id)\n        <? if exists("byIndented") ?>\n          AND (bomwork_item_id=item_id)\n          AND (bomwork_set_id=<? value("bomworkset_id") ?>)\n          <? if not exists("showExpired") ?>\n            AND (bomwork_expires > CURRENT_DATE)\n          <? endif ?>\n          <? if not exists("showFuture") ?>\n            AND (bomwork_effective <= CURRENT_DATE)\n          <? endif ?>\n        <? else ?>\n          AND (bomitem_parent_item_id=item_id)\n          AND (bomitem_item_id=<? value("item_id") ?>)\n          AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))\n          <? if not exists("notEffective") ?>\n            AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1)) \n          <? else ?>\n           AND (<? value("effective") ?> BETWEEN bomitem_effective AND (bomitem_expires-1))\n          <? endif ?>\n        <? endif ?>         \n      )\n<? if exists("byIndented") ?>\nORDER BY seqord\n<? else ?>\nORDER BY item_number\n<? endif ?>\n;\n        admin   2011-11-23      0
214 93      workOrderHistory        detail  used by dspWoHistoryByNumber, dspWoHistoryByItem, dspWoHistoryByClassCode Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.      -- Group: workOrderHistory\n-- Name: detail\n-- Notes: used by dspWoHistoryByNumber, dspWoHistoryByItem, dspWoHistoryByClassCode\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n<? if exists("woHistoryByClassCode") ?>\n       wo_id, formatWoNumber(wo_id) AS wonumber, wo_status,\n       wo_qtyord, wo_qtyrcv, wo_postedvalue,\n       wo_startdate, wo_duedate,\n<? elseif exists("woHistoryByItem") ?>\n       wo_id, formatWoNumber(wo_id) AS wonumber, wo_status,\n       wo_qtyord, wo_qtyrcv, wo_postedvalue,\n       wo_startdate, wo_duedate,\n<? else ?>\n       wo.*, COALESCE((prj_number || ' ' || prj_name), '') AS project,\n  <? if exists("revControl") ?>\n       COALESCE(bom.rev_number, '') AS bom_rev_number,\n       COALESCE(boo.rev_number, '') AS boo_rev_number,\n  <? endif ?>\n       'cost' AS wo_wipvalue_xtnumericrole,\n<? endif ?>\n<? if not exists("woHistoryByItem") ?>\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       item_descrip1, item_descrip2, uom_name,\n<? endif ?>\n       warehous_code,\n       formatDate(wo_startdate) AS f_wo_startdate,\n       formatDate(wo_duedate) AS f_wo_duedate,\n       formatQty(wo_qtyord) AS f_wo_qtyord,\n       formatQty(wo_qtyrcv) AS f_wo_qtyrcv,\n       formatCost(wo_postedvalue) AS f_wo_postedvalue,\n       'qty' AS wo_qtyord_xtnumericrole,\n       'qty' AS wo_qtyrcv_xtnumericrole,\n       'cost' AS wo_postedvalue_xtnumericrole\nFROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n        JOIN warehous ON (warehous_id=itemsite_warehous_id)\n<? if not exists("woHistoryByItem") ?>\n        JOIN item ON (item_id=itemsite_item_id)\n        JOIN uom ON (uom_id=item_inv_uom_id)\n<? endif ?>\n<? if exists("revControl") ?>\n        LEFT OUTER JOIN rev bom ON (bom.rev_id=wo_bom_rev_id)\n        LEFT OUTER JOIN rev boo ON (boo.rev_id=wo_boo_rev_id)\n<? endif ?>\n        LEFT OUTER JOIN prj ON (prj_id=wo_prj_id)\nWHERE ((true)\n<? if exists("woHistoryByItem") ?>\n   AND (itemsite_item_id=<? value("item_id") ?>)\n   AND (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n   AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("wo_number") ?>\n   AND (CAST(wo_number AS TEXT) ~ <? value("wo_number") ?>)\n<? endif ?>\n<? if exists("woHistoryByClassCode") ?>\n   AND (itemsite_item_id=item_id)\n   AND (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n  <? if exists("classcode_id") ?>\n    AND (item_classcode_id=<? value("classcode_id") ?>)\n  <? elseif exists("classcode_pattern") ?>\n    AND (item_classcode_id IN (SELECT classcode_id FROM classcode\n                               WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n  <? endif ?>\n<? endif ?>\n<? if exists("showOnlyTopLevel") ?>\n   AND ((wo_ordtype<>'W') OR (wo_ordtype IS NULL))\n<? endif ?>\n      )\n\n<? if exists("woHistoryByItem") ?>\n  ORDER BY wo_startdate DESC, wo_number, wo_subnumber\n<? elseif exists("woHistoryByClassCode") ?>\n  ORDER BY item_number\n<? else ?>\n  ORDER BY wo_number, wo_subnumber\n<? endif ?>\n;\n        admin   2011-11-23      0
215 132     workOrderMaterial       detail  used by dspWoMaterialsByItem, dspWoMaterialsByWorkOrder Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.        -- Group: workOrderMaterial\n-- Name: detail\n-- Notes: used by dspWoMaterialsByItem, dspWoMaterialsByWorkOrder\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT womatl.*, formatWONumber(wo_id) AS wonumber, item_number,\n       item_descrip1, item_descrip2,\n<? if exists("Manufacturing") ?>\n       formatwooperseq(womatl_wooper_id) AS wooperseq,\n<? endif ?>\n       CASE WHEN (womatl_issuemethod = 'S') THEN <? value("push") ?>\n            WHEN (womatl_issuemethod = 'L') THEN <? value("pull") ?>\n            WHEN (womatl_issuemethod = 'M') THEN <? value("mixed") ?>\n            ELSE <? value("error") ?>\n       END AS issuemethod,\n       uom_name,\n       noNeg(womatl_qtyreq - womatl_qtyiss) AS balance,\n<? if exists("includeFormatted") ?>\n       formatDate(womatl_duedate) AS f_duedate,\n       formatQty(womatl_qtyfxd) AS f_qtyfxd,\n       formatQtyPer(womatl_qtyper) AS f_qtyper,\n       formatPrcnt(womatl_scrap) AS f_scrap,\n       formatQty(womatl_qtyreq) AS f_qtyreq,\n       formatQty(womatl_qtyiss) AS f_qtyiss,\n       formatQty(womatl_qtywipscrap) AS f_qtywipscrap,\n       formatQty(noNeg(womatl_qtyreq - womatl_qtyiss)) AS f_balance,\n<? endif ?>\n       CASE WHEN (womatl_duedate <= CURRENT_DATE) THEN 'error' END AS womatl_duedate_qtforegroundrole,\n       'qty' AS womatl_qtyfxd_xtnumericrole,\n       'qtyper' AS womatl_qtyper_xtnumericrole,\n       'percent' AS womatl_scrap_xtnumericrole,\n       'qty' AS womatl_qtyreq_xtnumericrole,\n       'qty' AS womatl_qtyiss_xtnumericrole,\n       'qty' AS womatl_qtywipscrap_xtnumericrole,\n       'qty' AS balance_xtnumericrole,\n       0 AS womatl_qtyreq_xttotalrole,\n       0 AS womatl_qtyiss_xttotalrole,\n       0 AS womatl_qtywipscrap_xttotalrole,\n       0 AS balance_xttotalrole\nFROM wo JOIN womatl ON (womatl_wo_id=wo_id)\n        JOIN uom ON (uom_id=womatl_uom_id)\n        JOIN itemsite parentsite ON (parentsite.itemsite_id=wo_itemsite_id)\n        JOIN itemsite componentsite ON (componentsite.itemsite_id=womatl_itemsite_id)\n<? if exists("item_id") ?>\n        JOIN item ON (item_id=parentsite.itemsite_item_id)\n<? elseif exists("wo_id") ?>\n        JOIN item ON (item_id=componentsite.itemsite_item_id)\n<? endif ?>\nWHERE (1=1)\n<? if exists("item_id") ?>\n  AND (componentsite.itemsite_item_id=<? value("item_id") ?>)\n  AND (wo_status <> 'C')\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND (componentsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND (wo_id=<? value("wo_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\nORDER BY wo_startdate, item_number\n<? endif ?>\n<? if exists("wo_id") ?>\n  <? if exists("Manufacturing") ?>\n  ORDER BY wooperseq, item_number\n  <? else ?>\n  ORDER BY item_number\n  <? endif ?>\n<? endif ?>\n;\n     admin   2011-11-23      0
216 116     workOrderSchedule       parameterlist   used by dspWoScheduleByParameterList Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: workOrderSchedule\n-- Name: parameterlist\n-- Notes: used by dspWoScheduleByParameterList\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT wo_id,\n       CASE WHEN (wo_ordid IS NULL) THEN -1\n            ELSE wo_ordid\n       END AS orderid,\n       wo.*, warehous_code, uom_name,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       item_descrip1, item_descrip2,\n       formatQty(wo_qtyord) AS ordered,\n       formatQty(wo_qtyrcv) AS received,\n       formatDate(wo_startdate) AS startdate,\n       formatDate(wo_duedate) AS duedate,\n       formatWONumber(wo_id) AS wonumber,\n       'qty' AS wo_qtyord_xtnumericrole,\n       'qty' AS wo_qtyrcv_xtnumericrole,\n       CASE WHEN ((wo_startdate<=CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) THEN 'error'\n       END AS wo_startdate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error'\n       END AS wo_duedate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'Overdue'\n            ELSE 'On Time'\n       END AS condition,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error' END AS condition_qtforegroundrole\nFROM wo, itemsite, warehous, item, uom\nWHERE ( (wo_itemsite_id=itemsite_id)\n  AND (itemsite_item_id=item_id)\n  AND (item_inv_uom_id=uom_id)\n  AND (itemsite_warehous_id=warehous_id)\n  AND (wo_startdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND (wo_number IN (SELECT wo_number\n                     FROM wo\n                     WHERE (wo_id=<? value("wo_id") ?>)))\n<? endif ?>\n<? if exists("status_list") ?>\n  AND (wo_status IN (\n<? foreach("status_list") ?>\n  <? if not isfirst("status_list") ?>\n    ,\n  <? endif ?>\n  <? value("status_list") ?>\n<? endforeach ?> ))\n<? elseif exists("showOnlyRI") ?>\n  AND (wo_status IN ('R','I'))\n<? else ?>\n  AND (wo_status<>'C')\n<? endif ?>\n<? if exists("showOnlyTopLevel") ?>\n  AND (wo_ordtype<>'W')\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem\n                   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? elseif exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("wrkcnt_id") ?>\n  AND (wo_id IN (SELECT wooper_wo_id\n                 FROM wooper\n                 WHERE (wooper_wrkcnt_id=<? value("wrkcnt_id") ?>)))\n<? elseif exists("classcode_pattern") ?>\n  AND (item_classcode_id IN (SELECT classcode_id\n                             FROM classcode\n                             WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? elseif exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem, itemgrp\n                   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n<? elseif exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n                                FROM plancode\n                                WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? elseif exists("wrkcnt_pattern") ?>\n  AND (wo_id IN (SELECT wooper_wo_id\n                 FROM wooper, wrkcnt\n                 WHERE ((wooper_wrkcnt_id=wrkcnt_id) AND (wrkcnt_code ~ <? value("wrkcnt_pattern") ?>))))\n<? endif ?>\n<? if exists("wo_username") ?>\n  AND (wo_username=<? value("wo_username") ?>)\n<? endif ?>\n   )\nORDER BY \n<? if exists("sortByStartDate") ?>\n  wo_startdate,\n<? elseif exists("sortByDueDate") ?>\n  wo_duedate,\n<? elseif exists("sortByItemNumber") ?>\n  item_number,\n<? endif ?>\n  wo_number, wo_subnumber;\n   admin   2011-11-23      0
217 128     workOrderVariance       material        used by dspMaterialUsageVarianceByBOMItem, dspMaterialUsageVarianceByComponentItem, dspMaterialUsageVarianceByItem, dspMaterialUsageVarianceByWarehouse, dspMaterialUsageVarianceByWorkOrder Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: workOrderVariance\n-- Name: material\n-- Notes: used by dspMaterialUsageVarianceByBOMItem, dspMaterialUsageVarianceByComponentItem,\n--                dspMaterialUsageVarianceByItem, dspMaterialUsageVarianceByWarehouse,\n--                dspMaterialUsageVarianceByWorkOrder\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT womatlvar_id, posted, \n       parentitemnumber, parentdescrip,\n       componentitemnumber, componentdescrip,\n       ordered, received,\n       projreq, projqtyper,\n       actiss, actqtyper,\n       (actqtyper - projqtyper) AS qtypervar,\n       CASE WHEN (actqtyper=projqtyper) THEN 0\n            WHEN (projqtyper=0) THEN actqtyper\n            ELSE ((1 - (actqtyper / projqtyper)) * -1)\n       END AS qtypervarpercent,\n       womatlvar_notes, womatlvar_ref,\n<? if exists("includeFormatted") ?>\n       formatDate(posted) AS f_posted,\n       formatQty(ordered) AS f_ordered,\n       formatQty(received) AS f_received,\n       formatQty(projreq) AS f_projreq,\n       formatQtyPer(projqtyper) AS f_projqtyper,\n       formatQty(actiss) AS f_actiss,\n       formatQty(actqtyper) AS f_actqtyper,\n       formatQty(actqtyper - projqtyper) AS f_qtypervar,\n       CASE WHEN (actqtyper=projqtyper) THEN formatQty(0)\n            WHEN (projqtyper=0) THEN formatQty(actqtyper)\n            ELSE formatPrcnt((1 - (actqtyper / projqtyper)) * -1)\n       END AS f_qtypervarpercent,\n<? endif ?>\n       'qty' AS ordered_xtnumericrole,\n       'qty' AS received_xtnumericrole,\n       'qty' AS projreq_xtnumericrole,\n       'qtyper' AS projqtyper_xtnumericrole,\n       'qty' AS actiss_xtnumericrole,\n       'qtyper' AS actqtyper_xtnumericrole,\n       'qtyper' AS qtypervar_xtnumericrole,\n       'percent' AS qtypervarpercent_xtnumericrole\nFROM ( SELECT womatlvar_id, womatlvar_posted AS posted,\n              parentitem.item_number AS parentitemnumber,\n              parentitem.item_descrip1 || ' ' || parentitem.item_descrip2 as parentdescrip,\n              componentitem.item_number AS componentitemnumber,\n              componentitem.item_descrip1 || ' ' || componentitem.item_descrip2 as componentdescrip,\n              womatlvar_notes, womatlvar_ref,\n              womatlvar_qtyord AS ordered, womatlvar_qtyrcv AS received,\n              ((womatlvar_qtyfxd + womatlvar_qtyrcv * womatlvar_qtyper) * (1 + womatlvar_scrap)) AS projreq,\n              womatlvar_qtyper AS projqtyper,\n              (womatlvar_qtyiss) AS actiss, (NONEG(womatlvar_qtyiss - womatlvar_qtyfxd) / (womatlvar_qtyrcv * (1 + womatlvar_scrap))) AS actqtyper\n       FROM womatlvar LEFT OUTER JOIN wo ON ( (wo_number=womatlvar_number) AND\n                                              (wo_subnumber=womatlvar_subnumber) )\n                      LEFT OUTER JOIN itemsite parent ON (parent.itemsite_id=womatlvar_parent_itemsite_id)\n                      LEFT OUTER JOIN item parentitem ON (parentitem.item_id=parent.itemsite_item_id)\n                      LEFT OUTER JOIN itemsite component ON (component.itemsite_id=womatlvar_component_itemsite_id)\n                      LEFT OUTER JOIN item componentitem ON (componentitem.item_id=component.itemsite_item_id)\n       WHERE ( (1=1)\n<? if exists("startDate") ?>\n         AND   (womatlvar_posted BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n         AND   (wo_id=<? value("wo_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n         AND   (parent.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n         AND   (parent.itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("bomitem_id") ?>\n         AND   (womatlvar_bomitem_id=<? value("bomitem_id") ?>)\n<? endif ?>\n<? if exists("component_item_id") ?>\n         AND   (component.itemsite_item_id=<? value("component_item_id") ?>)\n<? endif ?>\n             ) ) AS data\nORDER BY posted;\n  admin   2011-11-23      0
218 444     bankrec checks  used by reconcileBankaccount Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: bankrec\n-- Name: checks\n-- Notes: used by reconcileBankaccount\n--        Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("summary") ?>\nSELECT COALESCE(SUM(amount),0.0) AS cleared_amount\n  FROM ( SELECT COALESCE( bankrecitem_amount,\n                          currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) ) AS amount\n           FROM (bankaccnt CROSS JOIN gltrans)\n                       JOIN bankrecitem ON ((bankrecitem_source='GL')\n                                        AND (bankrecitem_source_id=gltrans_id)\n                                        AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                        AND (bankrecitem_cleared))\n          WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n            AND (NOT gltrans_deleted)\n            AND (NOT gltrans_rec)\n            AND (gltrans_amount > 0)\n            AND (gltrans_doctype != 'JP')\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT COALESCE( bankrecitem_amount,\n                          currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) ) AS amount\n           FROM (bankaccnt CROSS JOIN sltrans)\n                       JOIN bankrecitem ON ((bankrecitem_source='SL')\n                                        AND (bankrecitem_source_id=sltrans_id)\n                                        AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                        AND (bankrecitem_cleared))\n          WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n            AND (NOT sltrans_rec)\n            AND (sltrans_amount > 0)\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n           FROM bankadj, bankadjtype, bankrecitem\n          WHERE ( (bankrecitem_source='AD')\n            AND (bankrecitem_source_id=bankadj_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (bankadj_bankadjtype_id=bankadjtype_id)\n            AND (NOT bankadj_posted)\n            AND (((bankadjtype_iscredit=true) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=false) AND (bankadj_amount < 0)))\n            AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>) ) ) AS data;\n<? else ?>\nSELECT gltrans_id AS id, 1 AS altid,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       gltrans_date AS transdate,\n       gltrans_doctype AS doc_type,\n       gltrans_docnumber AS doc_number,\n       gltrans_notes AS notes,\n       (SELECT currConcat(COALESCE(checkhead_curr_id, baseCurrId()))) AS doc_curr,\n       COALESCE(bankrecitem_curr_rate, checkhead_curr_rate, currRate(bankaccnt_curr_id, gltrans_date)) AS doc_exchrate,\n       gltrans_amount AS base_amount,\n       COALESCE( bankrecitem_amount,\n                 checkhead_amount,\n                 currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) ) AS amount,\n       gltrans_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM (bankaccnt CROSS JOIN gltrans)\n              LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n                                          AND (bankrecitem_source_id=gltrans_id)\n                                          AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                          AND (bankrecitem_cleared))\n              LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n                                        AND (gltrans_misc_id=checkhead_id))\n WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n   AND (NOT gltrans_deleted)\n   AND (NOT gltrans_rec)\n   AND (NOT COALESCE(checkhead_void, false))\n   AND (gltrans_amount > 0)\n   AND (gltrans_doctype != 'JP')\n   AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n UNION ALL\nSELECT sltrans_id AS id, 2 AS altid,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       sltrans_date AS transdate,\n       sltrans_doctype AS doc_type,\n       sltrans_docnumber AS doc_number,\n       sltrans_notes AS notes,\n       (SELECT currConcat(COALESCE(checkhead_curr_id, baseCurrId()))) AS doc_curr,\n       COALESCE(bankrecitem_curr_rate, checkhead_curr_rate, currRate(bankaccnt_curr_id, sltrans_date)) AS doc_exchrate,\n       sltrans_amount AS base_amount,\n       COALESCE( bankrecitem_amount,\n                 checkhead_amount,\n                 currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) ) AS amount,\n       sltrans_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM (bankaccnt CROSS JOIN sltrans)\n              LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n                                          AND (bankrecitem_source_id=sltrans_id)\n                                          AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                          AND (bankrecitem_cleared))\n              LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n                                        AND (sltrans_misc_id=checkhead_id))\n WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n   AND (NOT sltrans_rec)\n   AND (NOT COALESCE(checkhead_void, false))\n   AND (sltrans_amount > 0)\n   AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n UNION ALL\nSELECT bankadj_id AS id, 3 AS altid,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       bankadj_date AS transdate,\n       'ADJ' AS doc_type,\n       bankadj_docnumber AS doc_number,\n       bankadjtype_name AS notes,\n       (SELECT currConcat(bankadj_curr_id)) AS doc_curr,\n       1.0 AS doc_exchrate,\n       CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS base_amount,\n       CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS amount,\n       bankadj_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM (bankadjtype CROSS JOIN bankadj)\n               LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='AD')\n                                           AND (bankrecitem_source_id=bankadj_id)\n                                           AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                           AND (bankrecitem_cleared))\n WHERE ( (((bankadjtype_iscredit=true) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=false) AND (bankadj_amount < 0)))\n   AND (bankadj_bankadjtype_id=bankadjtype_id)\n   AND (NOT bankadj_posted)\n   AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>) )\nORDER BY sortdate;\n<? endif ?>\n       admin   2012-03-01      0
219 447     crmaccountmerge pickdatasources Show the records the user has selected to merge crm accounts. Emphasize the particular fields in each record that s/he has selected. Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: crmaccountmerge\n-- Name:  pickdatasources\n-- Notes: Show the records the user has selected to merge crm accounts. Emphasize\n--        the particular fields in each record that s/he has selected.\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT c.crmacct_id,\n       crmacctsel_dest_crmacct_id,\n       c.crmacct_active,\n       formatCntctName(c.crmacct_cntct_id_1) AS primary,\n       formatCntctName(c.crmacct_cntct_id_2) AS secondary,\n       c.crmacct_competitor_id IS NOT NULL   AS competitor,\n       c.crmacct_cust_id       IS NOT NULL   AS cust,\n       c.crmacct_emp_id        IS NOT NULL   AS emp,\n       c.crmacct_name,\n       c.crmacct_number,\n       c.crmacct_owner_username              AS owner,\n       p.crmacct_number                      AS parent,\n       c.crmacct_partner_id    IS NOT NULL   AS partner,\n       c.crmacct_prospect_id   IS NOT NULL   AS prospect,\n       c.crmacct_salesrep_id   IS NOT NULL   AS salesrep,\n       c.crmacct_taxauth_id    IS NOT NULL   AS taxauth,\n       c.crmacct_type,\n       c.crmacct_usr_username  IS NOT NULL   AS usr,\n       c.crmacct_vend_id       IS NOT NULL   AS vend,\n       trim(firstline(c.crmacct_notes))      AS notes,\n\n       CASE crmacctsel_src_crmacct_id=crmacctsel_dest_crmacct_id\n            WHEN true THEN '#ccc'\n       END AS qtbackgroundrole,\n\n       CASE WHEN c.crmacct_active IS NULL THEN <? value('na') ?> END AS crmacct_active_qtdisplayrole,\n       CASE WHEN COALESCE(formatCntctName(c.crmacct_cntct_id_1), '') = '' THEN <? value('na') ?> END AS primary_qtdisplayrole,\n       CASE WHEN COALESCE(formatCntctName(c.crmacct_cntct_id_2), '') = '' THEN <? value('na') ?> END AS secondary_qtdisplayrole,\n       CASE WHEN COALESCE(c.crmacct_name,           '') = '' THEN <? value('na') ?>  END AS crmacct_name_qtdisplayrole,\n       CASE WHEN COALESCE(c.crmacct_number,         '') = '' THEN <? value('na') ?>  END AS crmacct_number_qtdisplayrole,\n       CASE WHEN COALESCE(c.crmacct_owner_username, '') = '' THEN <? value('na') ?>  END AS owner_qtdisplayrole,\n       CASE WHEN COALESCE(p.crmacct_number,         '') = '' THEN <? value('na') ?>  END AS parent_qtdisplayrole,\n       CASE c.crmacct_type WHEN 'I' THEN <? value('individual') ?>\n                           WHEN 'O' THEN <? value('organization') ?>\n                           ELSE <? value('na') ?> END AS crmacct_type_qtdisplayrole,\n       CASE WHEN COALESCE(TRIM(firstline(c.crmacct_notes)), '') = '' THEN <? value('na') ?> END AS notes_qtdisplayrole,\n\n       CASE WHEN crmacctsel_mrg_crmacct_number         THEN 'emphasis' END AS crmacct_number_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_active         THEN 'emphasis' END AS crmacct_active_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_cntct_id_1     THEN 'emphasis' END AS primary_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_cntct_id_2     THEN 'emphasis' END AS secondary_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_competitor_id  THEN 'emphasis' END AS competitor_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_cust_id        THEN 'emphasis' END AS cust_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_emp_id         THEN 'emphasis' END AS emp_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_name           THEN 'emphasis' END AS crmacct_name_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_owner_username THEN 'emphasis' END AS owner_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_parent_id      THEN 'emphasis' END AS parent_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_partner_id     THEN 'emphasis' END AS partner_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_prospect_id    THEN 'emphasis' END AS prospect_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_salesrep_id    THEN 'emphasis' END AS salesrep_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_taxauth_id     THEN 'emphasis' END AS taxauth_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_type           THEN 'emphasis' END AS crmacct_type_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_usr_username   THEN 'emphasis' END AS usr_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_vend_id        THEN 'emphasis' END AS vend_qtforegroundrole,\n       CASE WHEN crmacctsel_mrg_crmacct_notes          THEN 'emphasis' END AS notes_qtforegroundrole,\n\n       c.crmacct_cntct_id_1   AS primary_xtidrole,\n       c.crmacct_cntct_id_2   AS secondary_xtidrole,\n       c.crmacct_cust_id      AS cust_xtidrole,\n       c.crmacct_emp_id       AS emp_xtidrole,\n       c.crmacct_parent_id    AS parent_xtidrole,\n       c.crmacct_prospect_id  AS prospect_xtidrole,\n       c.crmacct_salesrep_id  AS salesrep_xtidrole,\n       c.crmacct_taxauth_id   AS taxauth_xtidrole,\n       c.crmacct_usr_username AS usr_xtidrole,\n       c.crmacct_vend_id      AS vend_xtidrole,\n\n       c.crmacct_notes AS notes_qttooltiprole\n\n  FROM crmacct c\n  JOIN crmacctsel ON (c.crmacct_id=crmacctsel_src_crmacct_id)\n  LEFT OUTER JOIN crmacct p ON (c.crmacct_parent_id=p.crmacct_id)\n WHERE crmacctsel_dest_crmacct_id=<? value('destid') ?>\n ORDER BY qtbackgroundrole DESC, c.crmacct_number;\n      admin   2012-01-17      0
220 243     depositesRegister       detail  used by dspDepositsRegister Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.    -- Group: depositesRegister\n-- Name: detail\n-- Notes: used by dspDepositsRegister\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT trans_id, trans_date, trans_source,\n       CASE WHEN (trans_doctype='IN') THEN <? value("invoice") ?>\n            WHEN (trans_doctype='CM') THEN <? value("creditmemo") ?>\n         ELSE trans_doctype\n       END AS doctype,\n       trans_docnumber, firstLine(trans_notes) AS f_notes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n       CASE WHEN (trans_amount < 0) THEN formatMoney(ABS(trans_amount))\n         ELSE ''\n       END AS f_debit,\n       CASE WHEN (trans_amount < 0) THEN ABS(trans_amount)\n         ELSE 0\n       END AS debit,\n       CASE WHEN (trans_amount > 0) THEN trans_amount\n         ELSE 0\n       END AS credit,\n       (aropen_amount - aropen_paid) AS balance,\n       currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate) AS base_balance,\n       currconcat(aropen_curr_id) AS currAbbr,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS debit_xttotalrole,\n       0 AS credit_xttotalrole,\n       0 AS base_balance_xttotalrole\nFROM (\nSELECT gltrans_id AS trans_id, gltrans_date AS trans_date, gltrans_created AS trans_created,\n       gltrans_source AS trans_source, gltrans_doctype AS trans_doctype, gltrans_sequence AS trans_sequence,\n       gltrans_docnumber AS trans_docnumber, gltrans_notes AS trans_notes, gltrans_amount AS trans_amount,\n       accnt_id, accnt_descrip,\n       aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM gltrans LEFT OUTER JOIN aropen ON ((text(gltrans_docnumber) = 'I-' || text(aropen_docnumber))\n                                    AND (aropen_doctype='I')), accnt\nWHERE ((gltrans_accnt_id=accnt_id)\n   AND (gltrans_doctype = 'CR')\n   AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\nUNION\nSELECT sltrans_id AS trans_id, sltrans_date AS trans_date, sltrans_created AS trans_created,\n       sltrans_source AS trans_source, sltrans_doctype AS trans_doctype, sltrans_sequence AS trans_sequence,\n       sltrans_docnumber AS trans_docnumber, sltrans_notes AS trans_notes, sltrans_amount AS trans_amount,\n       accnt_id, accnt_descrip,\n       aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM sltrans LEFT OUTER JOIN aropen ON ((text(sltrans_docnumber) = 'I-' || text(aropen_docnumber))\n                                    AND (aropen_doctype='I')), accnt\nWHERE ((sltrans_accnt_id=accnt_id)\n   AND (sltrans_doctype = 'CR')\n   AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n     ) AS data\nORDER BY trans_created DESC, trans_sequence, trans_amount;\n        admin   2012-01-17      0
221 102     todolist        detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: todolist\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * FROM (\n/*        ---------TO DO-------------- */\n  SELECT todoitem_id AS id, \n         1 AS altId, \n         <? value("todo") ?> AS type, \n         CAST(incdt_number AS text) AS number,\n         todoitem_name AS name,\n         CASE WHEN (todoitem_active AND todoitem_status != 'C') THEN TRUE\n              ELSE FALSE\n         END AS active,\n         CASE WHEN (todoitem_status='C') THEN <? value("complete") ?>\n              WHEN (todoitem_status='D') THEN <? value("deferred") ?>\n              WHEN (todoitem_status='P') THEN <? value("pending") ?>\n              WHEN (todoitem_status='I') THEN <? value("inprocess") ?>\n              WHEN (todoitem_status='N') THEN <? value("new") ?>\n              ELSE '?'\n         END AS stage,\n         incdtpriority_name AS priority, \n         incdtpriority_order AS seq,\n         todoitem_owner_username AS owner, \n         todoitem_username AS assigned, \n         firstLine(todoitem_description) AS notes, \n         todoitem_start_date as start, \n         todoitem_due_date AS due, \n         formatDate(todoitem_due_date) AS f_due, \n         todoitem_start_date is not null AS hasStartDate,\n         todoitem_due_date is not null AS hasDueDate,\n         crmacct_id,\n         crmacct_number, \n         crmacct_name, \n         CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n           'OPP'\n              WHEN (todoitem_incdt_id IS NOT NULL) THEN\n           'INCDT'\n         END AS parent,\n         CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n           <? value("opportunity") ?> || '-' || ophead_number\n              WHEN (todoitem_incdt_id IS NOT NULL) THEN\n           <? value("incident") ?> || '-' || incdt_number\n         END AS parent_qtdisplayrole,\n         CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n           <? value("opportunity") ?> || '-' || ophead_number\n              WHEN (todoitem_incdt_id IS NOT NULL) THEN\n           <? value("incident") ?> || '-' || incdt_number\n         END AS f_parent,\n         COALESCE(todoitem_ophead_id, todoitem_incdt_id) AS parent_xtidrole,\n         COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n         crmacct_cust_id AS cust,\n         CASE WHEN (todoitem_active AND todoitem_due_date < CURRENT_DATE) THEN 'expired'\n              WHEN (todoitem_active AND todoitem_due_date > CURRENT_DATE) THEN 'future'\n         END AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n    FROM todoitem\n<? else ?>\n    FROM todoitem() \n<? endif ?>\n      LEFT OUTER JOIN incdt ON (incdt_id=todoitem_incdt_id) \n      LEFT OUTER JOIN ophead ON (ophead_id=todoitem_ophead_id)\n      LEFT OUTER JOIN crmacct ON (crmacct_id=todoitem_crmacct_id) \n      LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=todoitem_priority_id) \n<? if not exists("todoList")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (todoitem_start_date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (todoitem_start_date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (todoitem_due_date <= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (todoitem_due_date >= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (crmacct_id =<? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (todoitem_status = 'C')\t\t\t\n<? elseif not exists("completed") ?>\n  AND (todoitem_status != 'C')\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (todoitem_username, todoitem_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (todoitem_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (todoitem_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (todoitem_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (todoitem_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\nUNION ALL\n/*        ---------INCIDENT-------------- */\n  SELECT incdt_id AS id, \n         2 AS altId, \n         <? value("incident") ?> AS type, \n         CAST(incdt_number AS text) AS number,\n         incdt_summary AS name, \n         incdt_status != 'L' AS active,\n         CASE WHEN (incdt_status='N') THEN <? value("new") ?>\n              WHEN (incdt_status='F') THEN <? value("feedback") ?>\n              WHEN (incdt_status='C') THEN <? value("confirmed") ?>\n              WHEN (incdt_status='A') THEN <? value("assigned") ?>\n              WHEN (incdt_status='R') THEN <? value("resolved") ?>\n              WHEN (incdt_status='L') THEN <? value("closed") ?>\n              ELSE '?'\n         END AS stage,\n         incdtpriority_name AS priority,\n         incdtpriority_order AS seq,\n         incdt_owner_username AS owner, \n         incdt_assigned_username AS assigned,\n         firstLine(incdt_descrip) AS notes, \n         CAST(incdt_timestamp AS date) AS start, \n         null AS due, \n         null AS f_due, \n         false AS hasStartDate,\n         false AS hasDueDate,\n         crmacct_id,\n         crmacct_number, \n         crmacct_name,\n         '' AS parent,\n         '' AS parent_qtdisplay_role,\n         '' AS f_parent,\n         NULL AS parent_xtidrole,\n         COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n         COALESCE(crmacct_cust_id,-1) AS cust,\n         NULL AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n         FROM incdt\n<? else ?>\n         FROM incdt()\n<? endif ?>\n           LEFT OUTER JOIN crmacct ON (crmacct_id=incdt_crmacct_id) \n           LEFT OUTER JOIN cust ON (cust_id=crmacct_cust_id) \n           LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) \n<? if not exists("incidents")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (incdt_timestamp::date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (incdt_timestamp::date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND false\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND false\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (crmacct_id =<? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (incdt_status = 'L')\t\t\t\n<? elseif not exists("completed") ?>\n  AND (incdt_status != 'L')\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (incdt_assigned_username, incdt_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (incdt_assigned_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (incdt_assigned_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (incdt_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (incdt_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\nUNION ALL\n/*        ---------PROJECT TASK-------------- */\n    SELECT prjtask_id AS id, \n           3 AS altId, \n           <? value("task") ?> AS type,\n           prjtask_number AS number,\n           prjtask_name AS name, \n           prjtask_status != 'C' AS active,\n           CASE WHEN (prjtask_status='P') THEN <? value("concept") ?>\n                WHEN (prjtask_status='O') THEN <? value("inprocess") ?>\n                WHEN (prjtask_status='C') THEN <? value("complete") ?>\n                ELSE '?'\n           END AS stage,\n           NULL AS priority, \n           NULL AS seq, \n           prjtask_owner_username AS owner, \n           prjtask_username AS assigned, \n           firstLine(prjtask_descrip) AS notes, \n           prjtask_start_date AS start, \n           prjtask_due_date AS due, \n           formatDate(prjtask_due_date) AS f_due, \n           prjtask_start_date is not null AS hasStartDate,\n           prjtask_due_date is not null AS hasDueDate,\n           NULL AS crmacct_id,\n           '' AS crmacct_number, \n           '' AS crmacct_name,\n           'PRJ' AS parent,\n           <? value("project") ?> || '-' || prj_number AS parent_qtdisplay_role,\n           <? value("project") ?> || '-' || prj_number AS f_parent,\n           prjtask_prj_id AS parent_xtidrole,\n           false AS cust_qtdisplayrole, \n           null AS cust,\n           CASE WHEN (prjtask_status != 'C' AND prjtask_due_date < CURRENT_DATE) THEN 'expired'\n                WHEN (prjtask_status != 'C' AND prjtask_due_date > CURRENT_DATE) THEN 'future'\n           END AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n     FROM prjtask\n<? else ?>\n     FROM prjtask()\n<? endif ?>\n       JOIN prj ON (prj_id=prjtask_prj_id)\n<? if not exists("projects")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (prjtask_start_date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (prjtask_start_date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (prjtask_due_date <= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (prjtask_due_date >= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (prjtask_status = 'C')\t\t\t\n<? elseif not exists("completed") ?>\n  AND (prjtask_status != 'C')\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (prjtask_username, prjtask_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (prjtask_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (prjtask_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (prjtask_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (prjtask_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\nUNION ALL\n/*        ---------PROJECT-------------- */\n    SELECT prj_id AS id, \n           4 AS altId, \n           <? value("project") ?> AS type,\n           prj_number AS number,\n           prj_name AS name, \n           prj_status != 'C' AS active,\n           CASE WHEN (prj_status='P') THEN <? value("concept") ?>\n                WHEN (prj_status='O') THEN <? value("inprocess") ?>\n                WHEN (prj_status='C') THEN <? value("complete") ?>\n                ELSE '?'\n           END AS stage,\n           NULL AS priority, \n           NULL AS seq,\n           prj_owner_username AS owner, \n           prj_username AS assigned,\n           firstLine(prj_descrip) AS notes, \n           prj_start_date AS start, \n           prj_due_date AS due, \n           formatDate(prj_due_date) AS f_due, \n           prj_start_date IS NOT NULL AS hasStartDate,\n           prj_due_date IS NOT NULL AS hasDueDate,\n           null AS crmacct_id,\n           '' AS crmacct_number, \n           '' AS crmacct_name,\n           '' AS parent,\n           '' AS parent_qtdisplayrole,\n           '' AS f_parent,\n           NULL AS parent_xtidrole,\n           false AS cust_qtdisplayrole, \n           null AS cust,\n           CASE WHEN (prj_status != 'C'AND prj_due_date < CURRENT_DATE) THEN 'expired'\n                WHEN (prj_status != 'C'AND prj_due_date > CURRENT_DATE) THEN 'future'\n           END AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n       FROM prj\n<? else ?>\n       FROM prj()\n<? endif ?>\n<? if not exists("projects")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (prj_start_date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (prj_start_date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (prj_due_date <= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (prj_due_date >= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (prj_status = 'C')\t\t\t\n<? elseif not exists("completed") ?>\n  AND (prj_status != 'C')\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (prj_username, prj_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (prj_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (prj_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (prj_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (prj_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\nUNION ALL\n/*        ---------OPPORTUNITY-------------- */\n  SELECT ophead_id AS id, \n         5 AS altId, \n         <? value("opportunity") ?> AS type, \n         ophead_number AS number,\n         ophead_name AS name, \n         ophead_active AS active,\n         opstage_descrip AS stage,         \n         incdtpriority_name AS priority, \n         incdtpriority_order AS seq,\n         ophead_owner_username AS owner, \n         ophead_username AS assigned, \n         firstLine(ophead_notes) AS notes, \n         ophead_start_date AS start, \n         ophead_target_date AS due, \n         formatDate(ophead_target_date) AS f_due,\n         ophead_start_date is not null AS hasStartDate,\n         ophead_target_date is not null AS hasDueDate,\n         crmacct_id,\n         crmacct_number, \n         crmacct_name, \n         '' AS parent,\n         '' AS parent_qtdisplayrole,\n         '' AS f_parent,\n         NULL AS parent_xtidrole,\n         COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n         crmacct_cust_id AS cust,\n         CASE WHEN (ophead_active AND ophead_target_date < CURRENT_DATE) THEN 'expired'\n              WHEN (ophead_active AND ophead_target_date > CURRENT_DATE) THEN 'future'\n         END AS due_qtforegroundrole \n<? if exists("hasContext") ?>\n    FROM ophead\n<? else ?>\n    FROM ophead()\n<? endif ?>\n      JOIN opstage ON (ophead_opstage_id=opstage_id)\n      LEFT OUTER JOIN crmacct ON (crmacct_id=ophead_crmacct_id) \n      LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=ophead_priority_id) \n<? if not exists("opportunities")?>\n    WHERE false\n<? else ?>\n    WHERE true\n<? endif ?>\n<? if exists("startStartDate") ?>\n  AND (ophead_start_date <= <? value("startStartDate") ?>)\n<? endif ?>\n<? if exists("startEndDate") ?>\n  AND (ophead_start_date >= <? value("startEndDate") ?>)\n<? endif ?>\n<? if exists("dueStartDate") ?>\n  AND (ophead_target_date <= <? value("dueStartDate") ?>)\n<? endif ?>\n<? if exists("dueEndDate") ?>\n  AND (ophead_target_date >= <? value("dueEndDate") ?>)\n<? endif ?>\n<? if exists("crmacct_id") ?>\n  AND (crmacct_id =<? value("crmacct_id") ?>)\n<? endif ?>\n<? if exists("completedonly") ?>\n  AND (NOT ophead_active)\t\t\t\n<? elseif not exists("completed") ?>\n  AND (ophead_active)\t\t\t\n<? endif ?>\n<? if exists("username") ?>\n  AND (<? value("username") ?> IN (ophead_username, ophead_owner_username))\n<? endif ?>\n<? if exists("assigned_username") ?> \n  AND (ophead_username=<? value("assigned_username") ?>) \n<? elseif exists("assigned_usr_pattern") ?>\n  AND (ophead_username ~ <? value("assigned_usr_pattern") ?>) \n<? endif ?>\n<? if exists("owner_username") ?> \n  AND (ophead_owner_username=<? value("owner_username") ?>) \n<? elseif exists("owner_usr_pattern") ?>\n  AND (ophead_owner_username ~ <? value("owner_usr_pattern") ?>) \n<? endif ?>\n) AS data\nORDER BY hasDueDate desc, due, hasStartDate desc, start\n  admin   2012-01-17      0
222 106     bankrecHistory  unreconciled     Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: bankrecHistory\n-- Name: unreconciled\n-- Notes: \n--        Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n--        See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_date, formatDate(gltrans_date) AS f_date,\n      gltrans_docnumber,\n       CASE WHEN gltrans_doctype = 'CK' THEN <? value("Checks") ?>\n            WHEN gltrans_doctype = 'CR' THEN <? value("Deposits") ?>\n            ELSE <? value("Adjustments") ?> END AS type,\n       CASE WHEN gltrans_doctype = 'CK' THEN 1\n            WHEN gltrans_doctype = 'CR' THEN 2\n            ELSE '3' END AS sort,\n      gltrans_notes AS notes,\n      currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1 AS amount,\n      formatMoney(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1) AS f_amount,\n      CASE WHEN gltrans_doctype = 'CK' THEN \n        currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n      ELSE 0 END AS rtcheck,\n      CASE WHEN gltrans_doctype = 'CR' THEN \n        currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n      ELSE 0 END AS rtdep,\n      CASE WHEN gltrans_doctype NOT IN ('CK','CR') THEN \n        currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n      ELSE 0 END AS rtadj,\n      'curr' AS amount_xtnumericrole,\n      1 AS xtindentrole\n FROM gltrans\n   JOIN bankaccnt ON (bankaccnt_accnt_id = gltrans_accnt_id)\n   JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n                       AND (selrec.bankrec_id=<? value("bankrec_id") ?>))\n   LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n\n                              AND (bankrecitem_source_id=gltrans_id))\n   LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n   LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n                             AND (gltrans_misc_id=checkhead_id))\n<? if exists("showUnreconciled") ?>\n WHERE ((COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n  AND (NOT gltrans_deleted)\n  AND (NOT COALESCE(checkhead_void, false)))\n  AND (gltrans_doctype != 'JP')\n<? else ?>\n WHERE (false)\n<? endif ?>\n\nUNION\n\nSELECT sltrans_id, sltrans_date, formatDate(sltrans_date) AS f_date,\n      sltrans_docnumber,\n       CASE WHEN sltrans_doctype = 'CK' THEN <? value("Checks") ?>\n            WHEN sltrans_doctype = 'CR' THEN <? value("Deposits") ?>\n            ELSE <? value("Adjustments") ?> END AS type,\n       CASE WHEN sltrans_doctype = 'CK' THEN 1\n            WHEN sltrans_doctype = 'CR' THEN 2\n            ELSE '3' END AS sort,\n      sltrans_notes AS notes,\n      currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1 AS amount,\n      formatMoney(currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1) AS f_amount,\n      CASE WHEN sltrans_doctype = 'CK' THEN \n        currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n      ELSE 0 END AS rtcheck,\n      CASE WHEN sltrans_doctype = 'CR' THEN \n        currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n      ELSE 0 END AS rtdep,\n      CASE WHEN sltrans_doctype NOT IN ('CK','CR') THEN \n        currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n      ELSE 0 END AS rtadj,\n      'curr' AS amount_xtnumericrole,\n      1 AS xtindentrole\n FROM sltrans\n   JOIN bankaccnt ON (bankaccnt_accnt_id = sltrans_accnt_id)\n   JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n                       AND (selrec.bankrec_id=<? value("bankrec_id") ?>))\n   LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n\n                              AND (bankrecitem_source_id=sltrans_id))\n   LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n   LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n                             AND (sltrans_misc_id=checkhead_id))\n<? if exists("showUnreconciled") ?>\n WHERE ((COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n  AND (NOT COALESCE(checkhead_void, false)))\n<? if exists("treeView") ?>\nUNION\nSELECT -1, NULL, NULL, <? value("Checks") ?>, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL,'curr', 0 \nUNION\nSELECT -1, NULL, NULL, <? value("Deposits") ?>, NULL, 2, NULL, NULL, NULL, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, <? value("Adjustments") ?>, NULL, 3, NULL, NULL, NULL, NULL, NULL, NULL, 'curr', 0\n<? endif ?>\n\nORDER BY  sort, xtindentrole, type, f_date, gltrans_id\n<? else ?>\n WHERE (false)\n<? endif ?>\n    admin   2012-03-01      0
223 115     workOrderSchedule       detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: workOrderSchedule\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT wo_id,\n       CASE WHEN (wo_ordid IS NULL) THEN -1\n            ELSE wo_ordid\n       END AS orderid,\n       wo.*, warehous_code, uom_name,\n       item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       item_descrip1, item_descrip2,\n       formatQty(wo_qtyord) AS ordered,\n       formatQty(wo_qtyrcv) AS received,\n       formatDate(wo_startdate) AS startdate,\n       formatDate(wo_duedate) AS duedate,\n       formatWONumber(wo_id) AS wonumber,\n       'qty' AS wo_qtyord_xtnumericrole,\n       'qty' AS wo_qtyrcv_xtnumericrole,\n       CASE WHEN ((wo_startdate<=CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) THEN 'error'\n       END AS wo_startdate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error'\n       END AS wo_duedate_qtforegroundrole,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'Overdue'\n            ELSE 'On Time'\n       END AS condition,\n       CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error' END AS condition_qtforegroundrole\nFROM itemsite, warehous, item, uom, wo \n<? if reExists("woSoStatus") ?>\n JOIN coitem ON ((coitem_order_id=wo_id)\n             AND (coitem_order_type='W'))\n<? endif ?>\nWHERE ( (wo_itemsite_id=itemsite_id)\n  AND (itemsite_item_id=item_id)\n  AND (item_inv_uom_id=uom_id)\n  AND (itemsite_warehous_id=warehous_id)\n<? if exists("search_pattern") ?>\n  AND ( (wo_number::TEXT ~* <? value("search_pattern") ?>)\n    OR  (item_number ~* <? value("search_pattern") ?>)\n    OR  (item_descrip1 || item_descrip2 ~* <? value("search_pattern") ?>) )\n<? endif ?>\n<? if exists("woSoStatus") ?>\n  AND (coitem_status <> 'X')\n<? elseif exists("woSoStatusMismatch") ?>\n  AND (coitem_status='C')\n<? endif ?>\n<? if exists("startDate") ?>\n  AND (wo_startdate >= <? value("startDate") ?>)\n<? endif ?>\n<? if exists("startDate") ?>\n  AND (wo_startdate <= <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n  AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n  AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("wo_id") ?>\n  AND (wo_number IN (SELECT wo_number\n                     FROM wo\n                     WHERE (wo_id=<? value("wo_id") ?>)))\n<? endif ?>\n<? if exists("status_list") ?>\n<? foreach("status_list") ?>\n  <? if isfirst("status_list") ?>\n    AND (wo_status=<? value("status_list") ?>\n  <? else ?>\n    OR wo_status=<? value("status_list") ?>\n  <? endif ?>\n  <? if islast("status_list") ?>\n    )\n  <? endif ?>\n<? endforeach ?>\n<? elseif exists("showOnlyRI") ?>\n  AND (wo_status IN ('R','I'))\n<? else ?>\n  AND (wo_status<>'C')\n<? endif ?>\n<? if exists("showOnlyTopLevel") ?>\n  AND (wo_ordtype<>'W')\n<? endif ?>\n<? if exists("classcode_id") ?>\n  AND (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem\n                   WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n  AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? endif ?>\n<? if exists("wrkcnt_id") ?>\n  AND (wo_id IN (SELECT wooper_wo_id\n                 FROM wooper\n                 WHERE (wooper_wrkcnt_id=<? value("wrkcnt_id") ?>)))\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n  AND (item_classcode_id IN (SELECT classcode_id\n                             FROM classcode\n                             WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n  AND (item_id IN (SELECT itemgrpitem_item_id\n                   FROM itemgrpitem, itemgrp\n                   WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n<? endif ?>\n<? if exists("plancode_pattern") ?>\n  AND (itemsite_plancode_id IN (SELECT plancode_id\n                                FROM plancode\n                                WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("wrkcnt_pattern") ?>\n  AND (wo_id IN (SELECT wooper_wo_id\n                 FROM wooper, wrkcnt\n                 WHERE ((wooper_wrkcnt_id=wrkcnt_id) AND (wrkcnt_code ~ <? value("wrkcnt_pattern") ?>))))\n<? endif ?>\n   )\nORDER BY \n<? if exists("sortByStartDate") ?>\n  wo_startdate,\n<? elseif exists("sortByDueDate") ?>\n  wo_duedate,\n<? elseif exists("sortByItemNumber") ?>\n  item_number,\n<? endif ?>\n  wo_number, wo_subnumber;\n admin   2012-01-17      0
224 39      arHistory       detail  used by dspCustomerARHistory, dspCustomerInformation Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: arHistory\n-- Name: detail\n-- Notes: used by dspCustomerARHistory, dspCustomerInformation\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT aropen_id, applyid,\n       sortdate, sortnumber, type,\n       docnumber, open, documenttype,\n       docdate, duedate, amount, balance, base_balance, currAbbr,\n       formatBoolYN(open) AS f_open,\n       formatDate(docdate) AS f_docdate, formatDate(duedate) AS f_duedate,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       type AS xtindentrole\n  FROM (\n    SELECT 0 AS type, aropen_id, -1 AS applyid,\n           aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n           aropen_docnumber AS docnumber,\n           aropen_open AS open,\n           CASE WHEN (aropen_doctype='I') THEN <? value("invoice") ?>\n                WHEN (aropen_doctype='C') THEN <? value("creditMemo") ?>\n                WHEN (aropen_doctype='D') THEN <? value("debitMemo") ?>\n                WHEN (aropen_doctype='R') then <? value("cashdeposit") ?>\n                ELSE <? value("other") ?>\n           END AS documenttype,\n           aropen_docdate AS docdate,\n           aropen_duedate AS duedate,\n           aropen_amount AS amount,\n           (aropen_amount - aropen_paid) AS balance,\n           CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n                        (currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate) * -1.0)\n                ELSE currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate)\n           END AS base_balance,\n           currConcat(aropen_curr_id) AS currAbbr\n     FROM aropen\n    WHERE ( (aropen_cust_id=<? value("cust_id") ?>) \n    <? if exists("startDate") ?>\n      AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?> )\n\n    UNION\n    SELECT 1 AS type, -1 AS aropen_id, arapply_source_aropen_id AS applyid,\n           aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n           CASE WHEN (arapply_source_doctype IN ('C','R')) THEN arapply_source_docnumber\n                WHEN (arapply_source_doctype='K') THEN arapply_refnumber\n                ELSE <? value("error") ?>\n           END AS docnumber,\n           NULL AS open,\n           CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n                WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n                WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n                WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n                WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n                WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n                WHEN (arapply_fundstype='A') THEN <? value("americanExpres") ?>\n                WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n                WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n                WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n                WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n                WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n           END AS documenttype,\n           COALESCE(cashrcpt_docdate, arapply_postdate) AS docdate,\n           arapply_distdate AS duedate,\n           arapply_applied AS amount,\n           0 AS balance,\n           0 AS base_balance,\n           currConcat(arapply_curr_id) AS currAbbr\n     FROM arapply JOIN aropen ON (arapply_target_aropen_id=aropen_id)\n                  LEFT OUTER JOIN cashrcptitem ON ( (arapply_reftype='CR') AND\n                                                    (arapply_ref_id=cashrcptitem_id) )\n                  LEFT OUTER JOIN cashrcpt ON (cashrcpt_id=cashrcptitem_cashrcpt_id)\n    WHERE ( (arapply_target_doctype IN ('I', 'D'))\n      AND   (arapply_cust_id=<? value("cust_id") ?>)\n      AND   (aropen_cust_id=<? value("cust_id") ?>)\n    <? if exists("startDate") ?>\n      AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?> )\n\n    UNION\n    SELECT 2 AS type, -1 AS aropen_id, arapply_target_aropen_id AS applyid,\n           aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n           arapply_target_docnumber AS docnumber,\n           NULL AS open,\n           CASE WHEN (arapply_target_doctype='I') THEN <? value("invoice") ?>\n                WHEN (arapply_target_doctype='D') THEN <? value("debitMemo") ?>\n                ELSE <? value("other") ?>\n           END AS documenttype,\n           arapply_postdate AS docdate,\n           arapply_distdate AS duedate,\n           arapply_applied AS amount,\n           0 AS balance,\n           0 AS base_balance,\n           currConcat(arapply_curr_id) AS currAbbr\n     FROM arapply, aropen\n    WHERE ( (arapply_source_doctype IN ('K', 'C', 'R'))\n      AND  (arapply_source_aropen_id=aropen_id)\n      AND  (arapply_cust_id=<? value("cust_id") ?>)\n      AND  (aropen_cust_id=<? value("cust_id") ?>)\n    <? if exists("startDate") ?>\n      AND   (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?> )\n\n    UNION\n    SELECT 0 AS type, -1 AS aropen_id, -1 AS applyid,\n           invchead_invcdate AS sortdate, (invchead_invcnumber || 'I') AS sortnumber,\n           invchead_invcnumber AS docnumber,\n           false AS open,\n           <? value("zeroinvoice") ?> AS documenttype,\n           invchead_invcdate AS docdate,\n           invchead_invcdate AS duedate,\n           0 AS amount,\n           0 AS balance,\n           0 AS base_balance,\n           currConcat(invchead_curr_id) AS currAbbr\n     FROM invchead\n    WHERE ( (invchead_cust_id=<? value("cust_id") ?>) \n    <? if exists("startDate") ?>\n      AND   (invchead_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n    <? endif ?>\n      AND   (invchead_posted)\n      AND   ((SELECT SUM(invcitem_price)\n              FROM invcitem\n             WHERE (invcitem_invchead_id=invchead_id))=0) )\n  ) AS data\n  ORDER BY sortdate, sortnumber, type;\n    admin   2012-03-01      0
225 446     bankrec receipts        used by reconcileBankaccount Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: bankrec\n-- Name: receipts\n-- Notes: used by reconcileBankaccount\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("summary") ?>\nSELECT COALESCE(SUM(amount),0.0) AS cleared_amount\n  FROM ( SELECT COALESCE( bankrecitem_amount,\n                          (currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) AS amount\n           FROM (bankaccnt CROSS JOIN gltrans)\n                      JOIN bankrecitem ON ((bankrecitem_source='GL')\n                                       AND (bankrecitem_source_id=gltrans_id)\n                                       AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                       AND (bankrecitem_cleared))\n          WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n            AND (NOT gltrans_deleted)\n            AND (NOT gltrans_rec)\n            AND (gltrans_amount < 0)\n            AND (gltrans_doctype != 'JP')\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT COALESCE( bankrecitem_amount,\n                          (currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) AS amount\n           FROM (bankaccnt CROSS JOIN sltrans)\n                      JOIN bankrecitem ON ((bankrecitem_source='SL')\n                                       AND (bankrecitem_source_id=sltrans_id)\n                                       AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                                       AND (bankrecitem_cleared))\n          WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n            AND (NOT sltrans_rec)\n            AND (sltrans_amount < 0)\n            AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n          UNION ALL\n         SELECT CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n           FROM bankrecitem, bankadj, bankadjtype\n          WHERE ( (bankrecitem_source='AD')\n            AND (bankrecitem_source_id=bankadj_id)\n            AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n            AND (bankrecitem_cleared)\n            AND (bankadj_bankadjtype_id=bankadjtype_id)\n            AND (NOT bankadj_posted)\n            AND (((bankadjtype_iscredit=false) AND (bankadj_amount > 0)) OR (bankadjtype_iscredit=true AND (bankadj_amount < 0)))\n            AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>) ) ) AS data;\n<? else ?>\nSELECT gltrans_id AS id, 1 AS altid,\n       jrnluse_use AS use, gltrans_journalnumber AS jrnlnum,\n       COALESCE(date(jrnluse_date), gltrans_date) AS f_jrnldate,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       gltrans_date AS f_date,\n       gltrans_doctype AS doc_type,\n       gltrans_docnumber AS docnumber,\n       gltrans_notes AS notes,\n       currConcat(COALESCE(cashrcpt_curr_id, baseCurrId())) AS doc_curr,\n       COALESCE(bankrecitem_curr_rate, cashrcpt_curr_rate, currRate(bankaccnt_curr_id, gltrans_date)) AS doc_exchrate,\n       (gltrans_amount * -1.0) AS base_amount,\n       COALESCE( bankrecitem_amount,\n                 cashrcpt_amount,\n                 (currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) AS amount,\n       COALESCE(date(jrnluse_date), gltrans_date) AS jrnldate,\n       gltrans_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM bankaccnt\n  JOIN gltrans ON (bankaccnt_accnt_id=gltrans_accnt_id)\n  LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n                              AND (bankrecitem_source_id=gltrans_id)\n                              AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                              AND (bankrecitem_cleared))\n  LEFT OUTER JOIN jrnluse ON (jrnluse_number=gltrans_journalnumber AND jrnluse_use='C/R')\n  LEFT OUTER JOIN cashrcpt  ON ((gltrans_source='A/R')\n                            AND (gltrans_doctype='CR')\n                            AND (gltrans_misc_id=cashrcpt_id))\n  LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n                            AND (gltrans_misc_id=checkhead_id))\n WHERE ((NOT gltrans_deleted)\n   AND (NOT gltrans_rec)\n   AND (NOT COALESCE(checkhead_void, false))\n   AND (gltrans_amount < 0)\n   AND (gltrans_doctype != 'JP')\n   AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n UNION ALL\nSELECT sltrans_id AS id, 2 AS altid,\n       jrnluse_use AS use, sltrans_journalnumber AS jrnlnum,\n       COALESCE(date(jrnluse_date), sltrans_date) AS f_jrnldate,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       sltrans_date AS f_date,\n       sltrans_doctype AS doc_type,\n       sltrans_docnumber AS docnumber,\n       sltrans_notes AS notes,\n       currConcat(COALESCE(cashrcpt_curr_id, baseCurrId())) AS doc_curr,\n       COALESCE(bankrecitem_curr_rate, cashrcpt_curr_rate, currRate(bankaccnt_curr_id, sltrans_date)) AS doc_exchrate,\n       (sltrans_amount * -1.0) AS base_amount,\n       COALESCE( bankrecitem_amount,\n                 cashrcpt_amount,\n                 (currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) AS amount,\n       COALESCE(date(jrnluse_date), sltrans_date) AS jrnldate,\n       sltrans_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM bankaccnt\n  JOIN sltrans ON (bankaccnt_accnt_id=sltrans_accnt_id)\n  LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n                              AND (bankrecitem_source_id=sltrans_id)\n                              AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>)\n                              AND (bankrecitem_cleared))\n  LEFT OUTER JOIN jrnluse ON (jrnluse_number=sltrans_journalnumber AND jrnluse_use='C/R')\n  LEFT OUTER JOIN cashrcpt  ON ((sltrans_source='A/R')\n                            AND (sltrans_doctype='CR')\n                            AND (sltrans_misc_id=cashrcpt_id))\n  LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n                            AND (sltrans_misc_id=checkhead_id))\n WHERE ((NOT sltrans_rec)\n   AND (NOT COALESCE(checkhead_void, false))\n   AND (sltrans_amount < 0)\n   AND (bankaccnt_id=<? value("bankaccntid") ?>) )\n UNION ALL\nSELECT bankadj_id AS id, 3 AS altid,\n       '' AS use, NULL AS jrnlnum, bankadj_date AS f_jrnldate,\n       COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n       bankadj_date AS f_date,\n       'ADJ' AS doc_type,\n       bankadj_docnumber AS docnumber,\n       bankadjtype_name AS notes,\n       currConcat(bankadj_curr_id) AS doc_curr,\n       1.0 AS doc_exchrate,\n       CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS base_amount,\n       CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS amount,\n       bankadj_date AS jrnldate,\n       bankadj_date AS sortdate,\n       'uomratio' AS doc_exchrate_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       'curr' AS amount_xtnumericrole\n  FROM (bankadjtype CROSS JOIN bankadj)\n               LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='AD')\n                                           AND (bankrecitem_source_id=bankadj_id)\n                                           AND (bankrecitem_bankrec_id=<? value("bankrecid") ?>))\n WHERE ( (((bankadjtype_iscredit=false) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=true) AND (bankadj_amount < 0)))\n   AND (bankadj_bankadjtype_id=bankadjtype_id)\n   AND (NOT bankadj_posted)\n   AND (bankadj_bankaccnt_id=<? value("bankaccntid") ?>) )\nORDER BY jrnldate, jrnlnum, sortdate;\n<? endif ?>\n      admin   2012-03-01      0
226 133     gltransactions  detail   Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.       -- Group: gltransactions\n-- Name:  detail\n-- Notes: \n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_accnt_id,gltrans_date,gltrans_source,\n       gltrans_doctype,gltrans_journalnumber,gltrans_posted,gltrans_username,\n       CASE WHEN(gltrans_docnumber='Misc.' AND\n              invhist_docnumber IS NOT NULL) THEN\n              (gltrans_docnumber || ' - ' || invhist_docnumber)\n            ELSE gltrans_docnumber\n       END AS docnumber,\n       firstLine(gltrans_notes) AS notes,\n       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n       CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n            ELSE NULL\n       END AS debit,\n       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n            ELSE NULL\n       END AS credit,\n       CASE WHEN accnt_type IN ('A','E') THEN \n         gltrans_amount * -1 \n       ELSE gltrans_amount END AS running,\n       'curr' AS debit_xtnumericrole,\n       'curr' AS credit_xtnumericrole,\n       'curr' AS running_xtnumericrole,\n       0 AS running_xtrunningrole,\n       gltrans_deleted AS xtdeletedrole,\n<? value("beginningBalance") ?> AS running_xtrunninginit \nFROM gltrans JOIN accnt ON (gltrans_accnt_id=accnt_id) \n     LEFT OUTER JOIN invhist ON (gltrans_misc_id=invhist_id\n                            AND gltrans_docnumber='Misc.') \n<? if exists("company_id") ?>\n     JOIN company ON (accnt_company=company_number) \n<? endif ?>\n<? if exists("prfcntr_id") ?>\n     JOIN prftcntr ON (accnt_profit=prftcntr_number) \n<? endif ?>\n<? if exists("subaccnt_id") ?>\n     JOIN subaccnt ON (accnt_sub=subaccnt_number) \n<? endif ?>\n<? if exists("subType") ?>\n     JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n<? endif ?>\nWHERE (\n<? if exists("startDate") ?>\n  <? if exists("endDate") ?>\n       (gltrans_date BETWEEN <? value("startDate") ?>\n                         AND <? value("endDate") ?>)\n  <? else ?>\n       (gltrans_date BETWEEN <? value("startDate") ?>\n                         AND endoftime())\n  <? endif ?>\n<? else ?>\n  <? if exists("endDate") ?>\n       (gltrans_date BETWEEN startoftime()\n                         AND <? value("endDate") ?>)\n  <? else ?>\n       (gltrans_date BETWEEN startoftime()\n                         AND endoftime())\n  <? endif ?>\n<? endif ?>\n<? if not exists("showDeleted") ?>\n   AND (NOT gltrans_deleted)\n<? endif ?>\n<? if exists("company_id") ?>\n   AND (company_id=<? value("company_id") ?>)\n<? endif ?>\n<? if exists("prfcntr_id") ?>\n   AND (prftcntr_id=<? value("prfcntr_id") ?>)\n<? endif ?>\n<? if exists("accnt_number") ?>\n   AND (accnt_number=<? value("accnt_number") ?>)\n<? endif ?>\n<? if exists("subaccnt_id") ?>\n   AND (subaccnt_id=<? value("subaccnt_id") ?>)\n<? endif ?>\n<? if exists("subType") ?>\n   AND (subaccnttype_id=<? value("subType") ?>)\n<? endif ?>\n<? if exists("accntType") ?>\n   AND (accnt_type= <? value("accntType") ?>)\n<? endif ?>\n<? if exists("accnt_id") ?>\n   AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("docnum") ?>\n   AND (gltrans_docnumber = case when <? value("docnum") ?> = '' then \n gltrans_docnumber else \n<? value("docnum") ?> end ) \n<? endif ?>\n<? if exists("source") ?>\n   AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n) \nORDER BY\n<? if exists("beginningBalance") ?>\n   gltrans_date,\n<? else ?>\n   gltrans_created DESC,\n<? endif ?>\n   gltrans_sequence, gltrans_amount;\n        admin   2012-04-26      0
227 268     pendingAvailability     detail  used by dspPendingAvailability Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: pendingAvailability\n-- Name: detail\n-- Notes: used by dspPendingAvailability\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("showIndented") ?>\n\n-- Indented BOM\nSELECT itemsite_id, reorderlevel,\n       bomdata_bomwork_level,\n       bomdata_bomwork_id,\n       bomdata_bomwork_parent_id,\n       bomdata_bomwork_seqnumber AS bomitem_seqnumber,\n       bomdata_item_number AS item_number,\n       bomdata_itemdescription AS item_descrip,\n       bomdata_uom_name AS uom_name,\n       pendalloc,\n       ordered,\n       qoh,\n       (totalalloc + pendalloc) AS totalalloc,\n       (qoh + ordered - (totalalloc + pendalloc)) AS totalavail,\n       'qty' AS pendalloc_xtnumericrole,\n       'qty' AS ordered_xtnumericrole,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS totalalloc_xtnumericrole,\n       'qty' AS totalavail_xtnumericrole,\n       CASE WHEN (qoh < pendalloc) THEN 'error' END AS qoh_qtforegroundrole,\n       CASE WHEN ((qoh + ordered - (totalalloc + pendalloc)) < reorderlevel)  THEN 'error'\n            WHEN ((qoh + ordered - (totalalloc + pendalloc)) = reorderlevel) THEN 'warning'\n       END AS totalavail_qtforegroundrole,\n       bomdata_bomwork_level - 1 AS xtindentrole\n  FROM ( SELECT itemsite_id,\n                CASE WHEN(itemsite_useparams)\n                     THEN itemsite_reorderlevel\n                     ELSE 0.0\n                     END AS reorderlevel,\n                ib.*,\n                ((bomdata_qtyreq::NUMERIC * <? value("buildQty") ?>) * (1 + bomdata_scrap::NUMERIC)) AS pendalloc,\n                qtyAllocated(itemsite_id, DATE(<? value("buildDate") ?>)) AS totalalloc,\n                noNeg(itemsite_qtyonhand) AS qoh,\n                qtyOrdered(itemsite_id, DATE(<? value("buildDate") ?>)) AS ordered\n           FROM indentedBOM(<? value("item_id") ?>,\n                            getActiveRevId('BOM', <? value("item_id") ?>),\n                            0,0) ib LEFT OUTER JOIN\n                itemsite ON ((itemsite_item_id=bomdata_item_id)\n                         AND (itemsite_warehous_id=<? value("warehous_id") ?>))\n          WHERE (bomdata_item_id > 0)\n       <? if not exists("effective") ?>\n           AND (CURRENT_DATE BETWEEN bomdata_effective AND (bomdata_expires-1))\n       <? else ?>\n           AND (<? value("effective") ?> BETWEEN bomdata_effective AND (bomdata_expires-1))\n       <? endif ?>\n       ) AS data\n<? if exists("showShortages") ?>\n  WHERE ((qoh + ordered - (totalalloc + pendalloc)) < 0)\n<? endif ?>   \nORDER BY bomworkSequence(bomdata_bomwork_id);\n\n<? else ?>\n\n-- Single Level BOM\nSELECT itemsite_id, bomitem_seqnumber, item_number, item_descrip, uom_name,\n       pendalloc, (totalalloc + pendalloc) AS totalalloc,\n       qoh, (qoh + ordered - (totalalloc + pendalloc)) AS totalavail,\n       reorderlevel,\n       'qty' AS pendalloc_xtnumericrole,\n       'qty' AS totalalloc_xtnumericrole,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS totalavail_xtnumericrole,\n       CASE WHEN (qoh < pendalloc) THEN 'error' END AS qoh_qtforegroundrole,\n       CASE WHEN ((qoh + ordered - (totalalloc + pendalloc)) < reorderlevel) THEN 'error'\n            WHEN ((qoh + ordered - (totalalloc + pendalloc)) = reorderlevel) THEN 'warning'\n       END AS totalavail_qtforegroundrole\nFROM ( SELECT itemsite_id, bomitem_seqnumber, item_number,\n              (item_descrip1 || ' ' || item_descrip2) AS item_descrip, uom_name,\n              ((itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n                            (bomitem_qtyfxd + bomitem_qtyper * <? value("buildQty") ?>) * (1 + bomitem_scrap)))) AS pendalloc,\n              qtyAllocated(itemsite_id, DATE(<? value("buildDate") ?>)) AS totalalloc,\n              noNeg(itemsite_qtyonhand) AS qoh,\n              qtyOrdered(itemsite_id, DATE(<? value("buildDate") ?>)) AS ordered,\n              CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel\n       FROM itemsite, item, bomitem(<? value("item_id") ?>), uom\n       WHERE ( (bomitem_item_id=itemsite_item_id)\n           AND (itemsite_item_id=item_id)\n           AND (item_inv_uom_id=uom_id)\n           AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n       <? if not exists("effective") ?>\n           AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1))\n       <? else ?>\n           AND (<? value("effective") ?> BETWEEN bomitem_effective AND (bomitem_expires-1))\n       <? endif ?>\n             )\n     ) AS data\n<? if exists("showShortages") ?>\n  WHERE ((qoh + ordered - (totalalloc + pendalloc)) < 0)\n<? endif ?>   \nORDER BY bomitem_seqnumber;\n\n<? endif ?>   \n  admin   2012-04-26      0
228 279     qoh     detail   Quanity on Hand By Location Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.   -- Group: qoh\n-- Name: detail\n-- Notes: \n--  Quanity on Hand By Location\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n<? if exists("byLocation") ?>\nSELECT itemloc_id, warehous_code, item_number,\n       f_descrip, f_lotserial, uom_name,\n       qoh, reservedqty,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS reservedqty_xtnumericrole,\n       level AS xtindentrole\nFROM (\n      SELECT itemloc_id, 0 AS level, item_number AS sortkey, warehous_code, item_number,\n             (item_descrip1 || ' ' || item_descrip2) AS f_descrip,\n             formatlotserialnumber(itemloc_ls_id) AS f_lotserial, uom_name,\n             itemloc_qty AS qoh,\n  <? if exists("EnableSOReservationsByLocation") ?>\n             qtyReservedLocation(itemloc_id) AS reservedqty\n  <? else ?>\n             0 AS reservedqty\n  <? endif ?>\n      FROM itemloc, itemsite, warehous, item, uom\n      WHERE ((itemloc_itemsite_id=itemsite_id)\n         AND (itemsite_item_id=item_id)\n         AND (item_inv_uom_id=uom_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemloc_location_id=<? value("location_id") ?>))\n      UNION\n      SELECT -1 AS itemloc_id, 0 AS level, item_number AS sortkey, warehous_code, item_number,\n             (item_descrip1 || ' ' || item_descrip2) AS f_descrip,\n             <? value("na") ?> AS f_lotserial, uom_name,\n             itemsite_qtyonhand AS qoh,\n             0 AS reservedqty\n      FROM itemsite, warehous, item, uom\n      WHERE ((itemsite_item_id=item_id)\n         AND (item_inv_uom_id=uom_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (NOT itemsite_loccntrl)\n         AND (itemsite_location_id=<? value("location_id") ?>))\n  <? if exists("EnableSOReservationsByLocation") ?>\n      UNION\n      SELECT itemloc_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n             (itemlocrsrv_source || '-' || formatSOItemNumber(itemlocrsrv_source_id)) AS f_descrip,\n             '' AS f_lotserial, '' AS uom_name,\n             NULL AS qoh,\n             itemlocrsrv_qty AS reservedqty\n      FROM itemlocrsrv, itemloc, itemsite, item\n      WHERE ((itemlocrsrv_itemloc_id=itemloc_id)\n         AND (itemsite_id=itemloc_itemsite_id)\n         AND(item_id=itemsite_item_id)\n         AND(itemloc_location_id=<? value("location_id") ?>))\n  <? endif ?>\n     ) AS data\nORDER BY\n         sortkey, itemloc_id, level;\n<? else ?>\n<? if exists("asOf") ?>\nSELECT forwardupdateinvbalance(invbal_id)\nFROM (\n      SELECT DISTINCT ON (itemsite_id) invbal_id\n      FROM invbal, itemsite, item, warehous, classcode, uom, costcat, period\n      WHERE ((invbal_dirty)\n         AND (invbal_period_id=period_id)\n         AND (itemsite_item_id=item_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemsite_active)\n         AND (item_inv_uom_id=uom_id)\n         AND (item_classcode_id=classcode_id)\n         AND (itemsite_costcat_id=costcat_id)\n  <? if exists("item_id") ?>\n         AND (itemsite_item_id=<? value("item_id") ?>)\n  <? endif ?>\n  <? if exists("classcode_id") ?>\n         AND (classcode_id=<? value("classcode_id") ?>)\n  <? endif ?>\n  <? if exists("classcode_pattern") ?>\n         AND (classcode_id IN (SELECT classcode_id\n                               FROM classcode\n                               WHERE classcode_code ~ <? value("classcode_pattern") ?>))\n  <? endif ?>\n  <? if exists("costcat_id") ?>\n         AND (costcat_id=<? value("costcat_id") ?>)\n  <? endif ?>\n  <? if exists("costcat_pattern") ?>\n         AND (costcat_id IN (SELECT costcat_id\n                               FROM costcat\n                               WHERE costcat_code ~ <? value("costcat_pattern") ?>))\n  <? endif ?>\n  <? if exists("itemgrp_id") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id\n                          FROM itemgrpitem\n                          WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n  <? endif ?>\n  <? if exists("itemgrp_pattern") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id\n                          FROM itemgrpitem, itemgrp\n                          WHERE ((itemgrpitem_itemgrp_id=itemgrp_id)\n                             AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>))))\n  <? endif ?>\n  <? if exists("showPositive") ?>\n       AND (itemsite_qtyonhand > 0)\n  <? elseif exists("showNegative") ?>\n       AND (itemsite_qtyonhand < 0)\n  <? endif ?>\n  <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n            )\n       ORDER BY itemsite_id, period_start\n     ) AS data\n;\n<? endif ?>\n--  Quantity on Hand\nSELECT itemsite_id, detail,warehous_code,\n       classcode_code, item_number, uom_name,\n       costcat_code,\n       item_descrip1, item_descrip2,\n       (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n       defaultlocation,\n       reorderlevel, formatQty(reorderlevel) AS f_reorderlevel,\n       qoh, formatQty(qoh) AS f_qoh,\n       nnqoh, formatQty(nnqoh) AS f_nnqoh,\n       CASE WHEN (itemsite_loccntrl) THEN nnqoh END AS f_nnqoh,\n       cost, (cost * qoh) AS value,\n       CASE WHEN (itemsite_loccntrl) THEN (cost * nnqoh) END AS nnvalue,\n       CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n            WHEN(itemsite_costmethod='S') THEN 'Standard'\n            WHEN(itemsite_costmethod='J') THEN 'Job'\n            WHEN(itemsite_costmethod='N') THEN 'None'\n         ELSE 'UNKNOWN'\n       END AS costmethod,\n  <? if exists("showValue") ?>\n       formatMoney(cost) AS f_cost, (cost * qoh) AS f_value,\n       CASE WHEN (itemsite_loccntrl) THEN (cost * nnqoh) END AS f_nnvalue,\n       CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n            WHEN(itemsite_costmethod='S') THEN 'Standard'\n            WHEN(itemsite_costmethod='J') THEN 'Job'\n            WHEN(itemsite_costmethod='N') THEN 'None'\n         ELSE 'UNKNOWN'\n       END AS f_costmethod,\n  <? endif ?>\n       'qty' AS reorderlevel_xtnumericrole,\n       'qty' AS qoh_xtnumericrole,\n       'qty' AS f_nnqoh_xtnumericrole,\n       0 AS qoh_xttotalrole,\n       0 AS nnqoh_xttotalrole,\n       'cost' AS cost_xtnumericrole,\n       'curr' AS value_xtnumericrole,\n       'curr' AS nnvalue_xtnumericrole,\n       0 AS value_xttotalrole,\n       0 AS nnvalue_xttotalrole,\n       <? value("na") ?> AS nnqoh_xtnullrole,\n       <? value("na") ?> AS nnvalue_xtnullrole,\n       CASE WHEN (qoh < 0) THEN 'error' END AS qoh_qtforegroundrole,\n       CASE WHEN (reorderlevel > qoh) THEN 'warning' END AS qoh_qtforegroundrole\nFROM (\n      SELECT itemsite_id, itemsite_loccntrl, itemsite_costmethod,\n             ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) ) AS detail,\n             classcode_code, item_number, uom_name, item_descrip1, item_descrip2,\n             costcat_code, \n             CASE WHEN (NOT useDefaultLocation(itemsite_id)) THEN <? value("none") ?>\n               ELSE defaultLocationName(itemsite_id)\n             END AS defaultlocation,\n             warehous_code,\n             CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel,\n  <? if exists("asOf") ?>\n             COALESCE(invbal_qoh_ending,0) AS qoh,\n             COALESCE(invbal_nn_ending,0) AS nnqoh,\n  <? else ?>\n             itemsite_qtyonhand AS qoh,\n             itemsite_nnqoh AS nnqoh,\n  <? endif ?>\n  <? if exists("useStandardCosts") ?>\n             stdcost(item_id) AS cost\n  <? elseif exists("useActualCosts") ?>\n             actcost(item_id) AS cost\n  <? else ?>\n    <? if exists("asOf") ?>\n             COALESCE((invbal_value_ending / CASE WHEN(invbal_qoh_ending=0) THEN 1\n                                                  ELSE invbal_qoh_ending END),0) AS cost\n    <? else ?>\n             (itemsite_value / CASE WHEN((itemsite_qtyonhand + itemsite_nnqoh)=0) THEN 1\n                                    ELSE (itemsite_qtyonhand + itemsite_nnqoh) END) AS cost\n    <? endif ?>\n  <? endif ?>\n      FROM item, warehous, classcode, uom, costcat, itemsite\n  <? if exists("asOf") ?>\n        LEFT OUTER JOIN invbal ON ((itemsite_id=invbal_itemsite_id)\n                               AND (invbal_period_id=<? value("asOf") ?>))\n  <? endif ?>\n      WHERE ((itemsite_item_id=item_id)\n         AND (itemsite_warehous_id=warehous_id)\n         AND (itemsite_active)\n         AND (item_inv_uom_id=uom_id)\n         AND (item_classcode_id=classcode_id)\n         AND (itemsite_costcat_id=costcat_id)\n  <? if exists("item_id") ?>\n         AND (itemsite_item_id=<? value("item_id") ?>)\n  <? endif ?>\n  <? if exists("classcode_id") ?>\n         AND (classcode_id=<? value("classcode_id") ?>)\n  <? endif ?>\n  <? if exists("classcode_pattern") ?>\n         AND (classcode_id IN (SELECT classcode_id\n                               FROM classcode\n                               WHERE classcode_code ~ <? value("classcode_pattern") ?>))\n  <? endif ?>\n  <? if exists("costcat_id") ?>\n         AND (costcat_id=<? value("costcat_id") ?>)\n  <? endif ?>\n  <? if exists("costcat_pattern") ?>\n         AND (costcat_id IN (SELECT costcat_id\n                               FROM costcat\n                               WHERE costcat_code ~ <? value("costcat_pattern") ?>))\n  <? endif ?>\n  <? if exists("itemgrp_id") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id\n                          FROM itemgrpitem\n                          WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n  <? endif ?>\n  <? if exists("itemgrp_pattern") ?>\n         AND (item_id IN (SELECT itemgrpitem_item_id\n                          FROM itemgrpitem, itemgrp\n                          WHERE ((itemgrpitem_itemgrp_id=itemgrp_id)\n                             AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>))))\n  <? endif ?>\n  <? if exists("showPositive") ?>\n    <? if exists("asOf") ?>\n       AND (COALESCE(invbal_qoh_ending,0) > 0)\n    <? else ?>\n       AND (itemsite_qtyonhand > 0)\n    <? endif ?>\n  <? elseif exists("showNegative") ?>\n    <? if exists("asOf") ?>\n       AND (COALESCE(invbal_qoh_ending,0) < 0)\n    <? else ?>\n       AND (itemsite_qtyonhand < 0)\n    <? endif ?>\n  <? endif ?>\n  <? if exists("warehous_id") ?>\n         AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n  <? endif ?>\n            )\n     ) AS data\nORDER BY warehous_code, item_number;\n<? endif ?>\n      admin   2012-04-26      0
229 303     vendorAPHistory detail  used by dspVendorAPHistory Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license.     -- Group: vendorAPHistory\n-- Name: detail\n-- Notes: used by dspVendorAPHistory\n-- Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apopen_id, -1 AS applyid, 0 AS type,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apopen_docnumber AS docnumber,\n       formatBoolYN(apopen_open) AS f_open,\n       CASE WHEN (apopen_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apopen_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (apopen_doctype='D') THEN <? value("debitMemo") ?>\n         ELSE <? value("other") ?>\n       END AS documenttype,\n       apopen_invcnumber AS invoicenumber,\n       apopen_ponumber AS ponumber,\n       apopen_docdate AS docdate, apopen_duedate AS duedate, apopen_amount AS amount,\n       (apopen_amount - apopen_paid) AS balance,\n       currconcat(apopen_curr_id) AS currAbbr,\n       CASE WHEN (apopen_doctype='C') THEN apopen_amount / apopen_curr_rate * -1.0\n         ELSE apopen_amount / apopen_curr_rate\n       END AS base_amount,\n       0 AS base_applied,\n       CASE WHEN (apopen_doctype='C') THEN (apopen_amount - apopen_paid) / apopen_curr_rate * -1.0\n         ELSE (apopen_amount - apopen_paid) / apopen_curr_rate\n       END AS base_balance,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       0 AS xtindentrole \nFROM apopen \nWHERE ( (apopen_vend_id=<? value("vend_id") ?>) \n    AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) ) \n\nUNION \nSELECT apopen_id, apapply_source_apopen_id AS applyid, 1 AS type,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apapply_source_docnumber AS docnumber,\n       '' AS f_open,\n       CASE WHEN (apapply_source_doctype='C') THEN <? value("creditMemo") ?>\n            WHEN (apapply_source_doctype='K') THEN <? value("check") ?>\n         ELSE <? value("other") ?>\n       END AS documenttype,\n       ' ' AS invoicenumber,\n       '' AS ponumber,\n       apapply_postdate AS docdate, CAST(NULL AS DATE) AS duedate,\n       apapply_amount AS amount,\n       0 AS balance,\n       currconcat(apapply_curr_id) AS currAbbr,\n       0 AS base_amount,\n       (apapply_amount / apopen_curr_rate) AS base_applied, \n       0 AS base_balance,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       1 AS xtindentrole \nFROM apapply, apopen \nWHERE ( (apapply_target_apopen_id=apopen_id)\n    AND (apapply_vend_id=<? value("vend_id") ?>)\n    AND (apopen_vend_id=<? value("vend_id") ?>)\n    AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) ) \n\nUNION \nSELECT apopen_id, apapply_target_apopen_id AS applyid, 2 AS type,\n       apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n       apapply_target_docnumber AS docnumber,\n       '' AS f_open,\n       CASE WHEN (apapply_target_doctype='V') THEN <? value("voucher") ?>\n            WHEN (apapply_target_doctype='D') THEN <? value("debitMemo") ?>\n         ELSE <? value("other") ?>\n       END AS documenttype,\n       apopen_invcnumber AS invoicenumber,\n       '' AS ponumber,\n       apapply_postdate AS docdate, CAST(NULL AS DATE) AS duedate,\n       apapply_amount AS amount,\n       0 AS balance,\n       currconcat(apapply_curr_id) AS currAbbr,\n       0 AS base_amount,\n       (apapply_amount / apopen_curr_rate) AS base_applied, \n       0 AS base_balance,\n       'curr' AS amount_xtnumericrole,\n       'curr' AS base_amount_xtnumericrole,\n       0 AS base_amount_xttotalrole,\n       'curr' AS base_applied_xtnumericrole,\n       0 AS base_applied_xttotalrole,\n       'curr' AS balance_xtnumericrole,\n       'curr' AS base_balance_xtnumericrole,\n       0 AS base_balance_xttotalrole,\n       1 AS xtindentrole \nFROM apapply, apopen \nWHERE ( (apapply_source_doctype IN ('C', 'K'))\n    AND (apapply_source_doctype=apopen_doctype)\n    AND (apapply_source_docnumber=apopen_docnumber)\n    AND (apapply_vend_id=<? value("vend_id") ?>)\n    AND (apopen_vend_id=<? value("vend_id") ?>)\n    AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) ) \nORDER BY sortdate, apopen_id, type;\n       admin   2012-07-09      0
230 \.
231
232
233 ALTER TABLE metasql ENABLE TRIGGER ALL;
234
235 --
236 -- Name: metasql_metasql_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin
237 --
238
239 SELECT pg_catalog.setval('metasql_metasql_id_seq', 455, true);
240
241
242 --
243 -- PostgreSQL database dump complete
244 --
245