234: ELSIF p_order_by = 'GREATEST_ORDER_VALUE' THEN
235: v_order_by_clause :=
236: 'ORDER BY DECODE(OH.transactional_curr_code, :gl_currency_code,
237: oe_oe_totals_summary.prt_order_total(OH.header_id),
238: gl_currency_api.convert_closest_amount_sql(
239: OH.transactional_curr_code,
240: :gl_currency_code,
241: DECODE(OH.conversion_rate_date, NULL,SYSDATE,OH.conversion_rate_date),
242: DECODE(OH.conversion_type_code, NULL,''Corporate'',OH.conversion_type_code),
877: END IF;
878:
879: OE_DEBUG_PUB.ADD('OUT OEXRCRCB: Credit_Check_Processor',1);
880: EXCEPTION
881: WHEN GL_CURRENCY_API.NO_RATE THEN
882: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_Check_Processor - Error',1);
883: OE_DEBUG_PUB.ADD('EXCEPTION: GL_CURRENCY_API.NO_RATE',1);
884: IF DBMS_SQL.IS_OPEN(v_hold_cursorID) THEN
885: DBMS_SQL.CLOSE_CURSOR(v_hold_cursorID);
879: OE_DEBUG_PUB.ADD('OUT OEXRCRCB: Credit_Check_Processor',1);
880: EXCEPTION
881: WHEN GL_CURRENCY_API.NO_RATE THEN
882: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_Check_Processor - Error',1);
883: OE_DEBUG_PUB.ADD('EXCEPTION: GL_CURRENCY_API.NO_RATE',1);
884: IF DBMS_SQL.IS_OPEN(v_hold_cursorID) THEN
885: DBMS_SQL.CLOSE_CURSOR(v_hold_cursorID);
886: END IF;
887: IF DBMS_SQL.IS_OPEN(v_release_cursorID) THEN
2077: -----convert overall_credit_limit, exposure and available credit into base currency
2078: OE_DEBUG_PUB.ADD('IN Convert amounts ');
2079:
2080: l_base_cur_overall_limit :=
2081: GL_CURRENCY_API.Convert_closest_amount_sql
2082: ( x_from_currency => party_prof_csr_rec.party_currency_code
2083: , x_to_currency => l_base_currency
2084: , x_conversion_date => sysdate
2085: , x_conversion_type => l_conversion_type
2087: , x_amount => party_prof_csr_rec.party_overall_limit
2088: , x_max_roll_days => -1
2089: );
2090:
2091: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2092: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2093:
2094: l_base_cur_exposure :=
2095: GL_CURRENCY_API.Convert_closest_amount_sql
2091: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2092: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2093:
2094: l_base_cur_exposure :=
2095: GL_CURRENCY_API.Convert_closest_amount_sql
2096: ( x_from_currency => party_prof_csr_rec.party_currency_code
2097: , x_to_currency => l_base_currency
2098: , x_conversion_date => sysdate
2099: , x_conversion_type => l_conversion_type
2101: , x_amount => l_party_total_exposure
2102: , x_max_roll_days => -1
2103: );
2104:
2105: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2106: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2107:
2108: l_base_cur_available :=
2109: GL_CURRENCY_API.Convert_closest_amount_sql
2105: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2106: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2107:
2108: l_base_cur_available :=
2109: GL_CURRENCY_API.Convert_closest_amount_sql
2110: ( x_from_currency => party_prof_csr_rec.party_currency_code
2111: , x_to_currency => l_base_currency
2112: , x_conversion_date => sysdate
2113: , x_conversion_type => l_conversion_type
2115: , x_amount => l_party_available
2116: , x_max_roll_days => -1
2117: );
2118:
2119: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2120: OE_DEBUG_PUB.ADD('l_base_cur_available = '
2121: || TO_CHAR(l_base_cur_available ));
2122:
2123: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
2418: -----convert overall_credit_limit, exposure and available credit into base currency
2419: OE_DEBUG_PUB.ADD('IN Convert amounts ');
2420:
2421: l_base_cur_overall_limit :=
2422: GL_CURRENCY_API.Convert_closest_amount_sql
2423: ( x_from_currency => party_prof_csr_rec.party_currency_code
2424: , x_to_currency => l_base_currency
2425: , x_conversion_date => sysdate
2426: , x_conversion_type => l_conversion_type
2428: , x_amount => party_prof_csr_rec.party_overall_limit
2429: , x_max_roll_days => -1
2430: );
2431:
2432: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2433: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2434:
2435: l_base_cur_exposure :=
2436: GL_CURRENCY_API.Convert_closest_amount_sql
2432: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2433: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2434:
2435: l_base_cur_exposure :=
2436: GL_CURRENCY_API.Convert_closest_amount_sql
2437: ( x_from_currency => party_prof_csr_rec.party_currency_code
2438: , x_to_currency => l_base_currency
2439: , x_conversion_date => sysdate
2440: , x_conversion_type => l_conversion_type
2442: , x_amount => l_party_total_exposure
2443: , x_max_roll_days => -1
2444: );
2445:
2446: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2447: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2448:
2449: l_base_cur_available :=
2450: GL_CURRENCY_API.Convert_closest_amount_sql
2446: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2447: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2448:
2449: l_base_cur_available :=
2450: GL_CURRENCY_API.Convert_closest_amount_sql
2451: ( x_from_currency => party_prof_csr_rec.party_currency_code
2452: , x_to_currency => l_base_currency
2453: , x_conversion_date => sysdate
2454: , x_conversion_type => l_conversion_type
2456: , x_amount => l_party_available
2457: , x_max_roll_days => -1
2458: );
2459:
2460: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2461: OE_DEBUG_PUB.ADD('l_base_cur_available = '
2462: || TO_CHAR(l_base_cur_available ));
2463:
2464: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
2704: -----convert overall_credit_limit, exposure and available credit into base currency
2705: OE_DEBUG_PUB.ADD('IN Convert amounts ');
2706:
2707: l_base_cur_overall_limit :=
2708: GL_CURRENCY_API.Convert_closest_amount_sql
2709: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
2710: , x_to_currency => l_base_currency
2711: , x_conversion_date => sysdate
2712: , x_conversion_type => l_conversion_type
2714: , x_amount => cust_prof_csr_rec.cust_overall_limit
2715: , x_max_roll_days => -1
2716: );
2717:
2718: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2719: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2720:
2721: l_base_cur_exposure :=
2722: GL_CURRENCY_API.Convert_closest_amount_sql
2718: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2719: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2720:
2721: l_base_cur_exposure :=
2722: GL_CURRENCY_API.Convert_closest_amount_sql
2723: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
2724: , x_to_currency => l_base_currency
2725: , x_conversion_date => sysdate
2726: , x_conversion_type => l_conversion_type
2728: , x_amount => l_cust_total_exposure
2729: , x_max_roll_days => -1
2730: );
2731:
2732: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2733: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2734:
2735: l_base_cur_available :=
2736: GL_CURRENCY_API.Convert_closest_amount_sql
2732: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2733: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2734:
2735: l_base_cur_available :=
2736: GL_CURRENCY_API.Convert_closest_amount_sql
2737: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
2738: , x_to_currency => l_base_currency
2739: , x_conversion_date => sysdate
2740: , x_conversion_type => l_conversion_type
2742: , x_amount => l_cust_available
2743: , x_max_roll_days => -1
2744: );
2745:
2746: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2747: OE_DEBUG_PUB.ADD('l_base_cur_available = '
2748: || TO_CHAR(l_base_cur_available ));
2749:
2750: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
3019: -----convert overall_credit_limit, exposure and available credit into base currency
3020: OE_DEBUG_PUB.ADD('IN Convert amounts ');
3021:
3022: l_base_cur_overall_limit :=
3023: GL_CURRENCY_API.Convert_closest_amount_sql
3024: ( x_from_currency => party_prof_csr_rec.party_currency_code
3025: , x_to_currency => l_base_currency
3026: , x_conversion_date => sysdate
3027: , x_conversion_type => l_conversion_type
3029: , x_amount => party_prof_csr_rec.party_overall_limit
3030: , x_max_roll_days => -1
3031: );
3032:
3033: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3034: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3035:
3036: l_base_cur_exposure :=
3037: GL_CURRENCY_API.Convert_closest_amount_sql
3033: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3034: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3035:
3036: l_base_cur_exposure :=
3037: GL_CURRENCY_API.Convert_closest_amount_sql
3038: ( x_from_currency => party_prof_csr_rec.party_currency_code
3039: , x_to_currency => l_base_currency
3040: , x_conversion_date => sysdate
3041: , x_conversion_type => l_conversion_type
3043: , x_amount => l_party_total_exposure
3044: , x_max_roll_days => -1
3045: );
3046:
3047: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3048: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3049:
3050: l_base_cur_available :=
3051: GL_CURRENCY_API.Convert_closest_amount_sql
3047: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3048: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3049:
3050: l_base_cur_available :=
3051: GL_CURRENCY_API.Convert_closest_amount_sql
3052: ( x_from_currency => party_prof_csr_rec.party_currency_code
3053: , x_to_currency => l_base_currency
3054: , x_conversion_date => sysdate
3055: , x_conversion_type => l_conversion_type
3057: , x_amount => l_party_available
3058: , x_max_roll_days => -1
3059: );
3060:
3061: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3062: OE_DEBUG_PUB.ADD('l_base_cur_available = '
3063: || TO_CHAR(l_base_cur_available ));
3064:
3065: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
3309: -----convert overall_credit_limit, exposure and available credit into base currency
3310: OE_DEBUG_PUB.ADD('IN Convert amounts ');
3311:
3312: l_base_cur_overall_limit :=
3313: GL_CURRENCY_API.Convert_closest_amount_sql
3314: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3315: , x_to_currency => l_base_currency
3316: , x_conversion_date => sysdate
3317: , x_conversion_type => l_conversion_type
3319: , x_amount => cust_prof_csr_rec.cust_overall_limit
3320: , x_max_roll_days => -1
3321: );
3322:
3323: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3324: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3325:
3326: l_base_cur_exposure :=
3327: GL_CURRENCY_API.Convert_closest_amount_sql
3323: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3324: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3325:
3326: l_base_cur_exposure :=
3327: GL_CURRENCY_API.Convert_closest_amount_sql
3328: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3329: , x_to_currency => l_base_currency
3330: , x_conversion_date => sysdate
3331: , x_conversion_type => l_conversion_type
3333: , x_amount => l_cust_total_exposure
3334: , x_max_roll_days => -1
3335: );
3336:
3337: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3338: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3339:
3340: l_base_cur_available :=
3341: GL_CURRENCY_API.Convert_closest_amount_sql
3337: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3338: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3339:
3340: l_base_cur_available :=
3341: GL_CURRENCY_API.Convert_closest_amount_sql
3342: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3343: , x_to_currency => l_base_currency
3344: , x_conversion_date => sysdate
3345: , x_conversion_type => l_conversion_type
3347: , x_amount => l_cust_available
3348: , x_max_roll_days => -1
3349: );
3350:
3351: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3352: OE_DEBUG_PUB.ADD('l_base_cur_available = '
3353: || TO_CHAR(l_base_cur_available ));
3354:
3355: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
3819: -----convert overall_credit_limit, exposure and available credit into base currency
3820: OE_DEBUG_PUB.ADD('IN Convert amounts ');
3821:
3822: l_base_cur_overall_limit :=
3823: GL_CURRENCY_API.Convert_closest_amount_sql
3824: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3825: , x_to_currency => l_base_currency
3826: , x_conversion_date => sysdate
3827: , x_conversion_type => l_conversion_type
3829: , x_amount => cust_prof_csr_rec.cust_overall_limit
3830: , x_max_roll_days => -1
3831: );
3832:
3833: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3834: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3835:
3836: l_base_cur_exposure :=
3837: GL_CURRENCY_API.Convert_closest_amount_sql
3833: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3834: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3835:
3836: l_base_cur_exposure :=
3837: GL_CURRENCY_API.Convert_closest_amount_sql
3838: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3839: , x_to_currency => l_base_currency
3840: , x_conversion_date => sysdate
3841: , x_conversion_type => l_conversion_type
3843: , x_amount => l_cust_total_exposure
3844: , x_max_roll_days => -1
3845: );
3846:
3847: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3848: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3849:
3850: l_base_cur_available :=
3851: GL_CURRENCY_API.Convert_closest_amount_sql
3847: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3848: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3849:
3850: l_base_cur_available :=
3851: GL_CURRENCY_API.Convert_closest_amount_sql
3852: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3853: , x_to_currency => l_base_currency
3854: , x_conversion_date => sysdate
3855: , x_conversion_type => l_conversion_type
3857: , x_amount => l_cust_available
3858: , x_max_roll_days => -1
3859: );
3860:
3861: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3862: OE_DEBUG_PUB.ADD('l_base_cur_available = '
3863: || TO_CHAR(l_base_cur_available ));
3864:
3865: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
4122: l_site_available:=site_prof_csr_rec.site_overall_limit - l_site_total_exposure;
4123:
4124: -----convert overall_credit_limit, exposure and available credit into base currency
4125: l_base_cur_overall_limit :=
4126: GL_CURRENCY_API.Convert_closest_amount_sql
4127: ( x_from_currency => site_prof_csr_rec.site_currency_code
4128: , x_to_currency => l_base_currency
4129: , x_conversion_date => SYSDATE
4130: , x_conversion_type => l_conversion_type
4132: , x_amount => site_prof_csr_rec.site_overall_limit
4133: , x_max_roll_days => -1
4134: );
4135:
4136: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
4137: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
4138:
4139:
4140: l_base_cur_exposure :=
4137: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
4138:
4139:
4140: l_base_cur_exposure :=
4141: GL_CURRENCY_API.Convert_closest_amount_sql
4142: ( x_from_currency => site_prof_csr_rec.site_currency_code
4143: , x_to_currency => l_base_currency
4144: , x_conversion_date => SYSDATE
4145: , x_conversion_type => l_conversion_type
4147: , x_amount => l_site_total_exposure
4148: , x_max_roll_days => -1
4149: );
4150:
4151: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
4152: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
4153:
4154:
4155: l_base_cur_available :=
4152: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
4153:
4154:
4155: l_base_cur_available :=
4156: GL_CURRENCY_API.Convert_closest_amount_sql
4157: ( x_from_currency => site_prof_csr_rec.site_currency_code
4158: , x_to_currency => l_base_currency
4159: , x_conversion_date => SYSDATE
4160: , x_conversion_type => l_conversion_type
4162: , x_amount => l_site_available
4163: , x_max_roll_days => -1
4164: );
4165:
4166: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
4167: OE_DEBUG_PUB.ADD('l_base_cur_available = '|| TO_CHAR(l_base_cur_available));
4168:
4169: -----insert data into temp table
4170: INSERT INTO OE_CREDIT_EXPOSURE_TEMP
4366: OE_DEBUG_PUB.ADD('Out of OEXRCRCB:Credit_exposure_report_utils with the status='||x_return_status);
4367:
4368: EXCEPTION
4369:
4370: WHEN GL_CURRENCY_API.NO_RATE THEN
4371: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_exposure_report_utils - GL_CURRENCY_API.NO_RATE');
4372: RAISE;
4373: WHEN OTHERS THEN
4374: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_exposure_report_utils - Unexpected Error',1);
4367:
4368: EXCEPTION
4369:
4370: WHEN GL_CURRENCY_API.NO_RATE THEN
4371: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_exposure_report_utils - GL_CURRENCY_API.NO_RATE');
4372: RAISE;
4373: WHEN OTHERS THEN
4374: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_exposure_report_utils - Unexpected Error',1);
4375: OE_DEBUG_PUB.ADD('EXCEPTION: '||SUBSTR(sqlerrm,1,200),1);