Sha256: ad767cc548d858a24104cf95c67380e08a4dbbacf279f21f6e45a5c7569f1312

Contents?: true

Size: 629 Bytes

Versions: 2

Compression:

Stored size: 629 Bytes

Contents

require 'atol/errors'

module Atol
  module Request
    class PostDocument
      module Item
        class Body
          def initialize(name:, price:, quantity: 1, config: nil)
            @config = config || Atol.config

            @body = Hash[]
            @body[:name] = name
            @body[:price] = price.to_f
            @body[:quantity] = quantity.to_f
            @body[:sum] = @body[:price] * @body[:quantity]
            @body[:tax] = @config.default_tax
          end

          def to_h
            body.clone
          end

          private

          attr_reader :body
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
atol-0.1.1 lib/atol/request/post_document/item/body.rb
atol-0.1 lib/atol/request/post_document/item/body.rb