NW

 [ExtensionOf(tableStr(CustInvoicePackingSlipQuantityMatch))]


internal final class GOPCustInvoicePackingSlipQuantityMatch_Extension


{


    /// <summary>


    ///


    /// </summary>


    /// <param name="sender"></param>


    /// <param name="e"></param>


    [DataEventHandler(tableStr(CustInvoicePackingSlipQuantityMatch), DataEventType::Inserted)]


    public static void CustInvoicePackingSlipQuantityMatch_onInserted(Common sender, DataEventArgs e)


    {


        CustInvoicePackingSlipQuantityMatch custInvoicePackingSlipQuantityMatch = sender as CustInvoicePackingSlipQuantityMatch;


        CustInvoiceTrans CustInvoiceTransReturn = custInvoiceTrans::findBySourceDocumentLine(custInvoicePackingSlipQuantityMatch.InvoiceSourceDocumentLine);


        CustInvoiceTrans CustInvoiceTransOrig;


        SalesLine creditNoteSalesLine;


        


        custPackingSlipTrans custPackingSlipTrans;


        SalesLine   salesLineOrig;


       


        salesLineOrig = CustInvoiceTransReturn.salesLine();




        select DeliveryDate from custPackingSlipTrans


                    order by DeliveryDate desc


            join Quantity from CustInvoicePackingSlipQuantityMatch


                where custPackingSlipTrans.sourceDocumentLine == custInvoicePackingSlipQuantityMatch.PackingSlipSourceDocumentLine


                    && custPackingSlipTrans.inventTransId == salesLineOrig.InventTransId


                    && custPackingSlipTrans.ItemId == CustInvoiceTransReturn.ItemId


                    && custPackingSlipTrans.SalesId == CustInvoiceTransReturn.SalesId;


                    


        TransDate dateStartMthpackingSlipDate = dateStartMth(custPackingSlipTrans.DeliveryDate);


        TransDate endMthpackingSlipDate = endMth(custPackingSlipTrans.DeliveryDate);




        


        select InvoiceDate from CustInvoiceTransOrig


                order by InvoiceDate desc


            where CustInvoiceTransOrig.InventTransId == salesLineOrig.InventTransIdReturn


                && CustInvoiceTransOrig.ItemId == salesLineOrig.ItemId


                && CustInvoiceTransOrig.InvoiceDate >= dateStartMthpackingSlipDate


                && CustInvoiceTransOrig.InvoiceDate <= endMthpackingSlipDate;


        if (CustInvoiceTransOrig.InvoiceDate)


        {


            ttsbegin;


            CustInvoiceTransReturn.selectForUpdate(1);


            CustInvoiceTransReturn.GOPIsOrigReturnInvoicedInSameMonth = NoYes::Yes;


            CustInvoiceTransReturn.GOPOriginalOrderInvoicedDate = CustInvoiceTransReturn.InvoiceDate;


            CustInvoiceTransReturn.update();


            ttscommit;


        }


    }




}




internal final class GOPInventAgingStorageEventHandler


{


        /// <summary>


    ///


    /// </summary>


    /// <param name="sender"></param>


    /// <param name="e"></param>


    [FormControlEventHandler(formControlStr(InventAgingStorage, GOPNWIHelperUpdate), FormControlEventType::Clicked)]


    public static void GOPNWIHelperUpdate_OnClicked(FormControl sender, FormControlEventArgs e)


    {


        //Gets the running SalesEditLines form  


        FormButtonControl  callerButton = sender as FormButtonControl;


        


        FormRun form = callerButton.formRun(); 




        //Get the salesId that was selected in the SalesEditLines form


        FormDataSource inventAgingStorage_ds = form.dataSource(formDataSourceStr(InventAgingStorage, InventAgingStorage)) as FormDataSource;


        InventAgingStorage InventAgingStorage = inventAgingStorage_ds.cursor();


        InventAgingStorage InventAgingStorageLoc;


        InventParameters InventParameters;


        


        ttsbegin;


        select ForUpdate InventAgingStorageLoc


            where InventAgingStorageLoc.TransactionId != InventAgingStorage.TransactionId


                && InventAgingStorageLoc.GOPNWIReportHelper == NoYes::Yes;


        if (InventAgingStorageLoc.GOPNWIReportHelper == NoYes::Yes)


        {


            InventAgingStorageLoc.GOPNWIReportHelper = NoYes::No;


            InventAgingStorageLoc.Update();


        }




        InventAgingStorageLoc.clear();


        select ForUpdate InventAgingStorageLoc


            where InventAgingStorageLoc.TransactionId == InventAgingStorage.TransactionId;


        if (InventAgingStorageLoc.GOPNWIReportHelper == NoYes::No)


        {


            InventAgingStorageLoc.GOPNWIReportHelper = NoYes::Yes;


            InventAgingStorageLoc.Update();


        }




        InventParameters = InventParameters::find(true);


        //InventParameters.selectForUpdate(1);


        InventParameters.GOPTransactionId = InventAgingStorage.TransactionId;


        InventParameters.GOPExecutionName = InventAgingStorage.ExecutionName;


        InventParameters.update();


        ttscommit;




        inventAgingStorage_ds.refresh();


        


    }




}/// <summary>


///    The <c>GOPInventTransUsageQuantityController</c> class handles the business logic for the


///    <c>CPEReport</c> report.


/// </summary>


public class GOPInventTransUsageQuantityController extends SrsReportRunController implements BatchRetryable


{


    




    public static void main(Args _args)


    {


        GOPInventTransUsageQuantityController controller = new GOPInventTransUsageQuantityController();


        controller.parmReportName(ssrsReportStr(GOPInventTransUsageQuantitysReport, Report));


        controller.parmArgs(_args);


        controller.startOperation();


    }




    /// <summary>


    /// Specifies if the batch task is retryable for transient exceptions or not.


    /// </summary>


    /// <returns>


    /// If true is returned, the batch task is retryable, otherwise it is not.


    /// </returns>


    [Hookable(false)]


    final boolean isRetryable()


    {


        return true;


    }




}




/// <summary>


/// The <c>GOPInventoryReportDp</c> class is the report Data Provider class for the


/// <c>GOPInventoryReportDp</c>SQL Server Reporting Services report.


/// </summary>


[SrsReportParameterAttribute(classStr(GOPInventTransUsageQuantityReportContract))]


class GOPInventTransUsageQuantityDP extendS SrsReportDataProviderPreProcessTempDB


{


    TransDate invFrom3rdMonth;


    TransDate invFrom6thMonth;


    TransDate invFrom9thMonth;


    TransDate invCloseDate;


    InventTrans inventTransUsageQuantityReceiptView;


    InventTransOrigin InventTransOrigin;


    InventDim InventDim;


    Counter icount;


    TransDate last36monthStartDate;


    GOPInventTransUsageQuantityReportContract contract;


    GOPInventTransUsageQuantityTmp inventTransUsageQuantityTmp;


    GOPInventTransUsageQuantityIssueView inventTransUsageQuantityIssueView;


    GOPInventTransUsageQuantityIssueView inventTransUsageQuantityIssueViewLoc;


    


    [SRSReportDataSetAttribute(tableStr(GOPInventTransUsageQuantityTmp))]


    public GOPInventTransUsageQuantityTmp getGOPInventTransUsageQuantityTmp()


    {


        select * from inventTransUsageQuantityTmp;


        return inventTransUsageQuantityTmp;


    }




    public void processReport()


    {


        InventLocation  inventLocation;


        LanguageId languageId = this.defaultProductLanguageId();


        


        invFrom3rdMonth = dateNull();


        invFrom6thMonth = dateNull();


        invFrom9thMonth = dateNull();


        invCloseDate = dateNull();




        contract = this.parmDataContract() as GOPInventTransUsageQuantityReportContract;


        invCloseDate   = contract.parmToDate();


        


        invCloseDate = GOPInventTransUsageQuantityDP::findPrevClosingDate(invCloseDate).TransDate;


        


        invFrom3rdMonth = prevQtr(invCloseDate);


        invFrom6thMonth = prevQtr(invFrom3rdMonth);


        invFrom9thMonth = prevQtr(invFrom6thMonth);


        last36monthStartDate = prevYr(prevYr(prevYr(invCloseDate)));


        




        if(!this.Validate(contract.parmToDate()))


        {


            throw error("Inventory is not closed, Please close inventory");


        }


        /*


        icount = 1;


        if (!contract.parmItemId())


        {


            while select  dataAreaid, ItemId, InventLocationId, inventSiteId, sum(QTY) from inventTransUsageQuantityIssueView


                group by dataAreaid, ItemId, InventLocationId, inventSiteId


            {


                


                this.populateSalesReportData();


            }


            inventTransUsageQuantityIssueView.clear();




            //while select  dataAreaid, ItemId, InventLocationId, inventSiteId, sum(QTY) from inventTransUsageQuantityReceiptView


            //    group by dataAreaid, ItemId, InventLocationId, inventSiteId


            while Select  InventTransOrigin


                join ItemId, DatePhysical, sum(QTY) from inventTransUsageQuantityReceiptView


                        group by ItemId


                    where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOrigin.RecId


                join InventLocationId, InventSiteId from InventDim


                        group by InventLocationId, InventSiteId


                    where InventDim.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                exists join inventLocation  


                    where inventLocation.InventLocationId == InventDim.InventLocationId


                        && inventLocation.GOPExcludeNWIWH == NoYes::No


                        && InventTransOrigin.REFERENCECATEGORY != InventTransType::Sales


                        && inventTransUsageQuantityReceiptView.statusReceipt != statusReceipt::None


                        && inventTransUsageQuantityReceiptView.StatusIssue == StatusIssue::None


            {


                inventTransUsageQuantityIssueView.clear();


                select  inventTransUsageQuantityIssueView


                    where inventTransUsageQuantityIssueView.ItemId == inventTransUsageQuantityReceiptView.ItemId


                        && inventTransUsageQuantityIssueView.InventLocationId == InventDim.InventLocationId


                    && inventTransUsageQuantityIssueView.inventSiteId == InventDim.inventSiteId;


                if (!inventTransUsageQuantityIssueView)


                {


                    this.populatePurchReportData();


                }


            }


            inventTransUsageQuantityReceiptView.clear();


        }


        else


        {


            while select  dataAreaid, ItemId, InventLocationId, inventSiteId, sum(QTY) from inventTransUsageQuantityIssueView


                group by dataAreaid, ItemId, InventLocationId, inventSiteId 


                where inventTransUsageQuantityIssueView.ItemId == contract.parmItemId()


            {


                this.populateSalesReportData();


            }




            while Select  InventTransOrigin


                join ItemId, DatePhysical, sum(QTY) from inventTransUsageQuantityReceiptView


                        group by ItemId


                    where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOrigin.RecId


                join InventLocationId, InventSiteId from InventDim


                        group by InventLocationId, InventSiteId


                    where InventDim.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                exists join inventLocation


                    where inventLocation.InventLocationId == InventDim.InventLocationId


                        && inventLocation.GOPExcludeNWIWH == NoYes::No


                        && InventTransOrigin.REFERENCECATEGORY != InventTransType::Sales


                        && inventTransUsageQuantityReceiptView.statusReceipt != statusReceipt::None


                        && inventTransUsageQuantityReceiptView.StatusIssue == StatusIssue::None


                        && inventTransUsageQuantityReceiptView.ItemId == contract.parmItemId()


            {


                inventTransUsageQuantityIssueView.clear();


                select  inventTransUsageQuantityIssueView


                    where inventTransUsageQuantityIssueView.ItemId == inventTransUsageQuantityReceiptView.ItemId


                        && inventTransUsageQuantityIssueView.InventLocationId == InventDim.InventLocationId


                    && inventTransUsageQuantityIssueView.inventSiteId == InventDim.inventSiteId;


                if (!inventTransUsageQuantityIssueView)


                {


                    this.populatePurchReportData();


                }


            }


            inventTransUsageQuantityReceiptView.clear();


        }


        */


        this.calculateSalesDataonSiteOrWH();


        this.calculatePurchaseDataonSiteOrWH();


          


    }




    public void populateSalesReportData()


    {


        InventTable inventTable;


        InventAgingTmp inventAgingTmp;


        InventLocation InventLocationLoc;


        InventTableModule inventTableModule;


        InventItemGroupItem inventItemGroupItem;


        EcoResProductTranslation ecoResProductTranslation;


        NoYes GOPTransactionId = InventParameters::find().GOPTransactionId;


        




        inventTable.clear();


        inventTableModule.clear();


        inventItemGroupItem.clear();


        ecoResProductTranslation.clear();


        inventTransUsageQuantitytmp.clear();


        inventTransUsageQuantityIssueViewLoc.clear();


        


        if (contract.parmInventLocationId() == InventAgingViewOnly::View)


        {


            /*


        select  * from inventAgingTmp


            where inventAgingTmp.CreatedTransactionId == InventParameters::find().GOPTransactionId


                &&  inventAgingTmp.ItemId == inventTransUsageQuantityIssueView.ItemId


                && inventAgingTmp.InventSiteId == inventTransUsageQuantityIssueView.InventSiteId


                && inventAgingTmp.InventLocationId == inventTransUsageQuantityIssueView.InventLocationId


        if (inventAgingTmp.RecId && inventAgingTmp.QtyOnHand)


        */




            select  * from inventAgingTmp


                where inventAgingTmp.CreatedTransactionId == GOPTransactionId


                    &&  inventAgingTmp.ItemId == inventTransUsageQuantityIssueView.ItemId


                    && inventAgingTmp.InventSiteId == inventTransUsageQuantityIssueView.InventSiteId


                    && inventAgingTmp.InventLocationId == inventTransUsageQuantityIssueView.InventLocationId;


        }


        else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


        {


            select sum(QtyOnHand), maxof(UnitPrice) from inventAgingTmp


                    group by InventSiteId


                join InventLocationLoc


                    where InventLocationLoc.InventLocationId == inventAgingTmp.InventLocationId


                        && InventLocationLoc.inventSiteId == inventAgingTmp.InventSiteId


                        && InventLocationLoc.GOPExcludeNWIWH == NoYes::No


                        && inventAgingTmp.CreatedTransactionId == GOPTransactionId


                        &&  inventAgingTmp.ItemId == inventTransUsageQuantityIssueView.ItemId


                        && inventAgingTmp.InventSiteId == inventTransUsageQuantityIssueView.InventSiteId;


        }


        else


        {


            select sum(QtyOnHand), maxof(UnitPrice) from inventAgingTmp


                    group by ItemId


                join InventLocationLoc


                    where InventLocationLoc.InventLocationId == inventAgingTmp.InventLocationId


                        && InventLocationLoc.inventSiteId == inventAgingTmp.InventSiteId


                        && inventAgingTmp.CreatedTransactionId == GOPTransactionId


                        && inventAgingTmp.ItemId == inventTransUsageQuantityIssueView.ItemId


                        && InventLocationLoc.GOPExcludeNWIWH == NoYes::No;


        }




        if(inventAgingTmp.QtyOnHand)


        {




            select firstonly GOPBusinessUnit, GOPDivisionCode, GOPCommodityCode, GOPMaterialClassCategory, GOPGlobalSalesCode,DataAreaId from inventTable


                where inventTable.ItemId == inventTransUsageQuantityIssueView.ItemId;




            select firstonly ItemGroupId from inventItemGroupItem


                where inventItemGroupItem.ItemId == inventTable.ItemId


                && InventItemGroupItem.ItemDataAreaId == inventTable.DataAreaId;




            LanguageId LanguageId = this.defaultProductLanguageId();


            select firstonly name from ecoResProductTranslation


                where ecoResProductTranslation.Product == inventTable.Product


                    && ecoResProductTranslation.LanguageId == LanguageId;




            select firstonly UnitId, Price from inventTableModule


                where InventTableModule.ItemId == inventTable.ItemId


                    && (inventTableModule.ModuleType == ModuleInventPurchSales::Sales || inventTableModule.ModuleType == ModuleInventPurchSales::Invent);




            inventTransUsageQuantitytmp.InventoryCloseDate = invCloseDate;


            inventTransUsageQuantitytmp.InvTRansOriDataAreaId =  inventTransUsageQuantityIssueView.dataAreaid;


            inventTransUsageQuantitytmp.GOPDivisionCode = inventTable.GOPDivisionCode;


            inventTransUsageQuantitytmp.GOPCommodityCode = inventTable.GOPCommodityCode;


            inventTransUsageQuantitytmp.ItemId = inventTransUsageQuantityIssueView.ItemId;


            inventTransUsageQuantitytmp.name = ecoResProductTranslation.name;


            inventTransUsageQuantitytmp.UnitId = InventTableModule.UnitId;


            inventTransUsageQuantitytmp.GOPMaterialClassCategory = GOPMaterialClassCategory::findByRecId(inventTable.GOPInvUsageMaterialClassCategory).MaterialClassCategory;


            inventTransUsageQuantitytmp.GOPGlobalSalesCode = inventTable.GOPGlobalSalesCode;


            /*


            inventTransUsageQuantitytmp.InventLocationId = inventTransUsageQuantityIssueView.InventLocationId;


            inventTransUsageQuantitytmp.InventSiteId = inventTransUsageQuantityIssueView.InventSiteId;


            */


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                inventTransUsageQuantitytmp.InventLocationId = inventTransUsageQuantityIssueView.InventLocationId;


                inventTransUsageQuantitytmp.InventSiteId = inventTransUsageQuantityIssueView.InventSiteId;


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                inventTransUsageQuantitytmp.InventSiteId = inventTransUsageQuantityIssueView.InventSiteId;


            }


            else


            {


                inventTransUsageQuantitytmp.InventLocationId = "";


                inventTransUsageQuantitytmp.InventSiteId =  "";


            }


            inventTransUsageQuantitytmp.MaterialClassCategory = inventTable.GOPMaterialClassCategory;


            inventTransUsageQuantitytmp.AvailPhysical = inventAgingTmp.QtyOnHand;


            inventTransUsageQuantitytmp.OnHandQty = inventAgingTmp.QtyOnHand;


            inventTransUsageQuantitytmp.InvUsageQty = abs(inventTransUsageQuantityIssueView.Qty);


            inventTransUsageQuantitytmp.ItemGroupId = inventItemGroupItem.ItemGroupId;


            inventTransUsageQuantitytmp.OnHandValue = (inventTransUsageQuantitytmp.OnHandQty * inventAgingTmp.UnitPrice);


        


            inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty = 0.00;


            inventTransUsageQuantitytmp.MonthsofStockQty = 0.00;


            inventTransUsageQuantitytmp.IsHardGoodSparePartIndicator = inventTable.itemGroup().IsHardGoodSparePartIndicator;


            this.setMonthlyAverageUsageForSold();


            this.setLastUsageDatelast36months();


            this.setNWIEarlyWarningAndDeadQty( inventAgingTmp.UnitPrice);


            


            if (inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty != 0)


            {


                inventTransUsageQuantitytmp.MonthsofStockQty = (inventTransUsageQuantitytmp.OnHandQty / inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty);


            }


            this.setNWISlow(inventAgingTmp.UnitPrice);


            this.setNWIExcess(inventAgingTmp.UnitPrice);


           


            inventTransUsageQuantitytmp.NWITotal = (inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue


                                                            + inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessValue


                                                            + inventTransUsageQuantitytmp.NWIDeadValue


                                                            + inventTransUsageQuantitytmp.NWIDeadQtyPlusValue);


        


            inventTransUsageQuantitytmp.NWIUnitsTotal = (inventTransUsageQuantitytmp.NWIDeadQty


                                                                + inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessQty


                                                                + inventTransUsageQuantitytmp.NWI7T012MonthsSlowQty


                                                                + inventTransUsageQuantitytmp.NWIDeadQtyPlus);


            ReqItemTable reqItemTable;


            select firstonly reqItemTable


                index hint ItemIdx


                where reqItemTable.ItemId == inventTransUsageQuantitytmp.ItemId;


            if(reqItemTable)


            {


                inventTransUsageQuantitytmp.InStock = GOPIsStock::Stock;


            }


            else


            {


                inventTransUsageQuantitytmp.InStock = GOPIsStock::NonStock;


            }


            inventTransUsageQuantitytmp.CompanyLogo = FormLetter::companyLogo();


            inventTransUsageQuantitytmp.curr = Ledger::accountingCurrency(CompanyInfo::current());


            this.setFirstAndLastOfPurchaseandReciviedDatePhysical(inventTransUsageQuantitytmp.ItemId, inventAgingTmp.UnitPrice);


            this.setFinancialprovision();


            inventTransUsageQuantitytmp.Doinsert();


        }


    }




    public void setMonthlyAverageUsageForSold()


    {


        GOPNWIReferenceCategory nwiReferenceCategory;


        CustInvoiceTrans custInvoiceTrans;


        inventTransUsageQuantityIssueViewLoc.clear();


        /*


        select sum(Qty) from inventTransUsageQuantityIssueViewLoc


            where inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                && inventTransUsageQuantityIssueViewLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted)


                && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                && inventTransUsageQuantityIssueViewLoc.DatePhysical >= invFrom6thMonth;


        */




        if (contract.parmInventLocationId() == InventAgingViewOnly::View)


        {


            select sum(Qty) from inventTransUsageQuantityIssueViewLoc


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityIssueViewLoc.ReferenceCategory


                        && inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && inventTransUsageQuantityIssueViewLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted)


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= invFrom6thMonth;


        }


        else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


        {


            select sum(Qty) from inventTransUsageQuantityIssueViewLoc


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityIssueViewLoc.ReferenceCategory


                        && inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted)


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= invFrom6thMonth;


        }


        else


        {


            select sum(Qty) from inventTransUsageQuantityIssueViewLoc


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityIssueViewLoc.ReferenceCategory


                        && inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted)


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= invFrom6thMonth;


    


        }




        select firstonly sum(Qty) from custInvoiceTrans


            where custInvoiceTrans.itemid == inventTransUsageQuantitytmp.itemId


                && custInvoiceTrans.GOPIsOrigReturnInvoicedInSameMonth == NoYes::Yes


                && custInvoiceTrans.InvoiceDate <= invCloseDate;


               // && custInvoiceTrans.InvoiceDate >= invFrom6thMonth;


        inventTransUsageQuantitytmp.UsageQty1 = abs(inventTransUsageQuantityIssueViewLoc.Qty);


        inventTransUsageQuantitytmp.UsageQty2 = abs(inventTransUsageQuantityIssueViewLoc.Qty - custInvoiceTrans.Qty);


        inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty = abs(((inventTransUsageQuantityIssueViewLoc.Qty - custInvoiceTrans.Qty) / 6));




        inventTransUsageQuantityIssueViewLoc.clear();


        /*


        select sum(Qty) from inventTransUsageQuantityIssueViewLoc


            where inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                && inventTransUsageQuantityIssueViewLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted)


                && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                && inventTransUsageQuantityIssueViewLoc.DatePhysical >= last36monthStartDate;


        inventTransUsageQuantitytmp.UsageQtyInlast36months = inventTransUsageQuantityIssueViewLoc.Qty;


        */


        if (contract.parmInventLocationId() == InventAgingViewOnly::View)


        {


            select sum(Qty) from inventTransUsageQuantityIssueViewLoc


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityIssueViewLoc.ReferenceCategory


                        && inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && inventTransUsageQuantityIssueViewLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted)


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= last36monthStartDate;


            inventTransUsageQuantitytmp.UsageQtyInlast36months = inventTransUsageQuantityIssueViewLoc.Qty;


        }


        else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


        {


            select sum(Qty) from inventTransUsageQuantityIssueViewLoc


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityIssueViewLoc.ReferenceCategory


                        && inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted)


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= last36monthStartDate;


            inventTransUsageQuantitytmp.UsageQtyInlast36months = inventTransUsageQuantityIssueViewLoc.Qty;


        }


        else


        {


            select sum(Qty) from inventTransUsageQuantityIssueViewLoc


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityIssueViewLoc.ReferenceCategory


                        && inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted)


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= last36monthStartDate;


            inventTransUsageQuantitytmp.UsageQtyInlast36months = inventTransUsageQuantityIssueViewLoc.Qty;


    


        }


    }




    /// <summary>


    /// find company languageId


    /// </summary>


    /// <returns>languageId</returns>


    protected LanguageId defaultProductLanguageId()


    {


        return CompanyInfo::languageId();


    }




    /// <summary>


    /// To find NWI slow


    /// </summary>


    /// <param name = "_Price"> to calc NWIvalues for Item avarage cost for NWI report</param>


    public void setNWISlow(Price _Price)


    {


        inventTransUsageQuantitytmp.NWI7T012MonthsSlowQty = 0.00;


        inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue = 0.00;


        if (inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty != 0


                && inventTransUsageQuantitytmp.MonthsofStockQty > 6 && inventTransUsageQuantitytmp.MonthsofStockQty  < 12)


        {


            inventTransUsageQuantitytmp.NWI7T012MonthsSlowQty = ((inventTransUsageQuantitytmp.MonthsofStockQty -6) * inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty);


            inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue = (inventTransUsageQuantitytmp.NWI7T012MonthsSlowQty * _Price);


            if (inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue < 0)


            {


                inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue = 0.00;


            }


            inventTransUsageQuantitytmp.NWIStatusexcess = GOPNWIStatusexcess::Slow;


        }


        else


        {


            inventTransUsageQuantitytmp.NWIStatusexcess = GOPNWIStatusexcess::None;


        }


    }




    /// <summary>


    /// To find NWI Excess


    /// </summary>


    /// <param name = "_Price">to calc NWI values for Item avarage cost for NWI report</param>


    public void setNWIExcess(Price _Price)


    {


        if (inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty != 0 && inventTransUsageQuantitytmp.MonthsofStockQty > 12)


        {


            inventTransUsageQuantitytmp.NWI7T012MonthsSlowQty = 0.00;


            inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue = 0.00;


        


            {


                inventTransUsageQuantitytmp.NWI7T012MonthsSlowQty = (6 * inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty);


                inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue = (inventTransUsageQuantitytmp.NWI7T012MonthsSlowQty * _Price);


                if (inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue < 0)


                {


                    inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue = 0.00;


                }


                inventTransUsageQuantitytmp.NWIStatusexcess = GOPNWIStatusexcess::Slow;


            }




            inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessQty = ((inventTransUsageQuantitytmp.MonthsofStockQty - 12) * inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty);


            inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessValue = (inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessQty * _Price);


            if (inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessValue < 0)


            {


                inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessValue = 0.00;


            }


            inventTransUsageQuantitytmp.NWIStatusexcess = GOPNWIStatusexcess::Excess;


        }


    }




    /// <summary>


    /// Find Last usage date for last 36 months


    /// </summary>


    public void setLastUsageDatelast36months()


    {


        


        GOPNWIReferenceCategory nwiReferenceCategory;


        inventTransUsageQuantityIssueViewLoc.clear();


        if (inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty || inventTransUsageQuantitytmp.UsageQtyInlast36months)


        {


            /*


            select firstonly DatePhysical from inventTransUsageQuantityIssueViewLoc


                        order by DatePhysical desc


                where inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold)


                    && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                    && inventTransUsageQuantityIssueViewLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                    && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                    && inventTransUsageQuantityIssueViewLoc.DatePhysical >= last36monthStartDate;


            inventTransUsageQuantitytmp.LastUsageDatelast36months = inventTransUsageQuantityIssueViewLoc.DatePhysical;


            */


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                select firstonly DatePhysical from inventTransUsageQuantityIssueViewLoc


                        order by DatePhysical desc


                    where inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold)


                        && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && inventTransUsageQuantityIssueViewLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= last36monthStartDate;


                inventTransUsageQuantitytmp.LastUsageDatelast36months = inventTransUsageQuantityIssueViewLoc.DatePhysical;


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                select firstonly DatePhysical from inventTransUsageQuantityIssueViewLoc


                        order by DatePhysical desc


                    where inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold)


                        && inventTransUsageQuantityIssueViewLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= last36monthStartDate;


                inventTransUsageQuantitytmp.LastUsageDatelast36months = inventTransUsageQuantityIssueViewLoc.DatePhysical;


            }


            else


            {


                select firstonly DatePhysical from inventTransUsageQuantityIssueViewLoc


                        order by DatePhysical desc


                    where inventTransUsageQuantityIssueViewLoc.itemid == inventTransUsageQuantitytmp.itemId


                        && (inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Deducted || inventTransUsageQuantityIssueViewLoc.StatusIssue == StatusIssue::Sold)


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityIssueViewLoc.DatePhysical >= last36monthStartDate;


                inventTransUsageQuantitytmp.LastUsageDatelast36months = inventTransUsageQuantityIssueViewLoc.DatePhysical;


    


            }




        }


       


    }




    /// <summary>


    /// First And Last Of Purchase and Recivied Date Physical


    /// </summary>


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


    public void setFirstAndLastOfPurchaseandReciviedDatePhysical(ItemId _itemId, Price _Price)


    {


        GOPInventTransUsageQuantityReceiptView inventTransUsageQuantityReceiptViewloc;


        InventLocation inventLocation;


        GOPNWIReferenceCategory nwiReferenceCategory;




        inventTransUsageQuantityReceiptViewloc.clear();


        /*


        select firstonly DatePhysical from inventTransUsageQuantityReceiptViewloc


                    order by DatePhysical asc


            where inventTransUsageQuantityReceiptViewloc.itemid == _itemId


                && inventTransUsageQuantityReceiptViewloc.DatePhysical <= invCloseDate


                && inventTransUsageQuantityReceiptViewloc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                && (inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Purchased || inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Received);


        inventTransUsageQuantitytmp.FirstReceiptDate = inventTransUsageQuantityReceiptViewloc.DatePhysical;




        inventTransUsageQuantityReceiptViewloc.clear();


        select firstonly DatePhysical from inventTransUsageQuantityReceiptViewloc


                    order by DatePhysical desc


            where inventTransUsageQuantityReceiptViewloc.itemid == _itemId


                && inventTransUsageQuantityReceiptViewloc.DatePhysical <= invCloseDate


                && inventTransUsageQuantityReceiptViewloc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                && (inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Purchased || inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Received);






        inventTransUsageQuantitytmp.LastReceiptDate = inventTransUsageQuantityReceiptViewloc.DatePhysical;


        */




        if (contract.parmInventLocationId() == InventAgingViewOnly::View)


        {


            select firstonly DatePhysical from inventTransUsageQuantityReceiptViewloc


                    order by DatePhysical asc


                exists join inventLocation


                    where inventLocation.InventLocationId == inventTransUsageQuantityReceiptViewloc.InventLocationId


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityReceiptViewloc.ReferenceCategory


                        && inventTransUsageQuantityReceiptViewloc.itemid == _itemId


                        && inventTransUsageQuantityReceiptViewloc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityReceiptViewloc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                        && inventTransUsageQuantityReceiptViewloc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && (inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Purchased || inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Received);


            inventTransUsageQuantitytmp.FirstReceiptDate = inventTransUsageQuantityReceiptViewloc.DatePhysical;




            inventTransUsageQuantityReceiptViewloc.clear();


            select firstonly DatePhysical from inventTransUsageQuantityReceiptViewloc


                    order by DatePhysical desc


                exists join inventLocation


                    where inventLocation.InventLocationId == inventTransUsageQuantityReceiptViewloc.InventLocationId


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityReceiptViewloc.ReferenceCategory


                        && inventTransUsageQuantityReceiptViewloc.itemid == _itemId


                        && inventTransUsageQuantityReceiptViewloc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityReceiptViewloc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId


                        && inventTransUsageQuantityReceiptViewloc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && (inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Purchased || inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Received);


            inventTransUsageQuantitytmp.LastReceiptDate = inventTransUsageQuantityReceiptViewloc.DatePhysical;


    


        }


        else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


        {


            select firstonly DatePhysical from inventTransUsageQuantityReceiptViewloc


                    order by DatePhysical asc


                exists join inventLocation


                    where inventLocation.InventLocationId == inventTransUsageQuantityReceiptViewloc.InventLocationId


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityReceiptViewloc.ReferenceCategory


                        &&  inventTransUsageQuantityReceiptViewloc.itemid == _itemId


                        && inventTransUsageQuantityReceiptViewloc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityReceiptViewloc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && (inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Purchased || inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Received);


            inventTransUsageQuantitytmp.FirstReceiptDate = inventTransUsageQuantityReceiptViewloc.DatePhysical;




            inventTransUsageQuantityReceiptViewloc.clear();


            select firstonly DatePhysical from inventTransUsageQuantityReceiptViewloc


                    order by DatePhysical desc


                exists join inventLocation


                    where inventLocation.InventLocationId == inventTransUsageQuantityReceiptViewloc.InventLocationId


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityReceiptViewloc.ReferenceCategory


                        && inventTransUsageQuantityReceiptViewloc.itemid == _itemId


                        && inventTransUsageQuantityReceiptViewloc.DatePhysical <= invCloseDate


                        && inventTransUsageQuantityReceiptViewloc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && (inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Purchased || inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Received);


            inventTransUsageQuantitytmp.LastReceiptDate = inventTransUsageQuantityReceiptViewloc.DatePhysical;


        }


        else


        {


            select firstonly DatePhysical from inventTransUsageQuantityReceiptViewloc


                    order by DatePhysical asc


                exists join inventLocation


                    where inventLocation.InventLocationId == inventTransUsageQuantityReceiptViewloc.InventLocationId


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityReceiptViewloc.ReferenceCategory


                        && inventTransUsageQuantityReceiptViewloc.itemid == _itemId


                        && inventTransUsageQuantityReceiptViewloc.DatePhysical <= invCloseDate


                        && (inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Purchased || inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Received);


            inventTransUsageQuantitytmp.FirstReceiptDate = inventTransUsageQuantityReceiptViewloc.DatePhysical;




            inventTransUsageQuantityReceiptViewloc.clear();


            select firstonly DatePhysical from inventTransUsageQuantityReceiptViewloc


                    order by DatePhysical desc


                exists join inventLocation


                    where inventLocation.InventLocationId == inventTransUsageQuantityReceiptViewloc.InventLocationId


                exists join nwiReferenceCategory


                    where nwiReferenceCategory.ReferenceCategory == inventTransUsageQuantityReceiptViewloc.ReferenceCategory


                        && inventTransUsageQuantityReceiptViewloc.itemid == _itemId


                        && inventTransUsageQuantityReceiptViewloc.DatePhysical <= invCloseDate


                        && (inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Purchased || inventTransUsageQuantityReceiptViewloc.StatusReceipt == StatusReceipt::Received);


            inventTransUsageQuantitytmp.LastReceiptDate = inventTransUsageQuantityReceiptViewloc.DatePhysical;


        }




        if (inventTransUsageQuantitytmp.LastUsageDatelast36months == dateNull())


        {


            inventTransUsageQuantitytmp.MonthOfNoSale = intvNo(invCloseDate,inventTransUsageQuantitytmp.FirstReceiptDate,IntvScale::YearMonth);


        }


        else


        {


            inventTransUsageQuantitytmp.MonthOfNoSale = intvNo(invCloseDate,inventTransUsageQuantitytmp.LastUsageDatelast36months,IntvScale::YearMonth);


        }


        // To use month of No sales to  update NWI status in case of LastUsageDatelast36months is null


        int MonthOfNoSale = inventTransUsageQuantitytmp.MonthOfNoSale;


        if(inventTransUsageQuantitytmp.LastUsageDatelast36months == dateNull()) 


        {


            if ( MonthOfNoSale > 3 && MonthOfNoSale <= 6 


                    && !inventTransUsageQuantitytmp.EarlyWarningQty 


                    && !inventTransUsageQuantitytmp.NWIDeadQty


                    && !inventTransUsageQuantitytmp.NWIDeadQtyPlus)


            {


                inventTransUsageQuantitytmp.EarlyWarningQty = abs(inventTransUsageQuantitytmp.OnHandQty);


                inventTransUsageQuantitytmp.EarlyWarningValue = (inventTransUsageQuantitytmp.EarlyWarningQty * _Price);


                inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::EarlyWarning;


            }


            else if ( MonthOfNoSale > 6 && MonthOfNoSale <= 9 


                    && !inventTransUsageQuantitytmp.EarlyWarningQty


                    && !inventTransUsageQuantitytmp.NWIDeadQty


                    && !inventTransUsageQuantitytmp.NWIDeadQtyPlus)


            {


                inventTransUsageQuantitytmp.NWIDeadQty = abs(inventTransUsageQuantitytmp.OnHandQty);


                inventTransUsageQuantitytmp.NWIDeadValue = (inventTransUsageQuantitytmp.NWIDeadQty * _Price);


                inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::Dead;


            }


            else if (MonthOfNoSale > 9 


                    && !inventTransUsageQuantitytmp.EarlyWarningQty


                    && !inventTransUsageQuantitytmp.NWIDeadQty


                    && !inventTransUsageQuantitytmp.NWIDeadQtyPlus)


            {


                inventTransUsageQuantitytmp.NWIDeadQtyPlus = abs(inventTransUsageQuantitytmp.OnHandQty);


                inventTransUsageQuantitytmp.NWIDeadQtyPlusValue = (inventTransUsageQuantitytmp.NWIDeadQtyPlus * _Price);


                inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::DeadPlus;


            }


        }


    }




    public void setFinancialprovision()


    {


        inventTransUsageQuantitytmp.Financialprovision = (((25 * inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessValue) / 100) + inventTransUsageQuantitytmp.NWIDeadValue + inventTransUsageQuantitytmp.NWIDeadQtyPlusValue);


    }




    public boolean validate(TransDate _date)


    {


        boolean ret = 1;


        if (invCloseDate == dateNull())


        {


            ret = 0;  


        }


        return ret;


    }




    static InventClosing findPrevClosingDate(


                                             TransDate              _currentClosingDate,


                                             InventTransCurrency_RU _inventTransCurrency = InventTransCurrency_RU::PrimaryCur)


    {


        InventClosing   inventClosing;




        if (_currentClosingDate)


        {


            select reverse firstonly inventClosing


                index TypeDateIdx


                where inventClosing.Active                 == NoYes::Yes                    &&


                      inventClosing.AdjustmentType         == InventAdjustmentType::Closing &&


                      inventClosing.Cancellation           == NoYes::No                     &&


                      inventClosing.InventCostStatus       == InventCostStatus::Ended       &&


                      inventClosing.InventTransCurrency_RU == _inventTransCurrency          &&


                      inventClosing.TransDate              <= _currentClosingDate;


        }




        return inventClosing;


    }




    public void populatePurchReportData()


    {


        InventTable inventTable;


        InventLocation InventLocationLoc;


        InventAgingTmp inventAgingTmp;


        InventTableModule inventTableModule;


        InventItemGroupItem inventItemGroupItem;


        EcoResProductTranslation ecoResProductTranslation;


        NoYes GOPTransactionId = InventParameters::find().GOPTransactionId;


        




        inventTable.clear();


        inventAgingTmp.clear();


        inventTableModule.clear();


        inventItemGroupItem.clear();


        ecoResProductTranslation.clear();


        inventTransUsageQuantitytmp.clear();


        


        if (contract.parmInventLocationId() == InventAgingViewOnly::View)


        {


        /*


        select  * from inventAgingTmp


            where inventAgingTmp.CreatedTransactionId == InventParameters::find().GOPTransactionId


                &&  inventAgingTmp.ItemId == inventTransUsageQuantityReceiptView.ItemId


                && inventAgingTmp.InventSiteId == InventDim.InventSiteId//


                && inventAgingTmp.InventLocationId == InventDim.InventLocationId;//


        if (inventAgingTmp.RecId && inventAgingTmp.QtyOnHand)


        */


            select sum(QtyOnHand), maxof(UnitPrice) from inventAgingTmp


                where inventAgingTmp.CreatedTransactionId == GOPTransactionId


                    && inventAgingTmp.ItemId == inventTransUsageQuantityReceiptView.ItemId


                    && inventAgingTmp.InventSiteId == InventDim.InventSiteId


                    && inventAgingTmp.InventLocationId == InventDim.InventLocationId;


        }


        else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


        {


            select sum(QtyOnHand), maxof(UnitPrice) from inventAgingTmp


                    group by ItemId, InventSiteId


                join InventLocationLoc


                    where InventLocationLoc.InventLocationId == inventAgingTmp.InventLocationId


                        && InventLocationLoc.inventSiteId == inventAgingTmp.InventSiteId


                        && InventLocationLoc.GOPExcludeNWIWH == NoYes::No


                        && inventAgingTmp.CreatedTransactionId == GOPTransactionId


                        &&  inventAgingTmp.ItemId == inventTransUsageQuantityReceiptView.ItemId


                        && inventAgingTmp.InventSiteId == InventDim.InventSiteId;


        }


        else


        {


            select sum(QtyOnHand), maxof(UnitPrice) from inventAgingTmp


                    group by ItemId


                join InventLocationLoc


                    where InventLocationLoc.InventLocationId == inventAgingTmp.InventLocationId


                        && InventLocationLoc.inventSiteId == inventAgingTmp.InventSiteId


                        && InventLocationLoc.GOPExcludeNWIWH == NoYes::No


                        && inventAgingTmp.CreatedTransactionId == GOPTransactionId


                        && inventAgingTmp.ItemId == inventTransUsageQuantityReceiptView.ItemId;




        }


        //if (inventAgingTmp.RecId && inventAgingTmp.QtyOnHand)


        if (inventAgingTmp.QtyOnHand)


        {




            select firstonly GOPBusinessUnit, GOPDivisionCode, GOPCommodityCode, GOPMaterialClassCategory, GOPGlobalSalesCode,DataAreaId from inventTable


                where inventTable.ItemId == inventTransUsageQuantityReceiptView.ItemId;




            select firstonly ItemGroupId from inventItemGroupItem


                where inventItemGroupItem.ItemId == inventTable.ItemId


                && InventItemGroupItem.ItemDataAreaId == inventTable.DataAreaId;




            LanguageId LanguageId = this.defaultProductLanguageId();


            select firstonly name from ecoResProductTranslation


                where ecoResProductTranslation.Product == inventTable.Product


                    && ecoResProductTranslation.LanguageId == LanguageId;




            select firstonly UnitId, Price from inventTableModule


                where InventTableModule.ItemId == inventTable.ItemId


                    && (inventTableModule.ModuleType == ModuleInventPurchSales::Sales || inventTableModule.ModuleType == ModuleInventPurchSales::Invent);




            inventTransUsageQuantitytmp.InventoryCloseDate = invCloseDate;


            inventTransUsageQuantitytmp.InvTRansOriDataAreaId =  inventTransUsageQuantityReceiptView.dataAreaid;


            inventTransUsageQuantitytmp.GOPDivisionCode = inventTable.GOPDivisionCode;


            inventTransUsageQuantitytmp.GOPCommodityCode = inventTable.GOPCommodityCode;


            inventTransUsageQuantitytmp.ItemId = inventTransUsageQuantityReceiptView.ItemId;


            inventTransUsageQuantitytmp.name = ecoResProductTranslation.name;


            inventTransUsageQuantitytmp.UnitId = InventTableModule.UnitId;


            inventTransUsageQuantitytmp.GOPMaterialClassCategory = GOPMaterialClassCategory::findByRecId(inventTable.GOPInvUsageMaterialClassCategory).MaterialClassCategory;


            inventTransUsageQuantitytmp.GOPGlobalSalesCode = inventTable.GOPGlobalSalesCode;


            /*


            inventTransUsageQuantitytmp.InventLocationId = InventDim.InventLocationId;//


            inventTransUsageQuantitytmp.InventSiteId = InventDim.InventSiteId;//


            */


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                inventTransUsageQuantitytmp.InventLocationId = InventDim.InventLocationId;


                inventTransUsageQuantitytmp.InventSiteId = InventDim.InventSiteId;


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                inventTransUsageQuantitytmp.InventSiteId = InventDim.InventSiteId;


            }


            else


            {


                inventTransUsageQuantitytmp.InventLocationId = "";


                inventTransUsageQuantitytmp.InventSiteId =  "";


            }


            inventTransUsageQuantitytmp.MaterialClassCategory = inventTable.GOPMaterialClassCategory;


            inventTransUsageQuantitytmp.AvailPhysical = inventAgingTmp.QtyOnHand;


            inventTransUsageQuantitytmp.OnHandQty = inventAgingTmp.QtyOnHand;


            inventTransUsageQuantitytmp.InvUsageQty = abs(inventTransUsageQuantityReceiptView.Qty);


            inventTransUsageQuantitytmp.ItemGroupId = inventItemGroupItem.ItemGroupId;


            inventTransUsageQuantitytmp.OnHandValue = (inventTransUsageQuantitytmp.OnHandQty * inventAgingTmp.UnitPrice);


        


            inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty = 0.00;


            inventTransUsageQuantitytmp.MonthsofStockQty = 0.00;


            inventTransUsageQuantitytmp.IsHardGoodSparePartIndicator = inventTable.itemGroup().IsHardGoodSparePartIndicator;


            this.setMonthlyAverageUsageForSold();


            this.setLastUsageDatelast36months();


            this.setPurchNWIEarlyWarningAndDeadQty( inventAgingTmp.UnitPrice);


            


            if (inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty != 0)


            {


                inventTransUsageQuantitytmp.MonthsofStockQty = (inventTransUsageQuantitytmp.OnHandQty / inventTransUsageQuantitytmp.MonthlyAverageUsageForSoldQty);


            }


            this.setNWISlow(inventAgingTmp.UnitPrice);


            this.setNWIExcess(inventAgingTmp.UnitPrice);


           


            inventTransUsageQuantitytmp.NWITotal = (inventTransUsageQuantitytmp.NWI7To12MonthsSlowValue


                                                            + inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessValue


                                                            + inventTransUsageQuantitytmp.NWIDeadValue


                                                            + inventTransUsageQuantitytmp.NWIDeadQtyPlusValue);


        


            inventTransUsageQuantitytmp.NWIUnitsTotal = (inventTransUsageQuantitytmp.NWIDeadQty


                                                                + inventTransUsageQuantitytmp.NWIGreaterThen12MonthExcessQty


                                                                + inventTransUsageQuantitytmp.NWI7T012MonthsSlowQty


                                                                + inventTransUsageQuantitytmp.NWIDeadQtyPlus);


            ReqItemTable reqItemTable;


            select firstonly reqItemTable


                index hint ItemIdx


                where reqItemTable.ItemId == inventTransUsageQuantitytmp.ItemId;


            if(reqItemTable)


            {


                inventTransUsageQuantitytmp.InStock = GOPIsStock::Stock;


            }


            else


            {


                inventTransUsageQuantitytmp.InStock = GOPIsStock::NonStock;


            }


            inventTransUsageQuantitytmp.CompanyLogo = FormLetter::companyLogo();


            inventTransUsageQuantitytmp.curr = Ledger::accountingCurrency(CompanyInfo::current());


            this.setFirstAndLastOfPurchaseandReciviedDatePhysical(inventTransUsageQuantitytmp.ItemId, inventAgingTmp.UnitPrice);


            this.setFinancialprovision();


            inventTransUsageQuantitytmp.Doinsert();


        }


    }




    public void  setPurchNWIEarlyWarningAndDeadQty( Price _Price)


    {


        boolean qtyAvilable = 0;   


        


        qtyAvilable = this.getPurchSalesHelerForDeatStatus(invCloseDate, invFrom3rdMonth,StatusReceipt::Purchased,StatusReceipt::Received,StatusIssue::None,StatusIssue::None,InventTransType::Sales);


        if (qtyAvilable == 0)


        {


            qtyAvilable = this.getPurchSalesHelerForDeatStatus(invFrom3rdMonth, invFrom6thMonth,StatusReceipt::Purchased,StatusReceipt::Received,StatusIssue::None,StatusIssue::None,InventTransType::Sales);


            if (qtyAvilable == 1)


            {


                inventTransUsageQuantitytmp.EarlyWarningQty = abs(inventTransUsageQuantitytmp.OnHandQty);


                inventTransUsageQuantitytmp.EarlyWarningValue = (inventTransUsageQuantitytmp.EarlyWarningQty * _Price);


                inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::EarlyWarning;


            }


            else


            {


                qtyAvilable = this.getPurchSalesHelerForDeatStatus(invFrom6thMonth, invFrom9thMonth,StatusReceipt::Purchased,StatusReceipt::Received,StatusIssue::None,StatusIssue::None,InventTransType::Sales);                


                if (qtyAvilable == 1)


                {


                    inventTransUsageQuantitytmp.NWIDeadQty = abs(inventTransUsageQuantitytmp.OnHandQty);


                    inventTransUsageQuantitytmp.NWIDeadValue = (inventTransUsageQuantitytmp.NWIDeadQty * _Price);


                    inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::Dead;


                }


                else


                {


                    qtyAvilable = this.getPurchSalesHelerForDeatStatus(invFrom9thMonth, dateNull(),StatusReceipt::Purchased,StatusReceipt::Received,StatusIssue::None,StatusIssue::None,InventTransType::Sales);


                    if (qtyAvilable == 1)


                    {


                        inventTransUsageQuantitytmp.NWIDeadQtyPlus = abs(inventTransUsageQuantitytmp.OnHandQty);


                        inventTransUsageQuantitytmp.NWIDeadQtyPlusValue = (inventTransUsageQuantitytmp.NWIDeadQtyPlus * _Price);


                        inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::DeadPlus;


                    }


                    else


                    {


                        inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::None;


                    }


                }


            }


        }


        else


        {


            inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::None;


        }


    }




    public boolean getPurchSalesHelerForDeatStatus(TransDate _toMonthRange, 


                                                    TransDate _fromMonthRange,


                                                    StatusReceipt _PurchasedStatusReceipt, 


                                                    StatusReceipt _ReceivedStatusReceipt, 


                                                    StatusIssue _SoldStatusIssue,


                                                    StatusIssue _DeductedStatusIssue,


                                                    InventTransType _InventTransType)


    {


        InventDim InventDimLoc;


        InventTransOrigin InventTransOriginLoc;


        InventTrans inventTransUsageQuantityReceiptViewLoc;


        InventLocation inventLocation;


        GOPNWIReferenceCategory nwiReferenceCategory;


        if (_fromMonthRange != dateNull())


        {


            /*


            Select InventTransOriginLoc


                join ItemId, sum(QTY) from inventTransUsageQuantityReceiptView


                        group by ItemId


                    where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOriginLoc.RecId


                join InventLocationId, InventSiteId from InventDimLoc


                        group by InventLocationId, InventSiteId


                    where InventDimLoc.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                        && inventTransUsageQuantityReceiptView.itemid == inventTransUsageQuantitytmp.itemId


                        && InventTransOriginLoc.REFERENCECATEGORY != _InventTransType


                        && (inventTransUsageQuantityReceiptView.StatusReceipt == _PurchasedStatusReceipt || inventTransUsageQuantityReceiptView.StatusReceipt == _ReceivedStatusReceipt)


                        && (inventTransUsageQuantityReceiptView.StatusIssue == _SoldStatusIssue || inventTransUsageQuantityReceiptView.StatusIssue == _DeductedStatusIssue)


                        && inventTransUsageQuantityReceiptView.DatePhysical <= _toMonthRange


                        && inventTransUsageQuantityReceiptView.DatePhysical >= _fromMonthRange


                        && InventDimLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && InventDimLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId;


            if (inventTransUsageQuantityReceiptView.Qty)


            {


                return 1;


            }


            */


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                Select InventTransOriginLoc


                    join ItemId, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOriginLoc.RecId


                    join InventLocationId, InventSiteId from InventDimLoc


                            group by InventLocationId, InventSiteId


                        where InventDimLoc.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDimLoc.InventLocationId


                    exists join nwiReferenceCategory


                        where nwiReferenceCategory.ReferenceCategory == InventTransOriginLoc.ReferenceCategory


                            && inventTransUsageQuantityReceiptView.itemid == inventTransUsageQuantitytmp.itemId


                            && InventTransOriginLoc.REFERENCECATEGORY != _InventTransType


                            && (inventTransUsageQuantityReceiptView.StatusReceipt == _PurchasedStatusReceipt || inventTransUsageQuantityReceiptView.StatusReceipt == _ReceivedStatusReceipt)


                            && (inventTransUsageQuantityReceiptView.StatusIssue == _SoldStatusIssue || inventTransUsageQuantityReceiptView.StatusIssue == _DeductedStatusIssue)


                            && inventTransUsageQuantityReceiptView.DatePhysical <= _toMonthRange


                            && inventTransUsageQuantityReceiptView.DatePhysical >= _fromMonthRange


                            && InventDimLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                            && InventDimLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId;


                if (inventTransUsageQuantityReceiptView.Qty)


                {


                    return 1;


                }


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                Select InventTransOriginLoc


                    join ItemId, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOriginLoc.RecId


                    join InventLocationId, InventSiteId from InventDimLoc


                            group by InventLocationId, InventSiteId


                        where InventDimLoc.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDimLoc.InventLocationId


                    exists join nwiReferenceCategory


                        where nwiReferenceCategory.ReferenceCategory == InventTransOriginLoc.ReferenceCategory


                            && inventTransUsageQuantityReceiptView.itemid == inventTransUsageQuantitytmp.itemId


                            && InventTransOriginLoc.REFERENCECATEGORY != _InventTransType


                            && (inventTransUsageQuantityReceiptView.StatusReceipt == _PurchasedStatusReceipt || inventTransUsageQuantityReceiptView.StatusReceipt == _ReceivedStatusReceipt)


                            && (inventTransUsageQuantityReceiptView.StatusIssue == _SoldStatusIssue || inventTransUsageQuantityReceiptView.StatusIssue == _DeductedStatusIssue)


                            && inventTransUsageQuantityReceiptView.DatePhysical <= _toMonthRange


                            && inventTransUsageQuantityReceiptView.DatePhysical >= _fromMonthRange


                            && InventDimLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId;


                if (inventTransUsageQuantityReceiptView.Qty)


                {


                    return 1;


                }


            }


            else


            {


                Select InventTransOriginLoc


                    join ItemId, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOriginLoc.RecId


                    join InventLocationId, InventSiteId from InventDimLoc


                            group by InventLocationId, InventSiteId


                        where InventDimLoc.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDimLoc.InventLocationId


                    exists join nwiReferenceCategory


                        where nwiReferenceCategory.ReferenceCategory == InventTransOriginLoc.ReferenceCategory


                            && inventTransUsageQuantityReceiptView.itemid == inventTransUsageQuantitytmp.itemId


                            && InventTransOriginLoc.REFERENCECATEGORY != _InventTransType


                            && (inventTransUsageQuantityReceiptView.StatusReceipt == _PurchasedStatusReceipt || inventTransUsageQuantityReceiptView.StatusReceipt == _ReceivedStatusReceipt)


                            && (inventTransUsageQuantityReceiptView.StatusIssue == _SoldStatusIssue || inventTransUsageQuantityReceiptView.StatusIssue == _DeductedStatusIssue)


                            && inventTransUsageQuantityReceiptView.DatePhysical <= _toMonthRange


                            && inventTransUsageQuantityReceiptView.DatePhysical >= _fromMonthRange


                            && InventDimLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId;


                if (inventTransUsageQuantityReceiptView.Qty)


                {


                    return 1;


                }


            }


        }


        else


        {


            /*


            Select InventTransOriginLoc


                join ItemId, sum(QTY) from inventTransUsageQuantityReceiptView


                        group by ItemId


                    where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOriginLoc.RecId


                join InventLocationId, InventSiteId from InventDimLoc


                        group by InventLocationId, InventSiteId


                    where InventDimLoc.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                        && inventTransUsageQuantityReceiptView.itemid == inventTransUsageQuantitytmp.itemId


                        && InventTransOriginLoc.REFERENCECATEGORY != _InventTransType


                        && (inventTransUsageQuantityReceiptView.StatusReceipt == _PurchasedStatusReceipt || inventTransUsageQuantityReceiptView.StatusReceipt == _ReceivedStatusReceipt)


                        && (inventTransUsageQuantityReceiptView.StatusIssue == _SoldStatusIssue || inventTransUsageQuantityReceiptView.StatusIssue == _DeductedStatusIssue)


                        && inventTransUsageQuantityReceiptView.DatePhysical <= _toMonthRange


                        && InventDimLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                        && InventDimLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId;


            if (inventTransUsageQuantityReceiptView.Qty)


            {


                return 1;


            }


            */


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                Select InventTransOriginLoc


                    join ItemId, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOriginLoc.RecId


                    join InventLocationId, InventSiteId from InventDimLoc


                            group by InventLocationId, InventSiteId


                        where InventDimLoc.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDimLoc.InventLocationId


                    exists join nwiReferenceCategory


                        where nwiReferenceCategory.ReferenceCategory == InventTransOriginLoc.ReferenceCategory


                            && inventTransUsageQuantityReceiptView.itemid == inventTransUsageQuantitytmp.itemId


                            && InventTransOriginLoc.REFERENCECATEGORY != _InventTransType


                            && (inventTransUsageQuantityReceiptView.StatusReceipt == _PurchasedStatusReceipt || inventTransUsageQuantityReceiptView.StatusReceipt == _ReceivedStatusReceipt)


                            && (inventTransUsageQuantityReceiptView.StatusIssue == _SoldStatusIssue || inventTransUsageQuantityReceiptView.StatusIssue == _DeductedStatusIssue)


                            && inventTransUsageQuantityReceiptView.DatePhysical <= _toMonthRange


                            && InventDimLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId


                            && InventDimLoc.InventLocationId == inventTransUsageQuantitytmp.InventLocationId;


                if (inventTransUsageQuantityReceiptView.Qty)


                {


                    return 1;


                }


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                Select InventTransOriginLoc


                    join ItemId, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOriginLoc.RecId


                    join InventLocationId, InventSiteId from InventDimLoc


                            group by InventLocationId, InventSiteId


                        where InventDimLoc.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDimLoc.InventLocationId


                    exists join nwiReferenceCategory


                        where nwiReferenceCategory.ReferenceCategory == InventTransOriginLoc.ReferenceCategory


                            && inventTransUsageQuantityReceiptView.itemid == inventTransUsageQuantitytmp.itemId


                            && InventTransOriginLoc.REFERENCECATEGORY != _InventTransType


                            && (inventTransUsageQuantityReceiptView.StatusReceipt == _PurchasedStatusReceipt || inventTransUsageQuantityReceiptView.StatusReceipt == _ReceivedStatusReceipt)


                            && (inventTransUsageQuantityReceiptView.StatusIssue == _SoldStatusIssue || inventTransUsageQuantityReceiptView.StatusIssue == _DeductedStatusIssue)


                            && inventTransUsageQuantityReceiptView.DatePhysical <= _toMonthRange


                            && InventDimLoc.InventSiteId == inventTransUsageQuantitytmp.InventSiteId;


                if (inventTransUsageQuantityReceiptView.Qty)


                {


                    return 1;


                }


            }


            else


            {


                Select InventTransOriginLoc


                    join ItemId, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOriginLoc.RecId


                    join InventLocationId, InventSiteId from InventDimLoc


                            group by InventLocationId, InventSiteId


                        where InventDimLoc.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDimLoc.InventLocationId


                    exists join nwiReferenceCategory


                        where nwiReferenceCategory.ReferenceCategory == InventTransOriginLoc.ReferenceCategory


                            && inventTransUsageQuantityReceiptView.itemid == inventTransUsageQuantitytmp.itemId


                            && InventTransOriginLoc.REFERENCECATEGORY != _InventTransType


                            && (inventTransUsageQuantityReceiptView.StatusReceipt == _PurchasedStatusReceipt || inventTransUsageQuantityReceiptView.StatusReceipt == _ReceivedStatusReceipt)


                            && (inventTransUsageQuantityReceiptView.StatusIssue == _SoldStatusIssue || inventTransUsageQuantityReceiptView.StatusIssue == _DeductedStatusIssue)


                            && inventTransUsageQuantityReceiptView.DatePhysical <= _toMonthRange;


                if (inventTransUsageQuantityReceiptView.Qty)


                {


                    return 1;


                }


            }




        }


        return 0;


    }




    public void setNWIEarlyWarningAndDeadQty( Price _Price)


    {


        boolean qtyAvilable = 0;


        


        qtyAvilable = this.getPurchSalesHelerForDeatStatus(invCloseDate, invFrom3rdMonth,StatusReceipt::None,StatusReceipt::None,StatusIssue::Sold,StatusIssue::Deducted,InventTransType::InventLossProfit);


        if (qtyAvilable == 0)


        {


            qtyAvilable = this.getPurchSalesHelerForDeatStatus(invFrom3rdMonth, invFrom6thMonth,StatusReceipt::None,StatusReceipt::None,StatusIssue::Sold,StatusIssue::Deducted,InventTransType::InventLossProfit);


            if (qtyAvilable == 1)


            {


                inventTransUsageQuantitytmp.EarlyWarningQty = abs(inventTransUsageQuantitytmp.OnHandQty);


                inventTransUsageQuantitytmp.EarlyWarningValue = (inventTransUsageQuantitytmp.EarlyWarningQty * _Price);


                inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::EarlyWarning;


            }


            else


            {


                qtyAvilable = this.getPurchSalesHelerForDeatStatus(invFrom6thMonth, invFrom9thMonth,StatusReceipt::None,StatusReceipt::None,StatusIssue::Sold,StatusIssue::Deducted,InventTransType::InventLossProfit);


                if (qtyAvilable == 1)


                {


                    inventTransUsageQuantitytmp.NWIDeadQty = abs(inventTransUsageQuantitytmp.OnHandQty);


                    inventTransUsageQuantitytmp.NWIDeadValue = (inventTransUsageQuantitytmp.NWIDeadQty * _Price);


                    inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::Dead;


                }


                else


                {


                    qtyAvilable = this.getPurchSalesHelerForDeatStatus(invFrom9thMonth, dateNull(),StatusReceipt::None,StatusReceipt::None,StatusIssue::Sold,StatusIssue::Deducted,InventTransType::InventLossProfit);


                    if (qtyAvilable == 1)


                    {


                        inventTransUsageQuantitytmp.NWIDeadQtyPlus = abs(inventTransUsageQuantitytmp.OnHandQty);


                        inventTransUsageQuantitytmp.NWIDeadQtyPlusValue = (inventTransUsageQuantitytmp.NWIDeadQtyPlus * _Price);


                        inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::DeadPlus;


                    }


                    else


                    {


                        inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::None;


                    }


                }


            }


        }


        else


        {


            inventTransUsageQuantitytmp.NWIStatusDead = GOPNWIStatusDead::None;


        }


    }




    public void calculateSalesDataonSiteOrWH()


    {


        GOPNWIReferenceCategory nwiReferenceCategory;


        InventLocation InventLocationLoc;


                


        if (!contract.parmItemId())


        {


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                while select  maxof(dataAreaid), maxof(ItemId), maxof(InventLocationId), maxof(inventSiteId), sum(QTY) from inventTransUsageQuantityIssueView


                    group by dataAreaid, ItemId, InventLocationId, inventSiteId


                {


                    this.populateSalesReportData();


                }


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                while select  maxof(dataAreaid), maxof(ItemId), maxof(InventLocationId), maxof(inventSiteId),  sum(QTY) from inventTransUsageQuantityIssueView


                    group by dataAreaid, ItemId, inventSiteId


                {


                    this.populateSalesReportData();


                }


            }


            else


            {


                while select  maxof(dataAreaid), maxof(ItemId), maxof(InventLocationId), maxof(inventSiteId), sum(QTY) from inventTransUsageQuantityIssueView


                    group by dataAreaid, ItemId


                {


                    this.populateSalesReportData();


                }


            }


        }


        else


        {


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                while select  maxof(dataAreaid), maxof(ItemId), maxof(InventLocationId), maxof(inventSiteId), sum(QTY) from inventTransUsageQuantityIssueView


                        group by dataAreaid, ItemId, InventLocationId, inventSiteId


                    where inventTransUsageQuantityIssueView.ItemId == contract.parmItemId()


                {


                    this.populateSalesReportData();


                }


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                while select  maxof(dataAreaid), maxof(ItemId), maxof(InventLocationId), maxof(inventSiteId),  sum(QTY) from inventTransUsageQuantityIssueView


                        group by dataAreaid, ItemId, inventSiteId


                    where inventTransUsageQuantityIssueView.ItemId == contract.parmItemId()


                {


                    this.populateSalesReportData();


                }


            }


            else


            {


                //InventLocation InventLocationLoc;


                while select  maxof(dataAreaid), maxof(ItemId), maxof(InventLocationId), maxof(inventSiteId), sum(QTY) from inventTransUsageQuantityIssueView


                        group by dataAreaid, ItemId


                    where inventTransUsageQuantityIssueView.ItemId == contract.parmItemId()


                {


                    this.populateSalesReportData();


                }


            }


        }


        


        inventTransUsageQuantityIssueView.clear();


    }




    public void calculatePurchaseDataonSiteOrWH()// re - wite the query using view and change the buffer.


    {


        InventLocation inventLocation;


        GOPNWIReferenceCategory nwiReferenceCategory;


        if (!contract.parmItemId())


        {


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                while Select  InventTransOrigin


                    join ItemId, DatePhysical, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOrigin.RecId


                    join InventLocationId, InventSiteId from InventDim


                            group by InventLocationId, InventSiteId


                        where InventDim.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDim.InventLocationId


                            && inventLocation.GOPExcludeNWIWH == NoYes::No


                            && InventTransOrigin.REFERENCECATEGORY != InventTransType::Sales


                            && inventTransUsageQuantityReceiptView.statusReceipt != statusReceipt::None


                            && inventTransUsageQuantityReceiptView.StatusIssue == StatusIssue::None 


                {


                    inventTransUsageQuantityIssueView.clear();


                    select  inventTransUsageQuantityIssueView


                        where inventTransUsageQuantityIssueView.ItemId == inventTransUsageQuantityReceiptView.ItemId


                            && inventTransUsageQuantityIssueView.InventLocationId == InventDim.InventLocationId


                            && inventTransUsageQuantityIssueView.inventSiteId == InventDim.inventSiteId;


                    if (!inventTransUsageQuantityIssueView)


                    {


                        this.populatePurchReportData();


                    }


                }


            


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                while Select  InventTransOrigin


                join ItemId, DatePhysical, sum(QTY) from inventTransUsageQuantityReceiptView


                        group by ItemId


                    where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOrigin.RecId


                join InventLocationId, InventSiteId from InventDim


                        group by InventSiteId


                    where InventDim.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                exists join inventLocation


                    where inventLocation.InventLocationId == InventDim.InventLocationId


                        && inventLocation.GOPExcludeNWIWH == NoYes::No


                        && InventTransOrigin.REFERENCECATEGORY != InventTransType::Sales


                        && inventTransUsageQuantityReceiptView.statusReceipt != statusReceipt::None


                        && inventTransUsageQuantityReceiptView.StatusIssue == StatusIssue::None


                {


                    inventTransUsageQuantityIssueView.clear();


                    select  inventTransUsageQuantityIssueView


                        where inventTransUsageQuantityIssueView.ItemId == inventTransUsageQuantityReceiptView.ItemId


                            && inventTransUsageQuantityIssueView.inventSiteId == InventDim.inventSiteId;


                    if (!inventTransUsageQuantityIssueView)


                    {


                        this.populatePurchReportData();


                    }


                }


            


            }


            else


            {


                while Select  InventTransOrigin


                    join ItemId, DatePhysical, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOrigin.RecId


                    join InventLocationId, InventSiteId from InventDim


                        where InventDim.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDim.InventLocationId


                            && inventLocation.GOPExcludeNWIWH == NoYes::No


                            && InventTransOrigin.REFERENCECATEGORY != InventTransType::Sales


                            && inventTransUsageQuantityReceiptView.statusReceipt != statusReceipt::None


                            && inventTransUsageQuantityReceiptView.StatusIssue == StatusIssue::None


                {


                    inventTransUsageQuantityIssueView.clear();


                    select  inventTransUsageQuantityIssueView


                        where inventTransUsageQuantityIssueView.ItemId == inventTransUsageQuantityReceiptView.ItemId;


                    if (!inventTransUsageQuantityIssueView)


                    {


                        this.populatePurchReportData();


                    }


                }


                


            }


        }


        else


        {


            if (contract.parmInventLocationId() == InventAgingViewOnly::View)


            {


                while Select  InventTransOrigin


                    join ItemId, DatePhysical, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOrigin.RecId


                    join InventLocationId, InventSiteId from InventDim


                            group by InventLocationId, InventSiteId


                        where InventDim.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDim.InventLocationId


                            && inventLocation.GOPExcludeNWIWH == NoYes::No


                            && InventTransOrigin.REFERENCECATEGORY != InventTransType::Sales


                            && inventTransUsageQuantityReceiptView.statusReceipt != statusReceipt::None


                            && inventTransUsageQuantityReceiptView.StatusIssue == StatusIssue::None


                            && inventTransUsageQuantityReceiptView.ItemId == contract.parmItemId()


                {


                    inventTransUsageQuantityIssueView.clear();


                    select  inventTransUsageQuantityIssueView


                    where inventTransUsageQuantityIssueView.ItemId == inventTransUsageQuantityReceiptView.ItemId


                        && inventTransUsageQuantityIssueView.InventLocationId == InventDim.InventLocationId


                        && inventTransUsageQuantityIssueView.inventSiteId == InventDim.inventSiteId;


                    if (!inventTransUsageQuantityIssueView)


                    {


                        this.populatePurchReportData();


                    }


                }


            


            }


            else if (contract.parmInventSiteId() == InventAgingViewOnly::View)


            {


                while Select  InventTransOrigin


                    join ItemId, DatePhysical, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOrigin.RecId


                    join InventLocationId, InventSiteId from InventDim


                            group by InventSiteId


                        where InventDim.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDim.InventLocationId


                            && inventLocation.GOPExcludeNWIWH == NoYes::No


                            && InventTransOrigin.REFERENCECATEGORY != InventTransType::Sales


                            && inventTransUsageQuantityReceiptView.statusReceipt != statusReceipt::None


                            && inventTransUsageQuantityReceiptView.StatusIssue == StatusIssue::None


                            && inventTransUsageQuantityReceiptView.ItemId == contract.parmItemId()


                {


                    inventTransUsageQuantityIssueView.clear();


                    select  inventTransUsageQuantityIssueView


                        where inventTransUsageQuantityIssueView.ItemId == inventTransUsageQuantityReceiptView.ItemId


                            && inventTransUsageQuantityIssueView.inventSiteId == InventDim.inventSiteId;


                    if (!inventTransUsageQuantityIssueView)


                    {


                        this.populatePurchReportData();


                    }


                }


            


            }


            else


            {


                while Select  InventTransOrigin


                    join ItemId, DatePhysical, sum(QTY) from inventTransUsageQuantityReceiptView


                            group by ItemId


                        where inventTransUsageQuantityReceiptView.InventTransOrigin == InventTransOrigin.RecId


                    join InventLocationId, InventSiteId from InventDim


                        where InventDim.inventDimId == inventTransUsageQuantityReceiptView.inventDimId


                    exists join inventLocation


                        where inventLocation.InventLocationId == InventDim.InventLocationId


                            && inventLocation.GOPExcludeNWIWH == NoYes::No


                            && InventTransOrigin.REFERENCECATEGORY != InventTransType::Sales


                            && inventTransUsageQuantityReceiptView.statusReceipt != statusReceipt::None


                            && inventTransUsageQuantityReceiptView.StatusIssue == StatusIssue::None


                            && inventTransUsageQuantityReceiptView.ItemId == contract.parmItemId()


                {


                    inventTransUsageQuantityIssueView.clear();


                    select  inventTransUsageQuantityIssueView


                        where inventTransUsageQuantityIssueView.ItemId == inventTransUsageQuantityReceiptView.ItemId;


                    if (!inventTransUsageQuantityIssueView)


                    {


                        this.populatePurchReportData();


                    }


                }


            }


        }


    }




}




[DataContractAttribute,


SysOperationContractProcessingAttribute(classstr(GOPInventTransUsageQuantityUIBuilder))]


/// <summary>


///     The <c>GOPInventTransUsageQuantityReportContract</c> class is the data contract for the <c>GOPInventTransUsageQuantityReportContract</c> report.


/// </summary>


class GOPInventTransUsageQuantityReportContract implements SysOperationValidatable


{


    ItemId      itemId;


    DataAreaId  dataAreaId;


    ToDate      ToDate;


    InventAgingViewOnly inventSiteId;


    InventAgingViewOnly inventLocationId;




    [DataMemberAttribute(identifierStr(ItemId)),


        SysOperationLabelAttribute ("@SYS12836"),


        //SysOperationHelpTextAttribute("@GOP:FromDate"),


        SysOperationDisplayOrderAttribute("2")]


    public ItemId parmItemId(ItemId _itemId = itemId)


    {


        itemId = _itemId;


        return itemId;


    }




    [DataMemberAttribute(identifierStr(ToDate)),


        SysOperationLabelAttribute ("@GOP:ToDate"),


        SysOperationHelpTextAttribute("@GOP:ToDate"),


        SysOperationDisplayOrderAttribute("1")]


    public TransDate parmToDate(TransDate _toDate = ToDate)


    {


        todate = _toDate;


        return ToDate;


    }




    [DataMemberAttribute(identifierStr(DataAreaId)),


        SysOperationLabelAttribute("Legal entity"),


        SysOperationDisplayOrderAttribute("3")]


    public dataAreaId parmDataAreaId(DataAreaId _dataAreaId = dataAreaId)


    {


        dataAreaId = _dataAreaId;


        return dataAreaId;


    }




    /// <summary>


    /// This method is for the parameters validation


    /// </summary>


    /// <returns>


    /// true if the from date and todate range exists bellow conditions; otherwise, false.


    /// </returns>


    public boolean validate()


    {


        boolean isValid = true;




        if ( toDate > today())


        {


            isValid = checkFailed("To date cannot be greater the today's date");


        }


        if (inventLocationId == InventAgingViewOnly::View && inventSiteId == InventAgingViewOnly::No)


        {


            isValid = checkFailed("Please set the Site to View");


        }




        return isValid;


    }




    [DataMemberAttribute(identifierStr(InventAgingViewOnlyWH)),


        SysOperationLabelAttribute("@SYS6437"),


        SysOperationDisplayOrderAttribute("5")]


    public InventAgingViewOnly parmInventLocationId(InventAgingViewOnly _inventLocationId = inventLocationId)


    {


        inventLocationId = _inventLocationId;


        return inventLocationId;


    }




    [DataMemberAttribute(identifierStr(InventAgingViewOnlySite)),


        SysOperationLabelAttribute("@SYS103211"),


        SysOperationDisplayOrderAttribute("4")]


    public InventAgingViewOnly parmInventSiteId(InventAgingViewOnly _inventSiteId = inventSiteId)


    {


        inventSiteId = _inventSiteId;


        return inventSiteId;


    }




}




internal final class GOPInventTransUsageQuantityUIBuilder extends SysOperationAutomaticUIBuilder


{


    DialogField     dialogFieldataAreaId;


    GOPInventTransUsageQuantityReportContract inventTransUsageQuantityReportContract;




    public boolean allowModifyDateModified(FormCheckBoxControl _checkBoxControl)


    {


        ;


        // set enabled or disabled based on checkbox


        dialogFieldataAreaId.enabled(any2enum(0));


        // or alternatively


        // dialogFieldTransDate.enabled(_checkBoxControl.checked());


   


        return true;


    }




    public void postBuild()


    {


        ;


        super();




        // get datacontract


        inventTransUsageQuantityReportContract = this.dataContractObject();




        // get dialog fields


        dialogFieldataAreaId        = this.bindInfo().getDialogField(inventTransUsageQuantityReportContract, methodstr(GOPInventTransUsageQuantityReportContract, parmDataAreaId));




        


        dialogFieldataAreaId.value(curExt());




        // enable/disable transdate based on checkbox


        dialogFieldataAreaId.enabled(0);


    }




}




<?xml version="1.0" encoding="utf-8"?>


<AxView xmlns:i="http://www.w3.org/2001/XMLSchema-instance">


<Name>GOPInventTransUsageQuantityIssueView</Name>


<SourceCode>


<Declaration><![CDATA[


public class GOPInventTransUsageQuantityIssueView extends common


{




}


]]></Declaration>


<Methods>


<Method>


<Name>getQuantity</Name>


<Source><![CDATA[


    private static str getQuantity()


    {


        return SysComputedColumn::abs(SysComputedColumn::sum(SysComputedColumn::returnField(tableStr(GOPInventTransUsageQuantityIssueView), identifierStr(InventTrans), fieldStr(InventTrans, Qty))));


    }




]]></Source>


</Method>


<Method>


<Name>findByInventTransId</Name>


<Source><![CDATA[


    /// <summary>


    /// Finds a sales line picked quantity by inventory transaction id.


    /// </summary>


    /// <param name = "_inventTransId">An inventory transaction id.</param>


    /// <returns>A <c>InventTransPickedQuantityView</c> view record if found, otherwise an empty buffer.</returns>


    public static GOPInventTransUsageQuantityIssueView findByInventTransId(InventTransId _inventTransId)


    {


        GOPInventTransUsageQuantityIssueView inventTransUsageQuantityIssueView;


        select firstonly inventTransUsageQuantityIssueView


            where inventTransUsageQuantityIssueView.InventTransId == _inventTransId;




        return inventTransUsageQuantityIssueView;


    }




]]></Source>


</Method>


</Methods>


</SourceCode>


<SubscriberAccessLevel>


<Read>Allow</Read>


</SubscriberAccessLevel>


<ReplacementKey>InventTransIdIdx</ReplacementKey>


<FieldGroups>


<AxTableFieldGroup>


<Name>AutoReport</Name>


<Fields />


</AxTableFieldGroup>


<AxTableFieldGroup>


<Name>AutoLookup</Name>


<Fields />


</AxTableFieldGroup>


<AxTableFieldGroup>


<Name>AutoIdentification</Name>


<AutoPopulate>Yes</AutoPopulate>


<Fields>


<AxTableFieldGroupField>


<DataField>InventTransId</DataField>


</AxTableFieldGroupField>


</Fields>


</AxTableFieldGroup>


<AxTableFieldGroup>


<Name>AutoSummary</Name>


<Fields />


</AxTableFieldGroup>


<AxTableFieldGroup>


<Name>AutoBrowse</Name>


<Fields />


</AxTableFieldGroup>


</FieldGroups>


<Fields>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>InventSiteId</Name>


<DataField>InventSiteId</DataField>


<DataSource>InventDim</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>InventLocationId</Name>


<DataField>InventLocationId</DataField>


<DataSource>InventDim</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>DataAreaIdCopy1</Name>


<DataField>DataAreaId</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>ItemId</Name>


<DataField>ItemId</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>DatePhysical</Name>


<DataField>DatePhysical</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>StatusIssue</Name>


<DataField>StatusIssue</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>Qty</Name>


<Aggregation>Sum</Aggregation>


<DataField>Qty</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>inventDimId</Name>


<DataField>inventDimId</DataField>


<DataSource>InventDim</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>InventTransId</Name>


<DataField>InventTransId</DataField>


<DataSource>InventTransOrigin</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>StatusReceipt</Name>


<DataField>StatusReceipt</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>ReferenceCategory</Name>


<DataField>ReferenceCategory</DataField>


<DataSource>InventTransOrigin</DataSource>


</AxViewField>


</Fields>


<Indexes>


<AxViewIndex>


<Name>InventTransIdIdx</Name>


<AlternateKey>Yes</AlternateKey>


<Fields>


<AxViewIndexField>


<DataField>InventTransId</DataField>


</AxViewIndexField>


</Fields>


</AxViewIndex>


</Indexes>


<Mappings />


<Relations />


<StateMachines />


<ViewMetadata>


<Name>Metadata</Name>


<SourceCode>


<Methods />


</SourceCode>


<DataSources>


<AxQuerySimpleRootDataSource>


<Name>InventTransOrigin</Name>


<DynamicFields>Yes</DynamicFields>


<Table>InventTransOrigin</Table>


<DataSources>


<AxQuerySimpleEmbeddedDataSource>


<Name>InventTrans</Name>


<DynamicFields>Yes</DynamicFields>


<Table>InventTrans</Table>


<DataSources>


<AxQuerySimpleEmbeddedDataSource>


<Name>InventDim</Name>


<DynamicFields>Yes</DynamicFields>


<FirstFast>Yes</FirstFast>


<FirstOnly>Yes</FirstOnly>


<Table>InventDim</Table>


<DataSources>


<AxQuerySimpleEmbeddedDataSource>


<Name>InventLocation</Name>


<DynamicFields>Yes</DynamicFields>


<FirstOnly>Yes</FirstOnly>


<Table>InventLocation</Table>


<DataSources />


<DerivedDataSources />


<Fields />


<Ranges>


<AxQuerySimpleDataSourceRange>


<Name>GOPExcludeNWIWH</Name>


<Field>GOPExcludeNWIWH</Field>


<Value>NOYes::NO</Value>


</AxQuerySimpleDataSourceRange>


</Ranges>


<JoinMode>ExistsJoin</JoinMode>


<Relations>


<AxQuerySimpleDataSourceRelation>


<Name>QueryDataSourceRelation1</Name>


<Field>inventLocationId</Field>


<JoinDataSource>InventDim</JoinDataSource>


<RelatedField>InventLocationId</RelatedField>


</AxQuerySimpleDataSourceRelation>


</Relations>


</AxQuerySimpleEmbeddedDataSource>


</DataSources>


<DerivedDataSources />


<Fields />


<Ranges />


<Relations>


<AxQuerySimpleDataSourceRelation>


<Name>QueryDataSourceRelation1</Name>


<Field>inventDimId</Field>


<JoinDataSource>InventTrans</JoinDataSource>


<RelatedField>inventDimId</RelatedField>


</AxQuerySimpleDataSourceRelation>


</Relations>


</AxQuerySimpleEmbeddedDataSource>


</DataSources>


<DerivedDataSources />


<Fields />


<Ranges>


<AxQuerySimpleDataSourceRange>


<Name>StatusReceipt</Name>


<Field>StatusReceipt</Field>


<Status>Locked</Status>


<Value>StatusReceipt::None</Value>


</AxQuerySimpleDataSourceRange>


<AxQuerySimpleDataSourceRange>


<Name>StatusIssue</Name>


<Field>StatusIssue</Field>


<Status>Locked</Status>


<Value>!StatusIssue::None</Value>


</AxQuerySimpleDataSourceRange>


</Ranges>


<Relations>


<AxQuerySimpleDataSourceRelation>


<Name>QueryDataSourceRelation1</Name>


<Field>InventTransId</Field>


<JoinDataSource>InventTransOrigin</JoinDataSource>


<JoinRelationName>InventTransOrigin</JoinRelationName>


<RelatedField>InventTransOrigin</RelatedField>


</AxQuerySimpleDataSourceRelation>


</Relations>


</AxQuerySimpleEmbeddedDataSource>


</DataSources>


<DerivedDataSources />


<Fields />


<Ranges />


<GroupBy />


<Having />


<OrderBy />


</AxQuerySimpleRootDataSource>


</DataSources>


</ViewMetadata>


</AxView>




<?xml version="1.0" encoding="utf-8"?>


<AxView xmlns:i="http://www.w3.org/2001/XMLSchema-instance">


<Name>GOPInventTransUsageQuantityReceiptView</Name>


<SourceCode>


<Declaration><![CDATA[


public class GOPInventTransUsageQuantityReceiptView extends common


{




}


]]></Declaration>


<Methods>


<Method>


<Name>getQuantity</Name>


<Source><![CDATA[


    private static str getQuantity()


    {


        return SysComputedColumn::abs(SysComputedColumn::sum(SysComputedColumn::returnField(tableStr(GOPInventTransUsageQuantityReceiptView), identifierStr(InventTrans), fieldStr(InventTrans, Qty))));


    }




]]></Source>


</Method>


<Method>


<Name>findByInventTransId</Name>


<Source><![CDATA[


    /// <summary>


    /// Finds a sales line picked quantity by inventory transaction id.


    /// </summary>


    /// <param name = "_inventTransId">An inventory transaction id.</param>


    /// <returns>A <c>InventTransPickedQuantityView</c> view record if found, otherwise an empty buffer.</returns>


    public static GOPInventTransUsageQuantityReceiptView findByInventTransId(InventTransId _inventTransId)


    {


        GOPInventTransUsageQuantityReceiptView inventTransUsageQuantityReceiptView;


        select firstonly inventTransUsageQuantityReceiptView


            where inventTransUsageQuantityReceiptView.InventTransId == _inventTransId;




        return inventTransUsageQuantityReceiptView;


    }




]]></Source>


</Method>


</Methods>


</SourceCode>


<SubscriberAccessLevel>


<Read>Allow</Read>


</SubscriberAccessLevel>


<ReplacementKey>InventTransIdIdx</ReplacementKey>


<FieldGroups>


<AxTableFieldGroup>


<Name>AutoReport</Name>


<Fields />


</AxTableFieldGroup>


<AxTableFieldGroup>


<Name>AutoLookup</Name>


<Fields />


</AxTableFieldGroup>


<AxTableFieldGroup>


<Name>AutoIdentification</Name>


<AutoPopulate>Yes</AutoPopulate>


<Fields>


<AxTableFieldGroupField>


<DataField>InventTransId</DataField>


</AxTableFieldGroupField>


</Fields>


</AxTableFieldGroup>


<AxTableFieldGroup>


<Name>AutoSummary</Name>


<Fields />


</AxTableFieldGroup>


<AxTableFieldGroup>


<Name>AutoBrowse</Name>


<Fields />


</AxTableFieldGroup>


</FieldGroups>


<Fields>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>InventSiteId</Name>


<DataField>InventSiteId</DataField>


<DataSource>InventDim</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>InventLocationId</Name>


<DataField>InventLocationId</DataField>


<DataSource>InventDim</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>DataAreaIdCopy1</Name>


<DataField>DataAreaId</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>ItemId</Name>


<DataField>ItemId</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>DatePhysical</Name>


<DataField>DatePhysical</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>StatusReceipt</Name>


<DataField>StatusReceipt</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>Qty</Name>


<Aggregation>Sum</Aggregation>


<DataField>Qty</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>inventDimId</Name>


<DataField>inventDimId</DataField>


<DataSource>InventDim</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>InventTransId</Name>


<DataField>InventTransId</DataField>


<DataSource>InventTransOrigin</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>StatusIssue</Name>


<DataField>StatusIssue</DataField>


<DataSource>InventTrans</DataSource>


</AxViewField>


<AxViewField xmlns=""


i:type="AxViewFieldBound">


<Name>ReferenceCategory</Name>


<DataField>ReferenceCategory</DataField>


<DataSource>InventTransOrigin</DataSource>


</AxViewField>


</Fields>


<Indexes>


<AxViewIndex>


<Name>InventTransIdIdx</Name>


<AlternateKey>Yes</AlternateKey>


<Fields>


<AxViewIndexField>


<DataField>InventTransId</DataField>


</AxViewIndexField>


</Fields>


</AxViewIndex>


</Indexes>


<Mappings />


<Relations />


<StateMachines />


<ViewMetadata>


<Name>Metadata</Name>


<SourceCode>


<Methods />


</SourceCode>


<DataSources>


<AxQuerySimpleRootDataSource>


<Name>InventTransOrigin</Name>


<DynamicFields>Yes</DynamicFields>


<Table>InventTransOrigin</Table>


<DataSources>


<AxQuerySimpleEmbeddedDataSource>


<Name>InventTrans</Name>


<DynamicFields>Yes</DynamicFields>


<Table>InventTrans</Table>


<DataSources>


<AxQuerySimpleEmbeddedDataSource>


<Name>InventDim</Name>


<DynamicFields>Yes</DynamicFields>


<FirstFast>Yes</FirstFast>


<FirstOnly>Yes</FirstOnly>


<Table>InventDim</Table>


<DataSources>


<AxQuerySimpleEmbeddedDataSource>


<Name>InventLocation</Name>


<DynamicFields>Yes</DynamicFields>


<FirstOnly>Yes</FirstOnly>


<Table>InventLocation</Table>


<DataSources />


<DerivedDataSources />


<Fields />


<Ranges>


<AxQuerySimpleDataSourceRange>


<Name>GOPExcludeNWIWH</Name>


<Field>GOPExcludeNWIWH</Field>


<Value>NOYes::NO</Value>


</AxQuerySimpleDataSourceRange>


</Ranges>


<JoinMode>ExistsJoin</JoinMode>


<Relations>


<AxQuerySimpleDataSourceRelation>


<Name>QueryDataSourceRelation1</Name>


<Field>inventLocationId</Field>


<JoinDataSource>InventDim</JoinDataSource>


<RelatedField>InventLocationId</RelatedField>


</AxQuerySimpleDataSourceRelation>


</Relations>


</AxQuerySimpleEmbeddedDataSource>


</DataSources>


<DerivedDataSources />


<Fields />


<Ranges />


<Relations>


<AxQuerySimpleDataSourceRelation>


<Name>QueryDataSourceRelation1</Name>


<Field>inventDimId</Field>


<JoinDataSource>InventTrans</JoinDataSource>


<RelatedField>inventDimId</RelatedField>


</AxQuerySimpleDataSourceRelation>


</Relations>


</AxQuerySimpleEmbeddedDataSource>


</DataSources>


<DerivedDataSources />


<Fields />


<Ranges>


<AxQuerySimpleDataSourceRange>


<Name>StatusReceipt</Name>


<Field>StatusReceipt</Field>


<Status>Locked</Status>


<Value>!StatusIssue::None</Value>


</AxQuerySimpleDataSourceRange>


<AxQuerySimpleDataSourceRange>


<Name>StatusIssue</Name>


<Field>StatusIssue</Field>


<Status>Locked</Status>


<Value>StatusIssue::None</Value>


</AxQuerySimpleDataSourceRange>


</Ranges>


<Relations>


<AxQuerySimpleDataSourceRelation>


<Name>QueryDataSourceRelation1</Name>


<Field>InventTransId</Field>


<JoinDataSource>InventTransOrigin</JoinDataSource>


<JoinRelationName>InventTransOrigin</JoinRelationName>


<RelatedField>InventTransOrigin</RelatedField>


</AxQuerySimpleDataSourceRelation>


</Relations>


</AxQuerySimpleEmbeddedDataSource>


</DataSources>


<DerivedDataSources />


<Fields />


<Ranges />


<GroupBy />


<Having />


<OrderBy />


</AxQuerySimpleRootDataSource>


</DataSources>


</ViewMetadata>


</AxView>


<?xml version="1.0" encoding="utf-8"?>

<AxTable xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

<Name>SolvInventTransUsageQuantityTmp</Name>

<SourceCode>

<Declaration><![CDATA[

public class SolvInventTransUsageQuantityTmp extends common

{

}

]]></Declaration>

<Methods />

</SourceCode>

<SubscriberAccessLevel>

<Read>Allow</Read>

</SubscriberAccessLevel>

<TableType>TempDB</TableType>

<DeleteActions />

<FieldGroups>

<AxTableFieldGroup>

<Name>AutoReport</Name>

<Fields />

</AxTableFieldGroup>

<AxTableFieldGroup>

<Name>AutoLookup</Name>

<Fields />

</AxTableFieldGroup>

<AxTableFieldGroup>

<Name>AutoIdentification</Name>

<AutoPopulate>Yes</AutoPopulate>

<Fields />

</AxTableFieldGroup>

<AxTableFieldGroup>

<Name>AutoSummary</Name>

<Fields />

</AxTableFieldGroup>

<AxTableFieldGroup>

<Name>AutoBrowse</Name>

<Fields />

</AxTableFieldGroup>

</FieldGroups>

<Fields>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>InvTRansOriDataAreaId</Name>

<ExtendedDataType>DataAreaId</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>MMMDivisionCode</Name>

<ExtendedDataType>EcoResCategoryCommodityCode</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@SCM:DivisionCode</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>MMMCommodityCode</Name>

<ExtendedDataType>EcoResCategoryCommodityCode</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@SYS8067</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>ItemId</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>ItemId</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>UnitId</Name>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>UnitOfMeasureSymbol</ExtendedDataType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>SolvMaterialClassCategory</Name>

<ExtendedDataType>String255</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:MaterialClass</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>SolvGlobalSalesCode</Name>

<ExtendedDataType>SolvGlobalSalesCode</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>InventLocationId</Name>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventLocationId</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>InventSiteId</Name>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventSiteId</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>ItemGroupId</Name>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>ItemGroupId</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:MaterialType</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>MaterialClassCategory</Name>

<ExtendedDataType>String255</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:MaterialClassCategory</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>MonthlyAverageUsageForSoldQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:AverageMonthlyUsage</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>OnHandQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:OnHandQuantity</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>OnHandValue</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:OnHandValue</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>Excess7To12MthsSlowQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>Amount</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:Excess7To12MthsSlowQty</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>Excess1To12MthsExcess</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:Excess1To12MthsExcess</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWIDeadValue</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:NWIObsoleteDead</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWITotal</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:NWITotal</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWIUnitsTotal</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:NWIUnitsTotal</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWIDeadQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:NWIDeadQty</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWIGreaterThen12MonthExcessQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:NWIExcessQty</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWI7T012MonthsSlowQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:NWISlowQty</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>MonthsofStockQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:MonthsofStockQty</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldDate">

<Name>LastUsageDatelast36months</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>DatePhysical</ExtendedDataType>

<Label>@MMM:LastUsageDatelast36months</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldDate">

<Name>FirstReceiptDate</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>DatePhysical</ExtendedDataType>

<Label>@MMM:FirstReceiptDate</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldDate">

<Name>LastReceiptDate</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>DatePhysical</ExtendedDataType>

<Label>@MMM:LastReceiptDate</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldEnum">

<Name>NWIStatusDead</Name>

<Label>@MMM:NWIStatusdead</Label>

<EnumType>SolvNWIStatusDead</EnumType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldEnum">

<Name>NWIStatusexcess</Name>

<Label>@MMM:NWIStatusExcess</Label>

<EnumType>SolvNWIStatusexcess</EnumType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldEnum">

<Name>InStock</Name>

<Label>@MMM:StockOrNonStock</Label>

<EnumType>SolvIsStock</EnumType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldEnum">

<Name>StatusReceipt</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<EnumType>StatusReceipt</EnumType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>InventTransId</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventTransId</ExtendedDataType>

<Mandatory>Yes</Mandatory>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldDate">

<Name>DatePhysical</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>DatePhysical</ExtendedDataType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>ReferenceId</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventTransRefId</ExtendedDataType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldEnum">

<Name>StatusIssue</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<EnumType>StatusIssue</EnumType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>AvailPhysical</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQtyAvailPhysical</ExtendedDataType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldInt">

<Name>MonthOfNoSale</Name>

<Label>@MMM:MonthOfNoSale</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWIDeadQtyPlus</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:NWIDeadQtyPlus</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWIGreaterThen12MonthExcessValue</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:NWIGreaterThen12MonthExcessValue</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWI7To12MonthsSlowValue</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:NWI7To12MonthsSlowValue</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>EarlyWarningQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:EarlyWarningQty</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>EarlyWarningValue</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:EarlyWarningValue</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>NWIDeadQtyPlusValue</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:NWIDeadValuePlus</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>Financialprovision</Name>

<ExtendedDataType>AmountCur</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

<Label>@MMM:Financialprovision</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldContainer">

<Name>CompanyLogo</Name>

<AssetClassification>System Metadata</AssetClassification>

<ExtendedDataType>Bitmap</ExtendedDataType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>Curr</Name>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>CurrencyCode</ExtendedDataType>

<Label>@sys137413</Label>

<Mandatory>Yes</Mandatory>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>InvUsageQty</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:OnHandQuantity</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldDate">

<Name>InventoryCloseDate</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>DatePhysical</ExtendedDataType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>UsageQty1</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:OnHandQuantity</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>UsageQty2</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

<Label>@MMM:OnHandQuantity</Label>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldString">

<Name>name</Name>

<ExtendedDataType>Description</ExtendedDataType>

<IgnoreEDTRelation>Yes</IgnoreEDTRelation>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldReal">

<Name>UsageQtyInlast36months</Name>

<AllowEdit>No</AllowEdit>

<AllowEditOnCreate>No</AllowEditOnCreate>

<AssetClassification>Customer Content</AssetClassification>

<ExtendedDataType>InventQty</ExtendedDataType>

</AxTableField>

<AxTableField xmlns=""

i:type="AxTableFieldEnum">

<Name>IsHardGoodSparePartIndicator</Name>

<HelpText>@MMM:HardGoodSparePartIndicatorHlpTxtx</HelpText>

<Label>@MMM:HardGoodSparePartIndicator</Label>

<EnumType>NoYes</EnumType>

</AxTableField>

</Fields>

<FullTextIndexes />

<Indexes />

<Mappings />

<Relations />

<StateMachines />

</AxTable>

Comments

Popular posts from this blog

Price disc agreement

Sample integration

Create ledger journals in D365FO using X++ + LedgerDimensionACType