Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performing a reimbursement of type store credit does not create a store credit #2780

Closed
fkoessler opened this issue Jun 20, 2018 · 2 comments

Comments

@fkoessler
Copy link
Contributor

Steps to reproduce

Create a customer return and choose a reimbursement of type "Store Credit".

screenshot-localhost 3000-2018-06-20-14-34-09

Perform the reimbursement.

screenshot-localhost 3000-2018-06-20-14-35-51

Expected behavior

A StoreCredit should be created (table spree_store_credits) and linked to from Reimbursement::Credit (table spree_reimbursement_credits).

Actual behavior

The StoreCredit creation fails without generating any error.
There is no line added to the spree_store_credits table.
The creditable_id column in the spree_reimbursement_credits table is nil.

Explanation

The StoreCredit creation is made in Spree::ReimbursementType::ReimbursementHelpers #create_creditable method.

def create_creditable(reimbursement, unpaid_amount)
  Spree::Reimbursement::Credit.default_creditable_class.new(
    user: reimbursement.order.user,
    amount: unpaid_amount,
    category: Spree::StoreCreditCategory.reimbursement_category(reimbursement),
    created_by: Spree::StoreCredit.default_created_by,
    memo: "Refund for uncreditable payments on order #{reimbursement.order.number}",
    currency: reimbursement.order.currency
  )
end

This method uses Spree::StoreCredit.default_created_by to retrieve the user creating the store credit.

class << self
  def default_created_by
    Spree.user_class.find_by(email: DEFAULT_CREATED_BY_EMAIL)
  end
end

The DEFAULT_CREATED_BY constant is hidden in the Spree::StoreCredit class and equals to [email protected].

If there is no such user, the StoreCredit creation fails.

Solution

Retrieve the actual logged in user or move the DEFAULT_CREATED_BY_EMAIL to a preference settings.

System configuration

Solidus Version: v2.6.0.rc1

Extensions in use: none (solidus ummy_app)

@fkoessler
Copy link
Contributor Author

This is actually the same issue as #2645.

Note that you won't be able to reproduce the bug if you have a user with email [email protected]

@kennyadsl
Copy link
Member

Closed with #2802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants