Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4335,6 +4335,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
IsHandled: Boolean;
Result: Boolean;
SufficientEntriesFound: Boolean;
NextStep: Integer;
begin
IsHandled := false;
OnBeforePrepareTempCustledgEntry(GenJnlLine, NewCVLedgEntryBuf, Cust, ApplyingDate, Result, IsHandled, TempOldCustLedgEntry);
Expand Down Expand Up @@ -4420,7 +4421,16 @@ codeunit 12 "Gen. Jnl.-Post Line"
if TempOldCustLedgEntry.Find('-') then begin
RemainingAmount := NewCVLedgEntryBuf."Remaining Amount";
TempOldCustLedgEntry.SetRange(Positive);
TempOldCustLedgEntry.Find('-');
// Weigh the entries of the same sign as the new document before the opposite-sign ones.
// The sign decision below is a property of the whole open-entry set, so the early exit
// must not stop before the opposite-sign entries have settled that sign.
if NewCVLedgEntryBuf."Remaining Amount" > 0 then begin
TempOldCustLedgEntry.Find('+');
NextStep := -1;
end else begin
TempOldCustLedgEntry.Find('-');
NextStep := 1;
end;
repeat
TempOldCustLedgEntry.CalcFields("Remaining Amount");
TempOldCustLedgEntry.RecalculateAmounts(
Expand All @@ -4429,10 +4439,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
TempOldCustLedgEntry."Remaining Amount" -= TempOldCustLedgEntry.GetRemainingPmtDiscPossible(NewCVLedgEntryBuf."Posting Date");
RemainingAmount += TempOldCustLedgEntry."Remaining Amount";
if (Cust."Application Method" = Cust."Application Method"::"Apply to Oldest") and
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" <= 0)
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" < 0)
Comment thread
dcenic marked this conversation as resolved.
then
SufficientEntriesFound := true;
until (TempOldCustLedgEntry.Next() = 0) or SufficientEntriesFound;
until (TempOldCustLedgEntry.Next(NextStep) = 0) or SufficientEntriesFound;
TempOldCustLedgEntry.SetRange(Positive, RemainingAmount < 0);
end else
TempOldCustLedgEntry.SetRange(Positive);
Expand Down Expand Up @@ -5325,6 +5335,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
IsHandled: Boolean;
Result: Boolean;
SufficientEntriesFound: Boolean;
NextStep: Integer;
begin
IsHandled := false;
OnBeforePrepareTempVendLedgEntry(GenJnlLine, NewCVLedgEntryBuf, TempOldVendLedgEntry, Vend, ApplyingDate, Result, IsHandled);
Expand Down Expand Up @@ -5394,7 +5405,16 @@ codeunit 12 "Gen. Jnl.-Post Line"
if TempOldVendLedgEntry.Find('-') then begin
RemainingAmount := NewCVLedgEntryBuf."Remaining Amount";
TempOldVendLedgEntry.SetRange(Positive);
TempOldVendLedgEntry.Find('-');
// Weigh the entries of the same sign as the new document before the opposite-sign ones.
// The sign decision below is a property of the whole open-entry set, so the early exit
// must not stop before the opposite-sign entries have settled that sign.
if NewCVLedgEntryBuf."Remaining Amount" > 0 then begin
TempOldVendLedgEntry.Find('+');
NextStep := -1;
end else begin
TempOldVendLedgEntry.Find('-');
NextStep := 1;
end;
repeat
TempOldVendLedgEntry.CalcFields("Remaining Amount");
TempOldVendLedgEntry.RecalculateAmounts(
Expand All @@ -5403,10 +5423,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
TempOldVendLedgEntry."Remaining Amount" -= TempOldVendLedgEntry.GetRemainingPmtDiscPossible(NewCVLedgEntryBuf."Posting Date");
RemainingAmount += TempOldVendLedgEntry."Remaining Amount";
if (Vend."Application Method" = Vend."Application Method"::"Apply to Oldest") and
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" <= 0)
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" < 0)
then
SufficientEntriesFound := true;
until (TempOldVendLedgEntry.Next() = 0) or SufficientEntriesFound;
until (TempOldVendLedgEntry.Next(NextStep) = 0) or SufficientEntriesFound;
TempOldVendLedgEntry.SetRange(Positive, RemainingAmount < 0);
end else
TempOldVendLedgEntry.SetRange(Positive);
Expand All @@ -5424,6 +5444,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
IsHandled: Boolean;
Result: Boolean;
SufficientEntriesFound: Boolean;
NextStep: Integer;
begin
IsHandled := false;
OnBeforePrepareTempEmplLedgEntry(GenJnlLine, NewCVLedgEntryBuf, TempOldEmplLedgEntry, Employee, ApplyingDate, Result, IsHandled);
Expand Down Expand Up @@ -5479,18 +5500,27 @@ codeunit 12 "Gen. Jnl.-Post Line"
if TempOldEmplLedgEntry.Find('-') then begin
RemainingAmount := NewCVLedgEntryBuf."Remaining Amount";
TempOldEmplLedgEntry.SetRange(Positive);
TempOldEmplLedgEntry.Find('-');
// Weigh the entries of the same sign as the new document before the opposite-sign ones.
// The sign decision below is a property of the whole open-entry set, so the early exit
// must not stop before the opposite-sign entries have settled that sign.
if NewCVLedgEntryBuf."Remaining Amount" > 0 then begin
TempOldEmplLedgEntry.Find('+');
NextStep := -1;
end else begin
TempOldEmplLedgEntry.Find('-');
NextStep := 1;
end;
repeat
TempOldEmplLedgEntry.CalcFields("Remaining Amount");
TempOldEmplLedgEntry.RecalculateAmounts(
TempOldEmplLedgEntry."Currency Code", NewCVLedgEntryBuf."Currency Code", NewCVLedgEntryBuf."Posting Date");
OnPrepareTempEmplLedgEntryOnBeforeUpdateRemainingAmount(TempOldEmplLedgEntry, NewCVLedgEntryBuf);
RemainingAmount += TempOldEmplLedgEntry."Remaining Amount";
if (Employee."Application Method" = Employee."Application Method"::"Apply to Oldest") and
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" <= 0)
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" < 0)
then
SufficientEntriesFound := true;
until (TempOldEmplLedgEntry.Next() = 0) or SufficientEntriesFound;
until (TempOldEmplLedgEntry.Next(NextStep) = 0) or SufficientEntriesFound;
TempOldEmplLedgEntry.SetRange(Positive, RemainingAmount < 0);
end else
TempOldEmplLedgEntry.SetRange(Positive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4054,6 +4054,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
IsHandled: Boolean;
Result: Boolean;
SufficientEntriesFound: Boolean;
NextStep: Integer;
begin
IsHandled := false;
OnBeforePrepareTempCustledgEntry(GenJnlLine, NewCVLedgEntryBuf, Cust, ApplyingDate, Result, IsHandled, TempOldCustLedgEntry);
Expand Down Expand Up @@ -4128,7 +4129,16 @@ codeunit 12 "Gen. Jnl.-Post Line"
if TempOldCustLedgEntry.Find('-') then begin
RemainingAmount := NewCVLedgEntryBuf."Remaining Amount";
TempOldCustLedgEntry.SetRange(Positive);
TempOldCustLedgEntry.Find('-');
// Weigh the entries of the same sign as the new document before the opposite-sign ones.
// The sign decision below is a property of the whole open-entry set, so the early exit
// must not stop before the opposite-sign entries have settled that sign.
if NewCVLedgEntryBuf."Remaining Amount" > 0 then begin
TempOldCustLedgEntry.Find('+');
NextStep := -1;
end else begin
TempOldCustLedgEntry.Find('-');
NextStep := 1;
end;
repeat
TempOldCustLedgEntry.CalcFields("Remaining Amount");
TempOldCustLedgEntry.RecalculateAmounts(
Expand All @@ -4137,10 +4147,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
TempOldCustLedgEntry."Remaining Amount" -= TempOldCustLedgEntry.GetRemainingPmtDiscPossible(NewCVLedgEntryBuf."Posting Date");
RemainingAmount += TempOldCustLedgEntry."Remaining Amount";
if (Cust."Application Method" = Cust."Application Method"::"Apply to Oldest") and
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" <= 0)
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" < 0)
then
SufficientEntriesFound := true;
until (TempOldCustLedgEntry.Next() = 0) or SufficientEntriesFound;
until (TempOldCustLedgEntry.Next(NextStep) = 0) or SufficientEntriesFound;
TempOldCustLedgEntry.SetRange(Positive, RemainingAmount < 0);
end else
TempOldCustLedgEntry.SetRange(Positive);
Expand Down Expand Up @@ -4917,6 +4927,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
IsHandled: Boolean;
Result: Boolean;
SufficientEntriesFound: Boolean;
NextStep: Integer;
begin
IsHandled := false;
OnBeforePrepareTempVendLedgEntry(GenJnlLine, NewCVLedgEntryBuf, TempOldVendLedgEntry, Vend, ApplyingDate, Result, IsHandled);
Expand Down Expand Up @@ -4986,7 +4997,16 @@ codeunit 12 "Gen. Jnl.-Post Line"
if TempOldVendLedgEntry.Find('-') then begin
RemainingAmount := NewCVLedgEntryBuf."Remaining Amount";
TempOldVendLedgEntry.SetRange(Positive);
TempOldVendLedgEntry.Find('-');
// Weigh the entries of the same sign as the new document before the opposite-sign ones.
// The sign decision below is a property of the whole open-entry set, so the early exit
// must not stop before the opposite-sign entries have settled that sign.
if NewCVLedgEntryBuf."Remaining Amount" > 0 then begin
TempOldVendLedgEntry.Find('+');
NextStep := -1;
end else begin
TempOldVendLedgEntry.Find('-');
NextStep := 1;
end;
repeat
TempOldVendLedgEntry.CalcFields("Remaining Amount");
TempOldVendLedgEntry.RecalculateAmounts(
Expand All @@ -4995,10 +5015,10 @@ codeunit 12 "Gen. Jnl.-Post Line"
TempOldVendLedgEntry."Remaining Amount" -= TempOldVendLedgEntry.GetRemainingPmtDiscPossible(NewCVLedgEntryBuf."Posting Date");
RemainingAmount += TempOldVendLedgEntry."Remaining Amount";
if (Vend."Application Method" = Vend."Application Method"::"Apply to Oldest") and
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" <= 0)
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" < 0)
then
SufficientEntriesFound := true;
until (TempOldVendLedgEntry.Next() = 0) or SufficientEntriesFound;
until (TempOldVendLedgEntry.Next(NextStep) = 0) or SufficientEntriesFound;
TempOldVendLedgEntry.SetRange(Positive, RemainingAmount < 0);
end else
TempOldVendLedgEntry.SetRange(Positive);
Expand All @@ -5016,6 +5036,7 @@ codeunit 12 "Gen. Jnl.-Post Line"
IsHandled: Boolean;
Result: Boolean;
SufficientEntriesFound: Boolean;
NextStep: Integer;
begin
IsHandled := false;
OnBeforePrepareTempEmplLedgEntry(GenJnlLine, NewCVLedgEntryBuf, TempOldEmplLedgEntry, Employee, ApplyingDate, Result, IsHandled);
Expand Down Expand Up @@ -5071,18 +5092,27 @@ codeunit 12 "Gen. Jnl.-Post Line"
if TempOldEmplLedgEntry.Find('-') then begin
RemainingAmount := NewCVLedgEntryBuf."Remaining Amount";
TempOldEmplLedgEntry.SetRange(Positive);
TempOldEmplLedgEntry.Find('-');
// Weigh the entries of the same sign as the new document before the opposite-sign ones.
// The sign decision below is a property of the whole open-entry set, so the early exit
// must not stop before the opposite-sign entries have settled that sign.
if NewCVLedgEntryBuf."Remaining Amount" > 0 then begin
TempOldEmplLedgEntry.Find('+');
NextStep := -1;
end else begin
TempOldEmplLedgEntry.Find('-');
NextStep := 1;
end;
repeat
TempOldEmplLedgEntry.CalcFields("Remaining Amount");
TempOldEmplLedgEntry.RecalculateAmounts(
TempOldEmplLedgEntry."Currency Code", NewCVLedgEntryBuf."Currency Code", NewCVLedgEntryBuf."Posting Date");
OnPrepareTempEmplLedgEntryOnBeforeUpdateRemainingAmount(TempOldEmplLedgEntry, NewCVLedgEntryBuf);
RemainingAmount += TempOldEmplLedgEntry."Remaining Amount";
if (Employee."Application Method" = Employee."Application Method"::"Apply to Oldest") and
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" <= 0)
(RemainingAmount * NewCVLedgEntryBuf."Remaining Amount" < 0)
then
SufficientEntriesFound := true;
until (TempOldEmplLedgEntry.Next() = 0) or SufficientEntriesFound;
until (TempOldEmplLedgEntry.Next(NextStep) = 0) or SufficientEntriesFound;
TempOldEmplLedgEntry.SetRange(Positive, RemainingAmount < 0);
end else
TempOldEmplLedgEntry.SetRange(Positive);
Expand Down
Loading
Loading