DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGI_CIS2007_IGIPPADR_PKG

Source


1 package body IGI_CIS2007_IGIPPADR_PKG AS
2 -- $Header: IGIPPADB.pls 120.2 2008/01/28 15:07:27 rsaini noship $
3       function BeforeReport return boolean is
4       begin
5         if UPPER(P_TOTAL_TYPE) = 'T' then
6           p_select_clause := ' , (lines.total_payments + lines.total_deductions) GROSS_AMOUNT_PAID,' ||
7                              ' lines.MATERIAL_COST MATERIAL_COST,' ||
8                              ' lines.LABOUR_COST LABOUR_COST, ' ||
9                              ' lines.TOTAL_DEDUCTIONS AMOUNT_DEDUCTED, ' ||
10 			     ' null INVOICE_NUM ' ;
11           p_from_clause := ', HR_LOCATIONS_V hrl';
12 
13           if UPPER(P_ZERO_DEDUCTIONS) = 'Y' Then
14 	     p_where_clause := ' and hrl.location_id = aprea.LOCATION_ID '||
15 	  	               ' and UPPER(hdr.period_name) ='''||UPPER(P_PERIOD)||'''';
16 	  else
17 	     p_where_clause := ' and hrl.location_id = aprea.LOCATION_ID '||
18 	  	               ' and UPPER(hdr.period_name) ='''||UPPER(P_PERIOD)||'''' ||
19 	  	               ' and nvl(lines.total_deductions,0) > 0' ;
20 	  end if;
21 
22           if (P_SUPPLIER_FROM IS NOT NULL) then
23             p_where_clause := p_where_clause || ' and LINES.vendor_name >= ' || '''' ||
24                               P_SUPPLIER_FROM || '''';
25           end if;
26           if (P_SUPPLIER_TO IS NOT NULL) then
27             p_where_clause := p_where_clause || ' and LINES.vendor_name <= ' || '''' ||
28                               P_SUPPLIER_TO || '''';
29           end if;
30 
31           p_where_clause := p_where_clause || ' order by lines.vendor_name ';
32 
33 
34         elsif UPPER(P_TOTAL_TYPE) = 'P' then
35           p_select_clause := ', (payment.amount + payment.total_deductions) GROSS_AMOUNT_PAID,' ||
36                              ' payment.MATERIAL_COST MATERIAL_COST,' ||
37                              ' payment.LABOUR_COST LABOUR_COST, ' ||
38                              ' payment.TOTAL_DEDUCTIONS AMOUNT_DEDUCTED, ' ||
39 			     ' invoice.INVOICE_NUM INVOICE_NUM ' ;
40           p_from_clause  := ', HR_LOCATIONS_V hrl, igi_cis_mth_ret_pay_h payment, AP_INVOICES invoice';
41           p_where_clause := ' and hrl.location_id = aprea.LOCATION_ID '||
42                             ' and UPPER(hdr.period_name) ='''||UPPER(P_PERIOD)||'''' ||' and payment.INVOICE_ID = invoice.INVOICE_ID ' ;
43           if UPPER(P_ZERO_DEDUCTIONS) = 'Y' Then
44              p_where_clause := p_where_clause ||' and lines.HEADER_ID = payment.header_id
45                                                and lines.vendor_id = payment.VENDOR_ID ';
46           else
47             p_where_clause := p_where_clause ||' and lines.HEADER_ID = payment.header_id and lines.vendor_id = payment.VENDOR_ID ' ||
48                             		       ' and nvl(payment.total_deductions,0) > 0' ;
49           end if;
50 
51           p_where_clause := p_where_clause ||' and lines.HEADER_ID = payment.header_id
52                                                and lines.vendor_id = payment.VENDOR_ID ';
53           if (P_SUPPLIER_FROM IS NOT NULL) then
54             p_where_clause := p_where_clause || ' and LINES.vendor_name >= ' || '''' ||
55                               P_SUPPLIER_FROM || '''';
56           end if;
57           if (P_SUPPLIER_TO IS NOT NULL) then
58             p_where_clause := p_where_clause || ' and LINES.vendor_name <= ' || '''' ||
59                               P_SUPPLIER_TO || '''';
60           end if;
61           p_where_clause := p_where_clause || ' order by lines.vendor_name ';
62 
63 
64         end if;
65         return(TRUE);
66       end BeforeReport;
67       -------------------------------------------------------------------------------------
68       function get_PRINT_TYPE return varchar2 is
69         l_print_type IGI_LOOKUPS.MEANING% TYPE := null;
70       begin
71         select meaning
72           into l_print_type
73           from IGI_LOOKUPS
74          where LOOKUP_TYPE = 'IGI_CIS2007_PRINT_TYPES'
75            and LOOKUP_CODE = P_PRINT_TYPE;
76             return(l_print_type);
77       exception
78         WHEN no_data_found THEN
79           return(l_print_type);
80       end get_PRINT_TYPE;
81       --------------------------------------------------------------------------------
82       function get_ORG_NAME return varchar2 is
83         l_org_id   HR_OPERATING_UNITS.organization_id%TYPE := null;
84         l_org_name HR_OPERATING_UNITS.name%TYPE := null;
85       begin
86         l_org_id := MO_GLOBAL.get_current_org_id;
87         select name
88           into l_org_name
89           from hr_operating_units
90          where organization_id = l_org_id;
91         return(l_org_name);
92       exception
93         WHEN no_data_found THEN
94           return(l_org_name);
95       end get_ORG_NAME;
96       -------------------------------------------------------------------------------
97       function get_PERIOD_END_DATE return varchar2 is
98         l_period_type AP_OTHER_PERIODS.Period_Type%TYPE;
99         l_end_date    AP_OTHER_PERIODS.Start_Date%TYPE;
100       begin
101         l_period_type := fnd_profile.value('IGI_CIS2007_CALENDAR');
102         select end_date
103           into l_end_date
104           from AP_OTHER_PERIODS
105          where period_type = l_period_type
106            and period_name = P_PERIOD;
107         return(l_end_date);
108       exception
109         WHEN no_data_found THEN
110           return(l_end_date);
111       end get_PERIOD_END_DATE;
112 end IGI_CIS2007_IGIPPADR_PKG;