使用ar_receipt_api_pub.apply這個API進行核銷時候,因為是以最少的參數進行核銷:
代碼
1 ar_receipt_api_pub.apply( -- Standard API parameters.
2 p_api_version => 1.0,
3 p_init_msg_list => fnd_api.g_true,
4 p_commit => fnd_api.g_true,
5 p_validation_level => fnd_api.g_valid_level_full,
6 x_return_status => l_return_status,
7 x_msg_count => l_msg_count,
8 x_msg_data => l_msg_data,
9
10
11 p_cash_receipt_id => rec_reciept.cash_receipt_id, --收款ID
12 p_customer_trx_id => rec_invoice.customer_trx_id, --交易處理ID
14 );
15
造成的失誤:
如果以最少的參數進行核銷,預設情況下,
假如有4張發票A/B/C/D,發票金額分別為1500,3500,2000,3000,收款8000
1. 標準功能核銷時候,A核銷1500,B核銷3500,C核銷2000,D核銷1000,即最後僅剩下D還有未核銷的情況。
2. 新開發的功能中,客戶可能是想A核銷1000,B核銷3000,C核銷1500,D核銷2500,即每張發票都有餘額。
我使用上面以最少參數進行核銷的API,核銷的結果是1的結果,而不是2的結果。
原因是因為沒有將核銷金額匯入API。
代碼
1 ar_receipt_api_pub.apply( -- Standard API parameters.
2 p_api_version => 1.0,
3 p_init_msg_list => fnd_api.g_true,
4 p_commit => fnd_api.g_true,
5 p_validation_level => fnd_api.g_valid_level_full,
6 x_return_status => l_return_status,
7 x_msg_count => l_msg_count,
8 x_msg_data => l_msg_data,
9 --Receipt application parameters.
10 p_cash_receipt_id => rec_reciept.cash_receipt_id, --收款ID
11 p_customer_trx_id => rec_invoice.customer_trx_id, --交易處理ID
12 p_amount_applied_from => rec_invoice.apply_account --核銷金額
13 );
原本以為OK了,後來提交請求出現錯誤:
+---------------------------------------------------------------------------+
FND_FILE 中日誌訊息開始
+---------------------------------------------------------------------------+
-------------------------------------------------------------
收款編號:++gzb2010042001
----------------------------------
稅票號:++gzb2010042001
-----------------
發票號:++1270335
返回狀態 :E
此發票核銷失敗:E+本位幣收款的已指派收款額與核銷額必須相同。收款編號:gzb2010042001發票號:1270335
error:ORA-0000: normal, successful completion
+---------------------------------------------------------------------------+
FND_FILE 中日誌訊息結束
+---------------------------------------------------------------------------+
解決辦法:
還是我的失誤,翻看Oracle User Guide查看API,在APPLY的與金額相關的三個參數說明:
Amount Applied
The amount applied cannot be null. The error message raised for an invalid value is AR_RAPI_APPLIED_AMT_NULL.
The amount applied must not be greater than the line amount for the given customer_trx_line ID (if specified). The error message raised for an invalid value is AR_RW_APPLIED_GREATER_LINE.
Depending on the creation sign, natural application flag, allow overapplication flag, and the amount due remaining of the specified transaction installment, the amount applied is validated to check for overapplication and natural application. The error messages raised for invalid values are AR_CKAP_OVERAPP, AR_CKAP_NATURALAPP, and AR_CKAP_CT_SIGN. For details of the messages, refer to Messages on page 7-131.
Note: This transaction can be in a currency that is different from the receipt currency.
For a cross currency application, the following equation sheould always be valid:
amount applied * trans to receipt rate = amount applied from
The error message raised is AR_RAPI_INVALID_CC_AMTS.
Amount Applied From
The amount applied from cannot be null. The error message raised for an invalid value is AR_RAPI_AMT_APP_FROM_NULL.
The amount applied from cannot be greater than the unapplied amount available on the receipt. The error message raised for invalid values is AR_RW_APP_NEG_UNAPP.
If the transaction currency and the receipt currency are the same, then the amount applied from must always be equal to the amount applied. The error message raised for an invalid value is AR_RAPI_AMT_APP_FROM_INVALID.
As mentioned previously for a cross currency application, the following equation must always be valid:
amount applied * trans to receipt rate = amount applied from
Trans to Receipt Rate
For a cross currency application, the trans to receipt rate should have a positive value. The error message raised for an invalid value is AR_RW_CC_RATE_POSITIVE.
If the transaction currency and the receipt currency are the same, then the rate should not have any value specified. The error message raised for an invalid value is AR_RAPI_INVALID_CC_RATE.
For a cross currency application, the following equation should always be valid:
amount applied * trans to receipt rate = amount applied from
If this condition is violated, then the error raised is AR_RAPI_CC_RATE_AMTS_INVALID.
發現我的參數搞錯了,匯入API時候,可能會對核銷金額做驗證,正確的Code:
代碼
1 ar_receipt_api_pub.apply( -- Standard API parameters.
2 p_api_version => 1.0,
3 p_init_msg_list => fnd_api.g_true,
4 p_commit => fnd_api.g_true,
5 p_validation_level => fnd_api.g_valid_level_full,
6 x_return_status => l_return_status,
7 x_msg_count => l_msg_count,
8 x_msg_data => l_msg_data,
9 --Receipt application parameters.
10 p_cash_receipt_id => rec_reciept.cash_receipt_id, --收款ID
11 p_customer_trx_id => rec_invoice.customer_trx_id, --交易處理ID
12 p_amount_applied => rec_invoice.apply_account--, --核銷金額
13 );