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

(-)a/C4/Budgets.pm (+13 lines)
Lines 41-46 BEGIN { Link Here
41
        &DelBudget
41
        &DelBudget
42
        &GetBudgetSpent
42
        &GetBudgetSpent
43
        &GetBudgetOrdered
43
        &GetBudgetOrdered
44
        &GetBudgetCredited
44
        &GetBudgetName
45
        &GetBudgetName
45
        &GetPeriodsCount
46
        &GetPeriodsCount
46
        &GetChildBudgetsSpent
47
        &GetChildBudgetsSpent
Lines 357-362 sub GetBudgetOrdered { Link Here
357
	return $sum;
358
	return $sum;
358
}
359
}
359
360
361
# -------------------------------------------------------------------
362
sub GetBudgetCredited {
363
	my ($budget_id) = @_;
364
	my $dbh = C4::Context->dbh;
365
	my $sth = $dbh->prepare(qq|
366
        SELECT SUM(amountcredit) AS sum FROM aqcreditnotes
367
            WHERE budget_id = ?
368
    |);
369
	$sth->execute($budget_id);
370
	return $sth->fetchrow_array;
371
}
372
360
=head2 GetBudgetName
373
=head2 GetBudgetName
361
374
362
  my $budget_name = &GetBudgetName($budget_id);
375
  my $budget_name = &GetBudgetName($budget_id);
(-)a/C4/Creditnote.pm (+148 lines)
Line 0 Link Here
1
package C4::Creditnote;
2
3
# This file is part of Koha.
4
#
5
# Copyright (C) 2013 Amit Gupta (amitddng135@gmail.com)
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>..
19
20
21
use strict;
22
use warnings;
23
use C4::Context;
24
25
use vars qw($VERSION @ISA @EXPORT);
26
27
BEGIN {
28
    # set the version for version checking
29
    $VERSION = 3.07.00.049;
30
    require Exporter;
31
    @ISA    = qw(Exporter);
32
    @EXPORT = qw(
33
        &AddCreditnote &ModCreditnote &Creditnote &ShowCreditnoteid
34
        &DelCreditnote
35
36
    );
37
}
38
39
40
=head3 AddCreditnote
41
42
Create a new creditnote and return its id.
43
44
=cut
45
46
sub AddCreditnote {
47
    my ($booksellerid, $invoiceid, $vendorrefid, $amountcredit, $creditdate, $notes, $budget_id)  = @_;
48
    my $dbh = C4::Context->dbh;
49
    my $query = qq|
50
            INSERT INTO aqcreditnotes
51
                (booksellerid, invoiceid, vendorrefid, amountcredit, creditdate, notes, budget_id)
52
            VALUES (?,?,?,?,?,?,?)    |;
53
54
    my $sth = $dbh->prepare($query);
55
    $sth->execute( $booksellerid,$invoiceid,$vendorrefid,$amountcredit,$creditdate,$notes,$budget_id);
56
}
57
58
=head3 ModCreditnote
59
60
Modify an creditnote, creditnote_id is mandatory.
61
62
Return undef if it fails.
63
64
=cut
65
66
sub ModCreditnote {
67
    my ($vendorrefid,$amountcredit,$creditdate,$notes,$budget_id,$creditnote_id) = @_;
68
    my $dbh = C4::Context->dbh;
69
    my $query = qq|
70
        UPDATE aqcreditnotes
71
        SET    vendorrefid = ?, amountcredit = ?, creditdate = ?, notes = ?, budget_id = ?
72
        WHERE  creditnote_id=?
73
        |;
74
    my $sth = $dbh->prepare($query);
75
    $sth->execute($vendorrefid,$amountcredit,$creditdate,$notes,$budget_id,$creditnote_id);
76
}
77
78
=head3 Creditnote
79
80
Show all results against booksellerid and invoiceid
81
82
=cut
83
84
sub Creditnote {
85
    my ($booksellerid, $invoiceid)  = @_;
86
    my $dbh = C4::Context->dbh;
87
    my $query = qq|
88
            SELECT * FROM aqcreditnotes
89
            WHERE booksellerid = ? AND invoiceid = ?
90
                 |;
91
    my $sth = $dbh->prepare($query);
92
    my @results;
93
    $sth->execute($booksellerid, $invoiceid);
94
    return $sth->fetchall_arrayref( {} );
95
}
96
97
=head3 ShowCreditnoteid
98
99
Show particular result against creditnote_id
100
101
=cut
102
103
sub ShowCreditnoteid {
104
    my ($creditnote_id)  = @_;
105
    my $dbh        = C4::Context->dbh;
106
    my $query = "
107
        SELECT * FROM aqcreditnotes
108
        WHERE creditnote_id = ?
109
    ";
110
    my $sth=$dbh->prepare($query);
111
    $sth->execute($creditnote_id);
112
    return $sth->fetchrow_hashref;
113
}
114
115
=head3 DelCreditnote
116
117
  &DelCreditnote($creditnote_id,$booksellerid,$invoiceid);
118
119
Deletes the creditnote that has creditnote_id field $creditnote_id in the aqcreditnotes table.
120
121
=over
122
123
=item C<$creditnote_id> is the primary key of the creditnote in the aqcreditnotes table.
124
125
=back
126
127
=cut
128
129
sub DelCreditnote {
130
    my ($creditnote_id,$booksellerid,$invoiceid) = @_;
131
    my $dbh = C4::Context->dbh;
132
    my $query = qq|
133
            DELETE FROM aqcreditnotes
134
            WHERE creditnote_id = ? AND booksellerid = ? AND invoiceid = ?
135
                 |;
136
    my $sth = $dbh->prepare($query);
137
    $sth->execute($creditnote_id,$booksellerid,$invoiceid);
138
    $sth->finish;
139
}
140
141
1;
142
__END__
143
144
=head1 AUTHOR
145
146
Amit Gupta <amitddng135 AT gmail.com>
147
148
=cut
(-)a/acqui/acqui-home.pl (-3 / +13 lines)
Lines 85-95 my $totspent = 0; Link Here
85
my $totordered = 0;
85
my $totordered = 0;
86
my $totcomtd   = 0;
86
my $totcomtd   = 0;
87
my $totavail   = 0;
87
my $totavail   = 0;
88
my $totcredit = 0;
88
89
89
my $total_active        = 0;
90
my $total_active        = 0;
90
my $totspent_active     = 0;
91
my $totspent_active     = 0;
91
my $totordered_active   = 0;
92
my $totordered_active   = 0;
92
my $totavail_active     = 0;
93
my $totavail_active     = 0;
94
my $totavail_credit     = 0;
93
95
94
my @budget_loop;
96
my @budget_loop;
95
foreach my $budget ( @{$budget_arr} ) {
97
foreach my $budget ( @{$budget_arr} ) {
Lines 113-141 foreach my $budget ( @{$budget_arr} ) { Link Here
113
115
114
    $budget->{'budget_ordered'} = GetBudgetOrdered( $budget->{'budget_id'} );
116
    $budget->{'budget_ordered'} = GetBudgetOrdered( $budget->{'budget_id'} );
115
    $budget->{'budget_spent'}   = GetBudgetSpent( $budget->{'budget_id'} );
117
    $budget->{'budget_spent'}   = GetBudgetSpent( $budget->{'budget_id'} );
118
    $budget->{'budget_credit'}   = GetBudgetCredited( $budget->{'budget_id'} );
116
    if ( !defined $budget->{budget_spent} ) {
119
    if ( !defined $budget->{budget_spent} ) {
117
        $budget->{budget_spent} = 0;
120
        $budget->{budget_spent} = 0;
118
    }
121
    }
119
    if ( !defined $budget->{budget_ordered} ) {
122
    if ( !defined $budget->{budget_ordered} ) {
120
        $budget->{budget_ordered} = 0;
123
        $budget->{budget_ordered} = 0;
121
    }
124
    }
125
    if ( !defined $budget->{budget_credit} ) {
126
        $budget->{budget_credit} = 0;
127
    }
122
    $budget->{'budget_avail'} =
128
    $budget->{'budget_avail'} =
123
      $budget->{'budget_amount'} - ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} );
129
      ($budget->{'budget_amount'} + $budget->{'budget_credit'})- ( $budget->{'budget_spent'} + $budget->{'budget_ordered'} );
124
130
125
    $total      += $budget->{'budget_amount'};
131
    $total      += $budget->{'budget_amount'};
126
    $totspent   += $budget->{'budget_spent'};
132
    $totspent   += $budget->{'budget_spent'};
127
    $totordered += $budget->{'budget_ordered'};
133
    $totordered += $budget->{'budget_ordered'};
128
    $totavail   += $budget->{'budget_avail'};
134
    $totavail   += $budget->{'budget_avail'};
135
    $totcredit   += $budget->{'budget_credit'};
129
136
130
    if ($budget->{budget_period_active}){
137
    if ($budget->{budget_period_active}){
131
	$total_active      += $budget->{'budget_amount'};
138
	$total_active      += $budget->{'budget_amount'};
132
	$totspent_active   += $budget->{'budget_spent'};
139
	$totspent_active   += $budget->{'budget_spent'};
133
	$totordered_active += $budget->{'budget_ordered'};
140
	$totordered_active += $budget->{'budget_ordered'};
134
	$totavail_active   += $budget->{'budget_avail'};    
141
	$totavail_active   += $budget->{'budget_avail'};    
142
	$totavail_credit   += $budget->{'budget_credit'};
135
    }
143
    }
136
144
137
    for my $field (qw( budget_amount budget_spent budget_ordered budget_avail ) ) {
145
    for my $field (qw( budget_amount budget_spent budget_ordered budget_avail budget_credit ) ) {
138
        $budget->{"formatted_$field"} = $num_formatter->format_price( $budget->{$field} );
146
        $budget->{$field} = $num_formatter->format_price( $budget->{$field} );
139
    }
147
    }
140
148
141
    push @budget_loop, $budget;
149
    push @budget_loop, $budget;
Lines 150-159 $template->param( Link Here
150
    totordered    => $num_formatter->format_price($totordered),
158
    totordered    => $num_formatter->format_price($totordered),
151
    totcomtd      => $num_formatter->format_price($totcomtd),
159
    totcomtd      => $num_formatter->format_price($totcomtd),
152
    totavail      => $num_formatter->format_price($totavail),
160
    totavail      => $num_formatter->format_price($totavail),
161
    totcredit   => $num_formatter->format_price($totcredit),
153
    total_active  => $num_formatter->format_price($total_active),
162
    total_active  => $num_formatter->format_price($total_active),
154
    totspent_active     => $num_formatter->format_price($totspent_active),
163
    totspent_active     => $num_formatter->format_price($totspent_active),
155
    totordered_active   => $num_formatter->format_price($totordered_active),
164
    totordered_active   => $num_formatter->format_price($totordered_active),
156
    totavail_active     => $num_formatter->format_price($totavail_active),
165
    totavail_active     => $num_formatter->format_price($totavail_active),
166
    totavail_credit     => $num_formatter->format_price($totavail_credit),
157
    suggestions_count   => $suggestions_count,
167
    suggestions_count   => $suggestions_count,
158
);
168
);
159
169
(-)a/acqui/creditnote.pl (+121 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright (C) 2013 Amit Gupta (amitddng135@gmail.com)
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
=head1 NAME
21
22
creditnote.pl
23
24
=head1 DESCRIPTION
25
26
creditnote details
27
28
=cut
29
30
use strict;
31
use warnings;
32
33
use CGI;
34
use C4::Auth;
35
use C4::Output;
36
use C4::Acquisition;
37
use C4::Bookseller qw/GetBookSellerFromId/;
38
use C4::Creditnote;
39
use C4::Budgets;
40
use C4::Dates qw/format_date format_date_in_iso/;
41
42
my $input = new CGI;
43
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
44
    {
45
        template_name   => 'acqui/creditnote.tmpl',
46
        query           => $input,
47
        type            => 'intranet',
48
        authnotrequired => 0,
49
        flagsrequired   => { 'acquisition' => '*' },
50
        debug           => 1,
51
    }
52
);
53
54
my $invoiceid = $input->param('invoiceid');
55
my $booksellerid = $input->param('booksellerid');
56
my $vendorrefid = $input->param('vendorrefid');
57
my $amountcredit = $input->param('amountcredit');
58
my $budget_id       = $input->param('budget_id') || 0;
59
my $creditdate = C4::Dates->new($input->param('creditdate'))->output('iso');
60
my $notes = $input->param('notes');
61
my $creditnote_id = $input->param('creditnote_id');
62
my $op        = $input->param('op');
63
64
my $details     = GetInvoiceDetails($invoiceid);
65
my $bookseller  = GetBookSellerFromId($booksellerid);
66
67
# build budget list
68
my $budget_loop = [];
69
my $budgets = GetBudgetHierarchy;
70
foreach my $r (@{$budgets}) {
71
    push @{$budget_loop}, {
72
        b_id  => $r->{budget_id},
73
        b_txt => $r->{budget_name},
74
        b_active => $r->{budget_period_active},
75
        b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
76
    };
77
}
78
79
@{$budget_loop} =
80
  sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop};
81
82
my $script_name = "/cgi-bin/koha/acqui/creditnote.pl?booksellerid=$booksellerid&invoiceid=$invoiceid";
83
84
my $results = Creditnote($booksellerid, $invoiceid);
85
my @creditloop = ();
86
foreach my $credit (@$results) {
87
    my $budget_name =  GetBudget($credit->{'budget_id'});
88
            push @creditloop, {
89
            creditnote_id => $credit->{'creditnote_id'},
90
            vendorrefid => $credit->{'vendorrefid'},
91
            amountcredit  => sprintf( "%.2f", $credit->{'amountcredit'}),
92
            creditdate    => format_date($credit->{'creditdate'}),
93
            notes    => $credit->{'notes'},
94
            budget   => $budget_name->{'budget_name'},
95
        };
96
 }
97
98
99
if ($op eq 'add'){
100
    AddCreditnote($booksellerid, $invoiceid, $vendorrefid, $amountcredit, $creditdate, $notes, $budget_id);
101
    print $input->redirect($script_name);
102
    exit;
103
}
104
105
if ($op eq 'delete'){
106
    DelCreditnote($creditnote_id,$booksellerid,$invoiceid);
107
    print $input->redirect($script_name);
108
    exit;
109
}
110
111
$template->param(
112
    invoiceid        => $invoiceid,
113
    invoicenumber    => $details->{'invoicenumber'},
114
    suppliername     => $bookseller->{'name'},
115
    booksellerid     => $booksellerid,
116
    creditloop       => \@creditloop,
117
    budget_loop      => $budget_loop,
118
);
119
120
121
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/editcreditnote.pl (+104 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright (C) 2013 Amit Gupta (amitddng135@gmail.com)
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
=head1 NAME
21
22
creditnote.pl
23
24
=head1 DESCRIPTION
25
26
creditnote details
27
28
=cut
29
30
use strict;
31
use warnings;
32
33
use CGI;
34
use C4::Auth;
35
use C4::Output;
36
use C4::Acquisition;
37
use C4::Bookseller qw/GetBookSellerFromId/;
38
use C4::Creditnote;
39
use C4::Budgets;
40
use C4::Dates qw/format_date format_date_in_iso/;
41
42
my $input = new CGI;
43
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
44
    {
45
        template_name   => 'acqui/editcreditnote.tmpl',
46
        query           => $input,
47
        type            => 'intranet',
48
        authnotrequired => 0,
49
        flagsrequired   => { 'acquisition' => '*' },
50
        debug           => 1,
51
    }
52
);
53
54
my $invoiceid = $input->param('invoiceid');
55
my $booksellerid = $input->param('booksellerid');
56
my $creditnote_id = $input->param('creditnote_id');
57
my $vendorrefid = $input->param('vendorrefid');
58
my $amountcredit = $input->param('amountcredit');
59
my $budget_id    = $input->param('budget_id');
60
my $creditdate = C4::Dates->new($input->param('creditdate'))->output('iso');
61
my $notes = $input->param('notes');
62
63
my $op        = $input->param('op');
64
65
my $creditdetail = &ShowCreditnoteid($creditnote_id);
66
my $details      = GetInvoiceDetails($invoiceid);
67
my $bookseller   = GetBookSellerFromId($booksellerid);
68
69
# build budget list
70
my $budget_loop = [];
71
my $budgets = GetBudgetHierarchy;
72
foreach my $r (@{$budgets}) {
73
    push @{$budget_loop}, {
74
        b_id  => $r->{budget_id},
75
        b_txt => $r->{budget_name},
76
        b_active => $r->{budget_period_active},
77
        b_sel => ( $r->{budget_id} == $creditdetail->{'budget_id'} ) ? 1 : 0,
78
    };
79
}
80
81
@{$budget_loop} =
82
  sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop};
83
84
if ($op eq 'edit'){
85
      ModCreditnote($vendorrefid, $amountcredit, $creditdate,$notes,$budget_id, $creditnote_id);
86
      print $input->redirect("/cgi-bin/koha/acqui/creditnote.pl?booksellerid=$booksellerid&invoiceid=$invoiceid");
87
      exit;
88
    }
89
90
$template->param(
91
    invoiceid        => $invoiceid,
92
    invoicenumber    => $details->{'invoicenumber'},
93
    suppliername     => $bookseller->{'name'},
94
    booksellerid     => $booksellerid,
95
    creditnote_id    => $creditnote_id,
96
    amountcredit => sprintf("%.2f",$creditdetail->{'amountcredit'}),
97
    creditdate   => format_date($creditdetail->{'creditdate'}),
98
    vendorrefid => $creditdetail->{'vendorrefid'},
99
    notes => $creditdetail->{'notes'},
100
    budget_loop      => $budget_loop,
101
);
102
103
104
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/admin/aqbudgets.pl (-4 / +11 lines)
Lines 276-289 if ($op eq 'add_form') { Link Here
276
    my $toggle = 0;
276
    my $toggle = 0;
277
    my @loop;
277
    my @loop;
278
    my $period_total = 0;
278
    my $period_total = 0;
279
    my ( $period_alloc_total, $base_spent_total );
279
    my ( $period_alloc_total, $base_spent_total, $base_credit_total);
280
280
281
	#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 ?
281
	#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 ?
282
282
283
    foreach my $budget (@budgets) {
283
    foreach my $budget (@budgets) {
284
        #Level and sublevels total spent
284
        #Level and sublevels total spent
285
        $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"});
285
        $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"});
286
286
        $budget->{'budget_credit'} = GetBudgetCredited($budget->{"budget_id"});
287
        # PERMISSIONS
287
        # PERMISSIONS
288
        unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
288
        unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
289
            $budget->{'budget_lock'} = 1;
289
            $budget->{'budget_lock'} = 1;
Lines 303-309 if ($op eq 'add_form') { Link Here
303
        # adds to total  - only if budget is a 'top-level' budget
303
        # adds to total  - only if budget is a 'top-level' budget
304
        $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
304
        $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
305
        $base_spent_total += $budget->{'budget_spent'};
305
        $base_spent_total += $budget->{'budget_spent'};
306
        $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'};
306
        $base_credit_total += $budget->{'budget_credit'};
307
        $budget->{'budget_remaining'} = ($budget->{'budget_amount'} + $budget->{'budget_credit'}) - $budget->{'total_levels_spent'};
307
308
308
# if amount == 0 dont display...
309
# if amount == 0 dont display...
309
        delete $budget->{'budget_unalloc_sublevel'}
310
        delete $budget->{'budget_unalloc_sublevel'}
Lines 312-323 if ($op eq 'add_form') { Link Here
312
313
313
        $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
314
        $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
314
        $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
315
        $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
315
		for (grep {/total_levels_spent|budget_spent|budget_amount|budget_remaining|budget_unalloc/} keys %$budget){
316
		for (grep {/total_levels_spent|budget_spent|budget_amount|budget_remaining|budget_unalloc|budget_credit/} keys %$budget){
316
            $budget->{$_}               = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
317
            $budget->{$_}               = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
317
		}
318
		}
318
319
319
        # Value of budget_spent equals 0 instead of undefined value
320
        # Value of budget_spent equals 0 instead of undefined value
320
        $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
321
        $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
322
        $budget->{"budget_credit"} = $num->format_price(0) unless defined($budget->{"budget_credit"});
321
323
322
        my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} );
324
        my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} );
323
        $budget->{"budget_owner_name"}     = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
325
        $budget->{"budget_owner_name"}     = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
Lines 356-367 if ($op eq 'add_form') { Link Here
356
        $base_spent_total = $num->format_price($base_spent_total);
358
        $base_spent_total = $num->format_price($base_spent_total);
357
    }
359
    }
358
360
361
    if ($base_credit_total) {
362
        $base_credit_total = $num->format_price($base_credit_total);
363
    }
364
359
    $template->param(
365
    $template->param(
360
        else                   => 1,
366
        else                   => 1,
361
        budget                 => \@loop,
367
        budget                 => \@loop,
362
        budget_period_total    => $budget_period_total,
368
        budget_period_total    => $budget_period_total,
363
        period_alloc_total     => $period_alloc_total,
369
        period_alloc_total     => $period_alloc_total,
364
        base_spent_total       => $base_spent_total,
370
        base_spent_total       => $base_spent_total,
371
        base_credit_total      => $base_credit_total,
365
        branchloop             => \@branchloop2,
372
        branchloop             => \@branchloop2,
366
    );
373
    );
367
374
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt (-4 / +7 lines)
Lines 118-123 $(document).ready(function() { Link Here
118
            <th>Amount</th>
118
            <th>Amount</th>
119
            <th>Ordered</th>
119
            <th>Ordered</th>
120
            <th>Spent</th>
120
            <th>Spent</th>
121
            <th>Credited</th>
121
            <th>Avail</th>
122
            <th>Avail</th>
122
        </tr>
123
        </tr>
123
        </thead>
124
        </thead>
Lines 131-136 $(document).ready(function() { Link Here
131
            <th class="data"><span class="bu_active">[% total %]</span><span class="bu_inactive" >[% total_active %]</span></th>
132
            <th class="data"><span class="bu_active">[% total %]</span><span class="bu_inactive" >[% total_active %]</span></th>
132
            <th class="data"><span class="bu_active">[% totordered %]</span><span class="bu_inactive" >[% totordered_active %]</span></th>
133
            <th class="data"><span class="bu_active">[% totordered %]</span><span class="bu_inactive" >[% totordered_active %]</span></th>
133
            <th class="data"><span class="bu_active">[% totspent %]</span><span class="bu_inactive" >[% totspent_active %]</span></th>
134
            <th class="data"><span class="bu_active">[% totspent %]</span><span class="bu_inactive" >[% totspent_active %]</span></th>
135
            <th class="data"><span class="bu_active">[% totavail_credit %]</span><span class="bu_inactive" >[% totavail_credit %]</span></th>
134
            <th class="data"><span class="bu_active">[% totavail %]</span><span class="bu_inactive" >[% totavail_active %]</span></th>
136
            <th class="data"><span class="bu_active">[% totavail %]</span><span class="bu_inactive" >[% totavail_active %]</span></th>
135
        </tr>
137
        </tr>
136
        </tfoot>
138
        </tfoot>
Lines 154-163 $(document).ready(function() { Link Here
154
                    [% END %]
156
                    [% END %]
155
                </td>
157
                </td>
156
                <td>[% loop_budge.budget_branchname %]</td>
158
                <td>[% loop_budge.budget_branchname %]</td>
157
                <td class="data"><span title="[% loop_budge.budget_amount %]">[% loop_budge.formatted_budget_amount %]</span></td>
159
                <td class="data">[% loop_budge.budget_amount %]</td>
158
                <td class="data"><span title="[% loop_budge.budget_ordered %]"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.formatted_budget_ordered %]</a></span></td>
160
                <td class="data"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered %]</a></td>
159
                <td class="data"><span title="[% loop_budge.budget_spent %]"><a href="spent.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.formatted_budget_spent %]</span></a></td>
161
                <td class="data"><a href="spent.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent %]</a></td>
160
                <td class="data"><span title="[% loop_budge.budget_avail %]">[% loop_budge.formatted_budget_avail %]</td>
162
                <td class="data">[% loop_budge.budget_credit %]</td>
163
                <td class="data">[% loop_budge.budget_avail %]</td>
161
            </tr>
164
            </tr>
162
        [% ELSE %]
165
        [% ELSE %]
163
            <tr class="b_inactive">
166
            <tr class="b_inactive">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/creditnote.tt (+132 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'calendar.inc' %]
7
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
8
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
9
[% INCLUDE 'datatables-strings.inc' %]
10
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
11
<script type="text/javascript">
12
//<![CDATA[
13
    function Check(f) {
14
        if ((f.amountcredit.value.length == 0) && (f.budget_id.value.length == 0)) {
15
            alert("Budget and amount is missing");
16
            return false;
17
        } else if (f.amountcredit.value.length == 0) {
18
            alert("Amount is missing");
19
            return false;
20
        } else if (f.budget_id.value.length == 0) {
21
            alert("Budget is missing");
22
            return false;
23
        } else{
24
            document.Aform.submit();
25
        }
26
    }
27
    $(document).ready(function() {
28
        $("#table_credit").dataTable($.extend(true, {}, dataTablesDefaults, {
29
            "aoColumnDefs": [
30
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
31
            ],
32
            "aaSorting": [[ 1, "asc" ]],
33
            "iDisplayLength": 10,
34
            "aLengthMenu": [[2, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
35
        }));
36
    });
37
//]]>
38
</script>
39
</head>
40
41
<body>
42
[% INCLUDE 'header.inc' %]
43
[% INCLUDE 'acquisitions-search.inc' %]
44
45
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/creditnote.pl?booksellerid=[% booksellerid %]&amp;invoiceid=[% invoiceid %]">Credit note</a></div>
46
47
48
<div id="doc3" class="yui-t2">
49
50
<div id="bd">
51
  <div id="yui-main">
52
    <div class="yui-b">
53
      [% IF ( modified ) %]
54
        <div class="dialog message">
55
          <p>Invoice has been modified</p>
56
        </div>
57
      [% END %]
58
      <h1>Invoice: [% invoicenumber %]</h1>
59
      <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% suppliername %]</a></p>
60
        <form action="/cgi-bin/koha/acqui/creditnote.pl" name="Aform" method="post">
61
        <input type="hidden" name="op" value="add" />
62
        <input type="hidden" id="booksellerid" name="booksellerid" value="[% booksellerid %]"/>
63
        <input type="hidden" id="invoiceid" name="invoiceid" value="[% invoiceid %]"/>
64
        <fieldset class="rows">
65
            <ol>
66
            <li><label for="invoicenumber">Invoicenumber:</label>[% invoicenumber %]</li>
67
            <li><label for="suppliername">Vendorname:</label>[% suppliername %]</li>
68
            <li><label for="vendorrefid">Vendor ref. id:</label>
69
            <input type="text" size="30" id="vendorrefid" name="vendorrefid" value="[% vendorrefid %]" /></li>
70
            <li><label class="required" for="budget_id">Fund: </label>
71
                <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
72
                        <option value="">Select a budget</option>
73
                [% FOREACH budget_loo IN budget_loop %]
74
                    [% IF ( budget_loo.b_sel ) %]
75
                        <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
76
                    [% ELSE %]
77
                        [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]">[% budget_loo.b_txt %]</option>
78
                        [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive">[% budget_loo.b_txt %]</option>
79
                        [% END %]
80
                    [% END %]
81
                [% END %]
82
                </select>
83
            </li>
84
            <li><label for="amountcredit">Amount credit:</label>
85
            <input type="text" size="10" id="amountcredit" name="amountcredit" value="[% amountcredit %]" /></li>
86
            <li><label for="creditdate">Date:</label>
87
                    <input type="text" size="10" id="creditdate" name="creditdate" value="[% creditdate | $KohaDates %]" readonly="readonly" class="datepicker" /></li>
88
            <li><label for="notes">Notes: </label><textarea id = "notes" name="notes" width="40" rows="8" >[% notes %]</textarea></li>
89
                      <input type="hidden" name="op" value="mod" />
90
          <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
91
        </fieldset>
92
        <fieldset class="action">
93
            <input type="submit" value="Save" onclick="Check(this.form); return false;"/>
94
        </fieldset>
95
      </form>
96
       <h2>Credit details</h2>
97
      [% IF creditloop.size %]
98
          <table id="table_credit">
99
            <thead>
100
              <tr>
101
                <th>Vendor reference id</th>
102
                <th>Amount credit</th>
103
                <th>Credit date</th>
104
                <th>Budget</th>
105
                <th>Notes</th>
106
                <th></th>
107
                <th></th>
108
              </tr>
109
            </thead>
110
              [% FOREACH credit IN creditloop %]
111
                <tr>
112
                  <td>[% credit.vendorrefid %]</td>
113
                  <td>[% credit.amountcredit %]</td>
114
                  <td>[% credit.creditdate %]</td>
115
                  <td>[% credit.budget %]</td>
116
                  <td>[% credit.notes %]</td>
117
                  <td><a href="/cgi-bin/koha/acqui/editcreditnote.pl?creditnote_id=[% credit.creditnote_id %]&amp;booksellerid=[% booksellerid %]&amp;invoiceid=[% invoiceid %]">Edit</a></td>
118
                  <td><a href="/cgi-bin/koha/acqui/creditnote.pl?op=delete&amp;creditnote_id=[% credit.creditnote_id %]&amp;booksellerid=[% booksellerid %]&amp;invoiceid=[% invoiceid %]">Delete</a></td>
119
                </tr>
120
               </thead>
121
              [% END %]
122
          </table>
123
        [% ELSE %]
124
            <div class="dialog message"><p>No credit details yet</p></div>
125
        [% END %]
126
    </div>
127
  </div>
128
  <div class="yui-b">
129
    [% INCLUDE 'acquisitions-menu.inc' %]
130
  </div>
131
</div>
132
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/editcreditnote.tt (+63 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Acquisitions &rsaquo; Creditnote</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'calendar.inc' %]
6
</head>
7
8
<body>
9
[% INCLUDE 'header.inc' %]
10
[% INCLUDE 'acquisitions-search.inc' %]
11
12
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/editcreditnote.pl?creditnote_id=[% creditnote_id %]&amp;booksellerid=[% booksellerid %]&amp;invoiceid=[% invoiceid %]">Modify credit note</a></div>
13
14
<div id="doc3" class="yui-t2">
15
16
<div id="bd">
17
  <div id="yui-main">
18
    <div class="yui-b">
19
      <h1>Invoice: [% invoicenumber %]</h1>
20
      <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% suppliername %]</a></p>
21
        <form action="/cgi-bin/koha/acqui/editcreditnote.pl" name="Aform" method="post">
22
        <input type="hidden" name="op" value="edit" />
23
        <input type="hidden" id="booksellerid" name="booksellerid" value="[% booksellerid %]"/>
24
        <input type="hidden" id="invoiceid" name="invoiceid" value="[% invoiceid %]"/>
25
        <input type="hidden" id="creditnote_id" name="creditnote_id" value="[% creditnote_id %]"/>
26
        <fieldset class="rows">
27
            <ol>
28
            <li><label for="invoicenumber">Invoicenumber:</label>[% invoicenumber %]</li>
29
            <li><label for="suppliername">Vendorname:</label>[% suppliername %]</li>
30
            <li><label for="vendorrefid">Vendor ref. id:</label>
31
            <input type="text" size="30" id="vendorrefid" name="vendorrefid" value="[% vendorrefid %]" /></li>
32
            <li><label class="required" for="budget_id">Fund: </label>
33
                <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
34
                        <option value="">Select a budget</option>
35
                [% FOREACH budget_loo IN budget_loop %]
36
                    [% IF ( budget_loo.b_sel ) %]
37
                        <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
38
                    [% ELSE %]
39
                        [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]">[% budget_loo.b_txt %]</option>
40
                        [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive">[% budget_loo.b_txt %]</option>
41
                        [% END %]
42
                    [% END %]
43
                [% END %]
44
                </select>
45
            </li>
46
            <li><label for="amountcredit">Amount credit:</label>
47
            <input type="text" size="10" id="amountcredit" name="amountcredit" value="[% amountcredit %]" /></li>
48
            <li><label for="creditdate">Date:</label>
49
                    <input type="text" size="10" id="creditdate" name="creditdate" value="[% creditdate | $KohaDates %]" readonly="readonly" class="datepicker" /></li>
50
            <li><label for="notes">Notes: </label><textarea id = "notes" name="notes" width="40" rows="8" >[% notes %]</textarea></li>
51
                     <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
52
        </fieldset>
53
        <fieldset class="action">
54
            <input type="submit" value="Save"/>
55
        </fieldset>
56
      </form>
57
    </div>
58
  </div>
59
  <div class="yui-b">
60
    [% INCLUDE 'acquisitions-menu.inc' %]
61
  </div>
62
</div>
63
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+2 lines)
Lines 95-100 $(document).ready(function() { Link Here
95
                <th>Billing date</th>
95
                <th>Billing date</th>
96
                <th>Received biblios</th>
96
                <th>Received biblios</th>
97
                <th>Received items</th>
97
                <th>Received items</th>
98
                <th>Creditnote</th>
98
                <th>Status</th>
99
                <th>Status</th>
99
                <th>&nbsp;</th>
100
                <th>&nbsp;</th>
100
              </tr>
101
              </tr>
Lines 114-119 $(document).ready(function() { Link Here
114
                  </td>
115
                  </td>
115
                  <td>[% invoice.receivedbiblios %]</td>
116
                  <td>[% invoice.receivedbiblios %]</td>
116
                  <td>[% invoice.receiveditems %]</td>
117
                  <td>[% invoice.receiveditems %]</td>
118
                  <td><a href="/cgi-bin/koha/acqui/creditnote.pl?booksellerid=[% invoice.booksellerid %]&amp;invoiceid=[% invoice.invoiceid %]">Credit note</td>
117
                  <td>
119
                  <td>
118
                    [% IF invoice.closedate %]
120
                    [% IF invoice.closedate %]
119
                      Closed on [% invoice.closedate | $KohaDates %]
121
                      Closed on [% invoice.closedate | $KohaDates %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-1 / +3 lines)
Lines 247-252 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
247
            <th>Base-level<br />allocated</th>
247
            <th>Base-level<br />allocated</th>
248
            <th>Base-level<br />spent</th>
248
            <th>Base-level<br />spent</th>
249
            <th>Total sublevels<br />spent</th>
249
            <th>Total sublevels<br />spent</th>
250
            <th>Base-level<br />credited</th>
250
            <th>Base-level<br />remaining</th>
251
            <th>Base-level<br />remaining</th>
251
            <th class="tooltipcontent">&nbsp;</th>
252
            <th class="tooltipcontent">&nbsp;</th>
252
            <th>Actions</th>
253
            <th>Actions</th>
Lines 259-264 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
259
    <th nowrap="nowrap"  class="data"> [% base_alloc_total %]</th>
260
    <th nowrap="nowrap"  class="data"> [% base_alloc_total %]</th>
260
    <th class="data">[% base_spent_total %]</th>
261
    <th class="data">[% base_spent_total %]</th>
261
    <th class="data">[% base_spent_total %]</th>
262
    <th class="data">[% base_spent_total %]</th>
263
    <th class="data">[% base_credit_total %]</th>
262
    <th class="data">[% base_remaining_total %]</th>
264
    <th class="data">[% base_remaining_total %]</th>
263
    <th class="tooltipcontent"></th>
265
    <th class="tooltipcontent"></th>
264
    <th></th>
266
    <th></th>
Lines 278-283 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
278
    <td class="data">[% budge.budget_amount %] </td>
280
    <td class="data">[% budge.budget_amount %] </td>
279
    <td class="data">[% budge.budget_spent %] </td>
281
    <td class="data">[% budge.budget_spent %] </td>
280
    <td class="data">[% budge.total_levels_spent %]</td>
282
    <td class="data">[% budge.total_levels_spent %]</td>
283
    <td class="data">[% budge.budget_credit %]</td>
281
    [% IF ( budge.remaining_pos ) %]
284
    [% IF ( budge.remaining_pos ) %]
282
        <td class="data" style="color: green;">
285
        <td class="data" style="color: green;">
283
    [% ELSIF ( budge.remaining_neg ) %] 
286
    [% ELSIF ( budge.remaining_neg ) %] 
284
- 

Return to bug 10412