diff --git a/app/graphql/types/invoice_subscription/object.rb b/app/graphql/types/invoice_subscription/object.rb index b9b27858fa6..d31972393df 100644 --- a/app/graphql/types/invoice_subscription/object.rb +++ b/app/graphql/types/invoice_subscription/object.rb @@ -39,7 +39,7 @@ def should_use_in_advance_charges_interval return @should_use_in_advance_charges_interval if defined? @should_use_in_advance_charges_interval @should_use_in_advance_charges_interval = - object.fees.charge_kind.any? && + object.fees.charge.any? && object.subscription.plan.charges.where(pay_in_advance: true).any? && !object.subscription.plan.pay_in_advance? end diff --git a/app/models/fee.rb b/app/models/fee.rb index b13c3b91ca8..dfec68cde13 100644 --- a/app/models/fee.rb +++ b/app/models/fee.rb @@ -50,10 +50,6 @@ class Fee < ApplicationRecord validates :true_up_fee_id, presence: false, unless: :charge? validates :total_aggregated_units, presence: true, if: :charge? - scope :subscription_kind, -> { where(fee_type: :subscription) } - scope :charge_kind, -> { where(fee_type: :charge) } - scope :commitment_kind, -> { where(fee_type: :commitment) } - scope :positive_units, -> { where('units > ?', 0) } # NOTE: pay_in_advance fees are not be linked to any invoice, but add_on fees does not have any subscriptions diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 1edd5075a26..5a4a02f4597 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -162,11 +162,11 @@ def fee_total_amount_cents end def charge_amount_cents - fees.charge_kind.sum(:amount_cents) + fees.charge.sum(:amount_cents) end def subscription_amount_cents - fees.subscription_kind.sum(:amount_cents) + fees.subscription.sum(:amount_cents) end def invoice_subscription(subscription_id) @@ -185,7 +185,7 @@ def progressice_billing_credits(subscription) def existing_fees_in_interval?(subscription_id:, charge_in_advance: false) subscription_fees(subscription_id) - .charge_kind + .charge .positive_units .where(true_up_parent_fee: nil) .joins(:charge) diff --git a/app/models/invoice_subscription.rb b/app/models/invoice_subscription.rb index 3c1c38348c2..04a6d8b5e65 100644 --- a/app/models/invoice_subscription.rb +++ b/app/models/invoice_subscription.rb @@ -71,7 +71,7 @@ def previous_invoice_subscription end def charge_amount_cents - fees.charge_kind.sum(:amount_cents) + fees.charge.sum(:amount_cents) end def subscription_amount_cents @@ -79,11 +79,11 @@ def subscription_amount_cents end def subscription_fee - fees.subscription_kind.first + fees.subscription.first end def commitment_fee - fees.commitment_kind.first + fees.commitment.first end def total_amount_cents diff --git a/app/models/subscription.rb b/app/models/subscription.rb index 7a2438cb2f8..cbdc7eedd64 100644 --- a/app/models/subscription.rb +++ b/app/models/subscription.rb @@ -120,7 +120,7 @@ def next_subscription end def already_billed? - fees.subscription_kind.any? + fees.subscription.any? end def starting_in_the_future? diff --git a/app/services/commitments/minimum/in_advance/calculate_true_up_fee_service.rb b/app/services/commitments/minimum/in_advance/calculate_true_up_fee_service.rb index ed454b81be1..8033bc4bc4c 100644 --- a/app/services/commitments/minimum/in_advance/calculate_true_up_fee_service.rb +++ b/app/services/commitments/minimum/in_advance/calculate_true_up_fee_service.rb @@ -25,7 +25,7 @@ def subscription_fees ).call Fee - .subscription_kind + .subscription .joins(subscription: :plan) .where( "(fees.properties->>'from_datetime') >= ?", @@ -45,7 +45,7 @@ def charge_fees invoices_result = FetchInvoicesService.call(commitment: minimum_commitment, invoice_subscription:) Fee - .charge_kind + .charge .joins(:charge) .where( subscription_id: subscription.id, @@ -61,7 +61,7 @@ def charge_in_advance_fees ).call Fee - .charge_kind + .charge .joins(:charge) .where( subscription_id: subscription.id, @@ -87,7 +87,7 @@ def charge_in_advance_recurring_fees ).call Fee - .charge_kind + .charge .joins(:charge) .joins(charge: :billable_metric) .where(billable_metric: {recurring: true}) diff --git a/app/services/commitments/minimum/in_arrears/calculate_true_up_fee_service.rb b/app/services/commitments/minimum/in_arrears/calculate_true_up_fee_service.rb index 2978fd6fa7b..ab406c15fd3 100644 --- a/app/services/commitments/minimum/in_arrears/calculate_true_up_fee_service.rb +++ b/app/services/commitments/minimum/in_arrears/calculate_true_up_fee_service.rb @@ -10,7 +10,7 @@ def subscription_fees invoices_result = FetchInvoicesService.call(commitment: minimum_commitment, invoice_subscription:) Fee - .subscription_kind + .subscription .joins(subscription: :plan) .where( subscription_id: subscription.id, @@ -26,7 +26,7 @@ def charge_fees ).call Fee - .charge_kind + .charge .joins(:charge) .where( subscription_id: subscription.id, @@ -49,7 +49,7 @@ def charge_in_advance_fees ).call Fee - .charge_kind + .charge .joins(:charge) .where( subscription_id: subscription.id, @@ -84,7 +84,7 @@ def charge_in_advance_recurring_fees ).call scope = Fee - .charge_kind + .charge .joins(:charge) .joins(charge: :billable_metric) .where(billable_metric: {recurring: true}) diff --git a/app/services/fees/commitments/minimum/create_service.rb b/app/services/fees/commitments/minimum/create_service.rb index 578950fda15..b17d84cd8db 100644 --- a/app/services/fees/commitments/minimum/create_service.rb +++ b/app/services/fees/commitments/minimum/create_service.rb @@ -53,7 +53,7 @@ def call delegate :organization, to: :invoice def invoice_has_minimum_commitment_fee? - invoice.fees.commitment_kind.where(subscription:).any? { |fee| fee.invoiceable.minimum_commitment? } + invoice.fees.commitment.where(subscription:).any? { |fee| fee.invoiceable.minimum_commitment? } end end end diff --git a/app/services/fees/subscription_service.rb b/app/services/fees/subscription_service.rb index afac890db91..6cc103b9794 100644 --- a/app/services/fees/subscription_service.rb +++ b/app/services/fees/subscription_service.rb @@ -95,7 +95,7 @@ def adjusted_fee end def already_billed? - existing_fee = invoice.fees.subscription_kind.find_by(subscription_id: subscription.id) + existing_fee = invoice.fees.subscription.find_by(subscription_id: subscription.id) return false unless existing_fee result.fee = existing_fee @@ -138,7 +138,7 @@ def should_use_full_amount? # However, we should not bill full amount if subscription is downgraded since in that case, first invoice # should be prorated (this part is covered with first_subscription_amount method). return true if plan.pay_in_advance? && subscription.anniversary? && !subscription.previous_subscription_id - return true if subscription.fees.subscription_kind.where('created_at < ?', invoice.created_at).exists? + return true if subscription.fees.subscription.where('created_at < ?', invoice.created_at).exists? return true if subscription.started_in_past? && plan.pay_in_advance? if subscription.started_in_past? && diff --git a/app/services/invoices/calculate_fees_service.rb b/app/services/invoices/calculate_fees_service.rb index 4e3d0455894..abcd3dea1af 100644 --- a/app/services/invoices/calculate_fees_service.rb +++ b/app/services/invoices/calculate_fees_service.rb @@ -226,7 +226,7 @@ def should_create_subscription_fee?(subscription, boundaries) # NOTE: When plan is pay in advance we generate an invoice upon subscription creation # We want to prevent creating subscription fee if subscription creation already happened on billing day fee_exists = subscription.fees - .subscription_kind + .subscription .where(created_at: issuing_date.beginning_of_day..issuing_date.end_of_day) .where.not(invoice_id: invoice.id) .any? diff --git a/app/services/subscriptions/free_trial_billing_service.rb b/app/services/subscriptions/free_trial_billing_service.rb index f99f2ba2a11..502d77916f9 100644 --- a/app/services/subscriptions/free_trial_billing_service.rb +++ b/app/services/subscriptions/free_trial_billing_service.rb @@ -40,7 +40,7 @@ def call # during the customer trial period # Unfortunately, this introduces an N+1 query def already_billed_on_day_one?(subscription) - Fee.subscription_kind.where( + Fee.subscription.where( invoice_id: subscription.invoice_subscriptions.select('invoices.id').joins(:invoice).where( 'invoices.invoice_type' => :subscription, 'invoices.status' => %i[draft finalized], diff --git a/app/views/templates/invoices/v1.slim b/app/views/templates/invoices/v1.slim index c6d046acdf5..9df5317d0c7 100644 --- a/app/views/templates/invoices/v1.slim +++ b/app/views/templates/invoices/v1.slim @@ -449,7 +449,7 @@ html - elsif subscription? td.body-1 style="text-align: right;" width="30%" = subscription_amount.format(format: I18n.t('money.format'), decimal_mark: I18n.t('money.decimal_mark'), thousands_separator: I18n.t('money.thousands_separator')) - - if fees.charge_kind.any? + - if fees.charge.any? tr td width="70%" .body-1 = I18n.t('invoice.all_usage_based_fees') @@ -499,19 +499,19 @@ html .body-1 = I18n.t('invoice.subscription_interval', plan_interval: I18n.t("invoice.#{subscription.plan.interval}"), plan_name: subscription.plan.invoice_name) td.body-1 style="text-align: right;" width="30%" - = subscription_fees(subscription.id).subscription_kind.first&.amount&.format(format: I18n.t('money.format'), decimal_mark: I18n.t('money.decimal_mark'), thousands_separator: I18n.t('money.thousands_separator')) + = subscription_fees(subscription.id).subscription.first&.amount&.format(format: I18n.t('money.format'), decimal_mark: I18n.t('money.decimal_mark'), thousands_separator: I18n.t('money.thousands_separator')) table.total-table width="100%" tr td.body-2 width="70%" = I18n.t('invoice.sub_total') td.body-1 width="30%" = invoice_subscription(subscription.id).subscription_amount.format(format: I18n.t('money.format'), decimal_mark: I18n.t('money.decimal_mark'), thousands_separator: I18n.t('money.thousands_separator')) - - if subscription? && subscription_fees(subscription.id).charge_kind.any? + - if subscription? && subscription_fees(subscription.id).charge.any? .body-1 = I18n.t('invoice.usage_based_fees') .mb-24.body-3 = I18n.t('invoice.list_of_charges', from: I18n.l(invoice_subscription(subscription.id).charges_from_datetime_in_customer_timezone&.to_date, format: :default), to: I18n.l(invoice_subscription(subscription.id).charges_to_datetime_in_customer_timezone&.to_date, format: :default)) .charge-details.mb-24 table.charge-details-table width="100%" - - subscription_fees(subscription.id).charge_kind.group_by(&:charge_id).each do |_charge_id, fees| + - subscription_fees(subscription.id).charge.group_by(&:charge_id).each do |_charge_id, fees| - fee = fees.first - if fees.all? { |f| f.group_id? } && fees.sum(&:units) > 0 tr diff --git a/app/views/templates/invoices/v2.slim b/app/views/templates/invoices/v2.slim index 2c6b6725b95..3b690d95bd1 100644 --- a/app/views/templates/invoices/v2.slim +++ b/app/views/templates/invoices/v2.slim @@ -449,7 +449,7 @@ html - elsif subscription? td.body-1 style="text-align: right;" width="30%" = subscription_amount.format(format: I18n.t('money.format'), decimal_mark: I18n.t('money.decimal_mark'), thousands_separator: I18n.t('money.thousands_separator')) - - if fees.charge_kind.any? + - if fees.charge.any? tr td width="70%" .body-1 = I18n.t('invoice.all_usage_based_fees') @@ -508,19 +508,19 @@ html .body-1 = I18n.t('invoice.subscription_interval', plan_interval: I18n.t("invoice.#{subscription.plan.interval}"), plan_name: subscription.plan.invoice_name) td.body-1 style="text-align: right;" width="30%" - = subscription_fees(subscription.id).subscription_kind.first&.amount&.format(format: I18n.t('money.format'), decimal_mark: I18n.t('money.decimal_mark'), thousands_separator: I18n.t('money.thousands_separator')) + = subscription_fees(subscription.id).subscription.first&.amount&.format(format: I18n.t('money.format'), decimal_mark: I18n.t('money.decimal_mark'), thousands_separator: I18n.t('money.thousands_separator')) table.total-table width="100%" tr td.body-2 width="70%" = I18n.t('invoice.sub_total') td.body-1 width="30%" = invoice_subscription(subscription.id).subscription_amount.format(format: I18n.t('money.format'), decimal_mark: I18n.t('money.decimal_mark'), thousands_separator: I18n.t('money.thousands_separator')) - - if subscription? && subscription_fees(subscription.id).charge_kind.any? + - if subscription? && subscription_fees(subscription.id).charge.any? .body-1 = I18n.t('invoice.usage_based_fees') .mb-24.body-3 = I18n.t('invoice.list_of_charges', from: I18n.l(invoice_subscription(subscription.id).charges_from_datetime_in_customer_timezone&.to_date, format: :default), to: I18n.l(invoice_subscription(subscription.id).charges_to_datetime_in_customer_timezone&.to_date, format: :default)) .charge-details.mb-24 table.charge-details-table width="100%" - - subscription_fees(subscription.id).charge_kind.where(true_up_parent_fee: nil).group_by(&:charge_id).each do |_charge_id, fees| + - subscription_fees(subscription.id).charge.where(true_up_parent_fee: nil).group_by(&:charge_id).each do |_charge_id, fees| - fee = fees.first - if fees.all? { |f| f.group_id? } && fees.sum(&:units) > 0 tr diff --git a/app/views/templates/invoices/v3/_subscription_details.slim b/app/views/templates/invoices/v3/_subscription_details.slim index d7da0307cc0..4f334e91944 100644 --- a/app/views/templates/invoices/v3/_subscription_details.slim +++ b/app/views/templates/invoices/v3/_subscription_details.slim @@ -4,7 +4,7 @@ h2.title-2.mb-24 class="#{'invoice-details-title' if subscriptions.count > 1}" = I18n.t('invoice.details', resource: subscription.invoice_name) / Subscription fee section - .invoice-resume.overflow-auto class="#{'mb-24' if subscription_fees(subscription.id).charge_kind.any?}" + .invoice-resume.overflow-auto class="#{'mb-24' if subscription_fees(subscription.id).charge.any?}" table.invoice-resume-table width="100%" tr td.body-2 = I18n.t('invoice.fees_from_to_date', from_date: I18n.l(invoice_subscription(subscription.id).from_datetime_in_customer_timezone&.to_date, format: :default), to_date: I18n.l(invoice_subscription(subscription.id).to_datetime_in_customer_timezone&.to_date, format: :default)) @@ -18,7 +18,7 @@ td.body-2 = MoneyHelper.format(invoice_subscription(subscription.id).subscription_amount) / Charge fees section for subsctiption invoice - - if subscription? && subscription_fees(subscription.id).charge_kind.any? + - if subscription? && subscription_fees(subscription.id).charge.any? / Charges payed in arrears OR charges and plan payed in advance - if (subscription.plan.charges.where(pay_in_advance: false).any? || (subscription.plan.charges.where(pay_in_advance: true).any? && subscription.plan.pay_in_advance?)) @@ -31,7 +31,7 @@ td.body-2 = I18n.t('invoice.amount_without_tax') / Loop over all top level fees - - subscription_fees(subscription.id).charge_kind.where(true_up_parent_fee: nil).group_by(&:charge_id).each do |_charge_id, fees| + - subscription_fees(subscription.id).charge.where(true_up_parent_fee: nil).group_by(&:charge_id).each do |_charge_id, fees| - fee = fees.first - next if fee.charge.pay_in_advance? && !fee.charge.plan.pay_in_advance? @@ -93,7 +93,7 @@ td.body-2 = I18n.t('invoice.amount_without_tax') / Loop over all top level fees - - subscription_fees(subscription.id).charge_kind.where(true_up_parent_fee: nil).group_by(&:charge_id).each do |_charge_id, fees| + - subscription_fees(subscription.id).charge.where(true_up_parent_fee: nil).group_by(&:charge_id).each do |_charge_id, fees| - fee = fees.first - next unless fee.charge.pay_in_advance? @@ -197,7 +197,7 @@ = MoneyHelper.format(invoice_subscription(subscription.id).total_amount) / Recuring fees breakdown - - if subscription? && subscription_fees(subscription.id).charge_kind.any? + - if subscription? && subscription_fees(subscription.id).charge.any? .invoice-resume.mb-24.overflow-auto - recurring_fees(subscription.id).group_by(&:charge_id).each do |_charge_id, fees| - next unless fees.sum(&:units) > 0 diff --git a/app/views/templates/invoices/v4/_progressive_billing_details.slim b/app/views/templates/invoices/v4/_progressive_billing_details.slim index 0872da8cd28..26e05a53893 100644 --- a/app/views/templates/invoices/v4/_progressive_billing_details.slim +++ b/app/views/templates/invoices/v4/_progressive_billing_details.slim @@ -12,14 +12,14 @@ td.body-2 = I18n.t('invoice.amount') / Charge fees section for subscription invoice -- if subscription_fees(subscription.id).charge_kind.any? +- if subscription_fees(subscription.id).charge.any? / Charges payed in arrears OR charges and plan payed in advance - if subscription.plan.charges.any? .invoice-resume.overflow-auto table.invoice-resume-table width="100%" / Loop over all top level fees - - subscription_fees(subscription.id).charge_kind.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees| + - subscription_fees(subscription.id).charge.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees| - fee = fees.first - next if fee.charge.pay_in_advance? diff --git a/app/views/templates/invoices/v4/_subscription_details.slim b/app/views/templates/invoices/v4/_subscription_details.slim index 3babd54367f..386818088c4 100644 --- a/app/views/templates/invoices/v4/_subscription_details.slim +++ b/app/views/templates/invoices/v4/_subscription_details.slim @@ -7,7 +7,7 @@ h2.title-2.mb-24 class="#{'invoice-details-title' if subscriptions.count > 1}" = I18n.t('invoice.details', resource: subscription.invoice_name) / Subscription fee section - .invoice-resume.overflow-auto class="#{'mb-24' if subscription_fees(subscription.id).charge_kind.any? && different_boundaries_for_subscription_and_charges(subscription)}" + .invoice-resume.overflow-auto class="#{'mb-24' if subscription_fees(subscription.id).charge.any? && different_boundaries_for_subscription_and_charges(subscription)}" table.invoice-resume-table width="100%" tr.first_child td.body-2 = I18n.t('invoice.fees_from_to_date', from_date: I18n.l(invoice_subscription.from_datetime_in_customer_timezone&.to_date, format: :default), to_date: I18n.l(invoice_subscription.to_datetime_in_customer_timezone&.to_date, format: :default)) @@ -27,11 +27,11 @@ td.body-2 == TaxHelper.applied_taxes(subscription_fee) td.body-2 = MoneyHelper.format(invoice_subscription.subscription_amount) - - if subscription? && subscription_fees(subscription.id).charge_kind.any? + - if subscription? && subscription_fees(subscription.id).charge.any? / Charges payed in advance on payed in advance plan - if subscription.plan.charges.where(pay_in_advance: true).any? && subscription.plan.pay_in_advance? / Loop over all top level fees - - subscription_fees(subscription.id).charge_kind.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees| + - subscription_fees(subscription.id).charge.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees| - fee = fees.first - next unless fee.charge.pay_in_advance? @@ -53,7 +53,7 @@ == SlimHelper.render('templates/invoices/v4/_fees_without_filters', fee) / Charge fees section for subscription invoice - - if subscription? && subscription_fees(subscription.id).charge_kind.any? + - if subscription? && subscription_fees(subscription.id).charge.any? / Charges payed in arrears OR charges and plan payed in advance - if subscription.plan.charges.where(pay_in_advance: false).any? && existing_fees_in_interval?(subscription_id: subscription.id) .invoice-resume.overflow-auto @@ -67,7 +67,7 @@ td.body-2 = I18n.t('invoice.amount') / Loop over all top level fees - - subscription_fees(subscription.id).charge_kind.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees| + - subscription_fees(subscription.id).charge.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees| - fee = fees.first - next if fee.charge.pay_in_advance? @@ -110,7 +110,7 @@ td.body-2 = I18n.t('invoice.amount') / Loop over all top level fees - - subscription_fees(subscription.id).charge_kind.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees| + - subscription_fees(subscription.id).charge.positive_units.where(true_up_parent_fee: nil).joins(charge: :billable_metric).sort_by { |f| f.invoice_sorting_clause }.group_by(&:charge_id).each do |_charge_id, fees| - fee = fees.first - next unless fee.charge.pay_in_advance? @@ -201,7 +201,7 @@ = MoneyHelper.format(invoice_subscription.total_amount) / Recuring fees breakdown - - if subscription? && subscription_fees(subscription.id).charge_kind.any? + - if subscription? && subscription_fees(subscription.id).charge.any? .invoice-resume.mb-24.overflow-auto - recurring_fees(subscription.id).group_by(&:charge_id).each do |_charge_id, fees| - next unless fees.sum(&:units) > 0 diff --git a/spec/scenarios/charge_models/prorated_graduated_spec.rb b/spec/scenarios/charge_models/prorated_graduated_spec.rb index c61cda01f53..0d70d319cad 100644 --- a/spec/scenarios/charge_models/prorated_graduated_spec.rb +++ b/spec/scenarios/charge_models/prorated_graduated_spec.rb @@ -607,7 +607,7 @@ .and change { subscription.invoices.count }.from(1).to(2) invoice = subscription.invoices.order(created_at: :desc).first - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) # 30226 (17 / 31 * 75 units) + 2.58 (2 / 31 * 20 units - prorated event in termination period) expect(invoice.total_amount_cents).to eq(27_323) diff --git a/spec/scenarios/commitments/minimum/in_advance/anniversary/monthly_spec.rb b/spec/scenarios/commitments/minimum/in_advance/anniversary/monthly_spec.rb index 928987f4e30..40c4a4b001b 100644 --- a/spec/scenarios/commitments/minimum/in_advance/anniversary/monthly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance/anniversary/monthly_spec.rb @@ -139,7 +139,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -154,7 +154,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(983_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(983_000) end end end @@ -174,7 +174,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 2.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end @@ -203,7 +203,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -218,7 +218,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(983_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(983_000) end end end @@ -238,7 +238,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 2.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end diff --git a/spec/scenarios/commitments/minimum/in_advance/anniversary/quarterly_spec.rb b/spec/scenarios/commitments/minimum/in_advance/anniversary/quarterly_spec.rb index 530ee9d40f8..b5a6b7cda36 100644 --- a/spec/scenarios/commitments/minimum/in_advance/anniversary/quarterly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance/anniversary/quarterly_spec.rb @@ -139,7 +139,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -154,7 +154,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 3.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(983_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(983_000) end end end @@ -174,7 +174,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 6.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end @@ -203,7 +203,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -218,7 +218,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 3.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(983_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(983_000) end end end @@ -238,7 +238,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 6.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end diff --git a/spec/scenarios/commitments/minimum/in_advance/anniversary/weekly_spec.rb b/spec/scenarios/commitments/minimum/in_advance/anniversary/weekly_spec.rb index f20731cb467..5395dc69288 100644 --- a/spec/scenarios/commitments/minimum/in_advance/anniversary/weekly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance/anniversary/weekly_spec.rb @@ -139,7 +139,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -154,7 +154,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(983_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(983_000) end end end @@ -174,7 +174,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 2.weeks) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end @@ -203,7 +203,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -218,7 +218,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(983_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(983_000) end end end @@ -238,7 +238,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 2.weeks) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end diff --git a/spec/scenarios/commitments/minimum/in_advance/anniversary/yearly_spec.rb b/spec/scenarios/commitments/minimum/in_advance/anniversary/yearly_spec.rb index 93a1a0e1049..0b573a45847 100644 --- a/spec/scenarios/commitments/minimum/in_advance/anniversary/yearly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance/anniversary/yearly_spec.rb @@ -144,7 +144,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time + 1.minute) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -184,8 +184,8 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.year) do aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.sum(:amount_cents)).to eq(981_100) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.sum(:amount_cents)).to eq(981_100) end end end diff --git a/spec/scenarios/commitments/minimum/in_advance/calendar/monthly_spec.rb b/spec/scenarios/commitments/minimum/in_advance/calendar/monthly_spec.rb index 74d1d38fa81..ebb1895f54a 100644 --- a/spec/scenarios/commitments/minimum/in_advance/calendar/monthly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance/calendar/monthly_spec.rb @@ -139,7 +139,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -154,7 +154,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.month).beginning_of_month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(61_276) + expect(invoice.fees.commitment.first.amount_cents).to eq(61_276) end end end @@ -174,7 +174,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 2.months).beginning_of_month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end @@ -203,7 +203,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -218,7 +218,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.month).beginning_of_month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(61_276) + expect(invoice.fees.commitment.first.amount_cents).to eq(61_276) end end end @@ -238,7 +238,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 2.months).beginning_of_month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end diff --git a/spec/scenarios/commitments/minimum/in_advance/calendar/quarterly_spec.rb b/spec/scenarios/commitments/minimum/in_advance/calendar/quarterly_spec.rb index d5d053941e6..76db9877b52 100644 --- a/spec/scenarios/commitments/minimum/in_advance/calendar/quarterly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance/calendar/quarterly_spec.rb @@ -139,7 +139,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -154,7 +154,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 3.months).beginning_of_quarter) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(210_582) + expect(invoice.fees.commitment.first.amount_cents).to eq(210_582) end end end @@ -174,7 +174,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 6.months).beginning_of_quarter) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end @@ -203,7 +203,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -218,7 +218,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 3.months).beginning_of_quarter) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(210_582) + expect(invoice.fees.commitment.first.amount_cents).to eq(210_582) end end end @@ -238,7 +238,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 6.months).beginning_of_quarter) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end diff --git a/spec/scenarios/commitments/minimum/in_advance/calendar/weekly_spec.rb b/spec/scenarios/commitments/minimum/in_advance/calendar/weekly_spec.rb index 71c163f90d2..68464457187 100644 --- a/spec/scenarios/commitments/minimum/in_advance/calendar/weekly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance/calendar/weekly_spec.rb @@ -139,7 +139,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -154,7 +154,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.week).beginning_of_week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(841_572) + expect(invoice.fees.commitment.first.amount_cents).to eq(841_572) end end end @@ -174,7 +174,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 2.weeks).beginning_of_week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end @@ -203,7 +203,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -218,7 +218,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.week).beginning_of_week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(841_572) + expect(invoice.fees.commitment.first.amount_cents).to eq(841_572) end end end @@ -238,7 +238,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 2.weeks).beginning_of_week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(988_500) + expect(invoice.fees.commitment.first.amount_cents).to eq(988_500) end end end diff --git a/spec/scenarios/commitments/minimum/in_advance/calendar/yearly_spec.rb b/spec/scenarios/commitments/minimum/in_advance/calendar/yearly_spec.rb index 164e751c22a..e65da80ee8b 100644 --- a/spec/scenarios/commitments/minimum/in_advance/calendar/yearly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance/calendar/yearly_spec.rb @@ -144,7 +144,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time + 1.minute) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -187,8 +187,8 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.year).beginning_of_year) do aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.sum(:amount_cents)).to eq(808_186) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.sum(:amount_cents)).to eq(808_186) end end end diff --git a/spec/scenarios/commitments/minimum/in_advance_spec.rb b/spec/scenarios/commitments/minimum/in_advance_spec.rb index cf37212fc9a..09fe036f9ab 100644 --- a/spec/scenarios/commitments/minimum/in_advance_spec.rb +++ b/spec/scenarios/commitments/minimum/in_advance_spec.rb @@ -56,7 +56,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -64,7 +64,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -72,7 +72,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -91,7 +91,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -99,7 +99,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -107,13 +107,13 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end context 'when subscription is terminated' do let(:invoices) { Invoice.order(:sequential_id) } - let(:commitment_fees) { Fee.commitment_kind.pluck(:amount_cents) } + let(:commitment_fees) { Fee.commitment.pluck(:amount_cents) } before do travel_to(DateTime.new(2023, 2, 13, 10)) @@ -126,10 +126,10 @@ end it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoices.first.fees.commitment_kind.count).to eq(0) - expect(invoices.second.fees.commitment_kind.count).to eq(1) - expect(invoices.third.fees.commitment_kind.count).to eq(1) - expect(invoices.fourth.fees.commitment_kind.count).to eq(1) + expect(invoices.first.fees.commitment.count).to eq(0) + expect(invoices.second.fees.commitment.count).to eq(1) + expect(invoices.third.fees.commitment.count).to eq(1) + expect(invoices.fourth.fees.commitment.count).to eq(1) expect(commitment_fees).to contain_exactly(328_571, 642_857, 900_000) end @@ -148,7 +148,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -156,7 +156,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -164,7 +164,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -183,7 +183,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -191,7 +191,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -199,8 +199,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end @@ -220,7 +220,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -228,7 +228,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -236,7 +236,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -255,7 +255,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -263,7 +263,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -271,8 +271,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end @@ -288,7 +288,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -296,7 +296,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -304,7 +304,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -323,7 +323,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -331,7 +331,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -339,8 +339,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end @@ -360,7 +360,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -368,7 +368,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -376,7 +376,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -395,7 +395,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -403,7 +403,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -411,8 +411,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end @@ -428,7 +428,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -436,7 +436,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -444,7 +444,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -463,7 +463,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -471,7 +471,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -479,8 +479,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end @@ -501,7 +501,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -509,7 +509,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -517,7 +517,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -536,7 +536,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -544,7 +544,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -552,8 +552,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end @@ -567,7 +567,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -575,7 +575,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -583,7 +583,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -602,7 +602,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -610,7 +610,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -618,8 +618,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end @@ -637,7 +637,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -645,7 +645,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -653,7 +653,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -672,7 +672,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -680,7 +680,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -688,8 +688,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end @@ -703,7 +703,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -711,7 +711,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -719,7 +719,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -738,7 +738,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -746,7 +746,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -754,8 +754,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears/anniversary/monthly_spec.rb b/spec/scenarios/commitments/minimum/in_arrears/anniversary/monthly_spec.rb index e85f98b205c..8e2c15e74ce 100644 --- a/spec/scenarios/commitments/minimum/in_arrears/anniversary/monthly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears/anniversary/monthly_spec.rb @@ -141,7 +141,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(987_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(987_000) end end end @@ -156,7 +156,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 2.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end @@ -185,7 +185,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(987_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(987_000) end end end @@ -200,7 +200,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 2.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears/anniversary/quarterly_spec.rb b/spec/scenarios/commitments/minimum/in_arrears/anniversary/quarterly_spec.rb index f3dc7b1ba25..5a35464f56f 100644 --- a/spec/scenarios/commitments/minimum/in_arrears/anniversary/quarterly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears/anniversary/quarterly_spec.rb @@ -141,7 +141,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 3.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(987_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(987_000) end end end @@ -156,7 +156,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 6.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end @@ -185,7 +185,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 3.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(987_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(987_000) end end end @@ -200,7 +200,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 6.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears/anniversary/weekly_spec.rb b/spec/scenarios/commitments/minimum/in_arrears/anniversary/weekly_spec.rb index b175fa531ab..fe51e98d407 100644 --- a/spec/scenarios/commitments/minimum/in_arrears/anniversary/weekly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears/anniversary/weekly_spec.rb @@ -141,7 +141,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(987_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(987_000) end end end @@ -156,7 +156,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 2.weeks) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end @@ -185,7 +185,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(987_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(987_000) end end end @@ -200,7 +200,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 2.weeks) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears/anniversary/yearly_spec.rb b/spec/scenarios/commitments/minimum/in_arrears/anniversary/yearly_spec.rb index ebd3520a62b..763108a9a11 100644 --- a/spec/scenarios/commitments/minimum/in_arrears/anniversary/yearly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears/anniversary/yearly_spec.rb @@ -144,7 +144,7 @@ Subscriptions::BillingService.new.call perform_all_enqueued_jobs - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -184,8 +184,8 @@ it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 1.year + 1.month) do aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.sum(:amount_cents)).to eq(981_100) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.sum(:amount_cents)).to eq(981_100) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears/calendar/monthly_spec.rb b/spec/scenarios/commitments/minimum/in_arrears/calendar/monthly_spec.rb index 148b645382e..94b8d48b324 100644 --- a/spec/scenarios/commitments/minimum/in_arrears/calendar/monthly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears/calendar/monthly_spec.rb @@ -141,7 +141,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.month).beginning_of_month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(65_276) + expect(invoice.fees.commitment.first.amount_cents).to eq(65_276) end end end @@ -156,7 +156,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 2.months).beginning_of_month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end @@ -190,7 +190,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.month).beginning_of_month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(65_276) + expect(invoice.fees.commitment.first.amount_cents).to eq(65_276) end end end @@ -205,7 +205,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 2.months).beginning_of_month) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears/calendar/quarterly_spec.rb b/spec/scenarios/commitments/minimum/in_arrears/calendar/quarterly_spec.rb index 0025fb76361..4a0c4ee1265 100644 --- a/spec/scenarios/commitments/minimum/in_arrears/calendar/quarterly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears/calendar/quarterly_spec.rb @@ -141,7 +141,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 3.months).beginning_of_quarter) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(214_582) + expect(invoice.fees.commitment.first.amount_cents).to eq(214_582) end end end @@ -156,7 +156,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 6.months).beginning_of_quarter) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end @@ -190,7 +190,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to(subscription_time + 3.months) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(214_582) + expect(invoice.fees.commitment.first.amount_cents).to eq(214_582) end end end @@ -205,7 +205,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 6.months).beginning_of_quarter) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears/calendar/weekly_spec.rb b/spec/scenarios/commitments/minimum/in_arrears/calendar/weekly_spec.rb index b34bca2caaf..a8c205ec626 100644 --- a/spec/scenarios/commitments/minimum/in_arrears/calendar/weekly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears/calendar/weekly_spec.rb @@ -141,7 +141,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.week).beginning_of_week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(845_572) + expect(invoice.fees.commitment.first.amount_cents).to eq(845_572) end end end @@ -156,7 +156,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 2.weeks).beginning_of_week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end @@ -190,7 +190,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.week).beginning_of_week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(845_572) + expect(invoice.fees.commitment.first.amount_cents).to eq(845_572) end end end @@ -205,7 +205,7 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 2.weeks).beginning_of_week) do - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(989_000) + expect(invoice.fees.commitment.first.amount_cents).to eq(989_000) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears/calendar/yearly_spec.rb b/spec/scenarios/commitments/minimum/in_arrears/calendar/yearly_spec.rb index 5210b38d6b8..29f223a95aa 100644 --- a/spec/scenarios/commitments/minimum/in_arrears/calendar/yearly_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears/calendar/yearly_spec.rb @@ -146,7 +146,7 @@ context 'when subscription is billed for the first period' do it 'creates an invoice with no minimum commitment fee' do travel_to(subscription_time + 1.minute) do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -184,8 +184,8 @@ it 'creates an invoice with minimum commitment fee' do travel_to((subscription_time + 1.year).beginning_of_year) do aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.sum(:amount_cents)).to eq(808_086) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.sum(:amount_cents)).to eq(808_086) end end end diff --git a/spec/scenarios/commitments/minimum/in_arrears_spec.rb b/spec/scenarios/commitments/minimum/in_arrears_spec.rb index 626e1d24914..a3ae093fda3 100644 --- a/spec/scenarios/commitments/minimum/in_arrears_spec.rb +++ b/spec/scenarios/commitments/minimum/in_arrears_spec.rb @@ -51,7 +51,7 @@ let(:minimum_commitment) { nil } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -59,7 +59,7 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1) } it 'creates an invoice without minimum commitment fee' do - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end @@ -67,8 +67,8 @@ let(:minimum_commitment) { create(:commitment, :minimum_commitment, plan:, amount_cents: 1_000_000) } it 'creates an invoice with minimum commitment fee', :aggregate_failures do - expect(invoice.fees.commitment_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.first.amount_cents).to eq(commitment_fee_amount_cents) + expect(invoice.fees.commitment.count).to eq(1) + expect(invoice.fees.commitment.first.amount_cents).to eq(commitment_fee_amount_cents) end end end diff --git a/spec/scenarios/coupons_breakdown_spec.rb b/spec/scenarios/coupons_breakdown_spec.rb index dd4ab58ee21..a2802b93c58 100644 --- a/spec/scenarios/coupons_breakdown_spec.rb +++ b/spec/scenarios/coupons_breakdown_spec.rb @@ -271,8 +271,8 @@ fees = invoice.fees subscription1 = Subscription.find_by(external_id: 'sub_external_id') subscription2 = Subscription.find_by(external_id: 'sub_external_id2') - sub1_fees = fees.charge_kind.where(subscription: subscription1).joins(:charge) - sub2_fees = fees.charge_kind.where(subscription: subscription2).joins(:charge) + sub1_fees = fees.charge.where(subscription: subscription1).joins(:charge) + sub2_fees = fees.charge.where(subscription: subscription2).joins(:charge) # Subscription 1 fees expect(sub1_fees.where(charge: {billable_metric_id: bm1.id}).first).to have_attributes( diff --git a/spec/scenarios/invoices/adjusted_charge_fees_spec.rb b/spec/scenarios/invoices/adjusted_charge_fees_spec.rb index edda9b4b2e6..4de21063637 100644 --- a/spec/scenarios/invoices/adjusted_charge_fees_spec.rb +++ b/spec/scenarios/invoices/adjusted_charge_fees_spec.rb @@ -58,7 +58,7 @@ perform_all_enqueued_jobs invoice = customer.invoices.order(created_at: :desc).first - fee = Fee.charge_kind.where(invoice:).first + fee = Fee.charge.where(invoice:).first expect(invoice.status).to eq('draft') expect(invoice.total_amount_cents).to eq(12_900) @@ -119,7 +119,7 @@ perform_all_enqueued_jobs invoice = customer.invoices.order(created_at: :desc).first - fee = Fee.charge_kind.where(invoice:).first + fee = Fee.charge.where(invoice:).first expect(invoice.status).to eq('draft') expect(invoice.total_amount_cents).to eq(12_900) diff --git a/spec/scenarios/invoices/invoices_spec.rb b/spec/scenarios/invoices/invoices_spec.rb index 5c696f8c9f2..67f7cdf6330 100644 --- a/spec/scenarios/invoices/invoices_spec.rb +++ b/spec/scenarios/invoices/invoices_spec.rb @@ -363,7 +363,7 @@ .and change { subscription.invoices.count }.from(0).to(1) invoice = subscription.invoices.first - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) end end end @@ -410,7 +410,7 @@ .and change { subscription.invoices.count }.from(0).to(1) invoice = subscription.invoices.first - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) end end end @@ -445,7 +445,7 @@ .and change { subscription.invoices.count }.from(0).to(1) invoice = subscription.invoices.first - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) end end end @@ -499,7 +499,7 @@ .and change { subscription.invoices.count }.from(0).to(1) invoice = subscription.invoices.first - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) end end end @@ -562,7 +562,7 @@ .and change { subscription.invoices.count }.from(0).to(1) invoice = subscription.invoices.first - expect(invoice.fees.charge_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(0) end end end @@ -609,7 +609,7 @@ .and change { subscription.invoices.count }.from(0).to(1) invoice = subscription.invoices.first - expect(invoice.fees.charge_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(0) end end end @@ -1153,7 +1153,7 @@ expect(terminated_invoice.credit_notes_amount_cents).to eq(0) # In terminated invoice there is only one fee that is charge kind - fee = terminated_invoice.fees.charge_kind.first + fee = terminated_invoice.fees.charge.first AdjustedFees::CreateService.call(organization:, fee:, params: adjusted_fee_params) credit_note = credit_note.reload @@ -1234,7 +1234,7 @@ expect(first_invoice.credit_notes_amount_cents).to eq(0) # There is only one fee that is subscription kind - fee = first_invoice.fees.subscription_kind.first + fee = first_invoice.fees.subscription.first AdjustedFees::CreateService.call(organization:, fee:, params: adjusted_fee_params) credit_note = credit_note.reload @@ -1315,7 +1315,7 @@ expect(first_invoice.credit_notes_amount_cents).to eq(0) # There is only one fee that is subscription kind - fee = first_invoice.fees.subscription_kind.first + fee = first_invoice.fees.subscription.first AdjustedFees::CreateService.call(organization:, fee:, params: adjusted_fee_params) credit_note = credit_note.reload diff --git a/spec/services/fees/commitments/minimum/create_service_spec.rb b/spec/services/fees/commitments/minimum/create_service_spec.rb index 39841cfaaf4..899def42e7d 100644 --- a/spec/services/fees/commitments/minimum/create_service_spec.rb +++ b/spec/services/fees/commitments/minimum/create_service_spec.rb @@ -20,7 +20,7 @@ it 'creates a commitment fee' do expect do service_call - end.not_to change(Fee.commitment_kind, :count) + end.not_to change(Fee.commitment, :count) end end @@ -28,13 +28,13 @@ it 'does not create a commitment fee' do expect do service_call - end.not_to change(Fee.commitment_kind, :count) + end.not_to change(Fee.commitment, :count) end end end context 'when plan has a minimum commitment' do - let(:commitment_fee) { Fee.commitment_kind.first } + let(:commitment_fee) { Fee.commitment.first } before { create(:commitment, :minimum_commitment, plan:) } @@ -43,19 +43,19 @@ it 'creates a commitment fee' do expect do service_call - end.to change(Fee.commitment_kind, :count).by(1) + end.to change(Fee.commitment, :count).by(1) end it 'saves taxes amount cents' do service_call - expect(Fee.commitment_kind.first.taxes_amount_cents).to eq(0) + expect(Fee.commitment.first.taxes_amount_cents).to eq(0) end it 'saves precise amount cents' do service_call - expect(Fee.commitment_kind.first.precise_amount_cents).to eq(1000.0) + expect(Fee.commitment.first.precise_amount_cents).to eq(1000.0) end end @@ -70,7 +70,7 @@ it 'creates a commitment fee' do expect do service_call - end.to change(Fee.commitment_kind, :count).by(1) + end.to change(Fee.commitment, :count).by(1) end end end @@ -81,7 +81,7 @@ it 'does not create a commitment fee' do expect do service_call - end.not_to change(Fee.commitment_kind, :count) + end.not_to change(Fee.commitment, :count) end end @@ -91,7 +91,7 @@ it 'does not create a commitment fee' do expect do service_call - end.to change(Fee.commitment_kind, :count).by(1) + end.to change(Fee.commitment, :count).by(1) end end end diff --git a/spec/services/invoices/calculate_fees_service_spec.rb b/spec/services/invoices/calculate_fees_service_spec.rb index 9b4ea8b6355..768abff985f 100644 --- a/spec/services/invoices/calculate_fees_service_spec.rb +++ b/spec/services/invoices/calculate_fees_service_spec.rb @@ -105,8 +105,8 @@ expect(invoice.subscriptions.first).to eq(subscription) expect(invoice.payment_status).to eq('pending') - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -335,7 +335,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(0) end end end @@ -361,7 +361,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) end end end @@ -383,7 +383,7 @@ aggregate_failures do expect(result).to be_success - expect(Fee.charge_kind.count).to eq(0) + expect(Fee.charge.count).to eq(0) end end end @@ -409,7 +409,7 @@ aggregate_failures do expect(result).to be_success - expect(Fee.charge_kind.where(invoice_id: nil).count).to eq(1) + expect(Fee.charge.where(invoice_id: nil).count).to eq(1) end end end @@ -430,7 +430,7 @@ aggregate_failures do expect(result).to be_success - expect(Fee.charge_kind.count).to eq(0) + expect(Fee.charge.count).to eq(0) end end end @@ -448,9 +448,9 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) + expect(invoice.fees.commitment.count).to eq(0) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -473,9 +473,9 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) + expect(invoice.fees.commitment.count).to eq(1) end end end @@ -498,7 +498,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) expect(Fee.where(invoice_id: nil).count).to eq(1) end end @@ -539,8 +539,8 @@ expect(result).to be_success expect(invoice.subscriptions.to_a).to match_array([subscription, subscription2]) expect(invoice.payment_status).to eq('pending') - expect(invoice.fees.subscription_kind.count).to eq(2) - expect(invoice.fees.charge_kind.count).to eq(2) + expect(invoice.fees.subscription.count).to eq(2) + expect(invoice.fees.charge.count).to eq(2) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -563,9 +563,9 @@ expect(result).to be_success expect(invoice.subscriptions.to_a).to match_array([subscription, subscription2]) expect(invoice.payment_status).to eq('pending') - expect(invoice.fees.subscription_kind.count).to eq(2) - expect(invoice.fees.charge_kind.count).to eq(2) - expect(invoice.fees.commitment_kind.count).to eq(2) + expect(invoice.fees.subscription.count).to eq(2) + expect(invoice.fees.charge.count).to eq(2) + expect(invoice.fees.commitment.count).to eq(2) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -593,8 +593,8 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.commitment.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -611,7 +611,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -645,8 +645,8 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(0) - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -662,8 +662,8 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(0) - expect(invoice.fees.commitment_kind.count).to eq(1) + expect(invoice.fees.charge.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(1) end end end @@ -692,8 +692,8 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(1) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -709,8 +709,8 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(1) - expect(invoice.fees.commitment_kind.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) + expect(invoice.fees.commitment.count).to eq(1) end end end @@ -752,7 +752,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(0) end end @@ -762,7 +762,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -778,7 +778,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(0) end end @@ -788,7 +788,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(1) + expect(invoice.fees.commitment.count).to eq(1) end end end @@ -831,7 +831,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(0) end end @@ -841,7 +841,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -857,7 +857,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.charge_kind.count).to eq(0) + expect(invoice.fees.charge.count).to eq(0) end end @@ -867,7 +867,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(1) + expect(invoice.fees.commitment.count).to eq(1) end end end @@ -885,7 +885,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -901,7 +901,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -916,7 +916,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -932,7 +932,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(1) + expect(invoice.fees.commitment.count).to eq(1) end end end @@ -956,7 +956,7 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) expect(invoice.payment_status).to eq('pending') - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) expect(invoice).to have_empty_charge_fees invoice_subscription = invoice.invoice_subscriptions.first @@ -973,7 +973,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -990,7 +990,7 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) expect(invoice.payment_status).to eq('pending') - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) expect(invoice).to have_empty_charge_fees invoice_subscription = invoice.invoice_subscriptions.first @@ -1007,7 +1007,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -1024,7 +1024,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(0) + expect(invoice.fees.subscription.count).to eq(0) end end end @@ -1041,7 +1041,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(0) + expect(invoice.fees.subscription.count).to eq(0) expect(invoice.invoice_subscriptions.count).to eq(1) expect(invoice.invoice_subscriptions.first.recurring).to be_falsey end @@ -1053,7 +1053,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -1069,7 +1069,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(0) + expect(invoice.fees.subscription.count).to eq(0) expect(invoice.invoice_subscriptions.count).to eq(1) expect(invoice.invoice_subscriptions.first.recurring).to be_falsey end @@ -1081,7 +1081,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -1096,8 +1096,8 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) end end end @@ -1150,7 +1150,7 @@ expect(result).to be_success expect(invoice).to be_payment_pending - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) expect(invoice).to have_empty_charge_fees invoice_subscription = invoice.invoice_subscriptions.first @@ -1167,7 +1167,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -1184,7 +1184,7 @@ expect(result).to be_success expect(invoice).to be_payment_pending - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) expect(invoice).to have_empty_charge_fees invoice_subscription = invoice.invoice_subscriptions.first @@ -1201,7 +1201,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -1248,8 +1248,8 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(0) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(0) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1265,7 +1265,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -1282,8 +1282,8 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.subscription_kind.count).to eq(0) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(0) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1299,7 +1299,7 @@ aggregate_failures do expect(result).to be_success - expect(invoice.fees.commitment_kind.count).to eq(0) + expect(invoice.fees.commitment.count).to eq(0) end end end @@ -1318,8 +1318,8 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1342,8 +1342,8 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1365,7 +1365,7 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(0) + expect(invoice.fees.subscription.count).to eq(0) expect(invoice).to have_empty_charge_fees # Because we didn't fake usage events end end @@ -1381,7 +1381,7 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) expect(invoice).to have_empty_charge_fees # Because we didn't fake usage events invoice_subscription = invoice.invoice_subscriptions.first @@ -1406,7 +1406,7 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(0) + expect(invoice.fees.subscription.count).to eq(0) expect(invoice).to have_empty_charge_fees # Because we didn't fake usage events end end @@ -1425,7 +1425,7 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) expect(invoice).to have_empty_charge_fees # Because we didn't fake usage events end end @@ -1443,8 +1443,8 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1468,8 +1468,8 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1494,8 +1494,8 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1528,8 +1528,8 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1555,8 +1555,8 @@ expect(result).to be_success expect(invoice.subscriptions.first).to eq(subscription) - expect(invoice.fees.subscription_kind.count).to eq(1) - expect(invoice.fees.charge_kind.count).to eq(1) + expect(invoice.fees.subscription.count).to eq(1) + expect(invoice.fees.charge.count).to eq(1) invoice_subscription = invoice.invoice_subscriptions.first expect(invoice_subscription).to have_attributes( @@ -1624,8 +1624,8 @@ expect(result.invoice.fees.first.properties['from_datetime']) .to eq (timestamp - 1.month).beginning_of_day.as_json expect(result.invoice.subscriptions.first).to eq(subscription) - expect(result.invoice.fees.subscription_kind.count).to eq(1) - expect(result.invoice.fees.charge_kind.count).to eq(1) + expect(result.invoice.fees.subscription.count).to eq(1) + expect(result.invoice.fees.charge.count).to eq(1) expect(result.invoice.sub_total_excluding_taxes_amount_cents).to eq(100) expect(result.invoice.taxes_amount_cents).to eq(20) expect(result.invoice.total_amount_cents).to eq(90) diff --git a/spec/services/invoices/refresh_draft_and_finalize_service_spec.rb b/spec/services/invoices/refresh_draft_and_finalize_service_spec.rb index ba958a47058..036b9bf9f98 100644 --- a/spec/services/invoices/refresh_draft_and_finalize_service_spec.rb +++ b/spec/services/invoices/refresh_draft_and_finalize_service_spec.rb @@ -71,8 +71,8 @@ aggregate_failures do expect(result).to be_success - expect(result.invoice.fees.charge_kind.count).to eq(1) - expect(result.invoice.fees.subscription_kind.count).to eq(1) + expect(result.invoice.fees.charge.count).to eq(1) + expect(result.invoice.fees.subscription.count).to eq(1) end end @@ -156,8 +156,8 @@ aggregate_failures do expect(result).to be_success - expect(result.invoice.fees.charge_kind.count).to eq(1) - expect(result.invoice.fees.subscription_kind.count).to eq(1) + expect(result.invoice.fees.charge.count).to eq(1) + expect(result.invoice.fees.subscription.count).to eq(1) end end end @@ -294,8 +294,8 @@ end it 'updates fees despite error result' do - expect { finalize_service.call }.to change(invoice.fees.charge_kind, :count).from(0).to(1) - .and change(invoice.fees.subscription_kind, :count).from(0).to(1) + expect { finalize_service.call }.to change(invoice.fees.charge, :count).from(0).to(1) + .and change(invoice.fees.subscription, :count).from(0).to(1) end it 'does not send any updates' do diff --git a/spec/services/invoices/retry_service_spec.rb b/spec/services/invoices/retry_service_spec.rb index 03fa0bcce81..b163e8193b1 100644 --- a/spec/services/invoices/retry_service_spec.rb +++ b/spec/services/invoices/retry_service_spec.rb @@ -159,8 +159,8 @@ aggregate_failures do expect(result).to be_success - expect(result.invoice.fees.charge_kind.count).to eq(1) - expect(result.invoice.fees.subscription_kind.count).to eq(1) + expect(result.invoice.fees.charge.count).to eq(1) + expect(result.invoice.fees.subscription.count).to eq(1) expect(result.invoice.currency).to eq('EUR') expect(result.invoice.fees_amount_cents).to eq(3_000) diff --git a/spec/services/invoices/subscription_service_spec.rb b/spec/services/invoices/subscription_service_spec.rb index 79f5d910207..893af3e672b 100644 --- a/spec/services/invoices/subscription_service_spec.rb +++ b/spec/services/invoices/subscription_service_spec.rb @@ -86,8 +86,8 @@ expect(result.invoice.issuing_date.to_date).to eq(timestamp) expect(result.invoice.invoice_type).to eq("subscription") expect(result.invoice.payment_status).to eq("pending") - expect(result.invoice.fees.subscription_kind.count).to eq(1) - expect(result.invoice.fees.charge_kind.count).to eq(1) + expect(result.invoice.fees.subscription.count).to eq(1) + expect(result.invoice.fees.charge.count).to eq(1) expect(result.invoice.currency).to eq("EUR") expect(result.invoice.fees_amount_cents).to eq(100) @@ -176,8 +176,8 @@ expect(result.invoice.issuing_date.to_date).to eq(timestamp) expect(result.invoice.invoice_type).to eq("subscription") expect(result.invoice.payment_status).to eq("pending") - expect(result.invoice.fees.subscription_kind.count).to eq(1) - expect(result.invoice.fees.charge_kind.count).to eq(1) + expect(result.invoice.fees.subscription.count).to eq(1) + expect(result.invoice.fees.charge.count).to eq(1) expect(result.invoice.currency).to eq("EUR") expect(result.invoice.fees_amount_cents).to eq(100)