Class: Codabel::Record::NewBalance
- Inherits:
-
Codabel::Record
- Object
- Codabel::Record
- Codabel::Record::NewBalance
- Defined in:
- lib/codabel/record/new_balance.rb
Constant Summary collapse
- FOLLOWING =
{ when_true: '1', when_false: '0' }.freeze
Instance Attribute Summary
Attributes inherited from Codabel::Record
Instance Method Summary collapse
Methods inherited from Codabel::Record
#actual_records, add_column, #auto_enrich, column, columns, for, header, #initialize, movement, movement21, movement22, movement23, new_balance, old_balance, required?, #to_coda, trailer
Constructor Details
This class inherits a constructor from Codabel::Record
Instance Method Details
#balance ⇒ Object
15 16 17 |
# File 'lib/codabel/record/new_balance.rb', line 15 def balance data[:balance] || 0 end |
#validate!(file) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/codabel/record/new_balance.rb', line 19 def validate!(file) return unless (old_balance = file.find_record(OldBalance)) expected = old_balance.balance + file.find_records(Movement21).map(&:amount).sum check!(expected == balance, "Invalid new balance: expected #{expected}, got #{balance}") end |