DBA Data[Home] [Help]

PACKAGE BODY: APPS.GL_TAX_OPTION_ACCOUNTS_PKG

Source


1 PACKAGE BODY gl_tax_option_accounts_pkg AS
2 /* $Header: glisttab.pls 120.6 2005/05/05 01:27:36 kvora ship $ */
3 
4   ---
5   --- PRIVATE VARIABLES
6   ---
7 
8   --- Position of the account segment
9   acct_seg_num		NUMBER := null;
10 
11 
12   ---
13   --- PRIVATE FUNCTIONS
14   ---
15 
16   --
17   -- Procedure
18   --   select_row
19   -- Purpose
20   --   Gets the row from gl_tax_option_accounts associated with
21   --   the given account, ledger id, and organization.
22   -- History
23   --   05-DEC-96  D J Ogg  Created.
24   -- Arguments
25   --   recinfo 		A row from gl_tax_options
26   -- Example
27   --   gl_tax_option_accounts_pkg.select_row(recinfo);
28   -- Notes
29   --
30   PROCEDURE select_row( recinfo IN OUT NOCOPY gl_tax_option_accounts%ROWTYPE )  IS
31   BEGIN
32     SELECT  *
33     INTO    recinfo
34     FROM    gl_tax_option_accounts
35     WHERE   account_segment_value = recinfo.account_segment_value
36     AND     ledger_id = recinfo.ledger_id
37     AND     org_id = recinfo.org_id;
38   EXCEPTION
39     WHEN app_exceptions.application_exception THEN
40       RAISE;
41     WHEN OTHERS THEN
42       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
43       fnd_message.set_token('PROCEDURE',
44                             'gl_tax_option_accounts_pkg.select_row');
45       RAISE;
46   END select_row;
47 
48 
49   --
50   -- FUNCTION
51   --   check_line
52   -- Purpose
53   --   Check if a give account wiht a given ledger is and organization,
54   --   has the given tax type.
55   -- History
56   --   22-Nov-96 	W Wong 	Created
57   -- Arguments
58   --   x_ledger_id	Ledger ID
59   --   x_org_id		Organization ID
60   --   x_account	Account Segment Value
61   --   x_tax_type	Tax Type to be checked
62   --   x_rowid		Row ID
63   --
64   -- Example
65   --   gl_tax_option_accounts_pkg.check_line(ledger_id, org_id, account, tax_type);
66   -- Notes
67   --
68 
69   FUNCTION check_line(  x_ledger_id		NUMBER,
70 			x_org_id		NUMBER,
71 			x_account 		VARCHAR2,
72 			x_tax_type 		VARCHAR2,
73 			x_rowid			VARCHAR2 ) RETURN NUMBER IS
74 
75   x_total NUMBER;
76 
77   BEGIN
78     -- Need to check if account has another input line
79     SELECT count(*)
80     INTO x_total
81     FROM gl_tax_option_accounts
82     WHERE ledger_id = x_ledger_id
83     AND   org_id = x_org_id
84     AND   account_segment_value = x_account
85     AND   tax_type_code = x_tax_type
86     AND ( x_rowid is null OR rowid <> x_rowid );
87 
88     return (x_total);
89 
90   END check_line;
91 
92 
93   --
94   -- PUBLIC FUNCTIONS
95   --
96 
97   PROCEDURE select_columns(
98 	      x_ledger_id				NUMBER,
99 	      x_org_id					NUMBER,
100 	      x_account_value				VARCHAR2,
101 	      x_tax_type_code			IN OUT NOCOPY	VARCHAR2,
102 	      x_tax_code			IN OUT NOCOPY 	VARCHAR2,
103 	      x_allow_override			IN OUT NOCOPY	VARCHAR2,
104  	      x_amount_includes_tax		IN OUT NOCOPY	VARCHAR2) IS
105 
106     recinfo gl_tax_option_accounts%ROWTYPE;
107 
108   BEGIN
109     recinfo.ledger_id := x_ledger_id;
110     recinfo.org_id := x_org_id;
111     recinfo.account_segment_value := x_account_value;
112     select_row( recinfo );
113     x_tax_type_code := recinfo.tax_type_code;
114     x_allow_override := recinfo.allow_tax_code_override_flag;
115     x_amount_includes_tax := recinfo.amount_includes_tax_flag;
116     x_tax_code := recinfo.tax_code;
117 
118   EXCEPTION
119     WHEN app_exceptions.application_exception THEN
120       RAISE;
121     WHEN OTHERS THEN
122       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
123       fnd_message.set_token('PROCEDURE',
124                             'gl_tax_option_accounts_pkg.select_columns');
125       RAISE;
126   END select_columns;
127 
128 
129   PROCEDURE check_tax_type(
130 		x_ledger_id				NUMBER,
131 		x_org_id				NUMBER,
132 		x_account_segment_value			VARCHAR2,
133 		x_tax_type_code				VARCHAR2,
134 		x_rowid					VARCHAR2) IS
135 
136   non_tax_lines		NUMBER;
137   duplicate_lines       NUMBER;
138   in_lines 		NUMBER;
139   out_lines		NUMBER;
140 
141   BEGIN
142     non_tax_lines := 0; duplicate_lines := 0; in_lines := 0; out_lines := 0;
143 
144     -- Need to check if account has a duplicate line
145     duplicate_lines := check_line(x_ledger_id, x_org_id,
146 	  	                  x_account_segment_value, x_tax_type_code,
147 				  x_rowid );
148 
149     IF (duplicate_lines <> 0) THEN
150       -- Account has a duplicate line
151       fnd_message.set_name('SQLGL', 'GL_STAX_DUPLICATE_TAX_TYPE');
152       app_exception.raise_exception;
153     END IF;
154 
155 
156     IF (x_tax_type_code IN ('I', 'O')) THEN
157 
158       -- Check if the given account has a non-taxable line
159       non_tax_lines := check_line(x_ledger_id, x_org_id, x_account_segment_value,
160 			 	  'N', x_rowid);
161 
162       IF (non_tax_lines <> 0) THEN
163         -- Account has non-taxable line.  Cannot define any input/output line.
164           fnd_message.set_name('SQLGL',  'GL_STAX_NO_INPUT_OUTPUT');
165           app_exception.raise_exception;
166 
167       END IF;
168 
169     ELSE
170       -- Tax type code is non_taxable
171       -- Need to check if there is another input/output line
172       in_lines := check_line(x_ledger_id, x_org_id, x_account_segment_value, 'I',
173                              x_rowid);
174 
175       IF (in_lines = 0) THEN
176 	-- There is no input line for this account, check output line.
177 	out_lines := check_line(x_ledger_id, x_org_id, x_account_segment_value,
178 		                'O', x_rowid);
179 
180         IF (out_lines <> 0) THEN
181           -- Account has an output line.  Cannot define non-taxable line.
182           fnd_message.set_name('SQLGL', 'GL_STAX_OUTPUT_NO_NON_TAX');
183           app_exception.raise_exception;
184 
185 	END IF;
186 
187       ELSE
188 	-- Account has an input line. Cannot define non-taxable line.
189           fnd_message.set_name('SQLGL', 'GL_STAX_INPUT_NO_NON_TAX');
190           app_exception.raise_exception;
191 
192       END IF;
193 
194     END IF;
195 
196   END check_tax_type;
197 
198 
199   FUNCTION get_acct_description(
200 	      x_coa_id					NUMBER,
201 	      x_account_val				VARCHAR2
202 	   ) RETURN VARCHAR2 IS
203   BEGIN
204     IF (acct_seg_num IS NULL) THEN
205       IF (NOT fnd_flex_apis.get_qualifier_segnum(
206                 appl_id 		=> 101,
207                 key_flex_code		=> 'GL#',
208       	        structure_number	=> x_coa_id,
209 	        flex_qual_name		=> 'GL_ACCOUNT',
210 	        segment_number		=> acct_seg_num)
211           ) THEN
212         app_exception.raise_exception;
213       END IF;
214     END IF;
215 
216     -- Get the description
217     IF (fnd_flex_keyval.validate_segs(
218           operation => 'CHECK_SEGMENTS',
219           appl_short_name => 'SQLGL',
220           key_flex_code => 'GL#',
221           structure_number => x_coa_id,
222           concat_segments => x_account_val,
223           displayable => 'GL_ACCOUNT',
224           allow_nulls => TRUE,
225           allow_orphans => TRUE)) THEN
226       null;
227     END IF;
228 
229     RETURN(fnd_flex_keyval.segment_description(acct_seg_num));
230   END get_acct_description;
231 
232 END gl_tax_option_accounts_pkg;
233