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

(-)a/Koha/REST/V1/Acquisitions/Vendors.pm (-1 / +10 lines)
Lines 171-177 sub delete { Link Here
171
    my $c = shift->openapi->valid_input or return;
171
    my $c = shift->openapi->valid_input or return;
172
172
173
    return try {
173
    return try {
174
        my $vendor = Koha::Acquisition::Booksellers->find( $c->param('vendor_id') );
174
        my $vendor             = Koha::Acquisition::Booksellers->find( $c->param('vendor_id') );
175
        my $basket_count       = $vendor->baskets->count;
176
        my $subscription_count = $vendor->subscriptions->count;
177
        my $invoice_count      = $vendor->invoices->count;
178
179
        my $safe_to_delete = ( $basket_count == 0 && $subscription_count == 0 && $invoice_count == 0 ) ? 1 : 0;
180
        return $c->render(
181
            status  => 409,
182
            openapi => { error => "Vendor cannot be deleted with existing baskets, subscriptions or invoices" }
183
        ) unless $safe_to_delete;
175
184
176
        return $c->render_resource_not_found("Vendor")
185
        return $c->render_resource_not_found("Vendor")
177
            unless $vendor;
186
            unless $vendor;
(-)a/api/v1/swagger/paths/acquisitions_vendors.yaml (-1 / +4 lines)
Lines 272-277 Link Here
272
        description: Vendor not found
272
        description: Vendor not found
273
        schema:
273
        schema:
274
          $ref: "../swagger.yaml#/definitions/error"
274
          $ref: "../swagger.yaml#/definitions/error"
275
      "409":
276
        description: Unable to perform action on vendor
277
        schema:
278
          $ref: "../swagger.yaml#/definitions/error"
275
      "500":
279
      "500":
276
        description: |
280
        description: |
277
          Internal server error. Possible `error_code` attribute values:
281
          Internal server error. Possible `error_code` attribute values:
278
- 

Return to bug 38010