English
English

AI Document Processing / Rebate Statement Automation

I designed and built an end-to-end document processing workflow for a distributor that receives quarterly rebate statements from multiple commercial partners.

Details

Role:

Role:

Service:

Service:

Industry:

Overview

Walkthrough Video:

https://www.boomshare.ai/shared/01KX3V82DXR9TWGMJYJ3A6CS7M


I designed and built an end-to-end document processing workflow for a fictional distributor that receives quarterly rebate statements from multiple commercial partners.

Each partner used a different document layout. Some statements contained a single table, others included both current-period rebates and prior-period adjustments, while some arrived as scanned PDFs or PNG images. The original process required Finance to manually read every document and enter each product line into a master spreadsheet.

The automation processes every statement from a Google Drive input folder, identifies the document format, extracts the relevant fields and normalizes them into one consistent data structure.

AI is used only for document understanding and structured extraction. Financial approval is handled separately through deterministic spreadsheet formulas. If even one row or section fails validation, the entire statement is blocked and moved to a Review Queue rather than being partially loaded.

Tools Used / Stack

  • n8n — workflow orchestration and document routing

  • Mistral OCR — extraction of structured Markdown from PDFs and scanned images

  • OpenAI Information Extractor — normalization into partner-specific JSON Schemas

  • Google Drive — input, approved and review folders

  • Google Sheets — staging, validation, final tracker and audit logs

  • JSON Schema — consistent field names, data types and allowed values

  • HTML Email — end-of-run notification

The workflow was built without custom Code nodes, making its logic easier to inspect and more portable to environments such as Power Automate, SharePoint and Excel Online.

Key Features

Multi-layout document processing

The workflow supports three different partner formats:

  • Atlas: single-table statements containing current rebate rows

  • Borealis: statements containing both current-period rebates and prior-period adjustments

  • Cascade: visually different statements, including scanned files and negative values represented with parentheses

Each layout is extracted through a dedicated JSON Schema but normalized into the same final structure.

Structured AI extraction

The Information Extractor converts OCR output into consistent fields such as:

  • Statement ID

  • Partner program

  • Region

  • Claim period

  • Record type

  • Product code and name

  • Unit rebate rate

  • Units and orders

  • Rebate amount

  • Printed section totals

Enums and field descriptions constrain the extractor. For example, Atlas can only return current, while Borealis can return either current or adjustment.

Deterministic financial validation

The workflow does not ask AI whether a statement “looks correct.”

Every extracted row is written to a staging area and validated using spreadsheet formulas:

  • Units × Rebate Rate is recalculated

  • The calculated amount is compared with the printed row amount

  • Extracted row amounts are summed

  • Section totals are reconciled against the totals printed in the statement

  • Borealis current and adjustment sections are validated separately

If any row or section exceeds the configured tolerance, the entire statement is flagged.

Statement-level approval

Statements are processed conservatively:

  • Approved: all rows are loaded into the Rebate Tracker

  • Flagged: no rows are loaded, and the original file is moved to the Review Queue

  • Unknown layout: the workflow does not guess the mapping and sends the file for manual review

  • Duplicate: previously processed Statement IDs are skipped

Auditability

The solution includes:

  • Rebate Tracker for approved rows

  • Staging Rows for temporary extracted data

  • Validation for calculations, deltas and final status

  • Review Queue for flagged statements and reasons

  • Run Log for processing history

  • Processed Registry for duplicate prevention

  • Approved and Review Queue folders for the original source documents

  • Completion email sent after the entire batch has finished processing

Outcome

The final workflow was tested on a batch of 11 rebate statements containing clean documents, scanned files, adjustments, mathematical inconsistencies and an unsupported partner layout.

The run produced:

  • 11 statements processed

  • 8 statements approved

  • 3 statements flagged

  • 46 product rows loaded into the Rebate Tracker

  • 0 known invalid statements loaded

The workflow correctly identified:

  • a statement whose printed total did not reconcile with its product rows;

  • a scanned statement containing an incorrect row-level rebate amount;

  • an unsupported partner format that required manual review.

The project demonstrates how AI-assisted document extraction can be combined with deterministic controls to create a finance workflow that is efficient, explainable and auditable.

Example Document / Statement

Create a free website with Framer, the website builder loved by startups, designers and agencies.