Class: InvoiceBar::Receipt

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Billable::Associations::Base, Billable::Base, Billable::Filters, Billable::Receipting, Billable::StrictValidations, Searchable
Defined in:
app/models/invoice_bar/receipt.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_invoice(invoice) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/models/invoice_bar/receipt.rb', line 48

def self.for_invoice(invoice)
  receipt = Receipt.new
  receipt.contact_name = invoice.contact_name
  receipt.contact_tax_id = invoice.contact_tax_id
  receipt.contact_tax_id2 = invoice.contact_tax_id2
  receipt. = invoice.
  receipt.issue_date = Date.today

  receipt.user_address = invoice.user_address.copy(
    addressable_type: "InvoiceBar::Receipt#user_address"
  )
  receipt.address = invoice.address.copy(
    addressable_type: "InvoiceBar::Receipt#contact_address"
  )

  invoice.items.each do |item|
    receipt.items << item.copy
  end

  receipt.note = invoice.note

  receipt
end

.searchable_fieldsObject



44
45
46
# File 'app/models/invoice_bar/receipt.rb', line 44

def self.searchable_fields
  %w( number contact_name contact_tax_id )
end

Instance Method Details

#mark_as_paidObject



72
73
74
# File 'app/models/invoice_bar/receipt.rb', line 72

def mark_as_paid
  self.paid = true
end

#mark_as_sentObject



76
77
78
# File 'app/models/invoice_bar/receipt.rb', line 76

def mark_as_sent
  self.sent = true
end