Repository avatar
Security
v1.0.0
active

nbrain-egypt-eta

io.github.NBrain-Studio/nbrain-egypt-eta

Egyptian Tax Authority (ETA) E-Invoice & E-Receipt canonicalization, SHA-256 UUID & EGP VAT/WHT MCP

Documentation

nbrain-egypt-eta — Egyptian Tax Authority (ETA) E-Invoice & E-Receipt Engine + MCP Server

Engineered by Eng. Nadeem Mohamed Badr El-Din at NBrain (منظومة إن برين — nbra.in).

nbrain-egypt-eta is a zero-dependency, deterministic Python SDK, CLI, and Model Context Protocol (MCP) server implementing the official Egyptian Tax Authority (مصلحة الضرائب المصرية — sdk.invoicing.eta.gov.eg) specifications for B2B E-Invoices v1.0 and B2C E-Receipts v1.2:

  • Official ETA Recursive Uppercase Serialization: Implements the exact sdk.invoicing.eta.gov.eg Document Serialization Approach (culture-invariant uppercase property framing, verbatim numeric/Decimal preservation so "0.0" never drifts, and repeated "ARRAYNAME""ARRAYNAME"<element> array prefixing).
  • CAdES-BES Hash & 64-Hex E-Receipt UUID Generation: Strips signatures (for B2B E-Invoices) or header.uuid (for B2C E-Receipts) and computes the exact UTF-8 SHA-256 digest.
  • Sequential POS previousUUID Chain Verification: Audits multi-receipt B2C POS batches for broken cryptographic links.
  • Zero-Drift Decimal Egyptian Tax Arithmetic (EGP): Standard 14% VAT (T1), Table Tax (T2/T3), and Withholding Tax (T4 — الخصم والتحصيل تحت حساب الضريبة at 1%, 3%, 5% deducted strictly from net amount).
  • Egyptian 9-Digit Tax Registration Number (RIN) Validator: Validates XXX-XXX-XXX / 9-digit corporate RIN identifiers.
  • Built-in MCP JSON-RPC 2.0 Server (nbrain-egypt-eta-mcp): Ready for Claude Desktop, Cursor, VS Code, Windsurf, and Google Antigravity.

Try Live in Browser (Zero Signup)

Quick Usage

from nbrain_egypt_eta import (
    serialize_eta_document,
    compute_eta_sha256_uuid,
    calculate_egypt_vat_and_wht,
    validate_egypt_rin,
)

raw_json = '''{
  "header": {"dateTimeIssued": "2026-12-06T10:00:00Z", "receiptNumber": "R-001", "uuid": ""},
  "seller": {"rin": "123456789", "companyTradeName": "NBrain Egypt"},
  "taxableItems": [
    {"taxType": "T1", "amount": 140.00, "subType": "V009", "rate": 14}
  ],
  "totalAmount": 1140.00
}'''

res = compute_eta_sha256_uuid(raw_json, mode="ereceipt")
print("Canonical:", res["canonical_string"])
print("64-Hex UUID:", res["sha256_hex"])

tax = calculate_egypt_vat_and_wht("1000.00", vat_rate="14", wht_rate="3")
print(tax)  # net=1000.00, vat=140.00, wht=30.00, payable=1110.00 EGP

Run Tests

PYTHONPATH=src python -m unittest discover -s tests -v

Citation & Author

Supply-Chain Verified Installation

pip install "git+https://github.com/NBrain-Studio/nbrain-egypt-eta.git@v1.0.0"
docker run -i --rm ghcr.io/nbrain-studio/nbrain-egypt-eta:1.0.0