-
-
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
don't allow multiple currencies in a batch #20884
Conversation
(Standard links)
|
a7838a7
to
531da5d
Compare
Ugh - this test is broken, and likely never worked except by accident.
However, |
jenkins, test this please |
CRM/Batch/BAO/EntityBatch.php
Outdated
$trxn = \Civi\Api4\FinancialTrxn::get(FALSE) | ||
->addSelect('currency', 'payment_instrument_id') | ||
->addWhere('id', '=', $params['entity_id']) | ||
->execute()[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.
If you change this from [0]
to ->first()
at least one of the test fails will disappear (ie ->execute()->first()
) trxn
will be an empty array if nothing is returned - which may, or may not, cause e-notices lower down.
api\v4\Entity\ConformanceTest::testConformance with data set "EntityBatch" ('EntityBatch')
Undefined offset: 0
@MegaphoneJon at a high level I think the tests are failing because you assume the presence of required values - but for update that may not be true |
That makes a lot of sense, Eileen. I'll investigate that. |
test this please |
1 similar comment
test this please |
@MegaphoneJon conflict :-( |
5ff258a
to
3af7aee
Compare
3af7aee
to
df33c0c
Compare
This finally passes tests. One failure is because you can have |
OK & I tested this & it works (after gaslighting myself that it didn't for a bit). Note that the demo data set now has some non us currency transactions by default - #22438 makes it easier to spot the Canadian ones |
I think there's an issue with UK Gift Aid extension relating to this MR: https://lab.civicrm.org/extensions/ukgiftaid/-/issues/30#note_75288 The Gift Aid extension works by making batches of contributions - but the currency checks here seem to assume only ever adding financial_trxn to batches? In particular this line https://github.com/MegaphoneJon/civicrm-core/blob/df33c0cd9bfa8c38aa8710a97f94ebb3da660a1a/CRM/Batch/BAO/EntityBatch.php#L42-L44 looks up a financial_trxn based on the |
Interesting @ufundo - I checked the entire core codebase and determined that Admittedly, I suspect that it's Gift Aid that needs to be changed, not this code. It seems like batches of contributions rather than FinancialTrxn records is going to be inexact. E.g. how does Gift Aid handle a contribution with two (or more) line items of different financial types? |
Hi @MegaphoneJon - thanks for having a look! Agree it feels like maybe Gift Aid should work on I don't know the logic of the design of But as a stop-gap? #23741 |
https://lab.civicrm.org/dev/financial/-/issues/89
Overview
Adding multiple currencies to a batch results in dataTables errors when viewing a list of batches.
Steps to replicate
Before
dataTables error.
After
No dataTables error - but more importantly - you are no longer allowed to add a contribution that doesn't match the currency of existing transactions in the batch.
Comments
When I went to make this change, I saw a lot of code quality issues and ended up doing a fair amount of refactoring in the process:
CRM_Financial_Page_AJAX::assignRemove()
andCRM_Financial_Page_AJAX::bulkAssignRemove()
.@JoeMurray you had this ticket assigned to yourself so I imagine you have some interest in this.