CREATE OR REPLACE PROCEDURE APPS.XXCUS_CRT_ARRECEIPT ( -- errbuff OUT VARCHAR2
--,retcode OUT VARCHAR2
P_CUSTOMER_ID IN NUMBER
,p_amount IN NUMBER
,p_receipt_date IN DATE
,p_deposit_date IN DATE
,p_gl_date IN DATE
,p_maturity_date IN DATE
,p_remittance_bank_account_id NUMBER --10003; -- بنك الفجيره الوطنى
/*
select REMIT_BANK_ACCT_USE_ID from ar_receipt_method_accounts_all
where org_id = 145
and receipt_method_id = 7019
*/
,P_COMMENTS IN VARCHAR2
--,p_customer_number IN VARCHAR2
--,p_Cust_Name IN OUT VARCHAR2
,p_receipt_number OUT VARCHAR2
,W_MID OUT VARCHAR2
,W_Status OUT VARCHAR2
,W_Message OUT VARCHAR2
)IS
l_user_id NUMBER := 26051;
l_resp_id NUMBER := 506011;
l_resp_appl_id NUMBER := 222;
l_org_id NUMBER := 1454;
--l_receipt_method_id NUMBER := 70197; --METHOD_NAME
p_global_attribute_rec AR_RECEIPT_API_PUB.global_attribute_rec_type;
p_attribute_rec AR_RECEIPT_API_PUB.attribute_rec_type;
p_currency_code VARCHAR2(100) := 'AED';
-- p_receipt_date DATE := TRUNC(SYSDATE);
-- p_gl_date DATE := TRUNC(SYSDATE);
-- p_deposit_date DATE := TRUNC(SYSDATE);
p_override_remit_account_flag VARCHAR2(100) := 'N';
--p_maturity_date DATE := TRUNC(SYSDATE);
-- p_comments VARCHAR2(100) := 'FROM WS-4';
---------------LOCAL VARIABLES-----------
p_payroll_end_dt date ;
p_api_version NUMBER;
p_init_msg_list VARCHAR2(240);
p_commit VARCHAR2(240);
p_validation_level NUMBER;
p_usr_currency_code VARCHAR2(240);
p_usr_exchange_rate_type VARCHAR2(240);
p_exchange_rate_type VARCHAR2(240);
p_exchange_rate NUMBER;
p_exchange_rate_date DATE;
p_factor_discount_amount NUMBER;
--p_receipt_date DATE;
p_postmark_date DATE;
p_customer_number VARCHAR2(240);
p_customer_bank_account_id NUMBER;
p_customer_bank_account_num VARCHAR2(240);
p_customer_bank_account_name VARCHAR2(240);
p_location VARCHAR2(240);
p_customer_receipt_reference VARCHAR2(240);
p_remittance_bank_account_num VARCHAR2(240);
p_remittance_bank_account_name VARCHAR2(240);
p_receipt_method_name VARCHAR2(240);
p_doc_sequence_value NUMBER;
p_ussgl_transaction_code VARCHAR2(240);
p_anticipated_clearing_date DATE;
p_called_from VARCHAR2(240);
--p_comments VARCHAR2(240);
p_issuer_name VARCHAR2(240);
p_issue_date DATE;
p_issuer_bank_branch_id NUMBER;
--p_amount NUMBER;
--p_receipt_number VARCHAR2(240);
p_receipt_method_id NUMBER := 7019; --Cاجمالى النقد FM
p_customer_name VARCHAR2(240);
--p_customer_id NUMBER;
--p_currency_code VARCHAR2(10);
--p_gl_date DATE;
--p_deposit_date DATE;
p_customer_site_use_id NUMBER;
--p_override_remit_account_flag VARCHAR2(1);
--p_remittance_bank_account_id NUMBER;
--p_maturity_date DATE;
x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(240);
p_cr_id NUMBER;
l_receipt_exists VARCHAR2(1);
l_customer_exists VARCHAR2(1);
l_exists_receipt_number VARCHAR2(30);
BEGIN
BEGIN
fnd_global.apps_initialize(l_user_id,l_resp_id,l_resp_id,0);
mo_global.set_policy_context('S',l_org_id);
mo_global.init ('AR');
p_attribute_rec.ATTRIBUTE5 := '1';
SELECT 'Y'
INTO l_customer_exists
FROM AR_CUSTOMERS ARC
where arc.customer_id = p_customer_id;
--where ARC.CUSTOMER_NUMBER = p_customer_number;
EXCEPTION WHEN OTHERS THEN
l_customer_exists := 'N';
END;
IF l_customer_exists = 'Y' then
p_receipt_number := 'WS-'||XX_CUST_CR_REC_S.NEXTVAL; --rECEIPT NUMBER
AR_RECEIPT_API_PUB.Create_cash (
p_api_version => 1.0
,p_init_msg_list => FND_API.G_FALSE
,p_commit => FND_API.G_FALSE
,p_validation_level => FND_API.G_VALID_LEVEL_FULL
,p_usr_currency_code => p_usr_currency_code
,p_currency_code => p_currency_code
,p_usr_exchange_rate_type => p_usr_exchange_rate_type
,p_exchange_rate_type => p_exchange_rate_type
,p_exchange_rate => p_exchange_rate
,p_exchange_rate_date => p_exchange_rate_date
,p_amount => p_amount
,p_factor_discount_amount => p_factor_discount_amount
,p_receipt_number => p_receipt_number
,p_receipt_date => p_receipt_date
,p_gl_date => p_gl_date
,p_maturity_date => p_maturity_date
,p_postmark_date => p_postmark_date
,p_customer_id => p_customer_id
,p_customer_name => p_customer_name
,p_customer_number => p_customer_number
,p_customer_bank_account_id => p_customer_bank_account_id
,p_customer_bank_account_num => p_customer_bank_account_num
,p_customer_bank_account_name => p_customer_bank_account_name
,p_location => p_location
,p_customer_site_use_id => p_customer_site_use_id
,p_customer_receipt_reference => p_customer_receipt_reference
,p_override_remit_account_flag => p_override_remit_account_flag
,p_remittance_bank_account_id => p_remittance_bank_account_id
,p_remittance_bank_account_num => p_remittance_bank_account_num
,p_remittance_bank_account_name => p_remittance_bank_account_name
,p_deposit_date => p_deposit_date
,p_receipt_method_id => p_receipt_method_id
,p_receipt_method_name => p_receipt_method_name
,p_doc_sequence_value => p_doc_sequence_value
,p_ussgl_transaction_code => p_ussgl_transaction_code
,p_anticipated_clearing_date => p_anticipated_clearing_date
,p_called_from => p_called_from
,p_global_attribute_rec => p_global_attribute_rec
,p_attribute_rec => p_attribute_rec
,p_comments => p_comments
,p_issuer_name => p_issuer_name
,p_issue_date => p_issue_date
,p_issuer_bank_branch_id => p_issuer_bank_branch_id
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data
,p_cr_id => p_cr_id
,p_org_id => l_org_id
);
IF (x_return_status = 'S') THEN
COMMIT;
--fnd_file.PUT_LINE(FND_FILE.OUTPUT,'==================MAIN EXCEPTIONS=================');
dbms_output.put_line('SUCCESS ReceiptNum >'||p_receipt_number);
dbms_output.put_line('Return Status = '|| SUBSTR (x_return_status,1,255));
dbms_output.put_line('p_cr_id = '||p_cr_id);
p_receipt_number := p_receipt_number;
BEGIN
SELECT CASH_RECEIPT_ID INTO W_MID
--,RECEIPT_NUMBER,RECEIPT_METHOD_ID,ORG_ID,CREATION_DATE
FROM AR_CASH_RECEIPTS_ALL
WHERE RECEIPT_NUMBER = p_receipt_number--'98107'
AND TRUNC(CREATION_DATE) LIKE SYSDATE
AND RECEIPT_METHOD_ID = p_receipt_method_id
--and type = 'MISC'
;
EXCEPTION WHEN OTHERS THEN NULL;
END;
--W_MID := 'Created from WS';
W_Status := 'S';
W_Message := 'Return Status = '|| SUBSTR (x_return_status,1,255) ;
ELSE
ROLLBACK;
dbms_output.put_line('Return Status = '|| SUBSTR (x_return_status,1,255));
dbms_output.put_line('Message Count = '|| TO_CHAR(x_msg_count ));
dbms_output.put_line('Message Data = '|| SUBSTR (x_msg_data,1,255));
dbms_output.put_line(APPS.FND_MSG_PUB.Get ( p_msg_index => APPS.FND_MSG_PUB.G_LAST,
p_encoded => APPS.FND_API.G_FALSE));
fnd_file.PUT_LINE(FND_FILE.OUTPUT,'Exception-1 Customer Number:'||p_customer_number||'-'||sqlerrm);
p_receipt_number := NULL;
W_MID := 'Not Created';
W_Status := 'N';
W_Message := 'Message Data = '|| SUBSTR (x_msg_data,1,255) ;
END IF;
ELSE
dbms_output.put_line('customer doesnt exists'||sqlerrm);
p_receipt_number := NULL;
W_MID := 'Not Created';
W_Status := 'N';
W_Message := 'Customer Not Exists = '|| SUBSTR (sqlerrm,1,255) ;
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Exception :'||sqlerrm);
fnd_file.PUT_LINE(FND_FILE.OUTPUT,'Exception-Last Customer Numebr:'||p_customer_number||'-'||sqlerrm);
p_receipt_number := NULL;
W_MID := 'Not Created';
W_Status := 'N';
W_Message := 'Message Data = '|| SUBSTR (sqlerrm,1,255) ;
END;
/
--,retcode OUT VARCHAR2
P_CUSTOMER_ID IN NUMBER
,p_amount IN NUMBER
,p_receipt_date IN DATE
,p_deposit_date IN DATE
,p_gl_date IN DATE
,p_maturity_date IN DATE
,p_remittance_bank_account_id NUMBER --10003; -- بنك الفجيره الوطنى
/*
select REMIT_BANK_ACCT_USE_ID from ar_receipt_method_accounts_all
where org_id = 145
and receipt_method_id = 7019
*/
,P_COMMENTS IN VARCHAR2
--,p_customer_number IN VARCHAR2
--,p_Cust_Name IN OUT VARCHAR2
,p_receipt_number OUT VARCHAR2
,W_MID OUT VARCHAR2
,W_Status OUT VARCHAR2
,W_Message OUT VARCHAR2
)IS
l_user_id NUMBER := 26051;
l_resp_id NUMBER := 506011;
l_resp_appl_id NUMBER := 222;
l_org_id NUMBER := 1454;
--l_receipt_method_id NUMBER := 70197; --METHOD_NAME
p_global_attribute_rec AR_RECEIPT_API_PUB.global_attribute_rec_type;
p_attribute_rec AR_RECEIPT_API_PUB.attribute_rec_type;
p_currency_code VARCHAR2(100) := 'AED';
-- p_receipt_date DATE := TRUNC(SYSDATE);
-- p_gl_date DATE := TRUNC(SYSDATE);
-- p_deposit_date DATE := TRUNC(SYSDATE);
p_override_remit_account_flag VARCHAR2(100) := 'N';
--p_maturity_date DATE := TRUNC(SYSDATE);
-- p_comments VARCHAR2(100) := 'FROM WS-4';
---------------LOCAL VARIABLES-----------
p_payroll_end_dt date ;
p_api_version NUMBER;
p_init_msg_list VARCHAR2(240);
p_commit VARCHAR2(240);
p_validation_level NUMBER;
p_usr_currency_code VARCHAR2(240);
p_usr_exchange_rate_type VARCHAR2(240);
p_exchange_rate_type VARCHAR2(240);
p_exchange_rate NUMBER;
p_exchange_rate_date DATE;
p_factor_discount_amount NUMBER;
--p_receipt_date DATE;
p_postmark_date DATE;
p_customer_number VARCHAR2(240);
p_customer_bank_account_id NUMBER;
p_customer_bank_account_num VARCHAR2(240);
p_customer_bank_account_name VARCHAR2(240);
p_location VARCHAR2(240);
p_customer_receipt_reference VARCHAR2(240);
p_remittance_bank_account_num VARCHAR2(240);
p_remittance_bank_account_name VARCHAR2(240);
p_receipt_method_name VARCHAR2(240);
p_doc_sequence_value NUMBER;
p_ussgl_transaction_code VARCHAR2(240);
p_anticipated_clearing_date DATE;
p_called_from VARCHAR2(240);
--p_comments VARCHAR2(240);
p_issuer_name VARCHAR2(240);
p_issue_date DATE;
p_issuer_bank_branch_id NUMBER;
--p_amount NUMBER;
--p_receipt_number VARCHAR2(240);
p_receipt_method_id NUMBER := 7019; --Cاجمالى النقد FM
p_customer_name VARCHAR2(240);
--p_customer_id NUMBER;
--p_currency_code VARCHAR2(10);
--p_gl_date DATE;
--p_deposit_date DATE;
p_customer_site_use_id NUMBER;
--p_override_remit_account_flag VARCHAR2(1);
--p_remittance_bank_account_id NUMBER;
--p_maturity_date DATE;
x_return_status VARCHAR2(1);
x_msg_count NUMBER;
x_msg_data VARCHAR2(240);
p_cr_id NUMBER;
l_receipt_exists VARCHAR2(1);
l_customer_exists VARCHAR2(1);
l_exists_receipt_number VARCHAR2(30);
BEGIN
BEGIN
fnd_global.apps_initialize(l_user_id,l_resp_id,l_resp_id,0);
mo_global.set_policy_context('S',l_org_id);
mo_global.init ('AR');
p_attribute_rec.ATTRIBUTE5 := '1';
SELECT 'Y'
INTO l_customer_exists
FROM AR_CUSTOMERS ARC
where arc.customer_id = p_customer_id;
--where ARC.CUSTOMER_NUMBER = p_customer_number;
EXCEPTION WHEN OTHERS THEN
l_customer_exists := 'N';
END;
IF l_customer_exists = 'Y' then
p_receipt_number := 'WS-'||XX_CUST_CR_REC_S.NEXTVAL; --rECEIPT NUMBER
AR_RECEIPT_API_PUB.Create_cash (
p_api_version => 1.0
,p_init_msg_list => FND_API.G_FALSE
,p_commit => FND_API.G_FALSE
,p_validation_level => FND_API.G_VALID_LEVEL_FULL
,p_usr_currency_code => p_usr_currency_code
,p_currency_code => p_currency_code
,p_usr_exchange_rate_type => p_usr_exchange_rate_type
,p_exchange_rate_type => p_exchange_rate_type
,p_exchange_rate => p_exchange_rate
,p_exchange_rate_date => p_exchange_rate_date
,p_amount => p_amount
,p_factor_discount_amount => p_factor_discount_amount
,p_receipt_number => p_receipt_number
,p_receipt_date => p_receipt_date
,p_gl_date => p_gl_date
,p_maturity_date => p_maturity_date
,p_postmark_date => p_postmark_date
,p_customer_id => p_customer_id
,p_customer_name => p_customer_name
,p_customer_number => p_customer_number
,p_customer_bank_account_id => p_customer_bank_account_id
,p_customer_bank_account_num => p_customer_bank_account_num
,p_customer_bank_account_name => p_customer_bank_account_name
,p_location => p_location
,p_customer_site_use_id => p_customer_site_use_id
,p_customer_receipt_reference => p_customer_receipt_reference
,p_override_remit_account_flag => p_override_remit_account_flag
,p_remittance_bank_account_id => p_remittance_bank_account_id
,p_remittance_bank_account_num => p_remittance_bank_account_num
,p_remittance_bank_account_name => p_remittance_bank_account_name
,p_deposit_date => p_deposit_date
,p_receipt_method_id => p_receipt_method_id
,p_receipt_method_name => p_receipt_method_name
,p_doc_sequence_value => p_doc_sequence_value
,p_ussgl_transaction_code => p_ussgl_transaction_code
,p_anticipated_clearing_date => p_anticipated_clearing_date
,p_called_from => p_called_from
,p_global_attribute_rec => p_global_attribute_rec
,p_attribute_rec => p_attribute_rec
,p_comments => p_comments
,p_issuer_name => p_issuer_name
,p_issue_date => p_issue_date
,p_issuer_bank_branch_id => p_issuer_bank_branch_id
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data
,p_cr_id => p_cr_id
,p_org_id => l_org_id
);
IF (x_return_status = 'S') THEN
COMMIT;
--fnd_file.PUT_LINE(FND_FILE.OUTPUT,'==================MAIN EXCEPTIONS=================');
dbms_output.put_line('SUCCESS ReceiptNum >'||p_receipt_number);
dbms_output.put_line('Return Status = '|| SUBSTR (x_return_status,1,255));
dbms_output.put_line('p_cr_id = '||p_cr_id);
p_receipt_number := p_receipt_number;
BEGIN
SELECT CASH_RECEIPT_ID INTO W_MID
--,RECEIPT_NUMBER,RECEIPT_METHOD_ID,ORG_ID,CREATION_DATE
FROM AR_CASH_RECEIPTS_ALL
WHERE RECEIPT_NUMBER = p_receipt_number--'98107'
AND TRUNC(CREATION_DATE) LIKE SYSDATE
AND RECEIPT_METHOD_ID = p_receipt_method_id
--and type = 'MISC'
;
EXCEPTION WHEN OTHERS THEN NULL;
END;
--W_MID := 'Created from WS';
W_Status := 'S';
W_Message := 'Return Status = '|| SUBSTR (x_return_status,1,255) ;
ELSE
ROLLBACK;
dbms_output.put_line('Return Status = '|| SUBSTR (x_return_status,1,255));
dbms_output.put_line('Message Count = '|| TO_CHAR(x_msg_count ));
dbms_output.put_line('Message Data = '|| SUBSTR (x_msg_data,1,255));
dbms_output.put_line(APPS.FND_MSG_PUB.Get ( p_msg_index => APPS.FND_MSG_PUB.G_LAST,
p_encoded => APPS.FND_API.G_FALSE));
fnd_file.PUT_LINE(FND_FILE.OUTPUT,'Exception-1 Customer Number:'||p_customer_number||'-'||sqlerrm);
p_receipt_number := NULL;
W_MID := 'Not Created';
W_Status := 'N';
W_Message := 'Message Data = '|| SUBSTR (x_msg_data,1,255) ;
END IF;
ELSE
dbms_output.put_line('customer doesnt exists'||sqlerrm);
p_receipt_number := NULL;
W_MID := 'Not Created';
W_Status := 'N';
W_Message := 'Customer Not Exists = '|| SUBSTR (sqlerrm,1,255) ;
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Exception :'||sqlerrm);
fnd_file.PUT_LINE(FND_FILE.OUTPUT,'Exception-Last Customer Numebr:'||p_customer_number||'-'||sqlerrm);
p_receipt_number := NULL;
W_MID := 'Not Created';
W_Status := 'N';
W_Message := 'Message Data = '|| SUBSTR (sqlerrm,1,255) ;
END;
/
No comments:
Post a Comment