Bugzilla – Attachment 34334 Details for
Bug 12768
Replacement cost and processing fee management
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12768 - Replacement cost and processing fee management
Bug-12768---Replacement-cost-and-processing-fee-ma.patch (text/plain), 16.39 KB, created by
simith.doliveira
on 2014-12-11 19:07:24 UTC
(
hide
)
Description:
Bug 12768 - Replacement cost and processing fee management
Filename:
MIME Type:
Creator:
simith.doliveira
Created:
2014-12-11 19:07:24 UTC
Size:
16.39 KB
patch
obsolete
>From ca2a63679115f375421502f1227132a9e464730c Mon Sep 17 00:00:00 2001 >From: simith <simith@inlibro.com> >Date: Thu, 11 Dec 2014 14:03:38 -0500 >Subject: [PATCH] Bug 12768 - Replacement cost and processing fee management > >--- > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/sysprefs.sql | 2 + > installer/data/mysql/updatedatabase.pl | 10 ++++ > .../en/modules/admin/preferences/circulation.pref | 8 ++++ > .../intranet-tmpl/prog/en/modules/tools/letter.tt | 6 +++ > misc/cronjobs/advance_notices.pl | 35 ++++++++++++++ > misc/cronjobs/overdue_notices.pl | 15 +++++- > tools/letter.pl | 53 ++++++++++++++-------- > 8 files changed, 109 insertions(+), 21 deletions(-) > >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 4ffbbf2..b126de8 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1388,6 +1388,7 @@ CREATE TABLE `letter` ( -- table for all notice templates in Koha > `title` varchar(200) NOT NULL default '', -- subject line of the notice > `content` text, -- body text for the notice or slip > `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice >+ `fee` decimal(10,2) DEFAULT NULL, -- set up the cost of sending a notice > PRIMARY KEY (`module`,`code`, `branchcode`, `message_transport_type`), > CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`) > REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index c3e308f..ab38623 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -100,6 +100,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('DefaultLongOverdueChargeValue', NULL, NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'), > ('DefaultLongOverdueDays', NULL, NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'), > ('DefaultLongOverdueLostValue', NULL, NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'), >+('defaultnoticefee','0',NULL,' set up how much cost the sending of a notice',NULL), > ('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'), > ('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'), > ('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'), >@@ -216,6 +217,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('NotesBlacklist','',NULL,'List of notes fields that should not appear in the title notes/description separator of details','free'), > ('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'), > ('NoticeCSS','',NULL,'Notices CSS url.','free'), >+('noticefeenote', '', NULL, 'Set up the notice fee note in the "accountlines" table', NULL), > ('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'), > ('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content. Requires Novelist Profile and Password','YesNo'), > ('NovelistSelectPassword',NULL,NULL,'Enable Novelist user Profile','free'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index cf17e0b..f13f79c 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -9585,6 +9585,16 @@ if ( CheckVersion($DBversion) ) { > SetVersion ($DBversion); > } > >+$DBversion = "XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do("ALTER TABLE `letter` add `fee` decimal(10,2) DEFAULT NULL"); >+ $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) >+ VALUES ('defaultnoticefee','0',NULL,' set up how much cost the sending of a notice',NULL), >+ ('noticefeenote', '', NULL, 'Set up the notice fee note in the accountlines table', NULL)"); >+ print "Upgrade to $DBversion done (Bug 12769 - Notice fee management)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index a296bf6..ac3e9a6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -632,6 +632,14 @@ Circulation: > yes: Charge > no: "Don't Charge" > - the replacement price when a patron loses an item. >+ - >+ - Set up how much cost the sending of a notice to >+ - pref: DefaultNoticeFee >+ class: integer >+ - >+ - Set up the notice fee note in the "accountlines" table to >+ - pref: NoticeFeeNote >+ > Self Checkout: > - > - "Include the following JavaScript on all pages in the web-based self checkout:" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >index cfda11c..e3a8bd1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >@@ -331,6 +331,12 @@ $(document).ready(function() { > [% END %] > </select> > </li> >+ [% IF (module == "circulation") %] >+ <li> >+ <label for="code" >Notice fee:</label> >+ <input type="text" id="fee" name="fee" size="7" maxlength="7" value="[% IF ( modify ) %][% fee %][% END %]"/> >+ </li> >+ [% END %] > <li> > [% IF adding %] > <label for="code" class="required">Code:</label> >diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl >index 62e36e4..729a21e 100755 >--- a/misc/cronjobs/advance_notices.pl >+++ b/misc/cronjobs/advance_notices.pl >@@ -245,6 +245,7 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > my $digest = $due_digest->{$upcoming->{'borrowernumber'}} ||= {}; > $digest->{email} ||= $from_address; > $digest->{count}++; >+ $digest->{itemnumber} = $upcoming->{'itemnumber'}; > } else { > my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} ); > my $letter_type = 'DUE'; >@@ -267,6 +268,9 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > } ) > or warn "no letter of type '$letter_type' found. Please see sample_notices.sql"; > push @letters, $letter; >+ if ($letter){ >+ noticefine($upcoming->{'borrowernumber'}, $upcoming->{'itemnumber'}, $letter_type, $upcoming->{'branchcode'}, $transport, $letter ); >+ } > } > } > } else { >@@ -281,6 +285,7 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > my $digest = $upcoming_digest->{$upcoming->{'borrowernumber'}} ||= {}; > $digest->{email} ||= $from_address; > $digest->{count}++; >+ $digest->{itemnumber} = $upcoming->{'itemnumber'}; > } else { > my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} ); > my $letter_type = 'PREDUE'; >@@ -303,6 +308,9 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > } ) > or warn "no letter of type '$letter_type' found. Please see sample_notices.sql"; > push @letters, $letter; >+ if ($letter){ >+ noticefine($upcoming->{'borrowernumber'}, $upcoming->{'itemnumber'}, $letter_type, $upcoming->{'branchcode'}, $transport, $letter ); >+ } > } > } > } >@@ -343,6 +351,7 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { > @letters = (); > my $count = $digest->{count}; > my $from_address = $digest->{email}; >+ my $itemnumber = $digest->{itemnumber}; > > my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, > message_name => 'advance_notice' } ); >@@ -378,6 +387,9 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { > ) > or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; > push @letters, $letter; >+ if ($letter){ >+ noticefine($borrowernumber, $itemnumber, $letter_type, $branch_info{"branches.branchcode"}, $transport, $letter ); >+ } > } > > if ( @letters ) { >@@ -403,6 +415,7 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { > @letters = (); > my $count = $digest->{count}; > my $from_address = $digest->{email}; >+ my $itemnumber = $digest->{itemnumber}; > > my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, > message_name => 'item_due' } ); >@@ -436,6 +449,9 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { > ) > or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; > push @letters, $letter; >+ if ($letter){ >+ noticefine($borrowernumber, $itemnumber, $letter_type, $branch_info{"branches.branchcode"}, $transport, $letter ); >+ } > } > > if ( @letters ) { >@@ -499,6 +515,25 @@ sub format_date { > return output_pref($dt); > } > >+sub noticefine { >+ my ($borrowernumber, $itemnumber, $code, $branchcode, $message_transport_type, $letter ) = @_; >+ >+ my $letterFee = C4::Letters::getletter( 'circulation', $code, $branchcode, $message_transport_type); >+ >+ if ($letterFee) { >+ my $sendfee; >+ if ($letter->{'fee'}){ >+ $sendfee = $letter->{'fee'}; >+ } else { >+ $sendfee = C4::Context->preference('DefaultNoticeFee'); >+ } >+ >+ if ($sendfee > 0){ >+ C4::Accounts::manualinvoice($borrowernumber, "", "", "F", $sendfee, C4::Context->preference('NoticeFeeNote')); >+ } >+ } >+} >+ > =head2 get_branch_info > > =cut >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 4e58e8a..f755af6 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -486,7 +486,7 @@ END_SQL > # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country> > > my $borrower_sql = <<'END_SQL'; >-SELECT issues.borrowernumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, phone, cardnumber, >+SELECT issues.borrowernumber, issues.itemnumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, phone, cardnumber, > TO_DAYS(?)-TO_DAYS(date_due) as difference, date_due > FROM issues,borrowers,categories > WHERE issues.borrowernumber=borrowers.borrowernumber >@@ -570,6 +570,7 @@ END_SQL > > my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode ); > >+ > unless ($letter) { > $verbose and warn "Message '$overdue_rules->{letter$i}' content not found"; > >@@ -577,7 +578,17 @@ END_SQL > # FIXME : Does this mean a letter must be defined in order to trigger a debar ? > next PERIOD; > } >- >+ my $sendfee; >+ if ($letter->{'fee'}){ >+ $sendfee = $letter->{'fee'}; >+ } else { >+ $sendfee = C4::Context->preference('DefaultNoticeFee'); >+ } >+ >+ if ($sendfee > 0){ >+ C4::Accounts::manualinvoice($borrowernumber, "", "", "F", $sendfee, C4::Context->preference('NoticeFeeNote')); >+ } >+ > if ( $overdue_rules->{"debarred$i"} ) { > > #action taken is debarring >diff --git a/tools/letter.pl b/tools/letter.pl >index ab4f78f..d139821 100755 >--- a/tools/letter.pl >+++ b/tools/letter.pl >@@ -159,10 +159,17 @@ sub add_form { > # So we can only sent the first one to the template. > for my $mtt ( @$message_transport_types ) { > # The letter_name >- if ( $first_flag and $letters->{$mtt}{name} ) { >- $template->param( >- letter_name=> $letters->{$mtt}{name}, >- ); >+ if ( $first_flag) { >+ if ($letters->{$mtt}{name}) { >+ $template->param( >+ letter_name=> $letters->{$mtt}{name}, >+ ); >+ } >+ if ($letters->{$mtt}{fee}) { >+ $template->param( >+ fee => $letters->{$mtt}{fee}, >+ ); >+ } > $first_flag = 0; > } > >@@ -246,9 +253,16 @@ sub add_validate { > my $oldmodule = $input->param('oldmodule'); > my $code = $input->param('code'); > my $name = $input->param('name'); >+ my $fee = $input->param('fee'); > my @mtt = $input->param('message_transport_type'); > my @title = $input->param('title'); > my @content = $input->param('content'); >+ >+ my $insertfee = $fee; >+ if (defined($fee) and $fee eq ''){ >+ $insertfee = undef; >+ } >+ > for my $mtt ( @mtt ) { > my $is_html = $input->param("is_html_$mtt"); > my $title = shift @title; >@@ -266,22 +280,23 @@ sub add_validate { > next; > } > elsif ( $letter and $letter->{message_transport_type} eq $mtt ) { >- $dbh->do( >- q{ >- UPDATE letter >- SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ? >- WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ? >- }, >- undef, >- $branchcode, $module, $name, $is_html || 0, $title, $content, >- $branchcode, $oldmodule, $code, $mtt >- ); >+ if (defined($fee)){ >+ $dbh->do(q{UPDATE letter SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?, fee = ? >+ WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?}, undef, >+ $branchcode, $module, $name, $is_html || 0, $title, $content, $insertfee, $branchcode, $oldmodule, $code, $mtt); >+ } else { >+ $dbh->do(q{UPDATE letter SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ? >+ WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?}, undef, >+ $branchcode, $module, $name, $is_html || 0, $title, $content, $branchcode, $oldmodule, $code, $mtt); >+ } > } else { >- $dbh->do( >- q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,?,?,?,?,?,?,?)}, >- undef, >- $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt >- ); >+ if (defined($fee) and $fee != ''){ >+ $dbh->do(q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type, fee) VALUES (?,?,?,?,?,?,?,?,?)},undef, >+ $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt, $fee); >+ } else { >+ $dbh->do(q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,?,?,?,?,?,?,?)},undef, >+ $branchcode, $module, $code, $name, $is_html || 0, $title, $content, $mtt); >+ } > } > } > # set up default display >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12768
:
34333
|
34334
|
36350
|
36505
|
36506
|
36552
|
36553
|
36554
|
36555
|
38365
|
38367
|
38368
|
38375
|
39298
|
39299
|
39300
|
39999
|
40000
|
40001
|
40002
|
42157
|
42158
|
43181
|
43546
|
64775
|
64776
|
66760
|
66761
|
67875
|
67876
|
67877
|
67878
|
67891
|
67892
|
67893
|
67894
|
67895
|
67896
|
67897
|
68035
|
68036
|
68037
|
68038
|
68039
|
68040
|
68041
|
68042
|
68076
|
68264
|
68265
|
68266
|
68267
|
68268
|
68269
|
68270
|
68271
|
68272
|
68273
|
68274
|
68332
|
68415
|
68416
|
68417
|
68426
|
68427