Skip to content

Commit

Permalink
Merge pull request #17176 from eileenmcnaughton/batch1
Browse files Browse the repository at this point in the history
Move batch-form support code back to the form
  • Loading branch information
colemanw authored Apr 30, 2020
2 parents 2e0edd7 + 2f8a402 commit f6740bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
20 changes: 19 additions & 1 deletion CRM/Batch/Form/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,27 @@ private function processContribution(&$params) {
}
}
$value['line_item'] = $lineItem;
$value['skipCleanMoney'] = TRUE;

//finally call contribution create for all the magic
$contribution = CRM_Contribute_BAO_Contribution::create($value);
// This code to retrieve the contribution has been moved here from the contribution create
// api. It may not be required.
$titleFields = [
'contact_id',
'total_amount',
'currency',
'financial_type_id',
];
$retrieveRequired = 0;
foreach ($titleFields as $titleField) {
if (!isset($contribution->$titleField)) {
$retrieveRequired = 1;
break;
}
}
if ($retrieveRequired == 1) {
$contribution->find(TRUE);
}
$batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate');
if (!empty($this->_batchInfo['type_id']) && ($this->_batchInfo['type_id'] == $batchTypes['Pledge Payment'])) {
$adjustTotalAmount = FALSE;
Expand Down
21 changes: 0 additions & 21 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,27 +508,6 @@ public static function create(&$params, $ids = []) {
CRM_Core_BAO_Note::add($noteParams);
}

// make entry in batch entity batch table
if (!empty($params['batch_id'])) {
// in some update cases we need to get extra fields - ie an update that doesn't pass in all these params
$titleFields = [
'contact_id',
'total_amount',
'currency',
'financial_type_id',
];
$retrieveRequired = 0;
foreach ($titleFields as $titleField) {
if (!isset($contribution->$titleField)) {
$retrieveRequired = 1;
break;
}
}
if ($retrieveRequired == 1) {
$contribution->find(TRUE);
}
}

CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);

$transaction->commit();
Expand Down

0 comments on commit f6740bf

Please sign in to comment.