# French DGFiP FEC Tax-Audit & LME Validator (`agos/fr-fec-tax-audit-validator`) Actor

Validate French DGFiP FEC accounting files (LPF Art. A.47 A-1) & audit B2B LME payment terms (Art. L.441-10) by AGOS. Checks 18/21/22-col layouts, SIREN naming, dates, entry balance, PCG VAT/cash/suspense & DGCCRF exposure with rulesetVersion provenance.

- **URL**: https://apify.com/agos/fr-fec-tax-audit-validator.md
- **Developed by:** [Applied General Operations & Systems](https://apify.com/agos) (community)
- **Categories:** Business, AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $250.00 / 1,000 fec files validated

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## French DGFiP FEC Tax-Audit & LME Validator

Validate French accounting exports (**Fichier des Écritures Comptables — FEC**) against **DGFiP LPF Art. L.47 A / Art. A.47 A-1** and **CGI Art. 1729 D** before a tax audit, and simultaneously run a **Code de commerce Art. L.441-10 LME payment-terms audit** — in a single deterministic **Pay-Per-Event Apify Actor** built by **AGOS**.

Designed for French *experts-comptables*, ERP integrators (Sage, Cegid, Pennylane, Odoo, SAP), corporate tax teams, and AI agents (**Apify MCP-ready**).

***

### What This Actor Checks

#### 1. DGFiP FEC Tax-Audit Pre-Check (`LPF Art. A.47 A-1`)

- **Statutory Column Framing**: Validates both **18-column general accrual** (`Debit`/`Credit` or `Montant`/`Sens`) and **21/22-column BIC/BNC cash-basis** layouts, pipe (`|`) or tab delimiters, UTF-8/BOM handling, and column order.
- **DGFiP Naming Convention**: Checks `<SIREN>FEC<YYYYMMDD>.txt` structure and 9-digit **SIREN Luhn checksum**.
- **Date & Chronology Integrity**: Validates strict `YYYYMMDD` dates, leap-year calendar correctness, optional `fiscalYearStart`/`fiscalYearEnd` boundaries, `ValidDate` presence, and sequential `EcritureNum` continuity.
- **Double-Entry & Lettering Balance**: Verifies per-entry (`EcritureNum`) debit/credit equilibrium, global trial balance, and balanced lettered (`EcritureLet`) groups.
- **PCG Forensic Heuristics**: Computes a **Plan Comptable Général (PCG)** trial balance by `CompteNum` plus VAT (`4456` / `4457`), negative cash (`53x` credit days), and un-cleared suspense account (`471`) risk signals.
- **Statutory Exposure Estimate**: Estimates CGI Art. 1729 D non-compliant FEC penalty exposure (€5,000 minimum or 10% of reassessment).

#### 2. LME B2B Payment-Terms Audit (`Code de commerce Art. L.441-10`)

- Analyzes supplier (`401`) and customer (`411`) settlement delays against French statutory caps (**60 days net** / **45 days end-of-month**).
- Computes statutory late-payment interest (ECB main refinancing rate + 10 percentage points or custom rate), mandatory **€40 recovery indemnities**, and **DGCCRF** administrative fine exposure.

#### 3. Machine-Readable Provenance & `regulatoryAssessment`

Every Dataset item carries:

- `rulesetVersion`: `"dgfip-fec-a47-2026.1"`
- `jurisdiction`: `"FR"`
- `regulatoryAssessment`: standardized `assessment`, `coverageScope`, `uncheckedRequirements`, `missingInputs`, and `requiresManualReview` fields.

***

### Pay-Per-Event Pricing

Pay strictly per validated FEC file — zero monthly subscription, runs comfortably on **256 MB RAM**, with batch support up to **20 FEC files per run**.

| Billing Event | Unit Price (USD) | Description |
|---|---|---|
| `actor-start` | **$0.01** / run | Flat one-time fee charged once per Actor run |
| `fec-file-validated` | **$0.25** / file | Charged per validated French FEC file (primary event) |

> Malformed batch items missing `fecContent` are **never charged**.

***

### Example Input (Single File)

```json
{
  "fileName": "552032534FEC20251231.txt",
  "regime": "auto",
  "includeTrialBalance": true,
  "includeLmeAudit": true,
  "fecContent": "JournalCode|JournalLib|EcritureNum|EcritureDate|CompteNum|CompteLib|CompAuxNum|CompAuxLib|PieceRef|PieceDate|EcritureLib|Debit|Credit|EcritureLet|DateLet|ValidDate|Montantdevise|Idevise\nVT|Journal des ventes|VT-001|20250115|411000|Clients|CL001|Client Alpha SAS|FA-2025-001|20250115|Facture FA-2025-001|1200,00|0,00|||20250120||\nVT|Journal des ventes|VT-001|20250115|706000|Prestations de services|||FA-2025-001|20250115|Facture FA-2025-001|0,00|1000,00|||20250120||\nVT|Journal des ventes|VT-001|20250115|445710|TVA collectee|||FA-2025-001|20250115|Facture FA-2025-001|0,00|200,00|||20250120||\n"
}
```

### Example Input (Batch Mode — Up to 20 FEC Files)

```json
{
  "includeTrialBalance": true,
  "includeLmeAudit": true,
  "continueOnError": true,
  "files": [
    {
      "id": "fy-2024",
      "fileName": "552032534FEC20241231.txt",
      "fecContent": "JournalCode|JournalLib|..."
    },
    {
      "id": "fy-2025",
      "fileName": "552032534FEC20251231.txt",
      "fecContent": "JournalCode|JournalLib|..."
    }
  ]
}
```

### Example Output Record

```json
{
  "itemIndex": 0,
  "itemId": "552032534FEC20251231.txt",
  "fileName": "552032534FEC20251231.txt",
  "charged": true,
  "ok": true,
  "engine": "fr_fec",
  "rulesetVersion": "dgfip-fec-a47-2026.1",
  "jurisdiction": "FR",
  "compliant": true,
  "score": 100,
  "riskLevel": "low",
  "errorCount": 0,
  "warningCount": 0,
  "lmeCompliant": true,
  "assessment": "passed_implemented_checks",
  "requiresManualReview": false,
  "regulatoryAssessment": {
    "assessment": "passed_implemented_checks",
    "coverageScope": "offline_deterministic_rules",
    "rulesetVersion": "dgfip-fec-a47-2026.1"
  },
  "result": { "...": "Full FEC findings, trialBalance, lmeAudit & statutory exposure" }
}
```

Every run also writes a `SUMMARY` record to the default Key-Value Store containing compliance tallies, risk-level breakdown, and exact Pay-Per-Event charges.

***

### Privacy & Scope

> **Privacy & Data Retention:** When run on the Apify platform, Actor inputs (Key-Value Store) and outputs (Dataset) are stored in Apify run storage subject to Apify's platform retention policies. For stateless, zero-payload-retention processing directly at the edge, call the AGOS Direct API / Remote MCP server at `https://api.agos.tools`.

- **Deterministic pre-audit**: Complements (does not replace) official DGFiP *Test Compta Demat* and substantive voucher review.

Built and maintained by **AGOS (Applied General Operations & Systems)**.

# Actor input Schema

## `fecContent` (type: `string`):

Raw French FEC file content (pipe '|' or tab delimited, including the 18-column general or 21/22-column BIC/BNC cash header row). Used when files\[] is empty.

## `fileName` (type: `string`):

Optional DGFiP FEC filename (e.g. 552032534FEC20251231.txt) for SIREN Luhn + closing-date naming validation.

## `regime` (type: `string`):

FEC statutory column layout detection mode.

## `fiscalYearStart` (type: `string`):

Optional fiscal year start date (YYYYMMDD or YYYY-MM-DD) to detect out-of-period postings.

## `fiscalYearEnd` (type: `string`):

Optional fiscal year end date (YYYYMMDD or YYYY-MM-DD) to detect out-of-period postings.

## `includeTrialBalance` (type: `boolean`):

Compute a Plan Comptable General (PCG) trial balance grouped by CompteNum.

## `includeLmeAudit` (type: `boolean`):

Run Code de commerce Art. L.441-10 LME payment-delay audit on supplier (401) and customer (411) accounts (60d net / 45d EOM, EUR 40 recovery fees, DGCCRF exposure).

## `lmeTermMode` (type: `string`):

Statutory LME payment-term due-date baseline mode.

## `maxRows` (type: `integer`):

Maximum FEC data rows to parse per file (1 to 50000).

## `ecbRefiRatePct` (type: `number`):

Optional ECB main refinancing rate (%) used to compute statutory LME late-payment interest (ECB + 10 pts).

## `lmeAnnualInterestRatePct` (type: `number`):

Optional explicit annual late-payment interest rate (%) overriding the ECB-derived default.

## `files` (type: `array`):

Optional array of up to 20 FEC file objects to validate in a single Actor run. Each item requires { fecContent, fileName?, id?, regime?, fiscalYearStart?, fiscalYearEnd?, includeTrialBalance?, includeLmeAudit?, maxRows?, ecbRefiRatePct?, lmeAnnualInterestRatePct?, lmeTermMode? }. When non-empty, files\[] takes precedence over single-file mode.

## `continueOnError` (type: `boolean`):

In batch mode, continue validating remaining files if one entry is malformed (malformed entries are not charged).

## Actor input object example

```json
{
  "fecContent": "JournalCode|JournalLib|EcritureNum|EcritureDate|CompteNum|CompteLib|CompAuxNum|CompAuxLib|PieceRef|PieceDate|EcritureLib|Debit|Credit|EcritureLet|DateLet|ValidDate|Montantdevise|Idevise\nVT|Journal des ventes|VT-001|20250115|411000|Clients|CL001|Client Alpha SAS|FA-2025-001|20250115|Facture FA-2025-001|1200,00|0,00|||20250120||\nVT|Journal des ventes|VT-001|20250115|706000|Prestations de services|||FA-2025-001|20250115|Facture FA-2025-001|0,00|1000,00|||20250120||\nVT|Journal des ventes|VT-001|20250115|445710|TVA collectee|||FA-2025-001|20250115|Facture FA-2025-001|0,00|200,00|||20250120||\n",
  "fileName": "552032534FEC20251231.txt",
  "regime": "auto",
  "includeTrialBalance": true,
  "includeLmeAudit": true,
  "lmeTermMode": "auto",
  "maxRows": 50000,
  "continueOnError": true
}
```

# Actor output Schema

## `results` (type: `string`):

Direct API link to all structured FEC validation records in JSON format.

## `resultsCsv` (type: `string`):

Direct API link to download flattened FEC audit results in CSV format.

## `summary` (type: `string`):

Aggregate compliance counts, risk distribution, and Pay-Per-Event billing breakdown.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "fecContent": `JournalCode|JournalLib|EcritureNum|EcritureDate|CompteNum|CompteLib|CompAuxNum|CompAuxLib|PieceRef|PieceDate|EcritureLib|Debit|Credit|EcritureLet|DateLet|ValidDate|Montantdevise|Idevise
VT|Journal des ventes|VT-001|20250115|411000|Clients|CL001|Client Alpha SAS|FA-2025-001|20250115|Facture FA-2025-001|1200,00|0,00|||20250120||
VT|Journal des ventes|VT-001|20250115|706000|Prestations de services|||FA-2025-001|20250115|Facture FA-2025-001|0,00|1000,00|||20250120||
VT|Journal des ventes|VT-001|20250115|445710|TVA collectee|||FA-2025-001|20250115|Facture FA-2025-001|0,00|200,00|||20250120||`,
    "fileName": "552032534FEC20251231.txt",
    "regime": "auto"
};

// Run the Actor and wait for it to finish
const run = await client.actor("agos/fr-fec-tax-audit-validator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "fecContent": """JournalCode|JournalLib|EcritureNum|EcritureDate|CompteNum|CompteLib|CompAuxNum|CompAuxLib|PieceRef|PieceDate|EcritureLib|Debit|Credit|EcritureLet|DateLet|ValidDate|Montantdevise|Idevise
VT|Journal des ventes|VT-001|20250115|411000|Clients|CL001|Client Alpha SAS|FA-2025-001|20250115|Facture FA-2025-001|1200,00|0,00|||20250120||
VT|Journal des ventes|VT-001|20250115|706000|Prestations de services|||FA-2025-001|20250115|Facture FA-2025-001|0,00|1000,00|||20250120||
VT|Journal des ventes|VT-001|20250115|445710|TVA collectee|||FA-2025-001|20250115|Facture FA-2025-001|0,00|200,00|||20250120||
""",
    "fileName": "552032534FEC20251231.txt",
    "regime": "auto",
}

# Run the Actor and wait for it to finish
run = client.actor("agos/fr-fec-tax-audit-validator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "fecContent": "JournalCode|JournalLib|EcritureNum|EcritureDate|CompteNum|CompteLib|CompAuxNum|CompAuxLib|PieceRef|PieceDate|EcritureLib|Debit|Credit|EcritureLet|DateLet|ValidDate|Montantdevise|Idevise\\nVT|Journal des ventes|VT-001|20250115|411000|Clients|CL001|Client Alpha SAS|FA-2025-001|20250115|Facture FA-2025-001|1200,00|0,00|||20250120||\\nVT|Journal des ventes|VT-001|20250115|706000|Prestations de services|||FA-2025-001|20250115|Facture FA-2025-001|0,00|1000,00|||20250120||\\nVT|Journal des ventes|VT-001|20250115|445710|TVA collectee|||FA-2025-001|20250115|Facture FA-2025-001|0,00|200,00|||20250120||\\n",
  "fileName": "552032534FEC20251231.txt",
  "regime": "auto"
}' |
apify call agos/fr-fec-tax-audit-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,agos/fr-fec-tax-audit-validator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/vDmVv3nJWsgIicyM8/builds/L5jhHqyqJsvla2T86/openapi.json
