Showing posts with label AR. Show all posts
Showing posts with label AR. Show all posts

Tuesday, January 12, 2021

Query to get active Customer and their Profile Details (HZ_CUST_ACCOUNTS, HZ_CUST_ACCT_SITES_ALL, HZ_CUSTOMER_PROFILES, HZ_CUST_PROFILE_AMTS)

 

 

 

 

 

 

 

In this post we have given a query which helps you to gather the basic customer details and profile  information. In other words, it helps to understand the link between below tables.

Tables Used:

  1. HZ_PARTIES
  2. HZ_CUST_ACCOUNTS
  3. HZ_CUST_ACCT_SITES_ALL
  4. HZ_CUSTOMER_PROFILES
  5. HZ_CUST_PROFILE_AMTS
  6. HZ_CUST_SITE_USES_ALL
  7. RA_GROUPING_RULES
  8. AR_STATEMENT_CYCLES
  9. RA_TERMS
  10. AR_COLLECTORS
  11. HZ_CUST_PROFILE_CLASSES

Instance: R12

Script: 

SELECT DISTINCT hzp.party_name, hzp.orig_system_reference party_osr, hzp.party_number, hzp.party_type, hzp.duns_number, hzp.tax_reference, hzp.category_code, hzc.orig_system_reference cust_osr, hzc.account_number, hzc.account_name, hou.NAME ou_name, (SELECT a.NAME FROM ar.hz_cust_profile_classes a WHERE a.profile_class_id = hzcp.profile_class_id ) profile_class_name, (SELECT a.NAME FROM ar.ar_collectors a WHERE a.collector_id = hzcp.collector_id ) collector_name, (SELECT a.NAME FROM ar.ar_statement_cycles a WHERE statement_cycle_id = hzcp.statement_cycle_id ) statement_cycle_name, (SELECT a.NAME FROM apps.ra_terms a WHERE a.term_id = hzcp.standard_terms) payment_term_name, (SELECT a.NAME FROM ar.ra_grouping_rules a WHERE a.grouping_rule_id = hzcp.grouping_rule_id) grouping_rules_name, (SELECT a.orig_system_reference FROM hz_cust_site_uses_all a WHERE a.site_use_id = hzcp.site_use_id) profile_site_use_osr, hzcp.credit_checking, hzcp.tolerance, hzcp.credit_hold, hzcp.credit_balance_statements, hzcp.send_statements, hzcp.jgzz_attribute1 enable_late_charges,      hzcp.interest_charges,        hzcp.jgzz_attribute2 late_charge_calculation_trx,      hzcp.jgzz_attribute5 hold_charged_invoices_flag, hzcp.dunning_letters, hzcp.discount_terms, hzcp.interest_period_days, hzcp.payment_grace_days, hzcp.discount_grace_days, hzcp.auto_rec_incl_disputed_flag, hzcp.attribute_category cust_prof_dff_category, hzcp.attribute2 cust_prof_dff_attr2, hzcpm.currency_code, hzcpm.trx_credit_limit, hzcpm.overall_credit_limit, hzcpm.min_dunning_amount, hzcpm.min_dunning_invoice_amount, hzcpm.max_interest_charge, hzcpm.min_statement_amount, hzcpm.auto_rec_min_receipt_amount, hzcpm.interest_rate, hzcpm.min_fc_balance_amount, hzcpm.min_fc_invoice_amount, (SELECT a.orig_system_reference FROM hz_cust_site_uses_all a WHERE a.site_use_id = hzcpm.site_use_id ) profile_amt_site_use_osr FROM ar.hz_parties hzp, ar.hz_cust_accounts hzc,        ar.hz_cust_acct_sites_All has, ar.hz_customer_profiles hzcp, ar.hz_cust_profile_amts hzcpm, apps.hr_operating_units hou WHERE hzp.party_id = hzc.party_id AND hzc.cust_account_id = hzcp.cust_account_id and hzcp.cust_account_profile_id = hzcpm.cust_account_profile_id(+) AND has.cust_account_id = hzc.cust_Account_id AND HAS.ORG_ID = HOU.ORGANIZATION_ID AND hou.organization_id = 105 -- Operating unit id -- Customer is active and created after cut off date AND ((trunc(hzc.creation_date) >'01-MAY-2012' and hzc.status = 'A') -- AR invoices created after cut off date or exists (SELECT 1 FROM ar.ra_customer_trx_all t WHERE trunc(t.trx_date)>'01-MAY-2012' and t.bill_to_customer_id = hzc.cust_account_id and t.org_id = hzc.org_id and hzc.status = 'A') -- AR invoice Payments are in open status or exists (SELECT 1 FROM ar.ar_payment_schedules_all apsa WHERE apsa.CLASS IN ('INV', 'CM', 'DM','PMT') AND apsa.status = 'OP' AND apsa.org_id = hzc.org_id AND apsa.customer_id = hzc.cust_account_id AND to_number(apsa.acctd_amount_due_remaining) <> to_number('0') GROUP BY apsa.customer_id having sum(nvl(apsa.acctd_amount_due_remaining,0))<>0))

Tuesday, January 12, 2021 by Team search · 0

Thursday, May 14, 2015

R12 : Query to fetch Internal Bank Account Details with Payables and Receivables Usages in Oracle Apps

This summary is not available. Please click here to view the post.

Thursday, May 14, 2015 by Team search · 2

Friday, April 12, 2013

Assign Receipt method to Customer via API in Oracle Apps R12 (hz_payment_method_pub.create_payment_method)






In this post, we have given a sample script to assign a payment method to Customer account in R12.

Test instance: R12

Script: 

SET SERVEROUTPUT ON;

DECLARE
  vl_payment_method_name          VARCHAR2(50) := 'AP/AR Netting';
  vl_cust_orig_sys_reference      VARCHAR2(50) := '17312';
  vl_site_use_orig_sys_reference  VARCHAR2(50) := '34914';

  vl_pay_method_rec         hz_payment_method_pub.payment_method_rec_type;
 
  vl_method_id_num          NUMBER;
  vl_acc_id_num             NUMBER;
  vl_party_id_num           NUMBER;
  vl_site_id_num            NUMBER;
  vg_status_txt             VARCHAR2 (1);
  vg_msg_cnt_num            NUMBER;
  vg_msg_data_txt           VARCHAR2 (2000);
  vl_cust_receipt_method_id NUMBER;
  lv_cust_rec_met_id        NUMBER;
BEGIN
 -- Apps initialize
  fnd_global.APPS_INITIALIZE (1119, 50937, 222);
  mo_global.init('AR');

  BEGIN
    SELECT receipt_method_id
      INTO vl_method_id_num
      FROM ar_receipt_methods
     WHERE NAME = vl_payment_method_name
       AND SYSDATE BETWEEN (nvl(start_date,SYSDATE - 1))
                       AND (nvl(end_date,SYSDATE + 1));
  EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line('Error deriving Receipt Method ID - ' || SQLERRM);
  END;

  BEGIN
    SELECT hca.cust_account_id,
           hca.party_id
      INTO vl_acc_id_num,
           vl_party_id_num
      FROM hz_cust_accounts hca
     WHERE hca.orig_system_reference = TRIM(vl_cust_orig_sys_reference);
  EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line('Error deriving Cust Account ID - ' || SQLERRM);
  END;

  BEGIN
    SELECT hcsua.site_use_id
      INTO vl_site_id_num
      FROM hz_cust_site_uses_all hcsua
     WHERE hcsua.orig_system_reference = vl_site_use_orig_sys_reference
       AND hcsua.site_use_code IN ('BILL_TO', 'SHIP_TO');
       dbms_output.put_line('vl_site_id_num :'||vl_site_id_num);
  EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line('Error deriving Site Use ID - ' || SQLERRM);
  END;

  vl_pay_method_rec.cust_account_id   := vl_acc_id_num;
  vl_pay_method_rec.receipt_method_id := vl_method_id_num;
  vl_pay_method_rec.primary_flag      := 'Y';
  vl_pay_method_rec.site_use_id       := vl_site_id_num;
  vl_pay_method_rec.start_date        := SYSDATE;
  vl_pay_method_rec.end_date          := NULL;
 
  hz_payment_method_pub.create_payment_method
               (p_init_msg_list          => fnd_api.g_false,
                p_payment_method_rec     => vl_pay_method_rec,
                x_cust_receipt_method_id => vl_cust_receipt_method_id,
                x_return_status          => vg_status_txt,
                x_msg_count              => vg_msg_cnt_num,
                x_msg_data               => vg_msg_data_txt);
                                             
  dbms_output.put_line('PAYMENT METHOD ');
  dbms_output.put_line('return_status=' || substr(vg_status_txt,1,255));
  dbms_output.put_line('count=' || to_char(vg_msg_cnt_num));
  dbms_output.put_line('Msg_data = ' || substr(vg_msg_data_txt,1,255));

  IF (nvl(vg_status_txt,'X') != fnd_api.g_ret_sts_success)
  THEN
    IF vg_msg_cnt_num >= 1
    THEN
      dbms_output.put_line('Create Payment Methods : ' || substr(fnd_msg_pub.get(p_encoded => fnd_api.g_false),1,255));
    END IF;
  ELSE
    BEGIN
    SELECT cust_receipt_method_id
      INTO lv_cust_rec_met_id
      FROM ra_cust_receipt_methods
     WHERE customer_id       = vl_acc_id_num
       AND site_use_id       = vl_site_id_num
       AND receipt_method_id = vl_method_id_num;
      
    dbms_output.put_line('Sucessfully Created the Payment Methods (cust_receipt_method_id) :'||lv_cust_rec_met_id);
    END;
   
    COMMIT;
  END IF;
EXCEPTION
  WHEN OTHERS THEN
    dbms_output.put_line('Unknown error during call to Create Payment Methods : ' || SQLERRM);
END;
/

I hope it helps you!!! If so, please provide your valuable comments and share it. Thank You!!

Friday, April 12, 2013 by Team search · 6

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.