Sunday, October 26, 2014

Tutorial Runbase batch class auto mail for customer open Invoice to customer

 // Tutorial Runbase batch class auto mail for customer open Invoice to customer

static void San_CustomerOpenInvoiceMail(Args _args)
{
        CustTransOpen                   custTransOpen,custTO;
    CustTrans                       custTrans,custT;
    CustTable                       custtable;
    SysMailer                       mail;
    str                             senderEmail,name,Accountno;
    str                             recipientEmail,recipientEmail2;
    str                             messageText, leavetype,letterTemplate;
    str                             cc, to, body, sub;
    int                             i,j=0;
    int64                           countrecid;
    container                       dataAccountNum,dataInvoice,dataDueDate,dataTransDate,dataInvoiceAmount,dataAmountNotSettled;

    mail = new SysMailer();

    sub                 =  strfmt("Regarding Customer Open Invoice payment Pending Request");
    senderEmail         =  'bharathi@cbizol.com';
   // recipientEmail    = 'sangeethr90@gmail.com';

     while select custtable
                where custtable.AccountNum like "1101"
    {

        if(custtable.AccountNum)
        {
                j =0;
                while select custTransOpen
                            where custTransOpen.AccountNum == custtable.AccountNum
                {
                    j ++;
                }
                if(j == 0)
                {
                    continue;
                }
                if(j >0)
                {
                    dataAccountNum          = conNull();
                    dataInvoice             = conNull();
                    dataDueDate             = conNull();
                    dataTransDate           = conNull();
                    dataInvoiceAmount       = conNull();
                    dataAmountNotSettled    = conNull();

                    while select custTO where custTO.AccountNum == custtable.AccountNum
                                            && custTO.AmountCur > 0.00
                            join custT where custT.AccountNum == custTO.AccountNum
                                            && custT.RecId == custTO.RefRecId
                    {
                        //info(strFmt("%1 -%2",custT.Invoice,custTO.AccountNum));
                        name                    = CustTable::find(custTO.AccountNum).name();
                        Accountno               = custTO.AccountNum;
                        recipientEmail          = 'sangeeth@cbizol.com';//CustTable::find(custTO.AccountNum).email();
                        dataAccountNum          += [custTO.AccountNum];
                        dataInvoice             += [custT.Invoice];
                        dataDueDate             += [custTO.DueDate];
                        dataTransDate           += [custTO.TransDate];
                        dataInvoiceAmount       += [custTO.AmountCur];
                        dataAmountNotSettled    += [custTO.AmountCur];

                        body            = "<html><body>"+ strfmt("Dear %1",name + "<br/><br>"+
                                            strfmt("\n Open Invoice Requested for the  Customer Account  (%1) and Reminder on %2",Accountno,today()) + "<br/><br>");
                        body            = Body + "<html> <body><table border='1'>";
                        body            = body+  "<tr><th>" +   "Invoice Number"    +"</th>";
                        body            = body+  "<th>" +   "Due Date"    +"</th>";
                        body            = body+  "<th>" +   "Trans Date"    +"</th>";
                        body            = body+  "<th>" +   "Invoice Amount"    +"</th>";
                        body            = body+  "<th>" +   "Amount Not Settled"    +"</th></tr>";
                        for(i = 1;i <= conLen(dataAccountNum); i++)
                        {
                            body            = body+  "<tr><td>" + strfmt("%1",conPeek(dataInvoice,i))    +"</td>";
                            body            = body+  "<td>" + strfmt("%1",conPeek(dataDueDate,i))    +"</td>";
                            body            = body+  "<td>" +  strfmt("%1",conPeek(dataTransDate,i))    +"</td>";
                            body            = body+  "<td>" +  strfmt("%1",conPeek(dataInvoiceAmount,i))    +"</td>";
                            body            = body+  "<td>" +  strfmt("%1",conPeek(dataAmountNotSettled,i))    +"</td></tr>";
                        }

                      }
                            Body                = Body + "</table>";
                            Body                = Body + strfmt("<br/><br/><b>Note:This is a system generated email.Please do not reply to this mail.</b> </body></html>");
                            mail.quickSend(senderEmail, recipientEmail,sub,body);
                }
        }
    }

}



No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...