Class: InvoicesWithTotal
- Inherits:
-
Invoice
- Object
- ActiveRecord::Base
- Invoice
- InvoicesWithTotal
show all
- Defined in:
- app/model_views/invoices_with_total.rb
Constant Summary
Constants inherited
from Invoice
Invoice::ACTIVITY_TOTAL_SQL
Instance Method Summary
collapse
Methods inherited from Invoice
#amount, #amount_outstanding, #amount_paid, #authorized_for?, #ensure_not_published_on_destroy, #ensure_not_published_on_update, #ensure_were_the_most_recent, find_with_totals, #grand_total, #initialize, #invalid_if_published, #is_most_recent_invoice?, #is_paid?, #long_name, #mark_invoice_payments, #name, #paid_on, #reattach_activities, #remove_invoice_payments, #sub_total, #taxes_total, #validate_on_update
append_features
Constructor Details
This class inherits a constructor from Invoice
Instance Method Details
#create(*args) ⇒ Object
9
10
11
|
# File 'app/model_views/invoices_with_total.rb', line 9
def create(*args)
invoice_assign_and_save! Invoice.new
end
|
#destroy ⇒ Object
17
18
19
20
|
# File 'app/model_views/invoices_with_total.rb', line 17
def destroy
inv = Invoice.find(id)
inv.destroy
end
|
#invoice_assign_and_save!(inv) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/model_views/invoices_with_total.rb', line 22
def invoice_assign_and_save!(inv)
invoice_columns = Invoice.columns.collect{|c| c.name}-['id']
inv.activity_type_ids = activity_type_ids
attributes.reject{|k,v| true unless invoice_columns.include? k }.each{ |k,v| inv.send "#{k}=", v }
inv.save!
inv.errors.each { |attr,msg| errors.add attr, msg }
inv
end
|
#update ⇒ Object
13
14
15
|
# File 'app/model_views/invoices_with_total.rb', line 13
def update
invoice_assign_and_save! Invoice.find(id)
end
|