Tuesday, January 8, 2019

Brand Stock Values Sold Summary

static void BrandStockValue_Sold(Args _args)
{
    ASAPG_BrandWiseValues                  globalTable ;
    ASAPG_BrandNameMaster                  brandMasterTable;
    Date                                   _today,_lastMonth;
    CustInvoiceJour                        custInvoiceJour;
    CustInvoiceTrans                       custInvoiceTrans;
    InventTable                            inventTable;

    TransDate                              startOfMth1,LastOfMth1;
    TransDate                             asonDate = mkDate(11,06,2018);  //today();

    _today          = asOnDate ;
    _lastMonth      = prevMth(_today );


    startOfMth1     = dateStartMth(_lastMonth );
    LastOfMth1      = endmth(_lastMonth);

    while select brandMasterTable  where brandMasterTable.Brand == 'HAS'
    {

     select  sum(LineAmount) from custInvoiceTrans
                where custInvoiceTrans.InvoiceDate >= startOfMth1 && custInvoiceTrans.InvoiceDate <= LastOfMth1
    join custInvoiceJour
        where custInvoiceTrans.SalesId == custInvoiceJour.SalesId  && custInvoiceTrans.InvoiceId == custInvoiceJour.InvoiceId
            && custInvoiceTrans.InvoiceDate == custInvoiceJour.InvoiceDate  && custInvoiceTrans.numberSequenceGroup == custInvoiceJour.numberSequenceGroup
            && custInvoiceJour.CustGroup != 'ASAP-3000'
    join inventTable
        where custInvoiceTrans.ItemId == inventTable.ItemId
            && inventTable.OGSBrand == brandMasterTable.Brand;

        globalTable.SalesAmount_1 = custInvoiceTrans.LineAmount;

        info(strFmt("Brand %1 - Amount %2", brandMasterTable.Brand, custInvoiceTrans.LineAmount));
    }
}

No comments:

Post a Comment