- my ( $spent, $comtd ) = bookfundbreakdown( $results[$i]->{'bookfundid'} );
-
- my $avail = $results[$i]->{'budgetamount'} - ( $spent + $comtd );
- my %line;
- $line{bookfundname} = $results[$i]->{'bookfundname'};
- $line{budgetamount} = $results[$i]->{'budgetamount'};
- $line{bookfundid} = $results[$i]->{'bookfundid'};
- $line{sdate} = $results[$i]->{'startdate'};
- $line{edate} = $results[$i]->{'enddate'};
- $line{aqbudgetid} = $results[$i]->{'aqbudgetid'};
- $line{spent} = sprintf( "%.2f", $spent );
- $line{comtd} = sprintf( "%.2f", $comtd );
- $line{avail} = sprintf( "%.2f", $avail );
- $line{'toggle'} = $toggle;
- push @loop_budget, \%line;
- $total += $results[$i]->{'budgetamount'};
- $totspent += $spent;
- $totcomtd += $comtd;
- $totavail += $avail;
-}
+ if ( !defined $budget->{budget_spent} ) {
+ $budget->{budget_spent} = 0;
+ }
+ if ( !defined $budget->{budget_ordered} ) {
+ $budget->{budget_ordered} = 0;
+ }
+ $budget->{'budget_avail'} =
+ $budget->{'budget_amount'} - ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} );