1 PACKAGE BODY PA_BURDEN_CMTS AS
2 /* $Header: PABCMTB.pls 115.5 2003/08/18 12:50:21 ajdas ship $ */
3
4 -- This function returns the compiled_set_id
5 -- This function will return NULL in case of error or if the compiled_set_id
6 -- is not found
7
8 FUNCTION get_cmt_compiled_set_id
9 ( x_transaction_id IN NUMBER,
10 x_transaction_type IN VARCHAR2,
11 x_task_id IN NUMBER,
12 x_expenditure_item_date IN DATE,
13 x_organization_id IN NUMBER,
14 p_expenditure_type IN pa_expenditure_types.expenditure_type%TYPE,
15 x_schedule_type IN VARCHAR2)
16 RETURN NUMBER
17 IS
18 compiled_set_id NUMBER;
19 cost_base pa_cost_bases.cost_base%TYPE;
20 cp_structure pa_cost_plus_structures.cost_plus_structure%TYPE;
21 rate_sch_rev_id NUMBER;
22 sch_id NUMBER;
23 sch_fixed_date DATE;
24 status NUMBER;
25 stage NUMBER;
26 BEGIN
27
28 -- First get the rate_sch_rev_id
29
30 compiled_set_id := NULL;
31
32 pa_cost_plus.find_rate_sch_rev_id(
33 x_transaction_id,
34 x_transaction_type,
35 x_task_id,
36 x_schedule_type,
37 x_expenditure_item_date,
38 sch_id,
39 rate_sch_rev_id,
40 sch_fixed_date,
41 status,
42 stage);
43
44 IF ( status <> 0 ) THEN
45 RETURN NULL;
46 END IF;
47
48 pa_cost_plus.get_cost_plus_structure( rate_sch_rev_id => rate_sch_rev_id
49 ,cp_structure => cp_structure
50 ,status => status
51 ,stage => stage
52 );
53
54 IF (status <> 0) THEN
55 return NULL;
56 END IF;
57
58 pa_cost_plus.get_cost_base( exp_type => p_expenditure_type
59 ,cp_structure => cp_structure
60 ,c_base => cost_base
61 ,status => status
62 ,stage => stage
63 );
64
65 IF (status <> 0) THEN
66 return NULL;
67 END IF;
68
69 -- Now get the compiled_set_id
70
71 pa_cost_plus.get_compiled_set_id(
72 rate_sch_rev_id,
73 x_organization_id,
74 cost_base,
75 compiled_set_id,
76 status,
77 stage);
78
79 IF (status <> 0) THEN
80 return NULL;
81 END IF;
82
83 RETURN compiled_set_id;
84
85 EXCEPTION
86 WHEN OTHERS THEN
87 RETURN NULL;
88 END get_cmt_compiled_set_id;
89
90 -- This function returns the burdened_cost
91 -- in case if it is not able to calculate the burden cost component
92 -- then it will return the direct_cost itself.
93
94 FUNCTION get_cmt_burdened_cost
95 ( x_transaction_id IN NUMBER,
96 x_transaction_type IN VARCHAR2,
97 x_task_id IN NUMBER,
98 x_expenditure_item_date IN DATE,
99 x_expenditure_type IN VARCHAR2,
100 x_organization_id IN NUMBER,
101 x_schedule_type IN VARCHAR2,
102 x_direct_cost IN NUMBER)
103 RETURN NUMBER
104 IS
105 indirect_cost NUMBER;
106 status NUMBER;
107 stage NUMBER;
108 BEGIN
109
110 -- Get the burden cost component first
111
112 indirect_cost := 0;
113
114 pa_cost_plus.view_indirect_cost(
115 x_transaction_id,
116 x_transaction_type,
117 x_task_id,
118 x_expenditure_item_date,
119 x_expenditure_type,
120 x_organization_id,
121 x_schedule_type,
122 x_direct_cost,
123 indirect_cost,
124 status,
125 stage);
126
127 IF ( status <> 0 ) THEN
128 RETURN x_direct_cost;
129 END IF;
130
131 RETURN x_direct_cost + indirect_cost;
132
133 EXCEPTION
134 WHEN OTHERS THEN
135 RETURN NULL;
136 END get_cmt_burdened_cost;
137
138 END PA_BURDEN_CMTS;