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

(-)a/C4/Circulation.pm (-4 / +4 lines)
Lines 3215-3224 sub AddRenewal { Link Here
3215
        # Add renewal record
3215
        # Add renewal record
3216
        my $renewal = Koha::Checkouts::Renewal->new(
3216
        my $renewal = Koha::Checkouts::Renewal->new(
3217
            {
3217
            {
3218
                issue_id   => $issue->issue_id,
3218
                checkout_id => $issue->issue_id,
3219
                renewer_id => C4::Context->userenv->{'number'},
3219
                renewer_id  => C4::Context->userenv->{'number'},
3220
                seen       => $seen,
3220
                seen        => $seen,
3221
                interface  => C4::Context->interface
3221
                interface   => C4::Context->interface
3222
            }
3222
            }
3223
        )->store();
3223
        )->store();
3224
3224
(-)a/Koha/Checkouts/Renewal.pm (-21 / +6 lines)
Lines 21-32 use Modern::Perl; Link Here
21
21
22
use base qw(Koha::Object);
22
use base qw(Koha::Object);
23
23
24
use Koha::Checkout;
25
use Koha::Checkouts;
24
use Koha::Checkouts;
26
use Koha::Exceptions;
27
use Koha::Exceptions::Checkouts::Renewals;
25
use Koha::Exceptions::Checkouts::Renewals;
26
use Koha::Exceptions::Object;
28
use Koha::Old::Checkouts;
27
use Koha::Old::Checkouts;
29
use Koha::Patron;
28
use Koha::Patrons;
30
29
31
=head1 NAME
30
=head1 NAME
32
31
Lines 54-66 sub store { Link Here
54
        Koha::Exceptions::Checkouts::Renewals::NoRenewerID->throw();
53
        Koha::Exceptions::Checkouts::Renewals::NoRenewerID->throw();
55
    }
54
    }
56
55
57
    unless ( ( !$self->issue_id && $self->in_storage )
56
    unless ( ( !$self->checkout_id && $self->in_storage )
58
        || Koha::Checkouts->find( $self->issue_id )
57
        || Koha::Checkouts->find( $self->checkout_id )
59
        || Koha::Old::Checkouts->find( $self->issue_id ) )
58
        || Koha::Old::Checkouts->find( $self->checkout_id ) )
60
    {
59
    {
61
        Koha::Exceptions::Object::FKConstraint->throw(
60
        Koha::Exceptions::Object::FKConstraint->throw(
62
            error     => 'Broken FK constraint',
61
            error     => 'Broken FK constraint',
63
            broken_fk => 'issue_id'
62
            broken_fk => 'checkout_id'
64
        );
63
        );
65
    }
64
    }
66
65
Lines 102-121 sub renewer { Link Here
102
    return Koha::Patron->_new_from_dbic( $renewer ) if $renewer;
101
    return Koha::Patron->_new_from_dbic( $renewer ) if $renewer;
103
}
102
}
104
103
105
=head3 to_api_mapping
106
107
This method returns the mapping for representing a Koha::Checkouts::Renewal object
108
on the API.
109
110
=cut
111
112
sub to_api_mapping {
113
    return {
114
        id       => 'renewal_id',
115
        issue_id => 'checkout_id'
116
    };
117
}
118
119
=head2 Internal methods
104
=head2 Internal methods
120
105
121
=head3 _type
106
=head3 _type
(-)a/Koha/Schema/Result/Borrower.pm (-2 / +2 lines)
Lines 1980-1987 Composing rels: L</user_permissions> -> permission Link Here
1980
__PACKAGE__->many_to_many("permissions", "user_permissions", "permission");
1980
__PACKAGE__->many_to_many("permissions", "user_permissions", "permission");
1981
1981
1982
1982
1983
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-05-06 19:32:13
1983
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-04-27 19:43:17
1984
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lGlRQ4XvRdsrqTye6sDpYg
1984
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:75KmxqXqexvJ93e4awqwbw
1985
1985
1986
__PACKAGE__->has_many(
1986
__PACKAGE__->has_many(
1987
  "extended_attributes",
1987
  "extended_attributes",
(-)a/Koha/Schema/Result/CheckoutRenewal.pm (-11 / +11 lines)
Lines 23-40 __PACKAGE__->table("checkout_renewals"); Link Here
23
23
24
=head1 ACCESSORS
24
=head1 ACCESSORS
25
25
26
=head2 id
26
=head2 renewal_id
27
27
28
  data_type: 'integer'
28
  data_type: 'integer'
29
  is_auto_increment: 1
29
  is_auto_increment: 1
30
  is_nullable: 0
30
  is_nullable: 0
31
31
32
=head2 issue_id
32
=head2 checkout_id
33
33
34
  data_type: 'integer'
34
  data_type: 'integer'
35
  is_nullable: 1
35
  is_nullable: 1
36
36
37
the id of the issue this renewal pertains to
37
the id of the checkout this renewal pertains to
38
38
39
=head2 renewer_id
39
=head2 renewer_id
40
40
Lines 72-80 the date and time the renewal took place Link Here
72
=cut
72
=cut
73
73
74
__PACKAGE__->add_columns(
74
__PACKAGE__->add_columns(
75
  "id",
75
  "renewal_id",
76
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
76
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
77
  "issue_id",
77
  "checkout_id",
78
  { data_type => "integer", is_nullable => 1 },
78
  { data_type => "integer", is_nullable => 1 },
79
  "renewer_id",
79
  "renewer_id",
80
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
80
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
Lines 95-107 __PACKAGE__->add_columns( Link Here
95
95
96
=over 4
96
=over 4
97
97
98
=item * L</id>
98
=item * L</renewal_id>
99
99
100
=back
100
=back
101
101
102
=cut
102
=cut
103
103
104
__PACKAGE__->set_primary_key("id");
104
__PACKAGE__->set_primary_key("renewal_id");
105
105
106
=head1 RELATIONS
106
=head1 RELATIONS
107
107
Lines 126-133 __PACKAGE__->belongs_to( Link Here
126
);
126
);
127
127
128
128
129
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-03-11 16:33:50
129
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-04-27 19:43:17
130
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:agLgLnVeKYB5wdWS06xD0A
130
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7mjiEx634L5FZyjroACUkg
131
131
132
=head2 checkout
132
=head2 checkout
133
133
Lines 140-146 Related object: L<Koha::Schema::Result::Issue> Link Here
140
__PACKAGE__->belongs_to(
140
__PACKAGE__->belongs_to(
141
    "checkout",
141
    "checkout",
142
    "Koha::Schema::Result::Issue",
142
    "Koha::Schema::Result::Issue",
143
    { issue_id => "issue_id" },
143
    { issue_id => "checkout_id" },
144
    {
144
    {
145
        is_deferrable => 1,
145
        is_deferrable => 1,
146
        join_type     => "LEFT",
146
        join_type     => "LEFT",
Lines 158-164 Related object: L<Koha::Schema::Result::OldIssue> Link Here
158
__PACKAGE__->belongs_to(
158
__PACKAGE__->belongs_to(
159
    "old_checkout",
159
    "old_checkout",
160
    "Koha::Schema::Result::OldIssue",
160
    "Koha::Schema::Result::OldIssue",
161
    { issue_id => "issue_id" },
161
    { issue_id => "checkout_id" },
162
    {
162
    {
163
        is_deferrable => 1,
163
        is_deferrable => 1,
164
        join_type     => "LEFT",
164
        join_type     => "LEFT",
(-)a/Koha/Schema/Result/Issue.pm (-1 / +1 lines)
Lines 384-390 Related object: L<Koha::Schema::Result::CheckoutRenewal> Link Here
384
__PACKAGE__->has_many(
384
__PACKAGE__->has_many(
385
    "renewals",
385
    "renewals",
386
    "Koha::Schema::Result::CheckoutRenewal",
386
    "Koha::Schema::Result::CheckoutRenewal",
387
    { "foreign.issue_id" => "self.issue_id" },
387
    { "foreign.checkout_id" => "self.issue_id" },
388
    { cascade_copy       => 0, cascade_delete => 0 },
388
    { cascade_copy       => 0, cascade_delete => 0 },
389
);
389
);
390
390
(-)a/Koha/Schema/Result/OldIssue.pm (-1 / +1 lines)
Lines 354-360 Related object: L<Koha::Schema::Result::CheckoutRenewal> Link Here
354
__PACKAGE__->has_many(
354
__PACKAGE__->has_many(
355
    "renewals",
355
    "renewals",
356
    "Koha::Schema::Result::CheckoutRenewal",
356
    "Koha::Schema::Result::CheckoutRenewal",
357
    { "foreign.issue_id" => "self.issue_id" },
357
    { "foreign.checkout_id" => "self.issue_id" },
358
    { cascade_copy       => 0, cascade_delete => 0 },
358
    { cascade_copy       => 0, cascade_delete => 0 },
359
);
359
);
360
360
(-)a/installer/data/mysql/atomicupdate/bug_30275.pl (-3 / +3 lines)
Lines 9-21 return { Link Here
9
        unless ( TableExists('checkout_renewals') ) {
9
        unless ( TableExists('checkout_renewals') ) {
10
            $dbh->do(q{
10
            $dbh->do(q{
11
                CREATE TABLE `checkout_renewals` (
11
                CREATE TABLE `checkout_renewals` (
12
                  `id` int(11) NOT NULL auto_increment,
12
                  `renewal_id` int(11) NOT NULL auto_increment,
13
                  `issue_id` int(11) DEFAULT NULL COMMENT 'the id of the issue this renewal pertains to',
13
                  `checkout_id` int(11) DEFAULT NULL COMMENT 'the id of the checkout this renewal pertains to',
14
                  `renewer_id` int(11) DEFAULT NULL COMMENT 'the id of the user who processed the renewal',
14
                  `renewer_id` int(11) DEFAULT NULL COMMENT 'the id of the user who processed the renewal',
15
                  `seen` tinyint(1) DEFAULT 0 COMMENT 'boolean denoting whether the item was present or not',
15
                  `seen` tinyint(1) DEFAULT 0 COMMENT 'boolean denoting whether the item was present or not',
16
                  `interface` varchar(16) NOT NULL COMMENT 'the interface this renewal took place on',
16
                  `interface` varchar(16) NOT NULL COMMENT 'the interface this renewal took place on',
17
                  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the renewal took place',
17
                  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the renewal took place',
18
                  PRIMARY KEY(`id`),
18
                  PRIMARY KEY(`renewal_id`),
19
                  KEY `renewer_id` (`renewer_id`),
19
                  KEY `renewer_id` (`renewer_id`),
20
                  CONSTRAINT `renewals_renewer_id` FOREIGN KEY (`renewer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
20
                  CONSTRAINT `renewals_renewer_id` FOREIGN KEY (`renewer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
21
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
21
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/installer/data/mysql/kohastructure.sql (-4 / +3 lines)
Lines 1698-1710 DROP TABLE IF EXISTS `checkout_renewals`; Link Here
1698
/*!40101 SET @saved_cs_client     = @@character_set_client */;
1698
/*!40101 SET @saved_cs_client     = @@character_set_client */;
1699
/*!40101 SET character_set_client = utf8 */;
1699
/*!40101 SET character_set_client = utf8 */;
1700
CREATE TABLE `checkout_renewals` (
1700
CREATE TABLE `checkout_renewals` (
1701
  `id` int(11) NOT NULL AUTO_INCREMENT,
1701
  `renewal_id` int(11) NOT NULL AUTO_INCREMENT,
1702
  `issue_id` int(11) DEFAULT NULL COMMENT 'the id of the issue this renewal pertains to',
1702
  `checkout_id` int(11) DEFAULT NULL COMMENT 'the id of the checkout this renewal pertains to',
1703
  `renewer_id` int(11) DEFAULT NULL COMMENT 'the id of the user who processed the renewal',
1703
  `renewer_id` int(11) DEFAULT NULL COMMENT 'the id of the user who processed the renewal',
1704
  `seen` tinyint(1) DEFAULT 0 COMMENT 'boolean denoting whether the item was present or not',
1704
  `seen` tinyint(1) DEFAULT 0 COMMENT 'boolean denoting whether the item was present or not',
1705
  `interface` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the interface this renewal took place on',
1705
  `interface` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the interface this renewal took place on',
1706
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the renewal took place',
1706
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the renewal took place',
1707
  PRIMARY KEY (`id`),
1707
  PRIMARY KEY (`renewal_id`),
1708
  KEY `renewer_id` (`renewer_id`),
1708
  KEY `renewer_id` (`renewer_id`),
1709
  CONSTRAINT `renewals_renewer_id` FOREIGN KEY (`renewer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
1709
  CONSTRAINT `renewals_renewer_id` FOREIGN KEY (`renewer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
1710
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1710
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1711
- 

Return to bug 30275