Sha256: 1f5290d30463207aa851ca8972a408c0d1178cec7ff9aa032a5fe4df96a61d5c
Contents?: true
Size: 973 Bytes
Versions: 11
Compression:
Stored size: 973 Bytes
Contents
module Crm class Invoice < ::ApplicationRecord self.table_name = "Invoice" self.primary_key = "InvoiceId" belongs_to :account, foreign_key: 'AccountId', crm_key: 'customerid_account' belongs_to :contact, foreign_key: 'ContactId', crm_key: 'customerid_contact' belongs_to :opportunity, foreign_key: 'OpportunityId', crm_key: 'opportunityid' belongs_to :price_list, foreign_key: 'PriceLevelId', crm_key: 'pricelevelid' belongs_to :currency, foreign_key: 'TransactionCurrencyId', crm_key: 'transactioncurrencyid' has_many :invoice_products, foreign_key: 'InvoiceId' has_many :notes, foreign_key: 'ObjectId', class_name: "Crm::InvoiceNote" validates :Name, presence: true validates :price_list, presence: true validate :contact_xor_account private def contact_xor_account unless contact.blank? ^ account.blank? errors.add(:base, "Specify a contact or account, not both") end end end end
Version data entries
11 entries across 11 versions & 1 rubygems