It could happen that inventory adjustment journals are created after an intercompany sales order is created with picking list generated and packing slip posted for the same item in the order and different price. This by it self doesn’t create a problem until the IC order has to be invoiced which updates the order lines with the latest price adjustments. As the intercompany rules require to keep the same price from creating the orders to invoicing in order to prevent the update (actually re-update) we need to extend class ‘IntercompanySalesAtCostPriceFormLetterHandler’ and method ‘onSalesLineSelected’. Before CoC we need to keep the previous value and then after it we will update the sales line with the original value.
[ExtensionOf(classStr(IntercompanySalesAtCostPriceFormLetterHandler))]
final class IntercompanySalesAtCostPriceFormLetterHandler_Extension
{
public void onSalesLineSelected(SalesLine _salesLine)
{
SalesPrice origSalesPrice = _salesLine.SalesPrice;
SalesLineAmount origLineAmount = _salesLine.LineAmount;
next onSalesLineSelected(_salesLine);
//revert the price to the original price
if (origSalesPrice)
{
ttsbegin;
SalesLine salesLineLocal = SalesLine::findRecId(_salesLine.RecId, true);
salesLineLocal.SalesPrice = origSalesPrice;
salesLineLocal.LineAmount = origLineAmount;
salesLineLocal.update();
ttscommit;
}
}
public void onSalesLinesSelectionStarted()
{
next onSalesLinesSelectionStarted();
}
public void onSalesLinesSelectionFinished()
{
next onSalesLinesSelectionFinished();
}
}
Just have in mind that you need to extend methods ‘onSalesLinesSelectionStarted’ and ‘onSalesLinesSelectionFinished’ as well as they must reside in the same transaction as ‘onSalesLineSelected’.
related posts
November 29, 2023