2186: where cust_acct_site_id = p_address_id
2187: and site_use_code = 'BILL_TO';
2188: BEGIN
2189:
2190: arp_debug.debug('transaction_morg_exists +');
2191: arp_debug.debug(' p_customer_id:'||p_customer_id);
2192: --
2193: BEGIN
2194:
2187: and site_use_code = 'BILL_TO';
2188: BEGIN
2189:
2190: arp_debug.debug('transaction_morg_exists +');
2191: arp_debug.debug(' p_customer_id:'||p_customer_id);
2192: --
2193: BEGIN
2194:
2195: -- check the flag: allow change to printed transaction is set to 'Y' or 'N'
2204: -- bill_to_site_use_id and ship_to_site_use_id. We have avoided this by using
2205: -- site_use_id (bill/ship) in conjunction with customer_id.
2206:
2207: BEGIN
2208: arp_debug.debug('transaction_morg_exists.p_address_id: ' || p_address_id);
2209: select change_printed_invoice_flag
2210: into check_value
2211: from ar_system_parameters_all
2212: where org_id =
2216: EXCEPTION
2217: WHEN NO_DATA_FOUND THEN
2218: FND_MESSAGE.SET_NAME( 'AR','AR_NO_ROW_IN_SYSTEM_PARAMETERS');
2219: FND_MSG_PUB.ADD;
2220: arp_debug.debug(' EXCEPTION AR_NO_ROW_IN_SYSTEM_PARAMETERS in transaction_morg_exists ');
2221: END ;
2222: arp_debug.debug(' check_value :'||check_value);
2223:
2224: IF check_value = 'Y' THEN
2218: FND_MESSAGE.SET_NAME( 'AR','AR_NO_ROW_IN_SYSTEM_PARAMETERS');
2219: FND_MSG_PUB.ADD;
2220: arp_debug.debug(' EXCEPTION AR_NO_ROW_IN_SYSTEM_PARAMETERS in transaction_morg_exists ');
2221: END ;
2222: arp_debug.debug(' check_value :'||check_value);
2223:
2224: IF check_value = 'Y' THEN
2225: arp_debug.debug('transaction_morg_exists - RESULT : FALSE');
2226: RETURN (FALSE);
2221: END ;
2222: arp_debug.debug(' check_value :'||check_value);
2223:
2224: IF check_value = 'Y' THEN
2225: arp_debug.debug('transaction_morg_exists - RESULT : FALSE');
2226: RETURN (FALSE);
2227: END IF;
2228: --
2229: for i in ship_to_site
2229: for i in ship_to_site
2230: loop
2231: --
2232: BEGIN
2233: arp_debug.debug(' cursor SHIP_TO_SITE site_use_id retrieved:'||i.site_use_id);
2234: select 'x'
2235: into invoice_count
2236: from dual
2237: where exists ( select 'y'
2262: and ct.ship_to_customer_id = p_customer_id
2263: and ct.ship_to_site_use_id = i.site_use_id
2264: );
2265:
2266: arp_debug.debug(' find existing data meeting existing of trx with posted or with activity or printed for ship_to site');
2267: arp_debug.debug('transaction_morg_exists RESULT : TRUE -');
2268: RETURN (TRUE);
2269: exit;
2270: --Bug Fix :1552964
2263: and ct.ship_to_site_use_id = i.site_use_id
2264: );
2265:
2266: arp_debug.debug(' find existing data meeting existing of trx with posted or with activity or printed for ship_to site');
2267: arp_debug.debug('transaction_morg_exists RESULT : TRUE -');
2268: RETURN (TRUE);
2269: exit;
2270: --Bug Fix :1552964
2271: EXCEPTION
2278: --
2279: for j in bill_to_site
2280:
2281: loop
2282: arp_debug.debug(' cursor BILL_TO_SITE site_use_id retrieved:'||j.site_use_id);
2283: select 'x'
2284: into invoice_count
2285: from dual
2286: where exists ( select 'y'
2311: and ct.bill_to_customer_id = p_customer_id
2312: and ct.bill_to_site_use_id = j.site_use_id
2313: );
2314:
2315: arp_debug.debug(' find existing data meeting existing of trx with posted or with activity or printed for bill_to site');
2316: arp_debug.debug('transaction_morg_exists RESULT : TRUE -');
2317: RETURN (TRUE);
2318: exit;
2319:
2312: and ct.bill_to_site_use_id = j.site_use_id
2313: );
2314:
2315: arp_debug.debug(' find existing data meeting existing of trx with posted or with activity or printed for bill_to site');
2316: arp_debug.debug('transaction_morg_exists RESULT : TRUE -');
2317: RETURN (TRUE);
2318: exit;
2319:
2320: end loop;
2321: --
2322: end if;
2323: EXCEPTION
2324: WHEN NO_DATA_FOUND THEN
2325: arp_debug.debug('No Ship To or Bill To SITE with posted trx or trx with activity or printed invoice');
2326: arp_debug.debug('transaction_morg_exists RESULT : FALSE -');
2327: RETURN (FALSE);
2328: --
2329: END;
2322: end if;
2323: EXCEPTION
2324: WHEN NO_DATA_FOUND THEN
2325: arp_debug.debug('No Ship To or Bill To SITE with posted trx or trx with activity or printed invoice');
2326: arp_debug.debug('transaction_morg_exists RESULT : FALSE -');
2327: RETURN (FALSE);
2328: --
2329: END;
2330:
2329: END;
2330:
2331: --
2332: if invoice_count is NULL then
2333: arp_debug.debug('No Ship To or Bill To SITE found');
2334: arp_debug.debug('transaction_morg_exists RESULT : FALSE -');
2335: RETURN (FALSE);
2336: end if;
2337: --
2330:
2331: --
2332: if invoice_count is NULL then
2333: arp_debug.debug('No Ship To or Bill To SITE found');
2334: arp_debug.debug('transaction_morg_exists RESULT : FALSE -');
2335: RETURN (FALSE);
2336: end if;
2337: --
2338: END transaction_morg_exists;
2426: END LOOP;
2427: close c_org_for_loc;
2428: /*End bug 4605384*/
2429:
2430: arp_debug.debug(' check_value:'||check_value);
2431: -- if check_value = 'Y' no processing required user can update addresses
2432:
2433: IF check_value = 'N' THEN
2434:
2439: x_exist_loc_rec => l_exist_location,
2440: x_loc_updated => loc_modified );
2441: --}
2442: --
2443: arp_debug.debug(' loc_modified:'||loc_modified);
2444:
2445: -- any transaction printed with this location
2446: IF loc_modified = 'Y' THEN
2447: --