ofx

package module
v0.0.0-...-72bc8c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2016 License: MIT Imports: 11 Imported by: 0

README

OFX Build Status GoDoc

Open Financial Exchange (OFX) response reader in go. Compatible with OFX / QFX(Intuit) versions 1.02, 1.03 and 1.06.

Response Services

  • Sign On
  • Banking
  • Credit Card
  • Payments
  • Investments

Example

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/luizbranco/ofx"
)

func main() {
	log.SetFlags(0)
	for _, a := range os.Args[1:] {
		f, err := os.Open(a)
		if err != nil {
			log.Fatalf("error reading file %s, %s", a, err)
		}
		t, err := ofx.Parse(f)
		if err != nil {
			log.Fatalf("error parsing file %s, %s", a, err)
		}
		fmt.Printf("%s", t)
	}
}
go run main.go example.ofx

TODO (Contributions welcomed)

  • Add more samples from different banks
  • Match OFX type specs for each element

Documentation

Index

Constants

View Source
const (
	AED Currency = "AED" // United Arab Emirates Dirham
	AFN          = "AFN" // Afghanistan Afghani
	ALL          = "ALL" // Albania Lek
	AMD          = "AMD" // Armenia Dram
	ANG          = "ANG" // Netherlands Antilles Guilder
	AOA          = "AOA" // Angola Kwanza
	ARS          = "ARS" // Argentina Peso
	AUD          = "AUD" // Australia Dollar
	AWG          = "AWG" // Aruba Guilder
	AZN          = "AZN" // Azerbaijan New Manat
	BAM          = "BAM" // Bosnia and Herzegovina Convertible Marka
	BBD          = "BBD" // Barbados Dollar
	BDT          = "BDT" // Bangladesh Taka
	BGN          = "BGN" // Bulgaria Lev
	BHD          = "BHD" // Bahrain Dinar
	BIF          = "BIF" // Burundi Franc
	BMD          = "BMD" // Bermuda Dollar
	BND          = "BND" // Brunei Darussalam Dollar
	BOB          = "BOB" // Bolivia Boliviano
	BRL          = "BRL" // Brazil Real
	BSD          = "BSD" // Bahamas Dollar
	BTN          = "BTN" // Bhutan Ngultrum
	BWP          = "BWP" // Botswana Pula
	BYR          = "BYR" // Belarus Ruble
	BZD          = "BZD" // Belize Dollar
	CAD          = "CAD" // Canada Dollar
	CDF          = "CDF" // Congo/Kinshasa Franc
	CHF          = "CHF" // Switzerland Franc
	CLP          = "CLP" // Chile Peso
	CNY          = "CNY" // China Yuan Renminbi
	COP          = "COP" // Colombia Peso
	CRC          = "CRC" // Costa Rica Colon
	CUC          = "CUC" // Cuba Convertible Peso
	CUP          = "CUP" // Cuba Peso
	CVE          = "CVE" // Cape Verde Escudo
	CZK          = "CZK" // Czech Republic Koruna
	DJF          = "DJF" // Djibouti Franc
	DKK          = "DKK" // Denmark Krone
	DOP          = "DOP" // Dominican Republic Peso
	DZD          = "DZD" // Algeria Dinar
	EGP          = "EGP" // Egypt Pound
	ERN          = "ERN" // Eritrea Nakfa
	ETB          = "ETB" // Ethiopia Birr
	EUR          = "EUR" // Euro Member Countries
	FJD          = "FJD" // Fiji Dollar
	FKP          = "FKP" // Falkland Islands (Malvinas) Pound
	GBP          = "GBP" // United Kingdom Pound
	GEL          = "GEL" // Georgia Lari
	GGP          = "GGP" // Guernsey Pound
	GHS          = "GHS" // Ghana Cedi
	GIP          = "GIP" // Gibraltar Pound
	GMD          = "GMD" // Gambia Dalasi
	GNF          = "GNF" // Guinea Franc
	GTQ          = "GTQ" // Guatemala Quetzal
	GYD          = "GYD" // Guyana Dollar
	HKD          = "HKD" // Hong Kong Dollar
	HNL          = "HNL" // Honduras Lempira
	HRK          = "HRK" // Croatia Kuna
	HTG          = "HTG" // Haiti Gourde
	HUF          = "HUF" // Hungary Forint
	IDR          = "IDR" // Indonesia Rupiah
	ILS          = "ILS" // Israel Shekel
	IMP          = "IMP" // Isle of Man Pound
	INR          = "INR" // India Rupee
	IQD          = "IQD" // Iraq Dinar
	IRR          = "IRR" // Iran Rial
	ISK          = "ISK" // Iceland Krona
	JEP          = "JEP" // Jersey Pound
	JMD          = "JMD" // Jamaica Dollar
	JOD          = "JOD" // Jordan Dinar
	JPY          = "JPY" // Japan Yen
	KES          = "KES" // Kenya Shilling
	KGS          = "KGS" // Kyrgyzstan Som
	KHR          = "KHR" // Cambodia Riel
	KMF          = "KMF" // Comoros Franc
	KPW          = "KPW" // Korea (North) Won
	KRW          = "KRW" // Korea (South) Won
	KWD          = "KWD" // Kuwait Dinar
	KYD          = "KYD" // Cayman Islands Dollar
	KZT          = "KZT" // Kazakhstan Tenge
	LAK          = "LAK" // Laos Kip
	LBP          = "LBP" // Lebanon Pound
	LKR          = "LKR" // Sri Lanka Rupee
	LRD          = "LRD" // Liberia Dollar
	LSL          = "LSL" // Lesotho Loti
	LYD          = "LYD" // Libya Dinar
	MAD          = "MAD" // Morocco Dirham
	MDL          = "MDL" // Moldova Leu
	MGA          = "MGA" // Madagascar Ariary
	MKD          = "MKD" // Macedonia Denar
	MMK          = "MMK" // Myanmar (Burma) Kyat
	MNT          = "MNT" // Mongolia Tughrik
	MOP          = "MOP" // Macau Pataca
	MRO          = "MRO" // Mauritania Ouguiya
	MUR          = "MUR" // Mauritius Rupee
	MVR          = "MVR" // Maldives (Maldive Islands) Rufiyaa
	MWK          = "MWK" // Malawi Kwacha
	MXN          = "MXN" // Mexico Peso
	MYR          = "MYR" // Malaysia Ringgit
	MZN          = "MZN" // Mozambique Metical
	NAD          = "NAD" // Namibia Dollar
	NGN          = "NGN" // Nigeria Naira
	NIO          = "NIO" // Nicaragua Cordoba
	NOK          = "NOK" // Norway Krone
	NPR          = "NPR" // Nepal Rupee
	NZD          = "NZD" // New Zealand Dollar
	OMR          = "OMR" // Oman Rial
	PAB          = "PAB" // Panama Balboa
	PEN          = "PEN" // Peru Nuevo Sol
	PGK          = "PGK" // Papua New Guinea Kina
	PHP          = "PHP" // Philippines Peso
	PKR          = "PKR" // Pakistan Rupee
	PLN          = "PLN" // Poland Zloty
	PYG          = "PYG" // Paraguay Guarani
	QAR          = "QAR" // Qatar Riyal
	RON          = "RON" // Romania New Leu
	RSD          = "RSD" // Serbia Dinar
	RUB          = "RUB" // Russia Ruble
	RWF          = "RWF" // Rwanda Franc
	SAR          = "SAR" // Saudi Arabia Riyal
	SBD          = "SBD" // Solomon Islands Dollar
	SCR          = "SCR" // Seychelles Rupee
	SDG          = "SDG" // Sudan Pound
	SEK          = "SEK" // Sweden Krona
	SGD          = "SGD" // Singapore Dollar
	SHP          = "SHP" // Saint Helena Pound
	SLL          = "SLL" // Sierra Leone Leone
	SOS          = "SOS" // Somalia Shilling
	SPL          = "SPL" // Seborga Luigino
	SRD          = "SRD" // Suriname Dollar
	STD          = "STD" // São Tomé and Príncipe Dobra
	SVC          = "SVC" // El Salvador Colon
	SYP          = "SYP" // Syria Pound
	SZL          = "SZL" // Swaziland Lilangeni
	THB          = "THB" // Thailand Baht
	TJS          = "TJS" // Tajikistan Somoni
	TMT          = "TMT" // Turkmenistan Manat
	TND          = "TND" // Tunisia Dinar
	TOP          = "TOP" // Tonga Pa'anga
	TRY          = "TRY" // Turkey Lira
	TTD          = "TTD" // Trinidad and Tobago Dollar
	TVD          = "TVD" // Tuvalu Dollar
	TWD          = "TWD" // Taiwan New Dollar
	TZS          = "TZS" // Tanzania Shilling
	UAH          = "UAH" // Ukraine Hryvnia
	UGX          = "UGX" // Uganda Shilling
	USD          = "USD" // United States Dollar
	UYU          = "UYU" // Uruguay Peso
	UZS          = "UZS" // Uzbekistan Som
	VEF          = "VEF" // Venezuela Bolivar
	VND          = "VND" // Viet Nam Dong
	VUV          = "VUV" // Vanuatu Vatu
	WST          = "WST" // Samoa Tala
	XAF          = "XAF" // Communauté Financière Africaine (BEAC) CFA Franc BEAC
	XCD          = "XCD" // East Caribbean Dollar
	XDR          = "XDR" // International Monetary Fund (IMF) Special Drawing Rights
	XOF          = "XOF" // Communauté Financière Africaine (BCEAO) Franc
	XPF          = "XPF" // Comptoirs Français du Pacifique (CFP) Franc
	YER          = "YER" // Yemen Rial
	ZAR          = "ZAR" // South Africa Rand
	ZMW          = "ZMW" // Zambia Kwacha
	ZWD          = "ZWD" // Zimbabwe Dollar
)

ISO 4217

View Source
const (
	Checking     AccountType = "CHECKING"
	Savings                  = "SAVINGS"
	MoneyMarket              = "MONEYMRKT"
	LineOfCredit             = "CREDITLINE"
)
View Source
const (
	Info  Severity = "INFO"
	Warn           = "WARN"
	Error          = "ERROR"
)
View Source
const (
	Credit           TransactionType = "CREDIT"
	Debit                            = "DEBIT"
	Interest                         = "INT"
	Dividend                         = "DIVIDEND"
	Fee                              = "FEE"
	ServiceCharge                    = "SRVCHG"
	Deposit                          = "DEP"
	ATM                              = "ATM"
	PointOfSale                      = "POS"
	Transfer                         = "XFER"
	Check                            = "CHECK"
	EletronicPayment                 = "PAYMENT"
	CashWithdrawal                   = "CASH"
	DirectDeposit                    = "DIRECTDEP"
	DirectDebit                      = "DIRECTDEBIT"
	RepeatingPayment                 = "REPEATPMT"
	Other                            = "OTHER"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountType

type AccountType string

type Amount

type Amount float64

func (*Amount) UnmarshalXML

func (a *Amount) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML tries to unmarshal the amount using a decimal point or comma separator

type Balance

type Balance struct {
	Amount        Amount   `xml:"BALAMT"`
	EffectiveDate DateTime `xml:"DTASOF"`
}

type BankStatementResponse

type BankStatementResponse struct {
	CurrencyDefault      Currency             `xml:"CURDEF"`
	BankingAccount       BankingAccount       `xml:"BANKACCTFROM"`
	BankTransactionsList BankTransactionsList `xml:"BANKTRANLIST,omitempty"`
	LedgerBalance        Balance              `xml:"LEDGERBAL"`
	AvailableBalance     Balance              `xml:"AVAILBAL,omitempty"`
	MarketingInfo        string               `xml:"MKTGINFO,omitempty"`
}

type BankTransactionsList

type BankTransactionsList struct {
	DateStart    Date          `xml:"DTSTART"`
	DateEnd      Date          `xml:"DTEND"`
	Transactions []Transaction `xml:"STMTTRN"`
}

type Banking

type Banking struct {
	BankingResponse []BankingResponse `xml:"STMTTRNRS"`
}

type BankingAccount

type BankingAccount struct {
	BankID      string      `xml:"BANKID"`
	BranchID    string      `xml:"BRANCHID,omitempty"`
	ID          string      `xml:"ACCTID"`
	AccountType AccountType `xml:"ACCTTYPE"`
	Key         string      `xml:"ACCTKEY,omitempty"`
}

type BankingResponse

type BankingResponse struct {
	TransactionUID        TransactionUID        `xml:"TRNUID"`
	ClientCookie          string                `xml:"CLTCOOKIE,omitempty"`
	Status                Status                `xml:"STATUS"`
	BankStatementResponse BankStatementResponse `xml:"STMTRS"`
}

type CorrectAction

type CorrectAction string
const (
	Replace CorrectAction = "REPLACE"
	Delete  CorrectAction = "DELETE"
)

type CreditCard

type CreditCard struct {
	CreditCardResponse []CreditCardResponse `xml:"CCSTMTTRNRS"`
}

type CreditCardAccount

type CreditCardAccount struct {
	ID  string `xml:"ACCTID"`
	Key string `xml:"ACCTKEY,omitempty"`
}

type CreditCardResponse

type CreditCardResponse struct {
	TransactionUID              TransactionUID              `xml:"TRNUID"`
	ClientCookie                string                      `xml:"CLTCOOKIE,omitempty"`
	Status                      Status                      `xml:"STATUS"`
	CreditCardStatementResponse CreditCardStatementResponse `xml:"CCSTMTRS"`
}

type CreditCardStatementResponse

type CreditCardStatementResponse struct {
	CurrencyDefault      Currency             `xml:"CURDEF"`
	CreditCardAccount    CreditCardAccount    `xml:"CCACCTFROM"`
	BankTransactionsList BankTransactionsList `xml:"BANKTRANLIST,omitempty"`
	LedgerBalance        Balance              `xml:"LEDGERBAL"`
	AvailableBalance     Balance              `xml:"AVAILBAL,omitempty"`
	MarketingInfo        string               `xml:"MKTGINFO,omitempty"`
}

type Currency

type Currency string

type Date

type Date string //YYYYMMDD

type DateTime

type DateTime string

func (DateTime) Time

func (d DateTime) Time() time.Time

type FITID

type FITID string

type FinancialInstitution

type FinancialInstitution struct {
	Organization string `xml:"ORG"`
	ID           string `xml:"FID"`
}

type Language

type Language string

type OFX

type OFX struct {
	SignOn     SignOn     `xml:"SIGNONMSGSRSV1"`
	Banking    Banking    `xml:"BANKMSGSRSV1,omitempty"`
	CreditCard CreditCard `xml:"CREDITCARDMSGSRSV1,omitempty"`
}

func Parse

func Parse(in io.Reader) (*OFX, error)

type Severity

type Severity string

type SignOn

type SignOn struct {
	SignOnResponse SignOnResponse `xml:"SONRS"`
}

type SignOnResponse

type SignOnResponse struct {
	Status               Status               `xml:"STATUS"`
	DateTimeServer       DateTime             `xml:"DTSERVER"`
	Language             Language             `xml:"LANGUAGE"`
	DateAccountUp        DateTime             `xml:"DTACCTUP,omitempty"`
	FinancialInstitution FinancialInstitution `xml:"FI,omitempty"`
	UserKey              string               `xml:"USERKEY,omitempty"`
}

type Status

type Status struct {
	Code     int      `xml:"CODE"`
	Severity Severity `xml:"SEVERITY"`
	Message  string   `xml:"MESSAGE,omitempty"`
}

type Transaction

type Transaction struct {
	TransactionType   TransactionType `xml:"TRNTYPE"`
	DatePosted        DateTime        `xml:"DTPOSTED"`
	DateUser          DateTime        `xml:"DTUSER,omitempty"`
	DateAvailable     DateTime        `xml:"DTAVAIL,omitempty"`
	Amount            Amount          `xml:"TRNAMT"`
	FITID             FITID           `xml:"FITID"`
	CorrectFITID      FITID           `xml:"CORRECTFITID,omitempty"`
	CorrectAction     CorrectAction   `xml:"CORRECTACTION,omitempty"`
	ServerID          string          `xml:"SRVRID,omitempty"`
	CheckNumber       string          `xml:"CHECKNUM,omitempty"`
	ReferenceNumber   string          `xml:"REFNUM,omitempty"`
	StdIndustrialCode string          `xml:"SIC"`
	PayeeID           string          `xml:"PAYEEID,omitempty"`
	Name              string          `xml:"NAME"`
	Memo              string          `xml:"MEMO,omitempty"`
}

type TransactionType

type TransactionType string

type TransactionUID

type TransactionUID string

Directories

Path Synopsis
cmd
ofx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL