The following lines contain the word 'select', 'insert', 'update' or 'delete':
Column 2 : update_allowed Varchar2(1) field with the values Y or N signifying if the field should be accessible
to the user.
Parameters IN
pbr_module : Varchar2(30) The forms module which contains fields for control.
Call this function in the WHEN-NEW-FORM-INSTANCE trigger of the form which uses this pl sql table
*/
-- ==========================================================================================================================
function get_all_items(pbr_module IN VARCHAR2) RETURN blockitemtabtyp IS
i INTEGER;
/* We need to reset all of the items back to being nonupdateble */
newstatus:=pbr_blockitem;
newstatus(i).update_allowed:='N';
IF brstate(i).update_allowed IN ('N')
THEN NULL;
IF newstatus(j).update_allowed in ('N' , 'Y') THEN
newstatus(j).update_allowed:=brstate(i).update_allowed;
IF brstate(i).update_allowed IN ('Y') THEN NULL;
newstatus(j).update_allowed:='N';
brstate(236).update_allowed:='M';
brstate(238).update_allowed:='M';
brstate(239).update_allowed:='N';
brstate(235).update_allowed:='N';
brstate(237).update_allowed:='N';
brstate(241).update_allowed:='N';
brstate(233).update_allowed:='N';
brstate(234).update_allowed:='N';
brstate(242).update_allowed:='N';
brstate(240).update_allowed:='N';
brstate(232).update_allowed:='N';
brstate(49).update_allowed:='N';
brstate(51).update_allowed:='N';
brstate(52).update_allowed:='N';
brstate(48).update_allowed:='N';
brstate(50).update_allowed:='N';
brstate(54).update_allowed:='N';
brstate(46).update_allowed:='N';
brstate(47).update_allowed:='N';
brstate(55).update_allowed:='N';
brstate(53).update_allowed:='N';
brstate(45).update_allowed:='N';
brstate(115).update_allowed:='Y';
brstate(117).update_allowed:='Y';
brstate(118).update_allowed:='N';
brstate(114).update_allowed:='N';
brstate(116).update_allowed:='N';
brstate(120).update_allowed:='N';
brstate(112).update_allowed:='N';
brstate(113).update_allowed:='N';
brstate(121).update_allowed:='N';
brstate(119).update_allowed:='N';
brstate(111).update_allowed:='N';
brstate(82).update_allowed:='Y';
brstate(84).update_allowed:='Y';
brstate(85).update_allowed:='Y';
brstate(81).update_allowed:='Y';
brstate(83).update_allowed:='Y';
brstate(87).update_allowed:='Y';
brstate(79).update_allowed:='Y';
brstate(80).update_allowed:='Y';
brstate(88).update_allowed:='Y';
brstate(86).update_allowed:='Y';
brstate(78).update_allowed:='Y';
brstate(181).update_allowed:='Y';
brstate(183).update_allowed:='Y';
brstate(184).update_allowed:='Y';
brstate(180).update_allowed:='Y';
brstate(182).update_allowed:='Y';
brstate(186).update_allowed:='Y';
brstate(178).update_allowed:='Y';
brstate(179).update_allowed:='Y';
brstate(187).update_allowed:='Y';
brstate(185).update_allowed:='Y';
brstate(177).update_allowed:='Y';
brstate(71).update_allowed:='Y';
brstate(73).update_allowed:='N';
brstate(74).update_allowed:='N';
brstate(70).update_allowed:='N';
brstate(72).update_allowed:='N';
brstate(76).update_allowed:='N';
brstate(68).update_allowed:='N';
brstate(69).update_allowed:='N';
brstate(77).update_allowed:='N';
brstate(75).update_allowed:='N';
brstate(67).update_allowed:='N';
brstate(192).update_allowed:='M';
brstate(194).update_allowed:='N';
brstate(195).update_allowed:='N';
brstate(191).update_allowed:='N';
brstate(193).update_allowed:='N';
brstate(197).update_allowed:='N';
brstate(189).update_allowed:='N';
brstate(190).update_allowed:='N';
brstate(198).update_allowed:='N';
brstate(196).update_allowed:='N';
brstate(188).update_allowed:='N';
brstate(203).update_allowed:='M';
brstate(205).update_allowed:='N';
brstate(206).update_allowed:='N';
brstate(202).update_allowed:='N';
brstate(204).update_allowed:='N';
brstate(208).update_allowed:='N';
brstate(200).update_allowed:='N';
brstate(201).update_allowed:='N';
brstate(209).update_allowed:='N';
brstate(207).update_allowed:='N';
brstate(199).update_allowed:='N';
brstate(38).update_allowed:='M';
brstate(40).update_allowed:='N';
brstate(41).update_allowed:='N';
brstate(37).update_allowed:='N';
brstate(39).update_allowed:='N';
brstate(43).update_allowed:='N';
brstate(35).update_allowed:='N';
brstate(36).update_allowed:='N';
brstate(44).update_allowed:='N';
brstate(42).update_allowed:='N';
brstate(34).update_allowed:='N';
brstate(93).update_allowed:='Y';
brstate(95).update_allowed:='N';
brstate(96).update_allowed:='N';
brstate(92).update_allowed:='N';
brstate(94).update_allowed:='N';
brstate(98).update_allowed:='N';
brstate(90).update_allowed:='N';
brstate(91).update_allowed:='N';
brstate(99).update_allowed:='N';
brstate(97).update_allowed:='N';
brstate(89).update_allowed:='N';
brstate(214).update_allowed:='Y';
brstate(216).update_allowed:='N';
brstate(217).update_allowed:='N';
brstate(213).update_allowed:='N';
brstate(215).update_allowed:='N';
brstate(219).update_allowed:='N';
brstate(211).update_allowed:='N';
brstate(212).update_allowed:='N';
brstate(220).update_allowed:='N';
brstate(218).update_allowed:='N';
brstate(210).update_allowed:='N';
brstate(225).update_allowed:='M';
brstate(227).update_allowed:='M';
brstate(228).update_allowed:='N';
brstate(224).update_allowed:='N';
brstate(226).update_allowed:='N';
brstate(230).update_allowed:='N';
brstate(222).update_allowed:='N';
brstate(223).update_allowed:='N';
brstate(231).update_allowed:='N';
brstate(229).update_allowed:='N';
brstate(221).update_allowed:='N';
brstate(170).update_allowed:='Y';
brstate(172).update_allowed:='Y';
brstate(173).update_allowed:='Y';
brstate(169).update_allowed:='N';
brstate(171).update_allowed:='N';
brstate(175).update_allowed:='N';
brstate(167).update_allowed:='N';
brstate(168).update_allowed:='N';
brstate(176).update_allowed:='Y';
brstate(174).update_allowed:='Y';
brstate(166).update_allowed:='N';
brstate(159).update_allowed:='Y';
brstate(161).update_allowed:='Y';
brstate(162).update_allowed:='Y';
brstate(158).update_allowed:='Y';
brstate(160).update_allowed:='Y';
brstate(164).update_allowed:='Y';
brstate(156).update_allowed:='Y';
brstate(157).update_allowed:='Y';
brstate(165).update_allowed:='Y';
brstate(163).update_allowed:='Y';
brstate(155).update_allowed:='Y';
brstate(27).update_allowed:='Y';
brstate(29).update_allowed:='Y';
brstate(30).update_allowed:='Y';
brstate(26).update_allowed:='N';
brstate(28).update_allowed:='N';
brstate(32).update_allowed:='N';
brstate(24).update_allowed:='N';
brstate(25).update_allowed:='N';
brstate(33).update_allowed:='Y';
brstate(31).update_allowed:='N';
brstate(23).update_allowed:='N';
brstate(16).update_allowed:='Y';
brstate(18).update_allowed:='Y';
brstate(19).update_allowed:='Y';
brstate(15).update_allowed:='N';
brstate(17).update_allowed:='N';
brstate(21).update_allowed:='N';
brstate(13).update_allowed:='N';
brstate(14).update_allowed:='N';
brstate(22).update_allowed:='Y';
brstate(20).update_allowed:='N';
brstate(12).update_allowed:='N';
brstate(247).update_allowed:='Y';
brstate(249).update_allowed:='Y';
brstate(250).update_allowed:='Y';
brstate(246).update_allowed:='N';
brstate(248).update_allowed:='N';
brstate(252).update_allowed:='N';
brstate(244).update_allowed:='N';
brstate(245).update_allowed:='N';
brstate(253).update_allowed:='Y';
brstate(251).update_allowed:='N';
brstate(243).update_allowed:='N';
brstate(5).update_allowed:='Y';
brstate(7).update_allowed:='Y';
brstate(8).update_allowed:='Y';
brstate(4).update_allowed:='N';
brstate(6).update_allowed:='N';
brstate(10).update_allowed:='N';
brstate(2).update_allowed:='N';
brstate(3).update_allowed:='N';
brstate(11).update_allowed:='Y';
brstate(9).update_allowed:='N';
brstate(1).update_allowed:='N';
brstate(148).update_allowed:='Y';
brstate(150).update_allowed:='Y';
brstate(151).update_allowed:='Y';
brstate(147).update_allowed:='Y';
brstate(149).update_allowed:='Y';
brstate(153).update_allowed:='N';
brstate(145).update_allowed:='Y';
brstate(146).update_allowed:='Y';
brstate(154).update_allowed:='Y';
brstate(152).update_allowed:='Y';
brstate(144).update_allowed:='Y';
brstate(126).update_allowed:='Y';
brstate(128).update_allowed:='Y';
brstate(129).update_allowed:='Y';
brstate(125).update_allowed:='Y';
brstate(127).update_allowed:='N';
brstate(131).update_allowed:='N';
brstate(123).update_allowed:='N';
brstate(124).update_allowed:='N';
brstate(132).update_allowed:='Y';
brstate(130).update_allowed:='N';
brstate(122).update_allowed:='N';
brstate(60).update_allowed:='M';
brstate(62).update_allowed:='N';
brstate(63).update_allowed:='N';
brstate(59).update_allowed:='N';
brstate(61).update_allowed:='N';
brstate(65).update_allowed:='N';
brstate(57).update_allowed:='N';
brstate(58).update_allowed:='N';
brstate(66).update_allowed:='N';
brstate(64).update_allowed:='N';
brstate(56).update_allowed:='N';
brstate(104).update_allowed:='M';
brstate(106).update_allowed:='N';
brstate(107).update_allowed:='N';
brstate(103).update_allowed:='N';
brstate(105).update_allowed:='N';
brstate(109).update_allowed:='N';
brstate(101).update_allowed:='N';
brstate(102).update_allowed:='N';
brstate(110).update_allowed:='N';
brstate(108).update_allowed:='N';
brstate(100).update_allowed:='N';
brstate(137).update_allowed:='M';
brstate(139).update_allowed:='N';
brstate(140).update_allowed:='N';
brstate(136).update_allowed:='N';
brstate(138).update_allowed:='N';
brstate(142).update_allowed:='N';
brstate(134).update_allowed:='N';
brstate(135).update_allowed:='N';
brstate(143).update_allowed:='N';
brstate(141).update_allowed:='N';
brstate(133).update_allowed:='N';
brstate( 254).update_allowed:='Y';
brstate( 255).update_allowed:='Y';
brstate( 256).update_allowed:='Y';
brstate( 257).update_allowed:='M';
brstate( 258).update_allowed:='M';
brstate( 259).update_allowed:='M';
brstate( 260).update_allowed:='Y';
brstate( 261).update_allowed:='Y';
brstate( 262).update_allowed:='M';
brstate( 263).update_allowed:='M';
brstate( 264).update_allowed:='Y';
brstate( 265).update_allowed:='Y';
brstate( 266).update_allowed:='M';
brstate( 267).update_allowed:='Y';
brstate( 268).update_allowed:='Y';
brstate( 269).update_allowed:='Y';
brstate( 270).update_allowed:='Y';
brstate( 271).update_allowed:='M';
brstate( 272).update_allowed:='M';
brstate( 273).update_allowed:='Y';
brstate( 274).update_allowed:='M';
brstate( 275).update_allowed:='M';
brstate( 276).update_allowed:='Y';
brstate( 277).update_allowed:='N';
brstate( 278).update_allowed:='N';
brstate( 279).update_allowed:='Y';
brstate( 280).update_allowed:='N';
brstate( 281).update_allowed:='N';
brstate( 282).update_allowed:='N';
brstate( 283).update_allowed:='Y';
brstate( 284).update_allowed:='N';
brstate( 285).update_allowed:='Y';
brstate( 286).update_allowed:='N';
brstate( 287).update_allowed:='Y';
brstate( 288).update_allowed:='Y';
brstate( 289).update_allowed:='N';
brstate( 290).update_allowed:='N';
brstate( 291).update_allowed:='N';
brstate( 292).update_allowed:='N';
brstate( 293).update_allowed:='N';
brstate( 294).update_allowed:='Y';
brstate( 295).update_allowed:='Y';
brstate( 296).update_allowed:='Y';
brstate( 297).update_allowed:='Y';
brstate( 298).update_allowed:='N';
brstate( 299).update_allowed:='N';
brstate( 300).update_allowed:='Y';
brstate( 301).update_allowed:='Y';
brstate( 302).update_allowed:='Y';
brstate( 303).update_allowed:='Y';
brstate( 304).update_allowed:='N';
brstate( 305).update_allowed:='N';
brstate( 306).update_allowed:='N';
brstate( 307).update_allowed:='N';
brstate( 308).update_allowed:='Y';
brstate( 309).update_allowed:='N';
brstate( 310).update_allowed:='N';
brstate( 311).update_allowed:='N';
brstate( 312).update_allowed:='Y';
brstate( 313).update_allowed:='N';
brstate( 314).update_allowed:='Y';
brstate( 315).update_allowed:='N';
brstate( 316).update_allowed:='Y';
brstate( 317).update_allowed:='Y';
brstate( 318).update_allowed:='N';
brstate( 319).update_allowed:='N';
brstate( 320).update_allowed:='N';
brstate( 321).update_allowed:='N';
brstate( 322).update_allowed:='N';
brstate( 323).br_state:='SELECTED';
brstate( 323).update_allowed:='N';
brstate( 324).br_state:='SELECTED';
brstate( 324).update_allowed:='N';
brstate( 325).br_state:='SELECTED';
brstate( 325).update_allowed:='N';
brstate( 326).br_state:='SELECTED';
brstate( 326).update_allowed:='N';
brstate( 327).br_state:='SELECTED';
brstate( 327).update_allowed:='N';
brstate( 328).br_state:='SELECTED';
brstate( 328).update_allowed:='N';
brstate( 329).br_state:='SELECTED';
brstate( 329).update_allowed:='N';
brstate( 330).br_state:='SELECTED';
brstate( 330).update_allowed:='N';
brstate( 331).br_state:='SELECTED';
brstate( 331).update_allowed:='Y';
brstate( 332).br_state:='SELECTED';
brstate( 332).update_allowed:='N';
brstate( 333).br_state:='SELECTED';
brstate( 333).update_allowed:='N';
brstate( 334).br_state:='SELECTED';
brstate( 334).update_allowed:='N';
brstate( 335).br_state:='SELECTED';
brstate( 335).update_allowed:='N';
brstate( 336).br_state:='SELECTED';
brstate( 336).update_allowed:='N';
brstate( 337).br_state:='SELECTED';
brstate( 337).update_allowed:='Y';
brstate( 338).br_state:='SELECTED';
brstate( 338).update_allowed:='N';
brstate( 339).br_state:='SELECTED';
brstate( 339).update_allowed:='N';
brstate( 340).br_state:='SELECTED';
brstate( 340).update_allowed:='Y';
brstate( 341).br_state:='SELECTED';
brstate( 341).update_allowed:='N';
brstate( 342).br_state:='SELECTED';
brstate( 342).update_allowed:='N';
brstate( 343).br_state:='SELECTED';
brstate( 343).update_allowed:='N';
brstate( 344).br_state:='SELECTED';
brstate( 344).update_allowed:='N';
brstate( 345).br_state:='SELECTED';
brstate( 345).update_allowed:='N';
Cursor Cposted (CustomerTrxId NUMBER) IS SELECT
customer_trx_id
from ar_transaction_history
where customer_trx_id = CUSTOMERTRXID
and posting_control_id <> -3
and gl_posted_date IS NOT NULL;
FUNCTION br_selected(p_customer_trx_id in number) return VARCHAR2 IS
cursor Cselremit(CustomerTrxId NUMBER)
IS SELECT
customer_trx_id
FROM
ar_batches b ,
ar_payment_schedules p
where p.customer_trx_id = CUSTOMERTRXID
and p.reserved_type = 'REMITTANCE'
and p.reserved_value=b.batch_id
and b.status='OP';
RETURN 'SELECTED';
END br_selected;
/* modified for tca update */
/* bug 1637367 Removed ; introduced in 115.11 (modifications for TCA update) */
'Select
TRX.trx_number,
TRX.doc_sequence_value,
TRX.trx_date,
TRX.comments,
TRX.purchase_order,
TRX.invoice_currency_code,
LINES.customer_trx_id,
NULL,
PAYS.amount_due_original,
PAYS.amount_due_remaining,
PAYS.acctd_amount_due_remaining,
PAYS.due_date,
PAYS.exchange_rate,
PAYS.terms_sequence_number,
PARTY.jgzz_fiscal_code,
CUST_ACCT.account_number,
substrb(party.party_name,1,50),
CUST_ACCT.customer_class_code,
PARTY.category_code,
ARPT_SQL_FUNC_UTIL.get_lookup_meaning(''CUSTOMER_CATEGORY'', party.category_code),
ARPT_SQL_FUNC_UTIL.get_trx_type_details(TRX.cust_trx_type_id,''NAME''),
ARPT_SQL_FUNC_UTIL.get_lookup_meaning(''INV/CM'', types.type),
ARPT_SQL_FUNC_UTIL.get_trx_type_details(TRX.cust_trx_type_id,''TYPE''),
METH.name,
METH.receipt_method_id,
SITE.location,
TRX.bill_to_site_use_id,
ABB.bank_name,
ABB.branch_party_id bank_branch_id,
ABA.bank_account_id,
CONS.cons_billing_number,
CONS.cons_inv_id,
LINES.br_ref_customer_trx_id,
LINES.br_ref_payment_schedule_id,
LINES.extended_amount,
LINES.extended_acctd_amount,
LINES.customer_trx_line_id
FROM
RA_CUSTOMER_TRX TRX ,
RA_CUST_TRX_TYPES TYPES,
AR_PAYMENT_SCHEDULES PAYS ,
HZ_CUST_ACCOUNTS CUST_ACCT ,
HZ_PARTIES PARTY,
AR_RECEIPT_METHODS METH,
CE_BANK_BRANCHES_V ABB,
HZ_CUST_SITE_USES SITE,
AP_BANK_ACCOUNTS ABA,
RA_CUSTOMER_TRX_LINES LINES ,
AR_CONS_INV_ALL CONS
WHERE trx.legal_entity_id = ' || p_le_id ||
' and trx.bill_to_customer_id = cust_acct.cust_account_id
and trx.cust_trx_type_id = types.cust_trx_type_id
and cust_acct.party_id = party.party_id
and trx.customer_trx_id = pays.customer_trx_id
and pays.payment_schedule_id = lines.br_ref_payment_schedule_id
and site.site_use_id = trx.bill_to_site_use_id
and trx.customer_bank_account_id = aba.bank_account_id (+)
and aba.bank_branch_id = abb.branch_party_id (+)
and cons.cons_inv_id(+) = pays.cons_inv_id
and trx.receipt_method_id = meth.receipt_method_id (+)
and lines.customer_trx_id = '|| Customer_trx_id;
arp_util.debug( 'Inserting the existing assignments into the table ');
select '''' || invoice_currency_code ||'''',
'to_dat'||'e(''' ||trx_date||''')'
into br_currency,
br_trxdate
from ra_customer_trx
where customer_trx_id = br_trxid;
arp_util.debug( 'Inserting the new assignments ');
/* modified for tca update */
/* bug7046838 : Modified the query for performance improvement. */
AssignCurStr:=
'Select
TRX.trx_number,
TRX.doc_sequence_value,
TRX.trx_date,
TRX.comments,
TRX.purchase_order,
TRX.invoice_currency_code,
NULL,
NULL,
PAYS.amount_due_original,
-- bug 2473700 NULL,
PAYS.amount_due_remaining,
NULL,
PAYS.due_date,
PAYS.exchange_rate,
PAYS.terms_sequence_number,
PARTY.jgzz_fiscal_code,
CUST_ACCT.account_number,
substrb(PARTY.PARTY_name,1,50),
CUST_ACCT.customer_class_code,
PARTY.category_code,
ARPT_SQL_FUNC_UTIL.get_lookup_meaning(''CUSTOMER_CATEGORY'', party.category_code),
ARPT_SQL_FUNC_UTIL.get_trx_type_details(TRX.cust_trx_type_id,''NAME''),
ARPT_SQL_FUNC_UTIL.get_lookup_meaning(''INV/CM'', types.type),
ARPT_SQL_FUNC_UTIL.get_trx_type_details(TRX.cust_trx_type_id,''TYPE''),
METH.name,
METH.receipt_method_id,
SITE.location,
TRX.bill_to_site_use_id,
ABB.bank_name,
ABB.branch_party_id bank_branch_id,
ABA.bank_account_id,
NULL,
NULL,
TRX.customer_trx_id, /* br_ref_customer_trx_id */
PAYS.payment_schedule_id, /* br_ref_payment_schedule_id */
PAYS.amount_due_remaining, /* Extended Amount */
PAYS.acctd_amount_due_remaining, /* Extended Acctd Amount */
NULL /* Customer_trx_line_id */
FROM
RA_CUST_TRX_TYPES TYPES,
RA_CUSTOMER_TRX TRX ,
AR_PAYMENT_SCHEDULES PAYS ,
HZ_CUST_ACCOUNTS CUST_ACCT ,
HZ_PARTIES PARTY,
AR_receipt_METHODS METH,
CE_BANK_BRANCHES_V ABB,
HZ_CUST_SITE_USES SITE,
ap_bank_accounts ABA
where trx.legal_entity_id = ' || p_le_id ||
' and decode(pays.class,''BR'', TRX.drawee_id, TRX.bill_to_customer_id) = cust_acct.cust_account_id
and CUST_ACCT.party_id = PARTY.party_id
and TRX.customer_trx_id = PAYS.customer_trx_id
and TRX.cust_trx_type_id = TYPES.cust_trx_type_id
and PAYS.reserved_type IS NULL
and PAYS.amount_due_remaining <> 0
and SITE.SITE_USE_ID = TRX.BILL_TO_SITE_USE_ID
and TRX.CUSTOMER_BANK_ACCOUNT_ID = ABA.BANK_ACCOUNT_ID (+)
and ABA.BANK_BRANCH_ID = ABB.branch_party_id (+)
and trx.receipt_method_id = meth.receipt_method_id (+)
and PAYS.selected_for_receipt_batch_id is null
and not exists
(select 1
from ra_customer_trx_lines sub,
ar_payment_schedules ps
where sub.br_ref_customer_trx_id = TRX.customer_trx_id
and ps.customer_trx_id = trx.customer_trx_id
and ( ( ps.amount_due_remaining = 0 and
sub.customer_trx_id <> ' || customer_trx_id || ' )' ||
' OR (sub.customer_trx_id = ' || customer_trx_id || ' )))' ||
' and trx.invoice_currency_code = ' || br_currency ||
' and trx.trx_date <= ' || br_trxdate;
/* modified for tca update */
if PAY_UNRELATED_INVOICES = 'N' THEN
AssignCurStr := AssignCurStr ||
' and trx.bill_to_customer_id in (
SELECT rr.related_cust_account_id
FROM hz_cust_acct_relate rr
WHERE rr.cust_account_id = ' || drawee_id ||
' and rr.related_cust_account_id = trx.bill_to_customer_id
and rr.bill_to_flag = ''Y'' ' ||
' UNION ' ||
' SELECT ' || drawee_id || ' from dual ' ||
' UNION ' ||
' SELECT rel.related_cust_account_id
FROM ar_paying_relationships_v rel,
hz_cust_accounts acc
WHERE rel.party_id = acc.party_id
AND rel.related_cust_account_id = trx.bill_to_customer_id
AND acc.cust_account_id = ' || drawee_id ||
' AND ' || br_trxdate || ' BETWEEN effective_start_date
AND effective_end_date) ';
/* modified for tca update */
AssignCurStr:=AssignCurStr||
'UNION Select
TRX.trx_number,
TRX.doc_sequence_value,
TRX.trx_date,
TRX.comments,
TRX.purchase_order,
TRX.invoice_currency_code,
NULL,
NULL,
PAYS.amount_due_original,
-- Bug 2473700 NULL,
PAYS.amount_due_remaining,
NULL,
PAYS.due_date,
PAYS.exchange_rate,
PAYS.terms_sequence_number,
PARTY.jgzz_fiscal_code,
CUST_ACCT.account_number,
substrb(party.party_name,1,50),
CUST_ACCT.customer_class_code,
PARTY.category_code,
ARPT_SQL_FUNC_UTIL.get_lookup_meaning(''CUSTOMER_CATEGORY'', party.category_code),
ARPT_SQL_FUNC_UTIL.get_trx_type_details(TRX.cust_trx_type_id,''NAME''),
ARPT_SQL_FUNC_UTIL.get_lookup_meaning(''INV/CM'', types.type),
ARPT_SQL_FUNC_UTIL.get_trx_type_details(TRX.cust_trx_type_id,''TYPE''),
METH.name,
METH.receipt_method_id,
SITE.location,
TRX.bill_to_site_use_id,
ABB.bank_name,
ABB.branch_party_id bank_branch_id,
ABA.bank_account_id,
NULL,
NULL,
TRX.customer_trx_id, /* br_ref_customer_trx_id */
PAYS.payment_schedule_id, /* br_ref_payment_schedule_id */
PAYS.amount_due_remaining, /* Extended Amount */
PAYS.acctd_amount_due_remaining, /* Extended Acctd Amount */
NULL /* Customer_TRX_LINE_ID */
FROM
RA_CUST_TRX_TYPES TYPES,
RA_CUSTOMER_TRX TRX ,
AR_PAYMENT_SCHEDULES PAYS ,
HZ_CUST_ACCOUNTS CUST_ACCT ,
HZ_PARTIES PARTY,
AR_receipt_METHODS METH,
CE_BANK_BRANCHES_V ABB,
HZ_CUST_SITE_USES SITE,
ap_bank_accounts ABA,
AR_TRANSACTION_HISTORY H
where trx.legal_entity_id = ' || p_le_id ||
' and TRX.drawee_id = cust_acct.cust_account_id
and cust_acct.party_id = party.party_id
and TRX.customer_trx_id = PAYS.customer_trx_id
and TRX.cust_trx_type_id = TYPES.cust_trx_type_id
and PAYS.amount_due_remaining <> 0
and PAYS.amount_due_remaining = TRX.br_amount
and PAYS.selected_for_receipt_batch_id is null
and SITE.SITE_USE_ID = TRX.drawee_site_use_id
and TRX.CUSTOMER_BANK_ACCOUNT_ID = ABA.BANK_ACCOUNT_ID (+)
and ABA.BANK_BRANCH_ID = ABB.branch_party_id (+)
and trx.receipt_method_id = meth.receipt_method_id (+)
and H.customer_trx_id = TRX.customer_trx_id
and H.current_record_flag = ''Y''
and H.status = ''UNPAID''
and not exists
(select 1
from ra_customer_trx_lines linesub,
ar_payment_schedules paysub ,
ra_customer_trx billsub
where linesub.br_ref_customer_trx_id = TRX.customer_trx_id
and linesub.customer_trx_id = billsub.customer_trx_id
and billsub.customer_trx_id = paysub.customer_trx_id
and (paysub.reserved_type is not null OR billsub.br_on_hold_flag = ''Y''))
and trx.invoice_currency_code = ' || br_currency ||
' and trx.trx_date <= ' || br_trxdate;
/* modified for tca update */
if PAY_UNRELATED_INVOICES='N' THEN
AssignCurStr := AssignCurStr||
' and TRX.drawee_id in (
SELECT rr.related_cust_account_id
FROM hz_cust_acct_relate rr
WHERE rr.cust_account_id = ' || drawee_id ||
' and rr.related_cust_account_id = trx.bill_to_customer_id
and rr.bill_to_flag = ''Y'' ' ||
' UNION ' ||
' SELECT ' || drawee_id || ' from dual ' ||
' UNION ' ||
' SELECT rel.related_cust_account_id
FROM ar_paying_relationships_v rel,
hz_cust_accounts acc
WHERE rel.party_id = acc.party_id
AND rel.related_cust_account_id = trx.bill_to_customer_id
AND acc.cust_account_id = ' || drawee_id ||
' AND ' || br_trxdate || ' BETWEEN effective_start_date
AND effective_end_date) ';