Skip to content
Open
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
17 changes: 14 additions & 3 deletions CRM/Banking/PluginImpl/Matcher/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@

// load last fee
if (!empty($last_fee_id)) {
$last_fee = civicrm_api3('Contribution', 'getsingle', ['id' => $last_fee_id]);
$last_fee['days'] = round((strtotime($btx->booking_date) - (int) strtotime($last_fee['receive_date'])) / (60 * 60 * 24));
$last_fee = civicrm_api3('Contribution', 'getsingle', ['id' => $last_fee_id]);
$last_fee['days_different'] = $this->getRelativeDays($btx->booking_date, $last_fee['receive_date']);

Check failure on line 174 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Cannot access offset 'days_different' on array|int.

Check failure on line 174 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Cannot access offset 'days_different' on array|int.

Check failure on line 174 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Cannot access offset 'days_different' on array|int.
$smarty_vars['last_fee'] = $last_fee;
}

// calculate some stuff
$date_field = ($config->based_on_start_date) ? 'start_date' : 'join_date';
$membership['days'] = round((strtotime($btx->booking_date) - strtotime($membership[$date_field])) / (60 * 60 * 24));
$membership['days_different'] = $this->getRelativeDays($btx->booking_date, $membership[$date_field]);

Check failure on line 180 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Cannot access offset 'days_different' on array|int.

Check failure on line 180 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Cannot access offset 'days_different' on array|int.

Check failure on line 180 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Cannot access offset 'days_different' on array|int.
$membership['percentage_of_minimum'] = round(($btx->amount / (float) $membership_type['minimum_fee']) * 100);
$membership['title'] = $this->getMembershipOption($membership['membership_type_id'], 'title', $membership_type['name']);

Expand Down Expand Up @@ -491,4 +491,15 @@
return $rating;
}

private function getRelativeDays($fromDate, $toDate) {

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has parameter $toDate with no type specified.

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has parameter $fromDate with no type specified.

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has no return type specified.

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has parameter $toDate with no type specified.

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has parameter $fromDate with no type specified.

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.1 prefer-lowest

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has no return type specified.

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has parameter $toDate with no type specified.

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has parameter $fromDate with no type specified.

Check failure on line 494 in CRM/Banking/PluginImpl/Matcher/Membership.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.4 prefer-stable

Method CRM_Banking_PluginImpl_Matcher_Membership::getRelativeDays() has no return type specified.
$days = round((strtotime($fromDate) - (int) strtotime($toDate)) / (60 * 60 * 24));
if ($days > 0) {
return E::ts('%1 days earlier', [1 => $days]);
}
if ($days < 0) {
return E::ts('%1 days later', [1 => -$days]);
}
return E::ts('Same day');
}

}
16 changes: 2 additions & 14 deletions templates/CRM/Banking/PluginImpl/Matcher/Membership.suggestion.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,8 @@
<div class="btxvalue">{$last_fee.total_amount|crmMoney:$last_fee.currency}</div>
</td>
<td>
{capture assign=day_count}{$last_fee.days|abs}{/capture}
{if $last_fee.days gt 0}
{capture assign=last_fee_days}{ts 1=$day_count domain='org.project60.banking'}(%1 days earlier){/ts}{/capture}
{else}
{capture assign=last_fee_days}{ts 1=$day_count domain='org.project60.banking'}(%1 days later){/ts}{/capture}
{/if}
<div class="btxlabel">{ts domain='org.project60.banking'}Paid{/ts}:</div>
<div class="btxvalue">{$last_fee.receive_date|crmDate:$config->dateformatFull} {$last_fee_days}</div>
<div class="btxvalue">{$last_fee.receive_date|crmDate:$config->dateformatFull} ({$last_fee.days_different})</div>
</td>
<td>
<div class="btxlabel">{ts domain='org.project60.banking'}Type{/ts}:</div>
Expand All @@ -89,14 +83,8 @@
<div class="btxvalue"><strong>{ts domain='org.project60.banking'}None{/ts}</strong></div>
</td>
<td>
{capture assign=day_count}{$membership.days|abs}{/capture}
{if $membership.days gt 0}
{capture assign=membership_days}{ts 1=$day_count domain='org.project60.banking'}(%1 days earlier){/ts}{/capture}
{else}
{capture assign=membership_days}{ts 1=$day_count domain='org.project60.banking'}(%1 days later){/ts}{/capture}
{/if}
<div class="btxlabel">{ts domain='org.project60.banking'}Due{/ts}:</div>
<div class="btxvalue">{$membership.start_date|crmDate:$config->dateformatFull} {$membership_days}</div>
<div class="btxvalue">{$membership.start_date|crmDate:$config->dateformatFull} ({$membership.days_different})</div>
</td>
<td>
<div class="btxlabel">{ts domain='org.project60.banking'}Fee{/ts}:</div>
Expand Down
Loading