在使用构造函数调度apex类时

时间:2016-10-25 06:22:31

标签: apex

请帮我预定课程代码。

Public class HFCRecord {
    public EMI__c acct ;

list<Detailed_Payment_Schedule__c> lst = new       list<Detailed_Payment_Schedule__c>();
      public integer NoOfdays{get;set;}
      public HFCRecord(ApexPages.StandardController stdController) {
        this.acct = (EMI__c )stdController.getRecord();
        Id emiId= acct.Id; 

lst = [select id,Payment_Received_Date__c,Clearance__c,Date__c,Net_Payment__c from Detailed_Payment_Schedule__c where EMI_EQI__c =: emiId  order by Payment_Received_Date__c  Desc];
        system.debug('valis'+lst );
           }
    public PageReference  updateEMI() {
    integer i = 0;
    integer da = 0;
    integer dab = 0;
    integer dac = 0;
    integer dad = 0;
    integer  TotalNoOfDays = 360;

        for(Detailed_Payment_Schedule__c d : lst ){

if(d.Clearance__c == true )acct.Last_Payment_Date__c = d.Payment_Received_Date__c;
if(d.Clearance__c == false && d.Date__c <= system.today())i+=1;
if(d.Clearance__c == false && d.Date__c <= system.today())da+=integer.valueOf(d.Net_Payment__c);
if(d.Clearance__c == True && d.Date__c <= system.today())dab+=integer.valueOf(d.Net_Payment__c);
if(d.Clearance__c == False && d.Date__c.day() <= system.today().day()){

       dac+=integer.valueOf(d.Net_Payment__c);
       NoOfdays = (d.Date__c.day() - System.today().day());
       acct.Penal_Charge__c = ((d.Net_Payment__c*(24/100)*1000/TotalNoOfDays)*NoOfdays);
       }
                        }
    system.debug('valisssdf'+i);
    acct.No_of_EMI_Overdue__c = i;
    acct.Overdue_Amount__c = da;
    acct.Amount_Collected__c= dab;
    acct.Penal_Charge__c = dac;
    acct.Total_Amount_Overdue__c = (acct.Penal_Charge__c +           acct.Overdue_Amount__c);
    update acct;
    PageReference pgref = new PageReference('/'+acct.id);
    pgref.setRedirect(true);
    return pgref;

    }
}

1 个答案:

答案 0 :(得分:0)

为了在Salesforce中安排顶级代码,您需要一个实现&#39; Schedulable&#39;的全局类。接口。然后,您可以通过UI(Setup-&gt; Apex Classes)或匿名顶点安排它。示例代码如下:

global class Schedulable_ClassExample implements Schedulable {
    global void execute(SchedulableContext SC) {
         HFCRecord hfcRecord = new HFCRecord();
         hfcRecord.DoStuff();
    }
}