创建AP计划付款API

ap_create_pay_scheds_pkg.Create_Payment_Schedules --创建计划付款

业务需要后台程序拆分发票计划付款行,可以使用上面的API。但是上述API存在如下问题

1.该API只能生成一条计划付款行,如果已经存在计划付款行,则会报错。

原因:因为每次调用该API都会生成  PAYMENT_NUM = 1 的记录。如果已经存在记录则报违反唯一性约束错误。

2.该API不能插入暂挂,暂挂原因,银行等字段


所以这个地方需要客户化cux_ap_create_pay_scheds_pkg,使其每次进入该API时生成MAX(PAYMENT_NUM)+1 的记录,

其次参数中添加 暂挂,暂挂原因,银行等字段


测试后证明:

使用上述方法可以对一张发票生成多行计划付款,而且能够实现暂挂。

但是当我们验证发票的时候,会发现验证程序会将我们插入的多行记录都删除,然后生成一行数量与发票数量相等的

计划付款,相当于将其初始化了。

验证的时候会调用AP_APPROVAL_PKG.Approve

其中有如下代码:

IF (l_recalc_pay_schedule_flag = 'Y') THEN

      SELECT DECODE(NVL((MAX(aps.last_update_date)- MIN(aps.creation_date)),0),
                     0,'N','Y')
        INTO l_diff_flag
        FROM ap_payment_schedules aps
       WHERE aps.invoice_id = l_invoice_id;

      IF (l_diff_flag = 'N') THEN
        AP_PPA_PKG.Due_Date_Sweeper(
                l_invoice_id,
                l_matched,
                l_system_user,
                l_receipt_acc_days,
                l_curr_calling_sequence);
      END IF;
   END IF;
其中: l_recalc_pay_schedule_flag在OU下设置,这个地方如果 l_diff_flag = 'N'则会进入AP_PPA_PKG.Due_Date_Sweeper。所以我们要使l_diff_flag = 'Y'

AP_PPA_PKG.Due_Date_Sweeper中会根据付款条件行与当前计划付款行条数进行对比,如果计划付款行数多于付款条件行数。

则该API会删除当前计划付款记录。然后插入新的自动生成的记录。

所以只需要在插入计划付款(cux_ap_create_pay_scheds_pkg.Create_Payment_Schedules)的时候使 aps.last_update_date 比 aps.creation_date 大个1s即可。

但是这样是否会有其他问题,还需验证。


调用 cux_ap_create_pay_scheds_pkg.Create_Payment_Schedules

BEGIN
  SELECT aia.terms_id,
         aia.terms_date,
         aia.batch_id,
         aia.invoice_amount,
         aia.payment_cross_rate,
         cfrh.payment_method_code, --aia.payment_method_lookup_code,
         aia.invoice_currency_code,
         aia.payment_currency_code,
         aia.amount_applicable_to_discount,
         aia.last_updated_by,
         aia.created_by,
         'Y',
         NULL
    INTO l_terms_id,
         l_terms_date,
         l_batch_id,
         l_invoice_amount,
         l_payment_cross_rate,
         l_payment_method_lookup_code,
         l_invoice_currency_code,
         l_payment_currency_code,
         l_amount_app_to_discount,
         l_last_update_by,
         l_created_by,
         l_hold_flag,
         l_iby_hold_reason
    FROM ap_invoices_all            aia,
         cux_fin_recpay_headers_all cfrh,
         cux_finreq_headers_all     cfh
   WHERE aia.invoice_id = p_invoice_id
     AND aia.attribute1 = cfh.req_number
     AND cfh.req_header_id = cfrh.req_header_id
     AND rownum = 1;

  cux_ap_create_pay_scheds_pkg.create_payment_schedules(p_invoice_id              => p_invoice_id,
                                                        p_terms_id                => l_terms_id,
                                                        p_last_updated_by         => l_last_update_by,
                                                        p_created_by              => l_created_by,
                                                        p_payment_priority        => 99,
                                                        p_batch_id                => l_batch_id,
                                                        p_terms_date              => l_terms_date,
                                                        p_invoice_amount          => l_invoice_amount,
                                                        p_pay_curr_invoice_amount => l_pay_curr_invoice_amount,--需要输入的金额
                                                        p_payment_cross_rate      => l_payment_cross_rate,
                                                        p_amount_for_discount     => l_amount_app_to_discount,
                                                        p_payment_method          => l_payment_method_lookup_code,
                                                        p_invoice_currency        => l_invoice_currency_code,
                                                        p_payment_currency        => l_payment_currency_code,
                                                        p_calling_sequence        => 'Import_invoices<- Before Report Trigger',
                                                        p_hold_flag               => l_hold_flag,
                                                        p_iby_hold_reason         => l_iby_hold_reason);

END;



你可能感兴趣的:(ORACLE,EBS,AP)