Monday, 8 October 2012

To Change Sales order Status



//declare the following varibale in class declaration of a form


public class FormRun extends ObjectRun
{
    SalesFormLetter_Confirm salesFormLetter_Confirm;
    SalesFormLetter_Invoice salesFormLetter_Invoice;
    SalesFormLetter_PackingSlip salesFormLetter_PackingSlip;
    SalesFormLetter_PickingList salesFormLetter_PickingList;
}

// when you click

void clicked()
{
    SalesTable salesTable;

    if(SalesId.valueStr()!="")
    {

        salesTable = SalesTable::find(SalesId.valueStr(), true);// retrives the sales id based on the slected sales id on text box;

    if(ActionType.valueStr() == enum2str(SalesOrderType::Confirm)) // if Sales order type is confirm
    {
        if(salesTable.DocumentStatus != DocumentStatus::None)// if sales order is confirmed, other wise else part
        {
            info(strFmt("@MAD39",salesTable.SalesId));

        }
        else
        {
            salesFormLetter_Confirm =SalesFormLetter::construct(DocumentStatus::Confirmation);
            salesFormLetter_Confirm.update(salesTable, SystemDateGet(), SalesUpdate::All,AccountOrder::None,false,false );
            info(strFmt("@MAD41",salesTable.SalesId));
        }
    }
    else
        if(ActionType.valueStr() == enum2str(SalesOrderType::Invoice)) // if saler order type is invoice
        {
            if(salesTable.SalesStatus == SalesStatus::Invoiced) // if sales order is invoiced ,other wise elese part.
            {
            info(strFmt("@MAD37",salesTable.SalesId));
            }
            else
            {
            salesFormLetter_Invoice =SalesFormLetter::construct(DocumentStatus::Invoice);
            salesFormLetter_Invoice.update(salesTable, SystemDateGet(), SalesUpdate::All,AccountOrder::None,false,false );

            info(strFmt("@MAD43",salesTable.SalesId));
            }
    }
    else
        if(ActionType.valueStr() == enum2str(SalesOrderType::PackingSlip)) // if sales order type is packing slip
        {
            if(salesTable.SalesStatus == SalesStatus::Delivered) // if packing slip is done for the saler order, other wise else part
            {
            info(strFmt("@MAD38",salesTable.SalesId));
            }
            else
            {
            salesFormLetter_PackingSlip =SalesFormLetter::construct(DocumentStatus::PackingSlip);
            salesFormLetter_PackingSlip.update(salesTable, SystemDateGet(), SalesUpdate::All,AccountOrder::None,false,false );
            info(strFmt("@MAD44",salesTable.SalesId));
            }
        }
    else
        if(actiontype.valuestr() == enum2str(salesordertype::pickinglist)) // if sales order type is picking list
        {
            if(salestable.salesstatus == salesstatus::delivered) // if picking list is done for the sales order , other wise elese part.
            {
            info(strfmt("@mad40",salestable.salesid));
            }
            else
            {
                salesformletter_pickinglist =salesformletter::construct(documentstatus::pickinglist);
                salesformletter_pickinglist.update(salestable, systemdateget(), salesupdate::PickingList,accountorder::none,false,false );
                info(strfmt("@mad45",salestable.salesid));
            }
        }
    }
    else
    {
        Box::stop("@MAD47","@SYS8500");
    }

    super();
}

No comments:

Post a Comment