Sha256: 8f9d50857a54beeb232568dbadd02bb1886ecc81fe79a11a191d57fef971c489

Contents?: true

Size: 576 Bytes

Versions: 8

Compression:

Stored size: 576 Bytes

Contents

class Receipt < ActiveRecord::Base
  belongs_to :document, :polymorphic => true
  serialize :fields

  scope :recent, where(
    arel_table[:created_at].gt(Date.today-1.month).or(arel_table[:printed].eq(false))
  ).order(arel_table[:id].desc)

  def print
    data   = fields.merge(:id => id, :keyword => Terminal.config.keyword)
    result = Liquid::Template.parse(template).render data.with_indifferent_access
    update_attributes(:printed => true) if Smartware.printer.print_text(result, 15)
  end

  def document_title
    document.blank? ? '' : document.title
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
smartkiosk-client-0.2.1 app/models/receipt.rb
smartkiosk-client-0.2 app/models/receipt.rb
smartkiosk-client-0.1.19 app/models/receipt.rb
smartkiosk-client-0.1.18 app/models/receipt.rb
smartkiosk-client-0.1.17 app/models/receipt.rb
smartkiosk-client-0.1.16 app/models/receipt.rb
smartkiosk-client-0.1.15 app/models/receipt.rb
smartkiosk-client-0.1.14 app/models/receipt.rb