Bug 23354: (follow-up) Make display of debit types configurable
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 17 Oct 2019 12:19:34 +0000 (13:19 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 13 Jan 2020 14:05:14 +0000 (14:05 +0000)
This patch adds a the ability to define where a debit type will be
available as a option for use.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Schema/Result/AccountDebitType.pm
admin/debit_types.pl
installer/data/mysql/account_debit_types.sql
installer/data/mysql/atomicupdate/bug_23354.perl
installer/data/mysql/kohastructure.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/debit_types.tt
members/maninvoice.pl
pos/pay.pl

index 146e971..5a858d8 100644 (file)
@@ -35,12 +35,18 @@ __PACKAGE__->table("account_debit_types");
   is_nullable: 1
   size: 200
 
-=head2 can_be_added_manually
+=head2 can_be_invoiced
 
   data_type: 'tinyint'
   default_value: 1
   is_nullable: 0
 
+=head2 can_be_sold
+
+  data_type: 'tinyint'
+  default_value: 0
+  is_nullable: 0
+
 =head2 default_amount
 
   data_type: 'decimal'
@@ -66,8 +72,10 @@ __PACKAGE__->add_columns(
   { data_type => "varchar", is_nullable => 0, size => 80 },
   "description",
   { data_type => "varchar", is_nullable => 1, size => 200 },
-  "can_be_added_manually",
+  "can_be_invoiced",
   { data_type => "tinyint", default_value => 1, is_nullable => 0 },
+  "can_be_sold",
+  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
   "default_amount",
   { data_type => "decimal", is_nullable => 1, size => [28, 6] },
   "is_system",
@@ -121,8 +129,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-23 13:48:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uDKsz1QUF6zY+haOVVQZNw
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-17 12:22:04
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8FIMJZ+JAmqa+Dx7oymBjw
 
 __PACKAGE__->add_columns(
     '+is_system' => { is_boolean => 1 }
index 89decf1..fe09d0b 100755 (executable)
@@ -76,7 +76,8 @@ if ( $op eq 'add_form' ) {
 }
 elsif ( $op eq 'add_validate' ) {
     my $description           = $input->param('description');
-    my $can_be_added_manually = $input->param('can_be_added_manually') || 0;
+    my $can_be_invoiced = $input->param('can_be_invoiced') || 0;
+    my $can_be_sold = $input->param('can_be_sold') || 0;
     my $default_amount        = $input->param('default_amount') || undef;
     my @branches = grep { $_ ne q{} } $input->multi_param('branches');
 
@@ -84,7 +85,8 @@ elsif ( $op eq 'add_validate' ) {
         $debit_type = Koha::Account::DebitType->new( { code => $code } );
     }
     $debit_type->description($description);
-    $debit_type->can_be_added_manually($can_be_added_manually);
+    $debit_type->can_be_invoiced($can_be_invoiced);
+    $debit_type->can_be_sold($can_be_sold);
     $debit_type->default_amount($default_amount);
 
     try {
index a5b93ca..671704b 100644 (file)
@@ -1,15 +1,15 @@
-INSERT INTO account_debit_types ( code, description, can_be_added_manually, default_amount, is_system ) VALUES
-('ACCOUNT', 'Account creation fee', 0, NULL, 1),
-('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1),
-('LOST', 'Lost item', 1, NULL, 1),
-('MANUAL', 'Manual fee', 1, NULL, 0),
-('NEW_CARD', 'New card fee', 1, NULL, 1),
-('OVERDUE', 'Overdue fine', 0, NULL, 1),
-('PROCESSING', 'Lost item processing fee', 0, NULL, 1),
-('PAYOUT', 'Payment from library to patron', 0, NULL, 1),
-('RENT', 'Rental fee', 0, NULL, 1),
-('RENT_DAILY', 'Daily rental fee', 0, NULL, 1),
-('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1),
-('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, NULL, 1),
-('RESERVE', 'Hold fee', 0, NULL, 1),
-('RESERVE_EXPIRED', 'Hold waiting too long', 0, NULL, 1);
+INSERT INTO account_debit_types ( code, description, can_be_invoiced, can_be_sold, default_amount, is_system ) VALUES
+('ACCOUNT', 'Account creation fee', 0, 0, NULL, 1),
+('ACCOUNT_RENEW', 'Account renewal fee', 0, 0, NULL, 1),
+('LOST', 'Lost item', 1, 0, NULL, 1),
+('MANUAL', 'Manual fee', 1, 0, NULL, 0),
+('NEW_CARD', 'New card fee', 1, 0, NULL, 1),
+('OVERDUE', 'Overdue fine', 0, 0, NULL, 1),
+('PROCESSING', 'Lost item processing fee', 0, 0, NULL, 1),
+('PAYOUT', 'Payment from library to patron', 0, 0, NULL, 1),
+('RENT', 'Rental fee', 0, 0, NULL, 1),
+('RENT_DAILY', 'Daily rental fee', 0, 0, NULL, 1),
+('RENT_RENEW', 'Renewal of rental item', 0, 0, NULL, 1),
+('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, 0, NULL, 1),
+('RESERVE', 'Hold fee', 0, 0, NULL, 1),
+('RESERVE_EXPIRED', 'Hold waiting too long', 0, 0, NULL, 1);
index edf3525..9e7d269 100644 (file)
@@ -5,6 +5,28 @@ if( CheckVersion( $DBversion ) ) {
         INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Purchase' );
     });
 
+    # Updating field in account_debit_types
+    unless ( column_exists('account_debit_types', 'can_be_invoiced') ) {
+        $dbh->do(
+            qq{
+                ALTER TABLE account_debit_types
+                CHANGE COLUMN
+                  can_be_added_manually can_be_invoiced tinyint(1) NOT NULL DEFAULT 1
+              }
+        );
+    }
+    unless ( column_exists('account_debit_types', 'can_be_sold') ) {
+        $dbh->do(
+            qq{
+                ALTER IGNORE TABLE account_debit_types
+                ADD
+                  can_be_sold tinyint(1) DEFAULT 0
+                AFTER
+                  can_be_invoiced
+              }
+        );
+    }
+
     $dbh->do(q{
 INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
 ('pos', 'RECEIPT', '', 'Point of sale receipt', 0, 'Receipt', '<table>
index c702d40..56d5d27 100644 (file)
@@ -2654,7 +2654,8 @@ DROP TABLE IF EXISTS `account_debit_types`;
 CREATE TABLE `account_debit_types` (
   `code` varchar(80) NOT NULL,
   `description` varchar(200) DEFAULT NULL,
-  `can_be_added_manually` tinyint(4) NOT NULL DEFAULT 1,
+  `can_be_invoiced` tinyint(1) NOT NULL DEFAULT 1, -- boolean flag to denote if this debit type is available for manual invoicing
+  `can_be_sold` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this debit type is available at point of sale
   `default_amount` decimal(28,6) DEFAULT NULL,
   `is_system` tinyint(1) NOT NULL DEFAULT 0,
   `archived` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this till is archived or not
index 2fdf187..736a181 100644 (file)
                                     <input type="text" name="description" id="description" required="required" class="required" size="80" maxlength="100" value="[% debit_type.description | html %]" /> <span class="required">Required</span>
                                 </li>
                                 <li>
-                                    <label for="can_be_added_manually">Can be added manually? </label>
-                                    [% IF debit_type.can_be_added_manually %]
-                                        <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" checked="checked" value="1" />
+                                    <label for="can_be_invoiced">Can be manually invoiced? </label>
+                                    [% IF debit_type.can_be_invoiced %]
+                                        <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" checked="checked" value="1" />
                                     [% ELSE %]
-                                        <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" value="1" />
+                                        <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" value="1" />
+                                    [% END %]
+                                </li>
+                                <li>
+                                    <label for="can_be_sold">Can be sold? </label>
+                                    [% IF debit_type.can_be_sold %]
+                                        <input type="checkbox" name="can_be_sold" id="can_be_sold" checked="checked" value="1" />
+                                    [% ELSE %]
+                                        <input type="checkbox" name="can_be_sold" id="can_be_sold" value="1" />
                                     [% END %]
                                 </li>
                                 <li>
                                 <th>Code</th>
                                 <th>Description</th>
                                 <th>Default amount</th>
-                                <th>Can be added manually</th>
+                                <th>Available for</th>
                                 <th>Library limitations</th>
                                 <th>Actions</th>
                             </thead>
                                     <td>[% debit_type.code | html %]</td>
                                     <td>[% debit_type.description | html %]</td>
                                     <td>[% debit_type.default_amount | $Price %]</td>
-                                    <td>[% IF debit_type.can_be_added_manually %]Yes[% ELSE %]No[% END %]</td>
+                                    <td>[% IF debit_type.can_be_invoiced && debit_type.can_be_sold %]
+                                        <i class="fa fa-id-card-o"></i> Invoicing, <i class="fa fa-shopping-cart"></i> Sale
+                                        [% ELSIF debit_type.can_be_invoiced %]
+                                        <i class="fa fa-id-card-o"></i> Invoicing
+                                        [% ELSIF debit_type.can_be_sold %]
+                                        <i class="fa fa-shopping-cart"></i> Sale
+                                        [% END %]
+                                    </td>
                                     <td>
                                         [% IF debit_type.library_limits.count > 0 %]
                                             [% library_limits_str = "" %]
index a54206f..f271d1f 100755 (executable)
@@ -126,7 +126,7 @@ else {
     );
 
     my @debit_types = Koha::Account::DebitTypes->search_with_library_limits(
-        { can_be_added_manually => 1, archived => 0 },
+        { can_be_invoiced => 1, archived => 0 },
         {}, $library_id );
     $template->param( debit_types => \@debit_types );
     $template->param(
index 3406f24..3d9956f 100755 (executable)
@@ -56,7 +56,7 @@ else {
 
 my $invoice_types =
   Koha::Account::DebitTypes->search_with_library_limits(
-    { can_be_added_manually => 1 },
+    { can_be_sold => 1 },
     {}, $library_id );
 $template->param( invoice_types => $invoice_types );