-
-
Notifications
You must be signed in to change notification settings - Fork 716
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
Add payment details to invoice #5712
Conversation
FYI those failing enterprise_controller specs are also in master and will be fixed by #5706 , so you shouldn't worry about them 👍 |
Thanks @sigmundpetersen - I think the failing |
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.
Nice one!
I think it's messy that the invoice templates are under orders, they should be a separate controller and views folder. And then it would be ok to have a dependency to the order_mailer... but this is not in scope for this PR.
I leave some comments below.
Updated screenshots - changed the column order as discussed in the issue #5208 - invoice PDF: And as it is affected by the addition of a helper, checking that the payments page is unchanged: |
@@ -4,4 +4,8 @@ module OrderHelper | |||
def last_payment_method(order) | |||
OrderPaymentFinder.new(order).last_payment&.payment_method | |||
end | |||
|
|||
def outstanding_balance_label(order) |
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.
@luisramos0 you mentioned extracting this logic to a service but it looked to me like it's more a helper type of thing...?
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 understand if you call it a label, I think this is more like a state. This the balance state of the order. This is something that will/could be needed in different places (the api for example) not just views. I see it as business logic that belongs in the service layer.
I think it's important we move all logic to services out of the MVC. This is something we have been doing lately in OFN and it's really good that we have thinner helpers/controllers/models and an organized service layer.
Anyway, I think this is an acceptable solution!
@@ -3,6 +3,7 @@ | |||
helper CheckoutHelper | |||
helper SpreeCurrencyHelper | |||
helper OrderHelper | |||
helper Spree::Admin::PaymentsHelper |
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.
Not sure if there's an issue with bringing in yet more helpers here
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.
Great!
Should I move this partial to app/views/spree/admin/shared?
app/views/spree/shared is fine 👍 ideally I'd prefer to see it outside the spree space, app/views/shared or app/views/admin/shared. Anyway, it's good as is 👍
I'm pretty sure we don't want the Spree based pretty_time method in more places, is there an alternate time formatter/technique we prefer that doesn't depend on Spree?
I dont know what's the best way to format a time BUT I dont see a problem of using spree code, as part of "bye bye spree" we will bring all the code we need from spree. base_helper is still on the spree side with a decorator on our side but we can definitely bring pretty_time to OFN and even improve it. I'd say let's use pretty time and improve it.
why is the order_mailer outside the admin dir anyway? Isn't it part of the orders admin form?
I am not sure why but all the spree mailers are outside admin. They are part of spree_core not spree_backend (which really is spree/admin).
@@ -4,4 +4,8 @@ module OrderHelper | |||
def last_payment_method(order) | |||
OrderPaymentFinder.new(order).last_payment&.payment_method | |||
end | |||
|
|||
def outstanding_balance_label(order) |
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 understand if you call it a label, I think this is more like a state. This the balance state of the order. This is something that will/could be needed in different places (the api for example) not just views. I see it as business logic that belongs in the service layer.
I think it's important we move all logic to services out of the MVC. This is something we have been doing lately in OFN and it's really good that we have thinner helpers/controllers/models and an organized service layer.
Anyway, I think this is an acceptable solution!
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.
oh, the build still has some relevant broken specs.
OK cool - I let them all run last night after doing some adhoc test runs locally, wasn't sure if the EDIT: Yay for tests. The change moving payments partial to shared has wider impact that I first realised, so this is something we'd need to add in the test plan. Impacted emails are:
Impacted invoice pdfs are:
|
One remaining failure on semaphore passes locally: spec/models/variant_override_spec.rb Reran the build and it failed again. Locally it works reliably - not sure what to do here. |
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.
yeah, that's it, well done!
We need to fix these flaky specs, not on this PR....
Hi @mbudm , I verified the issue described and used the steps described in #5208 to test the PR. I checked 4 cases, in which this information should be visible:
Verified that the generated pdf documents above were identical in all cases.
An issue not introduced by this PR: It's noticeable from the pics above, that shipping instructions appear on the email with the order confirmation, but are missing from the PDF file.
From the changes introduced by this PR, I would expected that "Credit Owed (£-12.00)" information would appear, somewhere in the area marked above. This is also not appearing in the order confirmation (email).
This looks good for merging, thank you for these improvements! Regarding the issues found:
|
Re the 2 issues:
Why do you think this is an issue? is it not a feature request? are the delivery instructions necessary on the invoice? why?
I think this is a bug in this PR. I think it could be the translation label :credit_owner missing from the en.yml file. |
Hey @luisramos0,
That's correct, that would be a feature request - not a bug. Invoice and order confirmation don't necessarily need the same info. Thanks!
Sounds good to me, especially knowing it's an easy fix. Moving back to In Dev 👍 Thanks again Luis! |
Hey @luisramos0,
That's correct, that would be a feature request - not a bug. Invoice and order confirmation don't necessarily need the same info. Thanks!
Sounds good to me, especially if looks like an easy fix. Would have a second look on it @mbudm? Moving back to In Dev 👍 |
b606ac2
to
fa7a6ef
Compare
Rebased, resolved conflicts, and the missing "credit owed" display should now be fixed. |
9a63a8e
to
7929f86
Compare
- Partial is used by both the invoice pdf and the order confirmation email - separate scss file for new payment list table - extracted outstanding balance logic (also changed in payments view.. admin/orders/RXXX/payments) - translations in shared.payments_list and lazy loaded
…t thought (yay tests)
The `Spree::Order#paid?` method actually includes orders with `payment_state == "credit_owed"`, which was breaking the desired display logic here.
7929f86
to
07b819a
Compare
I am moving to In Dev, I think it's worth doing the simple change I suggest now, ok Matt? |
Thanks @Matt-Yorkley Ready to go. |
What? Why?
Closes #5208
Add more detail on payment history to invoices. This helps to clarify the invoice when the status is balance due or credit owing.
Concerns/possible changes are:
scss
file where the invoice table is defined,app/assets/stylesheets/mail/email.scss
which feels a bit like a dumping ground - should we create a separate scss file for the invoice styles?What should we test?
Detailed steps to recreate are in the issue: #5208
A paid (completed) order - with a failed credit card attempt:
Release notes
Changelog Category: Changed