# Multi-Currency Ledger & Financial Invariant Auditor

> Static Python/SQLAlchemy financial AST scanner and multi-currency split-tender ledger auditor.

Multi-Currency Ledger & Financial Invariant Auditor is a paid AI agent skill on Agensi by Víctor Betancourt, in Finance & Accounting. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $15 (one-time purchase)
- Creator: [Víctor Betancourt](https://www.agensi.io/creators/mc3yohan)
- Category: [Finance & Accounting](https://www.agensi.io/skills/finance-accounting)
- Version: 1.0
- Last updated: 2026-11-27
- Security: scan passed (2026-11-27); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/multi-currency-ledger-financial-invariant-auditor
- Tags: finance, security, api, fintech, ledger, python, postgresql, sqlalchemy

## About this skill

Financial systems fail silently when binary floats cause rounding drift or race conditions lead to deadlocks. This skill audits Python and SQLAlchemy backends to enforce strict monetary invariants and deterministic concurrency patterns in multi-currency ledgers.

### What it does
- **AST Code Scanning** identifies high-risk `float` usage, unsafe `Decimal(float)` constructors, and incorrect SQLAlchemy column types for monetary data.
- **Multi-currency Settlement Auditing** validates JSON invoice exports to ensure conservation of value across USD, EUR, and crypto tenders while blocking split-rounding pumping.
- **Concurrency Enforcement** detects multi-row `FOR UPDATE` locks missing deterministic `ORDER BY` clauses to prevent PostgreSQL and SQLite deadlocks.
- **Schema Boundary Checks** flags internal cost, margin, and wholesale fields accidentally exposed in public or seller Pydantic/response DTOs.
- **Transaction Logic Validation** ensures duplicate SKUs are aggregated before stock checks to prevent inventory bypass exploits.

### How it works
1. **Static Analysis** runs the `scan_ledger_code.py` tool on your Python repository to detect `FIN-001` through `ERR-001` violations.
2. **Settlement Review** uses `audit_settlement.py` to process multi-currency invoice fixtures and verify rounding logic and FX conversions.
3. **DDL Implementation** applies provided PostgreSQL or SQLite schema templates that use `NUMERIC` types and identity columns.
4. **Concurrency Hardening** implements the global lock hierarchy (invoice -> payments -> products sorted by SKU) using the provided SQL references.

### Frameworks & tools
This skill is built for Python 3.10+ environments using SQLAlchemy, PostgreSQL, and SQLite WAL. It integrates with Pydantic for DTO validation and uses standard library AST parsing for zero-dependency static analysis.

### Why this beats prompting it yourself
Prompting alone often misses subtle IEEE-754 precision errors or complex row-level locking orders that lead to race conditions. This skill provides a specialized AST scanner and deterministic audit scripts that catch financial edge cases a general LLM might overlook during a standard code review.

### Use cases
- Audit a multi-currency checkout pipeline for precision loss and FX rounding errors.
- Scan a legacy SQLAlchemy codebase to migrate unsafe Float columns to Numeric.
- Harden a POS backend against deadlock errors under high concurrent load.
- Validate that internal margin data is isolated from public catalog API responses.

### Known limitations
The scanner requires Python 3.10 or higher. It only analyzes static code patterns and cannot detect runtime logic errors that occur outside the audited AST or JSON structures.

## Requires

- Python 3.10+

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Multi-Currency Ledger & Financial Invariant Auditor skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What specific financial risks does this skill address in my ledger?

This skill prevents 'silent' financial failures, such as rounding drift caused by float-based arithmetic and database deadlocks resulting from non-deterministic row locking in high-concurrency environments.

### Which database engines and Python versions are supported?

The skill is designed for Python 3.10+ environments using SQLAlchemy, with optimized schema templates for PostgreSQL and SQLite (WAL mode). While it focuses on these stacks, the AST scanning logic can be adapted for any Python-based backend.

### What exactly is included in the purchase of this skill?

You receive the specialized AST scanner (`scan_ledger_code.py`), the settlement auditor (`audit_settlement.py`), a library of SQLAlchemy/DDL schema templates, and the global lock hierarchy reference for concurrency hardening.

### How does this differ from just asking an LLM to review my financial code?

While a general LLM might overlook subtle IEEE-754 precision errors, this skill uses static analysis to catch specific violations (FIN-001 through ERR-001) that are often missed during standard manual code reviews.

### Can this skill help me prevent internal margin data from leaking to the frontend?

The skill includes a 'Schema Boundary' check that flags when sensitive internal fields—like wholesale costs or profit margins—are accidentally exposed via public Pydantic models or DTOs.

### How difficult is it to integrate these guardrails into an existing codebase?

The scanner is a static tool that integrates into your CI/CD pipeline or local development environment; simply point it at your repository to generate a report on monetary invariants and concurrency risks.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
