Class: OrangeData::ReceiptResult
- Inherits:
-
PayloadContent
- Object
- PayloadContent
- OrangeData::ReceiptResult
- Defined in:
- lib/orange_data/receipt.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(payload) ⇒ ReceiptResult
constructor
A new instance of ReceiptResult.
- #qr_code_content ⇒ Object
Methods inherited from PayloadContent
#==, #assign_attributes, #to_hash, #to_json
Constructor Details
#initialize(payload) ⇒ ReceiptResult
Returns a new instance of ReceiptResult.
170 171 172 173 |
# File 'lib/orange_data/receipt.rb', line 170 def initialize(payload) @payload = payload @content = ReceiptContent.new(@payload["content"]) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
180 181 182 |
# File 'lib/orange_data/receipt.rb', line 180 def content @content end |
Class Method Details
.from_hash(hash) ⇒ Object
175 176 177 178 |
# File 'lib/orange_data/receipt.rb', line 175 def self.from_hash(hash) raise ArgumentError, 'Expect hash here' unless hash.is_a?(Hash) new(hash) end |
Instance Method Details
#qr_code_content ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/orange_data/receipt.rb', line 183 def qr_code_content # Пример: t=20150720T1638&s=9999999.00&fn=000110000105&i=12345678&fp=123456&n=2 { # - t=<date/time - дата и время осуществления расчета в формате ГГГГММДДТЧЧММ> t: processed_at.gsub(/:\d{2}\z/, '').gsub(/[^0-9T]/, ''), # - s=<сумма расчета в рублях и копейках, разделенных точкой> s: content.check_close.payments.inject(0.0){|d, p| d + p.amount }, # - fn=<заводской номер фискального накопителя> fn: fs_number, # - i=<порядковый номер фискального документа, нулями не дополняется> i: document_number, # documentIndex?? # - fp=<фискальный признак документа, нулями не дополняется> fp: fp, # - n=<признак расчета>. n: content.raw_type, }.map{|k, v| "#{k}=#{v}" }.join('&') end |