Bug 10366: Alert librarian if an invoice number is duplicated

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.

To test:
1) Apply patch and run database update.
2) Make sure that you have created at least one invoice on
   acqui/parcels.pl and take note of the invoice number.
3) Try to create an invoice with the same invoice number.
4) Note that without changing your configuration this works exactly
   the same as before.
5) Turn on the AcqWarnOnDuplicateInvoice system preference.
6) Try to create a new invoice with the same number as the one you
   noted earlier.
7) Make sure you get a warning about a duplicate invoice.
8) Choose to receive on the existing invoice.
9) Confirm that you are receiving on said existing invoice.
10) Start the receiving process over, and this time choose "Create new
    invoice anyway."
11) Confirm that you are now receiving on a new invoice.

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.

I have followed the test plan, but also checked some more things:
- Checking the duplicate check works when you have the entered
  invoice number in your database multiple times already.
- Checking that no duplicate message is shown if you enter the
  invoice number and it's already been used for an invoice from
  another vendor.

Looks all good. I think the only thing we could argue about here
is if this could be activated by default for new installations.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Jared Camins-Esakov 2013-05-28 23:03:59 -04:00 committed by Galen Charlton
parent 37b3ac65e1
commit 2d47b85692
5 changed files with 74 additions and 7 deletions

View file

@ -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,

View file

@ -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('OpacHoldNotes',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');

View file

@ -7017,6 +7017,19 @@ if ( CheckVersion($DBversion) ) {
SetVersion($DBversion);
}
$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)

View file

@ -1,3 +1,4 @@
[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Acquisitions &rsaquo; 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">

View file

@ -36,6 +36,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:
-