Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
85381a51
Unverified
Commit
85381a51
authored
4 years ago
by
Seamus Lee
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #18271 from eileenmcnaughton/tax529
#1972
Fix tax_amount calclation on renewal form
parents
1b314d7d
dd118b15
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Financial/BAO/Order.php
+17
-3
17 additions, 3 deletions
CRM/Financial/BAO/Order.php
tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php
+2
-2
2 additions, 2 deletions
tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php
with
19 additions
and
5 deletions
CRM/Financial/BAO/Order.php
+
17
−
3
View file @
85381a51
...
...
@@ -236,18 +236,17 @@ class CRM_Financial_BAO_Order {
$lineItems
[
$valueID
]
=
CRM_Price_BAO_PriceSet
::
getLine
(
$params
,
$throwAwayArray
,
$this
->
getPriceSetID
(),
$this
->
getPriceFieldSpec
(
$fieldID
),
$fieldID
,
0
)[
1
][
$valueID
];
}
$taxRates
=
CRM_Core_PseudoConstant
::
getTaxRates
();
foreach
(
$lineItems
as
&
$lineItem
)
{
// Set any pre-calculation to zero as we will calculate.
$lineItem
[
'tax_amount'
]
=
0
;
if
(
$this
->
getOverrideFinancialTypeID
()
!==
FALSE
)
{
$lineItem
[
'financial_type_id'
]
=
$this
->
getOverrideFinancialTypeID
();
}
$taxRate
=
$t
axRates
[
$lineItem
[
'financial_type_id'
]
]
??
0
;
$taxRate
=
$t
his
->
getTaxRate
((
int
)
$lineItem
[
'financial_type_id'
]
)
;
if
(
$this
->
getOverrideTotalAmount
()
!==
FALSE
)
{
if
(
$taxRate
)
{
// Total is tax inclusive.
$lineItem
[
'tax_amount'
]
=
(
$taxRate
/
100
)
*
$this
->
getOverrideTotalAmount
();
$lineItem
[
'tax_amount'
]
=
(
$taxRate
/
100
)
*
$this
->
getOverrideTotalAmount
()
/
(
1
+
(
$taxRate
/
100
))
;
$lineItem
[
'line_total'
]
=
$lineItem
[
'unit_price'
]
=
$this
->
getOverrideTotalAmount
()
-
$lineItem
[
'tax_amount'
];
}
else
{
...
...
@@ -276,4 +275,19 @@ class CRM_Financial_BAO_Order {
return
$amount
;
}
/**
* Get the tax rate for the given financial type.
*
* @param int $financialTypeID
*
* @return float
*/
public
function
getTaxRate
(
int
$financialTypeID
)
{
$taxRates
=
CRM_Core_PseudoConstant
::
getTaxRates
();
if
(
!
isset
(
$taxRates
[
$financialTypeID
]))
{
return
0
;
}
return
$taxRates
[
$financialTypeID
];
}
}
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php
+
2
−
2
View file @
85381a51
...
...
@@ -241,7 +241,7 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase {
],
'credit_card_type'
=>
'Visa'
,
'billing_first_name'
=>
'Test'
,
'billing_middlename'
=>
'Last'
,
'billing_middle
_
name'
=>
'Last'
,
'billing_street_address-5'
=>
'10 Test St'
,
'billing_city-5'
=>
'Test'
,
'billing_state_province_id-5'
=>
'1003'
,
...
...
@@ -250,7 +250,7 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase {
]);
$contribution
=
$this
->
callAPISuccessGetSingle
(
'Contribution'
,
[
'contact_id'
=>
$this
->
_individualId
,
'is_test'
=>
TRUE
,
'return'
=>
[
'total_amount'
,
'tax_amount'
]]);
$this
->
assertEquals
(
50
,
$contribution
[
'total_amount'
]);
$this
->
assertEquals
(
5
,
$contribution
[
'tax_amount'
]);
$this
->
assertEquals
(
4.5
5
,
$contribution
[
'tax_amount'
]);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment