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

(-)a/C4/Installer.pm (+1 lines)
Lines 332-337 sub load_sql_in_order { Link Here
332
    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/userpermissions.sql";
332
    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/userpermissions.sql";
333
    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/audio_alerts.sql";
333
    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/audio_alerts.sql";
334
    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/account_offset_types.sql";
334
    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/account_offset_types.sql";
335
    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/account_debit_types.sql";
335
    foreach my $file (@fnames) {
336
    foreach my $file (@fnames) {
336
        #      warn $file;
337
        #      warn $file;
337
        undef $/;
338
        undef $/;
(-)a/Koha/Account.pm (-13 / +6 lines)
Lines 628-655 Charges exempt from non-issue are: Link Here
628
sub non_issues_charges {
628
sub non_issues_charges {
629
    my ($self) = @_;
629
    my ($self) = @_;
630
630
631
    # FIXME REMOVE And add a warning in the about page + update DB if length(MANUAL_INV) > 5
631
    #NOTE: With bug 23049 these preferences could be moved to being attached
632
    my $ACCOUNT_TYPE_LENGTH = 5;    # this is plain ridiculous...
632
    #to individual debit types to give more flexability and specificity.
633
634
    my @not_fines;
633
    my @not_fines;
635
    push @not_fines, 'Res'
634
    push @not_fines, 'Res'
636
      unless C4::Context->preference('HoldsInNoissuesCharge');
635
      unless C4::Context->preference('HoldsInNoissuesCharge');
637
    push @not_fines, 'Rent'
636
    push @not_fines, ( 'RENT', 'RENT_DAILY', 'RENT_RENEW', 'RENT_DAILY_RENEW' )
638
      unless C4::Context->preference('RentalsInNoissuesCharge');
637
      unless C4::Context->preference('RentalsInNoissuesCharge');
639
    unless ( C4::Context->preference('ManInvInNoissuesCharge') ) {
638
    unless ( C4::Context->preference('ManInvInNoissuesCharge') ) {
640
        my $dbh = C4::Context->dbh;
639
        my @man_inv = Koha::Account::DebitTypes->search({ system => 0 })->get_column('code');
641
        push @not_fines,
640
        push @not_fines, @man_inv;
642
          @{
643
            $dbh->selectcol_arrayref(q|
644
                SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'
645
            |)
646
          };
647
    }
641
    }
648
    @not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines);
649
642
650
    return $self->lines->search(
643
    return $self->lines->search(
651
        {
644
        {
652
            accounttype    => { -not_in => \@not_fines }
645
            debit_type => { -not_in => \@not_fines }
653
        },
646
        },
654
    )->total_outstanding;
647
    )->total_outstanding;
655
}
648
}
(-)a/Koha/Account/DebitType.pm (+60 lines)
Line 0 Link Here
1
package Koha::Account::DebitType;
2
3
# Copyright PTFS Europe 2019
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use List::Util qw/any/;
22
23
use Koha::Database;
24
use Koha::Exceptions;
25
26
use base qw(Koha::Object);
27
28
=head1 NAME
29
30
Koha::Account::DebitType - Koha Account debit type Object class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 delete
39
40
Overridden delete method to prevent system default deletions
41
42
=cut
43
44
sub delete {
45
    my ($self) = @_;
46
47
    Koha::Exceptions::CannotDeleteDefault->throw if $self->is_system;
48
49
    return $self->SUPER::delete;
50
}
51
52
=head3 type
53
54
=cut
55
56
sub _type {
57
    return 'AccountDebitType';
58
}
59
60
1;
(-)a/Koha/Account/DebitTypes.pm (+70 lines)
Line 0 Link Here
1
package Koha::Account::DebitTypes;
2
3
# Copyright PTFS Europe 2019
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use List::Util qw/any/;
22
23
use Koha::Database;
24
25
use base qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::Account::DebitTypes - Koha Account debit types Object set class
30
31
=head1 API
32
33
=head2 Class Methods
34
35
=head3 delete
36
37
Overridden delete method to prevent system default deletions
38
39
=cut
40
41
sub delete {
42
    my ($self) = @_;
43
44
    my @set = $self->as_list;
45
    for my $type (@set) {
46
        if ( $type->is_system ) {
47
            Koha::Exceptions::CannotDeleteDefault->throw;
48
        }
49
    }
50
51
    return $self->SUPER::delete;
52
}
53
54
=head3 type
55
56
=cut
57
58
sub _type {
59
    return 'AccountDebitType';
60
}
61
62
=head3 object_class
63
64
=cut
65
66
sub object_class {
67
    return 'Koha::Account::DebitType';
68
}
69
70
1;
(-)a/Koha/Schema/Result/AcDebitTypesBranch.pm (+97 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::AcDebitTypesBranch;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::AcDebitTypesBranch
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<ac_debit_types_branches>
19
20
=cut
21
22
__PACKAGE__->table("ac_debit_types_branches");
23
24
=head1 ACCESSORS
25
26
=head2 debit_type_code
27
28
  data_type: 'varchar'
29
  is_foreign_key: 1
30
  is_nullable: 1
31
  size: 16
32
33
=head2 branchcode
34
35
  data_type: 'varchar'
36
  is_foreign_key: 1
37
  is_nullable: 1
38
  size: 10
39
40
=cut
41
42
__PACKAGE__->add_columns(
43
  "debit_type_code",
44
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 16 },
45
  "branchcode",
46
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
47
);
48
49
=head1 RELATIONS
50
51
=head2 branchcode
52
53
Type: belongs_to
54
55
Related object: L<Koha::Schema::Result::Branch>
56
57
=cut
58
59
__PACKAGE__->belongs_to(
60
  "branchcode",
61
  "Koha::Schema::Result::Branch",
62
  { branchcode => "branchcode" },
63
  {
64
    is_deferrable => 1,
65
    join_type     => "LEFT",
66
    on_delete     => "CASCADE",
67
    on_update     => "RESTRICT",
68
  },
69
);
70
71
=head2 debit_type_code
72
73
Type: belongs_to
74
75
Related object: L<Koha::Schema::Result::AccountDebitType>
76
77
=cut
78
79
__PACKAGE__->belongs_to(
80
  "debit_type_code",
81
  "Koha::Schema::Result::AccountDebitType",
82
  { code => "debit_type_code" },
83
  {
84
    is_deferrable => 1,
85
    join_type     => "LEFT",
86
    on_delete     => "CASCADE",
87
    on_update     => "RESTRICT",
88
  },
89
);
90
91
92
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 10:47:58
93
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a4VtzV3gLrij1s0Czant2Q
94
95
96
# You can replace this text with custom code or comments, and it will be preserved on regeneration
97
1;
(-)a/Koha/Schema/Result/AccountDebitType.pm (+122 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::AccountDebitType;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::AccountDebitType
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<account_debit_types>
19
20
=cut
21
22
__PACKAGE__->table("account_debit_types");
23
24
=head1 ACCESSORS
25
26
=head2 code
27
28
  data_type: 'varchar'
29
  is_nullable: 0
30
  size: 16
31
32
=head2 default_amount
33
34
  data_type: 'decimal'
35
  is_nullable: 1
36
  size: [28,6]
37
38
=head2 description
39
40
  data_type: 'varchar'
41
  is_nullable: 1
42
  size: 200
43
44
=head2 can_be_added_manually
45
46
  data_type: 'tinyint'
47
  default_value: 1
48
  is_nullable: 0
49
50
=cut
51
52
__PACKAGE__->add_columns(
53
  "code",
54
  { data_type => "varchar", is_nullable => 0, size => 16 },
55
  "default_amount",
56
  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
57
  "description",
58
  { data_type => "varchar", is_nullable => 1, size => 200 },
59
  "can_be_added_manually",
60
  { data_type => "tinyint", default_value => 1, is_nullable => 0 },
61
);
62
63
=head1 PRIMARY KEY
64
65
=over 4
66
67
=item * L</code>
68
69
=back
70
71
=cut
72
73
__PACKAGE__->set_primary_key("code");
74
75
=head1 RELATIONS
76
77
=head2 ac_debit_types_branches
78
79
Type: has_many
80
81
Related object: L<Koha::Schema::Result::AcDebitTypesBranch>
82
83
=cut
84
85
__PACKAGE__->has_many(
86
  "ac_debit_types_branches",
87
  "Koha::Schema::Result::AcDebitTypesBranch",
88
  { "foreign.debit_type_code" => "self.code" },
89
  { cascade_copy => 0, cascade_delete => 0 },
90
);
91
92
=head2 accountlines
93
94
Type: has_many
95
96
Related object: L<Koha::Schema::Result::Accountline>
97
98
=cut
99
100
__PACKAGE__->has_many(
101
  "accountlines",
102
  "Koha::Schema::Result::Accountline",
103
  { "foreign.debit_type" => "self.code" },
104
  { cascade_copy => 0, cascade_delete => 0 },
105
);
106
107
108
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 10:47:58
109
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7DG78TAnHRei3U434Vuz9w
110
111
__PACKAGE__->add_columns(
112
    '+is_system' => { is_boolean => 1 }
113
);
114
115
sub koha_objects_class {
116
    'Koha::Account::DebitTypes';
117
}
118
sub koha_object_class {
119
    'Koha::Account::DebitType';
120
}
121
122
1;
(-)a/Koha/Schema/Result/Accountline.pm (-2 / +31 lines)
Lines 69-74 __PACKAGE__->table("accountlines"); Link Here
69
  is_nullable: 1
69
  is_nullable: 1
70
  size: 80
70
  size: 80
71
71
72
=head2 debit_type
73
74
  data_type: 'varchar'
75
  is_foreign_key: 1
76
  is_nullable: 1
77
  size: 16
78
72
=head2 status
79
=head2 status
73
80
74
  data_type: 'varchar'
81
  data_type: 'varchar'
Lines 143-148 __PACKAGE__->add_columns( Link Here
143
  { data_type => "longtext", is_nullable => 1 },
150
  { data_type => "longtext", is_nullable => 1 },
144
  "accounttype",
151
  "accounttype",
145
  { data_type => "varchar", is_nullable => 1, size => 80 },
152
  { data_type => "varchar", is_nullable => 1, size => 80 },
153
  "debit_type",
154
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 16 },
146
  "status",
155
  "status",
147
  { data_type => "varchar", is_nullable => 1, size => 16 },
156
  { data_type => "varchar", is_nullable => 1, size => 16 },
148
  "payment_type",
157
  "payment_type",
Lines 252-257 __PACKAGE__->belongs_to( Link Here
252
  },
261
  },
253
);
262
);
254
263
264
=head2 debit_type
265
266
Type: belongs_to
267
268
Related object: L<Koha::Schema::Result::AccountDebitType>
269
270
=cut
271
272
__PACKAGE__->belongs_to(
273
  "debit_type",
274
  "Koha::Schema::Result::AccountDebitType",
275
  { code => "debit_type" },
276
  {
277
    is_deferrable => 1,
278
    join_type     => "LEFT",
279
    on_delete     => "SET NULL",
280
    on_update     => "CASCADE",
281
  },
282
);
283
255
=head2 itemnumber
284
=head2 itemnumber
256
285
257
Type: belongs_to
286
Type: belongs_to
Lines 313-320 __PACKAGE__->belongs_to( Link Here
313
);
342
);
314
343
315
344
316
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-23 10:45:21
345
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 10:47:58
317
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L+QlTTT+MdGoA3shpyaBgQ
346
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RKg4gDSu0WwJ1C9YmDv3pw
318
347
319
sub koha_objects_class {
348
sub koha_objects_class {
320
    'Koha::Account::Lines';
349
    'Koha::Account::Lines';
(-)a/Koha/Schema/Result/Branch.pm (-2 / +17 lines)
Lines 211-216 __PACKAGE__->set_primary_key("branchcode"); Link Here
211
211
212
=head1 RELATIONS
212
=head1 RELATIONS
213
213
214
=head2 ac_debit_types_branches
215
216
Type: has_many
217
218
Related object: L<Koha::Schema::Result::AcDebitTypesBranch>
219
220
=cut
221
222
__PACKAGE__->has_many(
223
  "ac_debit_types_branches",
224
  "Koha::Schema::Result::AcDebitTypesBranch",
225
  { "foreign.branchcode" => "self.branchcode" },
226
  { cascade_copy => 0, cascade_delete => 0 },
227
);
228
214
=head2 accountlines
229
=head2 accountlines
215
230
216
Type: has_many
231
Type: has_many
Lines 677-684 __PACKAGE__->has_many( Link Here
677
);
692
);
678
693
679
694
680
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-23 10:45:22
695
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-26 15:59:23
681
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KDg4i49bpMxXQ1LP6OZFWQ
696
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IiEBfDpMBAi9cv7OqevVRQ
682
697
683
__PACKAGE__->add_columns(
698
__PACKAGE__->add_columns(
684
    '+pickup_location' => { is_boolean => 1 }
699
    '+pickup_location' => { is_boolean => 1 }
(-)a/installer/data/mysql/account_debit_types.sql (+14 lines)
Line 0 Link Here
1
INSERT INTO account_debit_types ( code, description, can_be_added_manually, default_amount, is_system ) VALUES
2
('ACCOUNT', 'Account creation fee', 0, NULL, 1),
3
('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1),
4
('HE', 'Hold waiting too long', 0, NULL, 1),
5
('LOST', 'Lost item', 1, NULL, 1),
6
('M', 'Manual fee', 1, NULL, 0),
7
('N', 'New card fee', 1, NULL, 1),
8
('OVERDUE', 'Overdue fine', 0, NULL, 1),
9
('PF', 'Lost item processing fee', 0, NULL, 1),
10
('RENT', 'Rental fee', 0, NULL, 1),
11
('RENT_DAILY', 'Daily rental fee', 0, NULL, 1),
12
('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1),
13
('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, NULL, 1),
14
('Res', 'Hold fee', 0, NULL, 1);
(-)a/installer/data/mysql/atomicupdate/bug_23049_debit.perl (+125 lines)
Line 0 Link Here
1
$DBversion = 'XXX';    # will be replaced by the RM
2
if ( CheckVersion($DBversion) ) {
3
4
    $dbh->do(
5
        qq{
6
            CREATE TABLE IF NOT EXISTS account_debit_types (
7
              code varchar(64) NOT NULL,
8
              description varchar(200) NULL,
9
              can_be_added_manually tinyint(4) NOT NULL DEFAULT 1,
10
              default_amount decimal(28, 6) NULL,
11
              is_system tinyint(1) NOT NULL DEFAULT 0,
12
              PRIMARY KEY (code)
13
            ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci
14
          }
15
    );
16
17
    $dbh->do(
18
        qq{
19
            CREATE TABLE IF NOT EXISTS ac_debit_types_branches (
20
                debit_type_code VARCHAR(64),
21
                branchcode VARCHAR(10),
22
                FOREIGN KEY (debit_type_code) REFERENCES account_debit_types(code) ON DELETE CASCADE,
23
                FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
24
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
25
        }
26
    );
27
28
    $dbh->do(
29
        qq{
30
            INSERT IGNORE INTO account_debit_types (
31
              code,
32
              description,
33
              can_be_added_manually,
34
              default_amount,
35
              is_system
36
            )
37
            VALUES
38
              ('ACCOUNT', 'Account creation fee', 0, NULL, 1),
39
              ('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1),
40
              ('HE', 'Hold waiting too long', 0, NULL, 1),
41
              ('LOST', 'Lost item', 1, NULL, 1),
42
              ('M', 'Manual fee', 1, NULL, 0),
43
              ('N', 'New card fee', 1, NULL, 1),
44
              ('OVERDUE', 'Overdue fine', 0, NULL, 1),
45
              ('PF', 'Lost item processing fee', 0, NULL, 1),
46
              ('RENT', 'Rental fee', 0, NULL, 1),
47
              ('RENT_DAILY', 'Daily rental fee', 0, NULL, 1),
48
              ('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1),
49
              ('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, NULL, 1),
50
              ('Res', 'Hold fee', 0, NULL, 1)
51
        }
52
    );
53
54
    $dbh->do(
55
        qq{
56
            INSERT IGNORE INTO account_debit_types (
57
              code,
58
              default_amount,
59
              description,
60
              can_be_added_manually,
61
              is_system
62
            )
63
            SELECT
64
              SUBSTR(authorised_value, 1, 64),
65
              lib,
66
              authorised_value,
67
              1,
68
              0
69
            FROM
70
              authorised_values
71
            WHERE
72
              category = 'MANUAL_INV'
73
          }
74
    );
75
76
    $dbh->do(
77
        qq{
78
            ALTER IGNORE TABLE accountlines
79
            ADD
80
              debit_type varchar(64) DEFAULT NULL
81
            AFTER
82
              accounttype
83
          }
84
    );
85
86
    $dbh->do(
87
        qq{
88
        ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_debit_type` FOREIGN KEY (`debit_type`) REFERENCES `account_debit_types` (`code`) ON DELETE SET NULL ON UPDATE CASCADE
89
          }
90
    );
91
92
    $dbh->do(
93
        qq{
94
        UPDATE accountlines SET debit_type = accounttype, accounttype = NULL WHERE accounttype IN (SELECT code from account_debit_types)
95
        }
96
    );
97
98
    # Clean up MANUAL_INV
99
    $dbh->do(
100
        qq{
101
        DELETE FROM authorised_values WHERE category = 'MANUAL_INV'
102
        }
103
    );
104
    $dbh->do(
105
        qq{
106
        DELETE FROM authorised_value_categories WHERE category_name = 'MANUAL_INV'
107
        }
108
    );
109
110
    # Add new permission
111
    $dbh->do(
112
        q{
113
            INSERT IGNORE INTO permissions (module_bit, code, description)
114
            VALUES
115
              (
116
                3,
117
                'manage_accounts',
118
                'Manage Account Debit and Credit Types'
119
              )
120
        }
121
    );
122
123
    SetVersion($DBversion);
124
    print "Upgrade to $DBversion done (Bug 23049 - Add account debit_types)\n";
125
}
(-)a/installer/data/mysql/en/mandatory/account_debit_types.sql (+14 lines)
Line 0 Link Here
1
INSERT INTO account_debit_types ( code, description, can_be_added_manually, default_amount, is_system ) VALUES
2
('ACCOUNT', 'Account creation fee', 0, NULL, 1),
3
('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1),
4
('HE', 'Hold waiting too long', 0, NULL, 1),
5
('LOST', 'Lost item', 1, NULL, 1),
6
('M', 'Manual fee', 1, NULL, 0),
7
('N', 'New card fee', 1, NULL, 1),
8
('OVERDUE', 'Overdue fine', 0, NULL, 1),
9
('PF', 'Lost item processing fee', 0, NULL, 1),
10
('RENT', 'Rental fee', 0, NULL, 1),
11
('RENT_DAILY', 'Daily rental fee', 0, NULL, 1),
12
('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1),
13
('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, NULL, 1),
14
('Res', 'Hold fee', 0, NULL, 1);
(-)a/installer/data/mysql/en/optional/auth_val.sql (-3 lines)
Lines 48-56 INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('NOT_L Link Here
48
-- restricted status of an item, linked to items.restricted
48
-- restricted status of an item, linked to items.restricted
49
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('RESTRICTED','1','Restricted Access');
49
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('RESTRICTED','1','Restricted Access');
50
50
51
-- manual invoice types
52
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('MANUAL_INV','Copier Fees','.25');
53
54
-- custom borrower notes
51
-- custom borrower notes
55
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_NOTES','ADDR','Address Notes');
52
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_NOTES','ADDR','Address Notes');
56
53
(-)a/installer/data/mysql/kohastructure.sql (-1 / +30 lines)
Lines 2621-2626 CREATE TABLE `cash_registers` ( Link Here
2621
  CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
2621
  CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
2622
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
2622
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
2623
2623
2624
--
2625
-- Table structure for table `account_debit_types`
2626
--
2627
2628
DROP TABLE IF EXISTS `account_debit_types`;
2629
CREATE TABLE `account_debit_types` (
2630
  `code` varchar(64) NOT NULL,
2631
  `description` varchar(200) DEFAULT NULL,
2632
  `can_be_added_manually` tinyint(4) NOT NULL DEFAULT 1,
2633
  `default_amount` decimal(28,6) DEFAULT NULL,
2634
  `is_system` tinyint(1) NOT NULL DEFAULT 0,
2635
  PRIMARY KEY (`code`)
2636
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2637
2638
--
2639
-- Table structure for table `ac_debit_types_branches`
2640
--
2641
2642
DROP TABLE IF EXISTS `ac_debit_types_branches`;
2643
CREATE TABLE `ac_debit_types_branches` (
2644
    `debit_type_code` VARCHAR(64),
2645
    `branchcode` VARCHAR(10),
2646
    FOREIGN KEY (`debit_type_code`) REFERENCES `account_debit_types` (`code`) ON DELETE CASCADE,
2647
    FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
2648
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2649
2624
--
2650
--
2625
-- Table structure for table `accountlines`
2651
-- Table structure for table `accountlines`
2626
--
2652
--
Lines 2635-2640 CREATE TABLE `accountlines` ( Link Here
2635
  `amount` decimal(28,6) default NULL,
2661
  `amount` decimal(28,6) default NULL,
2636
  `description` LONGTEXT,
2662
  `description` LONGTEXT,
2637
  `accounttype` varchar(80) default NULL,
2663
  `accounttype` varchar(80) default NULL,
2664
  `debit_type` varchar(64) default NULL,
2638
  `status` varchar(16) default NULL,
2665
  `status` varchar(16) default NULL,
2639
  `payment_type` varchar(80) default NULL, -- optional authorised value PAYMENT_TYPE
2666
  `payment_type` varchar(80) default NULL, -- optional authorised value PAYMENT_TYPE
2640
  `amountoutstanding` decimal(28,6) default NULL,
2667
  `amountoutstanding` decimal(28,6) default NULL,
Lines 2647-2652 CREATE TABLE `accountlines` ( Link Here
2647
  PRIMARY KEY (`accountlines_id`),
2674
  PRIMARY KEY (`accountlines_id`),
2648
  KEY `acctsborridx` (`borrowernumber`),
2675
  KEY `acctsborridx` (`borrowernumber`),
2649
  KEY `timeidx` (`timestamp`),
2676
  KEY `timeidx` (`timestamp`),
2677
  KEY `debit_type` (`debit_type`),
2650
  KEY `itemnumber` (`itemnumber`),
2678
  KEY `itemnumber` (`itemnumber`),
2651
  KEY `branchcode` (`branchcode`),
2679
  KEY `branchcode` (`branchcode`),
2652
  KEY `manager_id` (`manager_id`),
2680
  KEY `manager_id` (`manager_id`),
Lines 2654-2660 CREATE TABLE `accountlines` ( Link Here
2654
  CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2682
  CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2655
  CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2683
  CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2656
  CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
2684
  CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
2657
  CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
2685
  CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
2686
  CONSTRAINT `accountlines_ibfk_debit_type` FOREIGN KEY (`debit_type`) REFERENCES `account_debit_types` (`code`) ON DELETE SET NULL ON UPDATE CASCADE
2658
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2687
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2659
2688
2660
--
2689
--
(-)a/installer/data/mysql/mandatory/auth_val_cat.sql (-1 lines)
Lines 32-38 INSERT IGNORE INTO authorised_value_categories( category_name ) Link Here
32
    ('NOT_LOAN'),
32
    ('NOT_LOAN'),
33
    ('CCODE'),
33
    ('CCODE'),
34
    ('LOC'),
34
    ('LOC'),
35
    ('MANUAL_INV'),
36
    ('BOR_NOTES'),
35
    ('BOR_NOTES'),
37
    ('OPAC_SUG'),
36
    ('OPAC_SUG'),
38
    ('SIP_MEDIA_TYPE'),
37
    ('SIP_MEDIA_TYPE'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-2 lines)
Lines 384-391 Link Here
384
            <p>Shelving location (usually appears when adding or editing an item). LOC maps to items.location in the Koha database.</p>
384
            <p>Shelving location (usually appears when adding or editing an item). LOC maps to items.location in the Koha database.</p>
385
        [% CASE 'LOST' %]
385
        [% CASE 'LOST' %]
386
            <p>Descriptions for the items marked as lost (appears when adding or editing an item)</p>
386
            <p>Descriptions for the items marked as lost (appears when adding or editing an item)</p>
387
        [% CASE 'MANUAL_INV' %]
388
            <p>Values for manual invoicing types</p>
389
        [% CASE 'NOT_LOAN' %]
387
        [% CASE 'NOT_LOAN' %]
390
            <p>Reasons why a title is not for loan</p>
388
            <p>Reasons why a title is not for loan</p>
391
        [% CASE 'OPAC_SUG' %]
389
        [% CASE 'OPAC_SUG' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +1 lines)
Lines 352-358 Circulation: Link Here
352
              choices:
352
              choices:
353
                  yes: Include
353
                  yes: Include
354
                  no: "Don't include"
354
                  no: "Don't include"
355
            - MANUAL_INV charges when summing up charges for noissuescharge.
355
            - custom debit type charges when summing up charges for noissuescharge.
356
        -
356
        -
357
            - pref: HoldsInNoissuesCharge
357
            - pref: HoldsInNoissuesCharge
358
              choices:
358
              choices:
(-)a/misc/devel/populate_db.pl (+1 lines)
Lines 108-113 my @sample_files_mandatory = ( Link Here
108
    "$data_dir/userflags.sql",
108
    "$data_dir/userflags.sql",
109
    "$data_dir/userpermissions.sql",
109
    "$data_dir/userpermissions.sql",
110
    "$data_dir/account_offset_types.sql",
110
    "$data_dir/account_offset_types.sql",
111
    "$data_dir/account_debit_types.sql",
111
);
112
);
112
my @sample_lang_files_mandatory    = ( glob $root . "/installer/data/mysql/$lang/mandatory/*.sql" );
113
my @sample_lang_files_mandatory    = ( glob $root . "/installer/data/mysql/$lang/mandatory/*.sql" );
113
my @sample_lang_files_optional     = ( glob $root . "/installer/data/mysql/$lang/optional/*.sql" );
114
my @sample_lang_files_optional     = ( glob $root . "/installer/data/mysql/$lang/optional/*.sql" );
(-)a/t/db_dependent/Accounts.t (-9 / +8 lines)
Lines 786-808 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
786
            interface   => 'commandline'
786
            interface   => 'commandline'
787
        }
787
        }
788
    );
788
    );
789
    Koha::Account::DebitTypes->new(
790
        {
791
            code        => 'Copie',
792
            description => 'Fee for copie',
793
            is_system   => 0
794
        }
795
    )->store;
789
    Koha::Account::Line->new(
796
    Koha::Account::Line->new(
790
        {
797
        {
791
            borrowernumber    => $patron->borrowernumber,
798
            borrowernumber    => $patron->borrowernumber,
792
            date              => $today,
799
            date              => $today,
793
            description       => 'a Manual invoice fee',
800
            description       => 'a Manual invoice fee',
794
            accounttype       => 'Copie',
801
            debit_type        => 'Copie',
795
            amountoutstanding => $manual,
802
            amountoutstanding => $manual,
796
            interface         => 'commandline'
803
            interface         => 'commandline'
797
        }
804
        }
798
    )->store;
805
    )->store;
799
    Koha::AuthorisedValue->new(
800
        {
801
            category         => 'MANUAL_INV',
802
            authorised_value => 'Copie',
803
            lib              => 'Fee for copie',
804
        }
805
    )->store;
806
806
807
807
808
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   0 );
808
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   0 );
809
- 

Return to bug 23049