Skip to content

Commit

Permalink
BWS-PKG - Bug 37316 - Cannot add items to basket via file if barcodes…
Browse files Browse the repository at this point in the history
… not supplied

Bug 37316: Add tests

Signed-off-by: Martin Renvoize <[email protected]>

Bug 37316: Treat empty string barcodes as undef

To test:
1.Add the following to MarcItemFieldsToOrder:

homebranch: 949$a
holdingbranch: 949$b
itype: 949$y
nonpublic_note: 949$x
public_note: 949$z
loc: 949$c
ccode: 949$8
notforloan: 949$7
uri: 949$u
copyno: 949$t
price: 949$g|949$j
replacementprice: 949$v
itemcallnumber: 949$o
quantity: 949$k
budget_code: 949$l
coded_location_qualifier: 949$f
enumchron: 949$h

2. Add the following to MarcFieldsToOrder:

price: 949$g
quantity: 949$k
budget_code: 949$l
discount: 949$m
sort1: 949$n
sort2: 949$q

3. Acquisitions > Find a vendor
4. Create a new basket -> Add to basket -> From new file
5. Use the file uplodaded in this bug report.
6. Set format to MARCXML and stage for import.
7. Add staged files to basket
8. Select all, make sure you add an item type, and choose 'Do not look for matching records'
9. Save and kaboom.
10. APPLY PATCH and restart_all
11. Follow the steps again, this time no kaboom.

Signed-off-by: Martin Renvoize <[email protected]>

Bug 37316: Adjust tests

Signed-off-by: Eric Garcia <[email protected]>
Signed-off-by: Martin Renvoize <[email protected]>
  • Loading branch information
ricofreak authored and kylemhall committed Jul 12, 2024
1 parent 9a811c4 commit f3c1d27
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Koha/Item.pm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ sub store {
$self->itype($self->biblio->biblioitem->itemtype);
}

# Ensure barcode is either defined or undef
$self->barcode(undef) if $self->barcode eq '';

$self->barcode( C4::Circulation::barcodedecode( $self->barcode ) );

my $today = dt_from_string;
Expand Down
29 changes: 28 additions & 1 deletion t/db_dependent/Koha/Item.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Modern::Perl;
use utf8;

use Test::More tests => 34;
use Test::More tests => 35;
use Test::Exception;
use Test::MockModule;

Expand Down Expand Up @@ -843,6 +843,33 @@ subtest 'request_transfer' => sub {
$schema->storage->txn_rollback;
};

subtest 'store check barcodes' => sub {

plan tests => 3;

$schema->storage->txn_begin;

my $biblio = $builder->build_sample_biblio();

my $item = $builder->build_sample_item(
{
biblionumber => $biblio->biblionumber,
}
);

$item->barcode("")->store();
$item->discard_changes;
is( $item->barcode, undef, 'Empty string barcodes are treated as undef' );

$item->barcode("123456789")->store();
$item->discard_changes;
is( $item->barcode, "123456789", 'Non-empty string barcodes are unchanged' );

$item->barcode(undef)->store();
$item->discard_changes;
is( $item->barcode, undef, 'undef barcodes remain undef' );
};

subtest 'deletion' => sub {
plan tests => 15;

Expand Down

0 comments on commit f3c1d27

Please sign in to comment.