Skip to content
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

Fix Invoice class to not call validateData #18372

Merged
merged 1 commit into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, TRUE);

$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
1 change: 1 addition & 0 deletions tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function testInvoiceForDueDate() {

$this->assertNotContains('Due Date', $invoiceHTML[$result['id']]);
$this->assertNotContains('PAYMENT ADVICE', $invoiceHTML[$result['id']]);
$this->assertContains('Mr. Anthony Anderson II', $invoiceHTML[$result['id']]);

$this->assertContains('Due Date', $invoiceHTML[$contribution['id']]);
$this->assertContains('PAYMENT ADVICE', $invoiceHTML[$contribution['id']]);
Expand Down