ruby_ufebs 0.2.23 → 0.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2985e0f51751be6e2d39ad174ab1d162f081f7bc8a04fbc8319378b42179488d
4
- data.tar.gz: d71e02d5602bf66ed8fc2d658af25b5378f6699b1b72c59a7d424486213a2222
3
+ metadata.gz: 6ff1c48e339c56faf86b162c1fe9f1337d327fcb6f7e014ce440fef1e756d852
4
+ data.tar.gz: 967791229f3dc0956e30a63986cb6b02b4b1a78f7478f56075282d2f4d0a5ddb
5
5
  SHA512:
6
- metadata.gz: 6a28bf284844ca5d4ed778877518399dcaa724686424e30a0da60fd8879d0a678bdddbd10f4358306064e6457fe9e599c2073b56ef9b4ec80595e77aacddadaa
7
- data.tar.gz: 20664d0ab21c183cff7ceb6792689ae9a40c21e70a49e80e8d398cc7879d2b0a1d9afd419439be5d8cd2731aa2bba2fcc295ec2799b47e4ca84332d063de8828
6
+ metadata.gz: 5a7e69d400229877f1a605ec2c1b3c8e9ba83ee0de5f217b133257e47e4d6288aca658b94f9708be207be8d3dc6ba5e046c6ae49bc879e14e90370422c4ca499
7
+ data.tar.gz: b047649017890e80a9c704403ef92c0ac32eeee1cfc99872f66d89d52b78c5553d54c0080a6162258f96a690c75d8af028976a58d8427ddc4bb3824f7ae671f8
@@ -7,8 +7,8 @@ module Ufebs
7
7
  module Documents
8
8
  class BasePayment
9
9
  include HappyMapper
10
- DOCUMENT_NUMBER_TYPE = '06'.freeze
11
- SYSTEM_CODE = '02'.freeze
10
+ DOCUMENT_TRANS_KIND = '01'.freeze
11
+ SYSTEM_CODE = '02'.freeze
12
12
 
13
13
  def validate
14
14
  Ufebs.validate(to_xml)
@@ -18,53 +18,46 @@ module Ufebs
18
18
  to_xml(Nokogiri::XML::Builder.new(:encoding => encoding)).to_xml
19
19
  end
20
20
 
21
- def initialize(
22
- ed_date: Time.now,
23
- number: nil,
24
- sum: nil,
25
- charge_off_date: Time.now,
26
- priority: 0,
27
- receipt_date: Time.now,
28
- ed_author: '',
29
- acc_doc: nil,
30
- payer: nil,
31
- payee: nil,
32
- purpose: '',
33
- uin: nil,
34
- trans_kind: DOCUMENT_NUMBER_TYPE,
35
- payt_kind: nil,
36
- system_code: nil,
37
- payment_precedence: nil,
38
- processing_details: nil,
39
- departmental_info: nil
40
- )
41
- raise InvalidPriority.new('priority Реквизит должен иметь значение в диапазоне 0-5.') unless (0..5).include?(priority.to_i)
42
-
43
- @ed_date = Date.parse(ed_date.to_s).strftime('%Y-%m-%d')
44
- @number = number
45
- @sum = sum
46
- @charge_off_date = Date.parse(charge_off_date.to_s).strftime('%Y-%m-%d')
47
- @receipt_date = Date.parse(receipt_date.to_s).strftime('%Y-%m-%d')
48
- @priority = priority
49
- @acc_doc = acc_doc.is_a?(Hash) ? Ufebs::Entities::AccDoc.new(acc_doc) : acc_doc
50
- @payer = payer.is_a?(Hash) ? Ufebs::Entities::Participant.new(payer) : payer
51
- @payee = payer.is_a?(Hash) ? Ufebs::Entities::Participant.new(payee) : payee
52
- @purpose = purpose
53
- @departmental_info = departmental_info.is_a?(Hash) ? Ufebs::Entities::DepartmentalInfo.new(departmental_info) : departmental_info
54
- @uin = uin
55
- @payt_kind = payt_kind
56
-
57
- @payment_precedence = payment_precedence
58
- @processing_details = processing_details.is_a?(Hash) ? ::Ufebs::Entities::ProcessingDetails.new(processing_details) : processing_details
59
-
60
- @ed_author = ed_author
61
- @type_number = trans_kind
62
- @system_code = system_code || SYSTEM_CODE
21
+ def initialize(params = {})
22
+ params = {
23
+ ed_date: Time.now,
24
+ charge_off_date: Time.now,
25
+ priority: 0,
26
+ receipt_date: Time.now,
27
+ ed_author: '',
28
+ purpose: '',
29
+ trans_kind: DOCUMENT_TRANS_KIND,
30
+ system_code: SYSTEM_CODE
31
+ }.merge(params)
32
+
33
+ validate_priority(params[:priority])
34
+
35
+ params.each do |key, value|
36
+ case key.to_sym
37
+ when :ed_date then @ed_date = Date.parse(value.to_s).strftime('%Y-%m-%d')
38
+ when :charge_off_date then @charge_off_date = Date.parse(value.to_s).strftime('%Y-%m-%d')
39
+ when :receipt_date then @receipt_date = Date.parse(value.to_s).strftime('%Y-%m-%d')
40
+ when :acc_doc then @acc_doc = value.is_a?(Hash) ? Ufebs::Entities::AccDoc.new(value) : value
41
+ when :payer then @payer = value.is_a?(Hash) ? Ufebs::Entities::Participant.new(value) : value
42
+ when :payee then @payee = value.is_a?(Hash) ? Ufebs::Entities::Participant.new(value) : value
43
+ when :partial_payt then @partial_payt = value.is_a?(Hash) ? Ufebs::Entities::PartialPayt.new(value) : value
44
+ when :departmental_info then @departmental_info = value.is_a?(Hash) ? Ufebs::Entities::DepartmentalInfo.new(value) : value
45
+ when :processing_details then @processing_details = value.is_a?(Hash) ? Ufebs::Entities::ProcessingDetails.new(value) : value
46
+ else instance_variable_set("@#{key}".to_sym, value)
47
+ end
48
+ end
63
49
 
64
50
  yield self if block_given?
65
51
 
66
52
  super()
67
53
  end
54
+
55
+ protected
56
+
57
+ def validate_priority(priority)
58
+ return if (0..5).include?(priority.to_i)
59
+ raise InvalidPriority.new('priority Реквизит должен иметь значение в диапазоне 0-5.')
60
+ end
68
61
  end
69
62
  end
70
63
  end
@@ -0,0 +1,18 @@
1
+ require_relative 'base_payment'
2
+ require_relative '../fields/payment_doc'
3
+
4
+ module Ufebs
5
+ module Documents
6
+ class CollectionOrder < BasePayment
7
+ include HappyMapper
8
+ include Ufebs::Fields::PaymentDoc
9
+
10
+ register_namespace 'ed', 'urn:cbr-ru:ed:v2.0'
11
+ tag 'ED104'
12
+ namespace 'ed'
13
+
14
+ attribute :receipt_date_collect_bank, String, tag: 'ReceiptDateCollectBank'
15
+ attribute :file_date, String, tag: 'FileDate'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'base_payment'
2
+ require_relative '../fields/payment_doc'
3
+
4
+ module Ufebs
5
+ module Documents
6
+ class PayerOrder < BasePayment
7
+ include HappyMapper
8
+
9
+ register_namespace 'ed', 'urn:cbr-ru:ed:v2.0'
10
+ tag 'ED105'
11
+ namespace 'ed'
12
+
13
+ attribute :number, String, tag: 'EDNo'
14
+ attribute :ed_date, String, tag: 'EDDate'
15
+ attribute :ed_author, String, tag: 'EDAuthor'
16
+ attribute :sum, String, tag: 'Sum'
17
+ attribute :payt_kind, String, tag: 'PaytKind'
18
+ attribute :trans_kind, String, tag: 'TransKind'
19
+ attribute :uin, String, tag: 'PaymentID'
20
+ attribute :system_code, String, tag: 'SystemCode'
21
+ attribute :priority, String, tag: 'Priority'
22
+ attribute :payment_precedence, String, tag: 'PaymentPrecedence'
23
+ attribute :trans_content, String, tag: 'TransContent'
24
+
25
+ element :purpose, String, tag: 'Purpose'
26
+
27
+ has_one :acc_doc, ::Ufebs::Entities::AccDoc, tag: 'AccDoc'
28
+ has_one :payer, ::Ufebs::Entities::Participant, tag: 'Payer'
29
+ has_one :payee, ::Ufebs::Entities::Participant, tag: 'Payee'
30
+ has_one :partial_payt, ::Ufebs::Entities::PartialPayt, tag: 'PartialPayt'
31
+ has_one :processing_details, ::Ufebs::Entities::ProcessingDetails, tag: 'ProcessingDetails', state_when_nil: false
32
+ has_one :departmental_info, ::Ufebs::Entities::DepartmentalInfo, tag: 'DepartmentalInfo', state_when_nil: false
33
+ end
34
+ end
35
+ end
@@ -4,91 +4,13 @@ require_relative '../entities/participant'
4
4
 
5
5
  module Ufebs
6
6
  module Documents
7
- class PaymentOrder
7
+ class PaymentOrder < BasePayment
8
8
  include HappyMapper
9
- InvalidPriority = Class.new(StandardError)
9
+ include Ufebs::Fields::PaymentDoc
10
10
 
11
- DOCUMENT_NUMBER_TYPE = '01'.freeze
12
- SYSTEM_CODE = '02'.freeze
13
-
14
- register_namespace 'ed', "urn:cbr-ru:ed:v2.0"
11
+ register_namespace 'ed', 'urn:cbr-ru:ed:v2.0'
15
12
  tag 'ED101'
16
13
  namespace 'ed'
17
-
18
- attribute :number, String, tag: 'EDNo'
19
- attribute :ed_date, String, tag: 'EDDate'
20
- attribute :ed_author, String, tag: 'EDAuthor'
21
- attribute :sum, String, tag: 'Sum'
22
- attribute :payt_kind, String, tag: 'PaytKind'
23
- attribute :type_number, String, tag: 'TransKind'
24
- attribute :uin, String, tag: 'PaymentID'
25
- attribute :charge_off_date, String, tag: 'ChargeOffDate'
26
- attribute :receipt_date, String, tag: 'ReceiptDate'
27
- attribute :system_code, String, tag: 'SystemCode'
28
- attribute :priority, String, tag: 'Priority'
29
- attribute :payment_precedence, String, tag: 'PaymentPrecedence'
30
- has_one :acc_doc, ::Ufebs::Entities::AccDoc, tag: 'AccDoc'
31
- has_one :payer, ::Ufebs::Entities::Participant, tag: 'Payer'
32
- has_one :payee, ::Ufebs::Entities::Participant, tag: 'Payee'
33
- element :purpose, String, tag: 'Purpose'
34
-
35
- has_one :processing_details, ::Ufebs::Entities::ProcessingDetails, tag: 'ProcessingDetails', state_when_nil: false
36
- has_one :departmental_info, Ufebs::Entities::DepartmentalInfo, tag: 'DepartmentalInfo', state_when_nil: false
37
-
38
- def validate
39
- Ufebs.validate(to_xml)
40
- end
41
-
42
- def as_xml(encoding: 'UTF-8')
43
- to_xml(Nokogiri::XML::Builder.new(:encoding => encoding)).to_xml
44
- end
45
-
46
- def initialize(
47
- ed_date: Time.now,
48
- number: nil,
49
- sum: nil,
50
- charge_off_date: Time.now,
51
- priority: 0,
52
- receipt_date: Time.now,
53
- ed_author: '',
54
- acc_doc: nil,
55
- payer: nil,
56
- payee: nil,
57
- purpose: '',
58
- uin: nil,
59
- payt_kind: nil,
60
- payment_precedence: nil,
61
- processing_details: nil,
62
-
63
- system_code: SYSTEM_CODE,
64
- departmental_info: nil
65
- )
66
- raise InvalidPriority.new('priority Реквизит должен иметь значение в диапазоне 0-5.') unless (0..5).include?(priority.to_i)
67
-
68
- @ed_date = Date.parse(ed_date.to_s).strftime('%Y-%m-%d')
69
- @number = number
70
- @sum = sum
71
- @charge_off_date = Date.parse(charge_off_date.to_s).strftime('%Y-%m-%d')
72
- @receipt_date = Date.parse(receipt_date.to_s).strftime('%Y-%m-%d')
73
- @priority = priority
74
- @acc_doc = acc_doc.is_a?(Hash) ? Ufebs::Entities::AccDoc.new(acc_doc) : acc_doc
75
- @payer = payer.is_a?(Hash) ? Ufebs::Entities::Participant.new(payer) : payer
76
- @payee = payer.is_a?(Hash) ? Ufebs::Entities::Participant.new(payee) : payee
77
- @purpose = purpose
78
- @departmental_info = departmental_info.is_a?(Hash) ? Ufebs::Entities::DepartmentalInfo.new(departmental_info) : departmental_info
79
- @uin = uin
80
- @payt_kind = payt_kind
81
- @payment_precedence = payment_precedence
82
- @processing_details = processing_details.is_a?(Hash) ? ::Ufebs::Entities::ProcessingDetails.new(processing_details) : processing_details
83
-
84
- @ed_author = ed_author
85
- @type_number = DOCUMENT_NUMBER_TYPE
86
- @system_code = system_code
87
-
88
- yield self if block_given?
89
-
90
- super()
91
- end
92
14
  end
93
15
  end
94
16
  end
@@ -0,0 +1,22 @@
1
+ require_relative 'base_payment'
2
+ require_relative '../fields/payment_doc'
3
+
4
+ module Ufebs
5
+ module Documents
6
+ class PaymentRequirement < BasePayment
7
+ include HappyMapper
8
+ include Ufebs::Fields::PaymentDoc
9
+
10
+ register_namespace 'ed', "urn:cbr-ru:ed:v2.0"
11
+ tag 'ED103'
12
+ namespace 'ed'
13
+
14
+ attribute :receipt_date_collect_bank, String, tag: 'ReceiptDateCollectBank'
15
+ attribute :file_date, String, tag: 'FileDate'
16
+ attribute :payt_condition, String, tag: 'PaytCondition'
17
+ attribute :acpt_term, String, tag: 'AcptTerm'
18
+ attribute :doc_dispatch_date, String, tag: 'DocDispatchDate'
19
+ attribute :maturity_date, String, tag: 'MaturityDate'
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,31 @@
1
+ require_relative 'acc_doc'
2
+
3
+ module Ufebs
4
+ module Entities
5
+ class PartialPayt
6
+ include HappyMapper
7
+ register_namespace 'ed', 'urn:cbr-ru:ed:v2.0'
8
+ namespace 'ed'
9
+ tag 'PartialPayt'
10
+
11
+ attribute :payt_no, String, tag: 'PaytNo'
12
+ attribute :trans_kind, String, tag: 'TransKind'
13
+ attribute :sum_residual_payt, String, tag: 'SumResidualPayt'
14
+
15
+ has_one :acc_doc, ::Ufebs::Entities::AccDoc, tag: 'AccDoc'
16
+
17
+ def initialize(params = {})
18
+ params.each do |key, value|
19
+ case key.to_sym
20
+ when :acc_doc then set_acc_doc(value)
21
+ else instance_variable_set("@#{key}".to_sym, value)
22
+ end
23
+ end
24
+ end
25
+
26
+ def set_acc_doc(value)
27
+ @acc_doc = value.is_a?(Hash) ? ::Ufebs::Entities::AccDoc.new(value) : value
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,25 +2,26 @@ module Ufebs
2
2
  module Fields
3
3
  module PaymentDoc
4
4
  def self.included(content)
5
- content.attribute :number, String, tag: 'EDNo'
6
- content.attribute :ed_date, String, tag: 'EDDate'
7
- content.attribute :ed_author, String, tag: 'EDAuthor'
8
- content.attribute :sum, String, tag: 'Sum'
9
- content.attribute :payt_kind, String, tag: 'PaytKind'
10
- content.attribute :type_number, String, tag: 'TransKind'
11
- content.attribute :uin, String, tag: 'PaymentID'
12
- content.attribute :charge_off_date, String, tag: 'ChargeOffDate'
13
- content.attribute :receipt_date, String, tag: 'ReceiptDate'
14
- content.attribute :system_code, String, tag: 'SystemCode'
15
- content.attribute :priority, String, tag: 'Priority'
5
+ content.attribute :number, String, tag: 'EDNo'
6
+ content.attribute :ed_date, String, tag: 'EDDate'
7
+ content.attribute :ed_author, String, tag: 'EDAuthor'
8
+ content.attribute :sum, String, tag: 'Sum'
9
+ content.attribute :payt_kind, String, tag: 'PaytKind'
10
+ content.attribute :trans_kind, String, tag: 'TransKind'
11
+ content.attribute :uin, String, tag: 'PaymentID'
12
+ content.attribute :charge_off_date, String, tag: 'ChargeOffDate'
13
+ content.attribute :receipt_date, String, tag: 'ReceiptDate'
14
+ content.attribute :system_code, String, tag: 'SystemCode'
15
+ content.attribute :priority, String, tag: 'Priority'
16
16
  content.attribute :payment_precedence, String, tag: 'PaymentPrecedence'
17
- content.has_one :acc_doc, ::Ufebs::Entities::AccDoc, tag: 'AccDoc'
18
- content.has_one :payer, ::Ufebs::Entities::Participant, tag: 'Payer'
19
- content.has_one :payee, ::Ufebs::Entities::Participant, tag: 'Payee'
17
+
20
18
  content.element :purpose, String, tag: 'Purpose'
21
19
 
20
+ content.has_one :acc_doc, ::Ufebs::Entities::AccDoc, tag: 'AccDoc'
21
+ content.has_one :payer, ::Ufebs::Entities::Participant, tag: 'Payer'
22
+ content.has_one :payee, ::Ufebs::Entities::Participant, tag: 'Payee'
23
+ content.has_one :departmental_info, ::Ufebs::Entities::DepartmentalInfo, tag: 'DepartmentalInfo', state_when_nil: false
22
24
  content.has_one :processing_details, ::Ufebs::Entities::ProcessingDetails, tag: 'ProcessingDetails', state_when_nil: false
23
- content.has_one :departmental_info, Ufebs::Entities::DepartmentalInfo, tag: 'DepartmentalInfo', state_when_nil: false
24
25
  end
25
26
  end
26
27
  end
data/lib/ufebs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RubyUfebs
2
- VERSION = "0.2.23"
2
+ VERSION = "0.2.24"
3
3
  end
data/lib/ufebs.rb CHANGED
@@ -104,15 +104,15 @@ module Ufebs
104
104
  end
105
105
 
106
106
  def ED103(params)
107
- params.is_a?(Hash) ? Ufebs::Documents::PaymentClaim.new(params) : Ufebs::Documents::PaymentClaim.parse(params)
107
+ params.is_a?(Hash) ? Ufebs::Documents::PaymentRequirement.new(params) : Ufebs::Documents::PaymentRequirement.parse(params)
108
108
  end
109
109
 
110
110
  def ED104(params)
111
- params.is_a?(Hash) ? Ufebs::Documents::InvoiceOrder.new(params) : Ufebs::Documents::InvoiceOrder.parse(params)
111
+ params.is_a?(Hash) ? Ufebs::Documents::CollectionOrder.new(params) : Ufebs::Documents::CollectionOrder.parse(params)
112
112
  end
113
113
 
114
114
  def ED105(params)
115
- params.is_a?(Hash) ? Ufebs::Documents::BillingOrder.new(params) : Ufebs::Documents::BillingOrder.parse(params)
115
+ params.is_a?(Hash) ? Ufebs::Documents::PayerOrder.new(params) : Ufebs::Documents::PayerOrder.parse(params)
116
116
  end
117
117
 
118
118
  def ED107(params)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_ufebs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.23
4
+ version: 0.2.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Burdaev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -394,15 +394,15 @@ files:
394
394
  - lib/ufebs/configuration.rb
395
395
  - lib/ufebs/documents/bank_order.rb
396
396
  - lib/ufebs/documents/base_payment.rb
397
- - lib/ufebs/documents/billing_order.rb
398
- - lib/ufebs/documents/invoice_order.rb
397
+ - lib/ufebs/documents/collection_order.rb
399
398
  - lib/ufebs/documents/memorial_order.rb
400
399
  - lib/ufebs/documents/package.rb
401
400
  - lib/ufebs/documents/package_response.rb
402
- - lib/ufebs/documents/payment_claim.rb
401
+ - lib/ufebs/documents/payer_order.rb
403
402
  - lib/ufebs/documents/payment_order.rb
404
403
  - lib/ufebs/documents/payment_order_ed107.rb
405
404
  - lib/ufebs/documents/payment_order_ed108.rb
405
+ - lib/ufebs/documents/payment_requirement.rb
406
406
  - lib/ufebs/documents/payment_response.rb
407
407
  - lib/ufebs/documents/some_order.rb
408
408
  - lib/ufebs/entities/acc_doc.rb
@@ -415,6 +415,7 @@ files:
415
415
  - lib/ufebs/entities/ed_reestr_info.rb
416
416
  - lib/ufebs/entities/ed_ref_id.rb
417
417
  - lib/ufebs/entities/initial_packet.rb
418
+ - lib/ufebs/entities/partial_payt.rb
418
419
  - lib/ufebs/entities/participant.rb
419
420
  - lib/ufebs/entities/processing_details.rb
420
421
  - lib/ufebs/entities/session.rb
@@ -1,15 +0,0 @@
1
- require_relative 'base_payment'
2
- require_relative '../fields/payment_doc'
3
-
4
- module Ufebs
5
- module Documents
6
- class BillingOrder < BasePayment
7
- include HappyMapper
8
- include Ufebs::Fields::PaymentDoc
9
-
10
- register_namespace 'ed', "urn:cbr-ru:ed:v2.0"
11
- tag 'ED105'
12
- namespace 'ed'
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require_relative 'base_payment'
2
- require_relative '../fields/payment_doc'
3
-
4
- module Ufebs
5
- module Documents
6
- class InvoiceOrder < BasePayment
7
- include HappyMapper
8
- include Ufebs::Fields::PaymentDoc
9
-
10
- register_namespace 'ed', "urn:cbr-ru:ed:v2.0"
11
- tag 'ED104'
12
- namespace 'ed'
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require_relative 'base_payment'
2
- require_relative '../fields/payment_doc'
3
-
4
- module Ufebs
5
- module Documents
6
- class PaymentClaim < BasePayment
7
- include HappyMapper
8
- include Ufebs::Fields::PaymentDoc
9
-
10
- register_namespace 'ed', "urn:cbr-ru:ed:v2.0"
11
- tag 'ED103'
12
- namespace 'ed'
13
- end
14
- end
15
- end