2014年10月6日 星期一

[ AP ] Void Payment 產生分錄借貸不平, Accounting fatal error - 含修改APXPAWKB.fmb bug

User 在Payment 輸入完成時還沒有點選存檔, 就發現Payment 日期錯誤, 點選Action Void 系統會帶入void datea & gl_date 為sysdate, 只要GL_date 小於payment date , void的payment  分錄就會產生不平, 而且在第一次的payment 分錄, 出現借貸金額不符, void payment 的分錄, 則出現分錄不全的狀況, 就要自己補分錄



Payment 沒有存檔, 就以系統日期或小於payment date 日期輸入時, 只會出現Caution 訊息

如果payment 存過檔或是重新查詢, 則會出現Error 錯誤訊息, 則要求必須在Payment GL Date 之後




User 於月底時執行 Request : Payables Accounting Process
有Error 在Request 不會出現, 只會顯示Complete......Orz

要自已點到View output 跟log 檔才會看到錯誤~


當Void Payment 時, 若GL_Date 小於Payment Date 時, 會產生借貸不平的分錄



如果User沒注意到accounting 的output內有Fatal Error, 又執行了
Request: Payables Transfer to General Ledger 然後再自動呼叫了Journal Import
在Journal Import 就會看到 總借貸金額不符
前方則會顯示有問題的Payment Invoice Number




解決方法:
說明
相關語法
1.           
找出有借貸不平的資料
未轉GL

select ae_line_id
       ,ae_header_id
       , entered_dr
       ,accounted_dr
       , entered_cr
       ,accounted_cr
       , reference1  -- supplier
       , reference3  -- ap_invoice_payments.invoice_payment_id 沖帳的
       , reference4  -- check number
  from ap_ae_lines_all
 where  (entered_dr <> accounted_dr
     or entered_cr <> accounted_cr)
  and currency_code = 'TWD'
2.           
更新分錄借貸金額不平ap_ae_lines_all
update ap_ae_lines_all
set entered_dr = 7848
where ae_line_id = 1682587

3.           
找出有借貸不平的資料
已轉GL

SELECT reference21  -- supplier
      , reference24  -- pay document no 47439
      , reference25  -- invoice no
      , entered_dr
      , entered_cr
      , accounted_dr
      , accounted_cr
      , je_header_id
      , je_line_num
 from gl_interface  T
where user_je_source_name = 'Payables'
  and status != 'P'
  and (entered_dr <> accounted_dr
     or entered_cr <> accounted_cr)
4.           
更新GL
update gl_interface
set entered_dr = 7848
where user_je_source_name = 'Payables'
  and status != 'P'
  and je_line_num = 3611

5.           
執行 Request: Payables Accounting Process

執行結束後,Void 的分錄會產生, 但分錄產生不完全
6.           
檢查分錄, 新增分錄
SELECT AIP.INVOICE_PAYMENT_ID  --ap_ae_lines_all.source_id
      ,AC.DOC_SEQUENCE_ID      --ap_ae_lines_all.subledger_doc_sequence_id
      ,AC.DOC_SEQUENCE_VALUE   --ap_ae_lines_all.subledger_doc_sequence_value
      ,AIP.AMOUNT
  FROM ap_invoice_payments AIP
      ,AP_CHECKS_ALL AC
 WHERE AIP.CHECK_ID = AC.CHECK_ID
   AND AC.CHECK_NUMBER = 47439  -- VOIDED CHECK NUMBER


insert into ap.ap_ae_lines_all
(ae_line_id,
 ae_header_id,
 ae_line_number,
 ae_line_type_code,
 code_combination_id,
 currency_code,
 entered_dr,
 accounted_dr,
 source_table,
 source_id,
 third_party_id,
 third_party_sub_id,
 subledger_doc_sequence_id,
 subledger_doc_sequence_value,
 org_id, creation_date, created_by,
 last_update_date,
 last_updated_by,
 last_update_login,
 program_update_date,
 program_application_id,
 program_id, request_id, reference1, reference2,
 reference3, reference4, reference5, reference6,
 reference7, reference9, reference10)
values
(ap_ae_lines_s.nextval,
 456350,  --ae_header_id
 5,  --ae_line_number
 'LIABILITY', --ae_line_type_code
 1365,  --code_combination_id
 'TWD', --currency_code
 3924,  --entered_dr
 3924,  --accounted_dr
 'AP_INVOICE_PAYMENTS', --source_table
 269069,  --source_id  ap_invoice_payments.invoice_payment_id –沖帳的INVOICE
 18579,  --third_party_id  = VENDER_ID
 18833,  --third_party_sub_id = VENDER SITE ID
 105,    --subledger_doc_sequence_id = AP_CHECK_ALL.DOC_SEQUENCE_ID -- VOID
 63699,  --subledger_doc_sequence_value
 82,    --org_id
 sysdate,  --creation_date
 4399,    --created_by
 sysdate, --last_update_date
 4399,   --last_updated_by
 4399, --last_update_login
 sysdate, --program_update_date
 200,    --program_application_id
 -1,    -- program_id
 -1,    --request_id
 'XXXX Vendor Name'-- reference1 
 57814-- reference2 AP_INVOICES.INVOICE_ID
 28379,  -- reference3 AP_CHECKS_ALL.CHECK_ID
 1894-- reference4 AP_CHECKS_ALL.CHECK_NUMBER
 ' 140924XXXXXX',  -- reference5 立費用的INVOICE NUMBER
 'AP Payments',  -- reference6
 1, -- reference7
 269069,  -- reference9 = source_id ap_invoice_payments.invoice_payment_id 沖帳的INVOICE
 'LIABILITY');  -- reference10

7.           
檢查/更新 voidcheck number 狀態
update ap_checks_all
set status_lookup_code = 'VOIDED'
where check_id = 24985

8.           
更新Error
update ap_ae_headers_all
set accounting_error_code = null
where ae_header_id = 79085

9.           
更新accounting 狀態
update ap_ae_headers_all
set accounting_error_code =  null
where ae_header_id = 456350

10.       
執行 Request: Payables Accounting Process
檢查View output
Fatal Error 不見
11.       
若已轉GL
重新執行 GL\Journals \ Import \ RUN



Fix FORM bug....

Program Unit: PAY_ACTIONS_VOID
if (event = 'INIT' and :PAY_ACTIONS.void = 'Y') then
--=========================================================
-- 防止發生void_date payment date , 而產生分錄不平
-- 修改系統預設值, VOID DATE = PAYMENT DATE
--============================================= by JIAMIN ==
       --
       -- :PAY_ACTIONS.void_date := sysdate;
     
      :PAY_ACTIONS.void_date := NVL(:PAY_SUM_FOLDER.CHECK_DATE  , sysdate);

Program Unit: pay_sum_folder_multi
elsif (action = 'PRE-VOID') then
  --======================================================================
  -- Verify that the user wishes to perform action
  --fnd_message.set_name('SQLAP', 'AP_PAY_MULTI_PAY_VOID');  -- 2014.10.03 
  --======================================================== BY JIAMIN ==

  IF :PAY_ACTIONS.VOID_DATE < :PAY_SUM_FOLDER.CHECK_DATE
     OR :PAY_ACTIONS.GL_DATE < :PAY_SUM_FOLDER.CHECK_DATE THEN
       
     Form_Utilities.Display_Failure_Message('AP_VOID_DATE_BEF_INVPAY_DATE',
                     'GL_DATE', app_date.date_to_chardate(:parameter.payment_max_gl_date));     

  END IF;

沒有留言:

張貼留言