Sha256: 45269a496ff515060232e83b7029948464bea3cef1fc5358bf991df222806176
Contents?: true
Size: 831 Bytes
Versions: 3
Compression:
Stored size: 831 Bytes
Contents
require 'atol/errors' module Atol module Request class PostDocument module Item class Body def initialize(name:, price:, quantity: 1, config: nil) raise Atol::ZeroItemQuantityError if quantity.to_i.zero? @config = config || Atol.config @name = name @price = price.to_f @quantity = quantity.to_f end def to_h body.clone end def to_json body.to_json end private def body @body ||= { name: @name, price: @price, quantity: @quantity, sum: (@price * @quantity).round(2), tax: @config.default_tax } end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
atol-0.4.2 | lib/atol/request/post_document/item/body.rb |
atol-0.4.1 | lib/atol/request/post_document/item/body.rb |
atol-0.4 | lib/atol/request/post_document/item/body.rb |