More versatile mechanism for controlling editability of declarations

Created on 17 July 2025, about 2 months ago

Problem/Motivation

We want to allow for staff to correct data entry errors, but we don't want non-admins to make significant changes to declarations that have been sent confirmations or used to make claims as that could be invalidating.

Proposed resolution

Adopt the locking mechanism explored in 📌 Declaration states Active . This comprises of:

getDataStableTime
- Have Declaration implement EntityChanged Interface and use EntityChangedTrait
- Have a getDataStableTime() that indicates the timepoint at which data entry should be regarded as complete; e.g. perhaps the 'changed' time plus 48 hours
- Consider the data stable time when computing the claimable date

hasClaimed
- Have a 'claimed' boolean field on declarations that tracks whether there is any chance a claim may have been made under the declaration
- Have a hasClaimed() method that returns TRUE if either (A) the declaration is currently claimable and may have donations in scope (i.e. has started), or (B) the 'claimed' field stores true indicating it has been claimable in the past.
- In the declaration's presave hook, store the current value of hasClaimed in the claimed field

isLocked
- Have a Declaration::isLocked() method that returns true if hasClaimed() is true, or the declaration has been retracted by the donor, or if it needed confirmation and confirmation has been sent.
- In a Declaration::getCriticalFields() method, or a DeclarationInterface constant, store an array of critical fields that shouldn't be edited by staff once a confirmation has been sent or claim made: declared_date, date_based, start_date, end_date, donor, charity.
- on the DeclarationForm set #access to FALSE for these critical fields if the declaration is locked

Remaining tasks

This is a significant feature that is valuable for compliance, but it is not critical and other things don't depend on it.

📌 Task
Status

Postponed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom jonathanshaw Stroud, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024