LedgerSMB Documentation

Description manuals and libraries
LedgerSMB Documentation > Perl Modules > LedgerSMB::FileFormats::OFX::BankStatement
Source

NAME

LedgerSMB::FileFormats::OFX::BankStatement - Parse OFX Bank Statement files

SYNOPSIS

    my $ofx = LedgerSMB::FileFormats::OFX::BankStatement->new($filecontents);
    my @transactions = $ofx->transactions;

DESCRIPTION

This module provides basic parsing and data extraction of OFX bank statement files for LedgerSMB.

OFX SPECIFICATION

This parser has been created with reference to the Open Financial Exchange Specification, available from https://www.ofx.net/downloads/OFX%202.2.pdf.

This document, as retrieved on 2020-03-29 carries the following licence:

A royalty-free, worldwide, and perpetual license is hereby granted to any party to use the Open Financial Exchange Specification to make, use, and sell products and services that conform to this Specification.

Statement Transactions

A STMTTRN aggregate describes a single transaction. It identifies the type of the transaction and the date it was posted. It can also provide additional information to help recognize the transaction: check number, payee name, and memo.

Each STMTTRN contains an FITID (Financial Institution Trasaction ID) that the client can use to detect whether the transaction has previously been downloaded.

Transaction Types

The following TRNTYPEs are specified:

CREDIT, DEBIT, INT, DIV, FEE, SRVCHG, DEP, ATM, POS, XFER, CHECK, PAYMENT, CASH, DIRECTDEP, DIRECTDEBIT, REPEATPMT, OTHER.

Amounts

Amounts that do not represent whole numbers (for example, 540.32), must include a decimal point or comma to indicate the start of the fractional amount.

Amounts should not include any punctuation separating thousands, millions, and so forth. The maximum value accepted depends on the client.

Transaction Sign

Transaction amounts are signed from the perspective of the customer. For example, a credit card payment is positive while a credit card purchase is negative.

Payee Name

Either NAME or PAYEE elements may be provided within a STMTTRN element, but not both.

PAYEE provides a complete billing address for a payee. NAME will be provided as one of its child elements.

AUTODETECTION

The constructor returns undef if the file is not a OFX docuent.

METHODS

new($xml_string)

Pass in a string of XML data. Returns undef if the string is not valid XML or not identified as a OFX document.

dom

Returns the XML::LibXML DOM tree representing the input xml.

transactions

Returns a transaction list reference, each transaction being a hash with the following elements:

  * amount
  * cleared_date
  * scn
  * type

LICENSE AND COPYRIGHT

Copyright (C) 2020 The LedgerSMB Core Team

This file is licensed under the GNU General Public License version 2, or at your option any later version. A copy of the license should have been included with your software.