Class: Twinfield::Browse::Transaction::GeneralLedger
- Inherits:
-
AbstractModel
- Object
- AbstractModel
- Twinfield::Browse::Transaction::GeneralLedger
- Extended by:
- Helpers::Parsers
- Includes:
- Helpers::TransactionMatch
- Defined in:
- lib/twinfield/browse/transaction/general_ledger.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#dim1 ⇒ Object
Returns the value of attribute dim1.
-
#dim2 ⇒ Object
Returns the value of attribute dim2.
-
#key ⇒ Object
Returns the value of attribute key.
-
#number ⇒ Object
Returns the value of attribute number.
-
#status ⇒ Object
Returns the value of attribute status.
-
#value ⇒ Object
Returns the value of attribute value.
-
#yearperiod ⇒ Object
Returns the value of attribute yearperiod.
Class Method Summary collapse
- .find(customer_code: nil, invoice_number: nil, code: nil, number: nil) ⇒ Object
- .initialize_from_columns_response_row(transaction_xml) ⇒ Object
- .where(years: ((Date.today.year - 30)..Date.today.year), dim1: nil, dim2: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(number: nil, yearperiod: nil, currency: "EUR", value: nil, status: nil, dim1: nil, dim2: nil, key: nil, code: nil) ⇒ GeneralLedger
constructor
A new instance of GeneralLedger.
Methods included from Helpers::Parsers
parse_date, parse_datetime, parse_float
Methods included from Helpers::TransactionMatch
#match!, #to_match_xml, #to_transaction_match_line_xml
Constructor Details
#initialize(number: nil, yearperiod: nil, currency: "EUR", value: nil, status: nil, dim1: nil, dim2: nil, key: nil, code: nil) ⇒ GeneralLedger
Returns a new instance of GeneralLedger.
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 130 def initialize(number: nil, yearperiod: nil, currency: "EUR", value: nil, status: nil, dim1: nil, dim2: nil, key: nil, code: nil) self.number = number self.yearperiod = yearperiod self.currency = currency self.value = value self.status = status self.dim1 = dim1 self.dim2 = dim2 self.key = key self.code = code end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def code @code end |
#currency ⇒ Object
Returns the value of attribute currency.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def currency @currency end |
#dim1 ⇒ Object
Returns the value of attribute dim1.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def dim1 @dim1 end |
#dim2 ⇒ Object
Returns the value of attribute dim2.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def dim2 @dim2 end |
#key ⇒ Object
Returns the value of attribute key.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def key @key end |
#number ⇒ Object
Returns the value of attribute number.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def number @number end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def status @status end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def value @value end |
#yearperiod ⇒ Object
Returns the value of attribute yearperiod.
8 9 10 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 8 def yearperiod @yearperiod end |
Class Method Details
.find(customer_code: nil, invoice_number: nil, code: nil, number: nil) ⇒ Object
25 26 27 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 25 def find(customer_code: nil, invoice_number: nil, code: nil, number: nil) where(customer_code: customer_code, invoice_number: invoice_number, code: code, number: number).first end |
.initialize_from_columns_response_row(transaction_xml) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 11 def initialize_from_columns_response_row(transaction_xml) new( number: transaction_xml.css("td[field='fin.trs.head.number']").text, yearperiod: transaction_xml.css("td[field='fin.trs.head.yearperiod']").text, currency: transaction_xml.css("td[field='fin.trs.head.curcode']").text, value: transaction_xml.css("td[field='fin.trs.line.valuesigned']").text&.to_f, status: transaction_xml.css("td[field='fin.trs.head.status']").text, dim1: transaction_xml.css("td[field='fin.trs.line.dim1']").text, dim2: transaction_xml.css("td[field='fin.trs.line.dim2']").text, key: transaction_xml.css("key").text.gsub(/\s/, ""), code: transaction_xml.css("td[field='fin.trs.head.code']").text ) end |
.where(years: ((Date.today.year - 30)..Date.today.year), dim1: nil, dim2: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/twinfield/browse/transaction/general_ledger.rb', line 31 def where(years: ((Date.today.year - 30)..Date.today.year), dim1: nil, dim2: nil) build_request = %( <column> <field>fin.trs.head.yearperiod</field> <label>Periode</label> <visible>true</visible> <ask>false</ask> <operator>between</operator> <from>#{years.first}/01</from> <to>#{years.last}/12</to> <finderparam/> </column> <column> <field>fin.trs.line.dim1</field> <label>Grootboek</label> <visible>true</visible> <ask>false</ask> <operator>between</operator> <from>#{dim1}</from> <to>#{dim1}</to> <finderparam/> </column> <column> <field>fin.trs.line.dim2</field> <label>Kostenplaats</label> <visible>true</visible> <ask>false</ask> <operator>between</operator> <from>#{dim2}</from> <to>#{dim2}</to> </column> <column> <field>fin.trs.head.code</field> <label>Dagboek</label> <visible>true</visible> <ask>false</ask> <operator>equal</operator> <from/> <to/> <finderparam>hidden=1</finderparam> </column> <column> <field>fin.trs.head.number</field> <label>Boekst.nr.</label> <visible>true</visible> <ask>false</ask> <operator>between</operator> <from/> <to/> <finderparam/> </column> <column> <field>fin.trs.head.curcode</field> <label>Valuta</label> <visible>true</visible> <ask>false</ask> <operator>none</operator> <from/> <to/> <finderparam/> </column> <column> <field>fin.trs.line.valuesigned</field> <label>Bedrag</label> <visible>true</visible> <ask>false</ask> <operator>between</operator> <from/> <to/> <finderparam/> </column> <column> <field>fin.trs.head.status</field> <label>Status</label> <visible>true</visible> <ask>false</ask> <operator>equal</operator> <from>normal</from> <to/> <finderparam/> </column> ) response = Twinfield::Api::Process.request(:process_xml_string) do %( <columns code="000"> #{build_request} </columns> ) end xml = Nokogiri::XML(response.body[:process_xml_string_response][:process_xml_string_result]) xml.css("tr").map do |transaction_xml| Twinfield::Browse::Transaction::GeneralLedger.initialize_from_columns_response_row(transaction_xml) end end |