Bugzilla – Attachment 40081 Details for
Bug 12769
Manage fees for sending notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12769 - Notice fee management
Bug-12769---Notice-fee-management.patch (text/plain), 18.19 KB, created by
Eivin Giske Skaaren
on 2015-06-10 17:50:06 UTC
(
hide
)
Description:
Bug 12769 - Notice fee management
Filename:
MIME Type:
Creator:
Eivin Giske Skaaren
Created:
2015-06-10 17:50:06 UTC
Size:
18.19 KB
patch
obsolete
>From 1894c64e6ac8086d5bbaa278c55869fa3c7365ba Mon Sep 17 00:00:00 2001 >From: mxbeaulieu <maxime.beaulieu@inlibro.com> >Date: Fri, 5 Jun 2015 09:22:10 -0400 >Subject: [PATCH] Bug 12769 - Notice fee management > >Created an atomic update .sql file. > >Signed-off-by: Eivin Giske Skaaren <eivin@sysmystic.com> >--- > C4/Letters.pm | 2 +- > .../atomicupdate/bug12769_NoticeFeeManagement.sql | 4 ++ > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/sysprefs.sql | 2 + > .../en/modules/admin/preferences/circulation.pref | 8 +++ > .../intranet-tmpl/prog/en/modules/tools/letter.tt | 6 +++ > misc/cronjobs/advance_notices.pl | 57 ++++++++++++++++---- > misc/cronjobs/overdue_notices.pl | 15 +++++- > tools/letter.pl | 53 +++++++++++------- > 9 files changed, 116 insertions(+), 32 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug12769_NoticeFeeManagement.sql > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index c7751ca..492bb55 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -119,7 +119,7 @@ sub GetLetterTemplates { > my $dbh = C4::Context->dbh; > my $letters = $dbh->selectall_hashref( > q| >- SELECT module, code, branchcode, name, is_html, title, content, message_transport_type >+ SELECT module, code, branchcode, name, fee, is_html, title, content, message_transport_type > FROM letter > WHERE module = ? > AND code = ? >diff --git a/installer/data/mysql/atomicupdate/bug12769_NoticeFeeManagement.sql b/installer/data/mysql/atomicupdate/bug12769_NoticeFeeManagement.sql >new file mode 100644 >index 0000000..f9b559e >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug12769_NoticeFeeManagement.sql >@@ -0,0 +1,4 @@ >+ALTER TABLE `letter` add `fee` decimal(10,2) DEFAULT NULL AFTER `message_transport_type`; >+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); >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 6683125..ba220a9 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1393,6 +1393,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 a744cbf..2f66777 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -104,6 +104,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'), >@@ -221,6 +222,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/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index a16f231..d9e6da2 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 >@@ -626,6 +626,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 3106498..9d67d85 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >@@ -336,6 +336,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 16800f0..950bad0 100755 >--- a/misc/cronjobs/advance_notices.pl >+++ b/misc/cronjobs/advance_notices.pl >@@ -244,8 +244,10 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > > if ( $borrower_preferences->{'wants_digest'} ) { > # cache this one to process after we've run through all of the items. >- $due_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; >- $due_digest->{ $upcoming->{borrowernumber} }->{count}++; >+ 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,7 +269,10 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > message_transport_type => $transport, > } ) > or warn "no letter of type '$letter_type' found. Please see sample_notices.sql"; >- push @letters, $letter if $letter; >+ push @letters, $letter; >+ if ($letter){ >+ noticefine($upcoming->{'borrowernumber'}, $upcoming->{'itemnumber'}, $letter_type, $upcoming->{'branchcode'}, $transport, $letter ); >+ } > } > } > } else { >@@ -278,8 +283,10 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > > if ( $borrower_preferences->{'wants_digest'} ) { > # cache this one to process after we've run through all of the items. >- $upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; >- $upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; >+ 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'; >@@ -301,7 +308,10 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > message_transport_type => $transport, > } ) > or warn "no letter of type '$letter_type' found. Please see sample_notices.sql"; >- push @letters, $letter if $letter; >+ push @letters, $letter; >+ if ($letter){ >+ noticefine($upcoming->{'borrowernumber'}, $upcoming->{'itemnumber'}, $letter_type, $upcoming->{'branchcode'}, $transport, $letter ); >+ } > } > } > } >@@ -341,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' } ); >@@ -373,8 +384,11 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { > message_transport_type => $transport, > } > ) >- or warn "no letter of type '$letter_type' found. Please see sample_notices.sql"; >- push @letters, $letter if $letter; >+ 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 ) { >@@ -400,6 +414,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' } ); >@@ -430,8 +445,11 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { > message_transport_type => $transport, > } > ) >- or warn "no letter of type '$letter_type' found. Please see sample_notices.sql"; >- push @letters, $letter if $letter; >+ 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 ) { >@@ -495,6 +513,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 7068d3d..5dc437c 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -501,7 +501,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 >@@ -585,6 +585,7 @@ END_SQL > > my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode ); > >+ > unless ($letter) { > $verbose and warn qq|Message '$overdue_rules->{"letter$i"}' content not found|; > >@@ -592,7 +593,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 e9f39d9..b0eeca1 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; > } > >@@ -249,9 +256,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; >@@ -269,22 +283,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.7.10.4
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 12769
:
34335
|
36318
|
36351
|
36504
|
39900
|
39918
|
39919
| 40081 |
40082