2

In the Netherlands, the taxpayer can deduct gifts to charities from his income tax. The tax authorities take samples and can ask a charity to report the gifts it received from a particular contact. The length of the period they can ask this is seven years. So the records of this contact must be kept in these years. Is there an elegant way to prevent deleting, or trashing a contact that gave a contribution in the last seven years?

4 Answers 4

2

I assume writing a little extension that picks up the delete with the civicrm_pre hook is a fairy elegant way?

2

Another way to approach this, if you're trying to avoid coding, would be to take away the "delete contacts" permission at the CMS permissions level. This would take away the ability to delete contacts unless that permission is explicitly granted by an ACL rule.

The ACL system lets you get very specific about which contacts may delete other contacts. You could create a static group "Senior Staff" which has permission to delete contacts in a smart group called "Deletables." The task of defining the criteria for inclusion in this smart group is left to the reader.

1

Elaborating on the answer of Erik, I created an extension with the following hook

function preventcontactdelete_civicrm_pre($op, $objectName, $id, &$params) {
  if ($objectName == 'Individual' && $op == 'update') {
    if ($params['is_deleted'] && CRM_Preventcontactdelete_Check::hasRecentContribution($id)) {
      throw new Exception("Delete of contact $id not allowed - it has recent contributions");
    }
  }
}
1

If I am not mistaken, CiviCRM will (at least via the UI) does not allow contacts with live finacial transactions (so everyone with a completed donation) to be permanently deleted, unless you delete the contributions first.

This way, accidental deletion would not be possible and you can always not grant users the permission to delet contributions...

2
  • This really seems like the best answer ;-)
    – petednz - fuzion
    Commented Jun 21, 2017 at 20:41
  • It is true you cannot delete a contact with financial transactions. However, it is possible tot put it in trash Commented Jun 22, 2017 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.