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

(-)a/Koha/Schema/Result/Accountline.pm (+28 lines)
Lines 105-110 __PACKAGE__->table("accountlines"); Link Here
105
  is_foreign_key: 1
105
  is_foreign_key: 1
106
  is_nullable: 1
106
  is_nullable: 1
107
107
108
=head2 register_id
109
110
  data_type: 'integer'
111
  is_foreign_key: 1
112
  is_nullable: 1
113
108
=head2 interface
114
=head2 interface
109
115
110
  data_type: 'varchar'
116
  data_type: 'varchar'
Lines 154-159 __PACKAGE__->add_columns( Link Here
154
  { data_type => "mediumtext", is_nullable => 1 },
160
  { data_type => "mediumtext", is_nullable => 1 },
155
  "manager_id",
161
  "manager_id",
156
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
162
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
163
  "register_id",
164
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
157
  "interface",
165
  "interface",
158
  { data_type => "varchar", is_nullable => 0, size => 16 },
166
  { data_type => "varchar", is_nullable => 0, size => 16 },
159
  "branchcode",
167
  "branchcode",
Lines 284-289 __PACKAGE__->belongs_to( Link Here
284
  },
292
  },
285
);
293
);
286
294
295
=head2 register
296
297
Type: belongs_to
298
299
Related object: L<Koha::Schema::Result::CashRegister>
300
301
=cut
302
303
__PACKAGE__->belongs_to(
304
  "register",
305
  "Koha::Schema::Result::CashRegister",
306
  { id => "register_id" },
307
  {
308
    is_deferrable => 1,
309
    join_type     => "LEFT",
310
    on_delete     => "SET NULL",
311
    on_update     => "CASCADE",
312
  },
313
);
314
287
315
288
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-06 12:23:55
316
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-06 12:23:55
289
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/8Qeh530PbLC6ryxC1Dw9w
317
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/8Qeh530PbLC6ryxC1Dw9w
(-)a/Koha/Schema/Result/Branch.pm (-2 / +17 lines)
Lines 346-351 __PACKAGE__->has_many( Link Here
346
  { cascade_copy => 0, cascade_delete => 0 },
346
  { cascade_copy => 0, cascade_delete => 0 },
347
);
347
);
348
348
349
=head2 cash_registers
350
351
Type: has_many
352
353
Related object: L<Koha::Schema::Result::CashRegister>
354
355
=cut
356
357
__PACKAGE__->has_many(
358
  "cash_registers",
359
  "Koha::Schema::Result::CashRegister",
360
  { "foreign.branch" => "self.branchcode" },
361
  { cascade_copy => 0, cascade_delete => 0 },
362
);
363
349
=head2 categories_branches
364
=head2 categories_branches
350
365
351
Type: has_many
366
Type: has_many
Lines 662-669 __PACKAGE__->has_many( Link Here
662
);
677
);
663
678
664
679
665
# Created by DBIx::Class::Schema::Loader v0.07048 @ 2019-07-04 04:56:47
680
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-07-17 07:15:23
666
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:15/s0/8d2cNB9YLLlsEY4w
681
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qGiu+y4MHq5CvBQTj0m8QQ
667
682
668
__PACKAGE__->add_columns(
683
__PACKAGE__->add_columns(
669
    '+pickup_location' => { is_boolean => 1 }
684
    '+pickup_location' => { is_boolean => 1 }
(-)a/Koha/Schema/Result/CashRegister.pm (+153 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::CashRegister;
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::CashRegister
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<cash_registers>
19
20
=cut
21
22
__PACKAGE__->table("cash_registers");
23
24
=head1 ACCESSORS
25
26
=head2 id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 name
33
34
  data_type: 'varchar'
35
  is_nullable: 0
36
  size: 24
37
38
=head2 description
39
40
  data_type: 'longtext'
41
  is_nullable: 0
42
43
=head2 branch
44
45
  data_type: 'varchar'
46
  is_foreign_key: 1
47
  is_nullable: 0
48
  size: 10
49
50
=head2 branch_default
51
52
  data_type: 'tinyint'
53
  default_value: 0
54
  is_nullable: 0
55
56
=head2 starting_float
57
58
  data_type: 'decimal'
59
  is_nullable: 1
60
  size: [28,6]
61
62
=head2 archived
63
64
  data_type: 'tinyint'
65
  default_value: 0
66
  is_nullable: 0
67
68
=cut
69
70
__PACKAGE__->add_columns(
71
  "id",
72
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
73
  "name",
74
  { data_type => "varchar", is_nullable => 0, size => 24 },
75
  "description",
76
  { data_type => "longtext", is_nullable => 0 },
77
  "branch",
78
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 10 },
79
  "branch_default",
80
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
81
  "starting_float",
82
  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
83
  "archived",
84
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
85
);
86
87
=head1 PRIMARY KEY
88
89
=over 4
90
91
=item * L</id>
92
93
=back
94
95
=cut
96
97
__PACKAGE__->set_primary_key("id");
98
99
=head1 UNIQUE CONSTRAINTS
100
101
=head2 C<name>
102
103
=over 4
104
105
=item * L</name>
106
107
=item * L</branch>
108
109
=back
110
111
=cut
112
113
__PACKAGE__->add_unique_constraint("name", ["name", "branch"]);
114
115
=head1 RELATIONS
116
117
=head2 accountlines
118
119
Type: has_many
120
121
Related object: L<Koha::Schema::Result::Accountline>
122
123
=cut
124
125
__PACKAGE__->has_many(
126
  "accountlines",
127
  "Koha::Schema::Result::Accountline",
128
  { "foreign.register_id" => "self.id" },
129
  { cascade_copy => 0, cascade_delete => 0 },
130
);
131
132
=head2 branch
133
134
Type: belongs_to
135
136
Related object: L<Koha::Schema::Result::Branch>
137
138
=cut
139
140
__PACKAGE__->belongs_to(
141
  "branch",
142
  "Koha::Schema::Result::Branch",
143
  { branchcode => "branch" },
144
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
145
);
146
147
148
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-07-23 13:14:31
149
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TfGf0U/vWS7IviRlvDdE1w
150
151
152
# You can replace this text with custom code or comments, and it will be preserved on regeneration
153
1;
(-)a/installer/data/mysql/atomicupdate/bug_23321.perl (+30 lines)
Line 0 Link Here
1
$DBversion = 'XXX';    # will be replaced by the RM
2
if ( CheckVersion($DBversion) ) {
3
4
    $dbh->do(qq{
5
CREATE TABLE `cash_registers` (
6
  `id` int(11) NOT NULL auto_increment, -- unique identifier for each account register
7
  `name` varchar(24) NOT NULL, -- the user friendly identifier for each account register
8
  `description` longtext NOT NULL, -- the user friendly description for each account register
9
  `branch` varchar(10) NOT NULL, -- the foreign key the library this account register belongs
10
  `branch_default` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote that this till is the branch default
11
  `starting_float` decimal(28, 6), -- the starting float this account register should be assigned
12
  `archived` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this till is archived or not
13
  PRIMARY KEY (`id`),
14
  UNIQUE KEY `name` (`name`,`branch`),
15
  CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
16
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
17
    });
18
19
    unless ( column_exists( 'accountlines', 'register_id' ) ) {
20
        $dbh->do(qq{ALTER TABLE `accountlines` ADD `register_id` int(11) NULL DEFAULT NULL AFTER `manager_id`});
21
        $dbh->do(qq{
22
            ALTER TABLE `accountlines`
23
            ADD CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`)
24
            REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
25
        });
26
    }
27
28
    SetVersion($DBversion);
29
    print "Upgrade to $DBversion done (Bug 23321 - Add cash_registers table)\n";
30
}
(-)a/installer/data/mysql/kohastructure.sql (-2 / +21 lines)
Lines 2600-2605 CREATE TABLE `messages` ( -- circulation messages left via the patron's check ou Link Here
2600
  CONSTRAINT `messages_borrowernumber` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2600
  CONSTRAINT `messages_borrowernumber` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2601
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2601
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2602
2602
2603
--
2604
-- Table structure for table `cash_registers`
2605
--
2606
2607
DROP TABLE IF EXISTS `cash_registers`;
2608
CREATE TABLE `cash_registers` (
2609
  `id` int(11) NOT NULL auto_increment, -- unique identifier for each account register
2610
  `name` varchar(24) NOT NULL, -- the user friendly identifier for each account register
2611
  `description` longtext NOT NULL, -- the user friendly description for each account register
2612
  `branch` varchar(10) NOT NULL, -- the foreign key the library this account register belongs
2613
  `branch_default` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote that this till is the branch default
2614
  `starting_float` decimal(28, 6), -- the starting float this account register should be assigned
2615
  `archived` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this till is archived or not
2616
  PRIMARY KEY (`id`),
2617
  UNIQUE KEY `name` (`name`,`branch`),
2618
  CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
2619
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
2620
2603
--
2621
--
2604
-- Table structure for table `accountlines`
2622
-- Table structure for table `accountlines`
2605
--
2623
--
Lines 2620-2625 CREATE TABLE `accountlines` ( Link Here
2620
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2638
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2621
  `note` MEDIUMTEXT NULL default NULL,
2639
  `note` MEDIUMTEXT NULL default NULL,
2622
  `manager_id` int(11) NULL DEFAULT NULL,
2640
  `manager_id` int(11) NULL DEFAULT NULL,
2641
  `register_id` int(11) NULL DEFAULT NULL,
2623
  `interface` VARCHAR(16) NOT NULL,
2642
  `interface` VARCHAR(16) NOT NULL,
2624
  `branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
2643
  `branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
2625
  PRIMARY KEY (`accountlines_id`),
2644
  PRIMARY KEY (`accountlines_id`),
Lines 2631-2637 CREATE TABLE `accountlines` ( Link Here
2631
  CONSTRAINT `accountlines_ibfk_borrowers` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2650
  CONSTRAINT `accountlines_ibfk_borrowers` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2632
  CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2651
  CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2633
  CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2652
  CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2634
  CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE
2653
  CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
2654
  CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
2635
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2655
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2636
2656
2637
--
2657
--
2638
- 

Return to bug 23321