25 lines
474 B
Ruby
25 lines
474 B
Ruby
class PCommercial < ApplicationRecord
|
|
validates :name, :presence => true
|
|
validates :firstname, :presence => true
|
|
|
|
def long_name
|
|
self.firstname + " " + self.name
|
|
end
|
|
|
|
has_many :p_customers
|
|
|
|
has_many :p_customer_sheets
|
|
|
|
has_many :p_documents
|
|
|
|
|
|
def ca_ht
|
|
self.p_documents.where(:p_document_type_id => [4,7]).sum(:cache_total_ht)
|
|
end
|
|
|
|
def ca_ttc
|
|
self.p_documents.where(:p_document_type_id => [4,7]).sum(:cache_total_ttc)
|
|
end
|
|
|
|
end
|