You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ship order
Create returns authorisation
Create customer return with reimbursement type of Spree::StoreCredit
Create reimbursement
Expected behavior
Spree::StoreCredit created
Actual behavior
Reimbursement credit is created with a creditable_type of Spree::StoreCredit but a creditable_id of nil.
System configuration
Solidus Version: 2.4.2
After falling down the rabbit hole debugging this I think I have worked out what is going on.
module Spree::ReimbursementType::ReimbursementHelpers
#...
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
end
The first issue is that the create_creditable method requires a created_by attribute to be set, and Spree::StoreCredit.default_created_by, which turns out to be...
class Spree::StoreCredit < Spree::PaymentSource
#...
DEFAULT_CREATED_BY_EMAIL = "[email protected]"
#....
class << self
def default_created_by
Spree.user_class.find_by(email: DEFAULT_CREATED_BY_EMAIL)
end
end
end
So unless you still have a user with [email protected] as an email address in your database the store credits will never save.
The text was updated successfully, but these errors were encountered:
I confirm the bug on master sandbox. I'm trying to create a spec to reproduce the issue but still can't do that, it seems like our specs on that are correctly creating the creditable object.
Steps to reproduce
Ship order
Create returns authorisation
Create customer return with reimbursement type of
Spree::StoreCredit
Create reimbursement
Expected behavior
Spree::StoreCredit created
Actual behavior
Reimbursement credit is created with a
creditable_type
ofSpree::StoreCredit
but acreditable_id
ofnil
.System configuration
Solidus Version: 2.4.2
After falling down the rabbit hole debugging this I think I have worked out what is going on.
The first issue is that the
create_creditable
method requires acreated_by
attribute to be set, andSpree::StoreCredit.default_created_by
, which turns out to be...So unless you still have a user with
[email protected]
as an email address in your database the store credits will never save.The text was updated successfully, but these errors were encountered: