View | Details | Raw Unified | Return to bug 29018
Collapse All | Expand All

(-)a/Koha/REST/V1/Patrons.pm (-4 / +33 lines)
Lines 331-340 sub delete { Link Here
331
331
332
    return try {
332
    return try {
333
333
334
        $patron->delete;
334
        if ( $patron->checkouts->count > 0 ) {
335
        return $c->render(
335
            return $c->render(
336
            status  => 204,
336
                status  => 409,
337
            openapi => q{}
337
                openapi => { error => 'Pending checkouts prevent deletion' }
338
            );
339
        }
340
341
        my $account = $patron->account;
342
343
        if ( $account->outstanding_debits->total_outstanding > 0 ) {
344
            return $c->render(
345
                status  => 409,
346
                openapi => { error => 'Pending debts prevent deletion' }
347
            );
348
        }
349
350
        if ( $patron->guarantee_relationships->count > 0 ) {
351
            return $c->render(
352
                status  => 409,
353
                openapi => { error => 'Patron is a guarantor and it prevents deletion' }
354
            );
355
        }
356
357
        $patron->_result->result_source->schema->txn_do(
358
            sub {
359
                $patron->move_to_deleted;
360
                $patron->delete;
361
362
                return $c->render(
363
                    status  => 204,
364
                    openapi => q{}
365
                );
366
            }
338
        );
367
        );
339
    } catch {
368
    } catch {
340
        if ( blessed $_ && $_->isa('Koha::Exceptions::Patron::FailedDeleteAnonymousPatron') ) {
369
        if ( blessed $_ && $_->isa('Koha::Exceptions::Patron::FailedDeleteAnonymousPatron') ) {
(-)a/api/v1/swagger/paths/patrons.json (-1 / +12 lines)
Lines 700-705 Link Here
700
          "schema": {
700
          "schema": {
701
            "$ref": "../definitions.json#/error"
701
            "$ref": "../definitions.json#/error"
702
          }
702
          }
703
        },
704
        "409": {
705
          "description": "Conflict in updating resource",
706
          "schema": {
707
            "$ref": "../definitions.json#/error"
708
          }
709
        },
710
        "500": {
711
          "description": "Internal server error",
712
          "schema": {
713
            "$ref": "../definitions.json#/error"
714
          }
703
        }
715
        }
704
      },
716
      },
705
      "x-koha-authorization": {
717
      "x-koha-authorization": {
706
- 

Return to bug 29018