Sie sind auf Seite 1von 24

How to Create Custom Invoice Charges

Matching Validations for LCM

Version 1.0
How to Create Custom Invoice Charges Matching Validations for LCM

Disclaimer
The following is intended to outline our general product direction. It is intended for information purposes
only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code,
or functionality, and should not be relied upon in making purchasing decisions. The development, release,
and timing of any features or functionality described for Oracle’s products remains at the sole discretion
of Oracle.
How to Create Custom Invoice Charges Matching Validations for LCM

Introduction
The goal of this document is to guide technical users on how to create Custom Invoice Charges
Matching Validations for LCM.
LCM provides public APIs that are called during AP invoice matching to receipt and also during
invoice validations. Customers are expected to write their own logic within those public APIs, if they
need to validate the matches of Freight/Miscellaneous invoices to receipt lines, under LCM
perspective.
The following are supported by those APIs:
 Validate a match to an individual receipt line, under LCM perspective, and decide it the match
should be allowed or not, depending on the validation results
 Validate the whole invoice, under LCM perspective, and decide if the if the invoice should be put on
hold or not, depending on the validation results

Technical Information
Public APIs List
Customers can use the following public APIs to write their LCM-oriented validation logic:
1. INL_CUSTOM_PUB.Validate_APMatching:
This API receives the transaction id of the receipt line being matched, along with other input
parameters useful for validation, like cost factor and supplier. Based on those received parameters,
customers can write their own logic to derive other pieces of information, validate the receipt line
under LCM point of view, and then return output parameters that will determine whether the match
will be accepted or not, along with messages explaining the reasons.
2. INL_CUSTOM_PUB.Validate_APInvoice:
This API receives the id of the invoice being validated, along with other input parameters useful for
validation, like invoice date, currency conversion and supplier. Based on those received parameters,
customers can write their own logic to derive other pieces of information, validate the invoice under
LCM point of view, and then return output parameters that will determine whether the invoice will
be put on hold or not.

APIs Signatures
This section provides the signatures of the public APIs described in the section above.

2
How to Create Custom Invoice Charges Matching Validations for LCM

PROCEDURE Validate_APMatching (
p_calling_mode IN VARCHAR2,
p_rcv_transaction_id IN NUMBER,
p_cost_factor_id IN NUMBER,
p_vendor_id IN NUMBER,
p_vendor_site_id IN NUMBER,
x_msg_names OUT NOCOPY INL_MATCH_GRP.inl_msg_names_tbl_tp,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2
);
PROCEDURE Validate_APInvoice (
p_invoice_id IN NUMBER,
p_invoice_num IN VARCHAR2,
p_invoice_date IN DATE,
p_curr_conv_rate IN NUMBER,
p_vendor_id IN NUMBER,
p_calling_sequence IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2

);

3
How to Create Custom Invoice Charges Matching Validations for LCM

How to Customize Matching Validation Public API


The Matching Validation is triggered as soon as the user chooses a given receipt line, on the Match
Other Charges to Receipt form, by ckecking on the Match checkbox. At this moment, the
Validate_APMatching API is called, receiving the input parameters from the receipt line being
matched.
Customers should write their own logic to validate the receipt line against LCM, by comparing receipt
line attributes (or other attributes derived from the receipt line) against LCM attributes. Depending on
the results of that comparison, the customer may find that the receipt line one of the following:
 Compliant with LCM: in this case the user-defined logic should return the x_return_status output
parameter as “S”, which means “Success”
 Not compliant with LCM: in this case the user-defined logic should return the x_return_status
output parameter as “E”, which means “Error”. The Match checkbox will be automatically
unchecked, for those cases.
 Irrespective of the “Success” or “Error” return of x_return_status output parameter, customers can
also return one or more messages that explain the result of the validation.
For each message the customer wants to return, the following APIs should be called:

FND_MESSAGE.SET_NAME ('INL', 'MMMMMMMMMM');


FND_MSG_PUB.ADD;

Please notice that ‘MMMMMMMMMM’ refers to the message name, configured as recommended
on Message Setup section above.
For more details on Application Messages, please review the Message Dictionary APIs for PL/SQL
Procedures chapter of the Oracle Applications Developer’s Guide.
Please see the Sample Code section below, with respect to examples on how to call these APIs.
 In case on any unexpected error in the custom code (like a division by zero, for example),
x_return_status will be returned as “U”, which means “Unexpected Error”. Oracle error message
will be automatically returned and the Match checkbox will be automatically unchecked, for those
cases.

Messages Setup
Any message to be issued to the user through the Matching Validation feature below must be
previously configured, through the following steps:
 Login to Application Developer responsibility
 Navigate to Application -> Messages
 Enter the message, by informing the fields Name, Language, Application and Current Message Text

4
How to Create Custom Invoice Charges Matching Validations for LCM

 For Application field, please inform “INL” (Landed Cost Management product short name)
 Save the entered message, by clicking on the Save icon or clicking on File -> Save

5
How to Create Custom Invoice Charges Matching Validations for LCM

Below are the messages used in the sample code we are providing for Matching Validation.

Message used in Example 1: Missing ELC for a cost factor (CUST_INL_MTCH_ELC)

6
How to Create Custom Invoice Charges Matching Validations for LCM

Message used in Example 2: LCM Shipment Line is “Closed for Matching”


(CUST_INL_MTCH_SL_CLOSED)

7
How to Create Custom Invoice Charges Matching Validations for LCM

Message used in Example 3: Receipt is “Fully Returned” (CUST_INL_MTCH_SL_RETURNED)

Sample Code

Example 1: Validate whether estimated amounts exist when matching other charges to LCM-
enabled receipt lines

Database package INL_CUSTOM_PUB (INLPCUSB.pls file)


PROCEDURE Validate_APMatching (
p_calling_mode IN VARCHAR2,
p_rcv_transaction_id IN NUMBER,
p_cost_factor_id IN NUMBER,
p_vendor_id IN NUMBER,
p_vendor_site_id IN NUMBER,
x_msg_names OUT NOCOPY INL_MATCH_GRP.inl_msg_names_tbl_tp,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2
) IS
l_program_name CONSTANT VARCHAR2(30) := 'Validate_APMatching';
l_return_status VARCHAR2(1);

-- Sample code BEGIN


l_estimated_allocated_amt NUMBER := 0;
l_organization_code VARCHAR2(3);
l_ship_num VARCHAR2(25);
l_ship_line_num NUMBER;
l_ship_line_group_num NUMBER;

8
How to Create Custom Invoice Charges Matching Validations for LCM

-- Sample code END

BEGIN

... Standard code

-- Sample code BEGIN


SELECT
NVL(SUM(lc.estimated_allocated_amt),0),
x.organization_code,
x.ship_num,
x.ship_line_num,
x.ship_line_group_num
INTO
l_estimated_allocated_amt,
l_organization_code,
l_ship_num,
l_ship_line_num,
l_ship_line_group_num
FROM
inl_det_landed_costs_v lc,
(SELECT
NVL(sl.parent_ship_line_id,sl.ship_line_id) parent_ship_line_id,
sh.adjustment_num,
ood.organization_code,
sh.ship_num,
sl.ship_line_num,
slg.ship_line_group_num
FROM
inl_ship_lines_all sl,
inl_ship_line_groups slg,
inl_ship_headers_all sh,
rcv_transactions rt,
org_organization_definitions ood
WHERE sl.ship_line_id = rt.lcm_shipment_line_id
AND rt.transaction_id = p_rcv_transaction_id
AND sl.ship_header_id = slg.ship_header_id
AND sl.ship_line_group_id = slg.ship_line_group_id
AND sl.ship_header_id = sh.ship_header_id
AND ood.organization_id = sh.organization_id) x
WHERE lc.charge_line_type_id(+) = p_cost_factor_id
AND NVL(lc.parent_ship_line_id(+), lc.ship_line_id(+)) = x.parent_ship_line_id
AND lc.adjustment_num(+) = x.adjustment_num
GROUP BY x.organization_code,
x.ship_num,
x.ship_line_num,
x.ship_line_group_num;

IF l_estimated_allocated_amt = 0 THEN

FND_MESSAGE.SET_NAME ('INL', 'CUST_INL_MTCH_ELC') ;


FND_MESSAGE.SET_TOKEN ('ORG_CODE', l_organization_code) ;
FND_MESSAGE.SET_TOKEN ('SHIP_NUM', l_ship_num) ;
FND_MESSAGE.SET_TOKEN ('SHIP_GROUP', l_ship_line_group_num) ;
FND_MESSAGE.SET_TOKEN ('SHIP_LINE', l_ship_line_num) ;
FND_MSG_PUB.ADD;
x_msg_names(NVL(x_msg_names.COUNT,0)+1):='CUST_INL_MTCH_ELC';

-- Setting x_return_status to "Error", so that the Matching checkbox can be


-- automatically unchecked.
-- Comment this line, if you want the Match to be done in spite of the
validation failure.
x_return_status := fnd_api.G_RET_STS_ERROR;

END IF;

9
How to Create Custom Invoice Charges Matching Validations for LCM

-- Sample code END

... Standard code

END Validate_APMatching;

10
How to Create Custom Invoice Charges Matching Validations for LCM

Example 2: Control match closure status for LCM-enabled receipt lines

Database package INL_CUSTOM_PUB (INLPCUSB.pls file)

PROCEDURE Validate_APMatching (
p_calling_mode IN VARCHAR2,
p_rcv_transaction_id IN NUMBER,
p_cost_factor_id IN NUMBER,
p_vendor_id IN NUMBER,
p_vendor_site_id IN NUMBER,
x_msg_names OUT NOCOPY INL_MATCH_GRP.inl_msg_names_tbl_tp,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2
) IS
l_program_name CONSTANT VARCHAR2(30) := 'Validate_APMatching';
l_return_status VARCHAR2(1);

-- Sample code BEGIN


l_closed_for_matching_flag VARCHAR2(1);
l_organization_code VARCHAR2(3);
l_ship_num VARCHAR2(25);
l_ship_line_num NUMBER;
l_ship_line_group_num NUMBER;
-- Sample code END

BEGIN

... Standard code

-- Sample code BEGIN


SELECT
x.closed_for_matching_flag,
x.organization_code,
x.ship_num,
x.ship_line_num,
x.ship_line_group_num
INTO
l_closed_for_matching_flag,
l_organization_code,
l_ship_num,
l_ship_line_num,
l_ship_line_group_num
FROM
inl_det_landed_costs_v lc,
(SELECT
sl.closed_for_matching_flag,
NVL(sl.parent_ship_line_id,sl.ship_line_id) parent_ship_line_id,
sh.adjustment_num,
ood.organization_code,
sh.ship_num,
sl.ship_line_num,
slg.ship_line_group_num
FROM
inl_ship_lines_all sl,
inl_ship_line_groups slg,
inl_ship_headers_all sh,
rcv_transactions rt,
org_organization_definitions ood
WHERE sl.ship_line_id = rt.lcm_shipment_line_id
AND rt.transaction_id = p_rcv_transaction_id
AND sl.ship_header_id = slg.ship_header_id
AND sl.ship_line_group_id = slg.ship_line_group_id
AND sl.ship_header_id = sh.ship_header_id
AND ood.organization_id = sh.organization_id) x

11
How to Create Custom Invoice Charges Matching Validations for LCM

WHERE lc.charge_line_type_id(+) = p_cost_factor_id


AND NVL(lc.parent_ship_line_id(+), lc.ship_line_id(+)) = x.parent_ship_line_id
AND lc.adjustment_num(+) = x.adjustment_num
GROUP BY x.closed_for_matching_flag,
x.organization_code,
x.ship_num,
x.ship_line_num,
x.ship_line_group_num;

IF NVL(l_closed_for_matching_flag,'N')='Y' THEN

FND_MESSAGE.SET_NAME ('INL', 'CUST_INL_MTCH_SL_CLOSED') ;


FND_MESSAGE.SET_TOKEN ('ORG_CODE', l_organization_code) ;
FND_MESSAGE.SET_TOKEN ('SHIP_NUM', l_ship_num) ;
FND_MESSAGE.SET_TOKEN ('SHIP_GROUP', l_ship_line_group_num) ;
FND_MESSAGE.SET_TOKEN ('SHIP_LINE', l_ship_line_num) ;
FND_MSG_PUB.ADD;
x_msg_names(NVL(x_msg_names.COUNT,0)+1):='CUST_INL_MTCH_SL_CLOSED';

-- Setting x_return_status to "Error", so that the Matching checkbox can be


-- automatically unchecked.
-- Comment this line, if you want the Match to be done in spite of the
validation failure.
x_return_status := fnd_api.G_RET_STS_ERROR;

END IF;

-- Sample code END

... Standard code

END Validate_APMatching;

12
How to Create Custom Invoice Charges Matching Validations for LCM

Example 3: Alert whether the receipt line is fully returned


Database package INL_CUSTOM_PUB (INLPCUSB.pls file)

PROCEDURE Validate_APMatching (
p_calling_mode IN VARCHAR2,
p_rcv_transaction_id IN NUMBER,
p_cost_factor_id IN NUMBER,
p_vendor_id IN NUMBER,
p_vendor_site_id IN NUMBER,
x_msg_names OUT NOCOPY INL_MATCH_GRP.inl_msg_names_tbl_tp,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2
) IS
l_program_name CONSTANT VARCHAR2(30) := 'Validate_APMatching';
l_return_status VARCHAR2(1);

-- Sample code BEGIN


l_organization_code VARCHAR2(3);
l_ship_num VARCHAR2(25);
l_ship_line_num NUMBER;
l_ship_line_group_num NUMBER;
l_dummy NUMBER;
l_received_txn_qty NUMBER;
l_corrected_txn_qty NUMBER;
l_rtv_txn_qty NUMBER;
-- Sample code END

BEGIN

... Standard code

-- Sample code BEGIN


SELECT
x.organization_code,
x.ship_num,
x.ship_line_num,
x.ship_line_group_num
INTO
l_organization_code,
l_ship_num,
l_ship_line_num,
l_ship_line_group_num
FROM
inl_det_landed_costs_v lc,
(SELECT
NVL(sl.parent_ship_line_id,sl.ship_line_id) parent_ship_line_id,
sh.adjustment_num,
ood.organization_code,
sh.ship_num,
sl.ship_line_num,
slg.ship_line_group_num
FROM
inl_ship_lines_all sl,
inl_ship_line_groups slg,
inl_ship_headers_all sh,
rcv_transactions rt,
org_organization_definitions ood
WHERE sl.ship_line_id = rt.lcm_shipment_line_id
AND rt.transaction_id = p_rcv_transaction_id
AND sl.ship_header_id = slg.ship_header_id
AND sl.ship_line_group_id = slg.ship_line_group_id
AND sl.ship_header_id = sh.ship_header_id
AND ood.organization_id = sh.organization_id) x

13
How to Create Custom Invoice Charges Matching Validations for LCM

WHERE lc.charge_line_type_id(+) = p_cost_factor_id


AND NVL(lc.parent_ship_line_id(+), lc.ship_line_id(+)) = x.parent_ship_line_id
AND lc.adjustment_num(+) = x.adjustment_num
GROUP BY organization_code,
x.ship_num,
x.ship_line_num,
x.ship_line_group_num;

rcv_invoice_matching_sv.get_quantities
(top_transaction_id => p_rcv_transaction_id,
ordered_po_qty => l_dummy,
cancelled_po_qty => l_dummy,
received_po_qty => l_dummy,
corrected_po_qty => l_dummy,
delivered_po_qty => l_dummy,
rtv_po_qty => l_dummy,
billed_po_qty => l_dummy,
accepted_po_qty => l_dummy,
rejected_po_qty => l_dummy,
ordered_txn_qty => l_dummy,
cancelled_txn_qty => l_dummy,
received_txn_qty => l_received_txn_qty,
corrected_txn_qty => l_corrected_txn_qty,
delivered_txn_qty => l_dummy,
rtv_txn_qty => l_rtv_txn_qty,
billed_txn_qty => l_dummy,
accepted_txn_qty => l_dummy,
rejected_txn_qty => l_dummy);

IF (NVL(l_received_txn_qty,0) + NVL(l_corrected_txn_qty,0) -
NVL(l_rtv_txn_qty,0))<0.00001
THEN
FND_MESSAGE.SET_NAME ('INL', 'CUST_INL_MTCH_SL_RETURNED') ;
FND_MESSAGE.SET_TOKEN ('ORG_CODE', l_organization_code) ;
FND_MESSAGE.SET_TOKEN ('SHIP_NUM', l_ship_num) ;
FND_MESSAGE.SET_TOKEN ('SHIP_GROUP', l_ship_line_group_num) ;
FND_MESSAGE.SET_TOKEN ('SHIP_LINE', l_ship_line_num) ;
FND_MSG_PUB.ADD;
x_msg_names(NVL(x_msg_names.COUNT,0)+1):='CUST_INL_MTCH_SL_RETURNED';

-- Setting x_return_status to "Error", so that the Matching checkbox can be


-- automatically unchecked.
-- Comment this line, if you want the Match to be done in spite of the
validation failure.
x_return_status := fnd_api.G_RET_STS_ERROR;
END IF;

-- Sample code END

... Standard code

END Validate_APMatching;

14
How to Create Custom Invoice Charges Matching Validations for LCM

How to Customize Invoice Validation Public API


This validation is triggered as part of the invoice validation process. At this moment, the
Validate_APInvoice API is called, receiving the input parameters from the invoice being validated.
Customers should write their own logic to validate the invoice against LCM, generally by comparing
invoice amounts against LCM estimated amounts. Depending on the results of that comparison, the
customer may want to either prevent the invoice from being validated, raising applicable holds or
release previously raised holds.
 To raise a hold from within the custom code, customers should call the
ap_approval_pkg.process_inv_hold_status API.
 To release a previously raised hold from within the custom code, customers should call the
ap_holds_pkg.quick_release and ap_accounting_events_pkg.update_invoice_events_status APIs.
Please see the Sample Code section below, with respect to examples on how to call these APIs.

Holds Setup
Any holds to be raised through the Invoice Validation feature below must be previously configured,
through the following steps:
 Login to Oracle Payables responsibility
 Navigate to Invoices -> Setup -> Invoice -> Hold and Release Names
 Enter the hold, by informing the fields Name, Description, Type, Accounting Allowed and Manual
Release Allowed.
 Save the entered hold, by clicking on the Save icon or clicking on File -> Save

15
How to Create Custom Invoice Charges Matching Validations for LCM

Below are the holds used in the sample code we are providing for Invoice Validation.

Hold used in Example 4: Charge amount is over tolerance (CUST_INL_MTCH_OVER_TOL_HL)

16
How to Create Custom Invoice Charges Matching Validations for LCM

Hold used in Example 5: LCM Shipment Line is “Closed for Matching” (CUST_INL_MTCH_SL_CLOSED)

For more details on Holds, please review the Holds chapter of the Oracle Payables User’s Guide.

17
How to Create Custom Invoice Charges Matching Validations for LCM

Sample Code

Example 4: Check for charge price tolerance between actual amounts and estimated amounts
(Hold)
Database package INL_CUSTOM_PUB (INLPCUSB.pls file)
PROCEDURE Validate_APInvoice (
p_invoice_id IN NUMBER,
p_invoice_num IN VARCHAR2,
p_invoice_date IN DATE,
p_curr_conv_rate IN NUMBER,
p_vendor_id IN NUMBER,
p_calling_sequence IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2)
IS
l_program_name CONSTANT VARCHAR2(30) := 'Validate_APInvoice';
l_return_status VARCHAR2(1);

-- Sample code BEGIN


l_system_user NUMBER:=5;
l_charge_price_tolerance NUMBER:=10; --10%

CURSOR c_inv_lines
IS
SELECT
rt.transaction_id rcv_transaction_id,
rt.po_line_location_id,
l.cost_factor_id,
sh.adjustment_num,
sh.ship_header_id,
NVL(sl.parent_ship_line_id, sl.ship_line_id) parent_ship_line_id,
NVL(SUM(d.amount),0) amount,
NVL(SUM(lc.estimated_allocated_amt),0) estimated_allocated_amt
FROM
rcv_transactions rt,
ap_invoice_distributions_all d,
ap_invoice_lines_all l,
inl_det_landed_costs_v lc,
inl_ship_lines_all sl,
inl_ship_headers_all sh
WHERE d.invoice_id = p_invoice_id
AND d.invoice_id = l.invoice_id
AND d.invoice_line_number = l.line_number
AND l.line_type_lookup_code IN ('MISCELLANEOUS', 'FREIGHT', 'ITEM')
AND rt.lcm_shipment_line_id IS NOT NULL
AND rt.transaction_id = NVL(l.rcv_transaction_id,d.rcv_transaction_id)
AND sl.ship_line_id = rt.lcm_shipment_line_id
AND charge_line_type_id = l.cost_factor_id
AND sl.ship_header_id = sh.ship_header_id
AND NVL(lc.parent_ship_line_id, lc.ship_line_id) = NVL(sl.parent_ship_line_id,
sl.ship_line_id)
AND lc.adjustment_num = sh.adjustment_num
GROUP BY
rt.transaction_id,
rt.po_line_location_id,
l.cost_factor_id,
sl.closed_for_matching_flag,
sh.adjustment_num,
NVL(sl.parent_ship_line_id, sl.ship_line_id),
sh.ship_header_id;

TYPE inv_lines_type IS TABLE OF c_inv_lines%ROWTYPE;

18
How to Create Custom Invoice Charges Matching Validations for LCM

l_inv_lines_list inv_lines_type;
l_holds ap_approval_pkg.holdsarray;
l_holds_count ap_approval_pkg.countarray;
l_release_count ap_approval_pkg.countarray;
l_holds_count_num NUMBER;
l_hold_release_lookup_code VARCHAR2 (25) := 'INVOICE QUICK RELEASED';
l_approval_status_lookup_code VARCHAR2 (25);
l_charge_price_tolerance_error VARCHAR2 (1);
l_actual_allocated_amt NUMBER;
l_matched_amt NUMBER;
l_lcm_lines NUMBER;
-- Sample code END

BEGIN

... Standard code

-- Sample code BEGIN


OPEN c_inv_lines;
FETCH c_inv_lines
BULK COLLECT INTO l_inv_lines_list;
CLOSE c_inv_lines;
l_charge_price_tolerance_error:='N';
IF NVL (l_inv_lines_list.LAST, 0) > 0
THEN
FOR i IN l_inv_lines_list.FIRST .. l_inv_lines_list.LAST
LOOP

-- Check for charge price tolerance between actual amounts and estimated
amounts (Hold)
IF
l_inv_lines_list(i).estimated_allocated_amt*(1+l_charge_price_tolerance/100) >
l_inv_lines_list(i).amount
THEN
SELECT
NVL(SUM(alloc.allocation_amt),0)
INTO
l_actual_allocated_amt
FROM
inl_allocations alloc,
inl_ship_lines_all sl,
inl_ship_headers_all sh,
inl_charge_lines cl
WHERE alloc.ship_header_id = l_inv_lines_list(i).ship_header_id
AND alloc.ship_header_id = sh.ship_header_id
AND sl.ship_line_id = alloc.ship_line_id
AND NVL(sl.parent_ship_line_id, sl.ship_line_id) =
l_inv_lines_list(i).parent_ship_line_id
AND alloc.from_parent_table_name = 'INL_CHARGE_LINES'
AND alloc.from_parent_table_id = cl.charge_line_id
AND cl.charge_line_type_id = l_inv_lines_list(i).cost_factor_id
AND cl.adjustment_num > 0
AND alloc.adjustment_num = sh.adjustment_num;

IF
l_inv_lines_list(i).estimated_allocated_amt*(1+l_charge_price_tolerance/100) >
(l_inv_lines_list(i).amount + l_actual_allocated_amt)
THEN
SELECT NVL (SUM (NVL (mi.matched_amt, 0)), 0)
INTO l_matched_amt
FROM inl_matches_int mi
WHERE mi.to_parent_table_name = 'RCV_TRANSACTIONS'
AND mi.to_parent_table_id = l_inv_lines_list(i).rcv_transaction_id
AND mi.match_type_code = 'CHARGE'
AND mi.charge_line_type_id = l_inv_lines_list(i).cost_factor_id

19
How to Create Custom Invoice Charges Matching Validations for LCM

AND NOT EXISTS(


SELECT1
FROMinl_matches m
WHEREm.from_parent_table_name =
'AP_INVOICE_DISTRIBUTIONS'
AND m.from_parent_table_id = mi.from_parent_table_id);
IF
l_inv_lines_list(i).estimated_allocated_amt*(1+l_charge_price_tolerance/100) <
(l_inv_lines_list(i).amount + l_actual_allocated_amt + l_matched_amt)
THEN
l_charge_price_tolerance_error:='Y';
END IF;
ELSE
l_charge_price_tolerance_error:='Y';
END IF;
ELSE
l_charge_price_tolerance_error:='Y';
END IF;
IF l_charge_price_tolerance_error = 'Y'
THEN
ap_approval_pkg.process_inv_hold_status
(p_invoice_id => p_invoice_id,
p_line_location_id => l_inv_lines_list
(i).po_line_location_id,
p_rcv_transaction_id => l_inv_lines_list
(i).rcv_transaction_id,
p_hold_lookup_code => 'CUST_INL_MTCH_OVER_TOL_HL',
p_should_have_hold => 'Y',
p_hold_reason => NULL,
p_system_user => l_system_user,
p_holds => l_holds,
p_holds_count => l_holds_count,
p_release_count => l_release_count,
p_calling_sequence => p_calling_sequence
);
ELSE
ap_holds_pkg.quick_release
(x_invoice_id => p_invoice_id,
x_hold_lookup_code => 'CUST_INL_MTCH_OVER_TOL_HL',
x_release_lookup_code => l_hold_release_lookup_code,
x_release_reason => NULL,
x_responsibility_id => fnd_global.resp_id,
x_last_updated_by => l_system_user,
x_last_update_date => SYSDATE,
x_holds_count => l_holds_count_num,
x_approval_status_lookup_code =>
l_approval_status_lookup_code,
x_calling_sequence => p_calling_sequence
);
ap_accounting_events_pkg.update_invoice_events_status
(p_invoice_id => p_invoice_id,
p_calling_sequence => p_calling_sequence
);
END IF;

END LOOP;

END IF;
-- Sample code END

... Standard code

END Validate_APInvoice;

20
How to Create Custom Invoice Charges Matching Validations for LCM

Example 5: Invoice Matching Closure Status Check (Hold)


Database package INL_CUSTOM_PUB (INLPCUSB.pls file)
PROCEDURE Validate_APInvoice (
p_invoice_id IN NUMBER,
p_invoice_num IN VARCHAR2,
p_invoice_date IN DATE,
p_curr_conv_rate IN NUMBER,
p_vendor_id IN NUMBER,
p_calling_sequence IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2)
IS
l_program_name CONSTANT VARCHAR2(30) := 'Validate_APInvoice';
l_return_status VARCHAR2(1);

-- Sample code BEGIN


l_system_user NUMBER:=5;

l_charge_price_tolerance NUMBER:=10; --10%

CURSOR c_inv_lines
IS
SELECT distinct
rt.transaction_id rcv_transaction_id,
rt.po_line_location_id,
sl.closed_for_matching_flag
FROM
rcv_transactions rt,
ap_invoice_distributions_all d,
ap_invoice_lines_all l,
inl_det_landed_costs_v lc,
inl_ship_lines_all sl,
inl_ship_headers_all sh
WHERE d.invoice_id = p_invoice_id
AND d.invoice_id = l.invoice_id
AND d.invoice_line_number = l.line_number
AND l.line_type_lookup_code IN ('MISCELLANEOUS', 'FREIGHT', 'ITEM')
AND rt.lcm_shipment_line_id IS NOT NULL
AND rt.transaction_id = NVL(l.rcv_transaction_id,d.rcv_transaction_id)
AND sl.ship_line_id = rt.lcm_shipment_line_id
AND charge_line_type_id = l.cost_factor_id
AND sl.ship_header_id = sh.ship_header_id
AND NVL(lc.parent_ship_line_id, lc.ship_line_id) = NVL(sl.parent_ship_line_id,
sl.ship_line_id)
AND lc.adjustment_num = sh.adjustment_num;

TYPE inv_lines_type IS TABLE OF c_inv_lines%ROWTYPE;

l_inv_lines_list inv_lines_type;
l_holds ap_approval_pkg.holdsarray;
l_holds_count ap_approval_pkg.countarray;
l_release_count ap_approval_pkg.countarray;
l_holds_count_num NUMBER;
l_hold_release_lookup_code VARCHAR2 (25) := 'INVOICE QUICK RELEASED';
l_approval_status_lookup_code VARCHAR2 (25);
l_charge_price_tolerance_error VARCHAR2 (1);
l_actual_allocated_amt NUMBER;
l_matched_amt NUMBER;
l_lcm_lines NUMBER;
-- Sample code END

BEGIN

21
How to Create Custom Invoice Charges Matching Validations for LCM

... Standard code

-- Sample code BEGIN


OPEN c_inv_lines;
FETCH c_inv_lines
BULK COLLECT INTO l_inv_lines_list;
CLOSE c_inv_lines;
l_charge_price_tolerance_error:='N';
IF NVL (l_inv_lines_list.LAST, 0) > 0
THEN
FOR i IN l_inv_lines_list.FIRST .. l_inv_lines_list.LAST
LOOP

-- Invoice Matching Closure Status Check (Hold)


IF l_inv_lines_list(i).closed_for_matching_flag = 'Y'
THEN
ap_approval_pkg.process_inv_hold_status
(p_invoice_id => p_invoice_id,
p_line_location_id => l_inv_lines_list
(i).po_line_location_id,
p_rcv_transaction_id => l_inv_lines_list
(i).rcv_transaction_id,
p_hold_lookup_code => 'CUST_INL_MTCH_SL_CLOSED',
p_should_have_hold => 'Y',
p_hold_reason => NULL,
p_system_user => l_system_user,
p_holds => l_holds,
p_holds_count => l_holds_count,
p_release_count => l_release_count,
p_calling_sequence => p_calling_sequence
);
ELSE
ap_holds_pkg.quick_release
(x_invoice_id => p_invoice_id,
x_hold_lookup_code => 'CUST_INL_MTCH_SL_CLOSED',
x_release_lookup_code => l_hold_release_lookup_code,
x_release_reason => NULL,
x_responsibility_id => fnd_global.resp_id,
x_last_updated_by => l_system_user,
x_last_update_date => SYSDATE,
x_holds_count => l_holds_count_num,
x_approval_status_lookup_code =>
l_approval_status_lookup_code,
x_calling_sequence => p_calling_sequence
);
ap_accounting_events_pkg.update_invoice_events_status
(p_invoice_id => p_invoice_id,
p_calling_sequence => p_calling_sequence
);
END IF;

END LOOP;

END IF;
-- Sample code END

... Standard code

END Validate_APInvoice;

22
White Paper Title Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
[Month] 2013
Author: [OPTIONAL] This document is provided for information purposes only, and the contents hereof are subject to change without notice. This
Contributing Authors: [OPTIONAL] document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in
law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any
Oracle Corporation
liability with respect to this document, and no contractual obligations are formed either directly or indirectly by this document. This
World Headquarters
document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our
500 Oracle Parkway
prior written permission.
Redwood Shores, CA 94065
U.S.A.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Worldwide Inquiries:
Phone: +1.650.506.7000 Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and
Fax: +1.650.506.7200 are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are
trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 0113
oracle.com

Das könnte Ihnen auch gefallen