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

(-)a/Koha/Accounts.pm (+521 lines)
Line 0 Link Here
1
package Koha::Accounts;
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
use Data::Dumper qw(Dumper);
24
25
use C4::Context;
26
use C4::Log qw(logaction);
27
use Koha::DateUtils qw(get_timestamp);
28
29
use Koha::Accounts::CreditTypes;
30
use Koha::Accounts::DebitTypes;
31
32
use vars qw($VERSION @ISA @EXPORT);
33
34
BEGIN {
35
    require Exporter;
36
    @ISA    = qw(Exporter);
37
    @EXPORT = qw(
38
      AddDebit
39
      AddCredit
40
41
      NormalizeBalances
42
43
      RecalculateAccountBalance
44
45
      DebitLostItem
46
      CreditLostItem
47
    );
48
}
49
50
=head1 NAME
51
52
Koha::Accounts - Functions for dealing with Koha accounts
53
54
=head1 SYNOPSIS
55
56
use Koha::Accounts;
57
58
=head1 DESCRIPTION
59
60
The functions in this module deal with the monetary aspect of Koha,
61
including looking up and modifying the amount of money owed by a
62
patron.
63
64
=head1 FUNCTIONS
65
66
=head2 AddDebit
67
68
my $debit = AddDebit({
69
    borrowernumber => $borrowernumber,
70
    amount         => $amount,
71
    [ type         => $type,        ]
72
    [ itemnumber   => $itemnumber,  ]
73
    [ issue_id     => $issue_id,    ]
74
    [ description  => $description, ]
75
    [ notes        => $notes,       ]
76
    [ branchcode   => $branchcode,  ]
77
    [ manager_id   => $manager_id,  ]
78
    [ accruing     => $accruing,    ] # Default 0 if not accruing, 1 if accruing
79
});
80
81
Create a new debit for a given borrower. To standardize nomenclature, any charge
82
against a borrower ( e.g. a fine, a new card charge, the cost of losing an item )
83
will be referred to as a 'debit'.
84
85
=cut
86
87
sub AddDebit {
88
    my ($params) = @_;
89
90
    my $borrower = $params->{borrower};
91
    my $amount   = $params->{amount};
92
93
    my $type        = $params->{type};
94
    my $itemnumber  = $params->{itemnumber};
95
    my $issue_id    = $params->{issue_id};
96
    my $description = $params->{description};
97
    my $notes       = $params->{notes};
98
99
    my $branchcode = $params->{branchcode};
100
    $branchcode ||=
101
      defined( C4::Context->userenv )
102
      ? C4::Context->userenv->{branch}
103
      : undef;
104
105
    my $manager_id = $params->{manager_id};
106
    $manager_id ||=
107
      defined( C4::Context->userenv )
108
      ? C4::Context->userenv->{manager_id}
109
      : undef;
110
111
    my $accruing = $params->{accruing} || 0;
112
113
    croak("Required parameter 'borrower' not passed in.")
114
      unless ($borrower);
115
    croak("Required parameter 'amount' not passed in.")
116
      unless ($amount);
117
    croak("Invalid debit type: '$type'!")
118
      unless ( Koha::Accounts::DebitTypes::IsValid($type) );
119
    croak("No issue id passed in for accruing debit!")
120
      if ( $accruing && !$issue_id );
121
122
    my $debit = Koha::Database->new()->schema->resultset('AccountDebit')->create(
123
        {
124
            borrowernumber        => $borrower->borrowernumber(),
125
            itemnumber            => $itemnumber,
126
            issue_id              => $issue_id,
127
            type                  => $type,
128
            accruing              => $accruing,
129
            amount_original       => $amount,
130
            amount_outstanding    => $amount,
131
            amount_last_increment => $amount,
132
            description           => $description,
133
            notes                 => $notes,
134
            manager_id            => $manager_id,
135
            created_on            => get_timestamp(),
136
        }
137
    );
138
139
    if ($debit) {
140
        $borrower->account_balance( $borrower->account_balance() + $amount );
141
        $borrower->update();
142
143
        NormalizeBalances( { borrower => $borrower } );
144
145
        if ( C4::Context->preference("FinesLog") ) {
146
            logaction( "FINES", "CREATE_FEE", $debit->id,
147
                Dumper( { $debit->get_columns(), accruing => $accruing } ) );
148
        }
149
    }
150
    else {
151
        carp("Something went wrong! Debit not created!");
152
    }
153
154
    return $debit;
155
}
156
157
=head2 DebitLostItem
158
159
my $debit = DebitLostItem({
160
    borrower       => $borrower,
161
    issue          => $issue,
162
    [ description  => $description, ]
163
    [ notes        => $notes,       ]
164
    [ branchcode   => $branchcode,  ]
165
    [ manager_id   => $manager_id,  ]
166
});
167
168
DebitLostItem adds a replacement fee charge for the item
169
of the given issue.
170
171
=cut
172
173
sub DebitLostItem {
174
    my ($params) = @_;
175
176
    my $borrower = $params->{borrower};
177
    my $issue    = $params->{issue};
178
179
    croak("Required param 'borrower' not passed in!") unless ($borrower);
180
    croak("Required param 'issue' not passed in!")    unless ($issue);
181
182
# Don't add lost debit if borrower has already been charged for this lost item before,
183
# for this issue. It seems reasonable that a borrower could lose an item, find and return it,
184
# check it out again, and lose it again, so we should do this based on issue_id, not itemnumber.
185
    unless (
186
        Koha::Database->new()->schema->resultset('AccountDebit')->search(
187
            {
188
                borrowernumber => $borrower->borrowernumber(),
189
                issue_id       => $issue->issue_id(),
190
                type           => Koha::Accounts::DebitTypes::Lost
191
            }
192
        )->count()
193
      )
194
    {
195
        my $item = $issue->itemnumber();
196
197
        $params->{accruing}   = 0;
198
        $params->{type}       = Koha::Accounts::DebitTypes::Lost;
199
        $params->{amount}     = $item->replacementprice();
200
        $params->{itemnumber} = $item->itemnumber();
201
202
#TODO: Shouldn't we have a default replacement price? Either as a syspref or as part of the issuing rules?
203
        if ( $params->{amount} ) {
204
            return AddDebit($params);
205
        }
206
        else {
207
            carp("Cannot add lost debit! Item has no replacement price!");
208
        }
209
    }
210
}
211
212
=head2 CreditLostItem
213
214
my $debit = CreditLostItem({
215
    borrower       => $borrower,
216
    issue          => $issue,
217
    [ description  => $description, ]
218
    [ notes        => $notes,       ]
219
    [ branchcode   => $branchcode,  ]
220
    [ manager_id   => $manager_id,  ]
221
});
222
223
CreditLostItem creates a payment in the ammount equal
224
to the replacement price charge created by DebitLostItem.
225
226
=cut
227
228
sub CreditLostItem {
229
    my ($params) = @_;
230
231
    my $borrower      = $params->{borrower};
232
    my $account_debit = $params->{account_debit};
233
234
    croak("Required param 'borrower' not passed in!") unless ($borrower);
235
    croak("Required param 'account_debit' not passed in!")
236
      unless ($account_debit);
237
238
    my $item =
239
      Koha::Database->new()->schema->resultset('Item')
240
      ->find( $account_debit->itemnumber() );
241
    carp("No item found!") unless $item;
242
243
    $params->{type}     = Koha::Accounts::CreditTypes::Found;
244
    $params->{amount}   = $account_debit->amount_original();
245
    $params->{debit_id} = $account_debit->debit_id();
246
    $params->{notes}    = "Lost item found: " . $item->barcode();
247
    # TODO: It would be nice if we could directly connect the item and issue
248
    # directly to this credit in a simple way. Perhaps the action log is good enough
249
250
    return AddCredit($params);
251
}
252
253
=head2 AddCredit
254
255
AddCredit({
256
    borrower       => $borrower,
257
    amount         => $amount,
258
    [ branchcode   => $branchcode, ]
259
    [ manager_id   => $manager_id, ]
260
    [ debit_id     => $debit_id, ] # The primary debit to be paid
261
    [ notes        => $notes, ]
262
});
263
264
Record credit by a patron. C<$borrowernumber> is the patron's
265
borrower number. C<$credit> is a floating-point number, giving the
266
amount that was paid.
267
268
Amounts owed are paid off oldest first. That is, if the patron has a
269
$1 fine from Feb. 1, another $1 fine from Mar. 1, and makes a credit
270
of $1.50, then the oldest fine will be paid off in full, and $0.50
271
will be credited to the next one.
272
273
debit_id can be passed as a scalar or an array ref to make the passed
274
in debit or debits the first to be credited.
275
276
=cut
277
278
sub AddCredit {
279
    my ($params) = @_;
280
281
    my $type       = $params->{type};
282
    my $borrower   = $params->{borrower};
283
    my $amount     = $params->{amount};
284
    my $debit_id   = $params->{debit_id};
285
    my $notes      = $params->{notes};
286
    my $branchcode = $params->{branchcode};
287
    my $manager_id = $params->{manager_id};
288
289
    my $userenv = C4::Context->userenv;
290
291
    unless ( $manager_id || $userenv ) {
292
        $manager_id = $userenv->{number};
293
    }
294
295
    unless ( $branchcode || $userenv ) {
296
        $branchcode = $userenv->{branch};
297
    }
298
299
    unless ($borrower) {
300
        croak("Required parameter 'borrower' not passed in");
301
    }
302
    unless ($amount) {
303
        croak("Required parameter amount not passed in");
304
    }
305
306
    unless ( Koha::Accounts::CreditTypes::IsValid($type) ) {
307
        carp("Invalid credit type! Returning without creating credit.");
308
        return;
309
    }
310
311
    unless ($type) {
312
        carp("No type passed in, assuming Payment");
313
        $type = Koha::Accounts::CreditTypes::Payment;
314
    }
315
316
    my $debit = Koha::Database->new()->schema->resultset('AccountDebit')->find($debit_id);
317
318
    # First, we make the credit. We'll worry about what we paid later on
319
    my $credit = Koha::Database->new()->schema->resultset('AccountCredit')->create(
320
        {
321
            borrowernumber   => $borrower->borrowernumber(),
322
            type             => $type,
323
            amount_paid      => $amount,
324
            amount_remaining => $amount,
325
            notes            => $notes,
326
            manager_id       => $manager_id,
327
            created_on       => get_timestamp(),
328
        }
329
    );
330
331
    $borrower->account_balance( $borrower->account_balance() - $amount );
332
    $borrower->update();
333
334
    # If we are given specific debits, pay those ones first.
335
    if ( $debit_id ) {
336
        my @debit_ids = ref( $debit_id ) eq "ARRAY" ? @$debit_id : $debit_id;
337
        foreach my $debit_id (@debit_ids) {
338
            my $debit =
339
              Koha::Database->new()->schema->resultset('AccountDebit')->find($debit_id);
340
341
            if ($debit) {
342
                CreditDebit( { credit => $credit, debit => $debit } );
343
            }
344
            else {
345
                carp("Invalid debit_id passed in!");
346
            }
347
        }
348
    }
349
350
    # We still have leftover money, or we weren't given a specific debit to pay
351
    if ( $credit->amount_remaining() > 0 ) {
352
        my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search(
353
            {
354
                borrowernumber     => $borrower->borrowernumber(),
355
                amount_outstanding => { '>' => '0' }
356
            }
357
        );
358
359
        foreach my $debit (@debits) {
360
            if ( $credit->amount_remaining() > 0 ) {
361
                CreditDebit(
362
                    {
363
                        credit   => $credit,
364
                        debit    => $debit,
365
                        borrower => $borrower
366
                    }
367
                );
368
            }
369
        }
370
    }
371
372
    return $credit;
373
}
374
375
=head2 CreditDebit 
376
377
$account_offset = CreditDebit({
378
    credit => $credit,
379
    debit => $debit,
380
});
381
382
Given a credit and a debit, this subroutine
383
will pay the appropriate amount of the debit,
384
update the debit's amount outstanding, the credit's
385
amout remaining, and create the appropriate account
386
offset.
387
388
=cut
389
390
sub CreditDebit {
391
    my ($params) = @_;
392
393
    my $credit = $params->{credit};
394
    my $debit  = $params->{debit};
395
396
    croak("Required parameter 'credit' not passed in!")
397
      unless $credit;
398
    croak("Required parameter 'debit' not passed in!") unless $debit;
399
400
    my $amount_to_pay =
401
      ( $debit->amount_outstanding() > $credit->amount_remaining() )
402
      ? $credit->amount_remaining()
403
      : $debit->amount_outstanding();
404
405
    if ( $amount_to_pay > 0 ) {
406
        $debit->amount_outstanding(
407
            $debit->amount_outstanding() - $amount_to_pay );
408
        $debit->update();
409
410
        $credit->amount_remaining(
411
            $credit->amount_remaining() - $amount_to_pay );
412
        $credit->update();
413
414
        my $offset = Koha::Database->new()->schema->resultset('AccountOffset')->create(
415
            {
416
                amount     => $amount_to_pay,
417
                debit_id   => $debit->id(),
418
                credit_id  => $credit->id(),
419
                created_on => get_timestamp(),
420
            }
421
        );
422
423
        return $offset;
424
    }
425
}
426
427
=head2 RecalculateAccountBalance
428
429
$account_balance = RecalculateAccountBalance({
430
    borrower => $borrower
431
});
432
433
Recalculates a borrower's balance based on the
434
sum of the amount outstanding for the borrower's
435
debits minus the sum of the amount remaining for
436
the borrowers credits.
437
438
TODO: Would it be better to use af.amount_original - ap.amount_paid for any reason?
439
      Or, perhaps calculate both and compare the two, for error checking purposes.
440
=cut
441
442
sub RecalculateAccountBalance {
443
    my ($params) = @_;
444
445
    my $borrower = $params->{borrower};
446
    croak("Requred paramter 'borrower' not passed in!")
447
      unless ($borrower);
448
449
    my $debits =
450
      Koha::Database->new()->schema->resultset('AccountDebit')
451
      ->search( { borrowernumber => $borrower->borrowernumber() } );
452
    my $amount_outstanding = $debits->get_column('amount_outstanding')->sum();
453
454
    my $credits =
455
      Koha::Database->new()->schema->resultset('AccountCredit')
456
      ->search( { borrowernumber => $borrower->borrowernumber() } );
457
    my $amount_remaining = $credits->get_column('amount_remaining')->sum();
458
459
    my $account_balance = $amount_outstanding - $amount_remaining;
460
    $borrower->account_balance($account_balance);
461
    $borrower->update();
462
463
    return $account_balance;
464
}
465
466
=head2 CreditDebits
467
468
    $account_balance = CreditDebits({ borrower => $borrower });
469
470
    For a given borrower, this subroutine will find all debits 
471
    with an outstanding balance and all credits with an unused
472
    amount remaining and will pay those debits with those credits.
473
474
=cut
475
476
sub NormalizeBalances {
477
    my ($params) = @_;
478
479
    my $borrower = $params->{borrower};
480
481
    croak("Required param 'borrower' not passed in!") unless $borrower;
482
483
    my @credits = Koha::Database->new()->schema->resultset('AccountCredit')->search(
484
        {
485
            borrowernumber   => $borrower->borrowernumber(),
486
            amount_remaining => { '>' => '0' }
487
        }
488
    );
489
490
    return unless @credits;    # short circuit for speed
491
492
    my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search(
493
        {
494
            borrowernumber     => $borrower->borrowernumber(),
495
            amount_outstanding => { '>' => '0' }
496
        }
497
    );
498
499
    return unless @debits;     # short circuit for speed
500
501
    foreach my $credit (@credits) {
502
        foreach my $debit (@debits) {
503
            if (   $credit->amount_remaining()
504
                && $debit->amount_outstanding() )
505
            {
506
                CreditDebit( { credit => $credit, debit => $debit } );
507
            }
508
        }
509
    }
510
511
    return RecalculateAccountBalance( { borrower => $borrower } );
512
}
513
514
1;
515
__END__
516
517
=head1 AUTHOR
518
519
Kyle M Hall <kyle@bywatersolutions.com>
520
521
=cut
(-)a/Koha/Accounts/CreditTypes.pm (+117 lines)
Line 0 Link Here
1
package Koha::Accounts::CreditTypes;
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
=head1 NAME
23
24
Koha::AccountsCreditTypes - Module representing the enumerated data types for account fees
25
26
=head1 SYNOPSIS
27
28
use Koha::Accounts::CreditTypes;
29
30
my $type = Koha::Accounts::CreditTypes::Payment;
31
32
=head1 DESCRIPTION
33
34
The subroutines in this modules act as enumerated data types for the
35
different credit types in Koha ( i.e. payments, writeoffs, etc. )
36
37
=head1 FUNCTIONS
38
39
=head2 IsValid
40
41
This subroutine takes a given string and returns 1 if
42
the string matches one of the data types, and 0 if not.
43
44
FIXME: Perhaps we should use Class::Inspector instead of hard
45
coding the subs? It seems like it would be a major trade off
46
of speed just so we don't update something in two separate places
47
in the same file.
48
49
=cut
50
51
sub IsValid {
52
    my ($string) = @_;
53
54
    my $is_valid =
55
      (      $string eq Koha::Accounts::CreditTypes::Payment()
56
          || $string eq Koha::Accounts::CreditTypes::WriteOff()
57
          || $string eq Koha::Accounts::CreditTypes::Found()
58
          || $string eq Koha::Accounts::CreditTypes::Credit()
59
          || $string eq Koha::Accounts::CreditTypes::Forgiven() );
60
61
    unless ($is_valid) {
62
        $is_valid =
63
          Koha::Database->new()->schema->resultset('AuthorisedValue')
64
          ->count(
65
            { category => 'ACCOUNT_CREDIT', authorised_value => $string } );
66
    }
67
68
    return $is_valid;
69
}
70
71
=head2 Credit
72
73
=cut
74
75
sub Credit {
76
    return 'CREDIT';
77
}
78
79
=head2 Payment
80
81
=cut
82
83
sub Payment {
84
    return 'PAYMENT';
85
}
86
87
=head2 Writeoff
88
89
=cut
90
91
sub WriteOff {
92
    return 'WRITEOFF';
93
}
94
95
=head2 Writeoff
96
97
=cut
98
99
sub Found {
100
    return 'FOUND';
101
}
102
103
=head2 Forgiven
104
105
=cut
106
107
sub Forgiven {
108
    return 'FORGIVEN';
109
}
110
111
1;
112
113
=head1 AUTHOR
114
115
Kyle M Hall <kyle@bywatersolutions.com>
116
117
=cut
(-)a/Koha/Accounts/DebitTypes.pm (+138 lines)
Line 0 Link Here
1
package Koha::Accounts::DebitTypes;
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
=head1 NAME
23
24
Koha::Accounts::DebitTypes - Module representing an enumerated data type for account fees
25
26
=head1 SYNOPSIS
27
28
use Koha::Accounts::DebitTypes;
29
30
my $type = Koha::Accounts::DebitTypes::Fine;
31
32
=head1 DESCRIPTION
33
34
The subroutines in this modules act as an enumerated data type
35
for debit types ( stored in account_debits.type ) in Koha.
36
37
=head1 FUNCTIONS
38
39
=head2 IsValid
40
41
This subroutine takes a given string and returns 1 if
42
the string matches one of the data types, and 0 if not.
43
44
=cut
45
46
sub IsValid {
47
    my ($string) = @_;
48
49
    my $is_valid =
50
      (      $string eq Koha::Accounts::DebitTypes::Fine()
51
          || $string eq Koha::Accounts::DebitTypes::AccountManagementFee()
52
          || $string eq Koha::Accounts::DebitTypes::Sundry()
53
          || $string eq Koha::Accounts::DebitTypes::Lost()
54
          || $string eq Koha::Accounts::DebitTypes::NewCard() );
55
56
    unless ($is_valid) {
57
        $is_valid =
58
          Koha::Database->new()->schema->resultset('AuthorisedValue')
59
          ->count( { category => 'MANUAL_INV', authorised_value => $string } );
60
    }
61
62
    return $is_valid;
63
}
64
65
=head2 Fine
66
67
This data type represents a standard fine within Koha.
68
69
A fine still accruing no longer needs to be differiated by type
70
from a fine done accuring. Instead, that differentication is made
71
by which table the fine exists in, account_fees_accruing vs account_fees_accrued.
72
73
In addition, fines can be checked for correctness based on the issue_id
74
they have. A fine in account_fees_accruing should always have a matching
75
issue_id in the issues table. A fine done accruing will almost always have
76
a matching issue_id in the old_issues table. However, in the case of an overdue
77
item with fines that has been renewed, and becomes overdue again, you may have
78
a case where a given issue may have a matching fine in account_fees_accruing and
79
one or more matching fines in account_fees_accrued ( one for each for the first
80
checkout and one each for any subsequent renewals )
81
82
=cut
83
84
sub Fine {
85
    return 'FINE';
86
}
87
88
=head2 AccountManagementFee
89
90
This fee type is usually reserved for payments for library cards,
91
in cases where a library must charge a patron for the ability to
92
check out items.
93
94
=cut
95
96
sub AccountManagementFee {
97
    return 'ACCOUNT_MANAGEMENT_FEE';
98
}
99
100
=head2 Sundry
101
102
This fee type is basically a 'misc' type, and should be used
103
when no other fee type is more appropriate.
104
105
=cut
106
107
sub Sundry {
108
    return 'SUNDRY';
109
}
110
111
=head2 Lost
112
113
This fee type is used when a library charges for lost items.
114
115
=cut
116
117
sub Lost {
118
    return 'LOST';
119
}
120
121
=head2 NewCard
122
123
This fee type is used when a library charges for replacement
124
library cards.
125
126
=cut
127
128
sub NewCard {
129
    return 'NEW_CARD';
130
}
131
132
1;
133
134
=head1 AUTHOR
135
136
Kyle M Hall <kyle@bywatersolutions.com>
137
138
=cut
(-)a/Koha/DateUtils.pm (-1 / +6 lines)
Lines 21-33 use warnings; Link Here
21
use 5.010;
21
use 5.010;
22
use DateTime;
22
use DateTime;
23
use DateTime::Format::DateParse;
23
use DateTime::Format::DateParse;
24
use DateTime::Format::MySQL;
24
use C4::Context;
25
use C4::Context;
25
26
26
use base 'Exporter';
27
use base 'Exporter';
27
use version; our $VERSION = qv('1.0.0');
28
use version; our $VERSION = qv('1.0.0');
28
29
29
our @EXPORT = (
30
our @EXPORT = (
30
    qw( dt_from_string output_pref format_sqldatetime output_pref_due format_sqlduedatetime)
31
    qw( dt_from_string output_pref format_sqldatetime output_pref_due format_sqlduedatetime get_timestamp )
31
);
32
);
32
33
33
=head1 DateUtils
34
=head1 DateUtils
Lines 239-242 sub format_sqlduedatetime { Link Here
239
    return q{};
240
    return q{};
240
}
241
}
241
242
243
sub get_timestamp {
244
    return DateTime::Format::MySQL->format_datetime( dt_from_string() );
245
}
246
242
1;
247
1;
(-)a/Koha/Schema/Result/AccountCredit.pm (+134 lines)
Line 0 Link Here
1
package Koha::Schema::Result::AccountCredit;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::AccountCredit
15
16
=cut
17
18
__PACKAGE__->table("account_credits");
19
20
=head1 ACCESSORS
21
22
=head2 credit_id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 borrowernumber
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 0
33
34
=head2 type
35
36
  data_type: 'varchar'
37
  is_nullable: 0
38
  size: 255
39
40
=head2 amount_paid
41
42
  data_type: 'decimal'
43
  is_nullable: 0
44
  size: [28,6]
45
46
=head2 amount_remaining
47
48
  data_type: 'decimal'
49
  is_nullable: 0
50
  size: [28,6]
51
52
=head2 notes
53
54
  data_type: 'text'
55
  is_nullable: 1
56
57
=head2 manager_id
58
59
  data_type: 'integer'
60
  is_nullable: 1
61
62
=head2 created_on
63
64
  data_type: 'timestamp'
65
  is_nullable: 1
66
67
=head2 updated_on
68
69
  data_type: 'timestamp'
70
  is_nullable: 1
71
72
=cut
73
74
__PACKAGE__->add_columns(
75
  "credit_id",
76
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
77
  "borrowernumber",
78
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
79
  "type",
80
  { data_type => "varchar", is_nullable => 0, size => 255 },
81
  "amount_paid",
82
  { data_type => "decimal", is_nullable => 0, size => [28, 6] },
83
  "amount_remaining",
84
  { data_type => "decimal", is_nullable => 0, size => [28, 6] },
85
  "notes",
86
  { data_type => "text", is_nullable => 1 },
87
  "manager_id",
88
  { data_type => "integer", is_nullable => 1 },
89
  "created_on",
90
  { data_type => "timestamp", is_nullable => 1 },
91
  "updated_on",
92
  { data_type => "timestamp", is_nullable => 1 },
93
);
94
__PACKAGE__->set_primary_key("credit_id");
95
96
=head1 RELATIONS
97
98
=head2 borrowernumber
99
100
Type: belongs_to
101
102
Related object: L<Koha::Schema::Result::Borrower>
103
104
=cut
105
106
__PACKAGE__->belongs_to(
107
  "borrowernumber",
108
  "Koha::Schema::Result::Borrower",
109
  { borrowernumber => "borrowernumber" },
110
  { on_delete => "CASCADE", on_update => "CASCADE" },
111
);
112
113
=head2 account_offsets
114
115
Type: has_many
116
117
Related object: L<Koha::Schema::Result::AccountOffset>
118
119
=cut
120
121
__PACKAGE__->has_many(
122
  "account_offsets",
123
  "Koha::Schema::Result::AccountOffset",
124
  { "foreign.credit_id" => "self.credit_id" },
125
  { cascade_copy => 0, cascade_delete => 0 },
126
);
127
128
129
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-10-09 10:37:23
130
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uvt4OuaJxv4jk08zJsKouw
131
132
133
# You can replace this text with custom content, and it will be preserved on regeneration
134
1;
(-)a/Koha/Schema/Result/AccountDebit.pm (+200 lines)
Line 0 Link Here
1
package Koha::Schema::Result::AccountDebit;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::AccountDebit
15
16
=cut
17
18
__PACKAGE__->table("account_debits");
19
20
=head1 ACCESSORS
21
22
=head2 debit_id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 borrowernumber
29
30
  data_type: 'integer'
31
  default_value: 0
32
  is_foreign_key: 1
33
  is_nullable: 0
34
35
=head2 itemnumber
36
37
  data_type: 'integer'
38
  is_nullable: 1
39
40
=head2 issue_id
41
42
  data_type: 'integer'
43
  is_nullable: 1
44
45
=head2 type
46
47
  data_type: 'varchar'
48
  is_nullable: 0
49
  size: 255
50
51
=head2 accruing
52
53
  data_type: 'tinyint'
54
  default_value: 0
55
  is_nullable: 0
56
57
=head2 amount_original
58
59
  data_type: 'decimal'
60
  is_nullable: 1
61
  size: [28,6]
62
63
=head2 amount_outstanding
64
65
  data_type: 'decimal'
66
  is_nullable: 1
67
  size: [28,6]
68
69
=head2 amount_last_increment
70
71
  data_type: 'decimal'
72
  is_nullable: 1
73
  size: [28,6]
74
75
=head2 description
76
77
  data_type: 'mediumtext'
78
  is_nullable: 1
79
80
=head2 notes
81
82
  data_type: 'text'
83
  is_nullable: 1
84
85
=head2 dispute
86
87
  data_type: 'mediumtext'
88
  is_nullable: 1
89
90
=head2 notify_id
91
92
  data_type: 'integer'
93
  default_value: 0
94
  is_nullable: 0
95
96
=head2 notify_level
97
98
  data_type: 'integer'
99
  default_value: 0
100
  is_nullable: 0
101
102
=head2 manager_id
103
104
  data_type: 'integer'
105
  is_nullable: 1
106
107
=head2 created_on
108
109
  data_type: 'timestamp'
110
  is_nullable: 1
111
112
=head2 updated_on
113
114
  data_type: 'timestamp'
115
  is_nullable: 1
116
117
=cut
118
119
__PACKAGE__->add_columns(
120
  "debit_id",
121
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
122
  "borrowernumber",
123
  {
124
    data_type      => "integer",
125
    default_value  => 0,
126
    is_foreign_key => 1,
127
    is_nullable    => 0,
128
  },
129
  "itemnumber",
130
  { data_type => "integer", is_nullable => 1 },
131
  "issue_id",
132
  { data_type => "integer", is_nullable => 1 },
133
  "type",
134
  { data_type => "varchar", is_nullable => 0, size => 255 },
135
  "accruing",
136
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
137
  "amount_original",
138
  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
139
  "amount_outstanding",
140
  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
141
  "amount_last_increment",
142
  { data_type => "decimal", is_nullable => 1, size => [28, 6] },
143
  "description",
144
  { data_type => "mediumtext", is_nullable => 1 },
145
  "notes",
146
  { data_type => "text", is_nullable => 1 },
147
  "dispute",
148
  { data_type => "mediumtext", is_nullable => 1 },
149
  "notify_id",
150
  { data_type => "integer", default_value => 0, is_nullable => 0 },
151
  "notify_level",
152
  { data_type => "integer", default_value => 0, is_nullable => 0 },
153
  "manager_id",
154
  { data_type => "integer", is_nullable => 1 },
155
  "created_on",
156
  { data_type => "timestamp", is_nullable => 1 },
157
  "updated_on",
158
  { data_type => "timestamp", is_nullable => 1 },
159
);
160
__PACKAGE__->set_primary_key("debit_id");
161
162
=head1 RELATIONS
163
164
=head2 borrowernumber
165
166
Type: belongs_to
167
168
Related object: L<Koha::Schema::Result::Borrower>
169
170
=cut
171
172
__PACKAGE__->belongs_to(
173
  "borrowernumber",
174
  "Koha::Schema::Result::Borrower",
175
  { borrowernumber => "borrowernumber" },
176
  { on_delete => "CASCADE", on_update => "CASCADE" },
177
);
178
179
=head2 account_offsets
180
181
Type: has_many
182
183
Related object: L<Koha::Schema::Result::AccountOffset>
184
185
=cut
186
187
__PACKAGE__->has_many(
188
  "account_offsets",
189
  "Koha::Schema::Result::AccountOffset",
190
  { "foreign.debit_id" => "self.debit_id" },
191
  { cascade_copy => 0, cascade_delete => 0 },
192
);
193
194
195
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-10-09 10:37:23
196
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LuHGHKmf3tPEWsTqE4VoMQ
197
198
199
# You can replace this text with custom content, and it will be preserved on regeneration
200
1;
(-)a/Koha/Schema/Result/AccountOffset.pm (+110 lines)
Line 0 Link Here
1
package Koha::Schema::Result::AccountOffset;
2
3
# Created by DBIx::Class::Schema::Loader
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
5
6
use strict;
7
use warnings;
8
9
use base 'DBIx::Class::Core';
10
11
12
=head1 NAME
13
14
Koha::Schema::Result::AccountOffset
15
16
=cut
17
18
__PACKAGE__->table("account_offsets");
19
20
=head1 ACCESSORS
21
22
=head2 offset_id
23
24
  data_type: 'integer'
25
  is_auto_increment: 1
26
  is_nullable: 0
27
28
=head2 debit_id
29
30
  data_type: 'integer'
31
  is_foreign_key: 1
32
  is_nullable: 1
33
34
=head2 credit_id
35
36
  data_type: 'integer'
37
  is_foreign_key: 1
38
  is_nullable: 1
39
40
=head2 amount
41
42
  data_type: 'decimal'
43
  is_nullable: 0
44
  size: [28,6]
45
46
=head2 created_on
47
48
  data_type: 'timestamp'
49
  default_value: current_timestamp
50
  is_nullable: 0
51
52
=cut
53
54
__PACKAGE__->add_columns(
55
  "offset_id",
56
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
57
  "debit_id",
58
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
59
  "credit_id",
60
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
61
  "amount",
62
  { data_type => "decimal", is_nullable => 0, size => [28, 6] },
63
  "created_on",
64
  {
65
    data_type     => "timestamp",
66
    default_value => \"current_timestamp",
67
    is_nullable   => 0,
68
  },
69
);
70
__PACKAGE__->set_primary_key("offset_id");
71
72
=head1 RELATIONS
73
74
=head2 debit
75
76
Type: belongs_to
77
78
Related object: L<Koha::Schema::Result::AccountDebit>
79
80
=cut
81
82
__PACKAGE__->belongs_to(
83
  "debit",
84
  "Koha::Schema::Result::AccountDebit",
85
  { debit_id => "debit_id" },
86
  { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
87
);
88
89
=head2 credit
90
91
Type: belongs_to
92
93
Related object: L<Koha::Schema::Result::AccountCredit>
94
95
=cut
96
97
__PACKAGE__->belongs_to(
98
  "credit",
99
  "Koha::Schema::Result::AccountCredit",
100
  { credit_id => "credit_id" },
101
  { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" },
102
);
103
104
105
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-10-09 11:36:24
106
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:J/sEmYnIqdgAai3rfGY16g
107
108
109
# You can replace this text with custom content, and it will be preserved on regeneration
110
1;
(-)a/Koha/Schema/Result/Issue.pm (-2 / +2 lines)
Lines 153-160 __PACKAGE__->belongs_to( Link Here
153
);
153
);
154
154
155
155
156
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-10-31 07:41:39
156
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-10-09 11:36:25
157
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tvpuw8k1hjh2nbOsng5k/w
157
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uKa60yNvxVzZ9kGpBlLfcQ
158
158
159
__PACKAGE__->belongs_to(
159
__PACKAGE__->belongs_to(
160
  "borrower",
160
  "borrower",
(-)a/Koha/Template/Plugin/Currency.pm (+64 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Currency;
2
3
# Copyright ByWater Solutions 2013
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use base qw( Template::Plugin::Filter );
23
24
use Locale::Currency::Format;
25
26
use C4::Context;
27
use Koha::DateUtils;
28
29
sub init {
30
    my $self = shift;
31
32
    my $active_currency = C4::Context->dbh->selectrow_hashref(
33
        'SELECT * FROM currency WHERE active = 1', {} );
34
    $self->{active_currency} = $active_currency;
35
36
    return $self;
37
}
38
39
sub filter {
40
    my ( $self, $amount ) = @_;
41
42
    return $self->format($amount);
43
}
44
45
sub format {
46
    my ( $self, $amount, $format ) = @_;
47
48
    return currency_format( $self->{active_currency}->{currency},
49
        $amount, $format || FMT_HTML );
50
}
51
52
sub format_without_symbol {
53
    my ( $self, $amount ) = @_;
54
55
    return substr( $self->format( $amount, FMT_SYMBOL ), 1 );
56
}
57
58
sub symbol {
59
    my ($self) = @_;
60
61
    return currency_symbol( $self->{active_currency}->{'currency'}, SYM_HTML );
62
}
63
64
1;
(-)a/installer/data/mysql/kohastructure.sql (+83 lines)
Lines 3333-3338 ALTER TABLE `patron_list_patrons` Link Here
3333
  ADD CONSTRAINT patron_list_patrons_ibfk_1 FOREIGN KEY (patron_list_id) REFERENCES patron_lists (patron_list_id) ON DELETE CASCADE ON UPDATE CASCADE,
3333
  ADD CONSTRAINT patron_list_patrons_ibfk_1 FOREIGN KEY (patron_list_id) REFERENCES patron_lists (patron_list_id) ON DELETE CASCADE ON UPDATE CASCADE,
3334
  ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
3334
  ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
3335
3335
3336
--
3337
-- Table structure for table 'account_credits'
3338
--
3339
DROP TABLE IF EXISTS account_credits;
3340
CREATE TABLE IF account_credits (
3341
    credit_id int(11) NOT NULL AUTO_INCREMENT,
3342
    borrowernumber int(11) NOT NULL,
3343
    `type` varchar(255) NOT NULL,
3344
    amount_paid decimal(28,6) NOT NULL,
3345
    amount_remaining decimal(28,6) NOT NULL,
3346
    notes text,
3347
    manager_id int(11) DEFAULT NULL,
3348
    created_on timestamp NULL DEFAULT NULL,
3349
    updated_on timestamp NULL DEFAULT NULL,
3350
    PRIMARY KEY (credit_id),
3351
    KEY borrowernumber (borrowernumber)
3352
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3353
3354
--
3355
-- Constraints for table `account_credits`
3356
--
3357
ALTER TABLE `account_credits`
3358
  ADD CONSTRAINT account_credits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
3359
3360
--
3361
-- Table structure for table 'account_debits'
3362
--
3363
3364
DROP TABLE IF EXISTS account_debits;
3365
CREATE TABLE account_debits (
3366
    debit_id int(11) NOT NULL AUTO_INCREMENT,
3367
    borrowernumber int(11) NOT NULL DEFAULT '0',
3368
    itemnumber int(11) DEFAULT NULL,
3369
    issue_id int(11) DEFAULT NULL,
3370
    `type` varchar(255) NOT NULL,
3371
    accruing tinyint(1) NOT NULL DEFAULT '0',
3372
    amount_original decimal(28,6) DEFAULT NULL,
3373
    amount_outstanding decimal(28,6) DEFAULT NULL,
3374
    amount_last_increment decimal(28,6) DEFAULT NULL,
3375
    description mediumtext,
3376
    notes text,
3377
    dispute mediumtext,
3378
    notify_id int(11) NOT NULL DEFAULT '0',
3379
    notify_level int(2) NOT NULL DEFAULT '0',
3380
    manager_id int(11) DEFAULT NULL,
3381
    created_on timestamp NULL DEFAULT NULL,
3382
    updated_on timestamp NULL DEFAULT NULL,
3383
    PRIMARY KEY (debit_id),
3384
    KEY acctsborridx (borrowernumber),
3385
    KEY itemnumber (itemnumber),
3386
    KEY borrowernumber (borrowernumber),
3387
    KEY issue_id (issue_id)
3388
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3389
3390
--
3391
-- Constraints for table `account_debits`
3392
--
3393
ALTER TABLE `account_debits`
3394
    ADD CONSTRAINT account_debits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
3395
3396
--
3397
-- Table structure for table 'account_offsets'
3398
--
3399
3400
DROP TABLE IF EXISTS account_offsets;
3401
CREATE TABLE account_offsets (
3402
    offset_id int(11) NOT NULL AUTO_INCREMENT,
3403
    debit_id int(11) DEFAULT NULL,
3404
    credit_id int(11) DEFAULT NULL,
3405
    amount decimal(28,6) NOT NULL,
3406
    created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3407
    PRIMARY KEY (offset_id),
3408
    KEY fee_id (debit_id),
3409
    KEY payment_id (credit_id)
3410
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
3411
3412
--
3413
-- Constraints for table `account_offsets`
3414
--
3415
ALTER TABLE `account_offsets`
3416
    ADD CONSTRAINT account_offsets_ibfk_1 FOREIGN KEY (debit_id) REFERENCES account_debits (debit_id) ON DELETE CASCADE ON UPDATE CASCADE,
3417
    ADD CONSTRAINT account_offsets_ibfk_2 FOREIGN KEY (credit_id) REFERENCES account_credits (credit_id) ON DELETE CASCADE ON UPDATE CASCADE;
3418
3336
3419
3337
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3420
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3338
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3421
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
(-)a/installer/data/mysql/updatedatabase.pl (+78 lines)
Lines 7259-7264 if ( CheckVersion($DBversion) ) { Link Here
7259
7259
7260
    $dbh->{AutoCommit} = 1;
7260
    $dbh->{AutoCommit} = 1;
7261
    $dbh->{RaiseError} = 0;
7261
    $dbh->{RaiseError} = 0;
7262
   SetVersion ($DBversion);
7262
}
7263
}
7263
7264
7264
$DBversion = "3.13.00.031";
7265
$DBversion = "3.13.00.031";
Lines 7636-7641 if ( CheckVersion($DBversion) ) { Link Here
7636
    SetVersion($DBversion);
7637
    SetVersion($DBversion);
7637
}
7638
}
7638
7639
7640
$DBversion = "3.15.00.XXX";
7641
if ( CheckVersion($DBversion) ) {
7642
    $dbh->do("ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
7643
    $dbh->do("ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
7644
    $dbh->do("
7645
        CREATE TABLE IF NOT EXISTS account_credits (
7646
            credit_id int(11) NOT NULL AUTO_INCREMENT,
7647
            borrowernumber int(11) NOT NULL,
7648
            `type` varchar(255) NOT NULL,
7649
            amount_paid decimal(28,6) NOT NULL,
7650
            amount_remaining decimal(28,6) NOT NULL,
7651
            notes text,
7652
            manager_id int(11) DEFAULT NULL,
7653
            created_on timestamp NULL DEFAULT NULL,
7654
            updated_on timestamp NULL DEFAULT NULL,
7655
            PRIMARY KEY (credit_id),
7656
            KEY borrowernumber (borrowernumber)
7657
        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
7658
    ");
7659
    $dbh->do("
7660
        CREATE TABLE IF NOT EXISTS account_debits (
7661
            debit_id int(11) NOT NULL AUTO_INCREMENT,
7662
            borrowernumber int(11) NOT NULL DEFAULT '0',
7663
            itemnumber int(11) DEFAULT NULL,
7664
            issue_id int(11) DEFAULT NULL,
7665
            `type` varchar(255) NOT NULL,
7666
            accruing tinyint(1) NOT NULL DEFAULT '0',
7667
            amount_original decimal(28,6) DEFAULT NULL,
7668
            amount_outstanding decimal(28,6) DEFAULT NULL,
7669
            amount_last_increment decimal(28,6) DEFAULT NULL,
7670
            description mediumtext,
7671
            notes text,
7672
            dispute mediumtext,
7673
            notify_id int(11) NOT NULL DEFAULT '0',
7674
            notify_level int(2) NOT NULL DEFAULT '0',
7675
            manager_id int(11) DEFAULT NULL,
7676
            created_on timestamp NULL DEFAULT NULL,
7677
            updated_on timestamp NULL DEFAULT NULL,
7678
            PRIMARY KEY (debit_id),
7679
            KEY acctsborridx (borrowernumber),
7680
            KEY itemnumber (itemnumber),
7681
            KEY borrowernumber (borrowernumber),
7682
            KEY issue_id (issue_id)
7683
        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
7684
    ");
7685
7686
    $dbh->do("
7687
        CREATE TABLE account_offsets (
7688
            offset_id int(11) NOT NULL AUTO_INCREMENT,
7689
            debit_id int(11) DEFAULT NULL,
7690
            credit_id int(11) DEFAULT NULL,
7691
            amount decimal(28,6) NOT NULL COMMENT 'A positive number here represents a payment, a negative is a increase in a fine.',
7692
            created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
7693
            PRIMARY KEY (offset_id),
7694
            KEY fee_id (debit_id),
7695
            KEY payment_id (credit_id)
7696
        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
7697
    ");
7698
7699
    $dbh->do("
7700
        ALTER TABLE `account_credits`
7701
          ADD CONSTRAINT account_credits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7702
    ");
7703
    $dbh->do("
7704
        ALTER TABLE `account_debits`
7705
          ADD CONSTRAINT account_debits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7706
    ");
7707
    $dbh->do("
7708
        ALTER TABLE `account_offsets`
7709
          ADD CONSTRAINT account_offsets_ibfk_1 FOREIGN KEY (debit_id) REFERENCES account_debits (debit_id) ON DELETE CASCADE ON UPDATE CASCADE,
7710
          ADD CONSTRAINT account_offsets_ibfk_2 FOREIGN KEY (credit_id) REFERENCES account_credits (credit_id) ON DELETE CASCADE ON UPDATE CASCADE;
7711
    ");
7712
7713
    print "Upgrade to $DBversion done ( Bug 6427 - Rewrite of the accounts system )\n";
7714
    SetVersion ($DBversion);
7715
}
7716
7639
=head1 FUNCTIONS
7717
=head1 FUNCTIONS
7640
7718
7641
=head2 TableExists($table)
7719
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (-1 / +1 lines)
Lines 67-73 Link Here
67
        [% IF ( detailview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Details</a></li>
67
        [% IF ( detailview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Details</a></li>
68
    [% END %]
68
    [% END %]
69
    [% IF ( CAN_user_updatecharges ) %]
69
    [% IF ( CAN_user_updatecharges ) %]
70
        [% IF ( finesview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Fines</a></li>
70
        [% IF ( finesview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Fines</a></li>
71
    [% END %]
71
    [% END %]
72
    [% IF ( RoutingSerials ) %][% IF ( routinglistview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/routing-lists.pl?borrowernumber=[% borrowernumber %]">Routing lists</a></li>[% END %]
72
    [% IF ( RoutingSerials ) %][% IF ( routinglistview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/routing-lists.pl?borrowernumber=[% borrowernumber %]">Routing lists</a></li>[% END %]
73
    [% IF ( intranetreadinghistory ) %]
73
    [% IF ( intranetreadinghistory ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.tt (-1 / +1 lines)
Lines 70-76 in the global namespace %] Link Here
70
	[% IF ( detailview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]">Details</a></li>
70
	[% IF ( detailview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]">Details</a></li>
71
	[% END %]
71
	[% END %]
72
	 [% IF ( CAN_user_updatecharges ) %]
72
	 [% IF ( CAN_user_updatecharges ) %]
73
	[% IF ( finesview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrower.borrowernumber %]">Fines</a></li>
73
	[% IF ( finesview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Fines</a></li>
74
	[% END %]
74
	[% END %]
75
    [% IF ( RoutingSerials ) %][% IF ( routinglistview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/routing-lists.pl?borrowernumber=[% borrower.borrowernumber %]">Routing lists</a></li>[% END %]
75
    [% IF ( RoutingSerials ) %][% IF ( routinglistview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/routing-lists.pl?borrowernumber=[% borrower.borrowernumber %]">Routing lists</a></li>[% END %]
76
    [% IF ( intranetreadinghistory ) %][% IF ( readingrecordview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrower.borrowernumber %]">Circulation history</a></li>[% END %]
76
    [% IF ( intranetreadinghistory ) %][% IF ( readingrecordview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrower.borrowernumber %]">Circulation history</a></li>[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-menu.inc (-1 / +1 lines)
Lines 4-10 Link Here
4
    [% IF ( circview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% borrowernumber %]">Check out</a></li>
4
    [% IF ( circview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% borrowernumber %]">Check out</a></li>
5
    [% IF ( detailview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Details</a></li>
5
    [% IF ( detailview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Details</a></li>
6
    [% IF ( CAN_user_updatecharges ) %]
6
    [% IF ( CAN_user_updatecharges ) %]
7
        [% IF ( finesview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Fines</a></li>
7
        [% IF ( finesview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Fines</a></li>
8
    [% END %]
8
    [% END %]
9
    [% IF ( intranetreadinghistory ) %]
9
    [% IF ( intranetreadinghistory ) %]
10
        [% IF ( readingrecordview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrowernumber %]">Circulation history</a></li>
10
        [% IF ( readingrecordview ) %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrowernumber %]">Circulation history</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-2 / +2 lines)
Lines 577-587 No patron matched <span class="ex">[% message %]</span> Link Here
577
577
578
        	[% IF ( charges ) %]
578
        	[% IF ( charges ) %]
579
			    <li>
579
			    <li>
580
            <span class="circ-hlt">Fees &amp; Charges:</span> Patron has  <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Outstanding fees &amp; charges[% IF ( chargesamount ) %] of [% chargesamount %][% END %]</a>.
580
            <span class="circ-hlt">Fees &amp; Charges:</span> Patron has  <a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Outstanding fees &amp; charges[% IF ( chargesamount ) %] of [% chargesamount %][% END %]</a>.
581
                [% IF ( charges_is_blocker ) %]
581
                [% IF ( charges_is_blocker ) %]
582
                    Checkouts are <span class="circ-hlt">BLOCKED</span> because fine balance is <span class="circ-hlt">OVER THE LIMIT</span>.
582
                    Checkouts are <span class="circ-hlt">BLOCKED</span> because fine balance is <span class="circ-hlt">OVER THE LIMIT</span>.
583
                [% END %]
583
                [% END %]
584
            <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]">Make payment</a></li>
584
            <a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]">Make payment</a></li>
585
			[% END %]
585
			[% END %]
586
586
587
        	[% IF ( credits ) %]
587
        	[% IF ( credits ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +1 lines)
Lines 74-80 $(document).ready(function () { Link Here
74
[% IF ( fines ) %]
74
[% IF ( fines ) %]
75
    <div class="dialog alert">
75
    <div class="dialog alert">
76
        <h3>Patron has outstanding fines of [% fines %].</h3>
76
        <h3>Patron has outstanding fines of [% fines %].</h3>
77
        <p><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% fineborrowernumber %]">Make payment</a>.</p>
77
        <p><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% fineborrowernumber %]">Make payment</a>.</p>
78
    </div>
78
    </div>
79
[% END %]
79
[% END %]
80
80
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account.tt (+166 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Currency %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
<style type="text/css">
7
#account-tabs-debits, #account-tabs-credits {
8
    min-height:100px;
9
}
10
#account-tabs { 
11
    position: relative; 
12
    padding-right: 6.5em; 
13
} 
14
#account-tabs .ui-tabs-nav { 
15
    position: absolute; 
16
    right: 0.25em; 
17
    top: 1em; 
18
    bottom: 0.25em; 
19
    width: 6em; 
20
    padding: 0.2em 0.2em 0.2em 0em; 
21
} 
22
#account-tabs .ui-tabs-nav li { 
23
    width: 100%; 
24
    border-left: none; 
25
    border-bottom-width: 1px !important; 
26
    -moz-border-radius: 0px 4px 4px 0px; 
27
    -webkit-border-radius: 0px 4px 4px 0px; 
28
    border-radius: 0px 4px 4px 0px; 
29
    overflow: hidden; 
30
} 
31
#account-tabs .ui-tabs-nav li.ui-tabs-selected, 
32
#account-tabs .ui-tabs-nav li.ui-state-active { 
33
    left: -1px; 
34
    border-left: 1px solid transparent; 
35
} 
36
#account-tabs .ui-tabs-nav li a { 
37
    width: 100%; 
38
} 
39
</style>
40
<script>
41
$(function() {
42
    $( "#account-tabs" ).tabs();
43
    $( "#debits-accordion" ).accordion();
44
});
45
</script>
46
</head>
47
<body id="pat_borraccount" class="pat">
48
[% INCLUDE 'header.inc' %]
49
[% INCLUDE 'patron-search.inc' %]
50
51
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</div>
52
53
<div id="doc3" class="yui-t2">
54
    <div id="bd">
55
	    <div id="yui-main">
56
	        <div class="yui-b">
57
                [% INCLUDE 'members-toolbar.inc' %]
58
59
                <div class="statictabs">
60
                    <ul>
61
                        <li class="active">
62
                            <a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a>
63
                        </li>
64
65
                        <li>
66
                            <a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a>
67
                        </li>
68
69
                        <li>
70
                            <a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a>
71
                        </li>
72
73
                        <li>
74
                            <a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a>
75
                        </li>
76
                    </ul>
77
78
                    <div class="tabs-container">
79
80
                        <p>
81
                            <h3>Account balance: [% borrower.account_balance | $Currency %]</h3>
82
                        </p>
83
84
                        <div>
85
                            <div id="account-tabs">
86
                                <ul>
87
                                    <li>
88
                                        <a href="#account-tabs-debits">Fees</a>
89
                                    </li>
90
                                    <li>
91
                                     <a href="#account-tabs-credits">Payments</a>
92
                                    </li>
93
                                </ul>
94
95
                                <div id="account-tabs-debits">
96
                                    <div id="debits-accordion">
97
                                        [% FOREACH d IN debits %]
98
                                            <h3>
99
                                                &nbsp;&nbsp;&nbsp;&nbsp;
100
                                                [% d.amount_outstanding | $Currency %] ( [% d.amount_original | $Currency %] )
101
                                                [% d.created_on | $KohaDates %]
102
103
                                                [% d.description %]
104
                                            </h3>
105
106
                                            <div>
107
                                                [% IF d.notes %]
108
                                                    <p>
109
                                                        Notes: <i>[% d.notes %]</i>
110
                                                    </p>
111
                                                [% END %]
112
113
                                                [% IF d.updated_on %]
114
                                                    <p>
115
                                                        Last modified: [% d.updated_on | $KohaDates %]
116
                                                    </p>
117
                                                [% END %]
118
119
                                                [% IF d.account_offsets %]
120
                                                    <table>
121
                                                        <thead>
122
                                                            <tr>
123
                                                                <th colspan="5">Offsets</th>
124
                                                            </tr>
125
                                                            <tr>
126
                                                                <th>ID</td>
127
                                                                <th>Date applied</th>
128
                                                                <th>Amount applied</th>
129
                                                                <th>Type</th>
130
                                                                <th>Notes</th>
131
                                                            </tr>
132
                                                        </thead>
133
                                                                    
134
                                                        <tbody>
135
                                                            [% FOREACH ao IN d.account_offsets %]
136
                                                                <tr>
137
                                                                    <td>[% ao.credit.credit_id %]</td>
138
                                                                    <td>[% ao.created_on | $KohaDates %]</td>
139
                                                                    <td>[% ao.amount | $Currency %]</td>
140
                                                                    <td>[% ao.credit.type %]</td>
141
                                                                    <td>[% ao.credit.notes %]</td>
142
                                                                </tr>
143
                                                            [% END %]
144
                                                        </tbody>
145
                                                    </table>
146
                                                [% END %]
147
                                            </div>
148
                                        [% END %]
149
                                    </div>
150
                                </div>
151
152
                                <div id="account-tabs-credits">
153
                                    Payments
154
                                </div>
155
                            </div>
156
                        </div>
157
                    </div>
158
                </div>
159
            </div>
160
        </div>
161
162
    <div class="yui-b">
163
        [% INCLUDE 'circ-menu.inc' %]
164
    </div>
165
</div>
166
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_credit.tt (+91 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Borrowers &rsaquo; Create manual credit</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type="text/javascript">
5
//<![CDATA[
6
$(document).ready(function(){
7
        $('#account_credit').preventDoubleFormSubmit();
8
        $("fieldset.rows input").addClass("noEnterSubmit");
9
});
10
//]]>
11
</script>
12
</head>
13
<body id="pat_account_credit" class="pat">
14
    [% INCLUDE 'header.inc' %]
15
    [% INCLUDE 'patron-search.inc' %]
16
17
    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Manual credit</div>
18
19
    <div id="doc3" class="yui-t2">
20
        <div id="bd">
21
        	<div id="yui-main">
22
            	<div class="yui-b">
23
                    [% INCLUDE 'members-toolbar.inc' %]
24
25
                    <div class="statictabs">
26
                        <ul>
27
                            <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
28
                            <li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
29
                            <li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
30
                            <li class="active"><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
31
                        </ul>
32
33
                        <div class="tabs-container">
34
35
                            <form action="/cgi-bin/koha/members/account_credit_do.pl" method="post" id="account_credit">
36
                                <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
37
38
                                <fieldset class="rows">
39
                                    <legend>Manual credit</legend>
40
                                    
41
                                    <ol>
42
                                        <li>
43
                                            <label for="type">Credit Type: </label>
44
                                            <select name="type" id="type">
45
                                                <option value="CREDIT">Credit</option>
46
                                                <option value="FORGIVEN">Forgiven</option>
47
                                                [% FOREACH c IN credit_types_loop %]
48
                                                    <option value="[% c.authorised_value %]">[% c.lib %]</option>
49
                                                [% END %]
50
                                            </select>
51
                                        </li>
52
53
                                        <li>
54
                                            <label for="barcode">Barcode: </label>
55
                                            <input type="text" name="barcode" id="barcode" />
56
                                        </li>
57
58
                                        <li>
59
                                            <label for="desc">Description: </label>
60
                                            <input type="text" name="desc" size="50" id="desc" />
61
                                        </li>
62
63
                                        <li>
64
                                            <label for="note">Note: </label>
65
                                            <input type="text" name="note" size="50" id="note" />
66
                                        </li>
67
68
                                        <li>
69
                                            <label for="amount">Amount: </label>
70
                                            <input type="text" name="amount" id="amount" /> 
71
                                            Example: 5.00
72
                                        </li>
73
                                    </ol>
74
75
                                </fieldset>
76
77
                                <fieldset class="action">
78
                                    <input type="submit" name="add" value="Add credit" />
79
                                    <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Cancel</a>
80
                                </fieldset>
81
                            </form>
82
83
                        </div>
84
                    </div>
85
                </div>
86
            </div>
87
        <div class="yui-b">
88
            [% INCLUDE 'circ-menu.inc' %]
89
        </div>
90
    </div>
91
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_debit.tt (+108 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Borrowers &rsaquo; Create manual invoice</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type="text/javascript">
5
//<![CDATA[
6
$(document).ready(function(){
7
    $('#maninvoice').preventDoubleFormSubmit();
8
    $("fieldset.rows input").addClass("noEnterSubmit");
9
10
    var type_fees = new Array();
11
    type_fees['L'] = '';
12
    type_fees['F'] = '';
13
    type_fees['A'] = '';
14
    type_fees['N'] = '';
15
    type_fees['M'] = '';
16
    [% FOREACH invoice_types_loo IN invoice_types_loop %]
17
        type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.lib %]";
18
    [% END %]
19
});
20
//]]>
21
</script>
22
</head>
23
24
<body>
25
    [% INCLUDE 'header.inc' %]
26
    [% INCLUDE 'patron-search.inc' %]
27
28
    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Manual invoice</div>
29
30
    <div id="doc3" class="yui-t2">
31
        <div id="bd">
32
            <div id="yui-main">
33
                <div class="yui-b">
34
                    [% INCLUDE 'members-toolbar.inc' %]
35
36
                    <div class="statictabs">
37
                    <ul>
38
                        <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
39
                        <li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
40
                        <li class="active"><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
41
                        <li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
42
                    </ul>
43
                    <div class="tabs-container">
44
45
                    <form action="/cgi-bin/koha/members/account_debit_do.pl" method="post" id="account_debit">
46
                        <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
47
48
                        <fieldset class="rows">
49
                            <legend>Manual Invoice</legend>
50
51
                            <ol>
52
                                <li>
53
                                    <label for="type">Type: </label>
54
                                    <select name="type" id="type">
55
                                        <option value="LOST">Lost item</option>
56
                                        <option value="FINE">Fine</option>
57
                                        <option value="ACCOUNT_MANAGEMENT_FEE">Account management fee</option>
58
                                        <option value="NEW_CARD">New card</option>
59
                                        <option value="SUNDRY">Sundry</option>
60
61
                                        [% FOREACH invoice_types_loo IN invoice_types_loop %]
62
                                            <option value="[% invoice_types_loo.authorised_value %]">[% invoice_types_loo.lib %]</option>
63
                                        [% END %]
64
                                    </select>
65
                                </li>
66
67
                                <!-- TODO: Write ajax barcode validator that appends the itemnumber for this form in a hidden input -->
68
	                            <li>
69
                                    <label for="barcode">Barcode: </label>
70
                                    <input type="text" name="barcode" id="barcode" />
71
                                </li>
72
73
                                <li>
74
                                    <label for="description">Description: </label>
75
                                    <input type="text" name="description" id="description" size="50" />
76
                                </li>
77
    
78
                                <li>
79
                                    <label for="notes">Notes: </label>
80
                                    <input type="text" name="notes" size="50" id="notes" />
81
                                </li>
82
	
83
                                <li>
84
                                    <label for="amount">Amount: </label>
85
                                    <input type="text" name="amount" id="amount" /> Example: 5.00
86
                                </li>
87
88
                            </ol>
89
                        </fieldset>
90
91
                        <fieldset class="action">
92
                            <input type="submit" name="add" value="Save" /> 
93
                            <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Cancel</a>
94
                        </fieldset>
95
96
                    </form>
97
98
                </div>
99
            </div>
100
        </div>
101
    </div>
102
103
<div class="yui-b">
104
  [% INCLUDE 'circ-menu.inc' %]
105
</div>
106
107
</div>
108
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_payment.tt (+196 lines)
Line 0 Link Here
1
[% USE Currency %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Patrons &rsaquo; Pay Fines for  [% borrower.firstname %] [% borrower.surname %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
6
<script type= "text/javascript">
7
//<![CDATA[
8
$( document ).ready(function() {
9
    // Show amount recieved only if the "Receive different amount" checkbox is checked
10
    $("#amount-received-p").hide();
11
    $('#receive_different_amount').click(function() {
12
        if( $(this).is(':checked')) {
13
            $("#amount-received-p").show();
14
        } else {
15
            $("#amount-received-p").hide();
16
        }
17
    }); 
18
19
    // Enable the "Select all/Clear all" links
20
    $('#CheckAll').click(function() {
21
        $("input[name='debit_id']" ).prop('checked', true);
22
    }); 
23
    $('#ClearAll').click(function() {
24
        $("input[name='debit_id']" ).prop('checked', false);
25
    }); 
26
27
    // Update the "amount to pay" field whenever a fee checkbox is changed
28
    // Note, this is just a payment suggestion and can be changed to any amount
29
    $("input[name='debit_id']" ).change(function() {
30
        var sum = 0;
31
        $("input[name='debit_id']:checked" ).each(function(i,n){
32
            sum += parseFloat( $( "#amount_outstanding_" + $(this).val() ).val() );
33
        });
34
        $('#amount_to_pay').val( sum );
35
    });
36
});
37
38
function checkForm(){
39
    if ( parseFloat( $('#amount_to_receive').val() ) < parseFloat( $('#amount_to_pay').val() ) ) {
40
        alert( _("Cannot pay more than receieved!") );
41
        return false;
42
    }
43
44
    return true;
45
}
46
//]]>
47
</script>
48
</head>
49
<body id="pat_pay" class="pat">
50
    [% INCLUDE 'header.inc' %]
51
    [% INCLUDE 'patron-search.inc' %]
52
53
    <div id="breadcrumbs">
54
        <a href="/cgi-bin/koha/mainpage.pl">Home</a> 
55
        &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  
56
        &rsaquo; Pay fines for [% borrower.firstname %] [% borrower.surname %]
57
    </div>
58
59
    <div id="doc3" class="yui-t2">
60
        <div id="bd">
61
            <div id="yui-main">
62
                <div class="yui-b">
63
                    [% INCLUDE 'members-toolbar.inc' borrowernumber=borrower.borrowernumber %]
64
65
                    <div class="statictabs">
66
                        <ul>
67
                            <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Account</a></li>
68
                            <li class="active"><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrower.borrowernumber %]" >Pay fines</a></li>
69
                            <li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual invoice</a></li>
70
                            <li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a></li>
71
                        </ul>
72
73
                        <div class="tabs-container">
74
75
                        [% IF ( debits ) %]
76
                            <form action="/cgi-bin/koha/members/account_payment_do.pl" method="post" id="account-payment-form" onsubmit="return checkForm()">
77
78
                                <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
79
80
                                <p>
81
                                    <span class="checkall">
82
                                        <a id="CheckAll" href="#">Select all</a>
83
                                    </span> 
84
                                    
85
                                    | 
86
                                    
87
                                    <span class="clearall">
88
                                        <a id="ClearAll" href="#">Clear all</a>
89
                                    </span>
90
                                </p>
91
92
                                <table id="finest">
93
                                    <thead>
94
                                        <tr>
95
                                            <th>&nbsp;</th>
96
                                            <th>Description</th>
97
                                            <th>Account type</th>
98
                                            <th>Original amount</th>
99
                                            <th>Amount outstanding</th>
100
                                        </tr>
101
                                    </thead>
102
103
                                    <tbody>
104
                                        [% SET total_due = 0 %]
105
                                        [% FOREACH d IN debits %]
106
                                            [% SET total_due = total_due + d.amount_outstanding %]
107
                                            <tr>
108
                                                <td>
109
                                                    <input type="checkbox" checked="checked" name="debit_id" value="[% d.debit_id %]" />
110
                                                </td>
111
112
                                                <td>
113
                                                    [% d.description %]
114
115
                                                    [% IF d.notes %]
116
                                                        ( <i>[% d.notes %]</i> )
117
                                                    [% END %]
118
                                                </td>
119
120
                                                <td>
121
                                                    [% d.type %]
122
                                                </td>
123
124
                                                <td class="debit">
125
                                                    [% d.amount_original | $Currency %]
126
                                                    <input type="hidden" id="amount_original_[% d.debit_id %]" value="[% Currency.format_without_symbol( d.amount_original ) %]" />
127
                                                </td>
128
129
                                                <td class="debit">
130
                                                    [% d.amount_outstanding | $Currency %]
131
                                                    <input type="hidden" id="amount_outstanding_[% d.debit_id %]" value="[% Currency.format_without_symbol( d.amount_outstanding ) %]" />
132
                                                </td>
133
                                            </tr>
134
                                        [% END %]
135
                                    </tbody>
136
137
                                    <tfoot>
138
                                        <tr>
139
                                            <td class="total" colspan="4">Total Due:</td>
140
                                            <td>[% total_due | $Currency %]</td>
141
                                        </tr>
142
                                    </tfoot>
143
144
                                </table>
145
146
                                <fieldset>
147
                                    <p>
148
                                        <label for="amount_to_pay">Amount to pay: [% Currency.symbol() %]</label>
149
                                        <input type="text" name="amount_to_pay" id="amount_to_pay" value="[% Currency.format_without_symbol( total_due ) %]" />
150
151
                                        <input type="checkbox" id="receive_different_amount" />
152
                                        <label for="receive_different_amount"><i>Receive different amount</i></label>
153
                                    </p>
154
155
                                    <p id="amount-received-p">
156
                                        <label for="amount_to_receive">Amount recieved: [% Currency.symbol() %]</label>
157
                                        <input type="text" name="amount_to_receive" id="amount_to_receive" />
158
                                    </p>
159
160
                                    <p>
161
                                        <label for="type">Type:</label>
162
                                        <select id="type" name="type">
163
                                            <option value="PAYMENT">Payment</option>
164
                                            <option value="WRITEOFF">Write-off</option>
165
                                        </select>
166
                                    </p>
167
168
                                    <p>
169
                                        <label for="notes">Payment notes:</label>
170
                                        <input type="textbox" name="notes" id="notes" />
171
                                    <p>
172
                                </fieldset>
173
174
                                <fieldset class="action">
175
                                    <input type="submit" value="Process" class="submit" />
176
                                    <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a>
177
                                </fieldset>
178
179
                            </form>
180
181
                        [% ELSE %]
182
                            <p>
183
                                [% borrower.firstname %] [% borrower.surname %] has no outstanding fines.
184
                            </p>
185
                        [% END %]
186
187
                    </div>
188
                </div>
189
            </div>
190
        </div>
191
192
        <div class="yui-b">
193
            [% INCLUDE 'circ-menu.tt' %]
194
        </div>
195
    </div>
196
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-6 / +6 lines)
Lines 14-28 Link Here
14
	<div id="yui-main">
14
	<div id="yui-main">
15
	<div class="yui-b">
15
	<div class="yui-b">
16
[% INCLUDE 'members-toolbar.inc' %]
16
[% INCLUDE 'members-toolbar.inc' %]
17
<form action="/cgi-bin/koha/members/boraccount.pl" method="get"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" /></form>
17
<form action="/cgi-bin/koha/members/account.pl" method="get"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" /></form>
18
18
19
<!-- The manual invoice and credit buttons -->
19
<!-- The manual invoice and credit buttons -->
20
<div class="statictabs">
20
<div class="statictabs">
21
<ul>
21
<ul>
22
    <li class="active"><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
22
    <li class="active"><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
23
	<li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
23
	<li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
24
	<li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
24
	<li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
25
	<li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
25
	<li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
26
</ul>
26
</ul>
27
<div class="tabs-container">
27
<div class="tabs-container">
28
<!-- The table with the account items -->
28
<!-- The table with the account items -->
Lines 51-57 Link Here
51
    [% IF ( reverse_col ) %]
51
    [% IF ( reverse_col ) %]
52
      <td>
52
      <td>
53
	[% IF ( account.payment ) %]
53
	[% IF ( account.payment ) %]
54
		<a href="boraccount.pl?action=reverse&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]">Reverse</a>
54
		<a href="account.pl?action=reverse&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]">Reverse</a>
55
	[% ELSE %]
55
	[% ELSE %]
56
		&nbsp;
56
		&nbsp;
57
	[% END %]
57
	[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt (-6 / +6 lines)
Lines 26-39 $(document).ready(function(){ Link Here
26
<!-- The manual invoice and credit buttons -->
26
<!-- The manual invoice and credit buttons -->
27
<div class="statictabs">
27
<div class="statictabs">
28
<ul>
28
<ul>
29
	<li><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
29
	<li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
30
	<li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
30
	<li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
31
	<li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
31
	<li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
32
    <li class="active"><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
32
    <li class="active"><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
33
</ul>
33
</ul>
34
<div class="tabs-container">
34
<div class="tabs-container">
35
35
36
<form action="/cgi-bin/koha/members/mancredit.pl" method="post" id="mancredit">
36
<form action="/cgi-bin/koha/members/account_credit.pl" method="post" id="mancredit">
37
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
37
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
38
38
39
<fieldset class="rows">
39
<fieldset class="rows">
Lines 48-54 $(document).ready(function(){ Link Here
48
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
48
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
49
</ol></fieldset>
49
</ol></fieldset>
50
50
51
<fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Cancel</a></fieldset>
51
<fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Cancel</a></fieldset>
52
</form>
52
</form>
53
53
54
</div></div>
54
</div></div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt (-6 / +6 lines)
Lines 26-35 $(document).ready(function(){ Link Here
26
<!-- The manual invoice and credit buttons -->
26
<!-- The manual invoice and credit buttons -->
27
<div class="statictabs">
27
<div class="statictabs">
28
<ul>
28
<ul>
29
	<li><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
29
	<li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
30
	<li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
30
	<li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
31
    <li class="active"><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
31
    <li class="active"><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
32
	<li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
32
	<li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
33
</ul>
33
</ul>
34
<div class="tabs-container">
34
<div class="tabs-container">
35
35
Lines 38-44 $(document).ready(function(){ Link Here
38
  ERROR an invalid itemnumber was entered, please hit back and try again
38
  ERROR an invalid itemnumber was entered, please hit back and try again
39
[% END %]
39
[% END %]
40
[% ELSE %]
40
[% ELSE %]
41
<form action="/cgi-bin/koha/members/maninvoice.pl" method="post" id="maninvoice"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
41
<form action="/cgi-bin/koha/members/account_debit.pl" method="post" id="maninvoice"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
42
	<fieldset class="rows">
42
	<fieldset class="rows">
43
	<legend>Manual Invoice</legend>
43
	<legend>Manual Invoice</legend>
44
	<ol>
44
	<ol>
Lines 71-77 type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.li Link Here
71
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
71
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
72
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
72
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
73
	</ol></fieldset>
73
	</ol></fieldset>
74
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Cancel</a></fieldset>
74
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Cancel</a></fieldset>
75
</form>
75
</form>
76
76
77
[% END %]
77
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (-6 / +6 lines)
Lines 55-69 function enableCheckboxActions(){ Link Here
55
<!-- The manual invoice and credit buttons -->
55
<!-- The manual invoice and credit buttons -->
56
<div class="statictabs">
56
<div class="statictabs">
57
<ul>
57
<ul>
58
	<li><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrower.borrowernumber %]">Account</a></li>
58
	<li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Account</a></li>
59
    <li class="active"><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]" >Pay fines</a></li>
59
    <li class="active"><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrower.borrowernumber %]" >Pay fines</a></li>
60
	<li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual invoice</a></li>
60
	<li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual invoice</a></li>
61
	<li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a></li>
61
	<li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a></li>
62
</ul>
62
</ul>
63
<div class="tabs-container">
63
<div class="tabs-container">
64
64
65
[% IF ( accounts ) %]
65
[% IF ( accounts ) %]
66
    <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form">
66
    <form action="/cgi-bin/koha/members/account_payment.pl" method="post" id="pay-fines-form">
67
	<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
67
	<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
68
<p><span class="checkall"><a id="CheckAll" href="#">Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#">Clear all</a></span></p>
68
<p><span class="checkall"><a id="CheckAll" href="#">Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#">Clear all</a></span></p>
69
<table id="finest">
69
<table id="finest">
Lines 135-141 function enableCheckboxActions(){ Link Here
135
<input type="submit" id="paycollect" name="paycollect"  value="Pay amount" class="submit" />
135
<input type="submit" id="paycollect" name="paycollect"  value="Pay amount" class="submit" />
136
<input type="submit" name="woall"  id="woall" value="Write off all" class="submit" />
136
<input type="submit" name="woall"  id="woall" value="Write off all" class="submit" />
137
<input type="submit" id="payselected" name="payselected"  value="Pay selected" class="submit" />
137
<input type="submit" id="payselected" name="payselected"  value="Pay selected" class="submit" />
138
<a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a>
138
<a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a>
139
</fieldset>
139
</fieldset>
140
</form>
140
</form>
141
[% ELSE %]
141
[% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (-9 / +9 lines)
Lines 64-70 function moneyFormat(textObj) { Link Here
64
<body id="pat_paycollect" class="pat">
64
<body id="pat_paycollect" class="pat">
65
[% INCLUDE 'header.inc' %]
65
[% INCLUDE 'header.inc' %]
66
[% INCLUDE 'patron-search.inc' %]
66
[% INCLUDE 'patron-search.inc' %]
67
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]">Pay fines for [% borrower.firstname %] [% borrower.surname %]</a> &rsaquo; [% IF ( pay_individual ) %]Pay an individual fine[% ELSIF ( writeoff_individual ) %]Write off an individual fine[% ELSE %][% IF ( selected_accts ) %]Pay an amount toward selected fines[% ELSE %]Pay an amount toward all fines[% END %][% END %]</div>
67
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; <a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrower.borrowernumber %]">Pay fines for [% borrower.firstname %] [% borrower.surname %]</a> &rsaquo; [% IF ( pay_individual ) %]Pay an individual fine[% ELSIF ( writeoff_individual ) %]Write off an individual fine[% ELSE %][% IF ( selected_accts ) %]Pay an amount toward selected fines[% ELSE %]Pay an amount toward all fines[% END %][% END %]</div>
68
68
69
<div id="doc3" class="yui-t2">
69
<div id="doc3" class="yui-t2">
70
70
Lines 78-93 function moneyFormat(textObj) { Link Here
78
<div class="statictabs">
78
<div class="statictabs">
79
<ul>
79
<ul>
80
    <li>
80
    <li>
81
    <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrower.borrowernumber %]">Account</a>
81
    <a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Account</a>
82
    </li>
82
    </li>
83
    <li class="active">
83
    <li class="active">
84
    <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]" >Pay fines</a>
84
    <a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrower.borrowernumber %]" >Pay fines</a>
85
    </li>
85
    </li>
86
    <li>
86
    <li>
87
    <a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual invoice</a>
87
    <a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual invoice</a>
88
    </li>
88
    </li>
89
    <li>
89
    <li>
90
    <a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a>
90
    <a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a>
91
    </li>
91
    </li>
92
</ul>
92
</ul>
93
<div class="tabs-container">
93
<div class="tabs-container">
Lines 150-159 function moneyFormat(textObj) { Link Here
150
</fieldset>
150
</fieldset>
151
151
152
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
152
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
153
        <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a></div>
153
        <a class="cancel" href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a></div>
154
    </form>
154
    </form>
155
[% ELSIF ( writeoff_individual ) %]
155
[% ELSIF ( writeoff_individual ) %]
156
    <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
156
    <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/account_payment.pl" method="post" >
157
    <fieldset class="rows">
157
    <fieldset class="rows">
158
    <legend>Write off an individual fine</legend>
158
    <legend>Write off an individual fine</legend>
159
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
159
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
Lines 190-196 function moneyFormat(textObj) { Link Here
190
    </table>
190
    </table>
191
    </fieldset>
191
    </fieldset>
192
    <div class="action"><input type="submit" name="confirm_writeoff" id="confirm_writeoff" value="Write off this charge" />
192
    <div class="action"><input type="submit" name="confirm_writeoff" id="confirm_writeoff" value="Write off this charge" />
193
        <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a></div>
193
        <a class="cancel" href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a></div>
194
    </form>
194
    </form>
195
[% ELSE %]
195
[% ELSE %]
196
196
Lines 218-224 function moneyFormat(textObj) { Link Here
218
    </ol>
218
    </ol>
219
    </fieldset>
219
    </fieldset>
220
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
220
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
221
        <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a></div>
221
        <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a></div>
222
    </form>
222
    </form>
223
[% END %]
223
[% END %]
224
</div></div>
224
</div></div>
(-)a/members/account.pl (+111 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2013 ByWater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Dates qw/format_date/;
28
use C4::Members;
29
use C4::Branch;
30
use C4::Accounts;
31
use C4::Members::Attributes qw(GetBorrowerAttributes);
32
use Koha::Database;
33
34
my $cgi = new CGI;
35
36
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37
    {
38
        template_name   => "members/account.tt",
39
        query           => $cgi,
40
        type            => "intranet",
41
        authnotrequired => 0,
42
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
43
        debug           => 1,
44
    }
45
);
46
47
my $borrowernumber = $cgi->param('borrowernumber');
48
49
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
50
51
my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search(
52
    { 'me.borrowernumber' => $borrowernumber },
53
    { prefetch            => { account_offsets => 'credit' } }
54
);
55
56
my @credits => Koha::Database->new()->schema->resultset('AccountCredit')
57
  ->search( { borrowernumber => $borrowernumber } );
58
59
$template->param(
60
    debits   => \@debits,
61
    credits  => \@credits,
62
    borrower => $borrower,
63
);
64
65
# Standard /members/ borrower details data
66
## FIXME: This code is in every /members/ script and should be unified
67
68
if ( $borrower->{'category_type'} eq 'C' ) {
69
    my ( $catcodes, $labels ) =
70
      GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
71
    my $cnt = scalar(@$catcodes);
72
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
73
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
74
}
75
76
my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} );
77
$template->param( picture => 1 ) if $picture;
78
79
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
80
    my $attributes = GetBorrowerAttributes($borrowernumber);
81
    $template->param(
82
        ExtendedPatronAttributes => 1,
83
        extendedattributes       => $attributes
84
    );
85
}
86
87
$template->param(
88
    borrowernumber => $borrowernumber,
89
    firstname      => $borrower->{'firstname'},
90
    surname        => $borrower->{'surname'},
91
    cardnumber     => $borrower->{'cardnumber'},
92
    categorycode   => $borrower->{'categorycode'},
93
    category_type  => $borrower->{'category_type'},
94
    categoryname   => $borrower->{'description'},
95
    address        => $borrower->{'address'},
96
    address2       => $borrower->{'address2'},
97
    city           => $borrower->{'city'},
98
    state          => $borrower->{'state'},
99
    zipcode        => $borrower->{'zipcode'},
100
    country        => $borrower->{'country'},
101
    phone          => $borrower->{'phone'},
102
    email          => $borrower->{'email'},
103
    branchcode     => $borrower->{'branchcode'},
104
    branchname     => GetBranchName( $borrower->{'branchcode'} ),
105
    is_child       => ( $borrower->{'category_type'} eq 'C' ),
106
    activeBorrowerRelationship =>
107
      ( C4::Context->preference('borrowerRelationship') ne '' ),
108
    RoutingSerials => C4::Context->preference('RoutingSerials'),
109
);
110
111
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/members/account_credit.pl (+104 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#written 11/1/2000 by chris@katipo.oc.nz
4
#script to display borrowers account details
5
6
# Copyright 2000-2002 Katipo Communications
7
# Copyright 2010 BibLibre
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it under the
12
# terms of the GNU General Public License as published by the Free Software
13
# Foundation; either version 2 of the License, or (at your option) any later
14
# version.
15
#
16
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License along
21
# with Koha; if not, write to the Free Software Foundation, Inc.,
22
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
use strict;
25
use warnings;
26
27
use C4::Auth;
28
use C4::Output;
29
use CGI;
30
31
use C4::Koha;
32
use C4::Members;
33
use C4::Branch;
34
use C4::Accounts;
35
use C4::Items;
36
use C4::Members::Attributes qw(GetBorrowerAttributes);
37
use Koha::Database;
38
39
my $cgi = new CGI;
40
41
my $borrowernumber = $cgi->param('borrowernumber');
42
43
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
44
45
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
    {
47
        template_name   => "members/account_credit.tt",
48
        query           => $cgi,
49
        type            => "intranet",
50
        authnotrequired => 0,
51
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
52
        debug           => 1,
53
    }
54
);
55
56
$template->param( credit_types_loop => GetAuthorisedValues('ACCOUNT_CREDIT') );
57
58
# Standard /members/ borrower details data
59
## FIXME: This code is in every /members/ script and should be unified
60
61
if ( $borrower->{'category_type'} eq 'C' ) {
62
    my ( $catcodes, $labels ) =
63
      GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
64
    my $cnt = scalar(@$catcodes);
65
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
66
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
67
}
68
69
my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} );
70
$template->param( picture => 1 ) if $picture;
71
72
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
73
    my $attributes = GetBorrowerAttributes($borrowernumber);
74
    $template->param(
75
        ExtendedPatronAttributes => 1,
76
        extendedattributes       => $attributes
77
    );
78
}
79
80
$template->param(
81
    borrowernumber => $borrowernumber,
82
    firstname      => $borrower->{'firstname'},
83
    surname        => $borrower->{'surname'},
84
    cardnumber     => $borrower->{'cardnumber'},
85
    categorycode   => $borrower->{'categorycode'},
86
    category_type  => $borrower->{'category_type'},
87
    categoryname   => $borrower->{'description'},
88
    address        => $borrower->{'address'},
89
    address2       => $borrower->{'address2'},
90
    city           => $borrower->{'city'},
91
    state          => $borrower->{'state'},
92
    zipcode        => $borrower->{'zipcode'},
93
    country        => $borrower->{'country'},
94
    phone          => $borrower->{'phone'},
95
    email          => $borrower->{'email'},
96
    branchcode     => $borrower->{'branchcode'},
97
    branchname     => GetBranchName( $borrower->{'branchcode'} ),
98
    is_child       => ( $borrower->{'category_type'} eq 'C' ),
99
    activeBorrowerRelationship =>
100
      ( C4::Context->preference('borrowerRelationship') ne '' ),
101
    RoutingSerials => C4::Context->preference('RoutingSerials'),
102
);
103
104
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/members/account_credit_do.pl (+68 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2010 BibLibre
5
# Copyright 2013 ByWater Solutions
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
use Modern::Perl;
23
24
use CGI;
25
26
use C4::Auth;
27
use C4::Output;
28
use C4::Members;
29
use C4::Items;
30
use C4::Branch;
31
use C4::Members::Attributes qw(GetBorrowerAttributes);
32
use Koha::Accounts;
33
use Koha::Database;
34
35
my $cgi = new CGI;
36
37
my $borrowernumber = $cgi->param('borrowernumber');
38
my $borrower =
39
  Koha::Database->new()->schema->resultset('Borrower')->find($borrowernumber);
40
41
if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) {
42
43
    my $barcode     = $cgi->param('barcode');
44
    my $itemnumber  = $cgi->param('itemnumber');
45
    my $description = $cgi->param('description');
46
    my $amount      = $cgi->param('amount');
47
    my $type        = $cgi->param('type');
48
    my $notes       = $cgi->param('notes');
49
50
    if ( !$itemnumber && $barcode ) {
51
        $itemnumber = GetItemnumberFromBarcode($barcode);
52
    }
53
54
    my $debit = AddCredit(
55
        {
56
            borrower    => $borrower,
57
            amount      => $amount,
58
            type        => $type,
59
            itemnumber  => $itemnumber,
60
            description => $description,
61
            notes       => $notes,
62
63
        }
64
    );
65
66
    print $cgi->redirect(
67
        "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
68
}
(-)a/members/account_debit.pl (+104 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#written 11/1/2000 by chris@katipo.oc.nz
4
#script to display borrowers account details
5
6
# Copyright 2000-2002 Katipo Communications
7
# Copyright 2010 BibLibre
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it under the
12
# terms of the GNU General Public License as published by the Free Software
13
# Foundation; either version 2 of the License, or (at your option) any later
14
# version.
15
#
16
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License along
21
# with Koha; if not, write to the Free Software Foundation, Inc.,
22
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
use strict;
25
use warnings;
26
27
use CGI;
28
29
use C4::Auth;
30
use C4::Output;
31
use C4::Members;
32
use C4::Items;
33
use C4::Branch;
34
use C4::Members::Attributes qw(GetBorrowerAttributes);
35
use C4::Koha;
36
use Koha::Accounts;
37
use Koha::Database;
38
39
my $input = new CGI;
40
41
my $borrowernumber = $input->param('borrowernumber');
42
43
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
44
45
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
    {
47
        template_name   => "members/account_debit.tt",
48
        query           => $input,
49
        type            => "intranet",
50
        authnotrequired => 0,
51
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
52
        debug           => 1,
53
    }
54
);
55
56
$template->param( invoice_types_loop => GetAuthorisedValues('MANUAL_INV') );
57
58
# Standard /members/ borrower details data
59
## FIXME: This code is in every /members/ script and should be unified
60
61
if ( $borrower->{'category_type'} eq 'C' ) {
62
    my ( $catcodes, $labels ) =
63
      GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
64
    my $cnt = scalar(@$catcodes);
65
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
66
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
67
}
68
69
my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} );
70
$template->param( picture => 1 ) if $picture;
71
72
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
73
    my $attributes = GetBorrowerAttributes($borrowernumber);
74
    $template->param(
75
        ExtendedPatronAttributes => 1,
76
        extendedattributes       => $attributes
77
    );
78
}
79
80
$template->param(
81
    borrowernumber => $borrowernumber,
82
    firstname      => $borrower->{'firstname'},
83
    surname        => $borrower->{'surname'},
84
    cardnumber     => $borrower->{'cardnumber'},
85
    categorycode   => $borrower->{'categorycode'},
86
    category_type  => $borrower->{'category_type'},
87
    categoryname   => $borrower->{'description'},
88
    address        => $borrower->{'address'},
89
    address2       => $borrower->{'address2'},
90
    city           => $borrower->{'city'},
91
    state          => $borrower->{'state'},
92
    zipcode        => $borrower->{'zipcode'},
93
    country        => $borrower->{'country'},
94
    phone          => $borrower->{'phone'},
95
    email          => $borrower->{'email'},
96
    branchcode     => $borrower->{'branchcode'},
97
    branchname     => GetBranchName( $borrower->{'branchcode'} ),
98
    is_child       => ( $borrower->{'category_type'} eq 'C' ),
99
    activeBorrowerRelationship =>
100
      ( C4::Context->preference('borrowerRelationship') ne '' ),
101
    RoutingSerials => C4::Context->preference('RoutingSerials'),
102
);
103
104
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/account_debit_do.pl (+69 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2010 BibLibre
5
# Copyright 2013 ByWater Solutions
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
use Modern::Perl;
23
24
use CGI;
25
26
use C4::Auth;
27
use C4::Output;
28
use C4::Members;
29
use C4::Items;
30
use C4::Branch;
31
use C4::Members::Attributes qw(GetBorrowerAttributes);
32
use Koha::Accounts;
33
use Koha::Database;
34
35
my $cgi = new CGI;
36
37
my $borrowernumber = $cgi->param('borrowernumber');
38
my $borrower =
39
  Koha::Database->new()->schema->resultset('Borrower')->find($borrowernumber);
40
41
if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) {
42
43
    #  print $cgi->header;
44
    my $barcode     = $cgi->param('barcode');
45
    my $itemnumber  = $cgi->param('itemnumber');
46
    my $description = $cgi->param('description');
47
    my $amount      = $cgi->param('amount');
48
    my $type        = $cgi->param('type');
49
    my $notes       = $cgi->param('notes');
50
51
    if ( !$itemnumber && $barcode ) {
52
        $itemnumber = GetItemnumberFromBarcode($barcode);
53
    }
54
55
    my $debit = AddDebit(
56
        {
57
            borrower    => $borrower,
58
            amount      => $amount,
59
            type        => $type,
60
            itemnumber  => $itemnumber,
61
            description => $description,
62
            notes       => $notes,
63
64
        }
65
    );
66
67
    print $cgi->redirect(
68
        "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
69
}
(-)a/members/account_payment.pl (+123 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2010 BibLibre
5
# Copyright 2010,2011 PTFS-Europe Ltd
6
# Copyright 2013 ByWater Solutions
7
#
8
# This file is part of Koha.
9
#
10
# Koha is free software; you can redistribute it and/or modify it under the
11
# terms of the GNU General Public License as published by the Free Software
12
# Foundation; either version 2 of the License, or (at your option) any later
13
# version.
14
#
15
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License along
20
# with Koha; if not, write to the Free Software Foundation, Inc.,
21
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23
=head1 account_payment.pl
24
25
 written 11/1/2000 by chris@katipo.oc.nz
26
 part of the koha library system, script to facilitate paying off fines
27
28
=cut
29
30
use Modern::Perl;
31
32
use CGI;
33
34
use URI::Escape;
35
36
use C4::Context;
37
use C4::Auth;
38
use C4::Output;
39
use C4::Members;
40
use C4::Accounts;
41
use C4::Stats;
42
use C4::Koha;
43
use C4::Overdues;
44
use C4::Branch;
45
use C4::Members::Attributes qw(GetBorrowerAttributes);
46
use Koha::Database;
47
48
our $cgi = CGI->new;
49
50
our ( $template, $loggedinuser, $cookie ) = get_template_and_user(
51
    {
52
        template_name   => 'members/account_payment.tt',
53
        query           => $cgi,
54
        type            => 'intranet',
55
        authnotrequired => 0,
56
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
57
        debug           => 1,
58
    }
59
);
60
61
my $borrowernumber = $cgi->param('borrowernumber');
62
63
my $borrower = GetMember( borrowernumber => $borrowernumber );
64
65
my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search(
66
    {
67
        'me.borrowernumber' => $borrowernumber,
68
        amount_outstanding  => { '>' => 0 }
69
    }
70
);
71
72
$template->param(
73
    debits   => \@debits,
74
    borrower => $borrower,
75
);
76
77
# Standard /members/ borrower details data
78
## FIXME: This code is in every /members/ script and should be unified
79
80
if ( $borrower->{'category_type'} eq 'C' ) {
81
    my ( $catcodes, $labels ) =
82
      GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
83
    my $cnt = scalar(@$catcodes);
84
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
85
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
86
}
87
88
my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} );
89
$template->param( picture => 1 ) if $picture;
90
91
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
92
    my $attributes = GetBorrowerAttributes($borrowernumber);
93
    $template->param(
94
        ExtendedPatronAttributes => 1,
95
        extendedattributes       => $attributes
96
    );
97
}
98
99
$template->param(
100
    borrowernumber => $borrowernumber,
101
    firstname      => $borrower->{'firstname'},
102
    surname        => $borrower->{'surname'},
103
    cardnumber     => $borrower->{'cardnumber'},
104
    categorycode   => $borrower->{'categorycode'},
105
    category_type  => $borrower->{'category_type'},
106
    categoryname   => $borrower->{'description'},
107
    address        => $borrower->{'address'},
108
    address2       => $borrower->{'address2'},
109
    city           => $borrower->{'city'},
110
    state          => $borrower->{'state'},
111
    zipcode        => $borrower->{'zipcode'},
112
    country        => $borrower->{'country'},
113
    phone          => $borrower->{'phone'},
114
    email          => $borrower->{'email'},
115
    branchcode     => $borrower->{'branchcode'},
116
    branchname     => GetBranchName( $borrower->{'branchcode'} ),
117
    is_child       => ( $borrower->{'category_type'} eq 'C' ),
118
    activeBorrowerRelationship =>
119
      ( C4::Context->preference('borrowerRelationship') ne '' ),
120
    RoutingSerials => C4::Context->preference('RoutingSerials'),
121
);
122
123
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/members/account_payment_do.pl (+62 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2010 BibLibre
5
# Copyright 2013 ByWater Solutions
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
use Modern::Perl;
23
24
use CGI;
25
26
use C4::Auth;
27
use C4::Members;
28
use C4::Items;
29
use C4::Branch;
30
use C4::Members::Attributes qw(GetBorrowerAttributes);
31
use Koha::Accounts;
32
use Koha::Database;
33
34
my $cgi = new CGI;
35
36
if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) {
37
    my $borrowernumber = $cgi->param('borrowernumber');
38
39
    my $borrower =
40
      Koha::Database->new()->schema->resultset('Borrower')
41
      ->find($borrowernumber);
42
43
    my $amount_to_pay   = $cgi->param('amount_to_pay');
44
    my $amount_received = $cgi->param('amount_received');
45
    my $type            = $cgi->param('type');
46
    my $notes           = $cgi->param('notes');
47
    my @debit_id        = $cgi->param('debit_id');
48
49
    my $debit = AddCredit(
50
        {
51
            borrower => $borrower,
52
            amount   => $amount_to_pay,
53
            type     => $type,
54
            notes    => $notes,
55
            debit_id => \@debit_id,
56
57
        }
58
    );
59
60
    print $cgi->redirect(
61
        "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
62
}
(-)a/members/mancredit.pl (-1 / +1 lines)
Lines 57-63 if ($add){ Link Here
57
        $amount = -$amount;
57
        $amount = -$amount;
58
        my $type = $input->param('type');
58
        my $type = $input->param('type');
59
        manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
59
        manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
60
        print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
60
        print $input->redirect("/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
61
    }
61
    }
62
} else {
62
} else {
63
	my ($template, $loggedinuser, $cookie)
63
	my ($template, $loggedinuser, $cookie)
(-)a/members/maninvoice.pl (-1 / +1 lines)
Lines 72-78 if ($add){ Link Here
72
            $template->param( 'ERROR' => $error );
72
            $template->param( 'ERROR' => $error );
73
            output_html_with_http_headers $input, $cookie, $template->output;
73
            output_html_with_http_headers $input, $cookie, $template->output;
74
        } else {
74
        } else {
75
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
75
            print $input->redirect("/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
76
            exit;
76
            exit;
77
        }
77
        }
78
    }
78
    }
(-)a/members/pay.pl (-2 / +2 lines)
Lines 19-25 Link Here
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
21
22
=head1 pay.pl
22
=head1 account_payment.pl
23
23
24
 written 11/1/2000 by chris@katipo.oc.nz
24
 written 11/1/2000 by chris@katipo.oc.nz
25
 part of the koha library system, script to facilitate paying off fines
25
 part of the koha library system, script to facilitate paying off fines
Lines 197-203 sub writeoff_all { Link Here
197
197
198
    $borrowernumber = $input->param('borrowernumber');
198
    $borrowernumber = $input->param('borrowernumber');
199
    print $input->redirect(
199
    print $input->redirect(
200
        "/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
200
        "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
201
    return;
201
    return;
202
}
202
}
203
203
(-)a/members/paycollect.pl (-2 / +2 lines)
Lines 114-120 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
114
                    $user, $branch, $payment_note );
114
                    $user, $branch, $payment_note );
115
            }
115
            }
116
            print $input->redirect(
116
            print $input->redirect(
117
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
117
                "/cgi-bin/koha/members/account_payment.pl?borrowernumber=$borrowernumber");
118
        } else {
118
        } else {
119
            if ($select) {
119
            if ($select) {
120
                if ( $select =~ /^([\d,]*).*/ ) {
120
                if ( $select =~ /^([\d,]*).*/ ) {
Lines 130-136 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
130
# recordpayment does not return success or failure so lets redisplay the boraccount
130
# recordpayment does not return success or failure so lets redisplay the boraccount
131
131
132
            print $input->redirect(
132
            print $input->redirect(
133
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"
133
"/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber"
134
            );
134
            );
135
        }
135
        }
136
    }
136
    }
(-)a/members/printfeercpt.pl (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
3
4
#writen 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz
4
#writen 3rd May 2010 by kmkale@anantcorp.com adapted from account.pl by chris@katipo.oc.nz
5
#script to print fee receipts
5
#script to print fee receipts
6
6
7
7
(-)a/members/printinvoice.pl (-1 / +1 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
#writen 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz
3
#writen 3rd May 2010 by kmkale@anantcorp.com adapted from account.pl by chris@katipo.oc.nz
4
#script to print fee receipts
4
#script to print fee receipts
5
5
6
# Copyright Koustubha Kale
6
# Copyright Koustubha Kale
(-)a/misc/release_notes/release_notes_3_10_0.txt (-1 / +1 lines)
Lines 1762-1768 Staff Client Link Here
1762
	8996	normal	In result page items with negative notforloan are available
1762
	8996	normal	In result page items with negative notforloan are available
1763
	9017	normal	Quote of the day: Table footer not translated
1763
	9017	normal	Quote of the day: Table footer not translated
1764
	5312	minor	XHTML correction in authority summary
1764
	5312	minor	XHTML correction in authority summary
1765
	8009	minor	Item descriptive data not populated on pay.pl
1765
	8009	minor	Item descriptive data not populated on account_payment.pl
1766
	8593	minor	Add unique IDs to pending approval markup on staff client home page
1766
	8593	minor	Add unique IDs to pending approval markup on staff client home page
1767
	8646	minor	Certain search terms cause browser "script taking too long" error
1767
	8646	minor	Certain search terms cause browser "script taking too long" error
1768
	8793	minor	Fix materialTypeCode/typeOf008 icons for NORMARC XSLT
1768
	8793	minor	Fix materialTypeCode/typeOf008 icons for NORMARC XSLT
(-)a/misc/release_notes/release_notes_3_12_0.txt (-1 / +1 lines)
Lines 579-585 Architecture, internals, and plumbing Link Here
579
	8429	minor	Unnecessary use of Exporter in SIP/ILS objects
579
	8429	minor	Unnecessary use of Exporter in SIP/ILS objects
580
	9292	minor	Remove dead code related to 'publictype'
580
	9292	minor	Remove dead code related to 'publictype'
581
	9401	minor	Javascript used for tags handling wants access to CGISESSID cookie
581
	9401	minor	Javascript used for tags handling wants access to CGISESSID cookie
582
	9582	minor	Unused code in members/pay.pl
582
	9582	minor	Unused code in members/account_payment.pl
583
	10054	minor	When SingleBranchMode is enabled, allow superlibrarians to set logged in library
583
	10054	minor	When SingleBranchMode is enabled, allow superlibrarians to set logged in library
584
	10143	minor	Fix FSF address in license headers
584
	10143	minor	Fix FSF address in license headers
585
	9609	trivial	Rebuild zebra reports double numbers for exported records with -z option
585
	9609	trivial	Rebuild zebra reports double numbers for exported records with -z option
(-)a/t/db_dependent/Accounts.t (-4 / +186 lines)
Lines 1-16 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#
2
#
3
# This Koha test module is a stub!  
3
# This Koha test module is a stub!
4
# Add more tests here!!!
4
# Add more tests here!!!
5
5
6
use strict;
6
use strict;
7
use warnings;
7
use warnings;
8
8
9
use Test::More tests => 1;
9
use Test::More tests => 19;
10
11
use C4::Context;
10
12
11
BEGIN {
13
BEGIN {
12
        use_ok('C4::Accounts');
14
    use_ok('Koha::Database');
15
    use_ok('Koha::Accounts');
16
    use_ok('Koha::Accounts::DebitTypes');
17
    use_ok('Koha::Accounts::CreditTypes');
13
}
18
}
14
19
20
## Intial Setup ##
21
my $borrower = Koha::Database->new()->schema->resultset('Borrower')->create(
22
    {
23
        surname         => 'Test',
24
        categorycode    => 'S',
25
        branchcode      => 'MPL',
26
        account_balance => 0,
27
    }
28
);
29
30
my $biblio =
31
  Koha::Database->new()->schema->resultset('Biblio')
32
  ->create( { title => "Test Record" } );
33
my $biblioitem =
34
  Koha::Database->new()->schema->resultset('Biblioitem')
35
  ->create( { biblionumber => $biblio->biblionumber() } );
36
my $item = Koha::Database->new()->schema->resultset('Item')->create(
37
    {
38
        biblionumber     => $biblio->biblionumber(),
39
        biblioitemnumber => $biblioitem->biblioitemnumber(),
40
        replacementprice => 25.00,
41
        barcode          => q{TEST_ITEM_BARCODE}
42
    }
43
);
44
45
my $issue = Koha::Database->new()->schema->resultset('Issue')->create(
46
    {
47
        borrowernumber => $borrower->borrowernumber(),
48
        itemnumber     => $item->itemnumber(),
49
    }
50
);
51
## END initial setup
52
53
ok( Koha::Accounts::DebitTypes::Fine eq 'FINE', 'Test DebitTypes::Fine' );
54
ok( Koha::Accounts::DebitTypes::Lost eq 'LOST', 'Test DebitTypes::Lost' );
55
ok(
56
    Koha::Accounts::DebitTypes::IsValid('FINE'),
57
    'Test DebitTypes::IsValid with valid debit type'
58
);
59
ok(
60
    !Koha::Accounts::DebitTypes::IsValid('Not A Valid Fee Type'),
61
    'Test DebitTypes::IsValid with an invalid debit type'
62
);
63
my $authorised_value =
64
  Koha::Database->new()->schema->resultset('AuthorisedValue')->create(
65
    {
66
        category         => 'MANUAL_INV',
67
        authorised_value => 'TEST',
68
        lib              => 'Test',
69
    }
70
  );
71
ok( Koha::Accounts::DebitTypes::IsValid('TEST'),
72
    'Test DebitTypes::IsValid with valid authorised value debit type' );
73
$authorised_value->delete();
74
75
my $debit = AddDebit(
76
    {
77
        borrower   => $borrower,
78
        amount     => 5.00,
79
        type       => Koha::Accounts::DebitTypes::Fine,
80
        branchcode => 'MPL',
81
    }
82
);
83
ok( $debit, "AddDebit returned a valid debit id " . $debit->id() );
84
85
ok(
86
    $borrower->account_balance() == 5.00,
87
    "Borrower's account balance updated correctly"
88
);
89
90
my $debit2 = AddDebit(
91
    {
92
        borrower   => $borrower,
93
        amount     => 7.00,
94
        type       => Koha::Accounts::DebitTypes::Fine,
95
        branchcode => 'MPL',
96
    }
97
);
98
99
my $credit = AddCredit(
100
    {
101
        borrower   => $borrower,
102
        type       => Koha::Accounts::CreditTypes::Payment,
103
        amount     => 9.00,
104
        branchcode => 'MPL',
105
    }
106
);
107
108
RecalculateAccountBalance( { borrower => $borrower } );
109
ok(
110
    sprintf( "%.2f", $borrower->account_balance() ) eq "3.00",
111
    "RecalculateAccountBalance updated balance correctly."
112
);
113
114
Koha::Database->new()->schema->resultset('AccountCredit')->create(
115
    {
116
        borrowernumber   => $borrower->borrowernumber(),
117
        type             => Koha::Accounts::CreditTypes::Payment,
118
        amount_paid      => 3.00,
119
        amount_remaining => 3.00,
120
    }
121
);
122
NormalizeBalances( { borrower => $borrower } );
123
ok(
124
    $borrower->account_balance() == 0.00,
125
    "NormalizeBalances updated balance correctly."
126
);
127
128
# Adding advance credit with no balance due
129
$credit = AddCredit(
130
    {
131
        borrower   => $borrower,
132
        type       => Koha::Accounts::CreditTypes::Payment,
133
        amount     => 9.00,
134
        branchcode => 'MPL',
135
    }
136
);
137
ok(
138
    $borrower->account_balance() == -9,
139
'Adding a $9 credit for borrower with 0 balance results in a -9 dollar account balance'
140
);
141
142
my $debit3 = AddDebit(
143
    {
144
        borrower   => $borrower,
145
        amount     => 5.00,
146
        type       => Koha::Accounts::DebitTypes::Fine,
147
        branchcode => 'MPL',
148
    }
149
);
150
ok(
151
    $borrower->account_balance() == -4,
152
'Adding a $5 debit when the balance is negative results in the debit being automatically paid, resulting in a balance of -4'
153
);
154
155
my $debit4 = AddDebit(
156
    {
157
        borrower   => $borrower,
158
        amount     => 6.00,
159
        type       => Koha::Accounts::DebitTypes::Fine,
160
        branchcode => 'MPL',
161
    }
162
);
163
ok(
164
    $borrower->account_balance() == 2,
165
'Adding another debit ( 6.00 ) more than the negative account balance results in a partial credit and a balance due of 2.00'
166
);
167
$credit = AddCredit(
168
    {
169
        borrower   => $borrower,
170
        type       => Koha::Accounts::CreditTypes::WriteOff,
171
        amount     => 2.00,
172
        branchcode => 'MPL',
173
        debit_id   => $debit4->debit_id(),
174
    }
175
);
176
ok( $borrower->account_balance() == 0,
177
    'WriteOff of remaining 2.00 balance succeeds' );
178
179
my $debit5 = DebitLostItem(
180
    {
181
        borrower => $borrower,
182
        issue    => $issue,
183
    }
184
);
185
ok( $borrower->account_balance() == 25,
186
    'DebitLostItem adds debit for replacement price of item' );
15
187
188
my $lost_credit =
189
  CreditLostItem( { borrower => $borrower, account_debit => $debit5 } );
190
ok(
191
    $borrower->account_balance() == 0,
192
    'CreditLostItem adds credit for same about as the debit for the lost tiem'
193
);
16
194
17
- 
195
## Post test cleanup ##
196
$issue->delete();
197
$item->delete();
198
$biblio->delete();
199
$borrower->delete();

Return to bug 6427