Sha256: c73e6a503f68b2b172945a51e746b6f6cc0a27b001addccd53721a8bcf9b4ead

Contents?: true

Size: 594 Bytes

Versions: 23

Compression:

Stored size: 594 Bytes

Contents

require 'liquid'

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

23 entries across 23 versions & 1 rubygems

Version Path
smartkiosk-client-0.1.13 app/models/receipt.rb
smartkiosk-client-0.1.12 app/models/receipt.rb
smartkiosk-client-0.1.11 app/models/receipt.rb
smartkiosk-client-0.1.10 app/models/receipt.rb
smartkiosk-client-0.1.9 app/models/receipt.rb
smartkiosk-client-0.1.8 app/models/receipt.rb
smartkiosk-client-0.1.7 app/models/receipt.rb
smartkiosk-client-0.1.6 app/models/receipt.rb
smartkiosk-client-0.1.5 app/models/receipt.rb
smartkiosk-client-0.1.4 app/models/receipt.rb
smartkiosk-client-0.1.3 app/models/receipt.rb
smartkiosk-client-0.1.2 app/models/receipt.rb
smartkiosk-client-0.1.1 app/models/receipt.rb
smartkiosk-client-0.1.0 app/models/receipt.rb
smartkiosk-client-0.0.28 app/models/receipt.rb
smartkiosk-client-0.0.26 app/models/receipt.rb
smartkiosk-client-0.0.25 app/models/receipt.rb
smartkiosk-client-0.0.24 app/models/receipt.rb
smartkiosk-client-0.0.23 app/models/receipt.rb
smartkiosk-client-0.0.22 app/models/receipt.rb