-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
CRM-20852 Show Tax term on UI #10640
Conversation
@JoeMurray @monishdeb @eileenmcnaughton Any of you have time to review this PR? There's no functional change, it's a tweak to the UI in various places to display sales tax a little bit more nicely. Pinging you as I've seen lot's of nice contribution related UI changes coming through from you :-) |
There are 2 things in this - neither of which I'm the expert on - 1 is the translation & @mlutfy would know the best approach there. The second is the rounding of line items & where is safe to do so. I think this probably should be on the form layer rather than a utility function - but I'm not familiar enough with that function to know if that is an issue with this change @KarinG knows the rounding best I think |
(as an aside - you should rebase to get rid of the extraneous commits - git rebase -i origin/master (do a get fetch -f first) |
52d2d0a
to
cc3f313
Compare
@eileenmcnaughton Thanks for the rebase tip. Now done, and I've added a note to the dev docs issue so we can include this workflow: https://github.com/civicrm/civicrm-dev-docs/issues/192 |
Cool.. will be providing my feedback shortly !! |
@@ -653,7 +654,7 @@ CRM.$(function($) { | |||
var totalTaxAmount = taxAmount + Number(totalAmount); | |||
totalTaxAmount = formatMoney( totalTaxAmount, 2, separator, thousandMarker ); | |||
|
|||
$("#totalTaxAmount" ).html('Amount with tax : <span id="currencySymbolShow">' + currencySymbol + '</span> '+ totalTaxAmount); | |||
$("#totalTaxAmount" ).html('Amount with ' + taxTerm + ' : <span id="currencySymbolShow">' + currencySymbol + '</span> '+ totalTaxAmount); |
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 this text should be passed through ts(...) as $("#totalTaxAmount" ).html(ts('Amount ...
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.
Thanks @monishdeb I've fixed that now
I have tested the patch and ensured that Tax term are correctly shown in desired pages, except one place where I left comment. However, casting with float won't cause any regression or unintended side-effect. But, I like to have @KarinG feedback re rounding, before merge :) |
@mattwire - thanks for rebasing this - looking at this now. |
Hi @mattwire ! I've pulled your Edits into a 4.6 project that has extensive Sales Tax set up. Below is my summary screenshot; Only thing that did not display properly for me was online -> Contribution page for Membership -> Confirm and Thank you screens; they both show too many zeros [middle section of screenshot]. Both the invoice PDF and the Contribution view generated from it are fine. But Math is fine and many displays are much nicer - so don't let this stop the edits from being merged in. |
CRM/Price/BAO/LineItem.php
Outdated
@@ -301,7 +301,8 @@ public static function getLineItems($entityId, $entity = 'participant', $isQuick | |||
$taxRates = CRM_Core_PseudoConstant::getTaxRates(); | |||
if (isset($lineItems[$dao->id]['financial_type_id']) && array_key_exists($lineItems[$dao->id]['financial_type_id'], $taxRates)) { | |||
// We are close to output/display here - so apply some rounding at output/display level - to not show Tax Rate in all 8 decimals | |||
$lineItems[$dao->id]['tax_rate'] = round($taxRates[$lineItems[$dao->id]['financial_type_id']], 3); | |||
// Cast to float so trailing zero decimals are removed. | |||
$lineItems[$dao->id]['tax_rate'] = (float) round($taxRates[$lineItems[$dao->id]['financial_type_id']], 3); | |||
} |
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 is fine - I'm cautiously optimistic with the cast we can remove the round(,3) - but let's keep that in mind for later.
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've just checked, and removed the round here. It's only used for display so we don't need it with the cast.
Of course it would not be too hard to get rid of the trailing zeros in Confirm and ThankYou as well :-) |
…The actual change is a cast to float, but a small amount of rearranging the function was required so it was actually set. Added note that buildQuickform() in Confirm.php and Thankyou.php share quite a bit of code and would benefit from refactoring
@monishdeb @KarinG Thanks for spending the time to review! @KarinG Awesome screenshot! I just pushed a couple of commits which I think address all your comments. |
@@ -523,10 +523,11 @@ public function buildQuickForm() { | |||
$getTaxDetails = FALSE; | |||
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); |
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 feel these edits are going to require a lot more testing; multiple line items; online contribution form; w/ sales taxes;
I would prefer we merge your TaxTerm work in now: either delete this commit - or by replace it with a less invasive commit -> a TPL edit. All we really want is to change how line.tax_rate is displayed in the LineItem.tpl
<td class="right">{$taxTerm} ({$line.tax_rate}%)</td>
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.
So there doesn't seem to be an easy way of stripping zero decimals in smarty - there's things like this but it seems a bit heavy for a tpl: https://stackoverflow.com/questions/26565650/smarty-trim-zeros-from-the-end-of-string-float-value. I have just pushed a simpler, less invasive version of the previous patch. It still uses the cast to float as before, but only makes a single line change to Confirm.php (Thankyou.php requires a block of code to be moved so the lineItem variables are set for display but this is lower risk as Thankyou.php does not save anything, only displays to the end user). I have run tests with multiple line items on the contribution pages and can find no issues with displaying the line items (both use LineItem.tpl for actual display). @KarinG @monishdeb what do you think of the updated patch?
… forms. The actual change is a cast to float, but a small amount of rearranging the function was required so it was actually set. Added note that buildQuickform() in Confirm.php and Thankyou.php share quite a bit of code and would benefit from refactoring" This reverts commit 4b58e3b.
Thank you @mattwire - do you know if there is a test specific to online contributions - multiple line items w/ sales taxes? (not at a desk right now). |
So my thoughts are we should not make edits to Confirm and ThankYou php code if we don't have an existing test that proves that the edits are ok; Let's remove that commit; get this PR merged - then you can work on the more critical issue (support for more decimals) - first? |
@mattwire this test appears to give some cover - I've not read it carefully enough to know how it fits with the change you are making - there are some others in that class that might also |
That's the test I added [to secure the don't round sales taxes prematurely fix]. For sure it secures back-end entry [I tested the test left and right for that scenario] - but I'm not sure a |
Contribution_page.submit tests the postProcess (from Confirm I guess) - I don't think it tests Thank you at all. We don't have any precedent for testing thank you pages - but they are display pages rather than data saving pages. Not sure about the test that passed that you mention - presumably you hit a different variant of factors |
… forms - safer change" This reverts commit ec59f9c.
@KarinG I've broken out the changes to Confirm/Thankyou.php to a new issue https://issues.civicrm.org/jira/browse/CRM-21062 with PR#10856 So this one should now be good to merge? |
I'm comfortable with these edits. It's a good improvement (to start displaying actual TaxTerm) and there will be another day when we can be certain the tests are in place to ensure Confirm.php edits don't have unexpected consequences. |
Hey @monishdeb is this something you are happy to merge? Based on approval and testing from @KarinG |
Sorry for the delay. Merging based on @KarinG approval and my code review. |
@mattwire can you please close related JIRA issue(s)? Thanks |
Ref CRM-20772. Show the tax term on the UI when possible (eg. "VAT" instead of "tax").