Class: Ufebs::Documents::PaymentOrder

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

Constant Summary collapse

InvalidPriority =
Class.new(StandardError)
DOCUMENT_NUMBER_TYPE =
'01'.freeze
SYSTEM_CODE =
'02'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(ed_date: Time.now, number: nil, sum: nil, charge_off_date: Time.now, priority: 0, receipt_date: Time.now, ed_author: '', acc_doc: nil, payer: nil, payee: nil, purpose: '', uin: nil, payt_kind: nil, payment_precedence: nil, processing_details: nil, system_code: SYSTEM_CODE, departmental_info: nil) {|_self| ... } ⇒ PaymentOrder

Returns a new instance of PaymentOrder.

Yields:

  • (_self)

Yield Parameters:

Raises:



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
# File 'lib/ufebs/documents/payment_order.rb', line 46

def initialize(
  ed_date: Time.now,
  number: nil,
  sum: nil,
  charge_off_date: Time.now,
  priority: 0,
  receipt_date: Time.now,
  ed_author: '',
  acc_doc: nil,
  payer: nil,
  payee: nil,
  purpose: '',
  uin: nil,
  payt_kind: nil,
  payment_precedence: nil,
  processing_details: nil,

  system_code: SYSTEM_CODE,
  departmental_info: nil
)
  raise InvalidPriority.new('priority Реквизит должен иметь значение в диапазоне 0-5.') unless (0..5).include?(priority.to_i)

  @ed_date         = Date.parse(ed_date.to_s).strftime('%Y-%m-%d')
  @number          = number
  @sum             = sum
  @charge_off_date = Date.parse(charge_off_date.to_s).strftime('%Y-%m-%d')
  @receipt_date    = Date.parse(receipt_date.to_s).strftime('%Y-%m-%d')
  @priority        = priority
  @acc_doc         = acc_doc.is_a?(Hash) ? Ufebs::Entities::AccDoc.new(acc_doc) : acc_doc
  @payer           = payer.is_a?(Hash) ? Ufebs::Entities::Participant.new(payer) : payer
  @payee           = payer.is_a?(Hash) ? Ufebs::Entities::Participant.new(payee) : payee
  @purpose         = purpose
  @departmental_info = departmental_info.is_a?(Hash) ? Ufebs::Entities::DepartmentalInfo.new(departmental_info) : departmental_info
  @uin            = uin
  @payt_kind      = payt_kind
  @payment_precedence = payment_precedence
  @processing_details = processing_details.is_a?(Hash) ? ::Ufebs::Entities::ProcessingDetails.new(processing_details) : processing_details

  @ed_author   = ed_author
  @type_number = DOCUMENT_NUMBER_TYPE
  @system_code = system_code

  yield self if block_given?

  super()
end

Instance Method Details

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



42
43
44
# File 'lib/ufebs/documents/payment_order.rb', line 42

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

#validateObject



38
39
40
# File 'lib/ufebs/documents/payment_order.rb', line 38

def validate
  Ufebs.validate(to_xml)
end