diff --git a/CRM/Sepa/Page/ListGroup.php b/CRM/Sepa/Page/ListGroup.php index 41d8bcc1..1644adff 100644 --- a/CRM/Sepa/Page/ListGroup.php +++ b/CRM/Sepa/Page/ListGroup.php @@ -19,6 +19,7 @@ use CRM_Sepa_ExtensionUtil as E; use Civi\Api4\SepaTransactionGroup; use Civi\Api4\Contribution; +use Civi\Api4\SepaMandate; /** * back office sepa group content viewer @@ -36,6 +37,7 @@ public function run() { ->selectRowCount() ->addSelect( 'id', + 'type', 'reference', 'status_id', 'COUNT(DISTINCT contribution.id) AS total_count', @@ -63,7 +65,7 @@ public function run() { ); } - $result = Contribution::get() + $contributionApi = Contribution::get() ->selectRowCount() ->addSelect( 'contact_id.display_name', @@ -75,14 +77,41 @@ public function run() { 'financial_type_id', 'financial_type_id:label', 'campaign_id.title', - 'contribution_status_id:label' + 'contribution_status_id:label', + 'mandate.reference', + 'mandate.iban', ) - ->addJoin('SepaTransactionGroup AS sepa_transaction_group', 'INNER', 'SepaContributionGroup') + ->addJoin('SepaTransactionGroup AS sepa_transaction_group', 'INNER', 'SepaContributionGroup'); + if ($txGroup['type'] !== 'OOFF') { + // This is a recurring a group. + $contributionApi->addJoin('SepaMandate AS mandate', 'LEFT', NULL, + ['mandate.entity_table', '=', 'civicrm_contribution_recur', FALSE], + ['mandate.entity_id', '=', 'contribution_recur_id', TRUE] + ); + } + $result = $contributionApi ->addWhere('sepa_transaction_group.id', '=', $groupId) ->execute(); $statusStats = []; $contributions = []; foreach ($result as $contribution) { + if ($txGroup['type'] === 'OOFF') { + // For one off's we have to fetch the mandate per contribution + // There is an issue with Join between Contribution and Sepa Mandate + // CiviCRM core adds a join on first_contribution_id as well. + try { + $mandate = SepaMandate::get(FALSE) + ->addWhere('entity_table', '=', 'civicrm_contribution') + ->addWhere('entity_id', '=', $contribution['id']) + ->execute() + ->single(); + $contribution['mandate.reference'] = $mandate['reference']; + $contribution['mandate.iban'] = $mandate['iban']; + } + catch (\Exception $e) { + // @ignoreException + } + } $contributions[] = [ 'contact_display_name' => $contribution['contact_id.display_name'], 'contact_type' => $contribution['contact_id.contact_type'], @@ -105,6 +134,8 @@ public function run() { 'financial_type_id' => $contribution['financial_type_id'], 'financial_type' => $contribution['financial_type_id:label'], 'campaign' => $contribution['campaign_id.title'], + 'reference' => $contribution['mandate.reference'], + 'iban' => $contribution['mandate.iban'], ]; $statusStats[$contribution['contribution_status_id:label']] = 1 + ($statusStats[$contribution['contribution_status_id:label']] ?? 0); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 85356e94..76c72b98 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -48,12 +48,6 @@ parameters: count: 6 path: CRM/Admin/Form/Setting/SepaSettings.php - - - message: '#^PHPDoc tag @var with type HTML_QuickForm_select is not subtype of type HTML_QuickForm_Element\.$#' - identifier: varTag.type - count: 1 - path: CRM/Admin/Form/Setting/SepaSettings.php - - message: '#^Property CRM_Admin_Form_Setting_SepaSettings\:\:\$config_fields type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -944,12 +938,6 @@ parameters: count: 1 path: CRM/Sepa/Form/Search/SepaContactSearch.php - - - message: '#^Parameter \#4 \$attributes of method CRM_Core_Form\:\:add\(\) expects array\|null, true given\.$#' - identifier: argument.type - count: 2 - path: CRM/Sepa/Form/Search/SepaContactSearch.php - - message: '#^Parameter \#4 \$sort of method CRM_Contact_Form_Search_Custom_Base\:\:sql\(\) expects null, string\|null given\.$#' identifier: argument.type @@ -2245,6 +2233,18 @@ parameters: count: 1 path: CRM/Sepa/Page/ListGroup.php + - + message: '#^Cannot access offset ''mandate\.reference'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: CRM/Sepa/Page/ListGroup.php + + - + message: '#^Cannot access offset ''mandate\.iban'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: CRM/Sepa/Page/ListGroup.php + - message: '#^Cannot access offset ''contact_id\.contact_type'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -2290,7 +2290,7 @@ parameters: - message: '#^Cannot access offset ''id'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible - count: 2 + count: 3 path: CRM/Sepa/Page/ListGroup.php - @@ -3676,12 +3676,6 @@ parameters: count: 1 path: api/v3/SepaSddFile.php - - - message: '#^Call to an undefined static method CRM_Sepa_Logic_Batching\:\:batchContributionByCreditor\(\)\.$#' - identifier: staticMethod.notFound - count: 1 - path: api/v3/SepaTransactionGroup.php - - message: '#^Cannot access offset ''contributions_missing_transaction'' on array\|int\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -3706,18 +3700,6 @@ parameters: count: 1 path: api/v3/SepaTransactionGroup.php - - - message: '#^Cannot access offset ''is_error'' on array\|int\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: api/v3/SepaTransactionGroup.php - - - - message: '#^Cannot access offset ''values'' on array\|int\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: api/v3/SepaTransactionGroup.php - - message: '#^Cannot cast mixed to int\.$#' identifier: cast.int @@ -3733,12 +3715,6 @@ parameters: - message: '#^Only booleans are allowed in a negated boolean, int given\.$#' identifier: booleanNot.exprNotBoolean - count: 2 - path: api/v3/SepaTransactionGroup.php - - - - message: '#^Only booleans are allowed in a negated boolean, int\<0, max\> given\.$#' - identifier: booleanNot.exprNotBoolean count: 1 path: api/v3/SepaTransactionGroup.php @@ -3772,12 +3748,6 @@ parameters: count: 1 path: api/v3/SepaTransactionGroup.php - - - message: '#^Variable \$total might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: api/v3/SepaTransactionGroup.php - - message: '#^Binary operation "\." between ''\+'' and mixed results in an error\.$#' identifier: binaryOp.invalid diff --git a/templates/CRM/Sepa/Page/ListGroup.tpl b/templates/CRM/Sepa/Page/ListGroup.tpl index 30433c8b..37ffa6b4 100644 --- a/templates/CRM/Sepa/Page/ListGroup.tpl +++ b/templates/CRM/Sepa/Page/ListGroup.tpl @@ -24,6 +24,8 @@