scmc.InvoicingTaxCalculationBatchglobal with sharing class InvoicingTaxCalculationBatch implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful Enables you to calculate tax using Avalara for multiple invoices in a batch job.
Database.Batchable class. This enables you to:
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. // Retrieve the IDs of the invoices that you want to calculate tax for. List<Id> invoiceIds = new List<Id>(); List<SCMC__Invoicing__c> invoices = [SELECT Id FROM SCMC__Invoicing__c WHERE SCMC__Shipping__r.SCMC__Status__c='Shipment complete' AND SCMC__External_Tax_Status__c = 'Not Calculated']; for (SCMC__Invoicing__c invoice : invoices) { invoiceIds.add(invoice.Id); } // Create an instance of the class. SCMC.InvoicingTaxCalculationBatch taxBatch = new SCMC.InvoicingTaxCalculationBatch(); // Set the list of IDs. taxBatch.invoiceIds = invoiceIds; // Call the Database.executeBatch method with the instance // and a scope size. Id batchJobId = Database.executeBatch(taxBatch, 1); 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. // Retrieve the IDs of the invoices that you want to calculate tax for. List<Id> invoiceIds = new List<Id>(); List<SCMC__Invoicing__c> invoices = [SELECT Id FROM SCMC__Invoicing__c WHERE SCMC__Shipping__r.SCMC__Status__c='Shipment complete' AND SCMC__External_Tax_Status__c = 'Not Calculated']; for (SCMC__Invoicing__c invoice : invoices) { invoiceIds.add(invoice.Id); } // Create an instance of the class. SCMC.InvoicingTaxCalculationBatch taxBatch = new SCMC.InvoicingTaxCalculationBatch(); // Set the list of IDs. taxBatch.invoiceIds = invoiceIds; // Schedule the batch to start in 60 minutes // with a specific label and a scope. Id scheduledJobId = System.scheduleBatch(taxBatch, 'Calculate Tax for Invoices using AvaTax', 60, 1); Properties
Methods
startglobal Database.QueryLocator start(Database.BatchableContext context) Do not call this method directly. Pass the instance of the class to executeglobal void execute(Database.BatchableContext context, List<SObject> invoices) Do not call this method directly. Pass the instance of the class to finishglobal void finish(Database.BatchableContext context) Do not call this method directly. Pass the instance of the class to |