Bugzilla – Attachment 128779 Details for
Bug 29741
Add Koha::Patron->safe_to_delete
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29741: Add Koha::Patron->safe_to_delete
Bug-29741-Add-KohaPatron-safetodelete.patch (text/plain), 1.98 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-12-20 17:22:32 UTC
(
hide
)
Description:
Bug 29741: Add Koha::Patron->safe_to_delete
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-12-20 17:22:32 UTC
Size:
1.98 KB
patch
obsolete
>From 220d7767d4ccbac6a3a2d8c130da13bfe988c56c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 20 Dec 2021 14:17:49 -0300 >Subject: [PATCH] Bug 29741: Add Koha::Patron->safe_to_delete > >This patchset adds a handy method for checking if a patron meets the >conditions to be deleted. This conditions are: > >- Has no linked guarantees >- Has no pending debts >- Has no current checkouts >- Is not the system-configured anonymous user > >To test: >1. Apply the unit tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Patron.t >=> FAIL: Of course heh >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass, conditions are validated and the right string is >returned on each case >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Patron.pm | 45 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 85d9c01bf1..7a70ecc2dd 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1910,6 +1910,51 @@ sub queue_notice { > return \%return; > } > >+=head3 safe_to_delete >+ >+ my $result = $patron->safe_to_delete; >+ if ( $result eq 'has_guarantees' ) { ... } >+ elsif ( $result ) { ... } >+ else { # cannot delete } >+ >+This method tells if the Koha:Patron object can be deleted. Possible return values >+ >+=over 4 >+ >+=item 'ok' >+ >+=item 'has_checkouts' >+ >+=item 'has_debt' >+ >+=item 'has_guarantees' >+ >+=item 'is_anonymous_patron' >+ >+=back >+ >+=cut >+ >+sub safe_to_delete { >+ my ($self) = @_; >+ >+ my $anonymous_patron = C4::Context->preference('AnonymousPatron'); >+ >+ return 'is_anonymous_patron' >+ if $anonymous_patron && $self->id eq $anonymous_patron; >+ >+ return 'has_checkouts' >+ if $self->checkouts->count; >+ >+ return 'has_debt' >+ if $self->account->outstanding_debits->total_outstanding > 0; >+ >+ return 'has_guarantees' >+ if $self->guarantee_relationships->count; >+ >+ return 'ok'; >+} >+ > =head2 Internal methods > > =head3 _type >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29741
:
128778
|
128779
|
128784
|
128814
|
128815
|
128816
|
128994
|
128995
|
128996