63: PROCEDURE raise_business_event(p_api_version IN NUMBER,
64: p_init_msg_list IN VARCHAR2,
65: p_chr_id IN okc_k_headers_b.id%TYPE,
66: p_asset_id IN okc_k_lines_b.id%TYPE,
67: p_subsidy_id IN okl_subsidies_b.id%TYPE,
68: p_event_name IN VARCHAR2,
69: x_return_status OUT NOCOPY VARCHAR2,
70: x_msg_count OUT NOCOPY NUMBER,
71: x_msg_data OUT NOCOPY VARCHAR2
214: subb.name,
215: subt.short_description
216: from
217: okl_subsidies_tl subt,
218: okl_subsidies_b subb
219: where subt.id = subb.id
220: and subt.language = userenv('LANG')
221: and subb.id = p_sub_id;
222:
249:
250: --cursor to get subsidy id from subsidy name
251: cursor l_subname_csr (p_subsidy_name in varchar2) is
252: select id
253: from okl_subsidies_b subb
254: where name = ltrim(rtrim(p_subsidy_name,' '),' ');
255:
256: l_subsidy_id Number;
257:
432: subb.name,
433: subt.short_description
434: from
435: okl_subsidies_tl subt,
436: okl_subsidies_b subb
437: where subt.id = subb.id
438: and subt.language = userenv('LANG')
439: and subb.id = p_sub_id;
440:
487:
488: --cursor to get subsidy id from subsidy name
489: cursor l_subname_csr (p_subsidy_name in varchar2) is
490: select id
491: from okl_subsidies_b subb
492: where name = ltrim(rtrim(p_subsidy_name,' '),' ');
493:
494: l_subsidy_id Number;
495:
1070: --cursor : to check applicability at contract header ORG_ID
1071: cursor l_chr_csr (p_subsidy_id in number,
1072: p_asset_cle_id in number) is
1073: Select 'Y'
1074: from okl_subsidies_b sub,
1075: okc_k_headers_b chrb,
1076: okc_k_lines_b cleb
1077: where sub.id = p_subsidy_id
1078: and chrb.id = cleb.chr_id
1088: -- on release
1089: cursor l_relk_csr (p_subsidy_id in number,
1090: p_asset_cle_id in number) is
1091: Select 'Y'
1092: from okl_subsidies_b sub,
1093: okc_k_headers_b chrb,
1094: okc_k_lines_b cleb
1095: where sub.id = p_subsidy_id
1096: and chrb.id = cleb.chr_id
1104: -- on release
1105: cursor l_rela_csr (p_subsidy_id in number,
1106: p_asset_cle_id in number) is
1107: Select 'Y'
1108: from okl_subsidies_b sub,
1109: okc_rules_b rulb,
1110: okc_k_lines_b cleb
1111: where sub.id = p_subsidy_id
1112: and rulb.dnz_chr_id = cleb.chr_id
1117: sub.APPLICABLE_TO_RELEASE_YN) = sub.APPLICABLE_TO_RELEASE_YN
1118: union
1119: -- to take care of S and O where release yes-no flag is not applicable
1120: Select 'Y'
1121: from okl_subsidies_b sub,
1122: okc_k_lines_b cleb
1123: where sub.id = p_subsidy_id
1124: and cleb.id = p_asset_cle_id
1125: and not exists (select 1
1132: --cursor : to check applicability at line dates
1133: cursor l_cle_csr (p_subsidy_id in number,
1134: p_asset_cle_id in number) is
1135: Select 'Y'
1136: from okl_subsidies_b sub,
1137: okc_k_lines_b cleb
1138: where sub.id = p_subsidy_id
1139: and cleb.id = p_asset_cle_id
1140: -- start: okl.h cklee
1146:
1147: --cursor : to check existence of criteria
1148: cursor l_suc_csr (p_subsidy_id in number) is
1149: select 'Y'
1150: from okl_subsidies_b sub
1151: where sub.id = p_subsidy_id
1152: and exists (select 1
1153: from okl_subsidy_criteria suc
1154: where suc.subsidy_id = sub.id);
1155:
1156: --cursor : to check that inv check is required
1157: cursor l_invreq_csr (p_subsidy_id in number) is
1158: select 'Y'
1159: from okl_subsidies_b sub
1160: Where sub.id = p_subsidy_id
1161: and exists (select 1
1162: from okl_subsidy_criteria suc
1163: where suc.organization_id is not null
1189:
1190: --cursor : to check that credit class check is required
1191: cursor l_clsreq_csr (p_subsidy_id in number) is
1192: select 'Y'
1193: from okl_subsidies_b sub
1194: Where sub.id = p_subsidy_id
1195: and exists (select 1
1196: from okl_subsidy_criteria suc
1197: where suc.credit_classification_code is not null
1222:
1223: --cursor : to check that territory check is required
1224: cursor l_terrreq_csr (p_subsidy_id in number) is
1225: select 'Y'
1226: from okl_subsidies_b sub
1227: Where sub.id = p_subsidy_id
1228: and exists (select 1
1229: from okl_subsidy_criteria suc
1230: --cklee 03/16/2004
1298:
1299: --cursor : to check that product check is required
1300: cursor l_pdtreq_csr (p_subsidy_id in number) is
1301: select 'Y'
1302: from okl_subsidies_b sub
1303: Where sub.id = p_subsidy_id
1304: and exists (select 1
1305: from okl_subsidy_criteria suc
1306: where suc.PRODUCT_ID is not null
1321:
1322: --cursor : to check that sic_code check is required
1323: cursor l_sicreq_csr (p_subsidy_id in number) is
1324: select 'Y'
1325: from okl_subsidies_b sub
1326: Where sub.id = p_subsidy_id
1327: and exists (select 1
1328: from okl_subsidy_criteria suc
1329: where suc.INDUSTRY_CODE is not null
1352:
1353: --cursor : to check that subsidy expiration
1354: cursor l_not_expire_csr (p_subsidy_id in number) is
1355: select 'Y'
1356: from okl_subsidies_b sub
1357: Where sub.id = p_subsidy_id
1358:
1359: -- Start : Bug 6050165 : prasjain
1360: -- and TRUNC(nvl(sub.EFFECTIVE_TO_DATE,sysdate) + nvl(sub.EXPIRE_AFTER_DAYS,0)) >= TRUNC(sysdate);
1739: --cursor : to check applicability at contract header ORG_ID
1740: cursor l_chr_csr (p_subsidy_id in number,
1741: p_chr_id in number) is
1742: Select 'Y'
1743: from okl_subsidies_b sub,
1744: okc_k_headers_b chrb
1745: where sub.id = p_subsidy_id
1746: and chrb.id = p_chr_id
1747: --check for authoring org id
1754: cursor l_cle_csr (p_subsidy_id in number,
1755: p_start_date in date
1756: ) is
1757: Select 'Y'
1758: from okl_subsidies_b sub
1759: where sub.id = p_subsidy_id
1760: and p_start_date between sub.effective_from_date
1761: and nvl(sub.effective_to_date,p_start_date);
1762:
1762:
1763: --cursor : to check existence of criteria
1764: cursor l_suc_csr (p_subsidy_id in number) is
1765: select 'Y'
1766: from okl_subsidies_b sub
1767: where sub.id = p_subsidy_id
1768: and exists (select 1
1769: from okl_subsidy_criteria suc
1770: where suc.subsidy_id = sub.id);
1771:
1772: --cursor : to check that inv check is required
1773: cursor l_invreq_csr (p_subsidy_id in number) is
1774: select 'Y'
1775: from okl_subsidies_b sub
1776: Where sub.id = p_subsidy_id
1777: and exists (select 1
1778: from okl_subsidy_criteria suc
1779: where suc.organization_id is not null
1795:
1796: --cursor : to check that credit class check is required
1797: cursor l_clsreq_csr (p_subsidy_id in number) is
1798: select 'Y'
1799: from okl_subsidies_b sub
1800: Where sub.id = p_subsidy_id
1801: and exists (select 1
1802: from okl_subsidy_criteria suc
1803: where suc.credit_classification_code is not null
1824:
1825: --cursor : to check that territory check is required
1826: cursor l_terrreq_csr (p_subsidy_id in number) is
1827: select 'Y'
1828: from okl_subsidies_b sub
1829: Where sub.id = p_subsidy_id
1830: and exists (select 1
1831: from okl_subsidy_criteria suc
1832: where suc.SALES_TERRITORY_CODE is not null
1849:
1850: --cursor : to check that product check is required
1851: cursor l_pdtreq_csr (p_subsidy_id in number) is
1852: select 'Y'
1853: from okl_subsidies_b sub
1854: Where sub.id = p_subsidy_id
1855: and exists (select 1
1856: from okl_subsidy_criteria suc
1857: where suc.PRODUCT_ID is not null
1870:
1871: --cursor : to check that sic_code check is required
1872: cursor l_sicreq_csr (p_subsidy_id in number) is
1873: select 'Y'
1874: from okl_subsidies_b sub
1875: Where sub.id = p_subsidy_id
1876: and exists (select 1
1877: from okl_subsidy_criteria suc
1878: where suc.INDUSTRY_CODE is not null
2228: /* --cursor : to check applicability at contract header ORG_ID
2229: cursor l_chr_csr (p_subsidy_id in number,
2230: p_chr_id in number) is
2231: Select 'Y'
2232: from okl_subsidies_b sub,
2233: okc_k_headers_b chrb
2234: where sub.id = p_subsidy_id
2235: and chrb.id = p_chr_id
2236: --check for authoring org id
2242: cursor l_chr_csr (p_subsidy_id in number,
2243: p_authoring_org_id in number,
2244: p_currency_code in varchar2) is
2245: Select 'Y'
2246: from okl_subsidies_b sub
2247: where sub.id = p_subsidy_id
2248: --check for authoring org id
2249: and sub.org_id = p_authoring_org_id
2250: --check for currency code
2256: cursor l_cle_csr (p_subsidy_id in number,
2257: p_start_date in date
2258: ) is
2259: Select 'Y'
2260: from okl_subsidies_b sub
2261: where sub.id = p_subsidy_id
2262: -- start: okl.h cklee
2263: -- and p_start_date between sub.effective_from_date
2264: -- and nvl(sub.effective_to_date,p_start_date);
2268:
2269: --cursor : to check existence of criteria
2270: cursor l_suc_csr (p_subsidy_id in number) is
2271: select 'Y'
2272: from okl_subsidies_b sub
2273: where sub.id = p_subsidy_id
2274: and exists (select 1
2275: from okl_subsidy_criteria suc
2276: where suc.subsidy_id = sub.id);
2277:
2278: --cursor : to check that inv check is required
2279: cursor l_invreq_csr (p_subsidy_id in number) is
2280: select 'Y'
2281: from okl_subsidies_b sub
2282: Where sub.id = p_subsidy_id
2283: and exists (select 1
2284: from okl_subsidy_criteria suc
2285: where suc.organization_id is not null
2301:
2302: --cursor : to check that credit class check is required
2303: cursor l_clsreq_csr (p_subsidy_id in number) is
2304: select 'Y'
2305: from okl_subsidies_b sub
2306: Where sub.id = p_subsidy_id
2307: and exists (select 1
2308: from okl_subsidy_criteria suc
2309: where suc.credit_classification_code is not null
2341:
2342: --cursor : to check that territory check is required
2343: cursor l_terrreq_csr (p_subsidy_id in number) is
2344: select 'Y'
2345: from okl_subsidies_b sub
2346: Where sub.id = p_subsidy_id
2347: and exists (select 1
2348: from okl_subsidy_criteria suc
2349: where suc.SALES_TERRITORY_ID is not null
2377:
2378: --cursor : to check that product check is required
2379: cursor l_pdtreq_csr (p_subsidy_id in number) is
2380: select 'Y'
2381: from okl_subsidies_b sub
2382: Where sub.id = p_subsidy_id
2383: and exists (select 1
2384: from okl_subsidy_criteria suc
2385: where suc.PRODUCT_ID is not null
2409:
2410: --cursor : to check that sic_code check is required
2411: cursor l_sicreq_csr (p_subsidy_id in number) is
2412: select 'Y'
2413: from okl_subsidies_b sub
2414: Where sub.id = p_subsidy_id
2415: and exists (select 1
2416: from okl_subsidy_criteria suc
2417: where suc.INDUSTRY_CODE is not null
2744: -- 2. the subsidy pool has decision_status_code = 'ACTIVE' and sysdate between effective dates of the subsidy pool
2745: -- 3. the subsidy pool is logically active as on the start date of the asset
2746: -- 4. there exists a valid currency conversion basis between the pool and the asset/contract
2747: -- 5. the pool balance is valid before addition of the subsidy amount
2748: FUNCTION validate_subsidy_pool_applic(p_subsidy_id IN okl_subsidies_b.id%TYPE,
2749: p_asset_cle_id IN okc_k_lines_b.id%TYPE,
2750: p_ast_date_sq IN okc_k_lines_b.start_date%TYPE,
2751: p_trx_curr_code_sq IN okc_k_lines_b.currency_code%TYPE,
2752: --START: 09-Dec-2005 cklee - Fixed bug#4874385 |
2771: WHERE line.id = p_asset_cle_id;
2772:
2773: CURSOR c_get_subsidy_name_csr(p_subsidy_id number) IS
2774: SELECT sub.name
2775: FROM okl_subsidies_b sub
2776: WHERE sub.id = p_subsidy_id;
2777:
2778: CURSOR c_get_subsidy_pool_name_csr(p_subsidy_pool_id number) IS
2779: SELECT sub.subsidy_pool_name
2793: lv_asset_curr_code okc_k_lines_b.currency_code%TYPE;
2794: lv_start_date okc_k_lines_b.start_date%TYPE;
2795: --START: 09/29/2005 bug#4634871
2796: lv_asset_number okc_k_lines_v.name%TYPE;
2797: lv_subsidy_name okl_subsidies_b.name%TYPE;
2798: lv_subsidy_pool_name okl_subsidy_pools_v.subsidy_pool_name%TYPE;
2799: --END: 09/29/2005 bug#4634871
2800:
2801: l_module CONSTANT fnd_log_messages.module%TYPE := 'okl.plsql.OKL_ASSET_SUBSIDY_PVT.VALIDATE_SUBSIDY_POOL_APPLIC';
3027: RETURN(l_applicable);
3028: END validate_subsidy_pool_applic;
3029:
3030:
3031: FUNCTION is_sub_assoc_with_pool(p_subsidy_id IN okl_subsidies_b.id%TYPE
3032: ,x_subsidy_pool_id OUT NOCOPY okl_subsidy_pools_b.id%TYPE
3033: ,x_sub_pool_curr_code OUT NOCOPY okl_subsidy_pools_b.currency_code%TYPE) RETURN VARCHAR2 IS
3034: CURSOR c_subsidy_csr IS
3035: SELECT sub.subsidy_pool_id,pool.currency_code
3032: ,x_subsidy_pool_id OUT NOCOPY okl_subsidy_pools_b.id%TYPE
3033: ,x_sub_pool_curr_code OUT NOCOPY okl_subsidy_pools_b.currency_code%TYPE) RETURN VARCHAR2 IS
3034: CURSOR c_subsidy_csr IS
3035: SELECT sub.subsidy_pool_id,pool.currency_code
3036: FROM okl_subsidies_b sub
3037: ,okl_subsidy_pools_b pool
3038: WHERE sub.id = p_subsidy_id
3039: AND sub.subsidy_pool_id = pool.id;
3040: cv_subsidy c_subsidy_csr%ROWTYPE;
3150: END IF;
3151: return lv_return_status;
3152: END is_balance_valid_before_add;
3153:
3154: PROCEDURE is_balance_valid_after_add (p_subsidy_id okl_subsidies_b.id%TYPE,
3155: p_asset_id okc_k_lines_b.id%TYPE,
3156: p_subsidy_amount NUMBER,
3157: p_subsidy_name okl_subsidies_b.name%TYPE
3158: ,x_return_status OUT NOCOPY VARCHAR2
3153:
3154: PROCEDURE is_balance_valid_after_add (p_subsidy_id okl_subsidies_b.id%TYPE,
3155: p_asset_id okc_k_lines_b.id%TYPE,
3156: p_subsidy_amount NUMBER,
3157: p_subsidy_name okl_subsidies_b.name%TYPE
3158: ,x_return_status OUT NOCOPY VARCHAR2
3159: ,x_msg_count OUT NOCOPY NUMBER
3160: ,x_msg_data OUT NOCOPY VARCHAR2
3161: ) IS
3169: kle_sub.SUBSIDY_OVERRIDE_AMOUNT))
3170: from okc_k_lines_b cleb_sub,
3171: okc_line_styles_b lseb_sub,
3172: okl_k_lines kle_sub,
3173: okl_subsidies_b sub
3174: where kle_sub.id = cleb_sub.id And
3175: cleb_sub.lse_id = lseb_sub.id And
3176: sub.id = kle_sub.subsidy_id And
3177: sub.subsidy_pool_id = p_subsidy_pool_id And
3197:
3198: --START: 24-Oct-2005 cklee - Fixed bug#4687505 |
3199: CURSOR c_subsidy_name_csr(p_subsidy_id number) IS
3200: select sub.name
3201: from okl_subsidies_b sub
3202: where sub.id = p_subsidy_id;
3203:
3204: l_subsidy_name okl_subsidies_b.name%TYPE;
3205: --END: 24-Oct-2005 cklee - Fixed bug#4687505 |
3200: select sub.name
3201: from okl_subsidies_b sub
3202: where sub.id = p_subsidy_id;
3203:
3204: l_subsidy_name okl_subsidies_b.name%TYPE;
3205: --END: 24-Oct-2005 cklee - Fixed bug#4687505 |
3206:
3207: cv_pool_amount c_get_pool_amount_csr%ROWTYPE;
3208:
3390: -- Version : 1.0
3391: -- History : 07-Dec-2005 cklee created
3392: -- End of comments
3393:
3394: PROCEDURE is_balance_valid_after_add (p_subsidy_id IN okl_subsidies_b.id%TYPE
3395: ,p_currency_code IN VARCHAR2
3396: ,p_subsidy_amount IN NUMBER
3397: ,p_tot_subsidy_amount IN NUMBER
3398: ,p_dnz_asset_number IN VARCHAR2
3410: WHERE id = p_subsidy_pool_id;
3411:
3412: CURSOR c_subsidy_name_csr(p_subsidy_id number) IS
3413: select sub.name
3414: from okl_subsidies_b sub
3415: where sub.id = p_subsidy_id;
3416:
3417: l_subsidy_name okl_subsidies_b.name%TYPE;
3418:
3413: select sub.name
3414: from okl_subsidies_b sub
3415: where sub.id = p_subsidy_id;
3416:
3417: l_subsidy_name okl_subsidies_b.name%TYPE;
3418:
3419: cv_pool_amount c_get_pool_amount_csr%ROWTYPE;
3420:
3421: lv_return_status VARCHAR2(1);
3559: x_return_status OUT NOCOPY VARCHAR2,
3560: p_subsidy_id IN NUMBER) IS
3561: cursor l_sub_csr (p_subsidy_id in number) is
3562: select 'Y'
3563: from okl_subsidies_b subb
3564: where subb.id = p_subsidy_id;
3565:
3566: l_exists varchar2(1) default 'N';
3567: BEGIN
3874: p_subsidy_id in number,
3875: p_subsidy_cle_id in number) is
3876: Select 'Y',
3877: subb.name
3878: from okl_subsidies_b subb
3879: where subb.id = p_subsidy_id
3880: and nvl(subb.exclusive_yn,'N') = 'Y'
3881: and exists (select '1'
3882: from okc_k_lines_b sub_cleb,
4065: p_subsidy_id in number,
4066: p_subsidy_cle_id in number) is
4067: Select 'Y',
4068: subb.name
4069: from okl_subsidies_b subb
4070: where subb.id = p_subsidy_id
4071: and nvl(subb.exclusive_yn,'N') = 'Y'
4072: and exists (select '1'
4073: from okc_k_lines_b sub_cleb,
4082: --cursor to check if subsidy attached is exclusive
4083: cursor l_exclusive_csr(p_asset_cle_id in number) is
4084: Select 'Y',
4085: subb.name
4086: from okl_subsidies_b subb,
4087: okc_k_lines_b sub_cleb,
4088: okc_line_styles_b sub_lseb,
4089: okl_k_lines sub_kleb
4090: where sub_cleb.cle_id = p_asset_cle_id
4098: -- cursor to check if multiple rows exist for
4099: -- a p_asset_cle_id ('FREE_FORM1')
4100: cursor l_exclusive_csr2(p_asset_cle_id in number) is
4101: select count(1)
4102: from okl_subsidies_b subb,
4103: okc_k_lines_b sub_cleb,
4104: okc_line_styles_b sub_lseb,
4105: okl_k_lines sub_kleb
4106: where sub_cleb.cle_id = p_asset_cle_id
4253: l_asset_number okc_k_lines_tl.name%TYPE;
4254:
4255: cursor l_sub_csr(p_subsidy_id in number) is
4256: select subb.name
4257: from okl_subsidies_b subb
4258: where id = p_subsidy_id;
4259:
4260: l_subsidy_name okl_subsidies_b.name%TYPE;
4261:
4256: select subb.name
4257: from okl_subsidies_b subb
4258: where id = p_subsidy_id;
4259:
4260: l_subsidy_name okl_subsidies_b.name%TYPE;
4261:
4262: begin
4263: -----
4264: x_return_status := OKL_API.G_RET_STS_SUCCESS;