OfxFileReader 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package OfxFileReader --version 0.1.0
                    
NuGet\Install-Package OfxFileReader -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OfxFileReader" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OfxFileReader" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="OfxFileReader" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OfxFileReader --version 0.1.0
                    
#r "nuget: OfxFileReader, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OfxFileReader@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OfxFileReader&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=OfxFileReader&version=0.1.0
                    
Install as a Cake Tool

OfxFileReader

ℹ️ Disclosure: This application was developed using AI (vibecoding).

Class library .NET 8 para leitura e parsing de arquivos OFX (Open Financial Exchange).

Suporta OFX 1.x (SGML) e OFX 2.x (XML) com detecção automática de formato.

Features

  • Parse de extratos bancários (CHECKING, SAVINGS, MONEYMRKT, CREDITLINE)
  • Parse de faturas de cartão de crédito
  • Parse de extratos de investimento (ações, fundos, opções)
  • Parse de extratos de empréstimo (com informações de escrow)
  • Suporte a múltiplos blocos <OFX> concatenados
  • Detecção automática de encoding
  • Timezones (EST, GMT, UTC, offsets customizados)
  • Valores monetários como decimal (GAAP, parênteses para negativos)
  • API síncrona e assíncrona
  • Imutabilidade — todos os modelos são record
  • Integração via IOfxReader (DI-friendly)

Instalação

dotnet add package OfxFileReader

Uso Rápido

using OfxFileReader;

var reader = new OfxReader();
var doc = reader.Read("extrato.ofx");

Console.WriteLine($"Conta: {doc.BankStatements[0].Account.AccountId}");
Console.WriteLine($"Saldo: {doc.BankStatements[0].LedgerBalance?.Amount:C}");

foreach (var t in doc.BankStatements[0].Transactions)
    Console.WriteLine($"{t.DatePosted:d} {t.Type,-12} {t.Amount,10:C} {t.Name}");

API

OfxReader

Método Descrição
Read(string filePath) Lê arquivo OFX
Read(Stream stream) Lê de stream
Read(TextReader reader) Lê de TextReader
ReadAsync(...) Versões assíncronas com CancellationToken

OfxReaderOptions

new OfxReaderOptions
{
    Encoding = Encoding.UTF8,
    StrictMode = false,
    Logger = myLogger
};

Modelos

Modelo Descrição
OfxDocument Documento raiz com header, metadata e statements
BankStatement Extrato bancário (BANKMSGSRSV1)
CreditCardStatement Fatura cartão (CREDITCARDMSGSRSV1)
InvestmentStatement Extrato investimento (INVSTMTMSGSRSV1)
LoanStatement Extrato empréstimo (LOANMSGSRSV1)
BankTransaction Transação bancária com FITID, datas, amount
Status Código de status com severidade

Message Sets Suportados

  • SIGNONMSGSRSV1 — Autenticação
  • BANKMSGSRSV1 — Banking (checking, savings, money market, credit line)
  • CREDITCARDMSGSRSV1 — Cartão de crédito
  • INVSTMTMSGSRSV1 — Investimentos (ações, fundos, opções)
  • LOANMSGSRSV1 — Empréstimos (com escrow)

Arquitetura

IOfxReader (Facade) -> HeaderParser -> SgmlOfxParser | XmlOfxParser -> Mappers -> OfxDocument
  • Strategy Pattern: SGML vs XML detectado automaticamente
  • Chain of Responsibility: Tokenizer → TreeBuilder → Mappers
  • Imutabilidade: Todos os outputs são record

Práticas Bancárias Aplicadas

  • decimal para valores monetários (nunca float/double)
  • DateTimeOffset com timezone preservado
  • FitId como chave primária de deduplicação
  • Parênteses GAAP para valores negativos: (1500.00) = -1500.00
  • Idempotência via CancellationToken seguro
  • Logging estruturado com IOfxLogger
  • Proteção XXE no parser XML

Limitações Conhecidas

  • StrictMode disponível em OfxReaderOptions mas sem efeito atual
  • Parsing de investimento via XML é limitado (recomendado usar OFX 1.x SGML)
  • Message sets não implementados: INTERXFER, WIREXFER, BILLPAY, EMAIL, TAX

Licença

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 113 7/30/2026
0.1.2 124 7/19/2026
0.1.1 100 7/19/2026
0.1.0 122 7/19/2026