View | Details | Raw Unified | Return to bug 18605
Collapse All | Expand All

(-)a/C4/HoldsQueue.pm (-2 / +2 lines)
Lines 100-106 sub UpdateTransportCostMatrix { Link Here
100
100
101
    my $sth = $dbh->prepare("INSERT INTO transport_cost (frombranch, tobranch, cost, disable_transfer) VALUES (?, ?, ?, ?)");
101
    my $sth = $dbh->prepare("INSERT INTO transport_cost (frombranch, tobranch, cost, disable_transfer) VALUES (?, ?, ?, ?)");
102
102
103
    $dbh->do("TRUNCATE TABLE transport_cost");
103
    $dbh->do("DELETE FROM transport_cost");
104
    foreach (@$records) {
104
    foreach (@$records) {
105
        my $cost = $_->{cost};
105
        my $cost = $_->{cost};
106
        my $from = $_->{frombranch};
106
        my $from = $_->{frombranch};
Lines 109-115 sub UpdateTransportCostMatrix { Link Here
109
            $cost ||= 0;
109
            $cost ||= 0;
110
        }
110
        }
111
        elsif ( !defined ($cost) || ($cost !~ m/(0|[1-9][0-9]*)(\.[0-9]*)?/o) ) {
111
        elsif ( !defined ($cost) || ($cost !~ m/(0|[1-9][0-9]*)(\.[0-9]*)?/o) ) {
112
            warn  "Invalid $from -> $to cost $cost - must be a number >= 0, disablig";
112
            warn  "Invalid $from -> $to cost $cost - must be a number >= 0, disabling";
113
            $cost = 0;
113
            $cost = 0;
114
            $_->{disable_transfer} = 1;
114
            $_->{disable_transfer} = 1;
115
        }
115
        }
(-)a/t/db_dependent/HoldsQueue.t (-2 / +11 lines)
Lines 8-14 Link Here
8
8
9
use Modern::Perl;
9
use Modern::Perl;
10
10
11
use Test::More tests => 43;
11
use Test::More tests => 44;
12
use Data::Dumper;
12
use Data::Dumper;
13
13
14
use C4::Calendar;
14
use C4::Calendar;
Lines 724-729 C4::HoldsQueue::CreateQueue(); Link Here
724
my $queue_rs = $schema->resultset('TmpHoldsqueue');
724
my $queue_rs = $schema->resultset('TmpHoldsqueue');
725
is( $queue_rs->count(), 1, "Hold queue contains one hold from chosen from three possible items" );
725
is( $queue_rs->count(), 1, "Hold queue contains one hold from chosen from three possible items" );
726
726
727
subtest 'Trivial test for UpdateTransportCostMatrix' => sub {
728
    plan tests => 1;
729
    my $recs = [
730
        { frombranch => $library1->{branchcode}, tobranch => $library2->{branchcode} , cost => 1, disable_transfer => 0 },
731
        { frombranch => $library2->{branchcode}, tobranch => $library3->{branchcode}, cost => 0, disable_transfer => 1 },
732
    ];
733
    C4::HoldsQueue::UpdateTransportCostMatrix( $recs );
734
    is( $schema->resultset('TransportCost')->count, 2, 'UpdateTransportCostMatrix added two records' );
735
};
736
727
# Cleanup
737
# Cleanup
728
$schema->storage->txn_rollback;
738
$schema->storage->txn_rollback;
729
739
730
- 

Return to bug 18605