Change the code in the UnapplyCustLedgEntry function in the Gen. Jnl.-Post Line Codeunit (12) as follows:
Existing code 1...
TempVatEntryNo@1028 : Integer;
BEGIN
...
Replacement code 1...
TempVatEntryNo@1028 : Integer;
// Add the following lines.
MultipleDimensions@1170000000 : Boolean;
CustEntryAppPostEntries@1170000001 : Codeunit 226;
TotalAmtMD@1170000004 : ARRAY [10] OF Decimal;
TotalAmtAddCurMD@1170000003 : ARRAY [10] OF Decimal;
DimArr@1170000002 : ARRAY [2,10] OF Code[10];
Arrlen@1170000005 : Integer;
NewComb@1170000006 : Boolean;
// End of the added lines.
BEGIN
...
Existing code 2...
DtldCustLedgEntry2.FINDSET;
// Delete the following lines.
LedgEntryDim.SETRANGE("Table ID",DATABASE::"Cust. Ledger Entry");
LedgEntryDim.SETRANGE("Entry No.",DtldCustLedgEntry2."Applied Cust. Ledger Entry No.");
TempJnlLineDim.RESET;
TempJnlLineDim.DELETEALL;
DimMgt.CopyLedgEntryDimToJnlLineDim(LedgEntryDim,TempJnlLineDim);
IF TempJnlLineDim.GET(DATABASE::"Cust. Ledger Entry",'','',0,0,GLSetup."Global Dimension 1 Code") THEN
GenJnlLine."Shortcut Dimension 1 Code" := TempJnlLineDim."Dimension Value Code"
ELSE
GenJnlLine."Shortcut Dimension 1 Code" := '';
IF TempJnlLineDim.GET(DATABASE::"Cust. Ledger Entry",'','',0,0,GLSetup."Global Dimension 2 Code") THEN
GenJnlLine."Shortcut Dimension 2 Code" := TempJnlLineDim."Dimension Value Code"
ELSE
GenJnlLine."Shortcut Dimension 2 Code" := '';
// End of the deleted lines.
REPEAT
...
Replacement code 2...
DtldCustLedgEntry2.FINDSET;
// Add the following lines.
MultipleDimensions := CustEntryAppPostEntries.MultipleDimensions(DtldCustLedgEntry2."Initial Entry Global Dim. 1",
DtldCustLedgEntry2."Initial Entry Global Dim. 2",DtldCustLedgEntry2);
// End of the added lines.
REPEAT
...
Existing code 3...
REPEAT
// Delete the following lines.
NewDtldCustLedgEntry := DtldCustLedgEntry2;
NewDtldCustLedgEntry."Entry No." := NextDtldLedgEntryEntryNo;
NewDtldCustLedgEntry."Posting Date" := GenJnlLine."Posting Date";
NewDtldCustLedgEntry."Transaction No." := NextTransactionNo;
NewDtldCustLedgEntry.Amount := -DtldCustLedgEntry2.Amount;
NewDtldCustLedgEntry."Amount (LCY)" := -DtldCustLedgEntry2."Amount (LCY)";
NewDtldCustLedgEntry."Debit Amount" := -DtldCustLedgEntry2."Debit Amount";
NewDtldCustLedgEntry."Credit Amount" := -DtldCustLedgEntry2."Credit Amount";
NewDtldCustLedgEntry."Debit Amount (LCY)" := -DtldCustLedgEntry2."Debit Amount (LCY)";
NewDtldCustLedgEntry."Credit Amount (LCY)" := -DtldCustLedgEntry2."Credit Amount (LCY)";
NewDtldCustLedgEntry.Unapplied := TRUE;
NewDtldCustLedgEntry."Unapplied by Entry No." := DtldCustLedgEntry2."Entry No.";
NewDtldCustLedgEntry."Document No." := GenJnlLine."Document No.";
NewDtldCustLedgEntry."Source Code" := GenJnlLine."Source Code";
NewDtldCustLedgEntry."User ID" := USERID;
NewDtldCustLedgEntry.INSERT;
NextDtldLedgEntryEntryNo := NextDtldLedgEntryEntryNo + 1;
// End of the deleted lines.
...
Replacement code 3...
REPEAT
// Add the following lines.
IF DtldCustLedgEntry2."Applied Cust. Ledger Entry No." <> 0 THEN BEGIN
LedgEntryDim.RESET;
LedgEntryDim.SETRANGE("Table ID",DATABASE::"Cust. Ledger Entry");
LedgEntryDim.SETRANGE("Entry No.",DtldCustLedgEntry2."Applied Cust. Ledger Entry No.");
TempJnlLineDim.RESET;
TempJnlLineDim.DELETEALL;
DimMgt.CopyLedgEntryDimToJnlLineDim(LedgEntryDim,TempJnlLineDim);
IF TempJnlLineDim.GET(DATABASE::"Cust. Ledger Entry",'','',0,0,GLSetup."Global Dimension 1 Code") THEN
GenJnlLine."Shortcut Dimension 1 Code" := TempJnlLineDim."Dimension Value Code"
ELSE
GenJnlLine."Shortcut Dimension 1 Code" := '';
IF TempJnlLineDim.GET(DATABASE::"Cust. Ledger Entry",'','',0,0,GLSetup."Global Dimension 2 Code") THEN
GenJnlLine."Shortcut Dimension 2 Code" := TempJnlLineDim."Dimension Value Code"
ELSE
GenJnlLine."Shortcut Dimension 2 Code" := '';
END ELSE BEGIN
GenJnlLine."Shortcut Dimension 1 Code" := DtldCVLedgEntryBuf."Initial Entry Global Dim. 1";
GenJnlLine."Shortcut Dimension 2 Code" := DtldCVLedgEntryBuf."Initial Entry Global Dim. 2";
END;
// End of the added lines.
...
Existing code 4...
// Delete the following lines.
DtldCVLedgEntryBuf.TRANSFERFIELDS(NewDtldCustLedgEntry);
GenJnlLine."Source Currency Code" := DtldCustLedgEntry2."Currency Code";
IF GLSetup."Additional Reporting Currency" <> DtldCVLedgEntryBuf."Currency Code" THEN
DtldCVLedgEntryBuf."Additional-Currency Amount" :=
CalcAddCurrForUnapplication(DtldCVLedgEntryBuf."Posting Date",DtldCVLedgEntryBuf."Amount (LCY)")
ELSE
IF GLSetup."Additional Reporting Currency" <> '' THEN
DtldCVLedgEntryBuf."Additional-Currency Amount" := DtldCVLedgEntryBuf.Amount;
CurrencyLCY.InitRoundingPrecision;
// End of the deleted lines.
...
Replacement code 4...
// Add the following lines.
NewDtldCustLedgEntry := DtldCustLedgEntry2;
NewDtldCustLedgEntry."Entry No." := NextDtldLedgEntryEntryNo;
NewDtldCustLedgEntry."Posting Date" := GenJnlLine."Posting Date";
NewDtldCustLedgEntry."Transaction No." := NextTransactionNo;
NewDtldCustLedgEntry.Amount := -DtldCustLedgEntry2.Amount;
NewDtldCustLedgEntry."Amount (LCY)" := -DtldCustLedgEntry2."Amount (LCY)";
NewDtldCustLedgEntry."Debit Amount" := -DtldCustLedgEntry2."Debit Amount";
NewDtldCustLedgEntry."Credit Amount" := -DtldCustLedgEntry2."Credit Amount";
NewDtldCustLedgEntry."Debit Amount (LCY)" := -DtldCustLedgEntry2."Debit Amount (LCY)";
NewDtldCustLedgEntry."Credit Amount (LCY)" := -DtldCustLedgEntry2."Credit Amount (LCY)";
NewDtldCustLedgEntry.Unapplied := TRUE;
NewDtldCustLedgEntry."Unapplied by Entry No." := DtldCustLedgEntry2."Entry No.";
NewDtldCustLedgEntry."Document No." := GenJnlLine."Document No.";
NewDtldCustLedgEntry."Source Code" := GenJnlLine."Source Code";
NewDtldCustLedgEntry."User ID" := USERID;
NewDtldCustLedgEntry.INSERT;
NextDtldLedgEntryEntryNo := NextDtldLedgEntryEntryNo + 1;
// End of the added lines.
...
Existing code 5...
IF DtldCustLedgEntry2."Entry Type" IN [
...
Replacement code 5...
// Add the following lines.
DtldCVLedgEntryBuf.TRANSFERFIELDS(NewDtldCustLedgEntry);
GenJnlLine."Source Currency Code" := DtldCustLedgEntry2."Currency Code";
IF GLSetup."Additional Reporting Currency" <> DtldCVLedgEntryBuf."Currency Code" THEN
DtldCVLedgEntryBuf."Additional-Currency Amount" :=
CalcAddCurrForUnapplication(DtldCVLedgEntryBuf."Posting Date",DtldCVLedgEntryBuf."Amount (LCY)")
ELSE
IF GLSetup."Additional Reporting Currency" <> '' THEN
DtldCVLedgEntryBuf."Additional-Currency Amount" := DtldCVLedgEntryBuf.Amount;
CurrencyLCY.InitRoundingPrecision;
// End of the added lines.
IF DtldCustLedgEntry2."Entry Type" IN [
...
Existing code 6...
END;
// Delete the following lines.
TotalAmountLCY := TotalAmountLCY + DtldCVLedgEntryBuf."Amount (LCY)";
TotalAmountAddCurr := TotalAmountAddCurr + DtldCVLedgEntryBuf."Additional-Currency Amount";
IF DtldCVLedgEntryBuf."Entry Type" = DtldCVLedgEntryBuf."Entry Type"::Application THEN BEGIN
IF DtldCVLedgEntryBuf."Amount (LCY)" >= 0 THEN BEGIN
PositiveLCYAppAmt := PositiveLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
PositiveACYAppAmt :=
PositiveACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
END ELSE BEGIN
NegativeLCYAppAmt := NegativeLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
NegativeACYAppAmt :=
NegativeACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
// End of the deleted lines.
END;
...
Replacement code 6...
END;
// Add the following lines.
IF NOT MultipleDimensions THEN BEGIN
TotalAmountLCY := TotalAmountLCY + DtldCVLedgEntryBuf."Amount (LCY)";
TotalAmountAddCurr := TotalAmountAddCurr + DtldCVLedgEntryBuf."Additional-Currency Amount";
END ELSE BEGIN
NewComb := TRUE;
IF Arrlen > 0 THEN
FOR i:= 1 TO Arrlen DO BEGIN
IF (DimArr[1][i] = DtldCustLedgEntry2."Initial Entry Global Dim. 1") AND
(DimArr[2][i] = DtldCustLedgEntry2."Initial Entry Global Dim. 2") THEN BEGIN
NewComb := FALSE;
TotalAmtMD[i] += DtldCVLedgEntryBuf."Amount (LCY)";
TotalAmtAddCurMD[i] += DtldCVLedgEntryBuf."Additional-Currency Amount";
i := Arrlen;
END;
END;
IF NewComb THEN BEGIN
Arrlen += 1;
DimArr[1][Arrlen] := DtldCustLedgEntry2."Initial Entry Global Dim. 1";
DimArr[2][Arrlen] := DtldCustLedgEntry2."Initial Entry Global Dim. 2";
TotalAmtMD[Arrlen] += DtldCVLedgEntryBuf."Amount (LCY)";
TotalAmtAddCurMD[Arrlen] += DtldCVLedgEntryBuf."Additional-Currency Amount";
// End of the added lines.
END;
...
Existing code 7...
END;
IF NOT (DtldCVLedgEntryBuf."Entry Type" IN [
...
Replacement code 7...
END;
// Add the following lines.
IF DtldCVLedgEntryBuf."Entry Type" = DtldCVLedgEntryBuf."Entry Type"::Application THEN BEGIN
IF DtldCVLedgEntryBuf."Amount (LCY)" >= 0 THEN BEGIN
PositiveLCYAppAmt := PositiveLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
PositiveACYAppAmt :=
PositiveACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
END ELSE BEGIN
NegativeLCYAppAmt := NegativeLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
NegativeACYAppAmt :=
NegativeACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
END;
END;
// End of the added lines.
IF NOT (DtldCVLedgEntryBuf."Entry Type" IN [
...
Existing code 8...
IF (TotalAmountLCY <> 0) OR
// Delete the following lines.
(TotalAmountAddCurr <> 0) AND (GLSetup."Additional Reporting Currency" <> '')
THEN BEGIN
InitGLEntry(CustPostingGr."Receivables Account",TotalAmountLCY,TotalAmountAddCurr,TRUE,TRUE);
InsertGLEntry(TRUE);
// End of the deleted lines.
END;
...
Replacement code 8...
// Add the following lines.
IF NOT MultipleDimensions THEN BEGIN
IF (TotalAmountLCY <> 0) OR
(TotalAmountAddCurr <> 0) AND (GLSetup."Additional Reporting Currency" <> '')
THEN BEGIN
InitGLEntry(CustPostingGr."Receivables Account",TotalAmountLCY,TotalAmountAddCurr,TRUE,TRUE);
InsertGLEntry(TRUE);
END;
END ELSE BEGIN
FOR i := 1 TO Arrlen DO BEGIN
IF (TotalAmtMD[i] <> 0) OR
(TotalAmtAddCurMD[i] <> 0) AND (GLSetup."Additional Reporting Currency" <> '')
THEN BEGIN
GenJnlLine."Shortcut Dimension 1 Code" := DimArr[1][i];
GenJnlLine."Shortcut Dimension 2 Code" := DimArr[2][i];
InitGLEntry(CustPostingGr."Receivables Account",TotalAmtMD[i],TotalAmtAddCurMD[i],TRUE,TRUE);
InsertGLEntry(TRUE);
END;
END;
// End of the added lines.
END;
...
Change the code in the UnapplyVendLedgEntry function in the Gen. Jnl.-Post Line Codeunit (12) as follows:
Existing code 1...
DtldVendLedgEntry2.FINDSET;
// Delete the following lines.
LedgEntryDim.SETRANGE("Table ID",DATABASE::"Vendor Ledger Entry");
LedgEntryDim.SETRANGE("Entry No.",DtldVendLedgEntry2."Applied Vend. Ledger Entry No.");
TempJnlLineDim.RESET;
TempJnlLineDim.DELETEALL;
DimMgt.CopyLedgEntryDimToJnlLineDim(LedgEntryDim,TempJnlLineDim);
IF TempJnlLineDim.GET(DATABASE::"Vendor Ledger Entry",'','',0,0,GLSetup."Global Dimension 1 Code") THEN
GenJnlLine."Shortcut Dimension 1 Code" := TempJnlLineDim."Dimension Value Code"
ELSE
GenJnlLine."Shortcut Dimension 1 Code" := '';
IF TempJnlLineDim.GET(DATABASE::"Vendor Ledger Entry",'','',0,0,GLSetup."Global Dimension 2 Code") THEN
GenJnlLine."Shortcut Dimension 2 Code" := TempJnlLineDim."Dimension Value Code"
ELSE
GenJnlLine."Shortcut Dimension 2 Code" := '';
// End of the deleted lines.
REPEAT
...
Replacement code 1...
DtldVendLedgEntry2.FINDSET;
// Add the following lines.
MultipleDimensions := VendEntryAppPostEntries.MultipleDimensions(DtldVendLedgEntry2."Initial Entry Global Dim. 1",
DtldVendLedgEntry2."Initial Entry Global Dim. 2",DtldVendLedgEntry2);
// End of the added lines.
REPEAT
...
Existing code 2...
REPEAT
// Delete the following line.
DtldVendLedgEntry2.TESTFIELD(Unapplied,FALSE);
// End of the deleted line.
...
Replacement code 3...
REPEAT
// Add the following lines.
IF DtldVendLedgEntry2."Applied Vend. Ledger Entry No." <> 0 THEN BEGIN
LedgEntryDim.RESET;
LedgEntryDim.SETRANGE("Table ID",DATABASE::"Vendor Ledger Entry");
LedgEntryDim.SETRANGE("Entry No.",DtldVendLedgEntry2."Applied Vend. Ledger Entry No.");
TempJnlLineDim.RESET;
TempJnlLineDim.DELETEALL;
DimMgt.CopyLedgEntryDimToJnlLineDim(LedgEntryDim,TempJnlLineDim);
IF TempJnlLineDim.GET(DATABASE::"Vendor Ledger Entry",'','',0,0,GLSetup."Global Dimension 1 Code") THEN
GenJnlLine."Shortcut Dimension 1 Code" := TempJnlLineDim."Dimension Value Code"
ELSE
GenJnlLine."Shortcut Dimension 1 Code" := '';
IF TempJnlLineDim.GET(DATABASE::"Vendor Ledger Entry",'','',0,0,GLSetup."Global Dimension 2 Code") THEN
GenJnlLine."Shortcut Dimension 2 Code" := TempJnlLineDim."Dimension Value Code"
ELSE
GenJnlLine."Shortcut Dimension 2 Code" := '';
END ELSE BEGIN
GenJnlLine."Shortcut Dimension 1 Code" := DtldVendLedgEntry2."Initial Entry Global Dim. 1";
GenJnlLine."Shortcut Dimension 2 Code" := DtldVendLedgEntry2."Initial Entry Global Dim. 2";
END;
// End of the added lines.
...
Existing code 4...
NewDtldVendLedgEntry := DtldVendLedgEntry2;
...
Replacement code 4...
// Add the following line.
DtldVendLedgEntry2.TESTFIELD(Unapplied,FALSE);
// End of the added line.
NewDtldVendLedgEntry := DtldVendLedgEntry2;
...
Existing code 5...
END;
// Delete the following lines.
TotalAmountLCY := TotalAmountLCY + DtldCVLedgEntryBuf."Amount (LCY)";
TotalAmountAddCurr := TotalAmountAddCurr + DtldCVLedgEntryBuf."Additional-Currency Amount";
IF DtldCVLedgEntryBuf."Entry Type" = DtldCVLedgEntryBuf."Entry Type"::Application THEN BEGIN
IF DtldCVLedgEntryBuf."Amount (LCY)" >= 0 THEN BEGIN
PositiveLCYAppAmt := PositiveLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
PositiveACYAppAmt :=
PositiveACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
END ELSE BEGIN
NegativeLCYAppAmt := NegativeLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
NegativeACYAppAmt :=
NegativeACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
// End of the deleted lines.
END;
...
Replacement code 5...
END;
// Add the following lines.
IF NOT MultipleDimensions THEN BEGIN
TotalAmountLCY := TotalAmountLCY + DtldCVLedgEntryBuf."Amount (LCY)";
TotalAmountAddCurr := TotalAmountAddCurr + DtldCVLedgEntryBuf."Additional-Currency Amount";
END ELSE BEGIN
NewComb := TRUE;
IF Arrlen > 0 THEN
FOR i:= 1 TO Arrlen DO BEGIN
IF (DimArr[1][i] = DtldVendLedgEntry2."Initial Entry Global Dim. 1") AND
(DimArr[2][i] = DtldVendLedgEntry2."Initial Entry Global Dim. 2") THEN BEGIN
NewComb := FALSE;
TotalAmtMD[i] += DtldCVLedgEntryBuf."Amount (LCY)";
TotalAmtAddCurMD[i] += DtldCVLedgEntryBuf."Additional-Currency Amount";
i := Arrlen;
END;
END;
IF NewComb THEN BEGIN
Arrlen += 1;
DimArr[1][Arrlen] := DtldVendLedgEntry2."Initial Entry Global Dim. 1";
DimArr[2][Arrlen] := DtldVendLedgEntry2."Initial Entry Global Dim. 2";
TotalAmtMD[Arrlen] += DtldCVLedgEntryBuf."Amount (LCY)";
TotalAmtAddCurMD[Arrlen] += DtldCVLedgEntryBuf."Additional-Currency Amount";
// End of the added lines.
END;
...
Existing code 6Replacement code 6...
END;
// Add the following lines.
IF DtldCVLedgEntryBuf."Entry Type" = DtldCVLedgEntryBuf."Entry Type"::Application THEN BEGIN
IF DtldCVLedgEntryBuf."Amount (LCY)" >= 0 THEN BEGIN
PositiveLCYAppAmt := PositiveLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
PositiveACYAppAmt :=
PositiveACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
END ELSE BEGIN
NegativeLCYAppAmt := NegativeLCYAppAmt + DtldCVLedgEntryBuf."Amount (LCY)";
NegativeACYAppAmt :=
NegativeACYAppAmt + DtldCVLedgEntryBuf."Additional-Currency Amount";
END;
END;
// End of the added lines.
Existing code 7...
IF (TotalAmountLCY <> 0) OR
// Delete the following lines.
(TotalAmountAddCurr <> 0) AND (GLSetup."Additional Reporting Currency" <> '')
THEN BEGIN
HandlDtlAddjustment(DebitAddjustment,DebitAddjustmentAddCurr,CreditAddjustment,CreditAddjustmentAddCurr,
TotalAmountLCY,TotalAmountAddCurr,VendPostingGr."Payables Account");
InsertGLEntry(TRUE);
// End of the deleted lines.
END;
...
Replacement code 7...
IF NOT MultipleDimensions THEN BEGIN
// Add the following lines.
IF (TotalAmountLCY <> 0) OR
(TotalAmountAddCurr <> 0) AND (GLSetup."Additional Reporting Currency" <> '')
THEN BEGIN
InitGLEntry(VendPostingGr."Payables Account",TotalAmountLCY,TotalAmountAddCurr,TRUE,TRUE);
InsertGLEntry(TRUE);
END;
END ELSE BEGIN
FOR i := 1 TO Arrlen DO BEGIN
IF (TotalAmtMD[i] <> 0) OR
(TotalAmtAddCurMD[i] <> 0) AND (GLSetup."Additional Reporting Currency" <> '')
THEN BEGIN
GenJnlLine."Shortcut Dimension 1 Code" := DimArr[1][i];
GenJnlLine."Shortcut Dimension 2 Code" := DimArr[2][i];
InitGLEntry(VendPostingGr."Payables Account",TotalAmtMD[i],TotalAmtAddCurMD[i],TRUE,TRUE);
InsertGLEntry(TRUE);
END;
END;
// End of the added lines.
END;
...