Tuesday, 16 July 2013

Dp and Ui Builder class (employe loan report)


employee loan report:
Contract class:
 [
    DataContractAttribute,
   SysOperationContractProcessingAttribute(classStr(EmployeeLoanUIBuilder))
    // SysOperationContractProcessingAttribute(classstr(ProjHourUtilisationUIBuilder), SysOperationDataContractProcessingMode::CreateSeparateUIBuilderForEachContract)
    //SysOperationGroupAttribute('PrintOut', "@SYS12608", '2')
]
 public class EmpLoanReportContract //extends SRSReportDataProviderBase//implements SysOperationValidatable
{
    HcmPersonnelNumberId hcmPersonnelNumberId;

}
 [
    DataMemberAttribute('HcmPersonnelNumberId'),
    SysOperationLabelAttribute(literalstr("Empl ID:")),
    //SysOperationHelpTextAttribute(literalstr("@SYS67")),
    //SysOperationGroupMemberAttribute('Date'),
    SysOperationDisplayOrderAttribute('1')
]
public HcmPersonnelNumberId parmHcmPersonnelNumberId(HcmPersonnelNumberId _HcmPersonnelNumberId = hcmPersonnelNumberId)
{
    hcmPersonnelNumberId = _HcmPersonnelNumberId;
    return hcmPersonnelNumberId;
}
 Dp Class:
 [
    // SRSReportQueryAttribute(queryStr(EmpLoanReportContract)),//,NSGEmplLoansDup
     SRSReportQueryAttribute(queryStr(EmpLoans_Test)),
     SRSReportParameterAttribute(classStr(EmpLoanReportContract))
]
class EmpLoanReportDP extends SRSReportDataProviderBase
{
    EmpLoanTmp EmpLoanTmp;
    HcmPersonnelNumberId EmplId;
   // Qualification Qualification;
    //int i;
    real amount_loc;
    str preloanid;
    boolean first;
}
 private Query buildQuery( Query                   _query,
                          HcmPersonnelNumberId    _HcmPersonnelNumberId)
    {

    if(_HcmPersonnelNumberId)
        _query.dataSourceTable(tablenum(NSGLoans),1).addRange(fieldnum(NSGLoans, EmplId)).value(queryValue(EmplId));
        return _query;
     }
 [
    SRSReportDataSetAttribute(tablestr(EmpLoanTmp))
]
public EmpLoanTmp getEmpLoanTmp()
{
    select EmpLoanTmp;
    return EmpLoanTmp;
}
 private void getReportParameters()
{
    EmpLoanReportContract EmpLoanReportContract = this.parmDataContract();
    if (EmpLoanReportContract)
    {
         EmplId = EmpLoanReportContract.parmHcmPersonnelNumberId();
    }
private void insertEmpLoanTmp(HcmWorker _HcmWorker ,NSGLoans _NSGLoans)//,EMPVacationLoanDetails _EMPVacationLoanDetails)
{
    EMPVacationLoanDetails _EMPVacationLoanDetails;
    /*EmpLoanTmp.EmplId = _NSGLoans.EmplId;
    EmpLoanTmp.EmpName = _NSGLoans.EmplName();
    EmpLoanTmp.NASLoanSubType = _NSGLoans.NASLoanSubType;
    EmpLoanTmp.LoanTransId = _NSGLoans.LoanTransId;
    EmpLoanTmp.LoanDate  = _NSGLoans.LoanDate;
    EmpLoanTmp.LoanValue = _NSGLoans.LoanValue;
    EmpLoanTmp.MonthlyPayment = _NSGLoans.MonthlyPayment;
    EmpLoanTmp.RemainedValue = _NSGLoans.RemainedValue();
    EmpLoanTmp.LastPayment = _NSGLoans.LastPayment;
    EmpLoanTmp.FromMonth = _NSGLoans.FromMonth;
    EmpLoanTmp.FromYear = _NSGLoans.FromYear;*/

    while select _EMPVacationLoanDetails where_EMPVacationLoanDetails.LoanTransId == _NSGLoans.LoanTransId
    {
    EmpLoanTmp.LoanTransId = _EMPVacationLoanDetails.LoanTransId;
    EmpLoanTmp.Payment = _EMPVacationLoanDetails.Payment;
    EmpLoanTmp.DeductedValue = _EMPVacationLoanDetails.DeductedValue;
    EmpLoanTmp.DeductedMonth = _EMPVacationLoanDetails.DeductedMonth;
        EmpLoanTmp.DeductedYear = _EMPVacationLoanDetails.DeductedYear;
    EmpLoanTmp.GetmonthName = _EMPVacationLoanDetails.getmonthName();
        EmpLoanTmp.MPay = _EMPVacationLoanDetails.Payment;
        //EmpLoanTmp.LastPayment = _NSGLoans.LastPayment;
         EmpLoanTmp.LastPayment = _EMPVacationLoanDetails.Payment;
        EmpLoanTmp.EmplId = _NSGLoans.EmplId;
    EmpLoanTmp.EmpName = _NSGLoans.EmplName();
   // EmpLoanTmp.NASLoanSubType = _NSGLoans.NASLoanSubType;
      EmpLoanTmp.NASLoanSubType = _EMPVacationLoanDetails.NASLoanSubType;
    EmpLoanTmp.LoanDate  = _NSGLoans.LoanDate;
    EmpLoanTmp.LoanValue = _NSGLoans.LoanValue;
    EmpLoanTmp.MonthlyPayment = _NSGLoans.MonthlyPayment;
    EmpLoanTmp.RemainedValue = _NSGLoans.RemainedValue();

    EmpLoanTmp.FromMonth = _NSGLoans.FromMonth;
    EmpLoanTmp.FromYear = _NSGLoans.FromYear;
    //EmpLoanTmp.FromDate = _EMPVacationLoanDetails.DeductedMonth;
    EmpLoanTmp.Month = _EMPVacationLoanDetails.DeductedMonth;
    EmpLoanTmp.Year = _EMPVacationLoanDetails.DeductedYear;
   // EmpLoanTmp.AccumulatedValue = _EMPVacationLoanDetails.Payment;
   // EmpLoanTmp.AccumulatedValue = amount_loc+ _EMPVacationLoanDetails.Payment;
    amount_loc = EmpLoanTmp.AccumulatedValue;

    if(first && preloanid != EmpLoanTmp.LoanTransId)//{
        amount_loc =0;
        EmpLoanTmp.AccumulatedValue = amount_loc+ _EMPVacationLoanDetails.Payment;
       // }
  //  }
    EmpLoanTmp.RValue =  EmpLoanTmp.LoanValue-EmpLoanTmp.AccumulatedValue;
    first = true;
    preloanid = EmpLoanTmp.LoanTransId;
     EmpLoanTmp.insert();
}
    //if(amount_loc)
       // EmpLoanTmp.Payment = _EMPVacationLoanDetails.Payment + amount_loc;
    //else
       // EmpLoanTmp.Payment = amount_loc;//_EMPVacationLoanDetails.Payment;
       // amount_loc += EmpLoanTmp.Payment;
if(/*_NSGLoans.LoanTransId !=_EMPVacationLoanDetails.LoanTransId &&*/_NSGLoans.LoanTransId !=EmpLoanTmp.LoanTransId)
{
    EmpLoanTmp.EmplId = _NSGLoans.EmplId;
    EmpLoanTmp.EmpName = _NSGLoans.EmplName();
    EmpLoanTmp.NASLoanSubType = _NSGLoans.NASLoanSubType;
    EmpLoanTmp.LoanTransId = _NSGLoans.LoanTransId;
    EmpLoanTmp.LoanDate  = _NSGLoans.LoanDate;
    EmpLoanTmp.LoanValue = _NSGLoans.LoanValue;
    EmpLoanTmp.MPay = _NSGLoans.MonthlyPayment;
    EmpLoanTmp.MonthlyPayment = _NSGLoans.MonthlyPayment;
    EmpLoanTmp.RemainedValue = _NSGLoans.RemainedValue();
    EmpLoanTmp.LastPayment = _NSGLoans.LastPayment;
    EmpLoanTmp.FromMonth = _NSGLoans.FromMonth;
    EmpLoanTmp.FromYear = _NSGLoans.FromYear;
    EmpLoanTmp.AccumulatedValue = _NSGLoans.MonthlyPayment;
    EmpLoanTmp.RValue = _NSGLoans.RemainedValue();
    EmpLoanTmp.FromDate = _NSGLoans.FromMonth;
    EmpLoanTmp.Month = _NSGLoans.FromMonth;
    EmpLoanTmp.Year = _NSGLoans.FromYear;
   // EmpLoanTmp.FromDate = any2str(int2str(_NSGLoans.FromMonth) + int2str(_NSGLoans.FromYear));
    EmpLoanTmp.insert();
}
}
/*select _NSGLoans
if( _EMPVacationLoanDetails.LoanTransId == _NSGLoans.LoanTransId )
{
    while select _EMPVacationLoanDetails
    {
        EmpLoanTmp.LoanTransId = _EMPVacationLoanDetails.LoanTransId;
        EmpLoanTmp.EmplId = _NSGLoans.EmplId;
    EmpLoanTmp.EmpName = _NSGLoans.EmplName();
    EmpLoanTmp.NASLoanSubType = _NSGLoans.NASLoanSubType;
   // EmpLoanTmp.LoanTransId = _NSGLoans.LoanTransId;
    EmpLoanTmp.LoanDate  = _NSGLoans.LoanDate;
    EmpLoanTmp.LoanValue = _NSGLoans.LoanValue;
    EmpLoanTmp.MonthlyPayment = _NSGLoans.MonthlyPayment;
    EmpLoanTmp.RemainedValue = _NSGLoans.RemainedValue();
    EmpLoanTmp.LastPayment = _NSGLoans.LastPayment;
    EmpLoanTmp.FromMonth = _NSGLoans.FromMonth;
    EmpLoanTmp.FromYear = _NSGLoans.FromYear;
    EmpLoanTmp.Payment = _EMPVacationLoanDetails.Payment;
    EmpLoanTmp.DeductedValue = _EMPVacationLoanDetails.DeductedValue;
    EmpLoanTmp.DeductedMonth = _EMPVacationLoanDetails.DeductedMonth;
    EmpLoanTmp.GetmonthName = _EMPVacationLoanDetails.getmonthName();
   // EmpLoanTmp.AccumulatedValue = _EMPVacationLoanDetails.Payment;
   // EmpLoanTmp.AccumulatedValue = amount_loc+ _EMPVacationLoanDetails.Payment;
    amount_loc = EmpLoanTmp.AccumulatedValue;

    if(first && preloanid != EmpLoanTmp.LoanTransId)//{
        amount_loc =0;
        EmpLoanTmp.AccumulatedValue = amount_loc+ _EMPVacationLoanDetails.Payment;
       // }
  //  }

    first = true;
    preloanid = EmpLoanTmp.LoanTransId;
}
    //if(amount_loc)
       // EmpLoanTmp.Payment = _EMPVacationLoanDetails.Payment + amount_loc;
    //else
       // EmpLoanTmp.Payment = amount_loc;//_EMPVacationLoanDetails.Payment;
       // amount_loc += EmpLoanTmp.Payment;
}
else
    {
    EmpLoanTmp.EmplId = _NSGLoans.EmplId;
    EmpLoanTmp.EmpName = _NSGLoans.EmplName();
    EmpLoanTmp.NASLoanSubType = _NSGLoans.NASLoanSubType;
    EmpLoanTmp.LoanTransId = _NSGLoans.LoanTransId;
    EmpLoanTmp.LoanDate  = _NSGLoans.LoanDate;
    EmpLoanTmp.LoanValue = _NSGLoans.LoanValue;
    EmpLoanTmp.MonthlyPayment = _NSGLoans.MonthlyPayment;
    EmpLoanTmp.RemainedValue = _NSGLoans.RemainedValue();
    EmpLoanTmp.LastPayment = _NSGLoans.LastPayment;
    EmpLoanTmp.FromMonth = _NSGLoans.FromMonth;
    EmpLoanTmp.FromYear = _NSGLoans.FromYear;


}*/
  //  EmpLoanTmp.insert();
//}
[SysEntryPointAttribute(false)]
public void processReport()
{
    HcmWorker _HcmWorker;
    NSGLoans _NSGLoans;
    EMPVacationLoanDetails _EMPVacationLoanDetails, _EMPVacationLoanDetails_desc;
    QueryRun  queryRun;
    ;
    this.getReportParameters();
    queryRun = new QueryRun(this.buildQuery(this.parmQuery(),EmplId));
   // queryRun = new QueryRun(this.parmQuery());
    //this.getReportParameters();
   // queryRun = new QueryRun(this.buildQuery(this.parmQuery(),Qualification));
    //info(queryRun.toString());
   // _NSGLoans.EmplId = “00008″;

    while(queryRun.next())
    {
        _HcmWorker      = queryRun.get(tableNum(HcmWorker));
        _NSGLoans       = queryRun.get(tableNum(NSGLoans));

        if(EmplId)
        {
            this.insertEmpLoanTmp(_HcmWorker ,_NSGLoans);//,_EMPVacationLoanDetails);
        }
        if(!EmplId)
        {
            select firstOnly _EMPVacationLoanDetails where_EMPVacationLoanDetails.LoanTransId == _NSGLoans.LoanTransId;

            if( _NSGLoans.LoanTransId == _EMPVacationLoanDetails.LoanTransId)
            {
                select _EMPVacationLoanDetails_desc order by RecId desc where_EMPVacationLoanDetails_desc.LoanTransId == _NSGLoans.LoanTransId; //where _EMPVacationLoanDetails_desc.LoanTransId == _NSGLoans.LoanTransId;

                EmpLoanTmp.LoanTransId = _EMPVacationLoanDetails_desc.LoanTransId;
                EmpLoanTmp.Payment = _EMPVacationLoanDetails_desc.Payment;
                EmpLoanTmp.DeductedValue = _EMPVacationLoanDetails_desc.DeductedValue;
                EmpLoanTmp.DeductedMonth = _EMPVacationLoanDetails_desc.DeductedMonth;
                EmpLoanTmp.DeductedYear = _EMPVacationLoanDetails_desc.DeductedYear;
                EmpLoanTmp.Month = _EMPVacationLoanDetails_desc.DeductedMonth;
                EmpLoanTmp.Year = _EMPVacationLoanDetails_desc.DeductedYear;
                EmpLoanTmp.GetmonthName = _EMPVacationLoanDetails_desc.getmonthName();
                    EmpLoanTmp.MPay = _EMPVacationLoanDetails_desc.Payment;
                    //EmpLoanTmp.LastPayment = _NSGLoans.LastPayment;
                     EmpLoanTmp.LastPayment = _EMPVacationLoanDetails_desc.Payment;
                    EmpLoanTmp.EmplId = _NSGLoans.EmplId;
                EmpLoanTmp.EmpName = _NSGLoans.EmplName();
               // EmpLoanTmp.NASLoanSubType = _NSGLoans.NASLoanSubType;
                  EmpLoanTmp.NASLoanSubType = _EMPVacationLoanDetails_desc.NASLoanSubType;
                EmpLoanTmp.LoanDate  = _NSGLoans.LoanDate;
                EmpLoanTmp.LoanValue = _NSGLoans.LoanValue;
                EmpLoanTmp.MonthlyPayment = _NSGLoans.MonthlyPayment;
                EmpLoanTmp.RemainedValue = _NSGLoans.RemainedValue();
                EmpLoanTmp.FromMonth = _NSGLoans.FromMonth;
                EmpLoanTmp.FromYear = _NSGLoans.FromYear;
                EmpLoanTmp.FromDate = _EMPVacationLoanDetails_desc.DeductedMonth;

       // EmpLoanTmp.AccumulatedValue = _EMPVacationLoanDetails_desc.Payment;
       // EmpLoanTmp.AccumulatedValue = amount_loc+ _EMPVacationLoanDetails_desc.Payment;
        amount_loc = EmpLoanTmp.AccumulatedValue;

        if(first && preloanid != EmpLoanTmp.LoanTransId)//{
            amount_loc =0;
            EmpLoanTmp.AccumulatedValue = amount_loc+ _EMPVacationLoanDetails_desc.Payment;
           // }
      //  }
        //EmpLoanTmp.RValue =  EmpLoanTmp.LoanValue-EmpLoanTmp.AccumulatedValue;
                  EmpLoanTmp.RValue = _NSGLoans.RemainedValue();
        first = true;
        preloanid = EmpLoanTmp.LoanTransId;
                  select sum( Payment) from _EMPVacationLoanDetails_desc where_EMPVacationLoanDetails_desc.LoanTransId == _NSGLoans.LoanTransId && _EMPVacationLoanDetails_desc.EmpID == _NSGLoans.EmplId
&& _EMPVacationLoanDetails_desc.NASLoanSubType   ==  _NSGLoans.NASLoanSubType  ;
                 EmpLoanTmp.AccumulatedValue =  _EMPVacationLoanDetails_desc.Payment;
         EmpLoanTmp.insert();

          }
    else
        {
        EmpLoanTmp.EmplId = _NSGLoans.EmplId;
        EmpLoanTmp.EmpName = _NSGLoans.EmplName();
        EmpLoanTmp.NASLoanSubType = _NSGLoans.NASLoanSubType;
        EmpLoanTmp.LoanTransId = _NSGLoans.LoanTransId;
        EmpLoanTmp.LoanDate  = _NSGLoans.LoanDate;
        EmpLoanTmp.LoanValue = _NSGLoans.LoanValue;
        EmpLoanTmp.MPay = _NSGLoans.MonthlyPayment;
        EmpLoanTmp.MonthlyPayment = _NSGLoans.MonthlyPayment;
        EmpLoanTmp.RemainedValue = _NSGLoans.RemainedValue();
        EmpLoanTmp.LastPayment = _NSGLoans.LastPayment;
        EmpLoanTmp.FromMonth = _NSGLoans.FromMonth;
        EmpLoanTmp.FromYear = _NSGLoans.FromYear;
        EmpLoanTmp.AccumulatedValue = _NSGLoans.MonthlyPayment;
        EmpLoanTmp.RValue = _NSGLoans.RemainedValue();
        EmpLoanTmp.FromDate = _NSGLoans.FromMonth;
        EmpLoanTmp.Month = _NSGLoans.FromMonth;
        EmpLoanTmp.Year = _NSGLoans.FromYear;
       // EmpLoanTmp.FromDate = any2str(int2str(_NSGLoans.FromMonth) + int2str(_NSGLoans.FromYear));
        EmpLoanTmp.insert();
}
          }
        }
    //}
    }
        //EmployeeByQualTmp.doInsert();
  //}
UI Builder Class:
    class EmployeeLoanUIBuilder extends SysOperationAutomaticUIBuilder
{
    EmpLoanReportContract EmpLoanReportContract;
    DialogField dialogEmpId;
}
public void build()
{
    Dialog      dialogLocal = this.dialog();
     EmpLoanReportContract = this.dataContractObject();
    this.addDialogField(methodStr(EmpLoanReportContract,parmHcmPersonnelNumberId), EmpLoanReportContract);

}

public void getFromDialog()
{
    EmpLoanReportContract = this.dataContractObject();
    super();
}
public void initializeFields()
{
    EmpLoanReportContract = this.dataContractObject();
}

public void lookupEmplId(FormStringControl _control)
{
    Query query = new Query();
    SysTableLookup sysTablelookup;
    sysTablelookup =SysTableLookup::newParameters(tableNum(HcmWorker),_control);
    sysTablelookup.addLookupfield(fieldNum(HcmWorker,PersonnelNumber));
    sysTablelookup.addLookupMethod(“Name”);
    query.addDataSource(tableNum(HcmWorker));
   //query.dataSourceTable(tableNum(ProjCategory)).addRange(fieldNum(ProjCategory, CategoryType)).value(queryValue(ProjCategoryType::Hour));
    sysTablelookup.parmQuery(query);
    sysTablelookup.performFormLookup();
}



public void postBuild()
{
    ;
    super();
    dialogEmpId = this.bindInfo().getDialogField(this.dataContractObject(),
                         methodStr(EmpLoanReportContract,parmHcmPersonnelNumberId));
    // register override method for lookup customer
    dialogEmpId.registerOverrideMethod(methodStr(FormStringControl, lookup),methodStr(EmployeeLoanUIBuilder,lookupEmplId),this);

}
public void postRun()
{
    Dialog dialogLocal = this.dialog();
    super();
    // This method should be called in order to handle events on dialogs.
   dialogLocal.dialogForm().formRun().controlMethodOverload(false);


}

No comments:

Post a Comment