Thursday, July 30, 2026

Purchase Orders

 Before confirming a Purchase Order, the system should display a confirmation popup if the purchase order is associated with an active intercompany vendor.


[ExtensionOf(classStr(PurchFormLetter_PurchOrder))]

final class PurchFormLetter_PurchOrderClass_Extension

{

 public boolean validate(Object _calledFrom)

    {

        boolean ret = next validate(_calledFrom);


        if (ret)

        {

            PurchTable purchTable = this.purchTable();


            if (purchTable && InterCompanyValidationHelper::isPurchaseOrderWorkflowActive(purchTable))

            {

                ret = InterCompanyValidationHelper::validateVendor(

                    purchTable.OrderAccount);

            }

        }


        return ret;

    }

}


Helper class:-

public class InterCompanyValidationHelper

{

    public static boolean validateVendor(VendAccount _vendAccount)

    {

        VendTable                   vendTable;

        InterCompanyTradingPartner  tradingPartner;

        InterCompanyTradingRelation tradingRelation;

        LedgerParameters            ledgerParameters = LedgerParameters::find();


        if (ledgerParameters.VendInterCompany == NoYes::Yes)

        {

            if (!_vendAccount)

            {

                return true;

            }


            vendTable = VendTable::find(_vendAccount);


            if (!vendTable)

            {

                return true;

            }


            select firstOnly tradingPartner

                where tradingPartner.VendorParty      == vendTable.Party

                   && tradingPartner.VendorDataAreaId == vendTable.DataAreaId;


            if (tradingPartner)

            {

                select firstOnly tradingRelation

                    where tradingRelation.InterCompanyTradingVendor == tradingPartner.RecId

                       && tradingRelation.Active == NoYes::Yes;


                if (tradingRelation)

                {

                    if (Box::yesNo(

                        "You are trying to post a transaction for an intercompany vendor. Do you want to continue?",

                        DialogButton::No) == DialogButton::No)

                    {

                        return false;

                    }

                }

            }

        }


        return true;

    }

}

purchase order submit time through any validation or popup use this class :-PurchTableWorkflow

[ExtensionOf(classStr(PurchTableWorkflow))]

public final class PurchTableWorkflow_Extension

{

protected boolean canSubmit(PurchTable _purchTable)

{

    boolean ret = next canSubmit(_purchTable);


    if (ret)

    {

        ret = InterCompanyValidationHelper::validateVendor(_purchTable.OrderAccount);

    }


    return ret;

}

}

No comments:

Post a Comment

Purchase Orders

 Before confirming a Purchase Order, the system should display a confirmation popup if the purchase order is associated with an active inter...