PSA Apex API Developer Reference

pse.APIBillingService

global with sharing class APIBillingService

Enums

ObjectTypesRelease

Value Description
batch Group of one or more billing events.
event Group of one or more billing event items.

ObjectTypesRemove

Value Description
batch Group of one or more billing events.
event Group of one or more billing event items.
item Billing event item.

ObjectTypesClear

Value Description
budget business objects that you can clear the billing data for.
event business objects that you can clear the billing data for.
expense business objects that you can clear the billing data for.
expense_report business objects that you can clear the billing data for.
item business objects that you can clear the billing data for.
milestone business objects that you can clear the billing data for.
misc_adj business objects that you can clear the billing data for.
timecard business objects that you can clear the billing data for.
timecard_split business objects that you can clear the billing data for.
billing_event_batch business objects that you can clear the billing data for.

Methods

generate

global static pse.APICommonsService.BatchStatus generate(pse.APIBillingService.BillingContextGenerate bc)

Generates billing events using the values in the input parameters

Input Parameters

Name Type Description
bc pse.APIBillingService.BillingContextGenerate Structure containing the criteria on which to generate billing events.

Return Value

This method returns an APICommonsService.BatchStatus object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

static void testGenerate()
  {
    pse.APIBillingService.BillingContextGenerate bcg = new pse.APIBillingService.BillingContextGenerate();
     
    pse__Region__c r = [select id, name FROM pse__Region__c where Name = 'R1'];
    pse__Practice__c h = [SELECT id FROM pse__Practice__c WHERE name = 'P1'];
    pse__Grp__c g = [SELECT id FROM pse__Grp__c WHERE name = 'G1'];
    pse__Proj__c p = [SELECT id FROM pse__Proj__c WHERE name = 'Proj1'];
     
    bcg.regionID = r.id;
    bcg.projectID = p.id;
    bcg.groupID = g.id;
    bcg.practiceID = h.id;
    bcg.includePriorPeriods = true;
    bcg.useFlexiblePeriods = true;
    bcg.cutoff = Date.Today().addDays(60);
     
    pse.APICommonsService.BatchStatus bs = pse.APIBillingService.generate(bcg);
    system.assertEquals(bs.status,'Batched');
    system.assert(bs.jobId != null);
  }

release

global static pse.APICommonsService.BatchStatus release(pse.APIBillingService.BillingContextRelease bc)

Validates that all billing events are in an unreleased state and executes the FinancialForce PSA release process for the billing events specified in the input parameters.

Input Parameters

Name Type Description
bc pse.APIBillingService.BillingContextRelease Structure containing a list of IDs of billing event belonging to unreleased billing events to be released.

Return Value

This method returns a APICommonsService.BatchStatus object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

static void testRelease()
  {
     
    pse__Proj__c p = [SELECT id,pse__Account__c FROM pse__Proj__c WHERE name = 'Proj1'];
    pse__Time_Period__c tp = [select Id, Name, pse__Start_Date__c, pse__End_Date__c from pse__Time_Period__c WHERE name = 'Perpetual'];
    pse__Milestone__c m = [select id,pse__Project__c,pse__Actual_Date__c,pse__Description__c,CurrencyIsoCode,pse__Milestone_Amount__c
        FROM pse__Milestone__c
        WHERE pse__Project__c = :p.Id
          AND Name = 'Proj1-M1'
        ];
     
    pse__Billing_Event_Batch__c beb = new pse__Billing_Event_Batch__c();
    beb.pse__Account__c = p.pse__Account__c;
    beb.pse__Time_period__c = tp.id;
    insert beb;
     
    pse__Billing_Event__c be = new pse__Billing_Event__c();
    be.pse__Billing_Event_Batch__c = beb.id;
    be.pse__Project__c = p.id;
    insert be;
     
    pse__Billing_Event_Item__c bei = new pse__Billing_Event_Item__c();
    bei.pse__Billing_Event_Batch__c = beb.id;
    bei.pse__Billing_Event__c = be.id;
    bei.pse__Object_Id__c = m.id;
    bei.pse__Milestone__c = m.id;
    bei.pse__Project__c = p.Id;
    bei.CurrencyIsoCode = m.CurrencyIsoCode;
    bei.pse__Category__c = 'Milestone';
    insert bei;
     
    m.pse__Billing_Event_Item__c = bei.Id;
    update m;
    pse.APIBillingService.BillingContextRelease bc = new pse.APIBillingService.BillingContextRelease();
    bc.ids = new set<ID>{be.Id};
    bc.objectType = pse.APIBillingService.ObjectTypesRelease.Event;
     
    pse.APICommonsService.BatchStatus bs =  pse.APIBillingService.release(bc);
  }

invoice

global static pse.APICommonsService.BatchStatus invoice(pse.APIBillingService.BillingContextInvoice bc)

Validates that all billing events specified in the input parameters are unreleased and are not invoiced and then executes the FinancialForce PSA invoice process for the billing events specified in the input parameters.

Input Parameters

Name Type Description
bc pse.APIBillingService.BillingContextInvoice Structure containing a list of invoice information for billing events that are to be invoiced.

Return Value

This method returns an APICommonsService.BatchStatus object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

static void testInvoice()
  {
    pse__Proj__c p = [SELECT id,pse__Account__c FROM pse__Proj__c WHERE name = 'Proj1'];
    pse__Time_Period__c tp = [select Id, Name, pse__Start_Date__c, pse__End_Date__c from pse__Time_Period__c WHERE name = 'Perpetual'];
    pse__Milestone__c m = [select id,pse__Project__c,pse__Actual_Date__c,pse__Description__c,CurrencyIsoCode,pse__Milestone_Amount__c
        FROM pse__Milestone__c
        WHERE pse__Project__c = :p.Id
          AND Name = 'Proj1-M1'
        ];
 
    //GENERATE
    pse__Billing_Event_Batch__c beb = new pse__Billing_Event_Batch__c();
    beb.pse__Account__c = p.pse__Account__c;
    beb.pse__Time_period__c = tp.id;
    insert beb;
 
    pse__Billing_Event__c be = new pse__Billing_Event__c();
    be.pse__Billing_Event_Batch__c = beb.id;
    be.pse__Project__c = p.id;
    insert be;
 
    pse__Billing_Event_Item__c bei = new pse__Billing_Event_Item__c();
    bei.pse__Billing_Event_Batch__c = beb.id;
    bei.pse__Billing_Event__c = be.id;
    bei.pse__Object_Id__c = m.id;
    bei.pse__Milestone__c = m.id;
    bei.pse__Project__c = p.Id;
    bei.CurrencyIsoCode = m.CurrencyIsoCode;
    bei.pse__Category__c = 'Milestone';
    insert bei;
 
    m.pse__Billing_Event_Item__c = bei.Id;
    update m;
    //RELEASE
    be.pse__Is_Released__c = true;
    update be;
 
    pse.APIBillingService.BillingContextInvoice bc = new pse.APIBillingService.BillingContextInvoice();
     
    List<pse.BillingEventsManager.InvoiceInfo> invoiceInfos = new List<pse.BillingEventsManager.InvoiceInfo>();
    pse.BillingEventsManager.InvoiceInfo invoiceInfo = new pse.BillingEventsManager.InvoiceInfo(be.Id,'10000',Date.today());
    invoiceInfos.add(invoiceInfo);
    bc.invoiceInfo = invoiceInfos;
    pse.APICommonsService.BatchStatus bs = pse.APIBillingService.invoice(bc);     
  }

recalc

global static pse.APICommonsService.BatchStatus recalc(pse.APIBillingService.BillingContextRecalc bc)

Validates whether all billing events are in an unreleased state and executes the FinancialForce PSA recalc process for the billing events specified in the input parameters.

Input Parameters

Name Type Description
bc pse.APIBillingService.BillingContextRecalc Structure containing a list of IDs of billing events belonging to unreleased billing events to recalculate billing data for.

Return Value

This method returns a APICommonsService.BatchStatus object.

remove

global static pse.APICommonsService.BatchStatus remove(pse.APIBillingService.BillingContextRemove bc)

Removes billing events using the parameters specified. This deletes unreleased billing events or billing event items belonging to unreleased billing event items depending on the input provided.

Input Parameters

Name Type Description
bc pse.APIBillingService.BillingContextRemove Structure containing a list of IDs of billing events or billing event items belonging to unreleased billing events.

Return Value

This method returns an APICommonsService.BatchStatus object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

static void testRemove()
  {
     
    pse__Proj__c p = [SELECT id,pse__Account__c FROM pse__Proj__c WHERE name = 'Proj1'];
    pse__Time_Period__c tp = [select Id, Name, pse__Start_Date__c, pse__End_Date__c from pse__Time_Period__c WHERE name = 'Perpetual'];
    pse__Milestone__c m = [select id,pse__Project__c,pse__Actual_Date__c,pse__Description__c,CurrencyIsoCode,pse__Milestone_Amount__c
        FROM pse__Milestone__c
        WHERE pse__Project__c = :p.Id
          AND Name = 'Proj1-M1'
        ];
     
    //GENERATE
    pse__Billing_Event_Batch__c beb = new pse__Billing_Event_Batch__c();
    beb.pse__Account__c = p.pse__Account__c;
    beb.pse__Time_period__c = tp.id;
    insert beb;
     
    pse__Billing_Event__c be = new pse__Billing_Event__c();
    be.pse__Billing_Event_Batch__c = beb.id;
    be.pse__Project__c = p.id;
    insert be;
     
    pse__Billing_Event_Item__c bei = new pse__Billing_Event_Item__c();
    bei.pse__Billing_Event_Batch__c = beb.id;
    bei.pse__Billing_Event__c = be.id;
    bei.pse__Object_Id__c = m.id;
    bei.pse__Milestone__c = m.id;
    bei.pse__Project__c = p.Id;
    bei.CurrencyIsoCode = m.CurrencyIsoCode;
    bei.pse__Category__c = 'Milestone';
    insert bei;
     
    m.pse__Billing_Event_Item__c = bei.Id;
    update m;
     
    pse.APIBillingService.BillingContextRemove bc = new pse.APIBillingService.BillingContextRemove();
    bc.ids = new set<ID>{be.Id};
    bc.objectType = pse.APIBillingService.ObjectTypesRemove.Event;
     
    pse.APICommonsService.BatchStatus bs =  pse.APIBillingService.remove(bc);
  }

clear

global static pse.APICommonsService.BatchStatus clear(pse.APIBillingService.BillingContextClear bc)

Clears the billing data for the objects specified in the input parameters.

Input Parameters

Name Type Description
bc pse.APIBillingService.BillingContextClear Structure containing an ID of a business record to clear billing data for and the type of object to which it belongs.

Return Value

This method returns a APICommonsService.BatchStatus object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

static void testClear()
  {
    pse__Proj__c p = [SELECT id,pse__Account__c FROM pse__Proj__c WHERE name = 'Proj1'];
    pse__Time_Period__c tp = [select Id, Name, pse__Start_Date__c, pse__End_Date__c from pse__Time_Period__c WHERE name = 'Perpetual'];
    pse__Milestone__c m = [select id,pse__Project__c,pse__Actual_Date__c,pse__Description__c,CurrencyIsoCode,pse__Milestone_Amount__c FROM pse__Milestone__c LIMIT 1];
     
    //GENERATE
    pse__Billing_Event_Batch__c beb = new pse__Billing_Event_Batch__c();
    beb.pse__Account__c = p.pse__Account__c;
    beb.pse__Time_period__c = tp.id;
    insert beb;

    pse__Billing_Event__c be = new pse__Billing_Event__c();
    be.pse__Billing_Event_Batch__c = beb.id;
    be.pse__Project__c = p.id;
    insert be;
    pse__Billing_Event_Item__c bei = new pse__Billing_Event_Item__c();
    bei.pse__Billing_Event_Batch__c = beb.id;
    bei.pse__Billing_Event__c = be.id;
    bei.pse__Object_Id__c = m.id;
    bei.pse__Milestone__c = m.id;
    bei.pse__Project__c = p.Id;
    bei.CurrencyIsoCode = m.CurrencyIsoCode;
    bei.pse__Category__c = 'Milestone';
    insert bei;

    m.pse__Billing_Event_Item__c = bei.Id;
    update m;

    //RELEASE
    be.pse__Is_Released__c = true;
    update be;

    pse.APIBillingService.BillingContextClear bc = new pse.APIBillingService.BillingContextClear();
    bc.id = be.Id;
    bc.objectType = pse.APIBillingService.ObjectTypesClear.event;

    pse.APICommonsService.BatchStatus bs =  pse.APIBillingService.clear(bc);
    system.assertEquals('',bs.errorMessage,bs.errorMessage==null ? '' : bs.errorMessage);
    system.assertEquals(bs.status,'Completed');

    list<pse__Billing_Event__c> beList = [select id from pse__Billing_Event__c WHERE ID = :be.Id];
    list<pse__Milestone__c> bmList = [SELECT id, pse__Billed__c FROM pse__Milestone__c where Id = :m.id];
    system.assert(beList.isEmpty());
    system.assert(!bmList.isEmpty());
  }

schedule

global static pse.APICommonsService.BatchStatus schedule(pse.APIBillingService.BillingContextSchedule bc)

Schedules billing event generation using the input parameters specified.

Input Parameters

Name Type Description
bc pse.APIBillingService.BillingContextSchedule Structure containing the criteria on which to schedule billing event generation.

Return Value

This method returns an APICommonsService.BatchStatus object with a status of either Error or Scheduled.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

static void testSchedule()
  {
    pse.APIBillingService.BillingContextSchedule bc = new pse.APIBillingService.BillingContextSchedule();
     
    pse__Region__c r = [select id, name FROM pse__Region__c where Name = 'R1'];
    pse__Practice__c h = [SELECT id FROM pse__Practice__c WHERE name = 'P1'];
    pse__Grp__c g = [SELECT id FROM pse__Grp__c WHERE name = 'G1'];
    pse__Proj__c p = [SELECT id FROM pse__Proj__c WHERE name = 'Proj1'];
     
    bc.regionID = r.id;
    bc.projectID = p.id;
    bc.GroupID = g.id;
    bc.practiceID = h.id;
    bc.periodOffset = 7;
    bc.includePriorPeriods = true;
    bc.useFlexiblePeriods = true;
    bc.scheduledJobName = 'PSA Billing Service Unit Test';
    Date d = Date.today();
    integer day = d.day();
    integer month = d.month()==12 ? 1 : d.month()+1;
    String cronSch = '0 0 0 ' + string.valueOf(day) + ' ' + string.valueOf(month) + ' ? *';
    bc.cronSchedule = cronSch;
     
    pse.APICommonsService.BatchStatus bs = pse.APIBillingService.Schedule(bc);
  }

status

global static pse.APICommonsService.BatchStatus status(ID jobID)

Returns the status of the job from the job's object status field.

Input Parameters

Name Type Description
jobID ID ID of the job to provide the status for.

Return Value

This method returns an APICommonsService.BatchStatus object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

static void testStatus()
  {
    pse.APIBillingService.BillingContextGenerate bcg = new pse.APIBillingService.BillingContextGenerate();
     
    pse__Region__c r = [select id, name FROM pse__Region__c where Name = 'R1'];
    pse__Practice__c h = [SELECT id FROM pse__Practice__c WHERE name = 'P1'];
    pse__Grp__c g = [SELECT id FROM pse__Grp__c WHERE name = 'G1'];
    pse__Proj__c p = [SELECT id FROM pse__Proj__c WHERE name = 'Proj1'];
     
    bcg.regionID = r.id;
    bcg.projectID = p.id;
    bcg.groupID = g.id;
    bcg.practiceID = h.id;
    bcg.includePriorPeriods = true;
    bcg.useFlexiblePeriods = true;
    bcg.cutoff = Date.Today().addDays(60);
    pse.APICommonsService.BatchStatus bs = pse.APIBillingService.generate(bcg);
     
    //Status API method
    pse.APICommonsService.BatchStatus bs2 = pse.APIBillingService.status(bs.jobID);
    system.assert(bs2.Status!='Error','Status was Error');
    system.assert(bs2.Status!=null,'Status was null');
  }

fetch

global static pse.APIBillingService.BillingResults fetch(pse.APIBillingService.BillingContextFetch bc)

Returns a list of billing event batches. The billing event batches returned are filtered depending on the values specified in the input parameters.

Input Parameters

Name Type Description
bc pse.APIBillingService.BillingContextFetch Structure containing the criteria on which to filter billing data.

Return Value

This method returns a APIBillingService.BillingResults object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

static void testFetch()
  {
    pse__Region__c r = [select id, name FROM pse__Region__c where Name = 'R1'];
    pse__Practice__c h = [SELECT id FROM pse__Practice__c WHERE name = 'P1'];
    pse__Grp__c g = [SELECT id FROM pse__Grp__c WHERE name = 'G1'];
    pse__Proj__c p = [SELECT id FROM pse__Proj__c WHERE name = 'Proj1'];
     
    //Test Fetch API method
    pse.APIBillingService.BillingContextFetch bcf = new pse.APIBillingService.BillingContextFetch();
    bcf.regionID = r.id;
    bcf.practiceID = h.id;
    bcf.groupID = g.id;
    bcf.projectID = p.id;
    bcf.isReleased = false;
    bcf.isInvoiced = false;
    bcf.isApproved = false;
     
    set<ID> beIds = new set<ID>();
    set<ID> beiIds = new set<ID>();
     
    pse.APIBillingService.BillingResults br = pse.APIBillingService.fetch(bcf);
    for (pse.APIBillingService.BEBContainer bebc : br.billingEventBatches)
      for (pse.APIBillingService.BEContainer bec : bebc.billingEvents)
      {
        beIds.add(bec.billingEvent.Id);
        for (pse__Billing_Event_Item__c i : bec.billingEventItems)
          beiIds.add(i.Id);
      } 
  }

pse.APIBillingService.BillingContextGenerate

global class BillingContextGenerate extends APICommonsService.BatchContext

A structure containing the criteria on which to generate billing events. This class/type extends pse.APICommonsService.BatchContext

This class extends pse.APICommonsService.BatchContext

Properties

Name Type Description
regionID ID ID of the region, practice or group to filter billing event generation on. You can specify any combination of one regionID, one practiceID and one groupID, but at least one regionID, practiceID or groupID must be specified. Child regions, practices and groups are included automatically.
practiceID ID ID of the region, practice or group to filter billing event generation on. You can specify any combination of one regionID, one practiceID and one groupID, but at least one regionID, practiceID or groupID must be specified. Child regions, practices and groups are included automatically.
groupID ID ID of the region, practice or group to filter billing event generation on. You can specify any combination of one regionID, one practiceID and one groupID, but at least one regionID, practiceID or groupID must be specified. Child regions, practices and groups are included automatically.
timePeriodID ID ID of the time period to generate billing events for. If useFlexiblePeriods is true, this parameter is ignored.
accountID ID ID of the account to generate billing events for.
projectID ID ID of the project to generate billing events for.
billingCalculationID ID ID of the Billing Calculation record created by the generation process.
includePriorPeriods Boolean Determines whether billing events are to be generated for all time periods prior to and including the one in timePeriodID. When false, billing events are only generated for the time period specified in timePeriodID. If useFlexiblePeriods is true, this parameter is ignored.
useFlexiblePeriods Boolean Indicates whether billing events are to be generated in flexible time period mode. When in this mode, billing events are based on the cutoff date instead of a time period. Billing events are generated for time periods that end on or before the date you specify according to the time period type for which the account or project is to be billed. All business object records are grouped into billing events based on the time period types for which the account or project is to be billed.
cutoff Date The cut-off date on which to base project and account billing events. This parameter is ignored when useFlexiblePeriods is false. This is the latest inclusive date for which billing events are to be generated. The cut-off date is compared to the Effective Date on each region, practice, group, project and account and billing events are generated based on this comparison.

pse.APIBillingService.BillingContextRelease

global class BillingContextRelease extends APICommonsService.BatchContext

A structure containing a list of IDs of billing events belonging to unreleased billing events to be released. This class/type extends APICommonsService.BatchContext.

This class extends pse.APICommonsService.BatchContext

Properties

Name Type Description
ids Set<ID> Set of billing event IDs belonging to unreleased billing events.
objectType pse.APIBillingService.ObjectTypesRelease Type of billing record being released.

pse.APIBillingService.BillingContextInvoice

global class BillingContextInvoice extends APICommonsService.BatchContext

A structure containing a list of invoice information for billing events that are to be invoiced.

This class extends pse.APICommonsService.BatchContext

Properties

Name Type Description
invoiceInfo List<pse.BillingEventsManager.InvoiceInfo> List of invoice information for billing events that are to be invoiced

pse.APIBillingService.BillingContextRecalc

global class BillingContextRecalc extends APICommonsService.BatchContext

A structure containing a list of IDs of unreleased billing events on which to recalculate billing data for. This class/type extends APICommonsService.BatchContext.

This class extends pse.APICommonsService.BatchContext

Properties

Name Type Description
billingEventIds Set<ID> Set of billing event IDs belonging to unreleased billing events.

pse.APIBillingService.BillingContextRemove

global class BillingContextRemove extends APICommonsService.BatchContext

A structure containing a list of IDs of billing records belonging to unreleased billing events to be removed.

This class extends pse.APICommonsService.BatchContext

Properties

Name Type Description
ids Set<ID> Set of billing record IDs of unreleased billing events to be removed. This must contain IDs of objects that belong to the same type. For instance, either billing event items or billing events.
objectType objectTypesRemove Type of billing record being removed.

pse.APIBillingService.BillingContextClear

global class BillingContextClear extends APICommonsService.BatchContext

A structure containing an ID of a billing record belonging to unreleased billing events to clear billing data for.

This class extends pse.APICommonsService.BatchContext

Properties

Name Type Description
id ID Deprecated: see ids
ids Set<ID> IDs of billing events, billing event items, billing event batches, timecards, timecard splits, expense reports, expenses, milestones, budgets, or miscellaneous adjustments.
objectType pse.APIBillingService.ObjectTypesClear Type of object to which the id belongs.

pse.APIBillingService.BillingContextSchedule

global class BillingContextSchedule extends APICommonsService.BatchContext

A structure containing the criteria on which to schedule billing event generation.

This class extends pse.APICommonsService.BatchContext

Properties

Name Type Description
regionID ID ID of the region, practice or group to schedule billing event generation for. At least one regionID, practiceID or groupID must be specified. If any one of these contains a null value, this means that billing events will be generated for any child regions, practices or groups.
practiceID ID ID of the region, practice or group to schedule billing event generation for. At least one regionID, practiceID or groupID must be specified. If any one of these contains a null value, this means that billing events will be generated for any child regions, practices or groups.
groupID ID ID of the region, practice or group to schedule billing event generation for. At least one regionID, practiceID or groupID must be specified. If any one of these contains a null value, this means that billing events will be generated for any child regions, practices or groups.
timePeriodID ID ID of the time period to generate billing events for. If useFlexiblePeriods is true, this parameter is ignored.
accountID ID ID of the account to generate billing events for.
projectID ID ID of the project to generate billing events for.
includePriorPeriods Boolean Determines whether billing events are to be generated for all time periods prior to the one in timePeriodID. If useFlexiblePeriods is true, this parameter is ignored.
useFlexiblePeriods Boolean Indicates whether billing events are to be generated in flexible time period mode. When true, billing events are based on the periodOffset date instead of a time period. The periodOffset determines the cut-off date relative to today's date. When false, the periodOffset indicates which time period to generate billing events for.
periodOffset Integer The offset to use to calculate the cut-off date relative to today's date when useFlexiblePeriods is true. When useFlexiblePeriods is false, this determines which time period to generate billing events for. For instance, a value of 0 generates billing events for the current time period and -1 generates billing events for the previous time period.
scheduledJobName String Name to be applied to the scheduled job
cronSchedule String String defined by Salesforce that represents the schedule used to run the job. For more information, see the Apex Scheduler topic in the Salesforce Apex Code Developer's Guide.
cronDaysParm String

pse.APIBillingService.BillingContextFetch

global class BillingContextFetch extends APICommonsService.BatchContext

A structure containing the criteria on which to filter billing data when retrieving billing event batches.

This class extends pse.APICommonsService.BatchContext

Properties

Name Type Description
regionID ID ID of the region to filter billing data on.
practiceID ID ID of the practice to filter billing data on.
groupID ID ID of the group to filter billing data on.
timePeriodID ID ID of the time period to filter billing data on.
accountID ID ID of the account to filter billing data on.
projectID ID ID of the project to filter billing data on.
isReleased Boolean If a value is specified, filters billing data based on whether it is released. When true, only records that are released are returned. When false, only records that are not released are returned. When no value is specified, records are returned regardless of whether they are released.
isInvoiced Boolean If a value is specified, filters billing data based on whether it is invoiced. When true, only records that are invoiced are returned. When false, only records that are not invoiced are returned. When no value is specified, records are returned regardless of whether they are invoiced.
isApproved Boolean If a value is specified, filters billing data based on whether it is approved. When true, only records that are approved are returned. When false, only records that are not approved are returned. When no value is specified, records are returned regardless of whether they are approved.

pse.APIBillingService.BillingResults

global class BillingResults

A structure containing a list of billing event batch containers returned by APIBillingService.fetch.

Properties

Name Type Description
billingEventBatches List<pse.APIBillingService.BEBContainer> A list of billing event batch containers.

pse.APIBillingService.BEBContainer

global class BEBContainer

A structure containing a billing event batch and a billing event container that contains the billing events for that billing event batch.

Properties

Name Type Description
billingEventBatch pse__Billing_Event_Batch__c The billing event batch.
billingEvents List<pse.APIBillingService.BEContainer> A list of billing event containers.

pse.APIBillingService.BEContainer

global class BEContainer

A structure within a BEBContainer that contains a billing event and a list of billing event items which belong to that billing event.

Properties

Name Type Description
billingEvent pse__Billing_Event__c The billing event.
billingEventItems List<pse__Billing_Event_Item__c> A list of billing event items.

pse.APIBillingService.DefaultBillingGenerateHandler

global class DefaultBillingGenerateHandler implements APICommonsService.iBatchCallback

A structure containing the methods in the iBatchCallback interface that hook into the billing Generate process. See "Interface: iBatchCallback".

This class implements the following interfaces:

Methods

beforeStart

global void beforeStart(pse.APICommonsService.BatchContext bc)

This method is called before the logic of the Start method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void beforeStart(pse.APICommonsService.BatchContext bc){} 

afterStart

global void afterStart(pse.APICommonsService.BatchContext bc)

This method is called after the logic of the Start method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void afterStart(pse.APICommonsService.BatchContext bc){}

beforeExecute

global void beforeExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope)

This method is called before the logic of the Execute method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.
scope Set<ID> Contains the IDs of the records being processed in a specific batch.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void beforeExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope){} 

afterExecute

global void afterExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope)

This method is called after the logic of the Execute method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.
scope Set<ID> Contains the IDs of the records being processed in a specific batch.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void afterExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope){} 

beforeFinish

global void beforeFinish(pse.APICommonsService.BatchContext bc)

This method is called before the logic of the Finish method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void beforeFinish(pse.APICommonsService.BatchContext bc){}

getJobType

global pse.APICommonsService.BatchJobType getJobType()

This method must be implemented by the creator of any class that implements the iBatchCallback interface. This indicates the FinancialForce PSA billing process that the class is to intends to implement. These FinancialForce PSA billing processes all confirm that the implemented type matches their identity:
• Clear
• Generate
• Invoice
• Recalc
• Release
• Remove

Return Value

This method returns an APICommonsService.BatchJobType object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global pse.APICommonsService.BatchJobType getJobType(){return pse.APICommonsService.BatchJobType.Generate;}

afterFinish

global void afterFinish(pse.APICommonsService.BatchContext bc)

This method is called after the logic of the Finish method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void afterFinish(pse.APICommonsService.BatchContext bc){
  BillingContext bbc = (BillingContext)bc;
 
  appirio_core__Config_Value__c cv = [SELECT id,appirio_core__Value__c
    FROM appirio_core__Config_Value__c
    WHERE appirio_core__Config_Option__r.Name = 'nextInvoiceNumber'
    ];
 
    Integer invNum = Integer.valueOf(cv.appirio_core__Value__c);
 
    List<pse.BillingEventsManager.InvoiceInfo> invoiceInfo = new List<pse.BillingEventsManager.InvoiceInfo>();
    for (ID id : bbc.ids)
    {
      pse.BillingEventsManager.InvoiceInfo ii = new pse.BillingEventsManager.InvoiceInfo(id,String.ValueOf(invNum),Date.today());
      invoiceInfo.add(ii);
      invNum++;
    }
    cv.appirio_core__Value__c = String.ValueOf(invNum);
    update cv;
 
    pse.APIBillingService.Invoice(invoiceInfo);
}

pse.APIBillingService.DefaultBillingReleaseHandler

global class DefaultBillingReleaseHandler implements APICommonsService.iBatchCallback

A structure containing the methods in the iBatchCallback interface that hook into the billing Release process. See "Interface: iBatchCallback".

This class implements the following interfaces:

Methods

beforeStart

global void beforeStart(pse.APICommonsService.BatchContext bc)

This method is called before the logic of the Start method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void beforeStart(pse.APICommonsService.BatchContext bc){} 

afterStart

global void afterStart(pse.APICommonsService.BatchContext bc)

This method is called after the logic of the Start method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void afterStart(pse.APICommonsService.BatchContext bc){}

beforeExecute

global void beforeExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope)

This method is called before the logic of the Execute method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.
scope Set<ID> Contains the IDs of the records being processed in a specific batch.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void beforeExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope){} 

afterExecute

global void afterExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope)

This method is called after the logic of the Execute method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.
scope Set<ID> Contains the IDs of the records being processed in a specific batch.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void afterExecute(pse.APICommonsService.BatchContext bc, Set<ID> scope){} 

beforeFinish

global void beforeFinish(pse.APICommonsService.BatchContext bc)

This method is called before the logic of the Finish method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void beforeFinish(pse.APICommonsService.BatchContext bc){}

getJobType

global pse.APICommonsService.BatchJobType getJobType()

This method must be implemented by the creator of any class that implements the iBatchCallback interface. This indicates the FinancialForce PSA billing process that the class is to intends to implement. These FinancialForce PSA billing processes all confirm that the implemented type matches their identity:
• Clear
• Generate
• Invoice
• Recalc
• Release
• Remove

Return Value

This method returns an APICommonsService.BatchJobType object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global pse.APICommonsService.BatchJobType getJobType(){return pse.APICommonsService.BatchJobType.Release;}

afterFinish

global void afterFinish(pse.APICommonsService.BatchContext bc)

This method is called after the logic of the Finish method of a batch is processed.

Input Parameters

Name Type Description
bc pse.APICommonsService.BatchContext Information about the context of the job.

Return Value

This method does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

global void afterFinish(pse.APICommonsService.BatchContext bc){
  BillingContext bbc = (BillingContext)bc;
 
  appirio_core__Config_Value__c cv = [SELECT id,appirio_core__Value__c
    FROM appirio_core__Config_Value__c
    WHERE appirio_core__Config_Option__r.Name = 'nextInvoiceNumber'
    ];
 
    Integer invNum = Integer.valueOf(cv.appirio_core__Value__c);
 
    List<pse.BillingEventsManager.InvoiceInfo> invoiceInfo = new List<pse.BillingEventsManager.InvoiceInfo>();
    for (ID id : bbc.ids)
    {
      pse.BillingEventsManager.InvoiceInfo ii = new pse.BillingEventsManager.InvoiceInfo(id,String.ValueOf(invNum),Date.today());
      invoiceInfo.add(ii);
      invNum++;
    }
    cv.appirio_core__Value__c = String.ValueOf(invNum);
    update cv;
 
    pse.APIBillingService.Invoice(invoiceInfo);
 
}
© Copyright 2009–2019 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.