From: Jared Camins-Esakov <[email protected]> Some vendors ship materials from the same invoice in multiple packages. In those cases, it would be good to notify the librarian when they enter a duplicate invoice number, so that they can continue receiving on the previously-created invoice, rather than creating an invoice with a duplicate number.
Signed-off-by: Srdjan <[email protected]> --- acqui/parcels.pl | 34 +++++++++++++++++----- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 13 +++++++++ .../intranet-tmpl/prog/en/modules/acqui/parcels.tt | 29 ++++++++++++++++++ .../en/modules/admin/preferences/acquisitions.pref | 6 ++++ 5 files changed, 75 insertions(+), 8 deletions(-) diff --git a/acqui/parcels.pl b/acqui/parcels.pl index 405ff64..7c03f7b 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -98,14 +98,32 @@ our ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( } ); -if($op and $op eq 'new') { - my $invoicenumber = $input->param('invoice'); - my $shipmentdate = $input->param('shipmentdate'); - my $shipmentcost = $input->param('shipmentcost'); - my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid'); - if($shipmentdate) { - $shipmentdate = C4::Dates->new($shipmentdate)->output('iso'); +my $invoicenumber = $input->param('invoice'); +my $shipmentdate = $input->param('shipmentdate'); +my $shipmentcost = $input->param('shipmentcost'); +my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid'); +if($shipmentdate) { + $shipmentdate = C4::Dates->new($shipmentdate)->output('iso'); +} + +if ( $op and $op eq 'new' ) { + if ( C4::Context->preference('AcqWarnOnDuplicateInvoice') ) { + my @invoices = GetInvoices( + supplierid => $booksellerid, + invoicenumber => $invoicenumber, + ); + if ( $#invoices > 0 ) { + $template->{'VARS'}->{'duplicate_invoices'} = \@invoices; + $template->{'VARS'}->{'invoicenumber'} = $invoicenumber; + $template->{'VARS'}->{'shipmentdate'} = $shipmentdate; + $template->{'VARS'}->{'shipmentcost'} = $shipmentcost; + $template->{'VARS'}->{'shipmentcost_budgetid'} = + $shipmentcost_budgetid; + } } + $op = 'confirm' unless $template->{'VARS'}->{'duplicate_invoices'}; +} +if ($op and $op eq 'confirm') { my $invoiceid = AddInvoice( invoicenumber => $invoicenumber, booksellerid => $booksellerid, @@ -114,7 +132,7 @@ if($op and $op eq 'new') { shipmentcost_budgetid => $shipmentcost_budgetid, ); if(defined $invoiceid) { - # Successful 'Add' +# Successful 'Add' print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid"); exit 0; } else { diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 31485bc..6c5f073 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -427,3 +427,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo'); INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f3a90d8..dee9963 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6984,6 +6984,19 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( } +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do( + q{ +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo'); +} + ); + print +"Upgrade to $DBversion done (Bug 10366 - Add system preference to enabling warning librarian when invoice is duplicated)\n"; + SetVersion($DBversion); +} + + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt index 39c53e2..26e4af8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Acquisitions › Receive shipment from vendor [% name %]</title> <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> @@ -38,6 +39,34 @@ [% END %] <h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name %]</a></h1> + [% IF duplicate_invoices %] + <div id="parcels_duplicate_invoice" class="dialog alert"> + <p>This invoice number has already been used. Would you like to receive on an existing invoice?</p> + <table> + <thead><tr><th>Invoice no.</th><th>Shipment date</th><th></th></tr></thead> + <tbody> + [% FOREACH invoice IN duplicate_invoices %] + <tr> + <td>[% invoice.invoicenumber %]</td> + <td>[% invoice.shipmentdate | $KohaDates %]</td> + <td><a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoice.invoiceid %]">Receive</a></td> + </tr> + [% END %] + </tbody> + </table> + <form method="get" action="parcels.pl"> + <input type="hidden" name="booksellerid" value="[% booksellerid %]" /> + <input type="hidden" name="op" value="confirm" /> + <input type="hidden" name="invoice" value="[% invoicenumber %]" /> + <input type="hidden" name="shipmentdate" value="[% shipmentdate %]" /> + <input type="hidden" name="shipmentcost" value="[% shipmentcost %]" /> + <input type="hidden" name="shipmentcost_budgetid" value="[% shipmentcost_budgetid %]" /> + <input type="submit" class="button" value="Create new invoice anyway" /> + </form> + </div> + [% END %] + + [% IF ( count ) %] <p> [% count %] shipments</p> <div id="resultlist"> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index 1ec49ff..cb5a4c7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -35,6 +35,12 @@ Acquisitions: - Default tax rates are - pref: gist - (enter in numeric form, 0.12 for 12%. First is the default. If you want more than 1 value, please separate with |) + - + - pref: AcqWarnOnDuplicateInvoice + choices: + yes: Warn + no: "Do not warn" + - when the librarian tries to create an invoice with a duplicate number. Printing: - -- 1.8.1.2 _______________________________________________ Koha-patches mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
