From 454d4745b72aaf339a86cc1cd4c12ec8e00c82e5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 17 Oct 2019 13:19:34 +0100 Subject: [PATCH] Bug 23354: (follow-up) Make display of debit types configurable 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 Signed-off-by: Josef Moravec Signed-off-by: Martin Renvoize --- Koha/Schema/Result/AccountDebitType.pm | 16 +++++++--- admin/debit_types.pl | 6 ++-- installer/data/mysql/account_debit_types.sql | 30 +++++++++---------- .../data/mysql/atomicupdate/bug_23354.perl | 22 ++++++++++++++ installer/data/mysql/kohastructure.sql | 3 +- .../prog/en/modules/admin/debit_types.tt | 27 +++++++++++++---- members/maninvoice.pl | 2 +- pos/pay.pl | 2 +- 8 files changed, 78 insertions(+), 30 deletions(-) diff --git a/Koha/Schema/Result/AccountDebitType.pm b/Koha/Schema/Result/AccountDebitType.pm index 146e97199b..5a858d8256 100644 --- a/Koha/Schema/Result/AccountDebitType.pm +++ b/Koha/Schema/Result/AccountDebitType.pm @@ -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 } diff --git a/admin/debit_types.pl b/admin/debit_types.pl index 89decf1160..fe09d0b839 100755 --- a/admin/debit_types.pl +++ b/admin/debit_types.pl @@ -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 { diff --git a/installer/data/mysql/account_debit_types.sql b/installer/data/mysql/account_debit_types.sql index a5b93cac7a..671704be53 100644 --- a/installer/data/mysql/account_debit_types.sql +++ b/installer/data/mysql/account_debit_types.sql @@ -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); diff --git a/installer/data/mysql/atomicupdate/bug_23354.perl b/installer/data/mysql/atomicupdate/bug_23354.perl index edf3525626..9e7d269303 100644 --- a/installer/data/mysql/atomicupdate/bug_23354.perl +++ b/installer/data/mysql/atomicupdate/bug_23354.perl @@ -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', ' diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index c702d405a0..56d5d27d5a 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -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 diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/debit_types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/debit_types.tt index 2fdf187ff2..736a1815be 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/debit_types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/debit_types.tt @@ -83,11 +83,19 @@ Required
  • - - [% IF debit_type.can_be_added_manually %] - + + [% IF debit_type.can_be_invoiced %] + [% ELSE %] - + + [% END %] +
  • +
  • + + [% IF debit_type.can_be_sold %] + + [% ELSE %] + [% END %]
  • @@ -128,7 +136,7 @@
  • - + @@ -140,7 +148,14 @@ - +
    Code Description Default amountCan be added manuallyAvailable for Library limitations Actions [% debit_type.code | html %] [% debit_type.description | html %] [% debit_type.default_amount | $Price %][% IF debit_type.can_be_added_manually %]Yes[% ELSE %]No[% END %][% IF debit_type.can_be_invoiced && debit_type.can_be_sold %] + Invoicing, Sale + [% ELSIF debit_type.can_be_invoiced %] + Invoicing + [% ELSIF debit_type.can_be_sold %] + Sale + [% END %] + [% IF debit_type.library_limits.count > 0 %] [% library_limits_str = "" %] diff --git a/members/maninvoice.pl b/members/maninvoice.pl index a54206fb74..f271d1f791 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -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( diff --git a/pos/pay.pl b/pos/pay.pl index 3406f24461..3d9956f8a5 100755 --- a/pos/pay.pl +++ b/pos/pay.pl @@ -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 ); -- 2.39.5