@@ -, +, @@ duplicated acqui/parcels.pl and take note of the invoice number. the same as before. noted earlier. invoice anyway." --- acqui/parcels.pl | 30 ++++++++++++++----- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 13 ++++++++ .../intranet-tmpl/prog/en/modules/acqui/parcels.tt | 31 +++++++++++++++++++- .../en/modules/admin/preferences/acquisitions.pref | 6 ++++ 5 files changed, 73 insertions(+), 8 deletions(-) --- a/acqui/parcels.pl +++ a/acqui/parcels.pl @@ -98,14 +98,30 @@ our ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( } ); +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') { - 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 @invoices = GetInvoices( + supplierid => $booksellerid, + invoicenumber => $invoicenumber, + ); + if ($#invoices > 0 && C4::Context->preference('AcqWarnOnDuplicateInvoice')) { + $template->{'VARS'}->{'duplicate_invoices'} = \@invoices; + $template->{'VARS'}->{'invoicenumber'} = $invoicenumber; + $template->{'VARS'}->{'shipmentdate'} = $shipmentdate; + $template->{'VARS'}->{'shipmentcost'} = $shipmentcost; + $template->{'VARS'}->{'shipmentcost_budgetid'} = $shipmentcost_budgetid; + } else { + $op = 'confirm'; } +} +if ($op and $op eq 'confirm') { my $invoiceid = AddInvoice( invoicenumber => $invoicenumber, booksellerid => $booksellerid, @@ -114,7 +130,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 { --- a/installer/data/mysql/sysprefs.sql +++ a/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'); --- a/installer/data/mysql/updatedatabase.pl +++ a/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) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Koha › Acquisitions › Receive shipment from vendor [% name %] @@ -38,6 +39,34 @@ [% END %]

Receive shipment from vendor [% name %]

+ [% IF duplicate_invoices %] +
+

This invoice number has already been used. Would you like to receive on an existing invoice?

+ + + + [% FOREACH invoice IN duplicate_invoices %] + + + + + + [% END %] + +
Invoice no.Shipment date
[% invoice.invoicenumber %][% invoice.shipmentdate | $KohaDates %]Receive
+
+ + + + + + + +
+
+ [% END %] + + [% IF ( count ) %]

[% count %] shipments

@@ -107,7 +136,7 @@
[% END %] - +
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ a/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: - --