Class: Ufebs::Documents::BasePayment

Inherits:
Object
  • Object
show all
Includes:
HappyMapper
Defined in:
lib/ufebs/documents/base_payment.rb

Constant Summary collapse

DOCUMENT_TRANS_KIND =
'01'.freeze
SYSTEM_CODE =
'02'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) {|_self| ... } ⇒ BasePayment

Returns a new instance of BasePayment.

Yields:

  • (_self)

Yield Parameters:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ufebs/documents/base_payment.rb', line 21

def initialize(params = {})
  params = {
    ed_date:         Time.now,
    charge_off_date: Time.now,
    priority:        0,
    receipt_date:    Time.now,
    ed_author:       '',
    purpose:         '',
    trans_kind:      DOCUMENT_TRANS_KIND,
    system_code:     SYSTEM_CODE
  }.merge(params)

  validate_priority(params[:priority])

  params.each do |key, value|
    case key.to_sym
    when :ed_date             then @ed_date             = Date.parse(value.to_s).strftime('%Y-%m-%d')
    when :charge_off_date     then @charge_off_date     = Date.parse(value.to_s).strftime('%Y-%m-%d')
    when :receipt_date        then @receipt_date        = Date.parse(value.to_s).strftime('%Y-%m-%d')
    when :acc_doc             then @acc_doc             = value.is_a?(Hash) ? Ufebs::Entities::AccDoc.new(value) : value
    when :payer               then @payer               = value.is_a?(Hash) ? Ufebs::Entities::Participant.new(value) : value
    when :payee               then @payee               = value.is_a?(Hash) ? Ufebs::Entities::Participant.new(value) : value
    when :partial_payt        then @partial_payt        = value.is_a?(Hash) ? Ufebs::Entities::PartialPayt.new(value) : value
    when :departmental_info   then @departmental_info   = value.is_a?(Hash) ? Ufebs::Entities::DepartmentalInfo.new(value) : value
    when :processing_details  then @processing_details  = value.is_a?(Hash) ? Ufebs::Entities::ProcessingDetails.new(value) : value
    else instance_variable_set("@#{key}".to_sym, value)
    end
  end

  yield self if block_given?

  super()
end

Instance Method Details

#as_xml(encoding: 'UTF-8') ⇒ Object



17
18
19
# File 'lib/ufebs/documents/base_payment.rb', line 17

def as_xml(encoding: 'UTF-8')
  to_xml(Nokogiri::XML::Builder.new(:encoding => encoding)).to_xml
end

#validateObject



13
14
15
# File 'lib/ufebs/documents/base_payment.rb', line 13

def validate
  Ufebs.validate(to_xml)
end