diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index 2111ded8f51a..fb3b355cb9fc 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -445,9 +445,7 @@ public function import($values): void { return; } - // process pledge payment assoc w/ the contribution - $this->processPledgePayments($formatted); - $this->setImportStatus($rowNumber, $this->getStatus(self::PLEDGE_PAYMENT)); + $this->setImportStatus($rowNumber, $this->processPledgePayments($formatted) ? $this->getStatus(self::PLEDGE_PAYMENT) : $this->getStatus(self::VALID), '', $newContribution['id']); return; } $labels = [ @@ -494,12 +492,11 @@ public function import($values): void { //return soft valid since we need to show how soft credits were added if (!empty($formatted['soft_credit'])) { - $this->setImportStatus($rowNumber, $this->getStatus(self::SOFT_CREDIT)); + $this->setImportStatus($rowNumber, $this->getStatus(self::SOFT_CREDIT), '', $newContribution['id']); return; } - $this->processPledgePayments($formatted); - $this->setImportStatus($rowNumber, $this->getStatus(self::PLEDGE_PAYMENT)); + $this->setImportStatus($rowNumber, $this->processPledgePayments($formatted) ? $this->getStatus(self::PLEDGE_PAYMENT) : $this->getStatus(self::VALID), '', $newContribution['id']); return; } @@ -560,13 +557,12 @@ public function import($values): void { //return soft valid since we need to show how soft credits were added if (!empty($formatted['soft_credit'])) { - $this->setImportStatus($rowNumber, $this->getStatus(self::SOFT_CREDIT), ''); + $this->setImportStatus($rowNumber, $this->getStatus(self::SOFT_CREDIT), '', $newContribution['id']); return; } // process pledge payment assoc w/ the contribution - $this->processPledgePayments($formatted); - $this->setImportStatus($rowNumber, $this->getStatus(self::PLEDGE_PAYMENT)); + $this->setImportStatus($rowNumber, $this->processPledgePayments($formatted) ? $this->getStatus(self::PLEDGE_PAYMENT) : $this->getStatus(self::VALID), $newContribution['id']); return; } @@ -598,8 +594,10 @@ protected function getStatus(?int $code): string { * Process pledge payments. * * @param array $formatted + * + * @return bool */ - private function processPledgePayments(array $formatted) { + private function processPledgePayments(array $formatted): bool { if (!empty($formatted['pledge_payment_id']) && !empty($formatted['pledge_id'])) { //get completed status $completeStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); @@ -615,7 +613,9 @@ private function processPledgePayments(array $formatted) { NULL, $formatted['total_amount'] ); + return TRUE; } + return FALSE; } /**