Sha256: 7b31f8f4a106e27b5f62f4eb25f85c4b5b9800f69e252b5cc0dcfda1205bfffe
Contents?: true
Size: 1.91 KB
Versions: 2
Compression:
Stored size: 1.91 KB
Contents
module InvoicePrinter class Document # Line items for InvoicePrinter::Document # # Example: # # item = InvoicePrinter::Document::Item.new( # name: 'UX consultation', # quantity: '4', # unit: 'hours', # price: '$ 25', # tax: '$ 5' # amount: '$ 120' # ) # # +amount+ should equal the +quantity+ times +price+, # but this is not enforced. class Item attr_reader :name, :quantity, :unit, :price, :tax, :tax2, :tax3, :amount class << self def from_json(json) new( name: json['name'], quantity: json['quantity'], unit: json['unit'], price: json['price'], tax: json['tax'], tax2: json['tax2'], tax3: json['tax3'], amount: json['amount'] ) end end def initialize(name: nil, quantity: nil, unit: nil, price: nil, tax: nil, tax2: nil, tax3: nil, amount: nil) @name = String(name) @quantity = String(quantity) @unit = String(unit) @price = String(price) @tax = String(tax) @tax2 = String(tax2) @tax3 = String(tax3) @amount = String(amount) end def to_h { 'name': @name, 'quantity': @quantity, 'unit': @unit, 'price': @price, 'tax': @tax, 'tax2': @tax2, 'tax3': @tax3, 'amount': @amount, } end def to_json to_h.to_json end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
invoice_printer-1.2.0 | lib/invoice_printer/document/item.rb |
invoice_printer-1.2.0.alpha1 | lib/invoice_printer/document/item.rb |