@@ -, +, @@ the basket. click on invoices link on left hand side. click on Save button. --- C4/Budgets.pm | 13 ++ C4/Creditnote.pm | 148 ++++++++++++++++++++ acqui/acqui-home.pl | 16 ++- acqui/creditnote.pl | 121 ++++++++++++++++ acqui/editcreditnote.pl | 104 ++++++++++++++ admin/aqbudgets.pl | 15 +- .../prog/en/modules/acqui/acqui-home.tt | 11 +- .../prog/en/modules/acqui/creditnote.tt | 132 +++++++++++++++++ .../prog/en/modules/acqui/editcreditnote.tt | 63 +++++++++ .../prog/en/modules/acqui/invoices.tt | 2 + .../prog/en/modules/admin/aqbudgets.tt | 3 + 11 files changed, 617 insertions(+), 11 deletions(-) create mode 100644 C4/Creditnote.pm create mode 100755 acqui/creditnote.pl create mode 100755 acqui/editcreditnote.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/creditnote.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/editcreditnote.tt --- a/C4/Budgets.pm +++ a/C4/Budgets.pm @@ -41,6 +41,7 @@ BEGIN { &DelBudget &GetBudgetSpent &GetBudgetOrdered + &GetBudgetCredited &GetBudgetName &GetPeriodsCount &GetChildBudgetsSpent @@ -357,6 +358,18 @@ sub GetBudgetOrdered { return $sum; } +# ------------------------------------------------------------------- +sub GetBudgetCredited { + my ($budget_id) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare(qq| + SELECT SUM(amountcredit) AS sum FROM aqcreditnotes + WHERE budget_id = ? + |); + $sth->execute($budget_id); + return $sth->fetchrow_array; +} + =head2 GetBudgetName my $budget_name = &GetBudgetName($budget_id); --- a/C4/Creditnote.pm +++ a/C4/Creditnote.pm @@ -0,0 +1,148 @@ +package C4::Creditnote; + +# This file is part of Koha. +# +# Copyright (C) 2013 Amit Gupta (amitddng135@gmail.com) +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see .. + + +use strict; +use warnings; +use C4::Context; + +use vars qw($VERSION @ISA @EXPORT); + +BEGIN { + # set the version for version checking + $VERSION = 3.07.00.049; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw( + &AddCreditnote &ModCreditnote &Creditnote &ShowCreditnoteid + &DelCreditnote + + ); +} + + +=head3 AddCreditnote + +Create a new creditnote and return its id. + +=cut + +sub AddCreditnote { + my ($booksellerid, $invoiceid, $vendorrefid, $amountcredit, $creditdate, $notes, $budget_id) = @_; + my $dbh = C4::Context->dbh; + my $query = qq| + INSERT INTO aqcreditnotes + (booksellerid, invoiceid, vendorrefid, amountcredit, creditdate, notes, budget_id) + VALUES (?,?,?,?,?,?,?) |; + + my $sth = $dbh->prepare($query); + $sth->execute( $booksellerid,$invoiceid,$vendorrefid,$amountcredit,$creditdate,$notes,$budget_id); +} + +=head3 ModCreditnote + +Modify an creditnote, creditnote_id is mandatory. + +Return undef if it fails. + +=cut + +sub ModCreditnote { + my ($vendorrefid,$amountcredit,$creditdate,$notes,$budget_id,$creditnote_id) = @_; + my $dbh = C4::Context->dbh; + my $query = qq| + UPDATE aqcreditnotes + SET vendorrefid = ?, amountcredit = ?, creditdate = ?, notes = ?, budget_id = ? + WHERE creditnote_id=? + |; + my $sth = $dbh->prepare($query); + $sth->execute($vendorrefid,$amountcredit,$creditdate,$notes,$budget_id,$creditnote_id); +} + +=head3 Creditnote + +Show all results against booksellerid and invoiceid + +=cut + +sub Creditnote { + my ($booksellerid, $invoiceid) = @_; + my $dbh = C4::Context->dbh; + my $query = qq| + SELECT * FROM aqcreditnotes + WHERE booksellerid = ? AND invoiceid = ? + |; + my $sth = $dbh->prepare($query); + my @results; + $sth->execute($booksellerid, $invoiceid); + return $sth->fetchall_arrayref( {} ); +} + +=head3 ShowCreditnoteid + +Show particular result against creditnote_id + +=cut + +sub ShowCreditnoteid { + my ($creditnote_id) = @_; + my $dbh = C4::Context->dbh; + my $query = " + SELECT * FROM aqcreditnotes + WHERE creditnote_id = ? + "; + my $sth=$dbh->prepare($query); + $sth->execute($creditnote_id); + return $sth->fetchrow_hashref; +} + +=head3 DelCreditnote + + &DelCreditnote($creditnote_id,$booksellerid,$invoiceid); + +Deletes the creditnote that has creditnote_id field $creditnote_id in the aqcreditnotes table. + +=over + +=item C<$creditnote_id> is the primary key of the creditnote in the aqcreditnotes table. + +=back + +=cut + +sub DelCreditnote { + my ($creditnote_id,$booksellerid,$invoiceid) = @_; + my $dbh = C4::Context->dbh; + my $query = qq| + DELETE FROM aqcreditnotes + WHERE creditnote_id = ? AND booksellerid = ? AND invoiceid = ? + |; + my $sth = $dbh->prepare($query); + $sth->execute($creditnote_id,$booksellerid,$invoiceid); + $sth->finish; +} + +1; +__END__ + +=head1 AUTHOR + +Amit Gupta + +=cut --- a/acqui/acqui-home.pl +++ a/acqui/acqui-home.pl @@ -85,11 +85,13 @@ my $totspent = 0; my $totordered = 0; my $totcomtd = 0; my $totavail = 0; +my $totcredit = 0; my $total_active = 0; my $totspent_active = 0; my $totordered_active = 0; my $totavail_active = 0; +my $totavail_credit = 0; my @budget_loop; foreach my $budget ( @{$budget_arr} ) { @@ -113,29 +115,35 @@ foreach my $budget ( @{$budget_arr} ) { $budget->{'budget_ordered'} = GetBudgetOrdered( $budget->{'budget_id'} ); $budget->{'budget_spent'} = GetBudgetSpent( $budget->{'budget_id'} ); + $budget->{'budget_credit'} = GetBudgetCredited( $budget->{'budget_id'} ); if ( !defined $budget->{budget_spent} ) { $budget->{budget_spent} = 0; } if ( !defined $budget->{budget_ordered} ) { $budget->{budget_ordered} = 0; } + if ( !defined $budget->{budget_credit} ) { + $budget->{budget_credit} = 0; + } $budget->{'budget_avail'} = - $budget->{'budget_amount'} - ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} ); + ($budget->{'budget_amount'} + $budget->{'budget_credit'})- ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} ); $total += $budget->{'budget_amount'}; $totspent += $budget->{'budget_spent'}; $totordered += $budget->{'budget_ordered'}; $totavail += $budget->{'budget_avail'}; + $totcredit += $budget->{'budget_credit'}; if ($budget->{budget_period_active}){ $total_active += $budget->{'budget_amount'}; $totspent_active += $budget->{'budget_spent'}; $totordered_active += $budget->{'budget_ordered'}; $totavail_active += $budget->{'budget_avail'}; + $totavail_credit += $budget->{'budget_credit'}; } - for my $field (qw( budget_amount budget_spent budget_ordered budget_avail ) ) { - $budget->{"formatted_$field"} = $num_formatter->format_price( $budget->{$field} ); + for my $field (qw( budget_amount budget_spent budget_ordered budget_avail budget_credit ) ) { + $budget->{$field} = $num_formatter->format_price( $budget->{$field} ); } push @budget_loop, $budget; @@ -150,10 +158,12 @@ $template->param( totordered => $num_formatter->format_price($totordered), totcomtd => $num_formatter->format_price($totcomtd), totavail => $num_formatter->format_price($totavail), + totcredit => $num_formatter->format_price($totcredit), total_active => $num_formatter->format_price($total_active), totspent_active => $num_formatter->format_price($totspent_active), totordered_active => $num_formatter->format_price($totordered_active), totavail_active => $num_formatter->format_price($totavail_active), + totavail_credit => $num_formatter->format_price($totavail_credit), suggestions_count => $suggestions_count, ); --- a/acqui/creditnote.pl +++ a/acqui/creditnote.pl @@ -0,0 +1,121 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2013 Amit Gupta (amitddng135@gmail.com) +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +=head1 NAME + +creditnote.pl + +=head1 DESCRIPTION + +creditnote details + +=cut + +use strict; +use warnings; + +use CGI; +use C4::Auth; +use C4::Output; +use C4::Acquisition; +use C4::Bookseller qw/GetBookSellerFromId/; +use C4::Creditnote; +use C4::Budgets; +use C4::Dates qw/format_date format_date_in_iso/; + +my $input = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => 'acqui/creditnote.tmpl', + query => $input, + type => 'intranet', + authnotrequired => 0, + flagsrequired => { 'acquisition' => '*' }, + debug => 1, + } +); + +my $invoiceid = $input->param('invoiceid'); +my $booksellerid = $input->param('booksellerid'); +my $vendorrefid = $input->param('vendorrefid'); +my $amountcredit = $input->param('amountcredit'); +my $budget_id = $input->param('budget_id') || 0; +my $creditdate = C4::Dates->new($input->param('creditdate'))->output('iso'); +my $notes = $input->param('notes'); +my $creditnote_id = $input->param('creditnote_id'); +my $op = $input->param('op'); + +my $details = GetInvoiceDetails($invoiceid); +my $bookseller = GetBookSellerFromId($booksellerid); + +# build budget list +my $budget_loop = []; +my $budgets = GetBudgetHierarchy; +foreach my $r (@{$budgets}) { + push @{$budget_loop}, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_active => $r->{budget_period_active}, + b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, + }; +} + +@{$budget_loop} = + sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop}; + +my $script_name = "/cgi-bin/koha/acqui/creditnote.pl?booksellerid=$booksellerid&invoiceid=$invoiceid"; + +my $results = Creditnote($booksellerid, $invoiceid); +my @creditloop = (); +foreach my $credit (@$results) { + my $budget_name = GetBudget($credit->{'budget_id'}); + push @creditloop, { + creditnote_id => $credit->{'creditnote_id'}, + vendorrefid => $credit->{'vendorrefid'}, + amountcredit => sprintf( "%.2f", $credit->{'amountcredit'}), + creditdate => format_date($credit->{'creditdate'}), + notes => $credit->{'notes'}, + budget => $budget_name->{'budget_name'}, + }; + } + + +if ($op eq 'add'){ + AddCreditnote($booksellerid, $invoiceid, $vendorrefid, $amountcredit, $creditdate, $notes, $budget_id); + print $input->redirect($script_name); + exit; +} + +if ($op eq 'delete'){ + DelCreditnote($creditnote_id,$booksellerid,$invoiceid); + print $input->redirect($script_name); + exit; +} + +$template->param( + invoiceid => $invoiceid, + invoicenumber => $details->{'invoicenumber'}, + suppliername => $bookseller->{'name'}, + booksellerid => $booksellerid, + creditloop => \@creditloop, + budget_loop => $budget_loop, +); + + +output_html_with_http_headers $input, $cookie, $template->output; --- a/acqui/editcreditnote.pl +++ a/acqui/editcreditnote.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2013 Amit Gupta (amitddng135@gmail.com) +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +=head1 NAME + +creditnote.pl + +=head1 DESCRIPTION + +creditnote details + +=cut + +use strict; +use warnings; + +use CGI; +use C4::Auth; +use C4::Output; +use C4::Acquisition; +use C4::Bookseller qw/GetBookSellerFromId/; +use C4::Creditnote; +use C4::Budgets; +use C4::Dates qw/format_date format_date_in_iso/; + +my $input = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => 'acqui/editcreditnote.tmpl', + query => $input, + type => 'intranet', + authnotrequired => 0, + flagsrequired => { 'acquisition' => '*' }, + debug => 1, + } +); + +my $invoiceid = $input->param('invoiceid'); +my $booksellerid = $input->param('booksellerid'); +my $creditnote_id = $input->param('creditnote_id'); +my $vendorrefid = $input->param('vendorrefid'); +my $amountcredit = $input->param('amountcredit'); +my $budget_id = $input->param('budget_id'); +my $creditdate = C4::Dates->new($input->param('creditdate'))->output('iso'); +my $notes = $input->param('notes'); + +my $op = $input->param('op'); + +my $creditdetail = &ShowCreditnoteid($creditnote_id); +my $details = GetInvoiceDetails($invoiceid); +my $bookseller = GetBookSellerFromId($booksellerid); + +# build budget list +my $budget_loop = []; +my $budgets = GetBudgetHierarchy; +foreach my $r (@{$budgets}) { + push @{$budget_loop}, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_active => $r->{budget_period_active}, + b_sel => ( $r->{budget_id} == $creditdetail->{'budget_id'} ) ? 1 : 0, + }; +} + +@{$budget_loop} = + sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop}; + +if ($op eq 'edit'){ + ModCreditnote($vendorrefid, $amountcredit, $creditdate,$notes,$budget_id, $creditnote_id); + print $input->redirect("/cgi-bin/koha/acqui/creditnote.pl?booksellerid=$booksellerid&invoiceid=$invoiceid"); + exit; + } + +$template->param( + invoiceid => $invoiceid, + invoicenumber => $details->{'invoicenumber'}, + suppliername => $bookseller->{'name'}, + booksellerid => $booksellerid, + creditnote_id => $creditnote_id, + amountcredit => sprintf("%.2f",$creditdetail->{'amountcredit'}), + creditdate => format_date($creditdetail->{'creditdate'}), + vendorrefid => $creditdetail->{'vendorrefid'}, + notes => $creditdetail->{'notes'}, + budget_loop => $budget_loop, +); + + +output_html_with_http_headers $input, $cookie, $template->output; --- a/admin/aqbudgets.pl +++ a/admin/aqbudgets.pl @@ -276,14 +276,14 @@ if ($op eq 'add_form') { my $toggle = 0; my @loop; my $period_total = 0; - my ( $period_alloc_total, $base_spent_total ); + my ( $period_alloc_total, $base_spent_total, $base_credit_total); #This Looks WEIRD to me : should budgets be filtered in such a way ppl who donot own it would not see the amount spent on the budget by others ? foreach my $budget (@budgets) { #Level and sublevels total spent $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"}); - + $budget->{'budget_credit'} = GetBudgetCredited($budget->{"budget_id"}); # PERMISSIONS unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) { $budget->{'budget_lock'} = 1; @@ -303,7 +303,8 @@ if ($op eq 'add_form') { # adds to total - only if budget is a 'top-level' budget $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0; $base_spent_total += $budget->{'budget_spent'}; - $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'}; + $base_credit_total += $budget->{'budget_credit'}; + $budget->{'budget_remaining'} = ($budget->{'budget_amount'} + $budget->{'budget_credit'}) - $budget->{'total_levels_spent'}; # if amount == 0 dont display... delete $budget->{'budget_unalloc_sublevel'} @@ -312,12 +313,13 @@ if ($op eq 'add_form') { $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0; $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0; - for (grep {/total_levels_spent|budget_spent|budget_amount|budget_remaining|budget_unalloc/} keys %$budget){ + for (grep {/total_levels_spent|budget_spent|budget_amount|budget_remaining|budget_unalloc|budget_credit/} keys %$budget){ $budget->{$_} = $num->format_price( $budget->{$_} ) if defined($budget->{$_}) } # Value of budget_spent equals 0 instead of undefined value $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"}); + $budget->{"budget_credit"} = $num->format_price(0) unless defined($budget->{"budget_credit"}); my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} ); $budget->{"budget_owner_name"} = $borrower->{'firstname'} . ' ' . $borrower->{'surname'}; @@ -356,12 +358,17 @@ if ($op eq 'add_form') { $base_spent_total = $num->format_price($base_spent_total); } + if ($base_credit_total) { + $base_credit_total = $num->format_price($base_credit_total); + } + $template->param( else => 1, budget => \@loop, budget_period_total => $budget_period_total, period_alloc_total => $period_alloc_total, base_spent_total => $base_spent_total, + base_credit_total => $base_credit_total, branchloop => \@branchloop2, ); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt @@ -118,6 +118,7 @@ $(document).ready(function() { Amount Ordered Spent + Credited Avail @@ -131,6 +132,7 @@ $(document).ready(function() { [% total %][% total_active %] [% totordered %][% totordered_active %] [% totspent %][% totspent_active %] + [% totavail_credit %][% totavail_credit %] [% totavail %][% totavail_active %] @@ -154,10 +156,11 @@ $(document).ready(function() { [% END %] [% loop_budge.budget_branchname %] - [% loop_budge.formatted_budget_amount %] - [% loop_budge.formatted_budget_ordered %] - [% loop_budge.formatted_budget_spent %] - [% loop_budge.formatted_budget_avail %] + [% loop_budge.budget_amount %] + [% loop_budge.budget_ordered %] + [% loop_budge.budget_spent %] + [% loop_budge.budget_credit %] + [% loop_budge.budget_avail %] [% ELSE %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/creditnote.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/creditnote.tt @@ -0,0 +1,132 @@ +[% USE KohaDates %] + +[% INCLUDE 'doc-head-open.inc' %] +Koha › Acquisitions › Invoice +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'calendar.inc' %] + + +[% INCLUDE 'datatables-strings.inc' %] + + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'acquisitions-search.inc' %] + + + + +
+ +
+
+
+ [% IF ( modified ) %] +
+

Invoice has been modified

+
+ [% END %] +

Invoice: [% invoicenumber %]

+

Vendor: [% suppliername %]

+
+ + + +
+
    +
  1. [% invoicenumber %]
  2. +
  3. [% suppliername %]
  4. +
  5. +
  6. +
  7. + +
  8. +
  9. +
  10. +
  11. +
  12. +
  13. + + +
+
+ +
+
+

Credit details

+ [% IF creditloop.size %] + + + + + + + + + + + + + [% FOREACH credit IN creditloop %] + + + + + + + + + + + [% END %] +
Vendor reference idAmount creditCredit dateBudgetNotes
[% credit.vendorrefid %][% credit.amountcredit %][% credit.creditdate %][% credit.budget %][% credit.notes %]EditDelete
+ [% ELSE %] +

No credit details yet

+ [% END %] +
+
+
+ [% INCLUDE 'acquisitions-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/editcreditnote.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/editcreditnote.tt @@ -0,0 +1,63 @@ +[% USE KohaDates %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Acquisitions › Creditnote +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'calendar.inc' %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'acquisitions-search.inc' %] + + + +
+ +
+
+
+

Invoice: [% invoicenumber %]

+

Vendor: [% suppliername %]

+
+ + + + +
+
    +
  1. [% invoicenumber %]
  2. +
  3. [% suppliername %]
  4. +
  5. +
  6. +
  7. + +
  8. +
  9. +
  10. +
  11. +
  12. +
  13. + +
+
+ +
+
+
+
+
+ [% INCLUDE 'acquisitions-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt @@ -45,6 +45,7 @@ $(document).ready(function() { Billing date Received biblios Received items + Creditnote Status   @@ -63,6 +64,7 @@ $(document).ready(function() { [% invoice.receivedbiblios %] [% invoice.receiveditems %] + Credit note [% IF invoice.closedate %] Closed on [% invoice.closedate | $KohaDates %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt @@ -247,6 +247,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Base-level
allocated Base-level
spent Total sublevels
spent + Base-level
credited Base-level
remaining   Actions @@ -259,6 +260,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") [% base_alloc_total %] [% base_spent_total %] [% base_spent_total %] + [% base_credit_total %] [% base_remaining_total %] @@ -278,6 +280,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") [% budge.budget_amount %] [% budge.budget_spent %] [% budge.total_levels_spent %] + [% budge.budget_credit %] [% IF ( budge.remaining_pos ) %] [% ELSIF ( budge.remaining_neg ) %] --