- A
- B
- C
- D
- N
- R
- S
- T
Attributes
| [R] | coupon | |
| [R] | currency | |
| [R] | customer_id | |
| [R] | description | |
| [R] | id | |
| [R] | items | |
| [R] | status |
Class Public methods
new(data, policy) Link
Source: show
# File app/models/billing/invoice.rb, line 5 def initialize(data, policy) data = policy.new(data).data @id = data.id @customer_id = data.customer_id @timestamp = data.timestamp @status = data.status @description = data.description @currency = data.currency @total = data.total @amount_due = data.amount_due @amount_refunded = data.amount_refunded @applied_balance = data.applied_balance @timestamp_start = data.try(:timestamp_start) @timestamp_end = data.try(:timestamp_end) @tax = data.try(:tax) @tax_percent = data.try(:tax_percent) @coupon = generate_coupon(data.coupon) @items = generate_invoice_items(data.items) end
Instance Public methods
amount_due() Link
Source: show
# File app/models/billing/invoice.rb, line 67 def amount_due Service::Money.new(@amount_due, @currency).format end
amount_refunded() Link
Source: show
# File app/models/billing/invoice.rb, line 48 def amount_refunded @amount_refunded || 0 end
applied_balance() Link
Source: show
# File app/models/billing/invoice.rb, line 60 def applied_balance if @applied_balance && @applied_balance < 0 Service::Money.new(@applied_balance, @currency).format end end
billing_period() Link
Source: show
# File app/models/billing/invoice.rb, line 36 def billing_period if @timestamp_start && @timestamp_end start = format_timestamp @timestamp_start stop = format_timestamp @timestamp_end I18n.t("time.ranges.period", from: start, upto: stop) end end
coupon_description() Link
Source: show
# File app/models/billing/invoice.rb, line 89 def coupon_description if coupon.present? coupon.description end end
date() Link
Source: show
# File app/models/billing/invoice.rb, line 27 def date format_timestamp @timestamp end
date_short() Link
Source: show
# File app/models/billing/invoice.rb, line 31 def date_short time = Time.zone.at @timestamp I18n.l(time, format: :short_ordinal) end
refund?() Link
Source: show
# File app/models/billing/invoice.rb, line 71 def refund? @amount_refunded && @amount_refunded > 0 end
refund_amount() Link
Source: show
# File app/models/billing/invoice.rb, line 75 def refund_amount Service::Money.new(@amount_refunded, @currency).format end
starting_balance() Link
Source: show
# File app/models/billing/invoice.rb, line 56 def starting_balance Service::Money.new(@starting_balance, @currency).format if @starting_balance end
tax_line() Link
Source: show
# File app/models/billing/invoice.rb, line 79 def tax_line if @items.last.plan_id plan = DB::Plan.find_by({payment_gateway_id: @items.last.plan_id}) if plan && @tax_percent.to_i > 0 && @tax.to_i > 0 "#{plan.tax_description} #{@tax_percent}% : #{Service::Money.new(@tax, @currency).format}" end end end