Feb 2, 2012

Misc charges calculation

The following  is to calculate the header level and line level  misc charges for SalesQuotationDetails ..

I did this in my SalesQuotation report to show the misc charges at header level and line level


display AmountCur unitPrice()
{
    AmountCur         totalTableValue,  totalLineValue;
    MarkupTrans       markupTrans;
    MarkupTable       markTable;
    ;
     while select markupTrans
           where markupTrans.TransTableId  == SalesQuotationJour.TableId
           &&    markupTrans.TransRecId    == SalesQuotationJour.RecId          
      join       markTable
           where markTable.MarkupCode     == markupTrans.MarkupCode
           &&    markTable.ModuleType      == ModuleInventCustVend::Cust          
    {
            totalTableValue = totalTableValue + markUp::calcTrans(markupTrans,SalesQuotationTrans.Qty, SalesQuotationTrans.LineAmount);           
        }
    while select markupTrans
           where markupTrans.TransTableId  ==SalesQuotationTrans.TableId
           &&    markupTrans.TransRecId    == SalesQuotationTrans.RecId
    join       markTable
           where markTable.MarkupCode      == markupTrans.MarkupCode
           &&    markTable.ModuleType      == ModuleInventCustVend::Cust
        {
            totalLineValue = totalLineValue + MarkUp::calcTrans(markupTrans,SalesQuotationTrans.Qty, SalesQuotationTrans.LineAmout);           
        }
    return totalLineValue;}

How to compare the date in X++

The following is the simple job to compare the date with the string format date


static void Job74(Args _args)
{
    ;
    if(today() == str2date('20/12/2012',123))
            info("Condition Fullfilled");
    else
          info("Condition not satisfied");   
   
}

Feb 1, 2012

Replacing standard report with our report

Here i want to discuss about that how can we replace SalesInvoice standard report with our MySalesInvoicereport  in which i hav SalesTable and SalesLine as datasources

Then do the following ,


In printjournal() of custInvoiceJour table just change the menuitem  SalesInvoice to MyReportSalesInvoice

salesInvoiceMenu = new MenuFunction(menuitsemoutputstr(MyReportSalesInvoice),MenuItemType::Output);

Go to our MySalesInvoicereport 

In class declaration and declare the variables as

    SalesFormLetter                               salesFormLetter;
    SalesFormLetterReport_Invoice       salesFormLetterReport;
    RecordSortedList                             journalList;
    Salesid                                              salesid;               
     custInvoiceJour                                            custInvoiceJour;

In init() write the code as

super();

if (classidget(element.args().caller()) == classnum(SalesFormLetter_Invoice))
    {
        salesFormLetter = element.args().caller();
    }
else
    {
        if (element.args().record())
            journalList         = FormLetter::createJournalListCopy(element.args().record());
        else
            journalList         = element.args().object();
    }
    if (!journalList)
        throw '';
    journalList.first(custInvoiceJour);
    if (!custInvoiceJour)
        throw error("@SYS26348");
salesid  =  custInvoiceJour.salesId


In fetch() try to run the report on the basis of CustInvoiceJour

public boolean fetch()
{
    boolean ret;
    ;
    ret = true;
    select SalesTable_1 where SalesTable_1.SalesId == _salesId;
    if(SalesTable_1)
    element.send(SalesTable_1);
    while select salesLine_1 where salesLine_1.SalesId == _salesId
    {
    element.send(salesLine_1);
    }
    return ret;
}