-- Group: selectPayments
-- Name: discountitems
-- Notes: used by selectPayments
-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
-- See www.xtuple.com/CPAL for the full text of the software license.

SELECT selectDiscountItemsForPayment(vend_id, <? value("bankaccnt_id") ?>) AS result
FROM vendinfo
<? if exists("vend_id") ?>
WHERE (vend_id=<? value("vend_id") ?>)
<? elseif exists("vendtype_id") ?>
WHERE (vend_vendtype_id=<? value("vendtype_id") ?>)
<? elseif exists("vendtype_pattern") ?>
WHERE (vend_vendtype_id IN (SELECT vendtype_id
                            FROM vendtype
                            WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))
<? endif ?>
;
