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
a495d83a
Commit
a495d83a
authored
5 years ago
by
Pradeep Nayak
Browse files
Options
Downloads
Patches
Plain Diff
Added unit test
removed space
parent
d24d6560
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
+98
-0
98 additions, 0 deletions
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
with
98 additions
and
0 deletions
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
+
98
−
0
View file @
a495d83a
...
...
@@ -1573,6 +1573,104 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
),
$checkAgainst
);
}
/**
* https://lab.civicrm.org/dev/financial/issues/56
* Changing financial type on a contribution records correct financial items
*/
public
function
testChangingFinancialTypeWithoutTax
()
{
$ids
=
$values
=
[];
$contactId
=
$this
->
individualCreate
();
$params
=
array
(
'contact_id'
=>
$contactId
,
'receive_date'
=>
date
(
'YmdHis'
),
'total_amount'
=>
100.00
,
'financial_type_id'
=>
'Donation'
,
'contribution_status_id'
=>
'Completed'
,
);
/* first test the scenario when sending an email */
$contributionId
=
$this
->
callAPISuccess
(
'contribution'
,
'create'
,
$params
)[
'id'
];
// Update Financial Type.
$this
->
callAPISuccess
(
'contribution'
,
'create'
,
[
'id'
=>
$contributionId
,
'financial_type_id'
=>
'Event Fee'
,
]);
// Get line item
$lineItem
=
$this
->
callAPISuccessGetSingle
(
'LineItem'
,
[
'contribution_id'
=>
$contributionId
,
'return'
=>
[
"financial_type_id.name"
,
"line_total"
],
]);
$this
->
assertEquals
(
$lineItem
[
'line_total'
],
100.00
,
'Invalid line amount.'
);
$this
->
assertEquals
(
$lineItem
[
'financial_type_id.name'
],
'Event Fee'
,
'Invalid Financial Type stored.'
);
// Get Financial Items.
$financialItems
=
$this
->
callAPISuccess
(
'FinancialItem'
,
'get'
,
[
'entity_id'
=>
$lineItem
[
'id'
],
'sequential'
=>
1
,
'entity_table'
=>
'civicrm_line_item'
,
'options'
=>
[
'sort'
=>
"id"
],
'return'
=>
[
"financial_account_id.name"
,
"amount"
,
"description"
],
]);
$this
->
assertEquals
(
$financialItems
[
'count'
],
3
,
'Count mismatch.'
);
$toCheck
=
[
[
'Donation'
,
100.00
],
[
'Donation'
,
-
100.00
],
[
'Event Fee'
,
100.00
],
];
foreach
(
$financialItems
[
'values'
]
as
$key
=>
$values
)
{
$this
->
assertEquals
(
$values
[
'financial_account_id.name'
],
$toCheck
[
$key
][
0
],
'Invalid Financial Account stored.'
);
$this
->
assertEquals
(
$values
[
'amount'
],
$toCheck
[
$key
][
1
],
'Amount mismatch.'
);
$this
->
assertEquals
(
$values
[
'description'
],
'Contribution Amount'
,
'Description mismatch.'
);
}
// Check transactions.
$financialTransactions
=
$this
->
callAPISuccess
(
'EntityFinancialTrxn'
,
'get'
,
[
'return'
=>
[
"financial_trxn_id"
],
'entity_table'
=>
"civicrm_contribution"
,
'entity_id'
=>
$contributionId
,
'sequential'
=>
1
,
]);
$this
->
assertEquals
(
$financialTransactions
[
'count'
],
3
,
'Count mismatch.'
);
foreach
(
$financialTransactions
[
'values'
]
as
$key
=>
$values
)
{
$this
->
callAPISuccessGetCount
(
'EntityFinancialTrxn'
,
[
'financial_trxn_id'
=>
$values
[
'financial_trxn_id'
],
'amount'
=>
$toCheck
[
$key
][
1
],
'financial_trxn_id.total_amount'
=>
$toCheck
[
$key
][
1
],
],
2
);
}
}
/**
* CRM-21424 Check if the receipt update is set after composing the receipt message
*/
...
...
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