Skip to content

Commit

Permalink
Fix Invoice class to not call validateData
Browse files Browse the repository at this point in the history
This avoids calling the BaseIPN validateData class from Invoice.php and calls the narrower
loadRelatedObjects to avoid having to change the code around it
  • Loading branch information
eileenmcnaughton committed Sep 5, 2020
1 parent 30bd3f9 commit 1bd50d0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions CRM/Contribute/Form/Task/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) {
$pendingStatusId = CRM_Utils_Array::key('Pending', $contributionStatusID);

foreach ($invoiceElements['details'] as $contribID => $detail) {
$input = $ids = $objects = [];
$input = $ids = [];
if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) {
continue;
}
Expand All @@ -225,20 +225,17 @@ public static function printPDF($contribIDs, &$params, $contactIds) {
$ids['participant'] = $detail['participant'] ?? NULL;
$ids['event'] = $detail['event'] ?? NULL;

if (!$invoiceElements['baseIPN']->validateData($input, $ids, $objects, FALSE)) {
CRM_Core_Error::statusBounce('Supplied data was not able to be validated');
}

$contribution = &$objects['contribution'];
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $contribID;
$contribution->fetch();
$contribution->loadRelatedObjects($input, $ids);

$input['amount'] = $contribution->total_amount;
$input['invoice_id'] = $contribution->invoice_id;
$input['receive_date'] = $contribution->receive_date;
$input['contribution_status_id'] = $contribution->contribution_status_id;
$input['organization_name'] = $contribution->_relatedObjects['contact']->organization_name;

$objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date);

// Fetch the billing address. getValues should prioritize the billing
// address, otherwise will return the primary address.
$billingAddress = [];
Expand Down

0 comments on commit 1bd50d0

Please sign in to comment.