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

(-)a/Koha/REST/V1/Holds.pm (+4 lines)
Lines 274-279 sub edit { Link Here
274
274
275
        $pickup_library_id //= $hold->branchcode;
275
        $pickup_library_id //= $hold->branchcode;
276
        my $priority         = $body->{priority} // $hold->priority;
276
        my $priority         = $body->{priority} // $hold->priority;
277
        my $hold_date        = $body->{hold_date} // $hold->reservedate;
278
        my $expiration_date  = $body->{expiration_date} // $hold->expirationdate;
277
        # suspended_until can also be set to undef
279
        # suspended_until can also be set to undef
278
        my $suspended_until = $body->{suspended_until} || $hold->suspend_until;
280
        my $suspended_until = $body->{suspended_until} || $hold->suspend_until;
279
281
Lines 283-288 sub edit { Link Here
283
            rank          => $priority,
285
            rank          => $priority,
284
            suspend_until => $suspended_until,
286
            suspend_until => $suspended_until,
285
            itemnumber    => $hold->itemnumber,
287
            itemnumber    => $hold->itemnumber,
288
            reservedate => $hold_date,
289
            expirationdate  => $expiration_date,
286
        };
290
        };
287
291
288
        C4::Reserves::ModReserve($params);
292
        C4::Reserves::ModReserve($params);
(-)a/api/v1/swagger/paths/holds.yaml (+8 lines)
Lines 255-260 Link Here
255
              description: Date until which the hold has been suspended
255
              description: Date until which the hold has been suspended
256
              type: string
256
              type: string
257
              format: date-time
257
              format: date-time
258
            hold_date:
259
              description: Hold date
260
              type: string
261
              format: date
262
            expiration_date:
263
              description: Hold's expiration date
264
              type: string
265
              format: date
258
          additionalProperties: false
266
          additionalProperties: false
259
    consumes:
267
    consumes:
260
      - application/json
268
      - application/json
(-)a/t/db_dependent/api/v1/holds.t (-2 / +33 lines)
Lines 917-923 subtest 'pickup_locations() tests' => sub { Link Here
917
917
918
subtest 'edit() tests' => sub {
918
subtest 'edit() tests' => sub {
919
919
920
    plan tests => 39;
920
    plan tests => 47;
921
921
922
    $schema->storage->txn_begin;
922
    $schema->storage->txn_begin;
923
923
Lines 972-977 subtest 'edit() tests' => sub { Link Here
972
                branchcode   => $library_3->branchcode,
972
                branchcode   => $library_3->branchcode,
973
                itemnumber   => undef,
973
                itemnumber   => undef,
974
                priority     => 1,
974
                priority     => 1,
975
                reservedate   => '2022-01-01',
976
                expirationdate => '2022-03-01'
975
            }
977
            }
976
        }
978
        }
977
    );
979
    );
Lines 1026-1031 subtest 'edit() tests' => sub { Link Here
1026
    $biblio_hold->discard_changes;
1028
    $biblio_hold->discard_changes;
1027
    is( $biblio_hold->branchcode, $library_2->id, 'Pickup location changed correctly' );
1029
    is( $biblio_hold->branchcode, $library_2->id, 'Pickup location changed correctly' );
1028
1030
1031
    $biblio_hold_data = {
1032
        hold_date   => '2022-01-02',
1033
        expiration_date => '2022-03-02'
1034
    };
1035
1036
    $t->patch_ok( "//$userid:$password@/api/v1/holds/"
1037
          . $biblio_hold->id
1038
          => json => $biblio_hold_data )
1039
      ->status_is(200);
1040
    
1041
    $biblio_hold->discard_changes;
1042
    is( $biblio_hold->reservedate, '2022-01-02', 'Hold date changed correctly' );
1043
    is( $biblio_hold->expirationdate, '2022-03-02', 'Expiration date changed correctly' );
1044
1029
    # Test item-level holds
1045
    # Test item-level holds
1030
    my $item_hold = $builder->build_object(
1046
    my $item_hold = $builder->build_object(
1031
        {
1047
        {
Lines 1037-1042 subtest 'edit() tests' => sub { Link Here
1037
                priority     => 1,
1053
                priority     => 1,
1038
                suspend       => 0,
1054
                suspend       => 0,
1039
                suspend_until => undef,
1055
                suspend_until => undef,
1056
                reservedate   => '2022-01-01',
1057
                expirationdate => '2022-03-01'
1040
            }
1058
            }
1041
        }
1059
        }
1042
    );
1060
    );
Lines 1091-1096 subtest 'edit() tests' => sub { Link Here
1091
    is( $item_hold->suspend, 0, 'Location change should not activate suspended status' );
1109
    is( $item_hold->suspend, 0, 'Location change should not activate suspended status' );
1092
    is( $item_hold->suspend_until, undef, 'Location change should keep suspended_until be undef' );
1110
    is( $item_hold->suspend_until, undef, 'Location change should keep suspended_until be undef' );
1093
1111
1112
    $item_hold_data = {
1113
        hold_date   => '2022-01-02',
1114
        expiration_date => '2022-03-02'
1115
    };
1116
1117
    $t->patch_ok( "//$userid:$password@/api/v1/holds/"
1118
          . $item_hold->id
1119
          => json => $item_hold_data )
1120
      ->status_is(200);
1121
    
1122
    $item_hold->discard_changes;
1123
    is( $item_hold->reservedate, '2022-01-02', 'Hold date changed correctly' );
1124
    is( $item_hold->expirationdate, '2022-03-02', 'Expiration date changed correctly' );
1125
1094
    $schema->storage->txn_rollback;
1126
    $schema->storage->txn_rollback;
1095
1127
1096
};
1128
};
1097
- 

Return to bug 30661