Bug 15685: (QA follow-up) Address QA issues

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2017-10-10 12:11:14 +00:00 committed by Jonathan Druart
parent aceb989832
commit 04aea91de0
9 changed files with 36 additions and 23 deletions

View File

@ -1590,7 +1590,7 @@ sub CancelReceipt {
my $parent_ordernumber = $order->{'parent_ordernumber'};
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
my $basket = Koha::Acquisition::Order->find( $order->{ordernumber} )->basket;
my $basket = Koha::Acquisition::Orders->find({ordernumber => $ordernumber})->basket;
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) {
# The order line has no parent, just mark it as not received
@ -1604,7 +1604,7 @@ sub CancelReceipt {
};
$sth = $dbh->prepare($query);
$sth->execute(0, undef, undef, $ordernumber);
_cancel_items_receipt( $ordernumber );
_cancel_items_receipt( $basket->effective_create_items, $ordernumber );
} else {
# The order line has a parent, increase parent quantity and delete
# the order line.

View File

@ -109,7 +109,8 @@ Returns the basket associated to the order.
sub basket {
my ( $self ) = @_;
return Koha::Acquisition::Baskets->find( $self->basketno );
my $basket_rs = $self->_result->basketno;
return Koha::Acquisition::Basket->_new_from_dbic( $basket_rs );
}
=head2 Internal methods

View File

@ -797,7 +797,9 @@ sub quote_item {
);
}
if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
my $basket = Koha::Acquisition::Basket->find( $basketno );
if ( $basket->effective_create_item eq 'ordering' ) {
my $new_item = {
notforloan => -1,
cn_sort => q{},

View File

@ -103,8 +103,7 @@ if ($op eq ""){
"allmatch" => $allmatch,
);
import_biblios_list($template, $cgiparams->{'import_batch_id'});
my $basket = GetBasket($cgiparams->{basketno});
if ( $basket->effective_create_items eq 'ordering' && !$basket->{is_standing} ) {
if ( $basket->effective_create_items eq 'ordering' && !$basket->is_standing ) {
# prepare empty item form
my $cell = PrepareItemrecordDisplay( '', '', '', 'ACQ' );
@ -382,8 +381,7 @@ if ($op eq ""){
# 4th, add items if applicable
# parse the item sent by the form, and create an item just for the import_record_id we are dealing with
# this is not optimised, but it's working !
my $basket = GetBasket($cgiparams->{basketno});
if ( $basket->effective_create_items eq 'ordering' && !$basket->{is_standing} ) {
if ( $basket->effective_create_items eq 'ordering' && !$basket->is_standing ) {
my @tags = $input->multi_param('tag');
my @subfields = $input->multi_param('subfield');
my @field_values = $input->multi_param('field_value');

View File

@ -390,7 +390,6 @@ if ( $op eq 'list' ) {
}
$template->param(
basket => $basket,
basketno => $basketno,
basket => $basket,
basketname => $basket->{'basketname'},

View File

@ -31,6 +31,7 @@ use C4::Debug;
use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/;
use C4::Acquisition qw/GetOrdersByBiblionumber/;
use Koha::DateUtils;
use Koha::Acquisition::Baskets;
my $input = new CGI;
my $startdate = $input->param('from');
@ -55,6 +56,16 @@ if ($booksellerid && $basketno) {
$template->param( booksellerid => $booksellerid, basketno => $basketno );
}
my $effective_create_items;
if ( $basketno ){
my $basket = Koha::Acquisition::Baskets->find( $basketno );
if ($basket){
$effective_create_items = $basket->effective_create_items;
} else {
$effective_create_items = C4::Context->preference('AcqCreateItem');
}
}
$startdate = eval { dt_from_string( $startdate ) } if $startdate;
$enddate = eval { dt_from_string( $enddate ) } if $enddate;
@ -84,12 +95,12 @@ $sqldatewhere .= " AND reservedate <= ?";
push @query_params, output_pref({ dt => $enddate, dateformat => 'iso' });
my $include_aqorders_qty =
C4::Context->preference('AcqCreateItem') eq 'receiving'
$effective_create_items eq 'receiving'
? '+ COALESCE(aqorders.quantity, 0) - COALESCE(aqorders.quantityreceived, 0)'
: q{};
my $include_aqorders_qty_join =
C4::Context->preference('AcqCreateItem') eq 'receiving'
$effective_create_items eq 'receiving'
? 'LEFT JOIN aqorders ON reserves.biblionumber=aqorders.biblionumber'
: q{};

View File

@ -1,10 +1,12 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
$dbh->do(q{
ALTER TABLE aqbasket
ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL
});
unless( column_exists('aqbasket','create_items') ){
$dbh->do(q{
ALTER TABLE aqbasket
ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL
});
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 15685: Allow creation of items (AcqCreateItem) to be customizable per-basket)\n";

View File

@ -43,7 +43,7 @@
[% IF ( basketno ) %]
<li>
<input type="hidden" name="basketno" value="[% basketno %]" />
<input type="hidden" name="rs_an_edit" value="1" />
<input type="hidden" name="is_an_edit" value="1" />
</li>
[% END %]
<li>
@ -113,13 +113,13 @@
<label for="create_items">Create items when:</label>
<select name="create_items" id="create_items">
[% SWITCH Koha.Preference('AcqCreateItem') %]
[% CASE 'receiving' %]<option value="">use default (receiving an order).</option>
[% CASE 'cataloguing' %]<option value="">use default (cataloging the record).</option>
[% CASE %]<option value="">use default (placing an order).</option>
[% CASE 'receiving' %]<option value="">use default (receiving an order)</option>
[% CASE 'cataloguing' %]<option value="">use default (cataloging the record)</option>
[% CASE %]<option value="">use default (placing an order)</option>
[% END %]
<option value="ordering">placing an order.</option>
<option value="receiving">receiving an order.</option>
<option value="cataloguing">cataloging the record.</option>
<option value="ordering">placing an order</option>
<option value="receiving">receiving an order</option>
<option value="cataloguing">cataloging the record</option>
</select>
</li>
[% END %]

View File

@ -49,6 +49,7 @@ my $bookseller = Koha::Acquisition::Bookseller->new(
active => 1
}
)->store;
t::lib::Mocks::mock_preference('AcqCreateItem', 'receiving');
my $basketno1 = C4::Acquisition::NewBasket(
$bookseller->id
@ -66,7 +67,6 @@ my $budget = C4::Budgets::GetBudget( $budgetid );
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
my $itemnumber = AddItem( { itype => $itemtype }, $biblionumber );
t::lib::Mocks::mock_preference('AcqCreateItem', 'receiving');
my $order = Koha::Acquisition::Order->new(
{
basketno => $basketno1,