Class: Bankjob::Payee

Inherits:
Object
  • Object
show all
Defined in:
lib/bankjob/payee.rb

Overview

A Payee object represents an entity in a in a bank Transaction that receives a payment.

A Scraper will create Payees while scraping web pages in an online banking site. In many cases Payees will not be distinguished in the online bank site in which case rules will have to be applied to separate the Payees

A Payee object knows how to write itself as a record in a CSV (Comma Separated Values) file using to_csv or as an XML element in an OFX (Open Financial eXchange www.ofx.net) file using to_ofx

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

address of the payee Translates to OFX element ADDR1 – TODO Consider ADDR2,3



28
29
30
# File 'lib/bankjob/payee.rb', line 28

def address
  @address
end

#cityObject

city in which the payee is located Translates to OFX element CITY



32
33
34
# File 'lib/bankjob/payee.rb', line 32

def city
  @city
end

#countryObject

country in which the payee is located Translates to OFX element COUNTRY



44
45
46
# File 'lib/bankjob/payee.rb', line 44

def country
  @country
end

#nameObject

name of the payee Translates to OFX element NAME



23
24
25
# File 'lib/bankjob/payee.rb', line 23

def name
  @name
end

#phoneObject

phone number of the payee Translates to OFX element PHONE



48
49
50
# File 'lib/bankjob/payee.rb', line 48

def phone
  @phone
end

#postalcodeObject

post code or zip in which the payee is located Translates to OFX element POSTALCODE



40
41
42
# File 'lib/bankjob/payee.rb', line 40

def postalcode
  @postalcode
end

#stateObject

state in which the payee is located Translates to OFX element STATE



36
37
38
# File 'lib/bankjob/payee.rb', line 36

def state
  @state
end

Instance Method Details

#to_csvObject

Generates a string representing this Payee as a single string for use in a comma separated values column



54
55
56
# File 'lib/bankjob/payee.rb', line 54

def to_csv
  name
end

#to_ofxObject

Generates an XML string adhering to the OFX standard (see Open Financial Exchange www.ofx.net) representing a single Payee XML element.

The schema for the OFX produced is

<xsd:complexType name="Payee">
  <xsd:annotation>
    <xsd:documentation>
      The OFX element "PAYEE" is of type "Payee"
    </xsd:documentation>
  </xsd:annotation>
  <xsd:sequence>
    <xsd:element name="NAME" type="ofx:GenericNameType"/>
    <xsd:sequence>
      <xsd:element name="ADDR1" type="ofx:AddressType"/>
      <xsd:sequence minOccurs="0">
        <xsd:element name="ADDR2" type="ofx:AddressType"/>
        <xsd:element name="ADDR3" type="ofx:AddressType" minOccurs="0"/>
      </xsd:sequence>
    </xsd:sequence>
    <xsd:element name="CITY" type="ofx:AddressType"/>
    <xsd:element name="STATE" type="ofx:StateType"/>
    <xsd:element name="POSTALCODE" type="ofx:ZipType"/>
    <xsd:element name="COUNTRY" type="ofx:CountryType" minOccurs="0"/>
    <xsd:element name="PHONE" type="ofx:PhoneType"/>
  </xsd:sequence>
</xsd:complexType>


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/bankjob/payee.rb', line 88

def to_ofx
  buf = ""
  # Set margin=6 to indent it nicely within the output from Transaction.to_ofx
  x = Builder::XmlMarkup.new(:target => buf, :indent => 2, :margin=>6)
  x.PAYEE {
    x.NAME name
    x.ADDR1 address
    x.CITY city
    x.STATE state
    x.POSTALCODE postalcode
    x.COUNTRY country unless country.nil? # minOccurs="0" in schema (above)
    x.PHONE phone
  }
  return buf
end

#to_sObject

Produces the Payee as a row of comma separated values (delegates to to_csv)



108
109
110
# File 'lib/bankjob/payee.rb', line 108

def to_s
  to_csv
end