Class: Atol::Request::PostDocument::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/atol/request/post_document/payment.rb

Constant Summary collapse

CASH_TYPE =

наличные

0
CASHLESS_TYPE =

безналичный

1
PREPAID_TYPE =

предоплата/зачёт аванса (тег 1215)

2
POSTPAID_TYPE =

постоплата/кредит

3
COUNTER_PROVISION_TYPE =

встречное предоставление

4
EXTENDED_5_TYPE =

расширенный тип оплаты 5

5
EXTENDED_6_TYPE =

расширенный тип оплаты 6

6
EXTENDED_7_TYPE =

расширенный тип оплаты 7

7
EXTENDED_8_TYPE =

расширенный тип оплаты 8

8
EXTENDED_9_TYPE =

расширенный тип оплаты 9

9
TYPES =
[
  CASH_TYPE, CASHLESS_TYPE, PREPAID_TYPE, POSTPAID_TYPE, COUNTER_PROVISION_TYPE,
  EXTENDED_5_TYPE, EXTENDED_6_TYPE, EXTENDED_7_TYPE, EXTENDED_8_TYPE, EXTENDED_9_TYPE
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, sum:) ⇒ Payment

Returns a new instance of Payment.



27
28
29
30
31
32
33
# File 'lib/atol/request/post_document/payment.rb', line 27

def initialize(type:, sum:)
  raise(Atol::BadPaymentError, 'not allowed type') unless TYPES.include?(type)
  raise(Atol::BadPaymentError, 'sum must be zero or a positive number') unless sum.is_a?(Numeric) && sum >= 0

  @type = type
  @sum = sum
end

Instance Attribute Details

#sumObject (readonly)

Returns the value of attribute sum.



25
26
27
# File 'lib/atol/request/post_document/payment.rb', line 25

def sum
  @sum
end

#typeObject (readonly)

Returns the value of attribute type.



25
26
27
# File 'lib/atol/request/post_document/payment.rb', line 25

def type
  @type
end

Instance Method Details

#to_hObject



35
36
37
# File 'lib/atol/request/post_document/payment.rb', line 35

def to_h
  { sum: sum, type: type }
end