AI Systems

AI Document Processing / Rebate Statement Automation

A controlled document-processing workflow that turns inconsistent rebate statements into validated, audit-ready finance data.

n8nMistral OCROpenAIGoogle SheetsJSON Schema
n8n workflow for processing rebate statements

At a glance

The system, briefly.

Problem

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

Solution

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.

Role

Automation Architect · AI Workflow Developer

Stack

n8n · Mistral OCR · OpenAI · Google Sheets · JSON Schema

Industry

Finance · Distribution

Outcome

11 statements processed, 46 approved product rows loaded, and zero known invalid statements admitted.

01

Overview

Overview

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.

02

Stack

Tools Used / Stack

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.

  • 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
03

System detail

Multi-layout document processing

The workflow supports three different partner formats:

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

  • 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
04

System detail

Structured AI extraction

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

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

  • Statement ID
  • Partner program
  • Region
  • Claim period
  • Record type
  • Product code and name
  • Unit rebate rate
  • Units and orders
  • Rebate amount
  • Printed section totals
05

System detail

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:

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

  • 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
06

System detail

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
07

System detail

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
08

Outcome

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:

The workflow correctly identified:

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.

  • 11 statements processed
  • 8 statements approved
  • 3 statements flagged
  • 46 product rows loaded into the Rebate Tracker
  • 0 known invalid statements loaded
  • 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.

System views

Inside the build.

01 frames
Example rebate statement processed by the workflow
Example rebate statement processed by the workflow01

Walkthrough

See the workflow in motion.

Outcome

11 statements processed, 46 approved product rows loaded, and zero known invalid statements admitted.

Related sector solutions

Apply these components to a real business process.

Next project

Vellòria