- C
- M
- N
- O
- P
- S
- T
- ActiveModel::Validations
Attributes
| [R] | admin_view | |
| [R] | data | |
| [R] | member | |
| [R] | member_payment_gateway_id | |
| [R] | plan_payment_gateway_id | |
| [R] | proration_date | |
| [R] | subscription_payment_gateway_id |
Class Public methods
new(member:, proration_date: 20.minutes.from_now.to_i, new_plan: nil, admin_view: false) Link
Source: show
# File app/models/billing/upcoming_invoice.rb, line 8 def initialize(member:, proration_date: 20.minutes.from_now.to_i, new_plan: nil, admin_view: false) @member = member @proration_date = proration_date @plan_payment_gateway_id = new_plan @member_payment_gateway_id = member.payment_gateway_id @subscription_payment_gateway_id = member.active_subscription&.payment_gateway_id @data = stripe_invoice_data @admin_view = admin_view end
Instance Public methods
changing?() Link
Source: show
# File app/models/billing/upcoming_invoice.rb, line 21 def changing? !!new_plan&.subscription_plan_type? && !!member_payment_gateway_id && !!subscription_payment_gateway_id end
coupon_message() Link
Source: show
# File app/models/billing/upcoming_invoice.rb, line 29 def coupon_message coupon = data[:coupon] return unless coupon fetcher = Action::CouponFetcher.new(member.site, plan) coupon_data = fetcher.coupon_message(coupon) "#{translate("coupon_discount")}: #{coupon_data}" end
message() Link
Source: show
# File app/models/billing/upcoming_invoice.rb, line 25 def message @message ||= changing? ? "#{proration_message} #{next_bill_message}" : new_subscription_message end
old_sub() Link
Source: show
# File app/models/billing/upcoming_invoice.rb, line 55 def old_sub @old_sub ||= DB::Subscription.where(payment_gateway_id: subscription_payment_gateway_id).last end
prorated_amount_due() Link
Source: show
# File app/models/billing/upcoming_invoice.rb, line 38 def prorated_amount_due return nil unless changing? current_prorations = data[:items].select { |item| item[:timestamp_start] == proration_date } current_prorations.inject(0) { |cost, proration| cost + proration[:amount] } end