Generate subtotal lines for grouped items on schedule

Recipe ToolsDatabaseDeveloper Tool

What it does

When a scheduled interval triggers, this automation retrieves item groups from a collection and builds a table. Custom Ruby code then inserts subtotal rows after each group and verifies the updated structure.

Who it's for

Finance teams who need to automatically organize and subtotal grouped line items in batch operations.

How teams use this

Automate invoice line item subtotals

Run this automation on a schedule to insert subtotal rows after each product category on invoices. The table structure updates automatically without manual grouping or calculation.

Batch process purchase order groups

Apply this automation to purchase orders so subtotals appear after each vendor or department group. The scheduled run keeps all POs formatted consistently.

Add custom subtotal formulas

Extend the Ruby code to include weighted averages, tax calculations, or discount logic in the subtotal rows. Only the code block needs to change to add these formulas.

How it works

  1. Run on a specified interval. This automation runs on a schedule you set, such as daily or weekly, to process item groups and insert subtotals.
  2. Query and create table from collection. Smart List retrieves item groups from the collection and builds a table structure to hold the data and new subtotal rows.
  3. Insert subtotal rows into table. Smart List adds subtotal line items at the end of each group within the table based on the grouped data structure.
  4. Execute Ruby code for subtotals. Custom Ruby code processes the grouped items, calculates subtotals, positions the subtotal lines at correct locations, and verifies the final table.