Post PO Registration

/// <summary>

/// The <c>gopPuchProductRegistrationBatchServices</c> class is the service class for post the purchase order registration,packingslip and invoice

/// </summary>

class gopPuchProductRegistrationBatchServices extends SysOperationServiceBase

{

    Str1260 CaptureError;

    str        empty=null;

    /// <summary>

    /// The <c>gopPuchProductRegistrationBatchServices</c> class is the service class for post the purchase order registration,packingslip and invoice

    /// </summary>

    public void processOperation()

    {

        gopProductRegistrationTable    productRegistrationTable;

        

        this.validateBeforeRecipitInvoice();

        this.ASNProcessOperation();

        this.InvoiceProcessOperation();

        // Update the invoice status -start

        while select maxof(purchID), maxof(InvoiceNumber),maxof(LineNumber) from  productRegistrationTable group by purchID,invoiceNumber,LineNumber

            where productRegistrationTable.IspendingInvoiced == noyes::Yes

                && productRegistrationTable.IsInvoiced == noyes::No

                && productRegistrationTable.IsSAPInvoice == NoYes::Yes

                && productRegistrationTable.InboundValidationPassed == NoYes::Yes

        {

            VendInvoiceTrans                vendInvoiceTrans;

            gopProductRegistrationTable    productRegistrationTableInv;

            select firstonly  vendInvoiceTrans

                where vendInvoiceTrans.PurchaseLineLineNumber == productRegistrationTable.LineNumber

                && vendInvoiceTrans.InvoiceId == productRegistrationTable.InvoiceNumber

                && vendInvoiceTrans.PurchID   == productRegistrationTable.PurchId;

            if(vendInvoiceTrans)

            {

                update_recordset productRegistrationTableInv

                        setting IsInvoiced = NoYes::Yes,

                                IspendingInvoiced = noyes::No,

                                PurchStatus = gopal_PurchStatus::Invoiced,

                                Error   = empty

                        where productRegistrationTableInv.PurchId     == vendInvoiceTrans.PurchID

                        && productRegistrationTableInv.InvoiceNumber  == vendInvoiceTrans.InvoiceId

                        && productRegistrationTableInv.LineNumber     == vendInvoiceTrans.PurchaseLineLineNumber

                        && productRegistrationTableInv.IsSAPInvoice == NoYes::Yes

                        && productRegistrationTableInv.InboundValidationPassed == NoYes::Yes

                    

                    ;

            }

        }

        //Update the invoice status -End

    }


    //PO Registration process -End

    /// <summary>

    /// The <c>PostPOregistration</c> this method is used  for post the purchase order packingslip

    /// </summary>

    ///  /// <param name="_purchID">

    /// The new value of the datacontract parameter PurchID; Mandatory.

    /// </param>

    /// <param name="_PackingSlipId">

    /// The new value of the datacontract parameter PackingSlipId; Mandatory.

    /// </param>

    //PO Product Receipt process- start

    public void poProductRecipt(PurchID _purchID, PackingSlipId  _PackingSlipId, TransDate _DeliveryDateUpdate)

    {

        

        gopProductRegistrationTable    productRegistrationTableGRN,productRegistrationTablePKS;

        VendPackingSlipJour             vendPackingSlipJour;

        PurchTable                      purchTable;

        PurchFormLetter                 purchFormLetter;

        

        ttsbegin;

        select maxof(IsRegistred) from productRegistrationTablePKS group by PurchId,PackingSlipId

                        where productRegistrationTablePKS.PackingSlipId    == _PackingSlipId

                        && productRegistrationTablePKS.PurchId == _purchID

                        && productRegistrationTablePKS.IsRegistred == NoYes::Yes

                        && productRegistrationTablePKS.InboundValidationPassed == NoYes::Yes;

        if(productRegistrationTablePKS.IsRegistred == NoYes::Yes)

        {

            select firstonly  productRegistrationTableGRN

                            where productRegistrationTableGRN.PurchId == _purchID

                            && productRegistrationTableGRN.IsRegistred      == noyes::No

                            && productRegistrationTableGRN.IsProductReceipt == noyes::No

                            && productRegistrationTableGRN.PackingSlipId ==_PackingSlipId

                            && productRegistrationTableGRN.InboundValidationPassed == NoYes::Yes;

            if(productRegistrationTableGRN)

            {

                throw error(strFmt(literalStr("@gopal:POfullyNotRegistered"), productRegistrationTableGRN.PurchId));

            }

            if(!productRegistrationTableGRN)

            {

                select firstonly purchTable

                            where purchTable.PurchId == _purchID;

                

                purchFormLetter = purchFormLetter::construct(DocumentStatus::PackingSlip);

                purchFormLetter.update( purchTable,

                                        _PackingSlipId,

                                        _DeliveryDateUpdate,

                        //DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()),

                        PurchUpdate::Recorded,

                                        AccountOrder::None,

                                        false,

                                        false);

                select firstonly vendPackingSlipJour

                                where vendPackingSlipJour.PackingSlipId == _PackingSlipId

                            && vendPackingSlipJour.PurchID == _purchID;

                if(vendPackingSlipJour)

                {

                    productRegistrationTableGRN.clear();

                    select maxof(DocumentDate) from productRegistrationTableGRN group by PurchId,PackingSlipId

                        where productRegistrationTableGRN.PackingSlipId    == _PackingSlipId

                        && productRegistrationTableGRN.PurchId == _purchID

                        && productRegistrationTableGRN.IsRegistred == NoYes::Yes

                        && productRegistrationTableGRN.InboundValidationPassed == NoYes::Yes;


                    this.LTMPurchParmTablePSInsert(vendPackingSlipJour, productRegistrationTableGRN.DocumentDate);

                    update_recordset productRegistrationTablePKS

                        setting IsProductReceipt = NoYes::Yes,

                                PurchStatus = gopal_PurchStatus::ProdcutReceipt,

                                Error = empty

                            where productRegistrationTablePKS.PurchId     == vendPackingSlipJour.PurchID

                                && productRegistrationTablePKS.PackingSlipId  == vendPackingSlipJour.PackingSlipId

                                && productRegistrationTablePKS.InboundValidationPassed == NoYes::Yes;

                }

                else

                {

                    update_recordset productRegistrationTableGRN

                        setting Error = "@gopal:Errorwith"+_purchID+"@gopal:Comma"+_PackingSlipId+"@gopal:ProductReceiptIsfailed"

                        where productRegistrationTableGRN.PurchId     == _purchID

                            && productRegistrationTableGRN.PackingSlipId  ==_PackingSlipId

                            && productRegistrationTableGRN.InboundValidationPassed == NoYes::Yes;

                    throw Error("@gopal:ProductReceiptIsfailed");

                }

            }

        }

        ttscommit;

    }


    //PO Product Receipt process- End

    /// <summary>

    /// The <c>PostPOregistration</c> this method is used  for post the purchase order pending invoice

    /// </summary>

    /// <param name="_purchID">

    /// The new value of the datacontract parameter PurchID; Mandatory.

    /// </param>

    /// <param name="_PackingSlipId">

    /// The new value of the datacontract parameter PackingSlipId; Mandatory.

    /// </param>

    ///<param name="_invoiceID">

    /// The new value of the datacontract parameter InvoiceID; Mandatory.

    /// </param>

    //Process for vendor invoice Automation:-start

    public void PostPendingInvoice_old(PurchID _purchID, PackingSlipId  _PackingSlipId, InvoiceID _invoiceID)

    {

        VendorInvoiceHeaderEntity           vendorInvoiceHeaderEntity,VendorInvoiceHeaderEntityloc,VendorInvoiceHeaderEntityInv;

        VendPackingSlipJour                 vendPackingSlipJour;

        gopProductRegistrationTable        productRegistrationTablelvair,productRegistrationTableInv;

        VendInvoiceInfoTable                vendInvoiceInfoTable;

        VendInvoiceInfoLine                 vendInvoiceInfoLine;

        purchTable                          PurchTable;

        PriceDiscTable                      PriceDiscTable;

        select firstonly purchTable

                    where purchTable.PurchId == _purchID;

        select firstonly vendPackingSlipJour

                    where vendPackingSlipJour.PackingSlipId == _PackingSlipId;

        select firstonly VendorInvoiceHeaderEntityloc

                    where VendorInvoiceHeaderEntityloc.InvoiceNumber == _invoiceID;

        if(vendPackingSlipJour && !VendorInvoiceHeaderEntityloc)

        {

            vendorInvoiceHeaderEntity.HeaderOnlyImport = NoYes::Yes;

            vendorInvoiceHeaderEntity.PackingslipRange = _PackingSlipId;

            vendorInvoiceHeaderEntity.InvoiceAccount = purchTable.InvoiceAccount;

            vendorInvoiceHeaderEntity.PurchaseOrderNumber = purchTable.PurchId;

            vendorInvoiceHeaderEntity.VendorAccount = purchTable.OrderAccount;

            vendorInvoiceHeaderEntity.InvoiceNumber = _invoiceID;

            vendorInvoiceHeaderEntity.InvoiceDate   = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());

            vendorInvoiceHeaderEntity.insert();

            

            select firstonly VendorInvoiceHeaderEntityInv

                where VendorInvoiceHeaderEntityInv.InvoiceNumber        == _invoiceID

                    && VendorInvoiceHeaderEntityInv.PurchaseOrderNumber     == _PurchId;

            if(VendorInvoiceHeaderEntityInv)

            {

                /*update_recordset productRegistrationTablelvair

                            setting IspendingInvoiced = NoYes::Yes,

                                PurchStatus = gopal_PurchStatus::PendingInvoice,

                                Error = empty

                                where productRegistrationTablelvair.PurchId     == VendorInvoiceHeaderEntityInv.PurchaseOrderNumber

                    && productRegistrationTablelvair.InvoiceNumber  == VendorInvoiceHeaderEntityInv.InvoiceNumber;*/

                    //&& productRegistrationTablelvair.PackingSlipId == VendorInvoiceHeaderEntityInv.PackingslipRange;

                    while select maxof(InvoiceUnitPrice),maxof(ItemId),maxof(LineNumber),maxof(PurchId),Maxof(InvoiceNumber),maxof(NetAmount), maxof(SAPInvoicePackingSlipId), maxof(SAPInvoicePackingSlipLineNumber),maxof(ItemId) from  productRegistrationTableInv

                    group by itemId,PurchId,LineNumber,InvoiceNumber,SAPInvoicePackingSlipId,SAPInvoicePackingSlipLineNumber

                        where productRegistrationTableInv.PurchId    == _PurchId

                            && productRegistrationTableInv.InvoiceNumber == _invoiceID

                            && productRegistrationTableInv.SAPInvoicePackingSlipId == _PackingSlipId

                            && productRegistrationTableInv.InboundValidationPassed == NoYes::Yes

                        


                {

                    gopProductRegistrationTable    asnProductRegistrationTable;

                    //asnProductRegistrationTable = gopProductRegistrationTable::findSAPASNfromSAPInvoice(productRegistrationTableInv);

                    if (asnProductRegistrationTable)

                    {

                        ttsbegin;

                        select firstonly forupdate vendInvoiceInfoLine

                            where vendInvoiceInfoLine.LineNum         == productRegistrationTableInv.LineNumber

                                && vendInvoiceInfoLine.ItemId         == productRegistrationTableInv.ItemId

                            join vendInvoiceInfoTable

                                where vendInvoiceInfoTable.Num      == VendorInvoiceHeaderEntityInv.InvoiceNumber

                                    && vendInvoiceInfoTable.PurchId     == VendorInvoiceHeaderEntityInv.PurchaseOrderNumber

                                    && vendInvoiceInfoTable.TableRefId  == vendInvoiceInfoLine.TableRefId;

                        if(vendInvoiceInfoLine && productRegistrationTableInv.InvoiceUnitPrice)

                        {

                            // Adding new code for trade agrement price -<03-01-2024>-start

                            PurchLine purchLine;

                            select firstonly purchLine

                                    where purchLine.PurchId     ==productRegistrationTableInv.PurchId

                                        && purchLine.ItemId     == productRegistrationTableInv.ItemId

                                    && purchLine.LineNumber == productRegistrationTableInv.LineNumber;

                            PurchTable purchTableloc = purchLine.purchTable();

                            PriceDiscParameters parameters = PriceDiscParameters::construct();

                            parameters.parmModuleType(ModuleInventPurchSales::Purch);

                            parameters.parmItemId(purchLine.Itemid);

                            parameters.parmInventDim(purchLine.inventDim());

                            parameters.parmUnitID(purchLine.PurchUnit);

                            parameters.parmPriceDiscDate(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));

                            parameters.parmQty(1);

                            parameters.parmAccountNum(purchTableloc.OrderAccount);

                            parameters.parmCurrencyCode(purchLine.CurrencyCode);

                            PriceDisc priceDisc = PriceDisc::newFromPriceDiscParameters(parameters);

                            if (priceDisc)

                            {

            

                                if (!priceDisc.findPrice(purchLine.purchTable().PriceGroupId))

                                {

                                    priceDisc.priceUnit();

                                }

                                PriceDiscTable =  priceDisc.priceTable();

                            }

                            if(PriceDiscTable)

                            {

                                vendInvoiceInfoLine.PurchPrice  = productRegistrationTableInv.InvoiceUnitPrice*priceDisc.priceUnit();

                                vendInvoiceInfoLine.LineAmount  = (productRegistrationTableInv.InvoiceUnitPrice*priceDisc.priceUnit()*vendInvoiceInfoLine.ReceiveNow)/priceDisc.priceUnit();

                                vendInvoiceInfoLine.doUpdate();

                            }

                            // Adding new code for trade agrement price -<03-01-2024>-End

                            else

                            {

                                vendInvoiceInfoLine.PurchPrice  = productRegistrationTableInv.InvoiceUnitPrice;

                                vendInvoiceInfoLine.LineAmount  = productRegistrationTableInv.InvoiceUnitPrice*vendInvoiceInfoLine.ReceiveNow;

                                vendInvoiceInfoLine.doUpdate();

                            }

                        }


                        update_recordset productRegistrationTablelvair

                            setting IspendingInvoiced = NoYes::Yes,

                                PurchStatus = gopal_PurchStatus::PendingInvoice,

                                Error = empty

                                where productRegistrationTablelvair.PurchId     == VendorInvoiceHeaderEntityInv.PurchaseOrderNumber

                                    && productRegistrationTablelvair.InvoiceNumber  == VendorInvoiceHeaderEntityInv.InvoiceNumber

                                    && productRegistrationTablelvair.ItemId  == vendInvoiceInfoLine.ItemId

                                    && productRegistrationTablelvair.LineNumber == vendInvoiceInfoLine.LineNum

                                    && productRegistrationTablelvair.InboundValidationPassed == NoYes::Yes;

                   

                        ttscommit;

                    }

                    else

                    {

                        update_recordset productRegistrationTablelvair

                            setting Error = strFmt("@gopal:ErrorInfoASNnotProcessed",productRegistrationTablelvair.PackingSlipId, productRegistrationTablelvair.PackingSlipLineNumber, productRegistrationTablelvair.PurchId)

                                where productRegistrationTablelvair.PurchId     == VendorInvoiceHeaderEntityInv.PurchaseOrderNumber

                                    && productRegistrationTablelvair.InvoiceNumber  == VendorInvoiceHeaderEntityInv.InvoiceNumber

                                    && productRegistrationTablelvair.ItemId  == vendInvoiceInfoLine.ItemId

                                    && productRegistrationTablelvair.LineNumber == vendInvoiceInfoLine.LineNum

                                    && productRegistrationTablelvair.InboundValidationPassed == NoYes::Yes;


                    }

                }

            }

            else

            {

                gopProductRegistrationTable      productRegistrationTableerror;

                update_recordset productRegistrationTableerror

                            setting Error = "@gopal:Errorwith"+"@gopal:LineNumber"+_invoiceID+"@gopal:GeneratingPendingInvoice"

                                where productRegistrationTableerror.PurchId         == _PurchID

                                    && productRegistrationTableerror.PackingSlipId  == _PackingSlipId

                                    && productRegistrationTableerror.InvoiceNumber  == _invoiceID

                                    && productRegistrationTableerror.InboundValidationPassed == NoYes::Yes;

                throw error("@gopal:PendingInvoiceFailed");

                                    

            }

        }

    }


    public void ASNProcessOperation()

    {

        //Input any business process logic that need to be scheduled on batch

        gopProductRegistrationTable    productRegistrationTable,productRegistrationTableLoc;

        gopProductRegistrationTable    productRegistrationTablein;

        gopAckQtyDateUpdateOnPurchOrder ackQtyDateUpdateOnPurchOrderValidate;

        while select count(RecId),maxof(PurchId),maxof(PackingSlipId),maxof(InvoiceNumber)  from productRegistrationTable

                group by PurchId,PackingSlipId

                order by PurchID desc

            where productRegistrationTable.IsRegistred == NoYes::No

                && productRegistrationTable.IsSAPASN == NoYes::Yes

                && productRegistrationTable.RegistredQty > 0

                && productRegistrationTable.IsSkip == NoYes::No

                && productRegistrationTable.InboundValidationPassed == NoYes::Yes

        {

            try

            {

                gopProductRegistrationTable productRegistrationTableUpdate;

                if(PurchTable::find(productRegistrationTable.PurchId).PurchStatus == PurchStatus::Invoiced)

                {

                    ttsbegin;

                    update_recordset productRegistrationTableUpdate

                        setting IsSkip = NoYes::Yes

                        where productRegistrationTableUpdate.PurchId     == productRegistrationTable.PurchId

                            && productRegistrationTableUpdate.PackingSlipId  == productRegistrationTable.PackingSlipId

                            && productRegistrationTableUpdate.InboundValidationPassed == NoYes::Yes;

                    ttscommit;

                    throw error(strFmt("@gopal:gopPOInvCheck",productRegistrationTable.PurchId));

                }

                else if(PurchTable::find(productRegistrationTable.PurchId).PurchStatus == PurchStatus::Received)

                {

                    ttsbegin;

                    update_recordset productRegistrationTableUpdate

                        setting IsSkip = NoYes::Yes

                        where productRegistrationTableUpdate.PurchId     == productRegistrationTable.PurchId

                            && productRegistrationTableUpdate.PackingSlipId  == productRegistrationTable.PackingSlipId

                            && productRegistrationTableUpdate.InboundValidationPassed == NoYes::Yes;

                    ttscommit;

                    throw error(strFmt("@gopal:gopPORcvCheck",productRegistrationTable.PurchId));

                }


                ttsbegin;

                if(productRegistrationTable.RecId>1)

                {

                    while select productRegistrationTableLoc

                        where productRegistrationTableLoc.PurchId == productRegistrationTable.PurchId

                            && productRegistrationTableLoc.PackingSlipId == productRegistrationTable.PackingSlipId

                            && productRegistrationTableLoc.IsRegistred == NoYes::No

                            && productRegistrationTableLoc.IsSAPASN == NoYes::Yes

                            && productRegistrationTableLoc.IsSkip == NoYes::No

                            && productRegistrationTableLoc.InboundValidationPassed == NoYes::Yes

                    {

                        this.PostPOregistration(productRegistrationTableLoc);

                    }

                    this.poProductRecipt(productRegistrationTable.PurchId, productRegistrationTable.PackingSlipId, productRegistrationTable.DeliveryDateUpdate);

                    

                }

                else

                {

                    select firstonly productRegistrationTableLoc

                        where productRegistrationTableLoc.PurchId == productRegistrationTable.PurchId

                            && productRegistrationTableLoc.PackingSlipId  == productRegistrationTable.PackingSlipId

                            && productRegistrationTableLoc.IsRegistred == Noyes::no

                            && productRegistrationTableLoc.IsSAPASN == NoYes::Yes

                            && productRegistrationTableLoc.IsSkip == NoYes::No

                            && productRegistrationTableLoc.InboundValidationPassed == NoYes::Yes;

                    if (productRegistrationTableLoc)

                    {

                        this.PostPOregistration(productRegistrationTableLoc);

                        this.poProductRecipt(productRegistrationTable.PurchId, productRegistrationTable.PackingSlipId, productRegistrationTable.DeliveryDateUpdate);

                    }

                }

                ttscommit;

            }

            catch(Exception::Error)

            {

                SysInfoLogEnumerator                infoLogEnum;

                SysInfologMessageStruct             infoMessageStruct;

                str                                 errorinfo;

                gopProductRegistrationTable    productRegistrationTablecatch;

                infoLogEnum = SysInfoLogEnumerator::newData(infolog.infologData());

                while(infoLogEnum.moveNext())

                {

                    infoMessageStruct = SysInfologMessageStruct::construct(infoLogEnum.currentMessage());

                    errorinfo       = errorinfo + infoMessageStruct.message() + '\n';

                }

                update_recordset productRegistrationTablecatch

                        setting Error = errorinfo

                    where productRegistrationTablecatch.PurchId     == productRegistrationTableLoc.PurchId

                        && productRegistrationTablecatch.PackingSlipId  == productRegistrationTableLoc.PackingSlipId

                        && productRegistrationTablecatch.IsSAPASN  == NoYes::Yes

                        && productRegistrationTablecatch.ItemId  == productRegistrationTableLoc.ItemId

                        && productRegistrationTablecatch.PackingSlipLineNumber  == productRegistrationTableLoc.PackingSlipLineNumber

                        && productRegistrationTablecatch.InboundValidationPassed == NoYes::Yes;

                continue;

            }

            

        }

    }


    public void InvoiceProcessOperation()

    {

        //Input any business process logic that need to be scheduled on batch

        gopProductRegistrationTable    productRegistrationTable, productRegistrationTablecatch;

        gopackQtyDateUpdateOnPurchOrder ackQtyDateUpdateOnPurchOrderValidate;

        while select count(RecId),maxof(PurchId),maxof(SAPInvoicePackingSlipId),maxof(InvoiceNumber), maxof(SAPInvoicePackingSlipLineNumber), maxof(ItemId) from productRegistrationTable

                group by PurchId, SAPInvoicePackingSlipId

                order by PurchID desc

            where productRegistrationTable.IsSAPInvoice == NoYes::Yes

                && productRegistrationTable.IsInvoiced == NoYes::No

                && productRegistrationTable.IspendingInvoiced == NoYes::No

                && productRegistrationTable.InboundValidationPassed == NoYes::Yes

        {

            try

            {

                boolean    processForPendingInvoice;

                processForPendingInvoice = gopProductRegistrationTable::findSAPASNfromSAPInvoice(productRegistrationTable);

                if (processForPendingInvoice)

                {

                    ttsbegin;

                    this.PostPendingInvoice(productRegistrationTable.PurchId, productRegistrationTable.SAPInvoicePackingSlipId, productRegistrationTable.InvoiceNumber, productRegistrationTable.DocumentDate);

                    ttscommit;

                }

                else

                {

                    gopProductRegistrationTable productRegistrationTablelvair;

                    update_recordset productRegistrationTablelvair

                        setting Error = strFmt("@gopal:ErrorInfoASNnotProcessed",productRegistrationTable.SAPInvoicePackingSlipId, productRegistrationTablelvair.SAPInvoicePackingSlipLineNumber, productRegistrationTable.PurchId)

                        where productRegistrationTablelvair.PurchId == productRegistrationTable.PurchId

                            && productRegistrationTablelvair.IsSAPInvoice == NoYes::Yes

                            && productRegistrationTablelvair.ItemId == productRegistrationTable.ItemId

                            && productRegistrationTablelvair.InvoiceNumber  == productRegistrationTable.InvoiceNumber

                            && productRegistrationTablelvair.InvoiceLineNumber == productRegistrationTable.InvoiceLineNumber

                            && productRegistrationTablelvair.InboundValidationPassed == NoYes::Yes;


                }

                

            }

            catch(Exception::Error)

            {

                SysInfoLogEnumerator                infoLogEnum;

                SysInfologMessageStruct             infoMessageStruct;

                str                                 errorinfo;

                //gopProductRegistrationTable    productRegistrationTablecatch;

                infoLogEnum = SysInfoLogEnumerator::newData(infolog.infologData());

                while(infoLogEnum.moveNext())

                {

                    infoMessageStruct = SysInfologMessageStruct::construct(infoLogEnum.currentMessage());

                    errorinfo       = errorinfo + infoMessageStruct.message() + '\n';

                }

                update_recordset productRegistrationTablecatch

                        setting Error = "For record"+ productRegistrationTable.ItemId + productRegistrationTable.InvoiceNumber + productRegistrationTable.PurchId + errorinfo

                        where productRegistrationTablecatch.PurchId     == productRegistrationTable.PurchId

                        && productRegistrationTablecatch.IsSAPInvoice == NoYes::Yes

                        && productRegistrationTablecatch.InvoiceNumber == productRegistrationTable.InvoiceNumber

                        && productRegistrationTablecatch.ItemId == productRegistrationTable.ItemId

                        && productRegistrationTablecatch.InvoiceLineNumber == productRegistrationTable.InvoiceLineNumber

                        && productRegistrationTablecatch.InboundValidationPassed == NoYes::Yes;

                continue;

            }

            

        }

    }


    /// <summary>

    /// The <c>PostPOregistration</c> this method is used  for post the purchase order registration.

    /// </summary>

    ///  /// <param name="_productRegistrationTableLoc">

    /// The new value of the datacontract parameter gopProductRegistrationTable; Mandatory.

    /// </param>

    //PO Registration process -strat

    public void PostPOregistration(gopProductRegistrationTable _productRegistrationTableLoc)

    {

        PurchLine                       purchLine;

        InventTrans                     inventTrans;

        InventTransOrigin               inventTransOrigin;

        InventDim                       inventDim;

        InventTransWMS_Register         inventTransWMS_register;

        TmpInventTransWMS               tmpInventTransWMS;

        InventBatch                     inventBatch,inventBatchloc;

        inventSerial                    inventSerial,inventSerialLoc;

        boolean                         isinventstatus,ret;

        InventBatchId                   InventbatchIdOrSerialId;

        VendInvoiceTrans                vendInvoiceTrans;

        VendPackingSlipTrans            vendPackingSlipTrans;


        select firstonly vendPackingSlipTrans

            where vendPackingSlipTrans.OrigPurchid == _productRegistrationTableLoc.PurchId

            && vendPackingSlipTrans.LineNum == _productRegistrationTableLoc.LineNumber

            && vendPackingSlipTrans.ItemId == _productRegistrationTableLoc.ItemId;

        select firstonly vendInvoiceTrans

            where vendInvoiceTrans.OrigPurchId == _productRegistrationTableLoc.PurchId

            && vendInvoiceTrans.PurchaseLineLineNumber == _productRegistrationTableLoc.LineNumber

            && vendInvoiceTrans.ItemId == _productRegistrationTableLoc.ItemId;

        select firstonly purchLine

                        where purchLine.PurchId == _productRegistrationTableLoc.PurchId

                        && purchLine.LineNumber == _productRegistrationTableLoc.LineNumber

                        && purchLine.ItemId     == _productRegistrationTableLoc.ItemId;

        select firstonly inventTrans

                    where inventTrans.StatusReceipt == StatusReceipt::Ordered

                exists join inventTransOrigin

                    where inventTransOrigin.RecId         ==  inventTrans.InventTransOrigin

                    && inventTransOrigin.InventTransId == purchLine.InventTransId;

        

        

        if(inventTrans && inventTrans.StatusReceipt != StatusReceipt::Registered)

        {

            InventTableModule inventTableModule = InventTableModule::find(inventTrans.ItemId,ModuleInventPurchSales::Invent);

            inventDim = inventTrans.inventDim();

            tmpInventTransWMS.clear();

            tmpInventTransWMS.initFromInventTrans(inventTrans);

            tmpInventTransWMS.InventQty = inventTrans.Qty;


            if (_productRegistrationTableLoc.inventBatchId)

            {

                InventbatchIdOrSerialId = _productRegistrationTableLoc.inventBatchId;

            }

            else if (_productRegistrationTableLoc.inventSerialId)

            {

                InventbatchIdOrSerialId = _productRegistrationTableLoc.inventSerialId;

            }

            if (InventbatchIdOrSerialId)

            select firstonly inventBatchloc

                    where inventBatchloc.inventBatchId == InventbatchIdOrSerialId

                        && inventBatchloc.itemId == _productRegistrationTableLoc.itemId;

            if(!inventBatchloc )

            {

                if(InventbatchIdOrSerialId && _productRegistrationTableLoc.itemId)

                {

                    inventBatch.itemId          = _productRegistrationTableLoc.ItemId;

                    inventBatch.inventBatchId   = InventbatchIdOrSerialId;

                    inventBatch.prodDate        = _productRegistrationTableLoc.ManufacturingDate;

                    inventBatch.insert();


                    inventBatch = InventBatch::findOrCreate(InventbatchIdOrSerialId, inventTrans.ItemId);

                    inventDim.inventBatchId = inventBatch.inventBatchId;

                }

                

            }

            else

            {

                inventDim.inventBatchId = inventBatchloc.inventBatchId;

            }

        

            tmpInventTransWMS.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;

            tmpInventTransWMS.insert();

            if(purchLine.PurchUnit != inventTableModule.UnitId)

            {

                inventTrans.Qty = this.convertQty(_productRegistrationTableLoc.RegistredQty,purchLine.PurchUnit,inventTableModule.UnitId,_productRegistrationTableLoc.ItemId);

            }

            else

            {

                inventTrans.Qty = _productRegistrationTableLoc.RegistredQty;

            }

            inventTrans.Qty = _productRegistrationTableLoc.RegistredQty; /*register quantity*/    //NEW LINE;

            inventTrans.inventDimId = inventDim::findOrCreate(inventDim).inventDimId; //NEW LINE

            inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);

            ret =inventTransWMS_Register.createFromInventTrans(inventTrans, inventDim);

            inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS, inventTrans, inventTrans.inventDim());

            inventTransWMS_register.updateInvent(purchLine);

            if(ret)

            {

                ttsbegin;

                _productRegistrationTableLoc.selectForUpdate(true);

                _productRegistrationTableLoc.IsRegistred = NoYes::Yes;

                _productRegistrationTableLoc.Error = empty;

                _productRegistrationTableLoc.PurchStatus = gopal_PurchStatus::Registred;

                if(_productRegistrationTableLoc)

                {

                    _productRegistrationTableLoc.update();

                }

                ttscommit;

                isinventstatus =  inventTransWMS_register.updateInvent(purchLine);

            }

            else

            {

                ttsbegin;

                _productRegistrationTableLoc.selectForUpdate(true);

                _productRegistrationTableLoc.Error = "@gopal:ErrorIn"+"@gopal:LineNumber"+any2Str(_productRegistrationTableLoc.LineNumber)+"@gopal:Comma"+_productRegistrationTableLoc.PurchId+"@gopal:RegistrationIsFailed";

                if(_productRegistrationTableLoc)

                {

                    _productRegistrationTableLoc.update();

                }

                ttscommit;

                throw Error("@gopal:RegistrationIsFailed");

               

            }

        }

        else if(vendPackingSlipTrans)

        {

            ttsbegin;

            _productRegistrationTableLoc.selectForUpdate(true);

            _productRegistrationTableLoc.IsSkip = NoYes::Yes;

            _productRegistrationTableLoc.update();

            ttscommit;

            throw error(strFmt("@gopal:gopPOLineRcvCheck",_productRegistrationTableLoc.PurchId,any2Str(_productRegistrationTableLoc.LineNumber)));

        }

        else if(vendInvoiceTrans)

        {

            ttsbegin;

            _productRegistrationTableLoc.selectForUpdate(true);

            _productRegistrationTableLoc.IsSkip = NoYes::Yes;

            _productRegistrationTableLoc.update();

            ttscommit;

            throw error(strFmt("@gopal:gopPOLineInvCheck",_productRegistrationTableLoc.PurchId,any2Str(_productRegistrationTableLoc.LineNumber)));

        }

    }


    //PO Product Receipt process- End

    /// <summary>

    /// The <c>PostPOregistration</c> this method is used  for post the purchase order pending invoice

    /// </summary>

    /// <param name="_purchID">

    /// The new value of the datacontract parameter PurchID; Mandatory.

    /// </param>

    /// <param name="_PackingSlipId">

    /// The new value of the datacontract parameter PackingSlipId; Mandatory.

    /// </param>

    ///<param name="_invoiceID">

    /// The new value of the datacontract parameter InvoiceID; Mandatory.

    /// </param>

    //Process for vendor invoice Automation:-start

    public void PostPendingInvoice(PurchID _purchID, PackingSlipId  _PackingSlipId, InvoiceID _invoiceID, str _DocumentDate)

    {

        VendorInvoiceHeaderEntity           vendorInvoiceHeaderEntity,VendorInvoiceHeaderEntityloc,VendorInvoiceHeaderEntityInv;

        VendPackingSlipJour                 vendPackingSlipJour;

        gopProductRegistrationTable        productRegistrationTablelvair,productRegistrationTableInv;

        VendInvoiceInfoTable                vendInvoiceInfoTable;

        VendInvoiceInfoLine                 vendInvoiceInfoLine;

        purchTable                          PurchTable;

        PriceDiscTable                      PriceDiscTable;

        select firstonly purchTable

                    where purchTable.PurchId == _purchID;

        select firstonly vendPackingSlipJour

                    where vendPackingSlipJour.PackingSlipId == _PackingSlipId;

        select firstonly VendorInvoiceHeaderEntityloc

                    where VendorInvoiceHeaderEntityloc.InvoiceNumber == _invoiceID;

        if(vendPackingSlipJour && !VendorInvoiceHeaderEntityloc)

        {

            vendorInvoiceHeaderEntity.HeaderOnlyImport = NoYes::Yes;

            vendorInvoiceHeaderEntity.PackingslipRange = _PackingSlipId;

            vendorInvoiceHeaderEntity.InvoiceAccount = purchTable.InvoiceAccount;

            vendorInvoiceHeaderEntity.PurchaseOrderNumber = purchTable.PurchId;

            vendorInvoiceHeaderEntity.VendorAccount = purchTable.OrderAccount;

            vendorInvoiceHeaderEntity.InvoiceNumber = _invoiceID;

            vendorInvoiceHeaderEntity.DueDate = PurchTable.FixedDueDate;

            vendorInvoiceHeaderEntity.DocumentDate = str2Date(_DocumentDate,213);

            vendorInvoiceHeaderEntity.InvoiceDate   = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());

            vendorInvoiceHeaderEntity.insert();

            select firstonly VendorInvoiceHeaderEntityInv

                        where VendorInvoiceHeaderEntityInv.InvoiceNumber        == _invoiceID

                        && VendorInvoiceHeaderEntityInv.PurchaseOrderNumber     == _PurchId;

            if(VendorInvoiceHeaderEntityInv)

            {

                update_recordset productRegistrationTablelvair

                    setting IspendingInvoiced = NoYes::Yes,

                            PurchStatus = gopal_PurchStatus::PendingInvoice,

                            Error = empty

                        where productRegistrationTablelvair.PurchId == VendorInvoiceHeaderEntityInv.PurchaseOrderNumber

                            && productRegistrationTablelvair.InvoiceNumber == VendorInvoiceHeaderEntityInv.InvoiceNumber

                            && productRegistrationTablelvair.InboundValidationPassed == NoYes::Yes;


                while select maxof(InvoiceUnitPrice),maxof(ItemId),maxof(LineNumber),maxof(PurchId),Maxof(InvoiceNumber),maxof(NetAmount),maxof(DocumentDate) from  productRegistrationTableInv

                        group by itemId,PurchId,LineNumber,InvoiceNumber

                    where productRegistrationTableInv.PurchId == _PurchId

                        && productRegistrationTableInv.InvoiceNumber == _invoiceID

                        && productRegistrationTableInv.SAPInvoicePackingSlipId == _PackingSlipId

                        && productRegistrationTableInv.InboundValidationPassed == NoYes::Yes

                {

                    //gopProductRegistrationTable asnProductRegistrationTable;

                    //asnProductRegistrationTable = gopProductRegistrationTable::findSAPASNfromSAPInvoice(productRegistrfationTableInv);

                    //if (asnProductRegistrationTable)

                    ttsbegin;

                    select firstonly forupdate vendInvoiceInfoLine

                            where vendInvoiceInfoLine.LineNum == productRegistrationTableInv.LineNumber

                                && vendInvoiceInfoLine.ItemId == productRegistrationTableInv.ItemId

                        join vendInvoiceInfoTable

                            where vendInvoiceInfoTable.Num == VendorInvoiceHeaderEntityInv.InvoiceNumber

                                && vendInvoiceInfoTable.PurchId == VendorInvoiceHeaderEntityInv.PurchaseOrderNumber

                                && vendInvoiceInfoTable.TableRefId == vendInvoiceInfoLine.TableRefId;

                    if(vendInvoiceInfoLine)

                    {

                        this.LTMPurchParmTableJourInsert(vendInvoiceInfoTable, productRegistrationTableInv.DocumentDate);

                        if (PurchParameters::find().gopApplyLineAmtFromPRTable == NoYes::Yes)

                        {

                            vendInvoiceInfoLine.LineAmount = productRegistrationTableInv.NetAmount;

                            vendInvoiceInfoLine.doUpdate();

                        }

                        else if (productRegistrationTableInv.InvoiceUnitPrice)

                        {


                            // Adding new code for trade agrement price -<03-01-2024>-start

                            PurchLine purchLine;

                            select firstonly purchLine

                                where purchLine.PurchId ==productRegistrationTableInv.PurchId

                                    && purchLine.ItemId == productRegistrationTableInv.ItemId

                                    && purchLine.LineNumber == productRegistrationTableInv.LineNumber;

                            PurchTable purchTableloc = purchLine.purchTable();

                            PriceDiscParameters parameters = PriceDiscParameters::construct();

                            parameters.parmModuleType(ModuleInventPurchSales::Purch);

                            parameters.parmItemId(purchLine.Itemid);

                            parameters.parmInventDim(purchLine.inventDim());

                            parameters.parmUnitID(purchLine.PurchUnit);

                            parameters.parmPriceDiscDate(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));

                            parameters.parmQty(1);

                            parameters.parmAccountNum(purchTableloc.OrderAccount);

                            parameters.parmCurrencyCode(purchLine.CurrencyCode);

                            PriceDisc priceDisc = PriceDisc::newFromPriceDiscParameters(parameters);

                            if (priceDisc)

                            {

            

                                if (!priceDisc.findPrice(purchLine.purchTable().PriceGroupId))

                                {

                                    priceDisc.priceUnit();

                                }

                                PriceDiscTable =  priceDisc.priceTable();

                            }

                            if(PriceDiscTable)

                            {

                                vendInvoiceInfoLine.PurchPrice  = productRegistrationTableInv.InvoiceUnitPrice*priceDisc.priceUnit();

                                vendInvoiceInfoLine.LineAmount  = (productRegistrationTableInv.InvoiceUnitPrice*priceDisc.priceUnit()*vendInvoiceInfoLine.ReceiveNow)/priceDisc.priceUnit();

                                vendInvoiceInfoLine.doUpdate();

                            }

                            // Adding new code for trade agrement price -<03-01-2024>-End

                            else

                            {

                                vendInvoiceInfoLine.PurchPrice  = productRegistrationTableInv.InvoiceUnitPrice;

                                vendInvoiceInfoLine.LineAmount  = productRegistrationTableInv.InvoiceUnitPrice*vendInvoiceInfoLine.ReceiveNow;

                                vendInvoiceInfoLine.doUpdate();

                            }

                        }

                        

                    }

                   

                    ttscommit;

                }

            }

            else

            {

                gopProductRegistrationTable      productRegistrationTableerror;

                update_recordset productRegistrationTableerror

                        setting Error = "@gopal:Errorwith"+"@gopal:LineNumber"+productRegistrationTableInv.ItemId+_invoiceID+"@gopal:GeneratingPendingInvoice"

                    where productRegistrationTableerror.PurchId         == _PurchID

                        && productRegistrationTableerror.SAPInvoicePackingSlipId  == _PackingSlipId

                        && productRegistrationTableerror.InvoiceNumber  == _invoiceID

                        && productRegistrationTableerror.InboundValidationPassed == NoYes::Yes;

                throw error("@gopal:PendingInvoiceFailed");

                                    

            }

        }

    }


    /// <summary>

    /// get converted Qty

    /// </summary>

    /// <param name = "_qty">qty</param>

    /// <param name = "_fromUnitId">FromUnitId</param>

    /// <param name = "_toUnitId">ToUnitId</param>

    /// <param name = "_itemId">ItemId</param>

    /// <returns>Qty</returns>

    public Qty convertQty(Qty _qty, UnitOfMeasureSymbol _fromUnitId, UnitOfMeasureSymbol _toUnitId, ItemId _itemId)

    {

        Qty qty;

        qty = EcoResProductUnitConverter::convertForReleasedProduct(_itemId,InventTable::getInventDimId(_itemId),_qty,UnitOfMeasure::findBySymbol(_fromUnitId).RecId,UnitOfMeasure::findBySymbol(_toUnitId).RecId,NoYes::Yes);

        return qty;

    }


    /// <summary>

    /// This method is used to validate the purchase orders lines while inseting records from API.

    /// </summary>

    /// <returns>

    /// true if the validation succeeded; otherwise, false.

    /// </returns>

    public boolean validateWrite(gopProductRegistrationTable _registrationTable)

    {

        boolean ret;

        Counter errorCount;

        PurchTable                      purchTable, purchTableLoc;

        PurchLine                       purchLine;

        InventTrans                     inventTrans;

        InventTransOrigin               inventTransOrigin;

        VendPackingSlipJour             vendPackingSlipJour;

        VendInvoiceJour                 vendInvoiceJour;

        VendorInvoiceHeaderEntity       vendorInvoiceHeaderEntity;

        boolean processForPendingInvoice;

        gopAckQtyDateUpdateOnPurchOrder ackQtyDateUpdateOnPurchOrder,ackQtyDateUpdateOnPurchOrderIsPross;

        

        ret = true;


        if (_registrationTable.IsSAPInvoice)

        {

            select firstonly vendorInvoiceHeaderEntity

                where vendorInvoiceHeaderEntity.InvoiceNumber == _registrationTable.InvoiceNumber;

        }

               

        select firstonly  vendInvoiceJour

            where vendInvoiceJour.PurchId == _registrationTable.PurchId

                && vendInvoiceJour.InvoiceId  == _registrationTable.InvoiceNumber;

        select firstonly purchTable

            where purchTable.PurchId == _registrationTable.PurchId

                && purchTable.PurchStatus == PurchStatus::Backorder

                && purchTable.DocumentState == VersioningDocumentState::Confirmed;

        select firstonly purchLine

            where purchLine.LineNumber  == _registrationTable.LineNumber

                && purchLine.ItemId     == _registrationTable.ItemId

                && purchLine.PurchId    == _registrationTable.PurchId;

        select firstonly inventTrans

                where inventTrans.StatusReceipt == StatusReceipt::Ordered

            exists join inventTransOrigin

                where inventTransOrigin.RecId         ==  inventTrans.InventTransOrigin

                    && inventTransOrigin.InventTransId == purchLine.InventTransId;

        select firstonly  vendInvoiceJour

            where vendInvoiceJour.PurchId == _registrationTable.PurchId

                && vendInvoiceJour.InvoiceId  == _registrationTable.InvoiceNumber;

        select firstonly vendPackingSlipJour

            where vendPackingSlipJour.PackingSlipId == _registrationTable.PackingSlipId

                && vendPackingSlipJour.PurchID == _registrationTable.PurchId;


        select count(RecId) from ackQtyDateUpdateOnPurchOrder

            where ackQtyDateUpdateOnPurchOrder.PurchId == _registrationTable.PurchId

                && ackQtyDateUpdateOnPurchOrder.ItemId == _registrationTable.ItemId;

           

        select count(RecId) from ackQtyDateUpdateOnPurchOrderIsPross

            where ackQtyDateUpdateOnPurchOrderIsPross.PurchId == _registrationTable.PurchId

                && ackQtyDateUpdateOnPurchOrderIsPross.ItemId == _registrationTable.ItemId

                && ackQtyDateUpdateOnPurchOrderIsPross.IsProcessed == NoYes::No;


        processForPendingInvoice = gopProductRegistrationTable::findSAPASNfromSAPInvoice(_registrationTable);

        

        if (ret && !purchTable)

        {

            select firstonly purchTableLoc

                where purchTableLoc.PurchId == _registrationTable.PurchId

                    && purchTableLoc.PurchStatus == PurchStatus::Received

                    && purchTableLoc.DocumentState == VersioningDocumentState::Confirmed;

            if (ret && !purchTableLoc)

            {

                errorCount++;

                CaptureError = (strFmt("%2 -"+"@gopal:InvaildPurchaseOrder",_registrationTable.PurchId,errorCount));

                ret = false;

            }

        }

        if(ret && !purchLine)

        {

            errorCount++;

            CaptureError = (strFmt("%4: "+"@gopal:InvaildPurchaseOrderLineDetails",_registrationTable.PurchId, _registrationTable.ItemId,_registrationTable.LineNumber,errorCount));

            ret = false;


        }

        if(ret && vendPackingSlipJour)

        {

            errorCount++;

            CaptureError = (strFmt("%5: "+"@gopal:InvaildPurchaseOrderPackingslip", _registrationTable.PurchId, _registrationTable.ItemId,_registrationTable.LineNumber, _registrationTable.PackingSlipId,errorCount));

            ret = false;

        }

        if(ret && vendInvoiceJour)

        {

            errorCount++;

            CaptureError = (strFmt("%5: "+"@gopal:InvaildPurchaseOrderInvoice", _registrationTable.PurchId, _registrationTable.ItemId,_registrationTable.LineNumber, _registrationTable.InvoiceNumber,errorCount));

            ret = false;

        }

        if(ret && vendorInvoiceHeaderEntity && _registrationTable.IsSAPInvoice)

        {

            errorCount++;

            CaptureError = (strFmt("%5: "+"@gopal:InvaildPurchaseOrderInvoiceExists", _registrationTable.PurchId, _registrationTable.ItemId,_registrationTable.LineNumber, _registrationTable.InvoiceNumber,errorCount));

            ret = false;

        }

        if(ret && _registrationTable.RegistredQty ==0.00)

        {

            errorCount++;

            CaptureError = (strFmt("%5: "+"@gopal:InvaildPurchaseOrderLineRegistrationQtyZero",_registrationTable.PurchId, _registrationTable.ItemId,_registrationTable.LineNumber,_registrationTable.RegistredQty,errorCount));

            ret = false;

        }

        if (ret && _registrationTable.IsSAPASN && !_registrationTable.PackingSlipId)

        {

            errorCount++;

            CaptureError = (strFmt("%5: "+"@gopal:ASNPackingSlipIDValidation",_registrationTable.PurchId, _registrationTable.ItemId,_registrationTable.LineNumber,_registrationTable.RegistredQty,errorCount));

            ret = false;

        }

        if (ret && _registrationTable.IsSAPInvoice && !_registrationTable.InvoiceNumber)

        {

            errorCount++;

            CaptureError = (strFmt("%5: "+"@gopal:ASNInvoicePackingSlipIDValidation",_registrationTable.PurchId, _registrationTable.ItemId,_registrationTable.LineNumber,_registrationTable.RegistredQty,errorCount));

            ret = false;

        }

        /*if (ret && !ackQtyDateUpdateOnPurchOrder.RecId)

        {

            errorCount++;

            CaptureError = (strFmt("%5: "+"@gopal:POAnotCompletedValidationFailed",_registrationTable.PurchId,errorCount));

            ret = false;

        }

        if (ret && ackQtyDateUpdateOnPurchOrderIsPross.RecId)

        {

            errorCount++;

            CaptureError = (strFmt("%5: "+"@gopal:POAnotCompletedValidationFailed",_registrationTable.PurchId,errorCount));

            ret = false;

        }*/

        

        if (ret && !processForPendingInvoice && _registrationTable.IsSAPInvoice == NoYes::Yes)

        {

            errorCount++;

            CaptureError = strFmt("@gopal:ErrorInfoASNnotProcessed",_registrationTable.SAPInvoicePackingSlipId, _registrationTable.SAPInvoicePackingSlipLineNumber, _registrationTable.PurchId);

            ret = false;

        }

        return ret;

    }


    public void validateBeforeRecipitInvoice()

    {

        boolean isValidatioinPassed;

        gopProductRegistrationTable productRegistrationTableLoc;

        ttsbegin;

        while select productRegistrationTableLoc

            where (productRegistrationTableLoc.IsSAPASN == NoYes::Yes || productRegistrationTableLoc.IsSAPInvoice == NoYes::Yes)

                && productRegistrationTableLoc.IsSkip == NoYes::No

                && productRegistrationTableLoc.InboundValidationPassed == NoYes::No

                && productRegistrationTableLoc.PurchStatus == gopal_PurchStatus::None

        {

            isValidatioinPassed = this.validateWrite(productRegistrationTableLoc);

            if (!isValidatioinPassed)

            {

                productRegistrationTableLoc.selectForUpdate(1);

                productRegistrationTableLoc.InboundValidationPassed = NoYes::No;

                productRegistrationTableLoc.Error = CaptureError;

            }

            else

            {

                productRegistrationTableLoc.selectForUpdate(1);

                productRegistrationTableLoc.InboundValidationPassed = NoYes::Yes;

                productRegistrationTableLoc.Error = empty;

            }

            productRegistrationTableLoc.update();

        }


        

        ttscommit;

    }


    

}

Comments

Popular posts from this blog

Create ledger journals in D365FO using X++ + LedgerDimensionACType

Excel Import into D365 using x++ code

Sales invoice report