DBA Data[Home] [Help]

PACKAGE BODY: APPS.PYSOYTLS

Source


1 package body pysoytls as
2 /* $Header: pysoytls.pkb 120.0 2005/05/29 08:53:45 appldev noship $
3 
4  Copyright (c) Oracle Corporation 1995. All rights reserved
5 
6  Name          : pysoytls
7  Description   : Start Of Year Tools Functions
8  Author        : Barry Goodsell
9  Date Created  : 15-Aug-95
10 
11  Change List
12  -----------
13  Date        Name            Vers     Bug No   Description
14  +-----------+---------------+--------+--------+-----------------------+
15   15-Aug-95   B.Goodsell      40.0              First Created
16 
17   09-Oct-95   B.Goodsell      40.1              Edits required for
18 						release
19 
20   30-JUL-96   J.Alloun        40.2              Added error handling.
21 
22   01-APR-98   A.Rundell      110.1     649418   Added check for invalid
23 						chars in tax value.
24   17-Feb-00   ILeath         115.3              Added extra logic to Prefix
25                                                 Function to cope with new
26                                                 'S' codes.
27   27-Apr-00   AMills         115.4     1280564  Fixed Prefix function for
28                                                 2-char tax codes with no
29                                                 prefix, eg 3L.
30 
31 
32  +-----------+---------------+--------+--------+-----------------------+
33 */
34 --
35    g_numbers       varchar2(10)  := '0123456789';
36    g_alphabet      varchar2(26)  := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
37 --
38  ---------------------------------------------------------------------
39  -- NAME                                                            --
40  -- pyudet.trim                                    PRIVATE FUNCTION --
41  --                                                                 --
42  -- DESCRIPTION                                                     --
43  -- Function converts the input string to upper case and removes    --
44  -- all space characters                                            --
45  ---------------------------------------------------------------------
46 --
47 function trim (
48    p_string             in      varchar2)
49 return varchar2 is
50 begin
51    return(replace(upper(p_string),' '));
52 end trim;
53 --
54  ---------------------------------------------------------------------
55  -- NAME                                                            --
56  -- pyudet.tax_prefix                              PRIVATE FUNCTION --
57  --                                                                 --
58  -- DESCRIPTION                                                     --
59  -- Function strips out the Tax Code Prefix from a Tax Code, or     --
60  -- returns null if there is no prefix.                             --
61  -- 1999/2000.  Additional work to allow 2 characters in the prefix --
62  -- e.g. 'SK'.                                                      --
63  ---------------------------------------------------------------------
64 --
65 function tax_prefix (
66    p_tax_code		in	varchar2)
67 return varchar2 is
68 --
69 l_prefix varchar2(2);
70 --
71 begin
72 --
73    if instr(g_numbers,substr(trim(p_tax_code),1,1)) = 0 then
74    --
75    -- (If the first character of the Tax Code is not a number)
76    -- Account for tax codes that have two characters only and the first
77    -- character is not a prefix, eg 3L.
78    --
79     l_prefix :=  replace(translate(substr(trim(p_tax_code),1,2),g_numbers,' '),' ');
80    --
81    end if; -- else the tax code has a digit as the first
82            -- character so has no prefix, can return null.
83 --
84 return l_prefix;
85 --
86 end tax_prefix;
87 --
88  ---------------------------------------------------------------------
89  -- NAME                                                            --
90  -- pyudet.tax_value                               PRIVATE FUNCTION --
91  --                                                                 --
92  -- DESCRIPTION                                                     --
93  -- Function strips out the Tax Code Value from a Tax Code, or      --
94  -- returns null if there is no value                              --
95  ---------------------------------------------------------------------
96 --
97 function tax_value (
98    p_tax_code		in	varchar2)
99 return number is
100 
101 l_tax_value	VARCHAR2(30);
102 
103 begin
104 
105    l_tax_value := replace(translate(trim(p_tax_code),g_alphabet,' '),' ');
106 
107    if(translate(l_tax_value,'A'||g_numbers,'A') is not null) then
108 	l_tax_value := '999999';
109    end if;
110 
111    return(fnd_number.canonical_to_number(l_tax_value));
112 end tax_value;
113 --
114  ---------------------------------------------------------------------
115  -- NAME                                                            --
116  -- pyudet.tax_suffix                              PRIVATE FUNCTION --
117  --                                                                 --
118  -- DESCRIPTION                                                     --
119  -- Function strips out the Tax Code Suffix from a Tax Code, or     --
120  -- returns null if there is no suffix                              --
121  ---------------------------------------------------------------------
122 --
123 function tax_suffix (
124    p_tax_code		in	varchar2)
125 return varchar2 is
126 begin
127    return(replace(translate(substr(trim(p_tax_code),-1,1),g_numbers,' '),' '));
128 end tax_suffix;
129 --
130 end pysoytls;