Class: LSVplus::Record
Defined Under Namespace
Classes: InvalidAmount, InvalidProcessingDate
Constant Summary
collapse
- ATTRIBUTES =
%i(
type version
creditor_bank_clearing_number creditor_iban creditor_address
debitor_bank_clearing_number debitor_account debitor_address
amount message processing_date
reference_type reference esr_member_id
)
- TYPE =
'875'
- VERSION =
'0'
- MAX_AMOUNT =
BigDecimal.new('99_999_999.99')
- PROCESSING_MAX_IN_FUTURE =
30
- PROCESSING_MAX_IN_PAST =
10
Instance Method Summary
collapse
#set_attributes, #validate_presence_of_required_attributes
Constructor Details
#initialize(attributes) ⇒ Record
Returns a new instance of Record.
30
31
32
33
34
|
# File 'lib/lsv_plus/record.rb', line 30
def initialize(attributes)
attributes = attributes.merge type: TYPE, version: VERSION
validate attributes
super attributes
end
|
Instance Method Details
#==(other) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/lsv_plus/record.rb', line 57
def ==(other)
ATTRIBUTES.each do |attribute|
return false unless other.respond_to?(attribute)
return false unless send(attribute) == other.send(attribute)
end
true
end
|
#validate(attributes) ⇒ Object
36
37
38
39
40
|
# File 'lib/lsv_plus/record.rb', line 36
def validate(attributes)
super(attributes)
validate_processing_date(attributes)
validate_amount(attributes)
end
|
#validate_amount(attributes) ⇒ Object
51
52
53
54
55
|
# File 'lib/lsv_plus/record.rb', line 51
def validate_amount(attributes)
if attributes[:amount] > MAX_AMOUNT
raise InvalidAmount, "Must not be higher than #{MAX_AMOUNT}"
end
end
|
#validate_processing_date(attributes) ⇒ Object