Bug 7132: Acq: Check for duplicates when ordering from empty record

To test using a new empty record:

1. Ensure you have a vendor and a new basket available for ordering.
   Click on “+Add to basket” and select “From a new (empty) record”
2. Choose an existing record to test with for example “CSS : the
   definitive guide”
   (http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=12&searchid=scs_1759160315801)
3. Copy over the main details from the existing record in order to fill
   out the required details of the new order. I.e Title, and Koha item
   type. Click add item and then select a fund. It’s not necessary to
   fill anything else out.
4. Click save and notice that the duplicate record is not found.
5. Apply the patch and restart_all. Clear cache in your browser if
   necessary.
6. Repeat steps 2 - 4. This time a duplicate warning will appear. Ensure
   that all options of the duplicate warning work as expected.
7. Sign off and have a great day!

Signed-off-by: Kim Gnerre <kgnerre@hotchkiss.org>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Laura_Escamilla 2025-09-29 16:43:05 +00:00 committed by Lucas Gass
parent 290b6af654
commit 8a13329a41
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 72 additions and 14 deletions

View File

@ -128,6 +128,7 @@ use C4::Budgets qw( GetBudget GetBudgetSpent GetBudgetOrdered FieldsForCalcu
use C4::Items qw( AddItemFromMarc );
use C4::Log qw( logaction );
use C4::Output qw( output_html_with_http_headers );
use C4::Search qw( FindDuplicate );
use C4::Suggestions qw( ModSuggestion );
use Koha::Acquisition::Baskets;
use Koha::Acquisition::Currencies qw( get_active );
@ -147,6 +148,8 @@ my $op = $input->param('op') // q{};
if ( $op eq 'cud-order' ) {
my $use_ACQ_framework = $input->param('use_ACQ_framework');
my $confirm_not_duplicate = $input->param('confirm_not_duplicate') || 0;
# Check if order total amount exceed allowed budget
my $confirm_budget_exceeding = $input->param('confirm_budget_exceeding');
unless ($confirm_budget_exceeding) {
@ -328,6 +331,41 @@ if ( $op eq 'cud-order' ) {
}
C4::Acquisition::FillWithDefaultValues($record);
if ( !$confirm_not_duplicate ) {
my ( $dupe_biblionumber, $dupe_title ) = FindDuplicate($record);
if ($dupe_biblionumber) {
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "acqui/neworderempty_duplicate.tt",
query => $input,
type => "intranet",
flagsrequired => { acquisition => 'order_manage' },
}
);
my $vars = $input->Vars;
my @vars_loop;
foreach ( keys %$vars ) {
push @vars_loop, { name => $_, values => [ $input->multi_param($_) ] };
}
my $booksellerid = $input->param('booksellerid') // '';
my $basketno = $input->param('basketno') // '';
$template->param(
biblionumber => $dupe_biblionumber,
duplicatetitle => $dupe_title,
booksellerid => $booksellerid,
basketno => $basketno,
vars_loop => \@vars_loop,
);
output_html_with_http_headers $input, $cookie, $template->output;
exit;
}
}
# create the record in catalogue, with framework ''
my ( $biblionumber, $bibitemnum ) = AddBiblio( $record, '' );

View File

@ -33,10 +33,12 @@
[% WRAPPER 'main-container.inc' aside='acquisitions-menu' %]
<div class="alert alert-warning">
<h1>Duplicate warning</h1>
<p
>You selected a record from an external source that matches an existing record in your catalog:
<a target="_blank" title="Open in new window" href="[% PROCESS biblio_a_href biblionumber => biblionumber %]"><i class="fa-solid fa-window-restore"></i> [% duplicatetitle | html %]</a></p
>
[% IF breedingid %]
<p>You selected a record from an external source that matches an existing record in your catalog:</p>
[% ELSE %]
<p>The details you entered match an existing record in your catalog:</p>
[% END %]
<a target="_blank" title="Open in new window" href="[% PROCESS biblio_a_href biblionumber => biblionumber %]"><i class="fa-solid fa-window-restore"></i> [% duplicatetitle | html %]</a>
</div>
<div class="row">
@ -66,16 +68,34 @@
<div class="col-sm-4">
<div style="border: 1px solid #DDD; padding:1em;">
<form method="post" action="/cgi-bin/koha/acqui/neworderempty.pl">
[% INCLUDE 'csrf-token.inc' %]
<h4>Create new record</h4>
<p>Create a new record by importing the external (duplicate) record.</p>
<input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
<input type="hidden" name="basketno" value="[% basketno | html %]" />
<input type="hidden" name="breedingid" value="[% breedingid | html %]" />
<input type="hidden" name="op" value="cud-use_external_source" />
<input type="submit" class="btn btn-primary" value="Create new" />
</form>
[% IF breedingid %]
<form method="post" action="/cgi-bin/koha/acqui/neworderempty.pl">
[% INCLUDE 'csrf-token.inc' %]
<h4>Create new record</h4>
<p>Create a new record by importing the external (duplicate) record.</p>
<input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
<input type="hidden" name="basketno" value="[% basketno | html %]" />
<input type="hidden" name="breedingid" value="[% breedingid | html %]" />
<input type="hidden" name="op" value="cud-use_external_source" />
<input type="submit" class="btn btn-primary" value="Create new" />
</form>
[% ELSE %]
<form method="post" action="/cgi-bin/koha/acqui/addorder.pl">
[% INCLUDE 'csrf-token.inc' %]
<h4>Create new record</h4>
<p>Create a new record with the details you entered.</p>
<input type="hidden" name="op" value="cud-order" />
<input type="hidden" name="confirm_not_duplicate" value="1" />
[% FOREACH var IN vars_loop %]
[% FOREACH val IN var.values %]
[% IF var.name != 'confirm_not_duplicate' %]
<input type="hidden" name="[% var.name | html %]" value="[% val | html %]" />
[% END %]
[% END %]
[% END %]
<button type="submit" class="btn btn-primary">Create new</button>
</form>
[% END %]
</div>
</div>
</div>