Based On FromDate ,ToDate and WareHouse Show the Records


For this Scenario
we should insert data into Two table based on Two Jobs
one table for(DLSProjectManagment6_1016       ) all data and
another one(DLSProjectManagment7_1016   ) is for Consolidation ..
i write one code

i)
static void WareID(Args _args)
{
   InventTrans                      inventtrans;
    InventDim                       inventDim;
    DLSProjectManagment6_1016       dLSWarehoseTable;

   // delete_from dLSWarehoseTable;

    while select InventLocationId from inventDim
        join inventTrans

             where inventTrans.inventDimId == inventDim.inventDimId
           && ((inventTrans.StatusIssue == StatusIssue::Sold) || (inventTrans.StatusReceipt == StatusReceipt::Purchased))
    {

        dLSWarehoseTable.InventLocationId =inventDim.InventLocationId;
        if(inventTrans.StatusIssue == StatusIssue::Sold)
        {
            dLSWarehoseTable.SoldQty = inventTrans.Qty;
            dLSWarehoseTable.PurchQty = 0;
            dLSWarehoseTable.SoldPrice = inventTrans.lineAmount();
            dLSWarehoseTable.PurchPrice = 0;
            dLSWarehoseTable.DatePhysical = inventtrans.DatePhysical;
        }
        else
        {
            dLSWarehoseTable.SoldQty = 0;
            dLSWarehoseTable.PurchQty = inventTrans.Qty;
            dLSWarehoseTable.PurchPrice = inventTrans.lineAmount();
            dLSWarehoseTable.SoldPrice = 0;
             dLSWarehoseTable.DatePhysical = inventtrans.DatePhysical;

        }

            dLSWarehoseTable.insert();
    }
    info('Records Inserted');
}

====
based on aboue Table we consolidate the date ..
so i write below code 
ii)static void ware_house_insertrecordset(Args _args)
{
    DLSProjectManagment6_1016   DLSProjectManagment6_1016;
    DLSProjectManagment7_1016   dLSProjectManagment7_1016;

    delete_from dLSProjectManagment7_1016;

   insert_recordset dLSProjectManagment7_1016
        (InventLocationId,PurchQty,SoldPrice,SoldQty,PurchPrice)

   select InventLocationId,sum(PurchQty),sum(SoldPrice),sum(SoldQty),sum(PurchPrice) from DLSProjectManagment6_1016
         group by InventLocationId;

   update_recordSet  dLSProjectManagment7_1016 setting Total = dLSProjectManagment7_1016.SoldPrice+dLSProjectManagment7_1016.PurchPrice
        where dLSProjectManagment7_1016.InventLocationId;
       {
        info('Records inserted');
    }
}

After this done..
coming to our scenario..
FromDate ,to date and warehouse tha data should display
Note:
i) If i didnt give from date throw error
ii) if i didnt give todate it will take sysdate && at same time if i give todate is less than from date throw error..

iii)if i select boths date and didn't select ware house it will show all ware house data based on dates
  and
if i select both dates and selected ware house it will show that particular ware house data based on dates
 in form level we can write code to show all things in aboue Note

i)If i didnt give from date throw error
public boolean validate()
{
    boolean ret;

    ret = super();

    if( FromDate.dateValue() == dateNull() )
    {
       warning('Please enter Date');

    }


    return ret;

}

ii) if i didnt give todate it will take sysdate && at same time if i give todate is less than from date throw error..

public boolean validate()
{
    boolean ret;
    ToDate todate1;
    ret = super();
    if(ToDate.dateValue() < FromDate.dateValue() && ToDate.dateValue() != mkDate(1,1,1900))
    {
        warning('To_date must be greater or equal to From_date ');

    }


    return ret;

}

private void wareHouseDetails(InventLocationId _wareHouse,FromDate _FromDate,ToDate _ToDate)
{
        InventTrans                      inventTrans;
        InventDim                        inventDim;
        DLSProjectManagment6_1016        dLSWarehoseTable;
        DLSProjectManagment7_1016   dLSProjectManagment7_1016;

 delete_from dLSProjectManagment7_1016;

/*if i select boths date and didn't select ware house it will show all ware house data based on dates
  and
if i select both dates and selected ware house it will show that particular ware house data based on dates.*/
// This is the condition if u want check just comment below if(!Todate) condition.
    if( !_todate )
    {
        _todate =systemdateget();
    }


    if (!WareHouse1.valueStr())
    {
     insert_recordset dLSProjectManagment7_1016
        (InventLocationId,PurchQty,SoldPrice,SoldQty,PurchPrice)
   select InventLocationId,sum(PurchQty),sum(SoldPrice),sum(SoldQty),sum(PurchPrice) from dLSWarehoseTable
         group by InventLocationId
         where dLSWarehoseTable.InventLocationId == dLSWarehoseTable.InventLocationId
             && dLSWarehoseTable.DatePhysical >= _FromDate
           && dLSWarehoseTable.DatePhysical <= _ToDate
   ;
        update_recordSet  dLSProjectManagment7_1016 setting Total = dLSProjectManagment7_1016.SoldPrice+dLSProjectManagment7_1016.PurchPrice
        where dLSProjectManagment7_1016.InventLocationId;
    }
    else
    {
        insert_recordset dLSProjectManagment7_1016
        (InventLocationId,PurchQty,SoldPrice,SoldQty,PurchPrice)

   select InventLocationId,sum(PurchQty),sum(SoldPrice),sum(SoldQty),sum(PurchPrice) from dLSWarehoseTable
         group by InventLocationId
         where dLSWarehoseTable.InventLocationId == dLSWarehoseTable.InventLocationId
           && dLSWarehoseTable.InventLocationId == _wareHouse
            && dLSWarehoseTable.DatePhysical >= _FromDate
           && dLSWarehoseTable.DatePhysical <= _ToDate
   ;
        update_recordSet  dLSProjectManagment7_1016 setting Total = dLSProjectManagment7_1016.SoldPrice+dLSProjectManagment7_1016.PurchPrice
        where dLSProjectManagment7_1016.InventLocationId;

    }
}

After this write clicked method.to execute

void clicked()
{
    Args                   args;
    FormRun                formRun;
    
         this.wareHouseDetails(wareHouse1.valueStr(),FromDate.dateValue(),ToDate.dateValue());
        args = new args(formStr(DLSProjectManagment7_1016));
        formRun = classFactory.formRunClass(args);
        formRun.init();
        formRun.run();
        formRun.wait();
        formRun.detach();



}




Thank you..

Comments

Popular posts from this blog