Sha256: 8b7a698941b8537fadff87b91825dd379c85ed88be7866024606cf9b88edf792

Contents?: true

Size: 613 Bytes

Versions: 23

Compression:

Stored size: 613 Bytes

Contents

# frozen_string_literal: true

FactoryBot.define do
  factory :reimbursement, class: 'Spree::Reimbursement' do
    transient do
      return_items_count { 1 }
    end

    customer_return { create(:customer_return_with_accepted_items, line_items_count: return_items_count) }

    before(:create) do |reimbursement, _evaluator|
      reimbursement.order ||= reimbursement.customer_return.order
      if reimbursement.return_items.empty?
        reimbursement.return_items = reimbursement.customer_return.return_items
      end
      reimbursement.total = reimbursement.return_items.sum(&:amount)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
solidus_core-4.4.1 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.4.0 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.3.4 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.2.4 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.1.5 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.3.3 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.3.2 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.1.4 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.3.1 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.3.0 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.2.3 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.1.3 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.0.4 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.0.3 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.1.2 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.2.2 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.2.1 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.2.0 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.1.1 lib/spree/testing_support/factories/reimbursement_factory.rb
solidus_core-4.0.2 lib/spree/testing_support/factories/reimbursement_factory.rb