Table name: invoice_transaction_views
id :string(23) primary key payment_type_id :integer default(0), not null resource_id :integer resource_type :string(255) to_user_id :integer from_user_id :integer paid :integer charged :integer email_notifications :integer last_notification :datetime description :string(255) payable_amount :integer manually_billed :integer university_id :integer payment_type :string(11) default(""), not null created_at :datetime
Returns chargeable amount.
# File app/models/invoice_transaction_view.rb, line 98 def chargable_amount if self.payment_type == 'Transaction' chargable_amount = payable_amount.cents + Money.new(100).cents elsif self.payment_type == 'Invoice' payable_amount.cents end end
Return payable amount in the form of money object with its currency.
# File app/models/invoice_transaction_view.rb, line 93 def payable_amount Money.new(self[:payable_amount], Money.default_currency) end
Returns status of invoice transaction.
# File app/models/invoice_transaction_view.rb, line 82 def status if paid? 'Paid' elsif resource.is_a? TutoringSession (resource.occured.nil? or resource.occured?) ? 'Pending' : 'Rejected' else 'Pending' end end
Return title for tutor when user pay to tutor.
# File app/models/invoice_transaction_view.rb, line 51 def title_from_user if self.payment_type == 'Transaction' "#{self.from_user.name} paid you." elsif self.payment_type == 'Invoice' if paid? "#{self.from_user.name} paid you." else "You charged #{self.from_user.name}." end elsif self.resource.present? if self.resource.is_a? TutoringSession "You sent an invoice to #{self.from_user.name} for an tutoring session" end end end
Return title for user when user pay to tutor.
# File app/models/invoice_transaction_view.rb, line 34 def title_to_user if self.payment_type == 'Transaction' "You paid #{self.to_user.name}." elsif self.payment_type == 'Invoice' if paid? "You paid #{self.to_user.name}." else "#{self.to_user.name} Charged you." end elsif self.resource.present? if self.resource.is_a? TutoringSession "#{self.to_user.name} sent you an invoice for an tutoring session" end end end
Return total amount in the form of money object with its currency.
# File app/models/invoice_transaction_view.rb, line 77 def total_amount Money.new(total_chargable_amount, Money.default_currency) end
Returns total chargeable amount.
# File app/models/invoice_transaction_view.rb, line 68 def total_chargable_amount if chargable_amount > self.from_user.total_balance.cents ((chargable_amount*1.029)+30).round(0) else chargable_amount end end