Sha256: 744a14dcc74a9e949e03426acd9e851eace8c9721002f7c8aad4b8d3f0459c89

Contents?: true

Size: 699 Bytes

Versions: 1

Compression:

Stored size: 699 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

            raise Atol::ZeroItemQuantityError if quantity.to_i.zero?

            @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

1 entries across 1 versions & 1 rubygems

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