-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Refunding Doesn't Update Credit Owed #1475
Comments
My and @mtylty started to investigate this issue and we found these related issues: #1254, #1107, spree/spree#6229 , spree/spree#5907 |
In Spree::OrderUpdater the `update_payment_total` was incorrectly removing the refunds total from each order payment. This seems incorrect because they are separate things. Refund total has to be taken away into the outstanding_balance calculation instead. rel solidusio#1475
In Spree::OrderUpdater the `update_payment_total` was incorrectly removing the refunds total from each order payment. This seems incorrect because they are separate things. Refund total has to be taken away into the outstanding_balance calculation instead. Replace payment_total column with method that subtract refunds from incoming_payment. To keep backward compatibility update_payment_total call update_incoming_payment, and put in incoming_payment the sum of completed payments. rel solidusio#1475
The reason this is happening is because of this line: def outstanding_balance
# If reimbursement has happened add it back to total to prevent balance_due payment state
# See: https://github.com/spree/spree/issues/6229
adjusted_payment_total = payment_total + refund_total
if state == 'canceled'
-1 * adjusted_payment_total
else
total - adjusted_payment_total
end
end After a In turn, this method calls See https://github.com/solidusio/solidus/blob/master/core/app/models/spree/order_updater.rb#L141 def update_payment_total
order.payment_total = payments.completed.includes(:refunds).map { |payment| payment.amount - payment.refunds.sum(:amount) }.sum
end So TLDR; Get rid of EditI'm realizing that this method may be used at times when the payment total has not been updated. So the question stands on what is the best way to fix this? |
Created a spec to simulate the behavior listed in solidusio#1475 in order to properly fix the issue.
Created a spec to simulate the behavior listed in solidusio#1475 in order to properly fix the issue.
Created a spec to simulate the behavior listed in solidusio#1475 in order to properly fix the issue.
I believe this is fixed by #2002 |
When a refund is given, the "Credit Owed" in the admin and order payment state are not correctly updated.
Steps to Reproduce
Start up a Solidus Sandbox
Expected Results
The order should move into a paid state and balance due/credit owed should be $0
Actual Results
The order's payment state is still credit owed, with -$20.99 showing as credit owed at the top of the page.
Example
The text was updated successfully, but these errors were encountered: