[Home] [Help]
2088: WHERE fcc.enabled_flag = 'Y'
2089: AND fcc.set_of_books_id = c_ledger_id
2090: AND hzca.status = 'A'
2091: AND EXISTS (SELECT 'x'
2092: FROM fv_cust_finance_chrgs
2093: WHERE hzca.cust_account_id = customer_id
2094: AND fcc.charge_id = charge_id
2095: AND set_of_books_id = c_ledger_id)
2096: AND NOT EXISTS (SELECT 'x'
2147:
2148: -- commented the below UPDATE statement and added 3new UPDATE statements
2149:
2150:
2151: /* UPDATE fv_cust_finance_chrgs
2152: SET waive_flag = 'Y'
2153: WHERE customer_id = customer.customer_id
2154: AND charge_id NOT IN (SELECT charge_id
2155: FROM fv_finance_chrg_cust_classes,
2159: AND enabled_flag = 'Y'
2160: AND set_of_books_id = g_set_of_books_id);*/
2161:
2162: /* Commented for bug 9089029
2163: UPDATE fv_cust_finance_chrgs a
2164: SET CUSTOMER_CLASS_CODE = customer.cust_class_code,
2165: finance_charge_group_hdr_id = (SELECT finance_charge_group_hdr_id
2166: FROM fv_finance_chrg_cust_classes b
2167: WHERE customer_class= customer.cust_class_code
2173: AND a.set_of_books_id = c.set_of_books_id)
2174: AND customer_id = customer.customer_id;
2175: */
2176:
2177: UPDATE fv_cust_finance_chrgs
2178: SET waive_flag = 'Y'
2179: WHERE customer_id = customer.customer_id
2180: AND charge_id NOT IN (SELECT fcf.charge_id
2181: FROM fv_cust_finance_chrgs fcf,
2177: UPDATE fv_cust_finance_chrgs
2178: SET waive_flag = 'Y'
2179: WHERE customer_id = customer.customer_id
2180: AND charge_id NOT IN (SELECT fcf.charge_id
2181: FROM fv_cust_finance_chrgs fcf,
2182: fv_finance_chrg_cust_classes fcfc,
2183: hz_cust_accounts hzca,
2184: fv_finance_charge_grp_hdrs fcgh,
2185: fv_finance_charge_grp_dtls fcgd
2196: AND fcgd.start_date <= sysdate
2197: AND decode(fcgd.end_date,null,sysdate,fcgd.end_date) >= sysdate
2198: AND fcgd.base_charge_id = 0);
2199:
2200: UPDATE fv_cust_finance_chrgs
2201: SET waive_flag = 'N'
2202: WHERE customer_id = customer.customer_id
2203: AND charge_id IN (SELECT fcf.charge_id
2204: FROM fv_cust_finance_chrgs fcf,
2200: UPDATE fv_cust_finance_chrgs
2201: SET waive_flag = 'N'
2202: WHERE customer_id = customer.customer_id
2203: AND charge_id IN (SELECT fcf.charge_id
2204: FROM fv_cust_finance_chrgs fcf,
2205: fv_finance_chrg_cust_classes fcfc,
2206: hz_cust_accounts hzca,
2207: fv_finance_charge_grp_hdrs fcgh,
2208: fv_finance_charge_grp_dtls fcgd
2223: EXCEPTION
2224: WHEN OTHERS THEN
2225: p_retcode := g_FAILURE;
2226: p_errbuf := SQLERRM;
2227: l_location := l_module_name||'.update_fv_cust_finance_chrgs';
2228: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,l_location) ;
2229: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,p_errbuf) ;
2230: END;
2231: END LOOP;
2238: -- and old customer classes are assigned to the same finance charge group.
2239: -- To avoid this error, delete the previous customer finance charge
2240: -- assignment.
2241: BEGIN
2242: DELETE FROM fv_cust_finance_chrgs WHERE
2243: customer_id IN
2244: (SELECT hzca.cust_account_id
2245: FROM hz_cust_accounts hzca,
2246: fv_finance_charge_controls fcc,
2260: AND fcgh.ledger_id = g_set_of_books_id
2261: AND fccc.enabled_flag = 'Y'
2262: AND fcgd.base_charge_id = 0
2263: AND EXISTS (SELECT 'x'
2264: FROM fv_cust_finance_chrgs_all fcfc
2265: WHERE hzca.cust_account_id = fcfc.customer_id
2266: AND fcc.charge_id = fcfc.charge_id
2267: AND fcgd.finance_charge_group_hdr_id = fcfc.finance_charge_group_hdr_id
2268: AND fcfc.customer_class_code <> fccc.customer_class
2270: EXCEPTION
2271: WHEN OTHERS THEN
2272: p_retcode := g_FAILURE;
2273: p_errbuf := SQLERRM;
2274: l_location := l_module_name||'.delete_fv_cust_finance_chrgs';
2275: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,l_location) ;
2276: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,p_errbuf) ;
2277: END;
2278:
2276: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,p_errbuf) ;
2277: END;
2278:
2279: BEGIN
2280: INSERT INTO fv_cust_finance_chrgs
2281: (
2282: customer_id,
2283: charge_id,
2284: waive_flag,
2326: AND fcgh.ledger_id = g_set_of_books_id
2327: AND fccc.enabled_flag = 'Y'
2328: AND fcgd.base_charge_id = 0
2329: AND NOT EXISTS (SELECT 'x'
2330: FROM fv_cust_finance_chrgs fcfc
2331: WHERE hzca.cust_account_id = fcfc.customer_id
2332: AND fcc.charge_id = fcfc.charge_id
2333: AND fcgd.finance_charge_group_hdr_id = fcfc.finance_charge_group_hdr_id
2334: and fcfc.customer_class_code = fccc.customer_class
2336: EXCEPTION
2337: WHEN OTHERS THEN
2338: p_retcode := g_FAILURE;
2339: p_errbuf := SQLERRM;
2340: l_location := l_module_name||'.insert_fv_cust_finance_chrgs';
2341: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,l_location) ;
2342: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,p_errbuf) ;
2343: END;
2344: END IF;
2408: FROM fv_finance_charge_controls
2409: WHERE set_of_books_id = g_set_of_books_id)*/
2410:
2411: AND EXISTS (SELECT 'x'
2412: FROM fv_cust_finance_chrgs fcfc
2413: WHERE ract.bill_to_customer_id = fcfc.customer_id
2414: AND fcfc.enabled_flag = 'Y'
2415: AND fcfc.waive_flag = 'N')
2416: AND NOT EXISTS (SELECT 'x'
2420: EXCEPTION
2421: WHEN OTHERS THEN
2422: p_retcode := g_FAILURE;
2423: p_errbuf := SQLERRM;
2424: l_location := l_module_name||'.insert_fv_cust_finance_chrgs';
2425: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,l_location) ;
2426: fv_utility.log_mesg(fnd_log.level_unexpected, l_location,p_errbuf) ;
2427: END;
2428: END IF;
2461: fcgh.finance_charge_group_hdr_id,
2462: fcgd.finance_charge_group_dtl_id,
2463: 'Y'
2464: FROM ra_customer_trx ract,
2465: fv_cust_finance_chrgs fcfc,
2466: fv_finance_charge_controls fcc,
2467: ra_cust_trx_types rctt,
2468: fv_finance_charge_grp_dtls fcgd,
2469: fv_finance_charge_grp_hdrs fcgh