ReTAX

ReTAX

Case Study

5-Layer Reconciliation Engine for Tax Compliance

Overview

ReTAX is a 5-layer reconciliation engine for tax compliance. It helps finance teams match thousands of internal invoices with government eBupot documents — automatically detecting discrepancies, aggregating multiple invoices, and providing an audit trail.

This is a Proof of Concept that demonstrates the core logic and architecture — ready to be implemented for real clients.

Proof of Concept

Matching Results

From development log · 9 internal invoices + 3 eBupot

Auto Matched

85%

Strict matching · Layer 1-2

Need Review

8.7%

Fuzzy matching · Layer 3

Missing Ebupot

1.6%

Internal exists · External not found

Ghost Ebupot

1.0%

External exists · Internal not found

5-Layer Matching Engine

From actual code implementation

LAYER 0

Normalizer

Bersihkan dan standarisasi semua field referensi

normalizeNPWP() → 15-16 digit

normalizeReferenceNumber() → uppercase, no special

normalizeVendorName() → uppercase, no punctuation

LAYER 1

Exact Match

Reference + NPWP exact match, amount tolerance Rp 1.000

Confidence: 100%

Status: auto_matched

Match: reference + npwp + amount

LAYER 2

Aggregate Match

1-to-N (termin) & N-to-1 (konsolidasi) dengan subset sum

Confidence: 95% (exact) / 85% (partial)

Status: auto_matched_aggregate

Max 20 dokumen per group

LAYER 3

Fuzzy Match

Confidence scoring dengan 5 signal berbobot

NPWP: 40% (WAJIB)

Date: 25% (±7 hari)

Amount: 20% (±10%)

Reference: 15% (bonus)

Vendor Name: 15% (≥80%)

Sample Data

From development log · Nomor eBupot diblur (sensitive)

InternalExternalStatusLayerConfidence
KAxxxDOEBUPOT-2601RZV9GMATCHED1100%
ALxxxIMAEBUPOT-2601RZV9HAGGREGATE295%
APxxxNDOEBUPOT-2601RZV9IAGGREGATE285%
......REVIEW375%
Nomor eBupot & ID Internal diblur untuk menjaga kerahasiaan data

Review Queue Categories

6 kategori actionable untuk human-in-the-loop

SUGGESTED_MATCHConfidence 70-90%Approve / Reject
MISSING_EBUPOTInternal ada, External tidak ketemuUpload manual / Konfirmasi vendor
GHOST_EBUPOTExternal ada, Internal tidak ketemuCek faktur belum di-input
PARTIAL_AGGREGATEAggregate match tapi ada selisihVerifikasi termin / konsolidasi
COMPOUND_REFNomor dokumen mengandung listSplit dan assign ke multiple faktur
AMBIGUOUSMultiple possible matchesPilih match yang benar manual

Tech Stack

Frontend

Next.js 16, React 19, Tailwind CSS, shadcn/ui, Zustand

Backend

Next.js API Routes, Supabase, BullMQ, Redis

PDF Processing

pdf-parse + Tesseract.js (OCR fallback)

Security

Application-level encryption (AES-256), RLS policies

Key Takeaways

Hybrid Multi-Layer > Pure Logic — strict matching untuk auto-approve, everything else ke manual review

Smart Aggregate Detection — handles 1-to-N (termin) dan N-to-1 (konsolidasi)

Confidence Scoring Transparan — NPWP 40%, Date 25%, Amount 20%, Name 15%

Audit Trail Lengkap — setiap action tercatat (who, what, when, why)

Human-in-the-Loop — edge cases ke manual review queue

PDF Extraction — pdf-parse + Tesseract OCR fallback

Proof of Concept — core logic functional, ready for client implementation