...
LineRelation."Deducted Amount" := LineRelation."Deducted Amount" + AmountToDeduct;
LineRelation.MODIFY;
// Delete the following line.
CalcLinkedPmtAmountToApply(LetterLine,AmountToDeduct,LinkedAdvanceEntry);
IF LetterLine."VAT Amount" <> 0 THEN // NO VAT handling
PostVATCorrection(
LetterLine,SalesInvHeader,AmountToDeduct,DocNoForVATCorr,VATAmount,GenJnlPostLine,TempJnlLineDim);
...
...
LineRelation."Deducted Amount" := LineRelation."Deducted Amount" + AmountToDeduct;
LineRelation.MODIFY;
// Add the following lines.
CalcLinkedPmtAmountToApply(
LetterLine,
AmountToDeduct,
LinkedAdvanceEntry,
RetrieveSumAmountToApply(LineRelation,AmountToDeduct));
//End of the added lines.
IF LetterLine."VAT Amount" <> 0 THEN // NO VAT handling
PostVATCorrection(
LetterLine,SalesInvHeader,AmountToDeduct,DocNoForVATCorr,VATAmount,GenJnlPostLine,TempJnlLineDim);
...