-
Notifications
You must be signed in to change notification settings - Fork 3
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
Change calculation payment_total #3
Conversation
DEPRECATION WARNING: Passing a class as a value in an Active Record query is deprecated and will be removed. Pass a string instead. (called from block in <class:PromotionAction> at ...
The taxon products API which is used to manage display order falls down under its own weight in any sort of reasonable data set. In order to simplify that, I have added the ability to customize the return data from this controller. In a simple case, the results will be the same as they are right now, however you can pass `simple: 1` to the taxon/products API request and it will return significantly less data. Additionally, this updates the backend taxons.js.coffee to use this simple view for all it needs. This reduces the amount of data that needs to be queried and returned in order to make this fast. Previously I was seeing 20+ second response times for a small number of products in a complicated taxon structure. This reduces that down to the 100ms range.
Add the ability to get simple results from taxon API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also change the commit message to:
Fix how orders payment total is calculated
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.
@@ -355,7 +355,7 @@ def create_tax_charge! | |||
def outstanding_balance | |||
# If reimbursement has happened add it back to total to prevent balance_due payment state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these two comment lines do not apply anymore since we are not adding back any refund (but we are removing it). I'd probably remove them at all since the code is self-explanatory now.
@@ -73,7 +73,7 @@ def update_shipments | |||
end | |||
|
|||
def update_payment_total | |||
order.payment_total = payments.completed.includes(:refunds).map { |payment| payment.amount - payment.refunds.sum(:amount) }.sum | |||
order.payment_total = payments.completed.map { |payment| payment.amount }.sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order.payment_total = payments.completed.sum(&:amount)
@@ -185,15 +213,17 @@ module Spree | |||
context "for canceled orders" do | |||
before { order.update_attributes(state: 'canceled') } | |||
|
|||
it "it should be a negative amount incorporating reimbursements" do | |||
it "it should be a zero amount incorporating reimbursements" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this specs is saying that it should be a zero amount but you expect -10. Probably the description is wrong?
Previously, @prototype was conditionally (if the corresponding ID as included in the params) in a before create callback on the product. This functionality has be moved out into a Prototypes extension.
In the bootstrap refactoring, the argument "wrapper_class" given to rendering the `rebuild_vat_prices_checkbox` was lost, leading to method not founds for stores with VAT. This commit changes the reference from `wrapper_class` to `local_assigns[:wrapper_class]` so that a) the partial does not error out when rendered without it and b) it is immediately apparent to the reader that `wrapper_class` is not a helper.
…nsion Prototypes move to extension
Fix deprecations from PromotionAction.of_type
Change new order button text on users edit page
45de5ad
to
2e824cd
Compare
…ass-error Do not require 'wrapper_class' var in price checkbox partial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just two small things
it "should return negative amount when payment_total is greater than total" do | ||
order.total = 8.20 | ||
order.payment_total = 10.20 | ||
expect(order.outstanding_balance).to be_within(0.001).of(-2.00) | ||
end | ||
|
||
let(:amount_payed) { 20.0 } | ||
let(:reimbursement) { create(:reimbursement) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielePalombo can this be removed?
context "with reimburesements on the order" do | ||
let(:amount) { 10.0 } | ||
let(:amount_payed) { 20.0 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paid everywhere 😄
2e824cd
to
94e6e54
Compare
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
94e6e54
to
c851404
Compare
review done, opened on solidus repo: solidusio#1536! |
Implement voiding transactions
Internal review
In Spree::OrderUpdater the
update_payment_total
subs from payments therefunds. I change this behavior and now the
payment_total
is composedwith only payments completed.
rel solidusio#1475