Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] Codeunit 5805 "Item Charge Assgnt. (Purch.)".SuggestAssgnt #27672

Open
fridrichovsky opened this issue Nov 22, 2024 · 1 comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area

Comments

@fridrichovsky
Copy link
Contributor

fridrichovsky commented Nov 22, 2024

Describe the request

Please add new event

procedure SuggestAssgnt(PurchLine: Record "Purchase Line"; TotalQtyToAssign: Decimal; TotalAmtToAssign: Decimal; TotalQtyToHandle: Decimal; TotalAmtToHandle: Decimal)
    var
        ItemChargeAssgntPurch: Record "Item Charge Assignment (Purch)";
        Selection: Integer;
        SelectionTxt: Text;
        SuggestItemChargeMenuTxt: Text;
        SuggestItemChargeMessageTxt: Text;
        IsHandled: Boolean;
    begin
        //----------------------------------------------------------------------------OnBeforeSuggestAssgnt:BEGIN
        IsHandled := false;
        OnBeforeSuggestAssgnt(PurchLine, ItemChargeAssgntPurch, TotalQtyToAssign, TotalAmtToAssign, TotalQtyToHandle, TotalAmtToHandle, Selection, SelectionTxt, SuggestItemChargeMenuTxt, SuggestItemChargeMessageTxt, IsHandled);
        if IsHandled then
            exit;
        //----------------------------------------------------------------------------OnBeforeSuggestAssgnt:END
        PurchLine.TestField("Qty. to Invoice");
        ItemChargeAssgntPurch.SetRange("Document Type", PurchLine."Document Type");
        ItemChargeAssgntPurch.SetRange("Document No.", PurchLine."Document No.");
        ItemChargeAssgntPurch.SetRange("Document Line No.", PurchLine."Line No.");
        if ItemChargeAssgntPurch.IsEmpty() then
            exit;

        ItemChargeAssgntPurch.SetRange("Applies-to Doc. Type", ItemChargeAssgntPurch."Applies-to Doc. Type"::"Transfer Receipt");

        IsHandled := false;
        OnSuggestAssgntOnAfterItemChargeAssgntPurchSetFilters(ItemChargeAssgntPurch, PurchLine, TotalQtyToAssign, TotalAmtToAssign, IsHandled);
        if IsHandled then
            exit;

        Selection := 1;
        if ItemChargeAssgntPurch.IsEmpty() then
            SuggestItemChargeMenuTxt :=
              StrSubstNo(ItemChargeAssignedMenu4Lbl, AssignEquallyMenuText(), AssignByAmountMenuText(), AssignByWeightMenuText(), AssignByVolumeMenuText())
        else
            SuggestItemChargeMenuTxt :=
              StrSubstNo(ItemChargeAssignedMenu3Lbl, AssignEquallyMenuText(), AssignByWeightMenuText(), AssignByVolumeMenuText());
        ItemChargeAssgntPurch.SetRange("Applies-to Doc. Type");

        if ItemChargeAssgntPurch.Count > 1 then begin
            Selection := 2;
            SuggestItemChargeMessageTxt := SuggestItemChargeMsg;
            OnBeforeShowSuggestItemChargeAssignStrMenu(PurchLine, SuggestItemChargeMenuTxt, SuggestItemChargeMessageTxt, Selection);
            if SuggestItemChargeMenuTxt = '' then
                exit;
            if StrLen(DelChr(SuggestItemChargeMenuTxt, '=', DelChr(SuggestItemChargeMenuTxt, '=', ','))) > 1 then
                Selection := StrMenu(SuggestItemChargeMenuTxt, Selection, SuggestItemChargeMessageTxt)
            else
                Selection := 1;
        end;
        if Selection = 0 then
            exit;

        SelectionTxt := SelectStr(Selection, SuggestItemChargeMenuTxt);
        OnSuggestAssgntOnBeforeAssignItemCharges(PurchLine, ItemChargeAssgntPurch);
        AssignItemCharges(PurchLine, TotalQtyToAssign, TotalAmtToAssign, TotalQtyToHandle, TotalAmtToHandle, SelectionTxt);
    end;

    //----------------------------------------------------------------------------OnBeforeSuggestAssgnt:BEGIN
    [IntegrationEvent(true, false)]
    local procedure OnBeforeSuggestAssgnt(PurchLine: Record "Purchase Line"; ItemChargeAssgntPurch: Record "Item Charge Assignment (Purch)"; TotalQtyToAssign: Decimal; TotalAmtToAssign: Decimal; TotalQtyToHandle: Decimal; TotalAmtToHandle: Decimal; var Selection: Integer; var SelectionTxt: Text; var SuggestItemChargeMenuTxt: Text; var SuggestItemChargeMessageTxt: Text; var IsHandled: Boolean)
    begin
    end;
    //----------------------------------------------------------------------------OnBeforeSuggestAssgnt:END

Additional context

We have own logic for check and we need skip function.
Internal work item: AB#558496

@BardurKnudsen BardurKnudsen added event-request Request for adding an event SCM GitHub request for SCM area labels Nov 25, 2024
@BardurKnudsen
Copy link

Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area
Projects
None yet
Development

No branches or pull requests

2 participants