mht_brerp10
.adempiere
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
get1099bucket(numeric, timestamp with time zone, numeric)
Parameters
Name
Type
Mode
p_cbpartner_id
numeric
IN
p_cut_date
timestamp with time zone
IN
p_bucket
numeric
IN
Definition
DECLARE tmpvar numeric; /****************************************************************************** NAME: get1099bucket PURPOSE: REVISIONS: Ver Date Author Description --------- ---------- --------------- ------------------------------------ 1.0 04/01/2008 Carlos Ruiz 1. Created this function. ******************************************************************************/ BEGIN SELECT SUM ( (COALESCE (linenetamt, 0) + COALESCE (taxamt, 0)) * (CASE WHEN docbasetype = 'API' THEN 1 WHEN docbasetype = 'APC' THEN -1 ELSE 0 END) ) -- +API->AP Invoice / -APC->AP Credit Memo INTO tmpvar FROM C_INVOICE i, C_INVOICELINE il, C_1099BOX b, C_DOCTYPE dt WHERE i.c_invoice_id = il.c_invoice_id AND i.issotrx = 'N' AND il.c_1099box_id = b.c_1099box_id AND i.dateacct BETWEEN TRUNC (p_cut_date, 'YEAR') AND p_cut_date AND c_bpartner_id = p_cbpartner_id AND b.bucket = p_bucket AND i.c_doctype_id = dt.c_doctype_id AND i.docstatus IN ('CO', 'CL'); RETURN tmpvar; END;