pse.APIBillingServiceglobal with sharing class APIBillingService EnumsObjectTypesRelease
ObjectTypesRemove
ObjectTypesClear
Methods
generateglobal static pse.APICommonsService.BatchStatus generate(pse.APIBillingService.BillingContextGenerate bc) Generates billing events using the values in the input parameters Input Parameters
Return ValueThis 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); } releaseglobal static pse.APICommonsService.BatchStatus release(pse.APIBillingService.BillingContextRelease bc) Validates that all billing events are in an unreleased state and executes the PSA release process for the billing events specified in the input parameters. Input Parameters
Return ValueThis 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); } invoiceglobal 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 PSA invoice process for the billing events specified in the input parameters. Input Parameters
Return ValueThis 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); } recalcglobal static pse.APICommonsService.BatchStatus recalc(pse.APIBillingService.BillingContextRecalc bc) Validates whether all billing events are in an unreleased state and executes the PSA recalc process for the billing events specified in the input parameters. Input Parameters
Return ValueThis method returns a APICommonsService.BatchStatus object. combineglobal static pse.APICommonsService.BatchStatus combine(pse.APIBillingService.BillingContextCombine bc) Asynchronous process to combine unreleased billing events in the same project. Input Parameters
Return ValueThis 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. // The project has 2 billing events. We want to combine the billing events of the project. 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 m1 = [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__Milestone__c m2 = [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-M2' ]; List<pse__Billing_Event__c> beList = [SELECT Id FROM pse__Billing_Event__c WHERE pse__Project__c = :p.Id LIMIT 2]; //COMBINE pse.APIBillingService.BillingContextCombine combineContext = new pse.APIBillingService.BillingContextCombine(); combineContext.billingEventIds = new Set<Id> { beList.get(0).Id, beList.get(1).Id }; pse.APICommonsService.BatchStatus bs = pse.APIBillingService.combine(combineContext); System.assertNotEquals(null, bs.jobId); System.assertEquals('Batched', bs.status); removeglobal 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
Return ValueThis 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); } clearglobal static pse.APICommonsService.BatchStatus clear(pse.APIBillingService.BillingContextClear bc) Clears the billing data for the objects specified in the input parameters. Input Parameters
Return ValueThis 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()); } scheduleglobal static pse.APICommonsService.BatchStatus schedule(pse.APIBillingService.BillingContextSchedule bc) Schedules billing event generation using the input parameters specified. Input Parameters
Return ValueThis 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); } statusglobal static pse.APICommonsService.BatchStatus status(Id jobID) Returns the status of the job from the job's object status field. Input Parameters
Return ValueThis 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'); } fetchglobal 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
Return ValueThis 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.BillingContextGenerateglobal inherited sharing 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
pse.APIBillingService.BillingContextReleaseglobal inherited sharing 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
pse.APIBillingService.BillingContextInvoiceglobal inherited sharing 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
pse.APIBillingService.BillingContextRecalcglobal inherited sharing 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
pse.APIBillingService.BillingContextCombineglobal inherited sharing class BillingContextCombine extends APICommonsService.BatchContext A structure containing a list of IDs of unreleased billing events that we want to combine. Used as a parameter to the combine method. This class extends pse.APICommonsService.BatchContext Properties
pse.APIBillingService.BillingContextRemoveglobal inherited sharing 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
pse.APIBillingService.BillingContextClearglobal inherited sharing 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
pse.APIBillingService.BillingContextScheduleglobal inherited sharing class BillingContextSchedule extends APICommonsService.BatchContext A structure containing the criteria on which to schedule billing event generation. This class extends pse.APICommonsService.BatchContext Properties
pse.APIBillingService.BillingContextFetchglobal inherited sharing 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
pse.APIBillingService.BillingResultsglobal inherited sharing class BillingResults A structure containing a list of billing event batch containers returned by APIBillingService.fetch. Properties
pse.APIBillingService.BEBContainerglobal inherited sharing 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
pse.APIBillingService.BEContainerglobal inherited sharing 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
pse.APIBillingService.DefaultBillingGenerateHandlerglobal inherited sharing 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
beforeStartglobal void beforeStart(pse.APICommonsService.BatchContext bc) This method is called before the logic of the Start method of a batch is processed. Input Parameters
Return ValueThis 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){} afterStartglobal void afterStart(pse.APICommonsService.BatchContext bc) This method is called after the logic of the Start method of a batch is processed. Input Parameters
Return ValueThis 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){} beforeExecuteglobal 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
Return ValueThis 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){} afterExecuteglobal 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
Return ValueThis 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){} beforeFinishglobal void beforeFinish(pse.APICommonsService.BatchContext bc) This method is called before the logic of the Finish method of a batch is processed. Input Parameters
Return ValueThis 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){} getJobTypeglobal pse.APICommonsService.BatchJobType getJobType() This method must be implemented by the creator of any class that implements the iBatchCallback interface. This indicates the PSA billing process that the class is to intends to implement. These PSA billing processes all confirm that the implemented type matches their identity: Return ValueThis 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;} afterFinishglobal void afterFinish(pse.APICommonsService.BatchContext bc) This method is called after the logic of the Finish method of a batch is processed. Input Parameters
Return ValueThis 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.DefaultBillingReleaseHandlerglobal inherited sharing class DefaultBillingReleaseHandler implements APICommonsService.iBatchCallback A structure containing the methods in the iBatchCallback interface that hook into the billing Release process. See "Interface: iBatchCallback". CX_Ignore_Sharing This code is called by the PSA Billing process which operates in a without sharing context. Only the afterFinish defualt implementation does anything, and there it is appropriate to run without sharing. It is expected that this class will be extended by custom code which can declare its own sharing. This class implements the following interfaces: Methods
beforeStartglobal void beforeStart(pse.APICommonsService.BatchContext bc) This method is called before the logic of the Start method of a batch is processed. Input Parameters
Return ValueThis 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){} afterStartglobal void afterStart(pse.APICommonsService.BatchContext bc) This method is called after the logic of the Start method of a batch is processed. Input Parameters
Return ValueThis 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){} beforeExecuteglobal 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
Return ValueThis 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){} afterExecuteglobal 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
Return ValueThis 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){} beforeFinishglobal void beforeFinish(pse.APICommonsService.BatchContext bc) This method is called before the logic of the Finish method of a batch is processed. Input Parameters
Return ValueThis 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){} getJobTypeglobal pse.APICommonsService.BatchJobType getJobType() This method must be implemented by the creator of any class that implements the iBatchCallback interface. This indicates the PSA billing process that the class is to intends to implement. These PSA billing processes all confirm that the implemented type matches their identity: Return ValueThis 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;} afterFinishglobal void afterFinish(pse.APICommonsService.BatchContext bc) This method is called after the logic of the Finish method of a batch is processed. Input Parameters
Return ValueThis 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); } |