microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
748 stars 600 forks source link

[Protected var] Page 31284 "Apply G/L Entries CZA" #26395

Open fridrichovsky opened 2 months ago

fridrichovsky commented 2 months ago

Describe the request

Please change these variables to Protected Var:

  TempGLEntry: Record "G/L Entry" temporary;
  GLEntry: Record "G/L Entry";
  GLEntryPostApplicationCZA: Codeunit "G/L Entry Post Application CZA";
  ApplyingRemainingAmount: Decimal;
  ApplyingAmount: Decimal;
  AvailableAmount: Decimal;

Please do this function as global:

CalcApplnAmount 

Please add new event

page 31284 "Apply G/L Entries CZA"
{
    ...    
    local procedure SetApplyingGLEntry(EntryNo: Integer)
    begin
        Rec.Get(EntryNo);
        GLEntryPostApplicationCZA.SetApplyingGLEntry(Rec, true, GLApplID);
        if Rec.Amount > 0 then
            Rec.SetFilter(Amount, '<0')
        else
            Rec.SetFilter(Amount, '>0');
        //------------------------------------------------------------OnSetApplyingGLEntryByEntryNoOnAfterSetFilters:BEGIN
        OnSetApplyingGLEntryByEntryNoOnAfterSetFilters(Rec, GLEntryPostApplicationCZA);
        //------------------------------------------------------------OnSetApplyingGLEntryByEntryNoOnAfterSetFilters:END          
        Rec."Applying Entry CZA" := true;
        Rec.Modify();

        TempGLEntry := Rec;
        Rec.SetCurrentKey("Entry No.");
        Rec.SetFilter("Entry No.", '<> %1', Rec."Entry No.");
        AvailableAmount := Rec.Amount - Rec."Applied Amount CZA";
        ApplyingRemainingAmount := Rec.Amount - Rec."Applied Amount CZA";
        CalcApplnAmount();
        Rec.SetCurrentKey("G/L Account No.");
    end;    

    //------------------------------------------------------------OnSetApplyingGLEntryByEntryNoOnAfterSetFilters:BEGIN
    [IntegrationEvent(true, false)]
    local procedure OnSetApplyingGLEntryByEntryNoOnAfterSetFilters(var GLEntry: Record "G/L Entry"; var GLEntryPostApplicationCZA: Codeunit "G/L Entry Post Application CZA"); 
    begin
    end;    
    //------------------------------------------------------------OnSetApplyingGLEntryByEntryNoOnAfterSetFilters:END
}

Additional context

We need change standard behavior. Internal work item: AB#538724

fridrichovsky commented 4 weeks ago

Hello @darjoo, please can you check this issue?

JesperSchulz commented 3 weeks ago

Automations didn't work. We hence didn't get an internal work item. I've hopefully fixed that and we'll be on it ASAP.