AR Aging to GL Reconciliation
Description
- Categories
- Enginatics, R12 only
- Repository
- GitHub
Reconciles the receivable accounts at the end of a GL period three ways: the GL balance, the Receivables subledger accounting and the AR open balance as of the period end date, which equals the AR Aging total with Show On Account set to Age (open transactions, unapplied, on-account, unidentified and claim receipts; receipts at risk and bills receivable are not included).
AR to GL Reconciliation checks the activity of one period, whether its Receivables accounting reached GL. This report explains the balance: why the receivable accounts of the trial balance differ from the aging, per account and per customer.
The reconciliation is a roll-forward from the start of Period From to the end of Period. The opening balances are as of the day before Period From starts, and Opening Difference is the difference already present then. Set Period From to the first period of Receivables in the ledger to show every manual or other source journal since then in the columns.
Receivables Journals, Manual Journals and Other Source Journals split the posted GL movement on the account by journal source; other sources include revaluation.
Subledger Accounting is the final Receivables accounting dated in the range. Not Transferred to GL and Not Posted in GL are the part of it missing from the GL balance, the latter including journals still in the GL interface. Subledger Manual Entries change GL but not AR. Not Accounted is AR activity in the range without final accounting.
GL to Subledger Difference is the posted Receivables journals less the subledger accounting posted, for example a journal imported twice. AR to Subledger Difference is the AR movement the subledger accounting does not explain, for example a credit memo whose revenue line was accounted to the receivable account.
Closing Difference equals Opening Difference plus Manual Journals, Other Source Journals, Subledger Manual Entries and GL to Subledger Difference, less Not Transferred to GL, Not Posted in GL, Not Accounted and AR to Subledger Difference.
The accounts are all combinations of the natural accounts that carry open receivables at either date, or of the natural account range of Account From and Account To. The AR balances include every operating unit of the ledger: like the GL balances, they are secured by ledger access.
Show Customers gives a row per account and customer, with subledger accounting attributed as in the aging: transactions to the bill-to customer, unapplied cash to the receipt's customer. The GL columns stay on the account row. Template Customer Differences lists the customers whose AR movement differs from the subledger accounting, and Show Monthly Movement adds the subledger accounting per period.
AR to GL Reconciliation checks the activity of one period, whether its Receivables accounting reached GL. This report explains the balance: why the receivable accounts of the trial balance differ from the aging, per account and per customer.
The reconciliation is a roll-forward from the start of Period From to the end of Period. The opening balances are as of the day before Period From starts, and Opening Difference is the difference already present then. Set Period From to the first period of Receivables in the ledger to show every manual or other source journal since then in the columns.
Receivables Journals, Manual Journals and Other Source Journals split the posted GL movement on the account by journal source; other sources include revaluation.
Subledger Accounting is the final Receivables accounting dated in the range. Not Transferred to GL and Not Posted in GL are the part of it missing from the GL balance, the latter including journals still in the GL interface. Subledger Manual Entries change GL but not AR. Not Accounted is AR activity in the range without final accounting.
GL to Subledger Difference is the posted Receivables journals less the subledger accounting posted, for example a journal imported twice. AR to Subledger Difference is the AR movement the subledger accounting does not explain, for example a credit memo whose revenue line was accounted to the receivable account.
Closing Difference equals Opening Difference plus Manual Journals, Other Source Journals, Subledger Manual Entries and GL to Subledger Difference, less Not Transferred to GL, Not Posted in GL, Not Accounted and AR to Subledger Difference.
The accounts are all combinations of the natural accounts that carry open receivables at either date, or of the natural account range of Account From and Account To. The AR balances include every operating unit of the ledger: like the GL balances, they are secured by ledger access.
Show Customers gives a row per account and customer, with subledger accounting attributed as in the aging: transactions to the bill-to customer, unapplied cash to the receipt's customer. The GL columns stay on the account row. Template Customer Differences lists the customers whose AR movement differs from the subledger accounting, and Show Monthly Movement adds the subledger accounting per period.
SQL 478 lines
with p as ( select gl.ledger_id, gl.name ledger, gl.currency_code, gl.chart_of_accounts_id, gl.period_set_name, gl.accounted_period_type, gp0.start_date, gp1.end_date, gp0.period_year*10000+gp0.period_num period_from_num, gp1.period_year*10000+gp1.period_num period_to_num from gl_ledgers gl, gl_periods gp0, gl_periods gp1 where gl.name=:ledger and gl.ledger_id in (select xroa.id from xxen_report_org_access xroa where xroa.access_type='LEDGER') and gl.period_set_name=gp0.period_set_name and gl.accounted_period_type=gp0.period_type and gp0.period_name=:period_from and gl.period_set_name=gp1.period_set_name and gl.accounted_period_type=gp1.period_type and gp1.period_name=:period and gp0.start_date<=gp1.end_date ), ar as ( select /*+ materialize*/ x.code_combination_id, x.customer_id, sum(x.ar_opening) ar_opening, sum(x.ar_closing) ar_closing from ( select rctlgda.code_combination_id, y.customer_id, case when y.gl_date<y.start_date then y.acctd_amount_due_remaining+ ( select nvl(sum((decode(y.class,'CM',decode(araa.application_type,'CM',araa.acctd_amount_applied_from,araa.acctd_amount_applied_to),araa.acctd_amount_applied_to)+nvl(araa.acctd_earned_discount_taken,0)+nvl(araa.acctd_unearned_discount_taken,0))*decode(y.class,'CM',decode(araa.application_type,'CM',-1,1),1)),0) from ar_receivable_applications_all araa where (y.payment_schedule_id=araa.applied_payment_schedule_id or y.payment_schedule_id=araa.payment_schedule_id) and araa.status in ('APP','ACTIVITY') and nvl(araa.confirmed_flag,'Y')='Y' and araa.gl_date>=y.start_date )- (select nvl(sum(aaa.acctd_amount),0) from ar_adjustments_all aaa where y.payment_schedule_id=aaa.payment_schedule_id and aaa.status='A' and aaa.gl_date>=y.start_date) end ar_opening, case when y.gl_date_closed>y.end_date then y.acctd_amount_due_remaining+ ( select nvl(sum((decode(y.class,'CM',decode(araa.application_type,'CM',araa.acctd_amount_applied_from,araa.acctd_amount_applied_to),araa.acctd_amount_applied_to)+nvl(araa.acctd_earned_discount_taken,0)+nvl(araa.acctd_unearned_discount_taken,0))*decode(y.class,'CM',decode(araa.application_type,'CM',-1,1),1)),0) from ar_receivable_applications_all araa where (y.payment_schedule_id=araa.applied_payment_schedule_id or y.payment_schedule_id=araa.payment_schedule_id) and araa.status in ('APP','ACTIVITY') and nvl(araa.confirmed_flag,'Y')='Y' and araa.gl_date>y.end_date )- (select nvl(sum(aaa.acctd_amount),0) from ar_adjustments_all aaa where y.payment_schedule_id=aaa.payment_schedule_id and aaa.status='A' and aaa.gl_date>y.end_date) end ar_closing from ( select apsa.payment_schedule_id, apsa.customer_trx_id, apsa.customer_id, apsa.class, apsa.gl_date, apsa.gl_date_closed, apsa.acctd_amount_due_remaining, p.start_date, p.end_date from p, ar_payment_schedules_all apsa where apsa.gl_date_closed>=p.start_date and apsa.gl_date<=p.end_date and (apsa.gl_date<p.start_date or apsa.gl_date_closed>p.end_date) and apsa.class not in ('PMT','BR') and apsa.org_id in (select aspa.org_id from ar_system_parameters_all aspa where p.ledger_id=aspa.set_of_books_id) ) y, ra_cust_trx_line_gl_dist_all rctlgda where y.customer_trx_id=rctlgda.customer_trx_id and rctlgda.account_class='REC' and rctlgda.latest_rec_flag='Y' union all select araa.code_combination_id, apsa.customer_id, case when araa.gl_date<p.start_date and (araa.reversal_gl_date is null or apsa.gl_date<p.start_date) then -araa.acctd_amount_applied_from end ar_opening, case when apsa.gl_date_closed>p.end_date and (araa.reversal_gl_date is null or apsa.gl_date<=p.end_date) then -araa.acctd_amount_applied_from end ar_closing from p, ar_payment_schedules_all apsa, ar_receivable_applications_all araa where apsa.gl_date_closed>=p.start_date and (apsa.gl_date<p.start_date or apsa.gl_date_closed>p.end_date) and apsa.class='PMT' and nvl(apsa.receipt_confirmed_flag,'Y')='Y' and apsa.org_id in (select aspa.org_id from ar_system_parameters_all aspa where p.ledger_id=aspa.set_of_books_id) and apsa.cash_receipt_id=araa.cash_receipt_id and araa.status in ('ACC','UNAPP','UNID','OTHER ACC') and nvl(araa.confirmed_flag,'Y')='Y' and araa.gl_date<=p.end_date ) x group by x.code_combination_id, x.customer_id ), acc as ( select /*+ materialize*/ gcc.code_combination_id from p, gl_code_combinations gcc where p.chart_of_accounts_id=gcc.chart_of_accounts_id and gcc.summary_flag='N' and ( :account_from is null and gcc.&account_segment in (select gcc2.&account_segment from ar, gl_code_combinations gcc2 where ar.code_combination_id=gcc2.code_combination_id) or gcc.&account_segment between :account_from and :account_to ) ) select y.ledger, gcck.concatenated_segments account, xxen_util.segment_description(gcck.&account_segment,'&account_segment',gcck.chart_of_accounts_id) account_description, hp.party_name customer, hca.account_number customer_number, y.gl_opening "GL Opening Balance", y.ar_opening "AR Opening Balance", y.gl_opening-y.ar_opening opening_difference, y.receivables_journals, y.manual_journals, y.other_source_journals, y.subledger_accounting, y.not_transferred "Not Transferred to GL", y.not_posted "Not Posted in GL", y.subledger_manual "Subledger Manual Entries", y.not_accounted, y.gl_subledger_difference "GL to Subledger Difference", y.ar_subledger_difference "AR to Subledger Difference", &monthly_columns_outer y.gl_closing "GL Closing Balance", y.ar_closing "AR Closing Balance", y.gl_closing-y.ar_closing closing_difference from ( select x.*, case when row_number() over (partition by x.code_combination_id order by x.customer_id nulls first)=1 then sum(x.receivables_journals+x.not_transferred+x.not_posted-x.subledger_accounting) over (partition by x.code_combination_id) end gl_subledger_difference, x.ar_closing-x.ar_opening-x.subledger_accounting+x.subledger_manual-x.not_accounted ar_subledger_difference from ( select p.ledger, z.code_combination_id, decode(:show_customers,'Y',z.customer_id) customer_id, &monthly_columns nvl(sum(z.gl_opening),0) gl_opening, nvl(sum(z.ar_opening),0) ar_opening, nvl(sum(z.manual_journals),0) manual_journals, nvl(sum(z.other_source_journals),0) other_source_journals, nvl(sum(z.receivables_journals),0) receivables_journals, nvl(sum(z.subledger_accounting),0) subledger_accounting, nvl(sum(z.not_transferred),0) not_transferred, nvl(sum(z.not_posted),0) not_posted, nvl(sum(z.subledger_manual),0) subledger_manual, nvl(sum(z.not_accounted),0) not_accounted, nvl(sum(z.gl_closing),0) gl_closing, nvl(sum(z.ar_closing),0) ar_closing from p, ( select /*+ leading(p acc gb) use_nl(gb)*/ gb.code_combination_id, to_number(null) customer_id, to_char(null) period_name, sum(decode(gb.period_name,:period_from,nvl(gb.begin_balance_dr,0)-nvl(gb.begin_balance_cr,0))) gl_opening, to_number(null) ar_opening, to_number(null) manual_journals, to_number(null) other_source_journals, to_number(null) receivables_journals, to_number(null) subledger_accounting, to_number(null) not_transferred, to_number(null) not_posted, to_number(null) subledger_manual, to_number(null) not_accounted, sum(decode(gb.period_name,:period,nvl(gb.begin_balance_dr,0)-nvl(gb.begin_balance_cr,0)+nvl(gb.period_net_dr,0)-nvl(gb.period_net_cr,0))) gl_closing, to_number(null) ar_closing from p, acc, gl_balances gb where acc.code_combination_id=gb.code_combination_id and gb.period_name in (:period_from,:period) and p.ledger_id=gb.ledger_id and p.currency_code=gb.currency_code and gb.actual_flag='A' and nvl(gb.translated_flag,'x')<>'R' group by gb.code_combination_id union all select /*+ leading(p gp acc gjl) use_nl(gjl gjh)*/ gjl.code_combination_id, to_number(null) customer_id, to_char(null) period_name, to_number(null) gl_opening, to_number(null) ar_opening, sum(case when gjh.status='P' and gjh.je_source='Manual' then nvl(gjl.accounted_dr,0)-nvl(gjl.accounted_cr,0) end) manual_journals, sum(case when gjh.status='P' and gjh.je_source not in ('Manual','Receivables') then nvl(gjl.accounted_dr,0)-nvl(gjl.accounted_cr,0) end) other_source_journals, sum(case when gjh.status='P' and gjh.je_source='Receivables' then nvl(gjl.accounted_dr,0)-nvl(gjl.accounted_cr,0) end) receivables_journals, to_number(null) subledger_accounting, to_number(null) not_transferred, sum(case when gjh.status<>'P' and gjh.je_source='Receivables' then nvl(gjl.accounted_dr,0)-nvl(gjl.accounted_cr,0) end) not_posted, to_number(null) subledger_manual, to_number(null) not_accounted, to_number(null) gl_closing, to_number(null) ar_closing from p, acc, gl_periods gp, gl_je_lines gjl, gl_je_headers gjh where p.period_set_name=gp.period_set_name and p.accounted_period_type=gp.period_type and gp.period_year*10000+gp.period_num between p.period_from_num and p.period_to_num and acc.code_combination_id=gjl.code_combination_id and gp.period_name=gjl.period_name and p.ledger_id=gjl.ledger_id and gjl.je_header_id=gjh.je_header_id and gjh.actual_flag='A' and gjh.currency_code<>'STAT' group by gjl.code_combination_id union all select gi.code_combination_id, to_number(null) customer_id, to_char(null) period_name, to_number(null) gl_opening, to_number(null) ar_opening, to_number(null) manual_journals, to_number(null) other_source_journals, to_number(null) receivables_journals, to_number(null) subledger_accounting, to_number(null) not_transferred, sum(nvl(gi.accounted_dr,0)-nvl(gi.accounted_cr,0)) not_posted, to_number(null) subledger_manual, to_number(null) not_accounted, to_number(null) gl_closing, to_number(null) ar_closing from p, acc, gl_interface gi where acc.code_combination_id=gi.code_combination_id and p.ledger_id=gi.ledger_id and gi.user_je_source_name=(select gjsv.user_je_source_name from gl_je_sources_vl gjsv where gjsv.je_source_name='Receivables') and gi.accounting_date>=p.start_date and gi.accounting_date<p.end_date+1 and gi.actual_flag='A' group by gi.code_combination_id union all select s.code_combination_id, case when s.accounting_class_code in ('UNAPP','ACC','UNID','CLAIM','PREPAY') then coalesce((select acra.pay_from_customer from xla.xla_transaction_entities xte, ar_cash_receipts_all acra where s.entity_id=xte.entity_id and xte.application_id=222 and xte.entity_code='RECEIPTS' and xte.source_id_int_1=acra.cash_receipt_id),s.party_id) else s.party_id end customer_id, s.period_name, to_number(null) gl_opening, to_number(null) ar_opening, to_number(null) manual_journals, to_number(null) other_source_journals, to_number(null) receivables_journals, s.subledger_accounting, s.not_transferred, to_number(null) not_posted, s.subledger_manual, to_number(null) not_accounted, to_number(null) gl_closing, to_number(null) ar_closing from ( select /*+ leading(p acc xal) use_nl(xal)*/ xal.code_combination_id, xal.accounting_class_code, case when xal.accounting_class_code in ('UNAPP','ACC','UNID','CLAIM','PREPAY') then xah.entity_id end entity_id, decode(xal.party_type_code,'C',xal.party_id) party_id, xah.period_name, sum(nvl(xal.accounted_dr,0)-nvl(xal.accounted_cr,0)) subledger_accounting, sum(case when xah.gl_transfer_status_code<>'Y' then nvl(xal.accounted_dr,0)-nvl(xal.accounted_cr,0) end) not_transferred, sum(case when xah.event_type_code='MANUAL' then nvl(xal.accounted_dr,0)-nvl(xal.accounted_cr,0) end) subledger_manual from p, acc, xla_ae_lines xal, xla_ae_headers xah where acc.code_combination_id=xal.code_combination_id and p.ledger_id=xal.ledger_id and xal.accounting_date>=p.start_date and xal.accounting_date<p.end_date+1 and xal.application_id=222 and xal.ae_header_id=xah.ae_header_id and xah.application_id=222 and p.ledger_id=xah.ledger_id and xah.accounting_date>=p.start_date and xah.accounting_date<p.end_date+1 and xah.accounting_entry_status_code='F' and xah.balance_type_code='A' group by xal.code_combination_id, xal.accounting_class_code, case when xal.accounting_class_code in ('UNAPP','ACC','UNID','CLAIM','PREPAY') then xah.entity_id end, decode(xal.party_type_code,'C',xal.party_id), xah.period_name ) s union all select ar.code_combination_id, ar.customer_id, to_char(null) period_name, to_number(null) gl_opening, ar.ar_opening, to_number(null) manual_journals, to_number(null) other_source_journals, to_number(null) receivables_journals, to_number(null) subledger_accounting, to_number(null) not_transferred, to_number(null) not_posted, to_number(null) subledger_manual, to_number(null) not_accounted, to_number(null) gl_closing, ar.ar_closing from ar where ar.code_combination_id in (select acc.code_combination_id from acc) union all select n.code_combination_id, n.customer_id, to_char(null) period_name, to_number(null) gl_opening, to_number(null) ar_opening, to_number(null) manual_journals, to_number(null) other_source_journals, to_number(null) receivables_journals, to_number(null) subledger_accounting, to_number(null) not_transferred, to_number(null) not_posted, to_number(null) subledger_manual, sum(n.amount) not_accounted, to_number(null) gl_closing, to_number(null) ar_closing from ( select rctlgda.code_combination_id, rcta.bill_to_customer_id customer_id, rctlgda.acctd_amount amount from p, ra_cust_trx_line_gl_dist_all rctlgda, ra_customer_trx_all rcta where p.ledger_id=rctlgda.set_of_books_id and rctlgda.posting_control_id=-3 and rctlgda.gl_date>=p.start_date and rctlgda.gl_date<=p.end_date and rctlgda.account_class='REC' and rctlgda.latest_rec_flag='Y' and rctlgda.customer_trx_id=rcta.customer_trx_id and rcta.org_id in (select aspa.org_id from ar_system_parameters_all aspa where p.ledger_id=aspa.set_of_books_id) and rcta.customer_trx_id in (select apsa.customer_trx_id from ar_payment_schedules_all apsa where apsa.class<>'BR') union all select rctlgda.code_combination_id, apsa.customer_id, aaa.acctd_amount from p, ar_adjustments_all aaa, ar_payment_schedules_all apsa, ra_cust_trx_line_gl_dist_all rctlgda where p.ledger_id=aaa.set_of_books_id and aaa.posting_control_id=-3 and aaa.gl_date>=p.start_date and aaa.gl_date<=p.end_date and aaa.status='A' and aaa.org_id in (select aspa.org_id from ar_system_parameters_all aspa where p.ledger_id=aspa.set_of_books_id) and aaa.payment_schedule_id=apsa.payment_schedule_id and apsa.customer_trx_id=rctlgda.customer_trx_id and rctlgda.account_class='REC' and rctlgda.latest_rec_flag='Y' union all select rctlgda.code_combination_id, apsa.customer_id, -(decode(apsa.class,'CM',decode(araa.application_type,'CM',araa.acctd_amount_applied_from,araa.acctd_amount_applied_to),araa.acctd_amount_applied_to)+nvl(araa.acctd_earned_discount_taken,0)+nvl(araa.acctd_unearned_discount_taken,0))*decode(apsa.class,'CM',decode(araa.application_type,'CM',-1,1),1) from p, ar_receivable_applications_all araa, ar_payment_schedules_all apsa, ra_cust_trx_line_gl_dist_all rctlgda where p.ledger_id=araa.set_of_books_id and araa.posting_control_id=-3 and araa.gl_date>=p.start_date and araa.gl_date<=p.end_date and araa.status in ('APP','ACTIVITY') and nvl(araa.confirmed_flag,'Y')='Y' and araa.org_id in (select aspa.org_id from ar_system_parameters_all aspa where p.ledger_id=aspa.set_of_books_id) and (araa.applied_payment_schedule_id=apsa.payment_schedule_id or araa.payment_schedule_id=apsa.payment_schedule_id) and apsa.class not in ('PMT','BR') and apsa.customer_trx_id=rctlgda.customer_trx_id and rctlgda.account_class='REC' and rctlgda.latest_rec_flag='Y' union all select araa.code_combination_id, apsa.customer_id, -araa.acctd_amount_applied_from from p, ar_receivable_applications_all araa, ar_payment_schedules_all apsa where p.ledger_id=araa.set_of_books_id and araa.posting_control_id=-3 and araa.gl_date>=p.start_date and araa.gl_date<=p.end_date and araa.status in ('ACC','UNAPP','UNID','OTHER ACC') and nvl(araa.confirmed_flag,'Y')='Y' and araa.org_id in (select aspa.org_id from ar_system_parameters_all aspa where p.ledger_id=aspa.set_of_books_id) and araa.cash_receipt_id=apsa.cash_receipt_id and apsa.class='PMT' ) n where n.code_combination_id in (select acc.code_combination_id from acc) group by n.code_combination_id, n.customer_id ) z group by p.ledger, z.code_combination_id, decode(:show_customers,'Y',z.customer_id) ) x ) y, gl_code_combinations_kfv gcck, hz_cust_accounts hca, hz_parties hp where 3=3 and y.code_combination_id=gcck.code_combination_id and y.customer_id=hca.cust_account_id(+) and hca.party_id=hp.party_id(+) and (y.gl_opening<>0 or y.ar_opening<>0 or y.manual_journals<>0 or y.other_source_journals<>0 or y.receivables_journals<>0 or y.subledger_accounting<>0 or y.not_posted<>0 or y.not_accounted<>0 or y.gl_subledger_difference<>0 or y.gl_closing<>0 or y.ar_closing<>0) order by gcck.concatenated_segments, hp.party_name nulls first, hca.account_number |
Parameters 9
| Parameter | Type | List of values SQL | |
|---|---|---|---|
| Ledger | LOV | ||
| Period | LOV | ||
| Period From | LOV | ||
| Account From | LOV | ||
| Account To | LOV | ||
| Show Customers | LOV | ||
| Customer | LOV |
| |
| Differences Only | LOV |
| |
| Show Monthly Movement | LOV |
|