-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
[REF] Add in CiviCRM Status checks to check for inconsistencies betwe… #31538
Open
seamuslee001
wants to merge
1
commit into
civicrm:master
Choose a base branch
from
seamuslee001:status_check_line_item_payment_tables
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
<?php | ||
|
||
require_once 'civi_event.civix.php'; | ||
|
||
/** | ||
* Implements hook_civicrm_check(). | ||
* | ||
* Check for any legacy data where there is a participant_payment record but not a matching line item | ||
* | ||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_check/ | ||
*/ | ||
function civi_event_civicrm_check(&$messages) :void { | ||
$parcitipantPayments = CRM_Core_DAO::executeQuery("SELECT contribution_id, participant_id FROM civicrm_participant_payment"); | ||
$lineItemsMissingPayments = []; | ||
while ($parcitipantPayments->fetch()) { | ||
$lineItemCheck = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_line_item WHERE contribution_id = %1 AND entity_id = %2 AND entity_table = 'civicrm_participant'", [ | ||
1 => [$parcitipantPayments->contribution_id, 'Positive'], | ||
2 => [$parcitipantPayments->participant_id, 'Positive'], | ||
]); | ||
if (empty($lineItemCheck)) { | ||
$lineItemsMissingPayments[] = [ | ||
'contribution_id' => $parcitipantPayments->contribution_id, | ||
'participant_id' => $parcitipantPayments->participant_id, | ||
]; | ||
} | ||
} | ||
if (!empty($lineItemsMissingPayments)) { | ||
$strings = ''; | ||
foreach ($lineItemsMissingPayments as $lineItemsMissingPayment) { | ||
$strings .= '<tr><td>'. $lineItemsMissingPayment['contribution_id'] . '</td><td>' . $lineItemsMissingPayment['participant_id'] . '</td></tr>'; | ||
} | ||
$messages[] = new CRM_Utils_Check_Message( | ||
'civi_event_participant_payments_missing', | ||
ts('The Following Participant Payments do not have a corresponding line item record linking the contribution to participant.') . ts('This should be corrected either by updating the relevant line item record or adding a line item record as appropriate.') . '</p> | ||
<p></p><table><thead><th>Contribution ID</th><th>Participant ID</th></thead><tbody>' . $strings . '</tbody></table></p>', | ||
ts('CiviCRM Participant Payment Records not matching'), | ||
\Psr\Log\LogLevel::WARNING, | ||
'fa-database', | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
<?php | ||
|
||
require_once 'civi_member.civix.php'; | ||
|
||
/** | ||
* Implements hook_civicrm_check(). | ||
* | ||
* Check for any legacy data where there is a membership_payment record but not a matching line item | ||
* | ||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_check/ | ||
*/ | ||
function civi_member_civicrm_check(&$messages) :void { | ||
$membershipPayments = CRM_Core_DAO::executeQuery("SELECT contribution_id, membership_id FROM civicrm_membership_payment"); | ||
$lineItemsMissingPayments = []; | ||
while ($membershipPayments->fetch()) { | ||
$lineItemCheck = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_line_item WHERE contribution_id = %1 AND entity_id = %2 AND entity_table = 'civicrm_membership'", [ | ||
1 => [$membershipPayments->contribution_id, 'Positive'], | ||
2 => [$membershipPayments->membership_id, 'Positive'], | ||
]); | ||
if (empty($lineItemCheck)) { | ||
$lineItemsMissingPayments[] = [ | ||
'contribution_id' => $membershipPayments->contribution_id, | ||
'membership_id' => $membershipPayments->membership_id, | ||
]; | ||
} | ||
} | ||
if (!empty($lineItemsMissingPayments)) { | ||
$strings = ''; | ||
foreach ($lineItemsMissingPayments as $lineItemsMissingPayment) { | ||
$strings .= '<tr><td>'. $lineItemsMissingPayment['contribution_id'] . '</td><td>' . $lineItemsMissingPayment['membership_id'] . '</td></tr>'; | ||
} | ||
$messages[] = new CRM_Utils_Check_Message( | ||
'civi_member_membership_payments_missing', | ||
ts('The Following Membership Payments do not have a corresponding line item record linking the contribution to membership.') . ts('This should be corrected either by updating the relevant line item record or adding a line item record as appropriate.') . '</p> | ||
<p></p><table><thead><th>Contribution ID</th><th>Membership ID</th></thead><tbody>' . $strings . '</tbody></table></p>', | ||
ts('CiviCRM Membership Payment Records not matching'), | ||
\Psr\Log\LogLevel::WARNING, | ||
'fa-database', | ||
); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I wasn't clear what I meant. The paragraph of text should be together (the translator won't know what the word "this" means otherwise, and these sentences aren't going to be re-used elsewhere), and then the table should be separate except the column headers ts'd.
Also there's some mismatched p's.