ClaimProcessingExt
Below is a detailed documentation for the ClaimProcessingExt.cls Apex class. This class is a controller extension used in Salesforce for processing claims. It handles operations related to retrieving claim details, processing system and item records, creating pricing requests, applying replacement and repair cost bundles, and even generating technician payment records when certain tests are performed. The class interacts with several custom objects such as Order__c, Systems__c, Item__c, Pricing_Request__c, System_Replacement_Cost__c, SystemRepairCost__c, and more.
Happy reading! 🚀📄
Table of Contents
- Introduction
- Class Overview
- Methods and Remote Actions
- Usage Examples
- Notes and Considerations
- Test Method
- Conclusion
Introduction
The ClaimProcessingExt class is designed to aid in the claim processing workflow. It performs a multitude of tasks including:
- Retrieving & formatting claim details from the Order__c object.
- Collecting information about systems (via Systems__c) and items (via Item__c and Item_Component__c).
- Managing tax rate calculations based on claim properties.
- Handling part pricing requests to determine replacement or repair costs.
- Bulk creation of pricing requests as well as repair / replacement cost records.
- Processing technician test payments based on tests performed.
All these functionalities help ensure that the claims are processed with up-to-date pricing and cost data, and that the technicians or inspectors get the correct payment for their work. 😃
Class Overview
Properties
The class defines several public properties that store claim details, system and item records, pricing rates, URLs, and flags indicating specific claim conditions. Here’s a summary:
| Property | Type | Description |
|---|---|---|
pics |
List<Files__c> |
A list of file records (likely images) associated with the claim. |
systems |
List<Systems__c> |
Collection of system records linked to the claim (e.g., HVAC systems). |
items |
List<Item__c> |
Collection of item records for the claim, which can have associated components. |
systemIds |
List<String> |
A list of system record IDs. |
claim |
Order__c |
The primary claim record. |
claimId / claimNum |
String |
The unique identifiers and human-readable claim number. |
baseURL |
String |
The base URL of the Salesforce organization, computed at runtime. |
isOneSystem |
Boolean |
Flag indicating if only one system is associated with the claim. |
isCaliforniaClaim |
Boolean |
Flag for claims from California (affects tax and processing rules). |
isNewWayClaim |
Boolean |
Flag to indicate if the appointment exists, hinting at newer processing methods. |
isFarmers |
Boolean |
Flag checking if the client account is Farmers Insurance. |
technicianCheckoutComments |
String |
HTML-formatted string containing technician and inspector checkout notes. |
itemComments |
String |
HTML-formatted string with detailed item comments, including component-level details. |
laborRate, laborTaxRate |
Double |
Labor rates and tax multipliers computed based on the claim details. |
laborRepairTaxRate / partTaxRate |
Double |
Similar multipliers used specifically for repair labor and parts respectively. |
Constructors
There are two constructors in the class:
-
Standard Controller Constructor
public ClaimProcessingExt(ApexPages.StandardController stdController) { ... }- Purpose:
This constructor is invoked when the controller extension is used with anApexPages.StandardController. It:- Retrieves the Order__c record (claim) from the standard controller.
- Performs a SOQL query to fetch additional claim details such as Labor_Rate__c, State_Sales_Tax__c, and Technician_Checkout_Notes__c.
- Determines applicable tax multipliers. For example, if taxes are applied to labor or if the claim is in NC.
- Checks if any associated Appointment__c exists to flag the claim as a “new way claim.”
- Queries associated Systems__c and Item__c records, building an HTML summary of comments using data from both items and their components.
- Supports optional “limit” parameters to restrict the number of systems processed (useful for pagination).
- Purpose:
-
Large Loss Processing Controller Constructor
public ClaimProcessingExt(LargeLossProcessingController stdController) { ... }- Purpose:
This constructor accepts a different controller type and is focused on setting labor and tax rate details for larger loss claims.
- Purpose:
Methods and Remote Actions
The ClaimProcessingExt class contains a mix of instance methods and @RemoteAction methods.
Instance Methods
These methods update the records stored in the controller:
-
updateSystemInformation()
Updates any changes made to the list of system records (systems).
Usage:public void updateSystemInformation() { try { update systems; } catch (Exception ex) { System.debug(ex.getStackTraceString()); } } -
updateItemInformation()
Commits changes made to the item records (items) back to the database.
Usage:public void updateItemInformation() { try { update items; } catch (Exception ex) { System.debug(ex.getStackTraceString()); } }
Remote Action Methods
These methods are marked with the @RemoteAction annotation so they can be called from JavaScript via remoting. They serve a variety of functions:
| Method Name | Parameters | Purpose |
|---|---|---|
submitPartPricingRequest |
systemId, part, partNumber, partPrice, partSource, partNotes, partType | Creates a pricing request for a specified part on a particular system. The request’s status is set to "Completed", and it is automatically marked as complete. This is useful when processing pricing information for parts that need to be replaced. |
createPartPricingRequestFull |
systemId, part, notes, partType | Creates a pricing request record with the status "Submitted" (in a full pricing request context). |
createPartPricingRequest (bulk version) |
needPricing (List), partNotes (List) | Bulk creation of part pricing requests. It loops through a list of system/part info strings, retrieves related system details, and creates pricing requests accordingly. |
createReplacementCosts |
costs (List<System_Replacement_Cost__c>), deleteExisting, systemId | Inserts System Replacement Cost records. If deleteExisting is true, it first removes all existing replacement cost records for the given system. |
createRepairCosts |
costs (List<SystemRepairCost__c>), deleteExisting, systemId | Inserts System Repair Cost records, optionally deleting any pre-existing repair cost records if specified. |
createRepairandReplaceCosts |
repairCosts (List<SystemRepairCost__c>), replaceCosts (List<System_Replacement_Cost__c>), deleteExisting, systemId | Simultaneously creates both repair and replacement cost records. When deleteExisting is true, previously existing records for the system are cleared first. |
createReplace |
sysIds, hours, costs, name | Creates replacement cost records for each system ID provided. It splits a string of system IDs and creates a record for each, setting labor hours, parts cost, and a description/name. |
loadReplacementPricingBundlesBySystems |
claimId, startNum, endNum | Loads replacement pricing bundles for a specified subset (based on start and end indices) of systems associated with the claim. It calculates applicable bundle details (based on brand, tonnage, system type, and refrigerant type), then creates replacement cost records accordingly. Returns a message summarizing the bundle names or indicating if no bundle was found. |
loadReplacementPricingBundles |
claimId | Similar to the previous method, but applies to all systems related to the claim. |
createRepair |
sysIds, hours, costs, name | Creates repair cost records. It loops over the provided system IDs and creates a repair cost record using the passed labor hours, part cost, and description. |
createTechnicianTestPayments |
testsPerformed (List), claimId | When a technician performs certain tests, this method: |
- Checks for existing technician payment records.
- Cancels a payment if a test was not actually performed.
- Creates new payment requests for tests that lack a payment record.
It uses helper utility classes (e.g., CCGUtil, InvoiceUtil) to determine payment amounts and invoicing options. This ensures technicians are paid only for tests they have performed. |
| createRepairandBundles | sysIds, hours, costs, name | Combines the creation of repair costs with an application of repair bundles. It uses system details (like tonnage and system type) to look up a relevant bundle and then, based on connector definitions within that bundle, creates both primary and secondary repair cost records. This is particularly useful when a repair action spans multiple bundled parts. |
Helper Methods
-
createRequest
A private helper method used by the pricing request remote actions. It constructs a Pricing_Request__c record based on:- The system details retrieved from the Systems__c record.
- The type of part (e.g., Air Handler, Indoor, Outdoor), which determines which set of fields (age, brand, model, SEER, tonnage) should be populated.
- Additionally, if a related System_Part__c record exists, its type is updated accordingly.
Example snippet:
private static Pricing_Request__c createRequest(String systemId, String part, String partType) { Pricing_Request__c request = new Pricing_Request__c(); // Query the system record with detailed fields Systems__c sys = [Select Id, Name, Order__c, System_Year__c, System_Brand__c, System_Type__c, ... from Systems__c where Id =: systemId limit 1]; request.Part__c = part; request.Type__c = sys.System_Type__c; if (partType == 'Air Handler') { request.Part_Type__c = 'Air Handler'; // Assign Air Handler specific fields request.Age__c = sys.Air_Handler_Age__c; ... } else if (partType == 'Indoor') { request.Part_Type__c = 'Indoor'; // Assign Indoor Unit specific fields request.Age__c = sys.Indoor_System_Year__c; ... } else { // Defaulting to Outdoor request.Part_Type__c = 'Outdoor'; request.Age__c = sys.System_Year__c; ... } return request; } -
runTest
A simple method that is called during test execution (checked byTest.isRunningTest()). It does some iterative arithmetic which helps satisfy code coverage requirements without affecting production logic.
Usage Examples
Here are a few examples of how this class might be utilized in a Visualforce page or via JavaScript remoting:
Example 1: Instantiating the Controller
If your Visualforce page uses a standard controller, the instantiation would be similar to:
<apex:page standardController="Order__c" extensions="ClaimProcessingExt">
<!-- Visualforce Page Markup -->
</apex:page>
Example 2: Calling a Remote Action for Part Pricing Request
Using JavaScript remoting, you might call:
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ClaimProcessingExt.submitPartPricingRequest}',
systemId, part, partNumber, partPrice, partSource, partNotes, partType,
function(result, event) {
if (event.status) {
console.log('Part pricing request submitted successfully!');
} else {
console.error(event.message);
}
}
);
Example 3: Bulk Creation of Pricing Requests
let systemsInfo = ['sysId1:PartA', 'sysId2:PartB'];
let notes = ['Note for PartA', 'Note for PartB'];
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ClaimProcessingExt.createPartPricingRequest}',
systemsInfo,
notes,
function(result, event) {
if (event.status) {
console.log('Bulk pricing requests created!');
} else {
console.error(event.message);
}
}
);
Notes and Considerations
-
Error Handling:
Most data modifications (updates/inserts) are wrapped in try-catch blocks. Any exceptions are logged to the debug log usingSystem.debug(ex.getStackTraceString()). -
Conditional Logic:
The class checks for conditions such as:- Tax Calculations: Determines labor and repair tax rates based on state tax percentages and conditions (e.g., claims in NC or CA).
- Claim Specifics: For example, checking if the client account is "Farmers Insurance" or verifying whether a claim qualifies as a “new way claim” based on the existence of an appointment record.
-
Bundle Processing:
Several methods (e.g.,loadReplacementPricingBundles,createRepairandBundles) rely on matching system attributes (brand, tonnage, subtype, refrigerant type) with predefined bundles. The code even normalizes some brands (e.g., treating "Bryant" or "Payne" as "Carrier") to ensure accurate bundle retrieval. ⚙️ -
Test Mode:
The staticrunTest()method gets called when the system is running tests (Test.isRunningTest()), ensuring the test coverage is satisfied without executing production logic. -
Utility Classes:
The code refers to external utility classes such as CCGUtil and InvoiceUtil for payment-related constants and invoicing options. Ensure these utilities are available for full functionality.
Test Method
The method named runTest() is a simple internal routine that performs a series of arithmetic operations. It is included to contribute toward code coverage when tests are running:
public static void runTest() {
Integer i = 0;
// A simple loop that increments "i" multiple times
i++; i++; i++; // ... repeated operations
}
This method does not affect any business logic and is solely used during testing.
Conclusion
The ClaimProcessingExt class is a robust and versatile tool for managing claim processing tasks in Salesforce. It covers:
- Detailed retrieval and formatting of claim, system, and item data.
- Calculation and assignment of tax and labor rates.
- Submission and processing of pricing requests for part replacements.
- Creation of repair and replacement cost records, including handling bundled repairs.
- Validation and creation of technician payment records based on test results.
By centralizing these functionalities into a single controller extension, the class helps streamline the claim processing workflow and ensures data integrity across multiple custom objects.
We hope this documentation helps you understand and maintain the code more effectively. Happy coding! 😊🚀