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

(-)a/C4/Acquisition.pm (-1 / +3 lines)
Lines 712-718 sub GetPendingOrders { Link Here
712
    my $strsth = "
712
    my $strsth = "
713
        SELECT    ".($grouped?"count(*),":"")."aqbasket.basketno,
713
        SELECT    ".($grouped?"count(*),":"")."aqbasket.basketno,
714
                    surname,firstname,aqorders.*,biblio.*,biblioitems.isbn,
714
                    surname,firstname,aqorders.*,biblio.*,biblioitems.isbn,
715
                    aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname
715
                    aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname,
716
                    (SELECT count(*) FROM aqorders_items WHERE aqorders_items.ordernumber=aqorders.ordernumber) AS items
716
        FROM      aqorders
717
        FROM      aqorders
717
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
718
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
718
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
719
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
Lines 1266-1271 sub GetParcel { Link Here
1266
                aqorders.listprice,
1267
                aqorders.listprice,
1267
                aqorders.rrp,
1268
                aqorders.rrp,
1268
                aqorders.ecost,
1269
                aqorders.ecost,
1270
                aqorders.freight,
1269
                biblio.title
1271
                biblio.title
1270
        FROM aqorders
1272
        FROM aqorders
1271
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1273
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
(-)a/C4/Budgets.pm (-47 / +22 lines)
Lines 39-46 BEGIN { Link Here
39
	    &AddBudget
39
	    &AddBudget
40
        &ModBudget
40
        &ModBudget
41
        &DelBudget
41
        &DelBudget
42
        &GetBudgetSpent
43
        &GetBudgetOrdered
44
        &GetPeriodsCount
42
        &GetPeriodsCount
45
        &GetChildBudgetsSpent
43
        &GetChildBudgetsSpent
46
44
Lines 300-337 sub ModBudgetPlan { Link Here
300
}
298
}
301
299
302
# -------------------------------------------------------------------
300
# -------------------------------------------------------------------
303
sub GetBudgetSpent {
304
	my ($budget_id) = @_;
305
	my $dbh = C4::Context->dbh;
306
	my $sth = $dbh->prepare(qq|
307
        SELECT SUM( COALESCE(unitprice, ecost) * quantity ) AS sum FROM aqorders
308
            WHERE budget_id = ? AND
309
            quantityreceived > 0 AND
310
            datecancellationprinted IS NULL
311
    |);
312
313
	$sth->execute($budget_id);
314
	my $sum =  $sth->fetchrow_array;
315
	return $sum;
316
}
317
318
# -------------------------------------------------------------------
319
sub GetBudgetOrdered {
320
	my ($budget_id) = @_;
321
	my $dbh = C4::Context->dbh;
322
	my $sth = $dbh->prepare(qq|
323
        SELECT SUM(ecost *  quantity) AS sum FROM aqorders
324
            WHERE budget_id = ? AND
325
            quantityreceived = 0 AND
326
            datecancellationprinted IS NULL
327
    |);
328
329
	$sth->execute($budget_id);
330
	my $sum =  $sth->fetchrow_array;
331
	return $sum;
332
}
333
334
# -------------------------------------------------------------------
335
sub GetBudgetAuthCats  {
301
sub GetBudgetAuthCats  {
336
    my ($budget_period_id) = shift;
302
    my ($budget_period_id) = shift;
337
    # now, populate the auth_cats_loop used in the budget planning button
303
    # now, populate the auth_cats_loop used in the budget planning button
Lines 431-444 sub ModBudgetPeriod { Link Here
431
}
397
}
432
398
433
# -------------------------------------------------------------------
399
# -------------------------------------------------------------------
400
my $AQORDERS_CUMULATIVE_SUBQUERY = <<EOQ;
401
SELECT SUM( COALESCE(unitprice, ecost) * COALESCE(quantityreceived, 0)
402
          + CASE WHEN quantityreceived > 0 THEN COALESCE(freight, 0)
403
                 ELSE 0
404
            END ) AS budget_spent,
405
       SUM( CASE WHEN quantityreceived > 0 THEN 0
406
                 ELSE ecost * quantity + COALESCE(freight, 0)
407
            END ) AS budget_ordered,
408
       budget_id
409
FROM aqorders GROUP BY budget_id
410
EOQ
434
sub GetBudgetHierarchy {
411
sub GetBudgetHierarchy {
435
    my ( $budget_period_id, $branchcode, $owner ) = @_;
412
    my ( $budget_period_id, $branchcode, $owner ) = @_;
436
    my @bind_params;
413
    my @bind_params;
437
    my $dbh   = C4::Context->dbh;
414
    my $dbh   = C4::Context->dbh;
438
    my $query = qq|
415
    my $query = qq|
439
                    SELECT aqbudgets.*, aqbudgetperiods.budget_period_active
416
                    SELECT aqbudgets.*, aqbudgetperiods.budget_period_active, aqord.budget_spent, aqord.budget_ordered
440
                    FROM aqbudgets 
417
                    FROM aqbudgets 
441
                    JOIN aqbudgetperiods USING (budget_period_id)|;
418
                    JOIN aqbudgetperiods USING (budget_period_id)
419
                    LEFT OUTER JOIN ( $AQORDERS_CUMULATIVE_SUBQUERY ) aqord USING (budget_id)
420
                |;
442
                        
421
                        
443
	my @where_strings;
422
	my @where_strings;
444
    # show only period X if requested
423
    # show only period X if requested
Lines 548-565 sub GetBudgetHierarchy { Link Here
548
        $moo =~ s/\ /\&nbsp\;/g;
527
        $moo =~ s/\ /\&nbsp\;/g;
549
        $r->{'budget_name_indent'} = $moo;
528
        $r->{'budget_name_indent'} = $moo;
550
529
551
        $r->{'budget_spent'}       = GetBudgetSpent( $r->{'budget_id'} );
552
553
        $r->{'budget_amount_total'} =  $r->{'budget_amount'};
530
        $r->{'budget_amount_total'} =  $r->{'budget_amount'};
554
531
555
        # foreach sub-levels
556
        my $unalloc_count ;
557
558
		foreach my $sub (@subs_arr) {
532
		foreach my $sub (@subs_arr) {
559
			my $sub_budget = GetBudget($sub);
533
			my $sub_budget = GetBudget($sub);
560
534
561
			$r->{budget_spent_sublevel} +=    GetBudgetSpent( $sub_budget->{'budget_id'} );
535
			$r->{budget_spent_sublevel} += $sub_budget->{'budget_spent'};
562
			$unalloc_count +=   $sub_budget->{'budget_amount'};
563
		}
536
		}
564
	}
537
	}
565
	return \@sort;
538
	return \@sort;
Lines 603-608 sub GetBudget { Link Here
603
    my $query = "
576
    my $query = "
604
        SELECT *
577
        SELECT *
605
        FROM   aqbudgets
578
        FROM   aqbudgets
579
        LEFT OUTER JOIN ( $AQORDERS_CUMULATIVE_SUBQUERY ) aqord USING (budget_id)
606
        WHERE  budget_id=?
580
        WHERE  budget_id=?
607
        ";
581
        ";
608
    my $sth = $dbh->prepare($query);
582
    my $sth = $dbh->prepare($query);
Lines 626-639 sub GetChildBudgetsSpent { Link Here
626
    my $query = "
600
    my $query = "
627
        SELECT *
601
        SELECT *
628
        FROM   aqbudgets
602
        FROM   aqbudgets
629
        WHERE  budget_parent_id=?
603
        LEFT OUTER JOIN ( $AQORDERS_CUMULATIVE_SUBQUERY ) aqord USING (budget_id)
604
        WHERE  budget_id=? OR budget_parent_id=?
630
        ";
605
        ";
631
    my $sth = $dbh->prepare($query);
606
    my $sth = $dbh->prepare($query);
632
    $sth->execute( $budget_id );
607
    $sth->execute( $budget_id, $budget_id, );
633
    my $result = $sth->fetchall_arrayref({});
608
    my $result = $sth->fetchall_arrayref({});
634
    my $total_spent = GetBudgetSpent($budget_id);
609
    my $total_spent = 0;
635
    if ($result){
610
    if ($result){
636
        $total_spent += GetChildBudgetsSpent($_->{"budget_id"}) foreach @$result;    
611
        $total_spent += $_->{"budget_spent"} foreach @$result;    
637
    }
612
    }
638
    return $total_spent;
613
    return $total_spent;
639
}
614
}
(-)a/acqui/acqui-home.pl (-2 lines)
Lines 110-117 foreach my $budget ( @{$budget_arr} ) { Link Here
110
        $budget->{budget_amount} = 0;
110
        $budget->{budget_amount} = 0;
111
    }
111
    }
112
112
113
    $budget->{'budget_ordered'} = GetBudgetOrdered( $budget->{'budget_id'} );
114
    $budget->{'budget_spent'}   = GetBudgetSpent( $budget->{'budget_id'} );
115
    if ( !defined $budget->{budget_spent} ) {
113
    if ( !defined $budget->{budget_spent} ) {
116
        $budget->{budget_spent} = 0;
114
        $budget->{budget_spent} = 0;
117
    }
115
    }
(-)a/acqui/addorder.pl (+3 lines)
Lines 103-108 budget_id used to pay this order. Link Here
103
103
104
=item C<cost>
104
=item C<cost>
105
105
106
=item C<freight>
107
106
=item C<sub>
108
=item C<sub>
107
109
108
=item C<invoice>
110
=item C<invoice>
Lines 174-179 $orderinfo->{'uncertainprice'} ||= 0; Link Here
174
#my $gst           = $input->param('GST');
176
#my $gst           = $input->param('GST');
175
#my $budget        = $input->param('budget');
177
#my $budget        = $input->param('budget');
176
#my $cost          = $input->param('cost');
178
#my $cost          = $input->param('cost');
179
#my $freight       = $input->param('freight');
177
#my $sub           = $input->param('sub');
180
#my $sub           = $input->param('sub');
178
#my $purchaseorder = $input->param('purchaseordernumber');
181
#my $purchaseorder = $input->param('purchaseordernumber');
179
#my $invoice       = $input->param('invoice');
182
#my $invoice       = $input->param('invoice');
(-)a/acqui/basket.pl (-14 / +27 lines)
Lines 234-245 if ( $op eq 'delete_confirm' ) { Link Here
234
	my $total_rrp_gste; # RRP Total, GST excluded
234
	my $total_rrp_gste; # RRP Total, GST excluded
235
	my $gist_rrp;
235
	my $gist_rrp;
236
	my $total_rrp_est;
236
	my $total_rrp_est;
237
	my $total_freight;
238
	my $total_freight_gsti; # Freight Total, GST included
239
	my $total_freight_gste; # Freight Total, GST excluded
240
	my $gist_freight;
237
	
241
	
238
    my $qty_total;
242
    my $qty_total;
239
    my @books_loop;
243
    my @books_loop;
240
244
241
    for my $order ( @results ) {
245
    for my $order ( @results ) {
242
        my $rrp = $order->{'listprice'} || 0;
243
		my $qty = $order->{'quantity'} || 0;
246
		my $qty = $order->{'quantity'} || 0;
244
        if (!defined $order->{quantityreceived}) {
247
        if (!defined $order->{quantityreceived}) {
245
            $order->{quantityreceived} = 0;
248
            $order->{quantityreceived} = 0;
Lines 251-260 if ( $op eq 'delete_confirm' ) { Link Here
251
        }
254
        }
252
255
253
        my $budget = GetBudget(  $order->{'budget_id'} );
256
        my $budget = GetBudget(  $order->{'budget_id'} );
254
        $rrp = ConvertCurrency( $order->{'currency'}, $rrp );
255
257
256
        $total_rrp += $qty * $order->{'rrp'};
258
        $total_rrp += $qty * $order->{'rrp'};
257
        my $line_total = $qty * $order->{'ecost'};
259
        $total_freight += $order->{'freight'} || 0;
260
        my $line_total = $qty * $order->{'ecost'} + $order->{'freight'} || 0;
258
        $total_rrp_est += $qty * $order->{'ecost'};
261
        $total_rrp_est += $qty * $order->{'ecost'};
259
		# FIXME: what about the "actual cost" field?
262
		# FIXME: what about the "actual cost" field?
260
        $qty_total += $qty;
263
        $qty_total += $qty;
Lines 285-295 if ( $op eq 'delete_confirm' ) { Link Here
285
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
288
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
286
        $line{holds}                = $holds;
289
        $line{holds}                = $holds;
287
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
290
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
288
        $line{order_received}       = ( $qty == $order->{'quantityreceived'} );
291
        $line{order_received}       = ( $qty == $order->{quantityreceived} );
289
        $line{basketno}             = $basketno;
292
        $line{basketno}             = $basketno;
290
        $line{budget_name}          = $budget->{budget_name};
293
        $line{budget_name}          = $budget->{budget_name};
291
        $line{rrp}                  = sprintf( "%.2f", $line{'rrp'} );
294
        $line{rrp}                  = sprintf( "%.2f", $line{rrp} );
292
        $line{ecost}                = sprintf( "%.2f", $line{'ecost'} );
295
        $line{ecost}                = sprintf( "%.2f", $line{ecost} );
296
        $line{freight}              = sprintf( "%.2f", $line{freight} );
293
        $line{line_total}           = sprintf( "%.2f", $line_total );
297
        $line{line_total}           = sprintf( "%.2f", $line_total );
294
        if ($line{uncertainprice}) {
298
        if ($line{uncertainprice}) {
295
            $template->param( uncertainprices => 1 );
299
            $template->param( uncertainprices => 1 );
Lines 314-332 my $total_est_gste; Link Here
314
           $total_rrp_gsti = $total_rrp;                           # we know $total_rrp_gsti
318
           $total_rrp_gsti = $total_rrp;                           # we know $total_rrp_gsti
315
           $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 );      # and can reverse compute other values
319
           $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 );      # and can reverse compute other values
316
           $gist_rrp       = $total_rrp_gsti - $total_rrp_gste;    #
320
           $gist_rrp       = $total_rrp_gsti - $total_rrp_gste;    #
317
           $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount );
321
           $total_freight_gsti = $total_freight;
318
           $total_est_gsti = $total_rrp_est;
322
           $total_freight_gste = $total_freight_gsti / ( $gist + 1 );
323
           $gist_freight       = $total_freight_gsti - $total_freight_gste;    #
324
           $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount ) + $total_freight_gste;
325
           $total_est_gsti = $total_rrp_est + $total_freight_gsti;
319
        } else {                                                    # if prices does not include GST
326
        } else {                                                    # if prices does not include GST
320
           $total_rrp_gste = $total_rrp;                           # then we use the common way to compute other values
327
           $total_rrp_gste = $total_rrp;                           # then we use the common way to compute other values
321
           $gist_rrp       = $total_rrp_gste * $gist;              #
328
           $gist_rrp       = $total_rrp_gste * $gist;              #
322
           $total_rrp_gsti = $total_rrp_gste + $gist_rrp;          #
329
           $total_rrp_gsti = $total_rrp_gste + $gist_rrp;          #
323
           $total_est_gste = $total_rrp_est;
330
           $total_freight_gste = $total_freight;
324
           $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount );
331
           $gist_freight       = $total_freight_gste * $gist;
332
           $total_freight_gsti = $total_freight_gste + $gist_freight;
333
           $total_est_gste = $total_rrp_est + $total_freight_gste;
334
           $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount ) + $total_freight_gsti;
325
       }
335
       }
326
       $gist_est = $gist_rrp - ( $gist_rrp * $discount );
336
       $gist_est = $gist_rrp - ( $gist_rrp * $discount ) + $gist_freight;
327
    } else {
337
    } else {
328
    $total_rrp_gsti = $total_rrp;
338
    $total_rrp_gsti = $total_rrp;
329
    $total_est_gsti = $total_rrp_est;
339
    $total_freight_gsti = $total_freight;
340
    $total_est_gsti = $total_rrp_est + $total_freight_gsti;
330
}
341
}
331
342
332
    my $contract = &GetContract($basket->{contractnumber});
343
    my $contract = &GetContract($basket->{contractnumber});
Lines 361-373 my $total_est_gste; Link Here
361
        books_loop           => \@books_loop,
372
        books_loop           => \@books_loop,
362
        gist_rate            => sprintf( "%.2f", $gist * 100 ) . '%',
373
        gist_rate            => sprintf( "%.2f", $gist * 100 ) . '%',
363
        total_rrp_gste       => sprintf( "%.2f", $total_rrp_gste ),
374
        total_rrp_gste       => sprintf( "%.2f", $total_rrp_gste ),
375
        total_freight_gste   => sprintf( "%.2f", $total_freight_gste ),
364
        total_est_gste       => sprintf( "%.2f", $total_est_gste ),
376
        total_est_gste       => sprintf( "%.2f", $total_est_gste ),
365
        gist_est             => sprintf( "%.2f", $gist_est ),
377
        gist_est             => sprintf( "%.2f", $gist_est ),
366
        gist_rrp             => sprintf( "%.2f", $gist_rrp ),        
378
        gist_rrp             => sprintf( "%.2f", $gist_rrp ),        
379
        gist_freight         => sprintf( "%.2f", $gist_freight ),        
367
        total_rrp_gsti       => sprintf( "%.2f", $total_rrp_gsti ),
380
        total_rrp_gsti       => sprintf( "%.2f", $total_rrp_gsti ),
381
        total_freight_gsti   => sprintf( "%.2f", $total_freight_gsti ),
368
        total_est_gsti       => sprintf( "%.2f", $total_est_gsti ),
382
        total_est_gsti       => sprintf( "%.2f", $total_est_gsti ),
369
#        currency             => $bookseller->{'listprice'},
383
	    currency		=> $cur->{'currency'},
370
	currency		=> $cur->{'currency'},
371
        qty_total            => $qty_total,
384
        qty_total            => $qty_total,
372
        GST                  => $gist,
385
        GST                  => $gist,
373
        basketgroups         => $basketgroups,
386
        basketgroups         => $basketgroups,
(-)a/acqui/neworderempty.pl (+1 lines)
Lines 384-389 $template->param( Link Here
384
    quantityrec      => $data->{'quantity'},
384
    quantityrec      => $data->{'quantity'},
385
    rrp              => $data->{'rrp'},
385
    rrp              => $data->{'rrp'},
386
    listprice        => sprintf("%.2f", $data->{'listprice'}||$data->{'price'}||$listprice),
386
    listprice        => sprintf("%.2f", $data->{'listprice'}||$data->{'price'}||$listprice),
387
    freight          => sprintf("%.2f", $data->{'freight'}||0),
387
    total            => sprintf("%.2f", ($data->{'ecost'}||0)*($data->{'quantity'}||0) ),
388
    total            => sprintf("%.2f", ($data->{'ecost'}||0)*($data->{'quantity'}||0) ),
388
    ecost            => $data->{'ecost'},
389
    ecost            => $data->{'ecost'},
389
    unitprice        => sprintf("%.2f", $data->{'unitprice'}),
390
    unitprice        => sprintf("%.2f", $data->{'unitprice'}),
(-)a/acqui/parcel.pl (-27 / +22 lines)
Lines 166-204 my @loop_received = (); Link Here
166
for (my $i = 0 ; $i < $countlines ; $i++) {
166
for (my $i = 0 ; $i < $countlines ; $i++) {
167
167
168
    #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre)
168
    #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre)
169
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};    #weird, are the freight fees counted by book? (pierre)
169
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'} + $parcelitems[$i]->{'freight'};
170
    $parcelitems[$i]->{'unitprice'} += 0;
170
    $parcelitems[$i]->{'unitprice'} += 0;
171
    my %line;
171
    my %line;
172
    %line          = %{ $parcelitems[$i] };
172
    %line          = %{ $parcelitems[$i] };
173
    $line{invoice} = $invoice;
173
    $line{invoice} = $invoice;
174
    $line{gst}     = $gst;
174
    $line{gst}     = $gst;
175
    $line{freight} = sprintf($cfstr, $line{freight});
175
    $line{total} = sprintf($cfstr, $total);
176
    $line{total} = sprintf($cfstr, $total);
176
    $line{supplierid} = $supplierid;
177
    $line{supplierid} = $supplierid;
177
    push @loop_received, \%line;
178
    push @loop_received, \%line;
178
    $totalprice += $parcelitems[$i]->{'unitprice'};
179
    $totalprice += $parcelitems[$i]->{'unitprice'};
179
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
180
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
180
181
181
    #double FIXME - totalfreight is redefined later.
182
    $totalfreight  += $parcelitems[$i]->{'freight'};
182
183
# FIXME - each order in a  parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget..
184
    if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) {
185
        warn "FREIGHT CHARGE MISMATCH!!";
186
    }
187
    $totalfreight = $parcelitems[$i]->{'freight'};
188
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
183
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
189
    $tototal       += $total;
184
    $tototal       += $total;
190
}
185
}
191
186
192
my $pendingorders = GetPendingOrders($supplierid);
187
my $pendingorders = GetPendingOrders($supplierid);
193
my $countpendings = scalar @$pendingorders;
188
my $countpendingitems = 0;
189
if ($pendingorders) {
190
    $countpendingitems += $_->{quantity} || 1 foreach @$pendingorders;
191
}
192
my $freight_per_item = $freight && $countpendingitems ? $freight/$countpendingitems : 0;
194
193
195
# pending orders totals
194
# pending orders totals
196
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
195
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
197
my $ordergrandtotal;
196
my $ordergrandtotal;
198
my @loop_orders = ();
197
my @loop_orders = ();
199
for (my $i = 0 ; $i < $countpendings ; $i++) {
198
for (my $i = $startfrom; $i < $startfrom + $resultsperpage; $i++) {
200
    my %line;
199
    last unless $pendingorders->[$i];
201
    %line = %{$pendingorders->[$i]};
200
    my %line = %{$pendingorders->[$i]};
202
   
201
   
203
    $line{quantity}+=0;
202
    $line{quantity}+=0;
204
    $line{quantityreceived}+=0;
203
    $line{quantityreceived}+=0;
Lines 210-220 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
210
    $line{ecost} = sprintf("%.2f",$line{ecost});
209
    $line{ecost} = sprintf("%.2f",$line{ecost});
211
    $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
210
    $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
212
    $line{unitprice} = sprintf("%.2f",$line{unitprice});
211
    $line{unitprice} = sprintf("%.2f",$line{unitprice});
212
    $line{freight} = sprintf("%.2f",$freight_per_item * $line{quantity});
213
    $line{invoice} = $invoice;
213
    $line{invoice} = $invoice;
214
    $line{gst} = $gst;
214
    $line{gst} = $gst;
215
    $line{total} = $total;
215
    $line{total} = $total;
216
    $line{supplierid} = $supplierid;
216
    $line{supplierid} = $supplierid;
217
    $ordergrandtotal += $line{ecost} * $line{quantity};
217
    $ordergrandtotal += $line{ecost} * $line{quantity} + $line{freight} || 0;
218
    
218
    
219
    my $biblionumber = $line{'biblionumber'};
219
    my $biblionumber = $line{'biblionumber'};
220
    my $countbiblio = CountBiblioInOrders($biblionumber);
220
    my $countbiblio = CountBiblioInOrders($biblionumber);
Lines 244-265 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
244
    $line{holds}                = $holds;
244
    $line{holds}                = $holds;
245
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
245
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
246
    
246
    
247
    
247
    push @loop_orders, \%line;
248
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
249
}
248
}
250
$freight = $totalfreight unless $freight;
251
249
252
my $count = $countpendings;
250
my $countpendings = $pendingorders ? scalar (@$pendingorders) : 0;
253
251
254
if ($count>$resultsperpage){
252
if ($countpendings>$resultsperpage){
255
    my $displaynext=0;
253
    my $displaynext=0;
256
    my $displayprev=$startfrom;
254
    my $displayprev=$startfrom;
257
    if(($count - ($startfrom+$resultsperpage)) > 0 ) {
255
    if(($countpendings - ($startfrom+$resultsperpage)) > 0 ) {
258
        $displaynext = 1;
256
        $displaynext = 1;
259
    }
257
    }
260
258
261
    my @numbers = ();
259
    my @numbers = ();
262
    for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
260
    for (my $i=1; $i<$countpendings/$resultsperpage+1; $i++) {
263
            my $highlight=0;
261
            my $highlight=0;
264
            ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
262
            ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
265
            push @numbers, { number => $i,
263
            push @numbers, { number => $i,
Lines 269-290 if ($count>$resultsperpage){ Link Here
269
267
270
    my $from = $startfrom*$resultsperpage+1;
268
    my $from = $startfrom*$resultsperpage+1;
271
    my $to;
269
    my $to;
272
    if($count < (($startfrom+1)*$resultsperpage)){
270
    if($countpendings < (($startfrom+1)*$resultsperpage)){
273
        $to = $count;
271
        $to = $countpendings;
274
    } else {
272
    } else {
275
        $to = (($startfrom+1)*$resultsperpage);
273
        $to = (($startfrom+1)*$resultsperpage);
276
    }
274
    }
277
    $template->param(numbers=>\@numbers,
275
    $template->param(numbers=>\@numbers,
278
                     displaynext=>$displaynext,
276
                     displaynext=>$displaynext,
279
                     displayprev=>$displayprev,
277
                     displayprev=>$displayprev,
280
                     nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
278
                     nextstartfrom=>(($startfrom+$resultsperpage<$countpendings)?$startfrom+$resultsperpage:$countpendings),
281
                     prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
279
                     prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
282
                    );
280
                    );
283
}
281
}
284
282
285
#$totalfreight=$freight;
286
$tototal = $tototal + $freight;
287
288
$template->param(
283
$template->param(
289
    invoice               => $invoice,
284
    invoice               => $invoice,
290
    datereceived          => $datereceived->output('iso'),
285
    datereceived          => $datereceived->output('iso'),
Lines 300-306 $template->param( Link Here
300
    countpending          => $countpendings,
295
    countpending          => $countpendings,
301
    loop_orders           => \@loop_orders,
296
    loop_orders           => \@loop_orders,
302
    totalprice            => sprintf($cfstr, $totalprice),
297
    totalprice            => sprintf($cfstr, $totalprice),
303
    totalfreight          => $totalfreight,
298
    totalfreight          => sprintf($cfstr, $totalfreight),
304
    totalquantity         => $totalquantity,
299
    totalquantity         => $totalquantity,
305
    tototal               => sprintf($cfstr, $tototal),
300
    tototal               => sprintf($cfstr, $tototal),
306
    ordergrandtotal       => sprintf($cfstr, $ordergrandtotal),
301
    ordergrandtotal       => sprintf($cfstr, $ordergrandtotal),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (+6 lines)
Lines 203-208 Link Here
203
                        <th>RRP</th>
203
                        <th>RRP</th>
204
                        <th>Est.</th>
204
                        <th>Est.</th>
205
                        <th>Qty.</th>
205
                        <th>Qty.</th>
206
                        <th>Shipping</th>
206
                        <th>Total</th>
207
                        <th>Total</th>
207
                        <th>Fund</th>
208
                        <th>Fund</th>
208
                        [% IF ( active ) %]
209
                        [% IF ( active ) %]
Lines 220-225 Link Here
220
                    <th>[% total_rrp_gste %]</th>
221
                    <th>[% total_rrp_gste %]</th>
221
                    <th>&nbsp;</th>
222
                    <th>&nbsp;</th>
222
                    <th>[% qty_total %]</th>
223
                    <th>[% qty_total %]</th>
224
                    <th>[% total_freight_gste %]</th>
223
                    <th>[% total_est_gste %]</th>
225
                    <th>[% total_est_gste %]</th>
224
                        [% IF ( active ) %]
226
                        [% IF ( active ) %]
225
                            [% IF ( closedate ) %]
227
                            [% IF ( closedate ) %]
Lines 234-239 Link Here
234
                    <th>[% gist_rrp %]</th>
236
                    <th>[% gist_rrp %]</th>
235
                    <th>&nbsp;</th>
237
                    <th>&nbsp;</th>
236
                    <th>&nbsp;</th>
238
                    <th>&nbsp;</th>
239
                    <th>[% gist_freight %]</th>
237
                    <th>[% gist_est %]</th>
240
                    <th>[% gist_est %]</th>
238
                </tr>
241
                </tr>
239
                <tr>
242
                <tr>
Lines 241-246 Link Here
241
                    <th>[% total_rrp_gsti %]</th>
244
                    <th>[% total_rrp_gsti %]</th>
242
                    <th>&nbsp;</th>
245
                    <th>&nbsp;</th>
243
                    <th>[% qty_total %]</th>
246
                    <th>[% qty_total %]</th>
247
                    <th>[% total_freight_gsti %]</th>
244
                    <th>[% total_est_gsti %]</th>
248
                    <th>[% total_est_gsti %]</th>
245
                </tr>
249
                </tr>
246
                [% ELSE %]
250
                [% ELSE %]
Lines 249-254 Link Here
249
                    <th>[% total_rrp_gsti %]</th>
253
                    <th>[% total_rrp_gsti %]</th>
250
                    <th>&nbsp;</th>
254
                    <th>&nbsp;</th>
251
                    <th>[% qty_total %]</th>
255
                    <th>[% qty_total %]</th>
256
                    <th>[% total_freight_gsti %]</th>
252
                    <th>[% total_est_gsti %]</th>
257
                    <th>[% total_est_gsti %]</th>
253
                </tr>
258
                </tr>
254
                [% END %]
259
                [% END %]
Lines 269-274 Link Here
269
                        <td class="number">[% books_loo.rrp %]</td>
274
                        <td class="number">[% books_loo.rrp %]</td>
270
                        <td class="number">[% books_loo.ecost %]</td>
275
                        <td class="number">[% books_loo.ecost %]</td>
271
                        <td class="number">[% books_loo.quantity %]</td>
276
                        <td class="number">[% books_loo.quantity %]</td>
277
                        <td class="number">[% books_loo.freight %]</td>
272
                        <td class="number">[% books_loo.line_total %]</td>
278
                        <td class="number">[% books_loo.line_total %]</td>
273
                        <td>[% books_loo.budget_name %]</td>
279
                        <td>[% books_loo.budget_name %]</td>
274
                        [% IF ( active ) %]
280
                        [% IF ( active ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (+6 lines)
Lines 464-469 $(document).ready(function() Link Here
464
                <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" />
464
                <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" />
465
                [% END %]
465
                [% END %]
466
            </li>
466
            </li>
467
            [% IF ( quantityrec ) %]
468
            <li>
469
                <label for="freight">Freight: </label>
470
                <input type="text" id="freight" size="20" name="freight" value="[% freight %]" [% IF close %] readonly="readonly" [% END %]/>
471
            </li>
472
            [% END %]
467
            <li>
473
            <li>
468
                <label for="notes">Notes: </label>
474
                <label for="notes">Notes: </label>
469
                <textarea id="notes" cols="30" rows="3" name="notes" >[% notes %]</textarea>
475
                <textarea id="notes" cols="30" rows="3" name="notes" >[% notes %]</textarea>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-2 / +3 lines)
Lines 82-88 Link Here
82
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
82
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
83
    <input type="hidden" name="supplierid" value="[% supplierid %]" />
83
    <input type="hidden" name="supplierid" value="[% supplierid %]" />
84
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
84
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
85
    <input type="hidden" name="freight" value="[% freight %]" />
86
    <input type="hidden" name="gst" value="[% gst %]" />
85
    <input type="hidden" name="gst" value="[% gst %]" />
87
	</div>
86
	</div>
88
	<div class="yui-u">
87
	<div class="yui-u">
Lines 126-132 Link Here
126
         <input type="text" size="20" name="cost" id="cost" value="[% unitprice %]" />
125
         <input type="text" size="20" name="cost" id="cost" value="[% unitprice %]" />
127
        [% ELSE %]
126
        [% ELSE %]
128
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
127
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
129
        [% END %]</li></ol>
128
        [% END %]</li>
129
        <li><label for="freight">Shipping Cost: </label><input type="text" size="20" name="freight" id="freight" value="[% freight %]" /></li>
130
        </ol>
130
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
131
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
131
        <input type="hidden" name="invoice" value="[% invoice %]" />
132
        <input type="hidden" name="invoice" value="[% invoice %]" />
132
    </fieldset>
133
    </fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-12 / +9 lines)
Lines 213-218 Link Here
213
    	    <th>View Record</th>
213
    	    <th>View Record</th>
214
            <th>Quantity</th>
214
            <th>Quantity</th>
215
            <th>Unit cost</th>
215
            <th>Unit cost</th>
216
            <th>Shipping</th>
216
            <th>Order cost</th>
217
            <th>Order cost</th>
217
            <th>&nbsp;</th>
218
            <th>&nbsp;</th>
218
            <th>&nbsp;</th>
219
            <th>&nbsp;</th>
Lines 222-227 Link Here
222
            <tr><td colspan="4" class="total">TOTAL</td>
223
            <tr><td colspan="4" class="total">TOTAL</td>
223
                <td> [% totalPquantity %] </td>
224
                <td> [% totalPquantity %] </td>
224
				<td>&nbsp;</td>
225
				<td>&nbsp;</td>
226
				<td>&nbsp;</td>
225
                <td>[% ordergrandtotal %]</td>
227
                <td>[% ordergrandtotal %]</td>
226
				<td>&nbsp;</td>
228
				<td>&nbsp;</td>
227
				<td>&nbsp;</td>
229
				<td>&nbsp;</td>
Lines 245-250 Link Here
245
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
247
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
246
                <td>[% loop_order.quantity %]</td>
248
                <td>[% loop_order.quantity %]</td>
247
                <td>[% loop_order.ecost %]</td>
249
                <td>[% loop_order.ecost %]</td>
250
                <td>[% loop_order.freight %]</td>
248
                <td>[% loop_order.ordertotal %]</td>
251
                <td>[% loop_order.ordertotal %]</td>
249
				<td>
252
				<td>
250
				    <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;supplierid=[% loop_order.supplierid %]">Receive</a>
253
				    <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;supplierid=[% loop_order.supplierid %]">Receive</a>
Lines 310-315 Link Here
310
		<th>Quantity</th>  
313
		<th>Quantity</th>  
311
		<th>Est cost</th>
314
		<th>Est cost</th>
312
		<th>Actual cost</th>
315
		<th>Actual cost</th>
316
		<th>Shipping</th>
313
		<th>TOTAL</th>
317
		<th>TOTAL</th>
314
	    </tr>
318
	    </tr>
315
	</thead>
319
	</thead>
Lines 318-335 Link Here
318
		<td colspan="4" class="total">SUBTOTAL</td>
322
		<td colspan="4" class="total">SUBTOTAL</td>
319
		<td colspan="2">&nbsp;</td>
323
		<td colspan="2">&nbsp;</td>
320
		<td>[% totalprice %]</td>
324
		<td>[% totalprice %]</td>
325
		<td>[% totalfreight %]</td>
321
		<td>[% tototal %]</td>
326
		<td>[% tototal %]</td>
322
	    </tr>
327
	    </tr>
323
	      
328
      [% IF ( gst ) %]
324
	      [% IF ( totalfreight ) %]
325
		    <tr>
326
			<td colspan="6">&nbsp;
327
		</td>
328
			    <td>Shipping</td>
329
		<td>[% totalfreight %]</td>
330
	    	</tr> 
331
	    [% END %]
332
	      [% IF ( gst ) %]
333
		    <tr>
329
		    <tr>
334
			<td colspan="6">
330
			<td colspan="6">
335
		<p class="message">
331
		<p class="message">
Lines 340-350 Link Here
340
			    <td><b>Tax rate</b></td>
336
			    <td><b>Tax rate</b></td>
341
		<td>[% gst %]</td>
337
		<td>[% gst %]</td>
342
	    	</tr> 
338
	    	</tr> 
343
	    [% END %]
339
	  [% END %]
344
	    <tr>
340
	    <tr>
345
	    <td colspan="4" class="total">TOTAL</td>
341
	    <td colspan="4" class="total">TOTAL</td>
346
		<td>[% totalquantity %]</td>
342
		<td>[% totalquantity %]</td>
347
		<td colspan="2">&nbsp;</td>
343
		<td colspan="3">&nbsp;</td>
348
		<td>[% grandtot %]</td>
344
		<td>[% grandtot %]</td>
349
	    </tr>
345
	    </tr>
350
    </tfoot>
346
    </tfoot>
Lines 366-371 Link Here
366
                <td>[% loop_receive.quantityreceived %]</td>
362
                <td>[% loop_receive.quantityreceived %]</td>
367
                <td>[% loop_receive.ecost %]</td>
363
                <td>[% loop_receive.ecost %]</td>
368
                <td>[% loop_receive.unitprice %]</td>
364
                <td>[% loop_receive.unitprice %]</td>
365
                <td>[% loop_receive.freight %]</td>
369
                <td>[% loop_receive.total %]</td>
366
                <td>[% loop_receive.total %]</td>
370
            </tr>
367
            </tr>
371
	    [% END %]
368
	    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt (-4 / +2 lines)
Lines 96-106 Link Here
96
            <input type="text" size="20" id="gst" name="gst" />
96
            <input type="text" size="20" id="gst" name="gst" />
97
        </li>
97
        </li>
98
		[% END %]
98
		[% END %]
99
      <!--  // Removing freight input until shipping can be proplerly handled .
100
	  <li>
99
	  <li>
101
            <label for="freight">Shipping:</label>
100
            <label for="freight">Shipping cost:</label>
102
            <input type="text" size="20" id="freight" name="freight" />
101
            <input type="text" size="20" id="freight" name="freight" />
103
        </li> -->
102
        </li>
104
         <li><label for="datereceived">Shipment date: </label>
103
         <li><label for="datereceived">Shipment date: </label>
105
            <input type="text" id="datereceived" name="datereceived"  maxlength="10" size="10"  value="[% datereceived_today %]" />
104
            <input type="text" id="datereceived" name="datereceived"  maxlength="10" size="10"  value="[% datereceived_today %]" />
106
            <img src="[% themelang %]/lib/calendar/cal.gif" id="datereceived_button" alt="Show Calendar" />
105
            <img src="[% themelang %]/lib/calendar/cal.gif" id="datereceived_button" alt="Show Calendar" />
107
- 

Return to bug 6504