Thursday, 20 April 2017

Employee Integrations

Employee   Integrations



class AifEmployeeService
{

}




[SysEntryPointAttribute(true), AifCollectionTypeAttribute('_EMPContract',Types::Class)]
public void EmployeeSave(AifEmployeeContract _EMPContract)
{
        str                                         ErrorMessage;
        DirPerson                                   dirPerson;
        HcmEmployment                               HcmEmployment,hcmEmploymentFuture;
        Dirpersonname                               dirpersonname;
        HcmWorker                                   hcmWorker;
        Company                                     Company;
        ValidFromDateTime                           employmentStartDateTime;
        ValidToDateTime                             employmentEndDateTime;
        HcmWorkerBankAccount                        hcmWorkerBankAccount;



        ;

    try
    {
        changeCompany (_EMPContract.Company())
        {
             ErrorMessage = this.ValidateEmployee(_EMPContract);
            if(ErrorMessage != "")
            {
                throw Error(strFmtLB(ErrorMessage));
            }
            else
            {
                ttsBegin;
            // fill the worker Names

                hcmWorker = HcmWorker::findByPersonnelNumber(_EMPContract.PersonnelNumber(),true);
                if(!hcmWorker.RecId)  //If PersonnelNumber is not existing the initialize
                {
                    dirperson.Name      = _EMPContract.Name();
                    dirperson.NameAlias = _EMPContract.Name();
                    DirPerson.insert();

                    dirPersonName =  DirPersonName::find(dirPerson.RecId,true);
                    [dirPersonName.FirstName, dirPersonName.MiddleName, dirPersonName.LastName] = DirPerson::splitNameParts(_EMPContract.Name());
                    dirPersonName.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);


                    DirPersonName.Person        = dirPerson.RecId;
                    DirPersonName.ValidFrom     = DateTimeUtil::newDateTime(today(),0);
                    DirPersonName.ValidTo       = DateTimeUtil::maxValue();
                    dirpersonname.insert();

                    hcmWorker.PersonnelNumber = _EMPContract.PersonnelNumber();
                    hcmWorker.Person=dirPerson.RecId;
                    hcmWorker.insert();

                        // Hcm Employement Table Data
                    HcmEmployment.EmploymentType = HcmEmploymentType::Employee;
                    HcmEmployment.LegalEntity = CompanyInfo::find().RecId;
                    HcmEmployment.ValidFrom     = DateTimeUtil::newDateTime(today(),0);
                    HcmEmployment.ValidTo       = DateTimeUtil::maxValue();
                    //HcmEmployment.ValidFrom     = _EMPContract.employmentStartDateTime();
                    HcmEmployment.Worker=hcmWorker.RecId;
                    HcmEmployment.insert();
                }
                else
                {

                    dirPersonName =  DirPersonName::find(hcmWorker.Person,true);
                    [dirPersonName.FirstName, dirPersonName.MiddleName, dirPersonName.LastName] = DirPerson::splitNameParts(_EMPContract.Name());
                    dirPersonName.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
                    DirPersonName.ValidFrom     = DateTimeUtil::newDateTime(today(),0);
                    DirPersonName.ValidTo       = DateTimeUtil::maxValue();
                    //DirPersonName.ValidFrom     = _EMPContract.();
                    dirpersonname.update();

                    dirperson           = DirPerson::find(DirPersonName.Person);
                    dirperson.Name      = _EMPContract.Name();
                    dirperson.NameAlias = _EMPContract.Name();
                    DirPerson.update();
                }



              // HcmWorker Bank Account  Details
                select hcmworkerbankaccount;
                if(!hcmworkerbankaccount.AccountId)
                {
                    hcmworkerbankaccount.AccountId  = _EMPContract.EmpAccountId();
                    hcmworkerbankaccount.AccountNum = _empcontract.EmpAccountNum();
                    hcmworkerbankaccount.name       = _empcontract.EmpName();
                    hcmworkerbankaccount.Worker     = hcmWorker.RecId;
                    hcmworkerbankaccount.insert();
                }
                else
                {
                        //update HcmWorker Bank Account  Details
                    select  forUpdate hcmworkerbankaccount
                        where  hcmworkerbankaccount.AccountId ==  _empcontract.EmpAccountId();
                    if(hcmworkerbankaccount.AccountId == _EMPContract.EmpAccountId())
                    {
                        //ttsBegin;
                        hcmworkerbankaccount.AccountId  = _EMPContract.EmpAccountId();
                        hcmworkerbankaccount.AccountNum = _empcontract.EmpAccountNum();
                        hcmworkerbankaccount.name       = _empcontract.EmpName();
                        hcmworkerbankaccount.Worker     = hcmWorker.RecId;
                        hcmworkerbankaccount.update();
                        // ttsCommit;
                    }
                }



            }
            ttsCommit;


        }
    }
    catch (Exception::Error)
    {
        ttsAbort;
        throw Exception::Error;

    }
}


private str ValidateEmployee(AifEmployeeContract _EMPContract)
{
    boolean valid = true;

    str Message = "";
    if(_EMPContract.Name() == "")
    {
        Message = Message + "Name  is required!\n";
        valid = false;
    }

    if(_EMPContract.PersonnelNumber() == "")
    {
        Message = Message + "PersonnelNumber  is required!\n";
        valid = false;
    }

    if(_EMPContract.EmpAccountNum() == "")
    {
        Message = Message + "Employee Bank AccountNumber  is required!\n";
        valid = false;
    }

     if(_EMPContract.EmpName() == "")
    {
        Message = Message + "Employee Name  is required!\n";
        valid = false;
    }


    return Message;
}

 Calling   job



static void job_Employeeinsert(Args _args)
{
    AifEmployeeContract        aifEmployeeContract;
     AifEmployeeService      aifEmployeeService;

    AifEmployeeContract = new AifEmployeeContract();
     AifEmployeeService = new AifEmployeeService();



    aifEmployeeContract.PersonnelNumber('');
    aifEmployeeContract.Name ('');
   aifEmployeeContract.EmpName("");
    aifEmployeeContract.EmpAccountNum("2");
    aifEmployeeContract.AccountId("");



    aifEmployeeContract.Company("");



     aifEmployeeService.EmployeeSave(aifEmployeeContract);
     info(aifEmployeeContract.PersonnelNumber());


}

Project Times heets Integrations

Project Times heets Integrations

class AIFTimeSheetsService
{
}



[SysEntryPointAttribute(true), AifCollectionTypeAttribute('_TimeSheets',Types::Class)]
public void CreateTimesheets(AIFTimesheetsContract _TimeSheets)
{

        projJournalTable                projJournalTable;
        ProjJournalTrans                ProjJournalTrans;
        str                             ErrorMessage;
        ProjJournalTableData            jourTableData;
        ProjJournalTransData            jourTransData;
        numberSequenceTable             numberSequenceTable;
        ProjJournalStatic               jourStatic;
        journalTransData                journalTransData;
        journalTableData                journalTableData;
        NumberSeq                       numberSeq;
        LedgerJournalName               ledgerJournalName;
        LedgerJournalTable                      jourTable;
        LedgerJournalTrans                      jourTrans;
         Voucher         voucher;


    try
    {
        changeCompany (_TimeSheets.Company())
        ErrorMessage = this.ValidateTimeSheet(_TimeSheets);
            if(ErrorMessage != "")
            {
                throw Error(strFmtLB(ErrorMessage));
            }
            else
            {
            ttsBegin;

            projJournalTable    = ProjJournalTable::find(_TimeSheets.JournalId(),true);
            if(!numberSequenceTable.RecId)
            {

                while select  forUpdate ProjJournalTrans   where ProjJournalTrans.JournalId == _TimeSheets.JournalId()
                {
                    ProjJournalTrans.doDelete();
                }
                while select  forUpdate projJournalTable   where projJournalTable.JournalId == _TimeSheets.JournalId()
                {
                    projJournalTable.doDelete();
                }
            }



                jourTableData = JournalTableData::newTable(projJournalTable);
                ProjJournalTable.JournalId          = jourTableData.nextJournalId();
                ProjJournalTable.JournalType        = ProjJournalType::Hour;
                jourTableData.initFromJournalName(ProjJournalName::find(projJournalTable.JournalNameId));
                jourStatic                          = jourTableData.journalStatic();
                jourTransData                       = jourStatic.newJournalTransData(ProjJournalTrans,jourTableData);
                projJournalTable.JournalNameId      = "hours";
                projJournalTable.Description        = _TimeSheets.Description();
                projJournalTable.ProjQty            = _TimeSheets.ProjQty();
                jourTransData.initFromJournalTable();
                ProjJournalTrans.initValue();
                projJournalTable.insert();


                //numberSequenceTable = NumberSequenceTable::find(LedgerJournalName::find(jourTable.JournalName).NumberSequenceTable);
                //jourTrans.Voucher =  NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();
                //jourTrans.LineNum = LedgerJournalTrans::lastLineNum(jourTrans.JournalNum) + 1;
               // jourTrans.insert();
                ProjJournalTrans.TransDate         = _TimeSheets.TimeSheetLineProjTransDate();
                ProjJournalTrans.ProjTransDate     = _TimeSheets.TimeSheetLineProjTransDate();
                ProjJournalTrans.Txt               = _TimeSheets.TimeSheetLineDescription();
                ProjJournalTrans.CurrencyId        = _TimeSheets.TimeSheetLineCurrency();
                ProjJournalTrans.Worker            = hcmWorker::findByPersonnelNumber(_TimeSheets.TimeSheetLinePersonnelNumber()).RecId;
                ProjJournalTrans.ProjId            = _TimeSheets.TimeSheetLineProjId();
                ProjJournalTrans.CategoryId        = _TimeSheets.TimeSheetLineCategoryId();
                ProjJournalTrans.LinePropertyId    = _TimeSheets.TimeSheetLineLinePropertyId();
                ProjJournalTrans.Qty               = _TimeSheets.TimeSheetLineHours();
                ProjJournalTrans.CostPrice         = _TimeSheets.TimeSheetLineCostPrice();
                ProjJournalTrans.SalesPrice        = _TimeSheets.TimeSheetLineSalesPrice();
                ProjJournalTrans.TransactionDescription = _TimeSheets.TimeSheetLineEnglishRefence();
                ProjJournalTrans.LanguageTxt       = _TimeSheets.TimeSheetLineArabicReference();
                ProjJournalTrans.ReverseDate       = _TimeSheets.TimeSheetLineReverseDate();
                ProjJournalTrans.TransId           = ProjParameters::newTransId();

                //journalTransData.create();
                ProjJournalTrans.insert();
              }


            ttsCommit;


            }

    catch (Exception::Error)
    {
        ttsAbort;
        throw Exception::Error;
    }
}



private str ValidateTimeSheet(AIFTimesheetsContract _TimeSheets)
{
    boolean valid =         true;
    projTable               projTable;
    boolean                 ret=false,okk=true;
     ErrorLog               _ErrorLog,_ErrorLogAll,errorline;
    HcmWorker               hcmWorker;
    dirperson               dirperson;
    HcmEmployment           HcmEmployment;

    str Message = "";
    if(_TimeSheets.TimeSheetLineProjId() == "")
    {
        Message = Message + "Project id is required!\n";
        valid = false;
    }
    else if(!projTable::exist(_TimeSheets.TimeSheetLineProjId()))
    {
        Message = Message + "ProjId does not exits in master!\n";
        valid = false;
    }
//
    //if(_TimeSheets.TimeSheetLineCategoryId() == "")
    //{
        //Message = Message + "Category id is required!\n";
        //valid = false;
    //}
    //else if(!CategoryTable::exist(_TimeSheets.TimeSheetLineCategoryId()))
    //{
        //Message = Message + "CategoryId does not exits in master!\n ";
        //valid = false;
    //}
//
   //if(_TimeSheets.TimeSheetLineCostPrice() == 0)
    //{
        //Message = Message + "Cost price should greater than Zero "+"\n";
        //valid = false;
    //}
//
    //if(_TimeSheets.TimeSheetLineSalesPrice  () == 0)
    //{
        //Message = Message + "SalesPrice should greater than Zero "+"\n";
        //valid = false;
    //}

    return Message;
}



calling  job





static void Job_TimeSheets(Args _args)
{

    AIFTimesheetsContract      _AIFTimesheetsContract = new AIFTimesheetsContract();
    AIFTimeSheetsService     _AIFTimeSheetsService = new AIFTimeSheetsService();



    _AIFTimesheetsContract.JournalNameId("HR TimeSheet ");
    //_AIFTimesheetsContract.JournalId("000031_123");
    _AIFTimesheetsContract.Description("HR TimeSheet  ");
    //_AIFTimesheetsContract.ProjQty(10.00);

    _AIFTimesheetsContract.TimeSheetLineProjTransDate(10\1\2014);
    _AIFTimesheetsContract.TimeSheetLineReverseDate(30\1\2014);
    _AIFTimesheetsContract.TimeSheetLineTransDate(4\6\2016);

    _AIFTimesheetsContract.TimeSheetLineDescription ("2345");
    _AIFTimesheetsContract.TimeSheetLineCurrency("SAR");
    _AIFTimesheetsContract.Type(ProjType::FixedPrice);
   _AIFTimesheetsContract.TimeSheetLineEnglishRefence("Project Hour/Cost Journal");
    _AIFTimesheetsContract.TimeSheetLineArabicReference("إستحقاق سنوي – رصيد إفتتاحي 2.5 يوم");
    _AIFTimesheetsContract.TimeSheetLinePersonnelNumber("A0039");
    _AIFTimesheetsContract.TimeSheetLineCategoryId("Normal");
    _AIFTimesheetsContract.TimeSheetLineLinePropertyId("NC");
    _AIFTimesheetsContract.TimeSheetLineHours(10);
    _AIFTimesheetsContract.TimeSheetLineCostPrice(10);
    _AIFTimesheetsContract.TimeSheetLineSalesPrice(10);
    _AIFTimesheetsContract.TimeSheetLineProjId("2055");
    _AIFTimesheetsContract.Voucher("HRJ000023");
    //_AIFTimesheetsContract.ActivityNumber("000005_006");



     _AIFTimesheetsContract.Company("TAJ");
    _AIFTimeSheetsService.CreateTimesheets(_AIFTimesheetsContract);
   // _AIFTimeSheetsService.ExpenseTimesheets(_AIFTimesheetsContract);
    info(_AIFTimesheetsContract.JournalId());








}

Project Integrations

Project    Integrations





Project Contract


class AIFProjectService
{

}


[SysEntryPointAttribute(true), AifCollectionTypeAttribute('_Project',Types::Class)]
public void CreateAndUpdate_ProjectContract (AIFProjectContract _Project)
{
        ProjFundingSource           projFundingSource;
        str                         ErrorMessage;
        projInvoiceTable            projInvoiceTable;
        ProjFundingRule             projFundingRule;
        ProjTable                   ProjTable;
        ProjFundingRuleAllocation   ProjFundingRuleAllocation;


      ;


        ErrorMessage = this.ValidateProjcet(_Project);
        if(ErrorMessage != "")
        {
            throw Error(strFmtLB(ErrorMessage));
        }

    try
    {
        changeCompany (_Project.Company())
        {
                ttsBegin;
                // Projcet  Details
                projinvoiceTable = projinvoiceTable::find(_Project.ProjectContractId(), true);
                if(!projinvoiceTable.RecId)
                {
                projinvoiceTable.ProjInvoiceProjId  = _Project.ProjectContractId();
                projInvoiceTable.CurrencyId         = _Project.ContractCurrencyId();
                projinvoiceTable.Description        = _Project.ContractDescription();
                projInvoiceTable.insert();
                }
                else
                {
                while  select forUpdate projinvoiceTable where projinvoiceTable.ProjInvoiceProjId == _Project.ProjectContractId()
                {
                // Projcet  Details update
                projinvoiceTable.ProjInvoiceProjId  = _Project.ProjectContractId();
                projInvoiceTable.CurrencyId         = _Project.ContractCurrencyId();
                projinvoiceTable.Description        = _Project.ContractDescription();
                projInvoiceTable.update();
                }
                }
                //projFundingSource  Details
                projFundingSource       = projFundingSource::findCustAccount(_Project.FundingSourceId(),true);
                if(!projFundingSource.RecId)
                {
                projFundingSource.ContractId        = projInvoiceTable.ProjInvoiceProjId;
                projFundingSource.CustAccount       = _Project.CustomerAccountNum();
                projFundingSource.FundingType       = ProjFundingType::Customer;
                projFundingSource.PaymentTermsId    = _Project.PaymentTermsId();
                projFundingSource.PaymentscheduleId = _Project.PaymentscheduleId();
                projFundingSource.editProjFunder(true,projFundingSource.CustAccount);
                projFundingSource.insert();
                }
                else
                {
                while  select forUpdate projFundingSource where projFundingSource.FundingSourceId == _Project.FundingSourceId()

                projFundingSource.ContractId        = projInvoiceTable.ProjInvoiceProjId;
                projFundingSource.CustAccount       = _Project.CustomerAccountNum();
                projFundingSource.FundingType       = ProjFundingType::Customer;
                projFundingSource.PaymentTermsId    = _Project.PaymentTermsId();
                projFundingSource.PaymentscheduleId = _Project.PaymentscheduleId();
                projFundingSource.editProjFunder(true,projFundingSource.CustAccount);
                projFundingSource.update();
                }

                if(!ProjFundingRule.RecId)
                {
                ProjFundingRule.Priority        = _Project.FundingRulesPriority();
                ProjFundingRule.ContractId      = projInvoiceTable.ProjInvoiceProjId;
                ProjFundingRule.ItemId          = _Project.FundingRulesItemIdNumber();
                ProjFundingRule.ProjId          = _Project.ProjId();
                projFundingRule.CategoryGroupId = _Project.FundingRulesCategoryGroupId();
                projFundingRule.CategoryId      = _Project.FundingRulesCategoryId();
                projFundingRule.StartDate       = _Project.startDate();
                projFundingRule.EndDate         = _Project.EndDate();
                projFundingRule.insert();
                }
                else
                {
                while  select forUpdate ProjFundingRule where ProjFundingRule.ContractId == _Project.ProjectContractId()

                ProjFundingRule.Priority        = _Project.FundingRulesPriority();
                ProjFundingRule.ContractId      =  projInvoiceTable.ProjInvoiceProjId;
                ProjFundingRule.ProjId          = _Project.ProjId();
                ProjFundingRule.ItemId          = _Project.FundingRulesItemIdNumber();
                projFundingRule.CategoryGroupId = _Project.FundingRulesCategoryGroupId();
                projFundingRule.CategoryId      = _Project.FundingRulesCategoryId();
                projFundingRule.StartDate       = _Project.startDate();
                projFundingRule.EndDate         = _Project.EndDate();
                projFundingRule.update();
                }

                if(!ProjFundingRuleAllocation.RecId)
                {
                ProjFundingRuleAllocation.AllocateRounding      = NoYes::Yes;
                ProjFundingRuleAllocation.FundingSource         = projFundingSource.RecId;
                ProjFundingRuleAllocation.AllocationPercentage  = _Project.AllocationPercentage();
                ProjFundingRuleAllocation.FundingRule           = projFundingRule.RecId;
                ProjFundingRuleAllocation.insert();
                }
                else
                {
                ProjFundingRuleAllocation.AllocateRounding      = NoYes::Yes;
                ProjFundingRuleAllocation.FundingSource         = projFundingSource.RecId;
                ProjFundingRuleAllocation.AllocationPercentage  = _Project.AllocationPercentage();
                ProjFundingRuleAllocation.FundingRule           = projFundingRule.RecId;
                ProjFundingRuleAllocation.update();
                }
                ttsCommit;

        }
    }
    catch (Exception::Error)
    {
        ttsAbort;
        throw Exception::Error;
    }
}



Project




[SysEntryPointAttribute(true), AifCollectionTypeAttribute('__Project',Types::Class)]
public void CreateAndUpdate_Project(AIFProjectContract _Project)
{


        ProjTable           projTable;
        str                 ErrorMessage;
        CustTable           custTable;
        DirPartyTable       dirPartyTable;
        HcmWorker           hcmWorker;
        DirPerson           dirPerson;
        ProjinvoiceTable    projinvoiceTable;



    try
            changeCompany (_Project.Company())
    {
            ttsBegin;

         projTable    = ProjTable::find(_Project.ProjId(),true);
        if(!ProjTable.ProjId)
    {

            projTable.ProjId                = _Project.ProjId();
            projTable.Name                  = _Project.projectName();
            projTable.ProjGroupId           = _Project.ProjectGroupId();
            projTable.ProjInvoiceProjId     = _Project.ProjectContractId();
            projTable.CustAccount           = _Project.CustomerAccountNum();
            projTable.Email                 = _Project.Email();
            projTable.StartDate             = _Project.StartDate();
            projTable.EndDate               = _Project.EndDate();
            projTable.ProjectedStartDate    = _Project.ProjectedStartDate();
            projTable.ProjectedEndDate      = _Project.ProjectedEndDate();
            projTable.ExtensionDate         = _Project.ExtensionDate();
            projTable.Created               = _Project.Created();
            projTable.WorkerResponsible     = hcmWorker::findByPersonnelNumber(_Project.ProjectManager()).RecId;
            hcmWorker.RecId                 = projTable.WorkerResponsible;
            projTable.WorkerResponsibleFinancial     = hcmWorker::findByPersonnelNumber(_Project.ProjectController()).RecId;
            hcmWorker.RecId                 = projTable.WorkerResponsibleFinancial;
            projTable.WorkerResponsibleSales     = hcmWorker::findByPersonnelNumber(_Project.SalesManager()).RecId;
            hcmWorker.RecId                 = projTable.WorkerResponsibleSales;
            projTable.insert();
    }
    else
    {
            projTable.ProjId                = _Project.ProjId();
            projTable.Name                  = _Project.projectName();
            projTable.ProjGroupId           = _Project.ProjectGroupId();
            projTable.ProjInvoiceProjId     = _Project.ProjectContractId();
            projTable.CustAccount           = _Project.CustomerAccountNum();
            projTable.Email                 = _Project.Email();
            projTable.StartDate             = _Project.StartDate();
            projTable.EndDate               = _Project.EndDate();
            projTable.ProjectedStartDate    = _Project.ProjectedStartDate();
            projTable.ProjectedEndDate      = _Project.ProjectedEndDate();
            projTable.ExtensionDate         = _Project.ExtensionDate();
            projTable.Created               = _Project.Created();
            projTable.WorkerResponsible     = hcmWorker::findByPersonnelNumber(_Project.ProjectManager()).RecId;
            hcmWorker.RecId                 = projTable.WorkerResponsible;
            projTable.WorkerResponsibleFinancial     = hcmWorker::findByPersonnelNumber(_Project.ProjectController()).RecId;
            hcmWorker.RecId                 = projTable.WorkerResponsibleFinancial;
            projTable.WorkerResponsibleSales     = hcmWorker::findByPersonnelNumber(_Project.SalesManager()).RecId;
            hcmWorker.RecId                 = projTable.WorkerResponsibleSales;
            projTable.update();

    }


        ttsCommit;
    }
    catch (Exception::Error)
    {
        ttsAbort;
        throw Exception::Error;
    }
 }

Validate

private str ValidateProjcet(AIFProjectContract _Projcet)
{
    boolean valid = true;

    str Message = "";
    if(_Projcet.ProjectContractId() == "")
    {
        Message = Message + "ProjInvoiceProjId number is required!\n";
        valid = false;
    }
    if(!custTable::exist(_Projcet.CustomerAccountNum()))
    {
        Message = Message + "AccountNum  does not exits!\n";
        valid = false;
    }
    if(_Projcet.ProjId() == "")
    {
        Message = Message + "ProjId  is required!\n";
        valid = false;
    }
    if(_Projcet.projectName() == "")
    {
        Message = Message + "Name  is required!\n";
        valid = false;
    }
    if(_Projcet.ProjectContractId() == "")
    {
        Message = Message + "Project Contract Id  is required!\n";
        valid = false;
    }


    return Message;
}

Colling for Job



static void Job_Project(Args _args)
{



    AIFProjectContract   _AIFProjcetContract = new AIFProjectContract();
    AIFProjectService   _AIFProjcetService   = new AIFProjectService();


    _AIFProjcetContract.ProjectContractId("");
    _AIFProjcetContract.CustomerAccountNum("");
    _AIFProjcetContract.ProjId("");
    _AIFProjcetContract.FundingRulesItemIdNumber("");
    _AIFProjcetContract.ContractDescription("pramod ");
    _AIFProjcetContract.projectName("pramod ");
    _AIFProjcetContract.ProjectManager("");
    _AIFProjcetContract.ProjectController("");
    _AIFProjcetContract.SalesManager("");
    _AIFProjcetContract.Email("pramod@gmail.com");
    _AIFProjcetContract.PaymentscheduleId("");
    _AIFProjcetContract.ContractCurrencyId("SAR");
    _AIFProjcetContract.LanguageId("EN");
    _AIFProjcetContract.PaymentTermsId("");
    _AIFProjcetContract.FundingSourceId("");
    _AIFProjcetContract.startDate(1\1\2017);
    _AIFProjcetContract.EndDate(2\8\2019);
    _AIFProjcetContract.ProjectedStartDate(1\3\2017);
    _AIFProjcetContract.ProjectedEndDate(3\6\2020);
    _AIFProjcetContract.ExtensionDate(3\3\2023);
    _AIFProjcetContract.Created(9\3\2017);
    _AIFProjcetContract.ProjectGroupId("T & M-P&L");
    _AIFProjcetContract.FundingRulesPriority(1);
    _AIFProjcetContract.FundingRulesCategoryGroupId("sdss");
    _AIFProjcetContract.FundingRulesCategoryId("iuyss");
    _AIFProjcetContract.AllocationPercentage(100);


    _AIFProjcetContract.Company("");


   _AIFProjcetService.CreateAndUpdate_ProjectContract(_AIFProjcetContract);
    _AIFProjcetService.CreateAndUpdate_Project(_AIFProjcetContract);
    info(_AIFProjcetContract.ProjId());


}





Saturday, 18 February 2017

Create custom service customer details

create  custom service  customer  details  


[DataContractAttribute]

class AIFCustomerSContract

   str     accountNum;
    str     custGroup;
    str     currency;
    str     segmentId;
    str     subsegmentId;
    str     paymMode;
    str     deliveryMode;
    str     dlvTerm;
    str     PaymTerm;


[DataMemberAttribute('accountNum')]
public str accountNum(str _accountNum = accountNum)
{
    accountNum  = _accountNum;
    return  accountNum;
}


[DataMemberAttribute('Name')]
public str Name(str _Name = Name)
{
    Name  = _Name;
    return  Name;
}


[DataMemberAttribute('paymMode')]
public str paymMode(str _paymMode =paymMode)
{
    paymMode  = _paymMode;
    return  paymMode;
}


class AIFCustomerSService
{
}


AIF Customer services





[SysEntryPointAttribute(true), AifCollectionTypeAttribute('_cust',Types::Class)]
public void CreateAndUpDateCustomers(AIFCustomerSContract _cust)
{

    CustTable                   custTable;
    str                         ErrorMessage;
    DirParty                    dirParty;
    DirPartyTable               dirPartyTable;
    DirPerson                   dirperson;
    DirPersonName               dirPersonName;
    DirPartyType                partyType;


    ErrorMessage = this.ValidateCustomer(_cust);
    if(ErrorMessage != "")
    {
        throw Error(strFmtLB(ErrorMessage));
    }

    try
            changeCompany (_cust.Company())
    {
            ttsBegin;
            custTable = CustTable::find(_cust.AccountNum(), true);
            if(!custTable.RecId)  //If CustAccount is not existing the initialize
            {
                custTable.initValue();
                custTable.AccountNum            = _cust.AccountNum();
                custTable.CustGroup             = _cust.CustGroup();
                custTable.Currency              = _cust.Currency();
                custTable.PaymTermId            = _cust.PaymTerm();
                custTable.PaymMode              = _cust.PaymMode();
                custTable.PaymTermId            = _cust.PaymTerm();
                custTable.PaymMode              = _cust.PaymMode();
                custTable.SegmentId             = _cust.segmentId();
                custTable.SubsegmentId          = _cust.subsegmentId();
                custTable.dlvTerm               = _cust.dlvTerm();
                custTable.DlvMode               = _cust.DlvMode();
                custTable.LineOfBusinessId      = _cust.LineOfBusinessId();
                custTable.IdentificationNumber  = _cust.identificationNumber();
                dirParty = DirParty::constructFromCommon(custTable);
                custTable.IsIntegration     = NoYes::Yes;
                custTable.insert(_cust.PartyType(), _cust.Name());
            }
            else // For Updating existing Customer
            {
                custTable.CustGroup             = _cust.CustGroup();
                custTable.Currency              = _cust.Currency();
                custTable.PaymTermId            = _cust.PaymTerm();
                custTable.PaymMode              = _cust.PaymMode();
                custTable.PaymTermId            = _cust.PaymTerm();
                custTable.PaymMode              = _cust.PaymMode();
                custTable.SegmentId             = _cust.segmentId();
                custTable.SubsegmentId          = _cust.subsegmentId();
                custTable.dlvTerm               = _cust.dlvTerm();
                custTable.DlvMode               = _cust.DlvMode();
                custTable.LineOfBusinessId      = _cust.LineOfBusinessId();
                custTable.IdentificationNumber  = _cust.identificationNumber();
                custTable.update();
            }

            // fill Names
            if(!custTable.Party)
            {
              custTable.Party         = DirPartyTable::createNew(_cust.PartyType(), _cust.Name()).RecId;
            }

            dirPartyTable = DirPartyTable::findRec(custTable.Party, true, _cust.PartyType());
            // For Updating Person Name if the Party Type is Person.
            if (dirPartyTable.RecId && _cust.PartyType() == DirPartyType::Organization)
            {
                dirPartyTable.Name      = _cust.Name();
                dirPartyTable.NameAlias = _cust.Name();
                dirPartyTable.update();
            }
            // For Updating Person Name if the Party Type is Person.
            else if (dirPartyTable.RecId && _cust.PartyType() == DirPartyType::Person)
            {
                dirPerson = DirPerson::find(dirPartyTable.RecId,true);
                dirPerson.Name = _cust.Name();
                dirPerson.NameAlias = _cust.Name();
                dirPerson.update();

                //Update Person Name individually
                dirPersonName =  DirPersonName::find(dirPerson.RecId,true);
                [dirPersonName.FirstName, dirPersonName.MiddleName, dirPersonName.LastName] = DirPerson::splitNameParts(_cust.Name());
                dirPersonName.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
                dirPersonName.ValidFrom = DirUtility::getCurrentDateTime();
                dirPersonName.ValidTo = DateTimeUtil::maxValue();
                if (dirPersonName.validateWrite())
                {
                    dirPersonName.update();
                }
            }
        // calling  for  Customers Address
            this.CustomerAddress(_cust);

            ttsCommit;

    }
    catch (Exception::Error)
    {
        ttsAbort;
        throw Exception::Error;
    }
 }



customer address details



[SysEntryPointAttribute(true), AifCollectionTypeAttribute('_cust',Types::Class)]
public void CustomerAddress(AIFCustomerSContract _cust)
{
        CustTable                   custTable;
        NumberSeq                   numberSeq;
        str                         ErrorMessage;
        DirParty                    dirParty;
        DirPartyPostalAddressView   dirPartyPostalAddressView;
        DirPartyContactInfoView     dirPartyContactInfo;
        DirPartyTable               dirPartyTable;


             try
         {
             ttsBegin;
            custTable = CustTable::find(_cust.AccountNum(), true);
            if(!custTable.RecId)
            {
                custTable.initValue();
            }

            dirParty = DirParty::constructFromCommon(custTable);
             // Fill address
            select dirPartyPostalAddressView
            where  dirPartyPostalAddressView.IsPrimary   == NoYes::Yes
                && dirPartyPostalAddressView.CountryRegionId == _cust.CountryCode()
                && dirPartyPostalAddressView.Party == custTable.Party;


            dirPartyPostalAddressView.LocationName      = _cust.Name();
            dirPartyPostalAddressView.City              = _cust.City();
            dirPartyPostalAddressView.Street            = _cust.Street();
            dirPartyPostalAddressView.StreetNumber      = _cust.StreetNumber();
            dirPartyPostalAddressView.CountryRegionId   = _cust.CountryCode();
            dirPartyPostalAddressView.Party             = custTable.Party;

            dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);

            // Fill Phone Number
            dirPartyContactInfo.clear();
              select dirPartyContactInfo
            where dirPartyContactInfo.IsPrimary       == NoYes::Yes
                && dirPartyContactInfo.Type            == LogisticsElectronicAddressMethodType::Phone
                && dirPartyContactInfo.Party == custTable.Party;

            dirPartyContactInfo.LocationName    =_cust.Name();
            dirPartyContactInfo.Locator         =_cust.Phone();
            dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Phone;
            dirPartyContactInfo.IsPrimary       = NoYes::Yes;
            dirPartyContactInfo.Party             =custTable.Party;
            // Fill Contacts
            dirParty.createOrUpdateContactInfo(dirPartyContactInfo);

            //Fill EmailId
            dirPartyContactInfo.clear();
            select dirPartyContactInfo
            where dirPartyContactInfo.IsPrimary == NoYes::Yes
                && dirPartyContactInfo.Type     == LogisticsElectronicAddressMethodType::Email
                && dirPartyContactInfo.Party    == custTable.Party
                ;
            dirPartyContactInfo.LocationName    = _cust.Name();
            dirPartyContactInfo.Locator         = _cust.Email();
            dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Email;
            dirPartyContactInfo.IsPrimary       = NoYes::Yes;
            dirPartyContactInfo.Party           = custTable.Party;
            dirParty.createOrUpdateContactInfo(dirPartyContactInfo);
            // Marks the end of transaction.
            ttsCommit;

     }
    catch (Exception::Error)
    {
        ttsAbort;
        throw Exception::Error;
    }


}




Validate Customer

private str ValidateCustomer(AIFCustomerSContract _cust)
{

       boolean valid = true;

    str Message = "";
    if(_cust.Phone() == "")
    {
        Message = Message + "Phone number is required!\n";
        valid = false;
    }
    if(_cust.Name() == "")
    {
        Message = Message + "Name  is required!\n";
        valid = false;
    }

    if(_cust.AccountNum() == "")
    {
        Message = Message + "AccountNum  is required!\n";
        valid = false;
    }

    if(_cust.Email() == "")
    {
        Message = Message + "EmailID  is required!\n";
        valid = false;
    }

    if(_cust.CountryCode() == "")
    {
        Message = Message + "CountryCode  is required!\n";
        valid = false;
    }

    //if(!CustGroup::exist(_cust.CustGroup()))
    //{
        //Message = Message + "Customer group does not exits!\n";
        //valid = false;
    //}

    if(_cust.PartyType() == DirPartyType::None )
    {
        Message = Message + "Party Type is required!\n";
        valid = false;
    }
    return Message;
}




Calling   for job


static void  job_CustomerInsertAndUpdate(Args _args)
{


    AIFCustomerSContract      _AIFCustomerSContract = new AIFCustomerSContract();
    AIFCustomerSService _AIFCustomerSService = new AIFCustomerSService();

    _AIFCustomerSContract.AccountNum("");
    _AIFCustomerSContract.Currency("");
    _AIFCustomerSContract.CustGroup("");
    _AIFCustomerSContract.segmentId("");
    _AIFCustomerSContract.subsegmentId("");
    _AIFCustomerSContract.paymMode("");
    _AIFCustomerSContract.PaymTerm("");
    _AIFCustomerSContract.dlvTerm("");
    _AIFCustomerSContract.DlvMode("");
    _AIFCustomerSContract.lineOfBusinessId('');
    _AIFCustomerSContract.identificationNumber('');

    _AIFCustomerSContract.Name("");

    _AIFCustomerSContract.CountryCode('');
    _AIFCustomerSContract.CountryRegionId('');
    _AIFCustomerSContract.Street('');
    _AIFCustomerSContract.City('');
    _AIFCustomerSContract.Phone("");
    _AIFCustomerSContract.ZipCode("");
    _AIFCustomerSContract.Email('');
    _AIFCustomerSContract.Company("");
    _AIFCustomerSContract.PartyType(DirPartyType::Person);



    _AIFCustomerSService.CreateAndUpDateCustomers(_AIFCustomerSContract);


    info(_AIFCustomerSContract.AccountNum());





}






Friday, 21 October 2016

Form _Splitters

Form _Splitters

Example : Tutorial_from_split





Create a new form by name - pramod_Splitters

Add a new static text control  and add a new string control

set autodeclarations for both controls to Yes

Drag and drop the group control from the tutorial_form_split to the newly created form in
 between the static
 text and string edit controls

In the class declaration

public class FormRun extends ObjectRun
{
    SysFormSplitter_Y _formSplitter;
}

override init() method of the element and instantiate the sysFormSplitter_y class object

public void init()
{
    super();

     _formSplitter = new SysFormSplitter_Y(groupSplitter,StaticText,element);
}

Three important methods on the group control which will help to resize the splitters are mouseup, mousemove, mousedown

int mouseUp(int x, int y, int button, boolean ctrl, boolean shift)
{
    int ret;

    ret = super(x, y, button, ctrl, shift);

    Return _formSplitter.mouseUp(x, y, button, ctrl, shift);
}

int mouseMove(int x, int y, int button, boolean ctrl, boolean shift)
{
    int ret;

    ret = super(x, y, button, ctrl, shift);

    Return _formSplitter.mouseMove(x,y,button,ctrl,shift);
}

int mouseDown(int x, int y, int button, boolean ctrl, boolean shift)
{
    int ret;

    ret = super(x, y, button, ctrl, shift);

    Return _formSplitter.mouseDown(x, y, button, ctrl, shift);
}






Saturday, 1 October 2016

Insert method, Update method and delete method

static void insert(Args _args)
{
    //LopTable        lopTable;
    //lopTable.Age = 12;
    //lopTable.Name ="pramod";
    //lopTable.Sid = "1001";
    //lopTable.insert();
    //{
        //info("all record  insered");
    //}
   // temTable.setTmp();
 
   
    LopTable            lopTable;
    ;
   
    //
    //ttsBegin;
       //update_recordSet lopTable setting Sid="10";
    //
    //
    //
    //lopTable.Sid ="151";
    //lopTable.update();
    //ttsCommit;
    //
    //{
        //info(strFmt("All record updated"));
    //}
   
   
    //ttsBegin;
    //
    //select  forUpdate lopTable where lopTable.Sid;
    //
    //lopTable.Sid = "160";
    //lopTable.update();
    //ttsCommit;
   
    ttsBegin;
    delete_from lopTable
   
    where lopTable.Sid =="160";
    ttsCommit;
   
    {
        info(strFmt("%1",lopTable.Sid));
    }
   
   
}

Friday, 23 September 2016

Run base batch framework SendmailBatch

 Run base batch framework SendmailBatch

//Class Declaration the  class should Extend RunBaseBatch

class sendmailBatch extends RunBaseBatch
{
    Name                name;
    DialogField         dialogfield;

    #define.CurrentVersion(1)
    #define.CurrentList(1)
    #define.Version(1)
    #define.ImageSysTestProjcet(1)
    #define.MainBalance(1)
    #localmacro.CurrentList
   


        MainBalance
    #endmacro

}

the method must be overloaded in situations where a class must be selectable for a batchJournal

public boolean conGoBatchJournal()
{
    return true;
}


This  is used to populate/add the fields to Dialog

public  Object dialog()
{
    DialogRunbase    dialog =super();
    #resAppl

    dialog.addImage(#ImageSysTestProjcet);
    //dialogfield = dialog.addFieldValue(extendedTypeStr(name),MainBalance);


    return dialog;
}


This  will get the  Values form the  dialog a used to populate into Fields


public boolean GetfromDialog()
{
    mainBalance = dialogfield.value();

    return super();

}

This is  used to initialize any  variables


public  boolean init()
{
    return true;
}

Constructer

protected void new()
{
    super();
}


public container pack()
{


    return [#currentVersion,#CurrentList];
}


public void Run()
{
    SysMailer  sysmailer;
    EmployeeTable       employeeTable;
    QueryRun                qr;

    str                 mailMessage;

    InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
    permission.assert();
    try
    {
        sysmailer = new SysMailer();
        employeeTable = qr.getNo(1);

        while select  employeeTable where employeeTable.Name>= name
        {
            mailMessage =strFmt("Dear Customer, your balancein in the is%1.please call us for further query",
            employeeTable.Age);

            //sysmailer.quickSend("",
            //employeeTable.Age,"Account Age",
            //mailMessage);
            //
            info("notification Mail sent");
        }
    }
    //{
        catch(Exception::Error)
        {
            info("Error due to maill configuration.chcek and run again");
        }

    }



public boolean validate(Object _CalledFrom = null)
{

    //if(name <=0)

    return checkFailed("Error!invaild value in minimun balance field");

    return true;
}

static ClassDescription Description()
{
    return "send mail Batch";
}



server static sendmailBatch construct()
{
    return new sendmailBatch();
}


static void Main(Args args)
{
    sendmailBatch       sendmailBatch;
    sendmailBatch = sendmailBatch::construct();
    if(sendmailBatch.prompt())
        sendmailBatch.run();

}