Bugzilla – Attachment 28716 Details for
Bug 11092
Need a processing fee and billing fee on late notices.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11092 - Add invoice on overdue items
Bug-11092---Add-invoice-on-overdue-items.patch (text/plain), 13.77 KB, created by
Blou
on 2014-06-06 21:26:33 UTC
(
hide
)
Description:
Bug 11092 - Add invoice on overdue items
Filename:
MIME Type:
Creator:
Blou
Created:
2014-06-06 21:26:33 UTC
Size:
13.77 KB
patch
obsolete
>From f5d0226d7bec2e67b5c303169de0620acdc89431 Mon Sep 17 00:00:00 2001 >From: Blou <philippe.blouin@inlibro.com> >Date: Fri, 6 Jun 2014 17:22:03 -0400 >Subject: [PATCH] Bug 11092 - Add invoice on overdue items > >This is a draft for Viktor, to see where he needs the functionnality to go. >It was my first try with the letter mechanism, and I haven't managed (yet) to >get the email in HTML. Much formatting is still needed. > >See tools/letter.pl?op=add_form&branchcode=&module=circulation&code=INVOICE for new letter added by updatedatabase.pl > > modified: ../../installer/data/mysql/updatedatabase.pl > modified: ../../koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt > modified: overdue_notices.pl > modified: ../../tools/overduerules.pl > >http://bugs.koha-community.org/show_bug.cgi?id=10192 >--- > installer/data/mysql/updatedatabase.pl | 24 ++++++++++++++++ > .../prog/en/modules/tools/overduerules.tt | 8 ++++++ > misc/cronjobs/overdue_notices.pl | 12 ++++++-- > tools/overduerules.pl | 30 +++++++++++++------- > 4 files changed, 60 insertions(+), 14 deletions(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 01472d7..11b3a0e 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8551,6 +8551,30 @@ if (CheckVersion($DBversion)) { > SetVersion($DBversion); > } > >+$DBversion = "3.17.00.XXX"; >+if (CheckVersion($DBversion)) { >+ $dbh->do("alter table overduerules >+ add invoice1 int(1) default 0 after debarred1, >+ add invoice2 int(1) default 0 after debarred2, >+ add invoice3 int(1) default 0 after debarred3 >+ "); >+ $dbh->do("insert into systempreferences values('InvoiceProcessingFee', 0, NULL, 'Invoice processing fee (charged once per item)', 'Float')"); >+ $dbh->do("insert into systempreferences values('InvoiceBillingFee', 0, NULL, 'Invoice billing fee (charged once per bill)', 'Float')"); >+ $dbh->do("insert into systempreferences values('DefaultReplacementPrice', 10.0, NULL,'Amount to use when the item has none associated to it.', 'Float')"); >+ $dbh->do("insert into letter (module, code, name, is_html, title, message_transport_type, content) values ('circulation', 'INVOICE', 'Processing/Billing invoice', 1, 'Billing invoice', 'email', >+ '<br>Dear <<borrowers.firstname>> <<borrowers.surname>>, >+ <br>The following items are now due and fines have been added: >+ <item><<biblio.title>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>> Replacement cost:<<items.replacementprice>>, Processing fee:<<items.invoiceprocessingfee>><br> >+ </item><br> >+ Billing fee: <<billingfee>><br> >+ Total: <<totalfine>><br> >+ </body><html> >+ ') >+ "); >+ print "Upgrade to $DBversion done (Bug 11092 - Add a processing fee and billing fee on late notices)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >index 8c109a5..d71730d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >@@ -92,6 +92,7 @@ $(document).ready(function() { > <th scope="col">Delay</th> > <th scope="col">Letter</th> > <th scope="col">Restrict</th> >+ <th scope="col">Issue an invoice</th> > [% FOREACH mtt IN message_transport_types %] > <th scpre="col"> > [% SWITCH mtt %] >@@ -142,6 +143,13 @@ $(document).ready(function() { > <input type="checkbox" name="debarred[% tab.number %]-[% value.overduename %]" value="1" /> > [% END %] > </td> >+ <td> >+ [% IF ( value.invoice ) %] >+ <input type="checkbox" name="invoice[% tab.number %]-[% value.overduename %]" checked="checked" value="1" /> >+ [% ELSE %] >+ <input type="checkbox" name="invoice[% tab.number %]-[% value.overduename %]" value="1" /> >+ [% END %] >+ </td> > [% FOREACH mtt IN value.message_transport_types %] > <td> > [% IF mtt.selected %] >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 2a9f8ae..785910c 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -34,7 +34,7 @@ use Pod::Usage; > use Text::CSV_XS; > use Locale::Currency::Format 1.28; > use Encode; >- >+use Data::Dumper; > use C4::Context; > use C4::Dates qw/format_date/; > use C4::Debug; >@@ -526,7 +526,6 @@ 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"; > >@@ -554,7 +553,7 @@ END_SQL > my $itemcount = 0; > my $titles = ""; > my @items = (); >- >+ my $totalFine = 0; > my $j = 0; > my $exceededPrintNoticesMaxLines = 0; > while ( my $item_info = $sth2->fetchrow_hashref() ) { >@@ -566,6 +565,11 @@ END_SQL > my @item_info = map { $_ =~ /^date|date$/ ? format_date( $item_info->{$_} ) : $item_info->{$_} || '' } @item_content_fields; > $titles .= join("\t", @item_info) . "\n"; > $itemcount++; >+ if($overdue_rules->{"invoice$i"}){ >+ $item_info->{invoiceprocessingfee} = C4::Context->preference("InvoiceProcessingFee"); >+ $item_info->{replacementprice} ||= C4::Context->preference("DefaultReplacementPrice"); >+ $totalFine += $item_info->{fine} + $item_info->{invoiceprocessingfee} + $item_info->{invoiceprocessingfee}; >+ } > push @items, $item_info; > } > $sth2->finish; >@@ -587,6 +591,8 @@ END_SQL > bib => $branch_details->{'branchname'}, # maybe 'bib' is a typo for 'lib<rary>'? > 'items.content' => $titles, > 'count' => $itemcount, >+ 'billingfee' => C4::Context->preference("InvoiceBillingFee"), >+ 'totalfine' => $totalFine + C4::Context->preference("InvoiceBillingFee"), > }, > message_transport_type => $mtt, > } >diff --git a/tools/overduerules.pl b/tools/overduerules.pl >index 810b1fd..7d688d7 100755 >--- a/tools/overduerules.pl >+++ b/tools/overduerules.pl >@@ -31,13 +31,13 @@ use C4::Overdues; > > our $input = new CGI; > my $dbh = C4::Context->dbh; >- >+warn "INLIBRO"; > my @categories = @{$dbh->selectall_arrayref( > 'SELECT description, categorycode FROM categories WHERE overduenoticerequired > 0', > { Slice => {} } > )}; > my @category_codes = map { $_->{categorycode} } @categories; >-our @rule_params = qw(delay letter debarred); >+our @rule_params = qw(delay letter debarred invoice); > > # blank_row($category_code) - return true if the entire row is blank. > sub blank_row { >@@ -74,16 +74,17 @@ my ($template, $loggedinuser, $cookie) > debug => 1, > }); > my $err=0; >- >+use Data::Dumper; > # save the values entered into tables > my %temphash; > my $input_saved = 0; > if ($op eq 'save') { > my @names=$input->param(); >+warn "INLIBRO" . join(',', @names); > my $sth_search = $dbh->prepare("SELECT count(*) AS total FROM overduerules WHERE branchcode=? AND categorycode=?"); > >- my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); >- my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, delay2=?, letter2=?, debarred2=?, delay3=?, letter3=?, debarred3=? WHERE branchcode=? AND categorycode=?"); >+ my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1,invoice1, delay2,letter2,debarred2,invoice2, delay3,letter3,debarred3,invoice3) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >+ my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, invoice1=?, delay2=?, letter2=?, debarred2=?, invoice2=?, delay3=?, letter3=?, debarred3=?, invoice3=? WHERE branchcode=? AND categorycode=?"); > my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?"); > my $sth_insert_mtt = $dbh->prepare(" > INSERT INTO overduerules_transport_types( >@@ -99,7 +100,7 @@ if ($op eq 'save') { > > foreach my $key (@names){ > # ISSUES >- if ($key =~ /(delay|letter|debarred)([1-3])-(.*)/) { >+ if ($key =~ /(delay|letter|debarred|invoice)([1-3])-(.*)/) { > my $type = $1; # data type > my $num = $2; # From 1 to 3 > my $bor = $3; # borrower category >@@ -115,7 +116,7 @@ if ($op eq 'save') { > > # figure out which rows need to be deleted > my @rows_to_delete = grep { blank_row($_) } @category_codes; >- >+warn Dumper(%temphash); > foreach my $bor (keys %temphash){ > # get category name if we need it for an error message > my $bor_category = GetBorrowercategory($bor); >@@ -148,9 +149,9 @@ if ($op eq 'save') { > $err=1; > } > unless ($err){ >- if (($temphash{$bor}->{delay1} and ($temphash{$bor}->{"letter1"} or $temphash{$bor}->{"debarred1"})) >- or ($temphash{$bor}->{delay2} and ($temphash{$bor}->{"letter2"} or $temphash{$bor}->{"debarred2"})) >- or ($temphash{$bor}->{delay3} and ($temphash{$bor}->{"letter3"} or $temphash{$bor}->{"debarred3"}))) { >+ if (($temphash{$bor}->{delay1} and ($temphash{$bor}->{"letter1"} or $temphash{$bor}->{"debarred1"} or $temphash{$bor}->{"invoice1"})) >+ or ($temphash{$bor}->{delay2} and ($temphash{$bor}->{"letter2"} or $temphash{$bor}->{"debarred2"} or $temphash{$bor}->{"invoice2"})) >+ or ($temphash{$bor}->{delay3} and ($temphash{$bor}->{"letter3"} or $temphash{$bor}->{"debarred3"} or $temphash{$bor}->{"invoice3"}))) { > $sth_search->execute($branch,$bor); > my $res = $sth_search->fetchrow_hashref(); > if ($res->{'total'}>0) { >@@ -158,12 +159,15 @@ if ($op eq 'save') { > ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef), > ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), > ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), >+ ($temphash{$bor}->{"invoice1"}?$temphash{$bor}->{"invoice1"}:0), > ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:undef), > ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), > ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), >+ ($temphash{$bor}->{"invoice2"}?$temphash{$bor}->{"invoice2"}:0), > ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef), > ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), > ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0), >+ ($temphash{$bor}->{"invoice3"}?$temphash{$bor}->{"invoice3"}:0), > $branch ,$bor > ); > } else { >@@ -171,12 +175,15 @@ if ($op eq 'save') { > ($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0), > ($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), > ($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), >+ ($temphash{$bor}->{"invoice1"}?$temphash{$bor}->{"invoice1"}:0), > ($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0), > ($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), > ($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), >+ ($temphash{$bor}->{"invoice2"}?$temphash{$bor}->{"invoice2"}:0), > ($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0), > ($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), >- ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0) >+ ($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0), >+ ($temphash{$bor}->{"invoice3"}?$temphash{$bor}->{"invoice3"}:0), > ); > } > >@@ -288,6 +295,7 @@ for my $data (@categories) { > } > if ($dat->{"delay$i"}){$row{delay}=$dat->{"delay$i"};} > if ($dat->{"debarred$i"}){$row{debarred}=$dat->{"debarred$i"};} >+ if ($dat->{"invoice$i"}){$row{invoice}=$dat->{"invoice$i"};} > my @selected_mtts = @{ GetOverdueMessageTransportTypes( $branch, $data->{'categorycode'}, $i) }; > my @mtts; > for my $mtt ( @$message_transport_types ) { >-- >1.7.9.5
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 11092
:
22158
|
22159
|
22160
| 28716