-
-
Notifications
You must be signed in to change notification settings - Fork 825
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-21580 - fix exporting financial batch fails when label of batch statuses changed #11434
Conversation
Can one of the admins verify this patch? |
test this please |
CRM/Financial/Form/Export.php
Outdated
@@ -90,7 +90,11 @@ public function preProcess() { | |||
} | |||
|
|||
$allBatchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id'); | |||
$this->_exportStatusId = CRM_Utils_Array::key('Exported', $allBatchStatus); | |||
$this->_exportStatusId = civicrm_api3('OptionValue', 'getSingle', array( |
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 (although we should not merge until 4.7.30 rc is cut since we are keeping short-form arrays out until then) but a shortcut would be to use 'getvalue' rather than 'getsingle' - you would need to add the 'return' => 'value' param.
Also, the 'sequential' => 1 param does nothing here - it causes the values to be re-indexed starting from 0 - but getsingle & getvalue return from a lower part of the array
email fails are on formatting / coding standards - see https://docs.civicrm.org/dev/en/latest/standards/ for what we use |
I followed your hints according to the getvalue and fixed the styling errors.Thanks for mentioning the getValue api call. I had never used that before. |
Test this please |
CRM/Financial/Form/Export.php
Outdated
$this->_exportStatusId = civicrm_api3('OptionValue', 'getValue', array( | ||
'option_group_id' => 'batch_status', | ||
'name' => 'Exported', | ||
'return' => 'value' |
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.
@JO0st you need to add a ,
to the end of this line
@civicrm-builder add to whitelist |
@JO0st do you know how to do a rebase to squash these 3 commits into one?
Then put
|
Unrelated test failure. @civicrm-builder retest this please. |
@civicrm-builder retest this please. |
1 similar comment
@civicrm-builder retest this please. |
Squashed the commits into 1 commit |
@JO0st there's a alternate way to fetch 'Exported' status ID, here's is it: diff --git a/CRM/Financial/Form/Export.php b/CRM/Financial/Form/Export.php
index e5d19dd..b58e57b 100644
--- a/CRM/Financial/Form/Export.php
+++ b/CRM/Financial/Form/Export.php
@@ -94,8 +94,7 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {
$this->_batchIds = $this->_id;
}
- $allBatchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
- $this->_exportStatusId = CRM_Utils_Array::key('Exported', $allBatchStatus);
+ $this->_exportStatusId = CRM_Core_PseudoConstant::getKey('CRM_Batch_DAO_Batch', 'status_id', 'Exported');
// check if batch status is valid, do not allow exported batches to export again
$batchStatus = CRM_Batch_BAO_Batch::getBatchStatuses($this->_batchIds); This fn does the same thing and eventually makes use of the pseudo information associated with a table column (see here) and fetch the corresponding option value. |
@monishdeb That works indeed. Is there a reason to use that over the API? |
@JO0st bcoz its just 1 LOC against 2 :) Also a standard approach to fetch the key( or option value) by using the pseudo information of a table column. Likewise, you can also fetch the label by using the key via |
I used @monishdeb 's way of getting the status id in stead of the api |
CRM-21580 - fix exporting financial batch fails when label of batch statuses changed
Overview
Only batches with the exported staus could be exported. The check wether a batch had the status exported was done based on the label of the batch status. I changed this to use the name (which shouldn't change) of the status
Before
Batches couldn't be exported if the label of the exported state has changed.
After
Batches can be exported if the label of the exported state has changed.