Within the app,"The Reckoning," I engineered a robust automated billing engine that utilizes Asynchronous Apex Batch processing to execute high-volume, multi-step financial calculations, including assistant fee distributions, social media plan prorations, and profit-sharing credits.
Tools: APEX Controller, APEX Batch, Custom Objects
Prior to this solution, the brokerage’s monthly billing was managed through a fragmented and "chaotic" Google Sheet. This manual process required accounting staff to hand-calculate complex assistant fee splits, proration for mid-month plan changes, and various agent credits. This was not only time-consuming but also prone to human error, which directly impacted revenue and agent trust. The business required a scalable, in-platform solution capable of processing thousands of financial line items with 100% mathematical accuracy and a clear audit trail.
I developed a suite of Apex Batch Jobs within a custom billing application, "The Reckoning", to replace manual spreadsheets with programmatic precision. By leveraging batch processing, I ensured the system could handle massive data volumes such as calculating leap-year adjusted prorations and multi-agent fee splits without encountering governor limits. To enhance the user experience for the accounting team, I integrated the AsyncApexJob object into a custom UI, providing real-time progress tracking and transparent error reporting for every billing cycle.
The engine executes specialized batch classes for distinct billing categories, such as Assistant Billing and Social Media Coordination. For assistant fees, the logic identifies all assistant records and their associated agents, then dynamically calculates fee distributions based on licensure status and pre-defined split percentages. For social media billing, the system evaluates active plans against start/end dates, incorporating leap-year logic for exact daily proration, and automatically updates agent records to prevent future overcharges. In each scenario, the Batch Job autonomously locates or generates the appropriate Billing Invoice Record, creates a detailed Billing Item with descriptive metadata, and links the two for a seamless billing output. By running these processes asynchronously, the system maintains high performance while providing users with a "live" status dashboard to monitor the health and completion of each billing step run.