Module: Ufebs

Extended by:
Ufebs
Included in:
Ufebs
Defined in:
lib/ufebs.rb,
lib/ufebs/configuration.rb,
lib/ufebs/entities/bank.rb,
lib/ufebs/fields/header.rb,
lib/ufebs/entities/acc_doc.rb,
lib/ufebs/documents/package.rb,
lib/ufebs/entities/participant.rb,
lib/ufebs/requests/test_request.rb,
lib/ufebs/requests/group_request.rb,
lib/ufebs/documents/payment_order.rb,
lib/ufebs/requests/package_request.rb,
lib/ufebs/entities/departmental_info.rb,
lib/ufebs/entities/processing_details.rb

Defined Under Namespace

Modules: Documents, Entities, Fields, Requests Classes: Configuration

Instance Method Summary collapse

Instance Method Details

#configurationObject



16
17
18
# File 'lib/ufebs.rb', line 16

def configuration
  @configuration ||= Configuration.new
end

#configure(&block) ⇒ Object

Конфигурация



21
22
23
# File 'lib/ufebs.rb', line 21

def configure(&block)
  block.call(configuration)
end

#ED101(params) ⇒ Ufebs::Documents::PaymentOrder+

Создание XML по формату ED101(Платежное поручение)

Examples:

Пример документа

ed101 = Ufebs::ED101(
  number: 7,
  sum: 150000,
  receipt_date: Time.now,
  acc_doc: { number: '3', date: Time.now },
  ed_author: 4525595000
  purpose: 'оплата в том числе ндс 4000 руб',
  payer: {
    name: 'ООО ТЕСТ',
    account: '40702810200203001037',
    inn: '7726274727',
    bank_bic: '044525545',
    bank_account: '30101810300000000545'
  },
  payee: {
    name: 'ООО ТЕСТ',
    account: '40702810200203001037',
    inn: '7726274727',
    bank_bic: '044525545',
    bank_account: '30101810300000000545'
  },
  departmental_info: {
    kbk: '18210301000010000110',
    okato: '45263591000',
    drawer_status: '01',
    tax_period: 'МС.03.2017',
    tax_payt_kind: 'НС',
    doc_no: '111',
    payt_reason: 'ТП'
  }
)
ed101.to_xml(Nokogiri::XML::Builder.new(encoding: 'UTF-8'), nil, nil).to_xml #=>
 '<?xml version="1.0" encoding="UTF-8"?>
 <ed:ED101 xmlns:ed="urn:cbr-ru:ed:v2.0" EDNo="7" EDDate="2017-12-11" EDAuthor="4525595000" Sum="150000" TransKind="01" ChargeOffDate="2017-12-11" ReceiptDate="2017-12-11" SystemCode="01" Priority="0">
   <ed:AccDoc AccDocNo="003" AccDocDate="2017-12-11"/>
   <ed:Payer INN="7726274727" PersonalAcc="40702810200203001037">
     <ed:Name>ООО ТЕСТ</ed:Name>
     <ed:Bank BIC="044525545" CorrespAcc="30101810300000000545"/>
   </ed:Payer>
   <ed:Payee INN="7726274727" PersonalAcc="40702810200203001037">
     <ed:Name>ООО ТЕСТ</ed:Name>
     <ed:Bank BIC="044525545" CorrespAcc="30101810300000000545"/>
   </ed:Payee>
   <ed:Purpose>оплата в том числе ндс 4000 руб</ed:Purpose>
   <ed:DepartmentalInfo CBC="18210301000010000110" OKATO="45263591000" TaxPeriod="МС.03.2017" DrawerStatus="01" PaytReason="ТП" DocNo="111" TaxPaytKind="НС" DocDate="2017-12-11"/>
 </ed:ED101>'

Чтение XML

Ufebs::ED101(File.read('packet_epd.xml')) #=> [#<Ufebs::Documents::PaymentOrder:0x00..>]

Parameters:

  • params (Hash, String)

    Hash значений документа или его строковое представление в виде XML

Options Hash (params):

  • :number (Integer)

    номер документа аттрибут EDNo

  • :sum (Integer)

    Сумма документа аттрибут Sum

  • :receipt_date (DateTime)

    ReceiptDate дата обработки

  • :acc_doc (Hash)

    AccDoc информация о счете(number: Номер исходного расчетного документа, date: Дата выписки расчетного документа

  • :purpose (String)

    Purpose предназначение-описание платежа

  • :payer (Hash)

    Payer плательщик

  • :payer (Hash)

    Payee получатель

  • :departmental_info (Hash) — default: {}

    DepartmentalInfo Ведомственная информация

Returns:



114
115
116
# File 'lib/ufebs.rb', line 114

def ED101(params)
  params.is_a?(Hash) ? Ufebs::Documents::PaymentOrder.new(params) : Ufebs::Documents::PaymentOrder.parse(params)
end

#ED210(params) ⇒ Object



41
42
# File 'lib/ufebs.rb', line 41

def ED210(params)
end

#ED218(params) ⇒ Object



47
48
# File 'lib/ufebs.rb', line 47

def ED218(params)
end

#ED243(params) ⇒ Object



44
45
# File 'lib/ufebs.rb', line 44

def ED243(params)
end

#ED244Object



50
51
# File 'lib/ufebs.rb', line 50

def ED244
end

#ED999(params) ⇒ Object

XML запрос-зонд

Parameters:

  • params (Hash)
  • :number (Hash)

    a customizable set of options

  • :ed_date (Hash)

    a customizable set of options

  • :ed_author (Hash)

    a customizable set of options



37
38
39
# File 'lib/ufebs.rb', line 37

def ED999(params)
  Ufebs::Requests::TestRequest.new(params)
end

#namespaceObject



12
13
14
# File 'lib/ufebs.rb', line 12

def namespace
  "urn:cbr-ru:ed:v2.0".freeze
end

#PackedEPD(payment_eds, params) ⇒ Object



118
119
120
# File 'lib/ufebs.rb', line 118

def PackedEPD(payment_eds, params)
  Ufebs::Documents::Package.new(payment_eds, params)
end

#validate(doc) ⇒ Object



122
123
124
125
126
127
128
129
130
131
# File 'lib/ufebs.rb', line 122

def validate(doc)
  doc = Nokogiri::XML(doc) if doc.is_a?(String)

  errors = []
  validation_schema.validate(doc).each do |error|
    errors << error.message
    puts error.message
  end
  errors.empty?
end

#validation_schemaObject



25
26
27
28
29
30
# File 'lib/ufebs.rb', line 25

def validation_schema
  @validation ||= begin
                    validation = Nokogiri::XML(File.read(configuration.schemas), configuration.schemas)
                    Nokogiri::XML::Schema.from_document(validation)
                  end
end