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),
869: END IF;
870:
871: OE_DEBUG_PUB.ADD('OUT OEXRCRCB: Credit_Check_Processor',1);
872: EXCEPTION
873: WHEN GL_CURRENCY_API.NO_RATE THEN
874: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_Check_Processor - Error',1);
875: OE_DEBUG_PUB.ADD('EXCEPTION: GL_CURRENCY_API.NO_RATE',1);
876: IF DBMS_SQL.IS_OPEN(v_hold_cursorID) THEN
877: DBMS_SQL.CLOSE_CURSOR(v_hold_cursorID);
871: OE_DEBUG_PUB.ADD('OUT OEXRCRCB: Credit_Check_Processor',1);
872: EXCEPTION
873: WHEN GL_CURRENCY_API.NO_RATE THEN
874: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_Check_Processor - Error',1);
875: OE_DEBUG_PUB.ADD('EXCEPTION: GL_CURRENCY_API.NO_RATE',1);
876: IF DBMS_SQL.IS_OPEN(v_hold_cursorID) THEN
877: DBMS_SQL.CLOSE_CURSOR(v_hold_cursorID);
878: END IF;
879: IF DBMS_SQL.IS_OPEN(v_release_cursorID) THEN
2066: -----convert overall_credit_limit, exposure and available credit into base currency
2067: OE_DEBUG_PUB.ADD('IN Convert amounts ');
2068:
2069: l_base_cur_overall_limit :=
2070: GL_CURRENCY_API.Convert_closest_amount_sql
2071: ( x_from_currency => party_prof_csr_rec.party_currency_code
2072: , x_to_currency => l_base_currency
2073: , x_conversion_date => sysdate
2074: , x_conversion_type => l_conversion_type
2076: , x_amount => party_prof_csr_rec.party_overall_limit
2077: , x_max_roll_days => -1
2078: );
2079:
2080: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2081: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2082:
2083: l_base_cur_exposure :=
2084: GL_CURRENCY_API.Convert_closest_amount_sql
2080: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2081: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2082:
2083: l_base_cur_exposure :=
2084: GL_CURRENCY_API.Convert_closest_amount_sql
2085: ( x_from_currency => party_prof_csr_rec.party_currency_code
2086: , x_to_currency => l_base_currency
2087: , x_conversion_date => sysdate
2088: , x_conversion_type => l_conversion_type
2090: , x_amount => l_party_total_exposure
2091: , x_max_roll_days => -1
2092: );
2093:
2094: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2095: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2096:
2097: l_base_cur_available :=
2098: GL_CURRENCY_API.Convert_closest_amount_sql
2094: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2095: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2096:
2097: l_base_cur_available :=
2098: GL_CURRENCY_API.Convert_closest_amount_sql
2099: ( x_from_currency => party_prof_csr_rec.party_currency_code
2100: , x_to_currency => l_base_currency
2101: , x_conversion_date => sysdate
2102: , x_conversion_type => l_conversion_type
2104: , x_amount => l_party_available
2105: , x_max_roll_days => -1
2106: );
2107:
2108: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2109: OE_DEBUG_PUB.ADD('l_base_cur_available = '
2110: || TO_CHAR(l_base_cur_available ));
2111:
2112: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
2406: -----convert overall_credit_limit, exposure and available credit into base currency
2407: OE_DEBUG_PUB.ADD('IN Convert amounts ');
2408:
2409: l_base_cur_overall_limit :=
2410: GL_CURRENCY_API.Convert_closest_amount_sql
2411: ( x_from_currency => party_prof_csr_rec.party_currency_code
2412: , x_to_currency => l_base_currency
2413: , x_conversion_date => sysdate
2414: , x_conversion_type => l_conversion_type
2416: , x_amount => party_prof_csr_rec.party_overall_limit
2417: , x_max_roll_days => -1
2418: );
2419:
2420: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2421: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2422:
2423: l_base_cur_exposure :=
2424: GL_CURRENCY_API.Convert_closest_amount_sql
2420: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2421: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2422:
2423: l_base_cur_exposure :=
2424: GL_CURRENCY_API.Convert_closest_amount_sql
2425: ( x_from_currency => party_prof_csr_rec.party_currency_code
2426: , x_to_currency => l_base_currency
2427: , x_conversion_date => sysdate
2428: , x_conversion_type => l_conversion_type
2430: , x_amount => l_party_total_exposure
2431: , x_max_roll_days => -1
2432: );
2433:
2434: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2435: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2436:
2437: l_base_cur_available :=
2438: GL_CURRENCY_API.Convert_closest_amount_sql
2434: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2435: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2436:
2437: l_base_cur_available :=
2438: GL_CURRENCY_API.Convert_closest_amount_sql
2439: ( x_from_currency => party_prof_csr_rec.party_currency_code
2440: , x_to_currency => l_base_currency
2441: , x_conversion_date => sysdate
2442: , x_conversion_type => l_conversion_type
2444: , x_amount => l_party_available
2445: , x_max_roll_days => -1
2446: );
2447:
2448: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2449: OE_DEBUG_PUB.ADD('l_base_cur_available = '
2450: || TO_CHAR(l_base_cur_available ));
2451:
2452: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
2691: -----convert overall_credit_limit, exposure and available credit into base currency
2692: OE_DEBUG_PUB.ADD('IN Convert amounts ');
2693:
2694: l_base_cur_overall_limit :=
2695: GL_CURRENCY_API.Convert_closest_amount_sql
2696: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
2697: , x_to_currency => l_base_currency
2698: , x_conversion_date => sysdate
2699: , x_conversion_type => l_conversion_type
2701: , x_amount => cust_prof_csr_rec.cust_overall_limit
2702: , x_max_roll_days => -1
2703: );
2704:
2705: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2706: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2707:
2708: l_base_cur_exposure :=
2709: GL_CURRENCY_API.Convert_closest_amount_sql
2705: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2706: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
2707:
2708: l_base_cur_exposure :=
2709: GL_CURRENCY_API.Convert_closest_amount_sql
2710: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
2711: , x_to_currency => l_base_currency
2712: , x_conversion_date => sysdate
2713: , x_conversion_type => l_conversion_type
2715: , x_amount => l_cust_total_exposure
2716: , x_max_roll_days => -1
2717: );
2718:
2719: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2720: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2721:
2722: l_base_cur_available :=
2723: GL_CURRENCY_API.Convert_closest_amount_sql
2719: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2720: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
2721:
2722: l_base_cur_available :=
2723: GL_CURRENCY_API.Convert_closest_amount_sql
2724: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
2725: , x_to_currency => l_base_currency
2726: , x_conversion_date => sysdate
2727: , x_conversion_type => l_conversion_type
2729: , x_amount => l_cust_available
2730: , x_max_roll_days => -1
2731: );
2732:
2733: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
2734: OE_DEBUG_PUB.ADD('l_base_cur_available = '
2735: || TO_CHAR(l_base_cur_available ));
2736:
2737: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
3005: -----convert overall_credit_limit, exposure and available credit into base currency
3006: OE_DEBUG_PUB.ADD('IN Convert amounts ');
3007:
3008: l_base_cur_overall_limit :=
3009: GL_CURRENCY_API.Convert_closest_amount_sql
3010: ( x_from_currency => party_prof_csr_rec.party_currency_code
3011: , x_to_currency => l_base_currency
3012: , x_conversion_date => sysdate
3013: , x_conversion_type => l_conversion_type
3015: , x_amount => party_prof_csr_rec.party_overall_limit
3016: , x_max_roll_days => -1
3017: );
3018:
3019: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3020: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3021:
3022: l_base_cur_exposure :=
3023: GL_CURRENCY_API.Convert_closest_amount_sql
3019: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3020: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3021:
3022: l_base_cur_exposure :=
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 => l_party_total_exposure
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_exposure = '|| TO_CHAR(l_base_cur_exposure));
3035:
3036: l_base_cur_available :=
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_exposure = '|| TO_CHAR(l_base_cur_exposure));
3035:
3036: l_base_cur_available :=
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_available
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_available = '
3049: || TO_CHAR(l_base_cur_available ));
3050:
3051: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
3294: -----convert overall_credit_limit, exposure and available credit into base currency
3295: OE_DEBUG_PUB.ADD('IN Convert amounts ');
3296:
3297: l_base_cur_overall_limit :=
3298: GL_CURRENCY_API.Convert_closest_amount_sql
3299: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3300: , x_to_currency => l_base_currency
3301: , x_conversion_date => sysdate
3302: , x_conversion_type => l_conversion_type
3304: , x_amount => cust_prof_csr_rec.cust_overall_limit
3305: , x_max_roll_days => -1
3306: );
3307:
3308: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3309: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3310:
3311: l_base_cur_exposure :=
3312: GL_CURRENCY_API.Convert_closest_amount_sql
3308: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3309: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3310:
3311: l_base_cur_exposure :=
3312: GL_CURRENCY_API.Convert_closest_amount_sql
3313: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3314: , x_to_currency => l_base_currency
3315: , x_conversion_date => sysdate
3316: , x_conversion_type => l_conversion_type
3318: , x_amount => l_cust_total_exposure
3319: , x_max_roll_days => -1
3320: );
3321:
3322: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3323: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3324:
3325: l_base_cur_available :=
3326: GL_CURRENCY_API.Convert_closest_amount_sql
3322: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3323: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3324:
3325: l_base_cur_available :=
3326: GL_CURRENCY_API.Convert_closest_amount_sql
3327: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3328: , x_to_currency => l_base_currency
3329: , x_conversion_date => sysdate
3330: , x_conversion_type => l_conversion_type
3332: , x_amount => l_cust_available
3333: , x_max_roll_days => -1
3334: );
3335:
3336: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3337: OE_DEBUG_PUB.ADD('l_base_cur_available = '
3338: || TO_CHAR(l_base_cur_available ));
3339:
3340: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
3794: -----convert overall_credit_limit, exposure and available credit into base currency
3795: OE_DEBUG_PUB.ADD('IN Convert amounts ');
3796:
3797: l_base_cur_overall_limit :=
3798: GL_CURRENCY_API.Convert_closest_amount_sql
3799: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3800: , x_to_currency => l_base_currency
3801: , x_conversion_date => sysdate
3802: , x_conversion_type => l_conversion_type
3804: , x_amount => cust_prof_csr_rec.cust_overall_limit
3805: , x_max_roll_days => -1
3806: );
3807:
3808: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3809: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3810:
3811: l_base_cur_exposure :=
3812: GL_CURRENCY_API.Convert_closest_amount_sql
3808: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3809: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
3810:
3811: l_base_cur_exposure :=
3812: GL_CURRENCY_API.Convert_closest_amount_sql
3813: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3814: , x_to_currency => l_base_currency
3815: , x_conversion_date => sysdate
3816: , x_conversion_type => l_conversion_type
3818: , x_amount => l_cust_total_exposure
3819: , x_max_roll_days => -1
3820: );
3821:
3822: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3823: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3824:
3825: l_base_cur_available :=
3826: GL_CURRENCY_API.Convert_closest_amount_sql
3822: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3823: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
3824:
3825: l_base_cur_available :=
3826: GL_CURRENCY_API.Convert_closest_amount_sql
3827: ( x_from_currency => cust_prof_csr_rec.cust_currency_code
3828: , x_to_currency => l_base_currency
3829: , x_conversion_date => sysdate
3830: , x_conversion_type => l_conversion_type
3832: , x_amount => l_cust_available
3833: , x_max_roll_days => -1
3834: );
3835:
3836: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
3837: OE_DEBUG_PUB.ADD('l_base_cur_available = '
3838: || TO_CHAR(l_base_cur_available ));
3839:
3840: OE_DEBUG_PUB.ADD('OUT Convert amounts ');
4096: l_site_available:=site_prof_csr_rec.site_overall_limit - l_site_total_exposure;
4097:
4098: -----convert overall_credit_limit, exposure and available credit into base currency
4099: l_base_cur_overall_limit :=
4100: GL_CURRENCY_API.Convert_closest_amount_sql
4101: ( x_from_currency => site_prof_csr_rec.site_currency_code
4102: , x_to_currency => l_base_currency
4103: , x_conversion_date => SYSDATE
4104: , x_conversion_type => l_conversion_type
4106: , x_amount => site_prof_csr_rec.site_overall_limit
4107: , x_max_roll_days => -1
4108: );
4109:
4110: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
4111: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
4112:
4113:
4114: l_base_cur_exposure :=
4111: OE_DEBUG_PUB.ADD('l_base_cur_overall_limit = '|| TO_CHAR(l_base_cur_overall_limit));
4112:
4113:
4114: l_base_cur_exposure :=
4115: GL_CURRENCY_API.Convert_closest_amount_sql
4116: ( x_from_currency => site_prof_csr_rec.site_currency_code
4117: , x_to_currency => l_base_currency
4118: , x_conversion_date => SYSDATE
4119: , x_conversion_type => l_conversion_type
4121: , x_amount => l_site_total_exposure
4122: , x_max_roll_days => -1
4123: );
4124:
4125: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
4126: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
4127:
4128:
4129: l_base_cur_available :=
4126: OE_DEBUG_PUB.ADD('l_base_cur_exposure = '|| TO_CHAR(l_base_cur_exposure));
4127:
4128:
4129: l_base_cur_available :=
4130: GL_CURRENCY_API.Convert_closest_amount_sql
4131: ( x_from_currency => site_prof_csr_rec.site_currency_code
4132: , x_to_currency => l_base_currency
4133: , x_conversion_date => SYSDATE
4134: , x_conversion_type => l_conversion_type
4136: , x_amount => l_site_available
4137: , x_max_roll_days => -1
4138: );
4139:
4140: OE_DEBUG_PUB.ADD('GL_currency_api.Convert_closest_amount_sql ');
4141: OE_DEBUG_PUB.ADD('l_base_cur_available = '|| TO_CHAR(l_base_cur_available));
4142:
4143: -----insert data into temp table
4144: INSERT INTO OE_CREDIT_EXPOSURE_TEMP
4339: OE_DEBUG_PUB.ADD('Out of OEXRCRCB:Credit_exposure_report_utils with the status='||x_return_status);
4340:
4341: EXCEPTION
4342:
4343: WHEN GL_CURRENCY_API.NO_RATE THEN
4344: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_exposure_report_utils - GL_CURRENCY_API.NO_RATE');
4345: RAISE;
4346: WHEN OTHERS THEN
4347: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_exposure_report_utils - Unexpected Error',1);
4340:
4341: EXCEPTION
4342:
4343: WHEN GL_CURRENCY_API.NO_RATE THEN
4344: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_exposure_report_utils - GL_CURRENCY_API.NO_RATE');
4345: RAISE;
4346: WHEN OTHERS THEN
4347: OE_DEBUG_PUB.ADD('OEXRCRCB: Credit_exposure_report_utils - Unexpected Error',1);
4348: OE_DEBUG_PUB.ADD('EXCEPTION: '||SUBSTR(sqlerrm,1,200),1);