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

(-)a/C4/Accounts.pm (-64 / +111 lines)
Lines 35-41 BEGIN { Link Here
35
	@ISA    = qw(Exporter);
35
	@ISA    = qw(Exporter);
36
	@EXPORT = qw(
36
	@EXPORT = qw(
37
		&recordpayment &makepayment &manualinvoice
37
		&recordpayment &makepayment &manualinvoice
38
		&getnextacctno &reconcileaccount &getcharges &ModNote &getcredits
38
		&getnextacctno &reconcileaccount &getcharges &ModNote &ModMeansOfPayment &ModManagerId &getMeansOfPaymentList &getcredits
39
		&getrefunds &chargelostitem
39
		&getrefunds &chargelostitem
40
		&ReversePayment
40
		&ReversePayment
41
	); # removed &fixaccounts
41
	); # removed &fixaccounts
Lines 104-113 sub recordpayment { Link Here
104
            $newamtos   = $accdata->{'amountoutstanding'} - $amountleft;
104
            $newamtos   = $accdata->{'amountoutstanding'} - $amountleft;
105
            $amountleft = 0;
105
            $amountleft = 0;
106
        }
106
        }
107
        my $thisacct = $accdata->{accountno};
107
        my $thisacct = $accdata->{id};
108
        my $usth     = $dbh->prepare(
108
        my $usth     = $dbh->prepare(
109
            "UPDATE accountlines SET amountoutstanding= ?
109
            "UPDATE accountlines SET amountoutstanding= ?
110
     WHERE (borrowernumber = ?) AND (accountno=?)"
110
     WHERE (id=?)"
111
        );
111
        );
112
        $usth->execute( $newamtos, $borrowernumber, $thisacct );
112
        $usth->execute( $newamtos, $borrowernumber, $thisacct );
113
        $usth->finish;
113
        $usth->finish;
Lines 124-131 sub recordpayment { Link Here
124
    # create new line
124
    # create new line
125
    my $usth = $dbh->prepare(
125
    my $usth = $dbh->prepare(
126
        "INSERT INTO accountlines
126
        "INSERT INTO accountlines
127
  (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
127
  (borrowernumber, accountno,date,time,amount,description,accounttype,amountoutstanding)
128
  VALUES (?,?,now(),?,'Payment,thanks','Pay',?)"
128
  VALUES (?,?,now(),CURRENT_TIME,?,'Payment,thanks','Pay',?)"
129
    );
129
    );
130
    $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft );
130
    $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft );
131
    $usth->finish;
131
    $usth->finish;
Lines 135-141 sub recordpayment { Link Here
135
135
136
=head2 makepayment
136
=head2 makepayment
137
137
138
  &makepayment($borrowernumber, $acctnumber, $amount, $branchcode);
138
  &makepayment($accountlineid, $borrowernumber, $acctnumber, $amount, $branchcode, $note, $meansofpayment, $manager_id, $partpaymentamount);
139
139
140
Records the fact that a patron has paid off the entire amount he or
140
Records the fact that a patron has paid off the entire amount he or
141
she owes.
141
she owes.
Lines 144-150 C<$borrowernumber> is the patron's borrower number. C<$acctnumber> is Link Here
144
the account that was credited. C<$amount> is the amount paid (this is
144
the account that was credited. C<$amount> is the amount paid (this is
145
only used to record the payment. It is assumed to be equal to the
145
only used to record the payment. It is assumed to be equal to the
146
amount owed). C<$branchcode> is the code of the branch where payment
146
amount owed). C<$branchcode> is the code of the branch where payment
147
was made.
147
was made. If $partpaymentamount > 0 it's a part payment.
148
148
149
=cut
149
=cut
150
150
Lines 156-162 sub makepayment { Link Here
156
    #here we update both the accountoffsets and the account lines
156
    #here we update both the accountoffsets and the account lines
157
    #updated to check, if they are paying off a lost item, we return the item
157
    #updated to check, if they are paying off a lost item, we return the item
158
    # from their card, and put a note on the item record
158
    # from their card, and put a note on the item record
159
    my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_;
159
    my ( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, $partpaymentamount ) = @_;
160
    my $dbh = C4::Context->dbh;
160
    my $dbh = C4::Context->dbh;
161
161
162
    # begin transaction
162
    # begin transaction
Lines 164-204 sub makepayment { Link Here
164
    my $newamtos    = 0;
164
    my $newamtos    = 0;
165
    my $sth =
165
    my $sth =
166
      $dbh->prepare(
166
      $dbh->prepare(
167
        "SELECT * FROM accountlines WHERE  borrowernumber=? AND accountno=?");
167
        "SELECT * FROM accountlines WHERE id=?");
168
    $sth->execute( $borrowernumber, $accountno );
168
    $sth->execute( $accountlineid );
169
    my $data = $sth->fetchrow_hashref;
169
    my $data = $sth->fetchrow_hashref;
170
    $sth->finish;
170
    $sth->finish;
171
171
172
    my $newamountoutstanding=0;
173
    my $payment = 0 - $amount;
174
    $payment = 0-$data->{'amountoutstanding'};
175
    my $finalamount = $amount;
176
    my $descriptionpayment="Payment for account n°".$accountno.",thanks - ".$user." : ".$data->{'description'};
177
	if($partpaymentamount!=0)
178
	{
179
		$newamountoutstanding=$data->{'amountoutstanding'}-$partpaymentamount;
180
		$payment = 0 - $partpaymentamount;
181
		$finalamount = $partpaymentamount;
182
		$descriptionpayment="Part Payment for account n°".$accountno.",thanks - ".$user." : ".$data->{'description'};
183
	}
184
172
    $dbh->do(
185
    $dbh->do(
173
        "UPDATE  accountlines
186
        "UPDATE  accountlines
174
        SET     amountoutstanding = 0
187
        SET     amountoutstanding = $newamountoutstanding
175
        WHERE   borrowernumber = $borrowernumber
188
        WHERE   id = $accountlineid
176
          AND   accountno = $accountno
177
        "
189
        "
178
    );
190
    );
179
191
180
    #  print $updquery;
181
#    $dbh->do( "
182
#        INSERT INTO     accountoffsets
183
#                        (borrowernumber, accountno, offsetaccount,
184
#                         offsetamount)
185
#        VALUES          ($borrowernumber, $accountno, $nextaccntno, $newamtos)
186
#        " );
187
188
    # create new line
192
    # create new line
189
    my $payment = 0 - $amount;
190
    $dbh->do( "
193
    $dbh->do( "
191
        INSERT INTO     accountlines
194
        INSERT INTO     accountlines
192
                        (borrowernumber, accountno, date, amount,
195
                        (borrowernumber, accountno, date, time, amount,
193
                         description, accounttype, amountoutstanding)
196
                         description, accounttype, amountoutstanding,
194
        VALUES          ($borrowernumber, $nextaccntno, now(), $payment,
197
                         note, meansofpayment, manager_id)
195
                        'Payment,thanks - $user', 'Pay', 0)
198
        VALUES          ($borrowernumber, $nextaccntno, now(), CURRENT_TIME, $payment,
199
                        '$descriptionpayment', 'Pay', 0, '$note', '$meansofpayment', '$manager_id')
196
        " );
200
        " );
197
201
198
    # FIXME - The second argument to &UpdateStats is supposed to be the
202
    # FIXME - The second argument to &UpdateStats is supposed to be the
199
    # branch code.
203
    # branch code.
200
    # UpdateStats is now being passed $accountno too. MTJ
204
    # UpdateStats is now being passed $accountno too. MTJ
201
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber,
205
    UpdateStats( $user, 'payment', $finalamount, '', '', '', $borrowernumber,
202
        $accountno );
206
        $accountno );
203
    $sth->finish;
207
    $sth->finish;
204
208
Lines 206-211 sub makepayment { Link Here
206
    if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) {
210
    if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) {
207
        returnlost( $borrowernumber, $data->{'itemnumber'} );
211
        returnlost( $borrowernumber, $data->{'itemnumber'} );
208
    }
212
    }
213
     
214
    my $sth = $dbh->prepare("SELECT max(id) AS lastinsertid FROM accountlines");
215
    $sth->execute();
216
    my $datalastinsertid = $sth->fetchrow_hashref;
217
    $sth->finish;
218
    return $datalastinsertid->{'lastinsertid'};
209
}
219
}
210
220
211
=head2 getnextacctno
221
=head2 getnextacctno
Lines 233-250 sub getnextacctno ($) { Link Here
233
243
234
=head2 fixaccounts (removed)
244
=head2 fixaccounts (removed)
235
245
236
  &fixaccounts($borrowernumber, $accountnumber, $amount);
246
  &fixaccounts($accountlineid, $borrowernumber, $accountnumber, $amount);
237
247
238
#'
248
#'
239
# FIXME - I don't understand what this function does.
249
# FIXME - I don't understand what this function does.
240
sub fixaccounts {
250
sub fixaccounts {
241
    my ( $borrowernumber, $accountno, $amount ) = @_;
251
    my ( $accountlineid, $borrowernumber, $accountno, $amount ) = @_;
242
    my $dbh = C4::Context->dbh;
252
    my $dbh = C4::Context->dbh;
243
    my $sth = $dbh->prepare(
253
    my $sth = $dbh->prepare(
244
        "SELECT * FROM accountlines WHERE borrowernumber=?
254
        "SELECT * FROM accountlines WHERE id=?"
245
     AND accountno=?"
246
    );
255
    );
247
    $sth->execute( $borrowernumber, $accountno );
256
    $sth->execute( $accountlineid );
248
    my $data = $sth->fetchrow_hashref;
257
    my $data = $sth->fetchrow_hashref;
249
258
250
    # FIXME - Error-checking
259
    # FIXME - Error-checking
Lines 256-263 sub fixaccounts { Link Here
256
        UPDATE  accountlines
265
        UPDATE  accountlines
257
        SET     amount = '$amount',
266
        SET     amount = '$amount',
258
                amountoutstanding = '$outstanding'
267
                amountoutstanding = '$outstanding'
259
        WHERE   borrowernumber = $borrowernumber
268
        WHERE   id = $accountlineid
260
          AND   accountno = $accountno
261
EOT
269
EOT
262
	# FIXME: exceedingly bad form.  Use prepare with placholders ("?") in query and execute args.
270
	# FIXME: exceedingly bad form.  Use prepare with placholders ("?") in query and execute args.
263
}
271
}
Lines 307-314 sub chargelostitem{ Link Here
307
            #  process (or person) to update it, since we don't handle any defaults for replacement prices.
315
            #  process (or person) to update it, since we don't handle any defaults for replacement prices.
308
            my $accountno = getnextacctno($issues->{'borrowernumber'});
316
            my $accountno = getnextacctno($issues->{'borrowernumber'});
309
            my $sth2=$dbh->prepare("INSERT INTO accountlines
317
            my $sth2=$dbh->prepare("INSERT INTO accountlines
310
            (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
318
            (borrowernumber,accountno,date,time,amount,description,accounttype,amountoutstanding,itemnumber)
311
            VALUES (?,?,now(),?,?,'L',?,?)");
319
            VALUES (?,?,now(),CURRENT_TIME,?,?,'L',?,?)");
312
            $sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'},
320
            $sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'},
313
            "Lost Item $issues->{'title'} $issues->{'barcode'}",
321
            "Lost Item $issues->{'title'} $issues->{'barcode'}",
314
            $issues->{'replacementprice'},$itemnumber);
322
            $issues->{'replacementprice'},$itemnumber);
Lines 327-333 sub chargelostitem{ Link Here
327
=head2 manualinvoice
335
=head2 manualinvoice
328
336
329
  &manualinvoice($borrowernumber, $itemnumber, $description, $type,
337
  &manualinvoice($borrowernumber, $itemnumber, $description, $type,
330
                 $amount, $note);
338
                 $amount, $note, $meansofpayment);
331
339
332
C<$borrowernumber> is the patron's borrower number.
340
C<$borrowernumber> is the patron's borrower number.
333
C<$description> is a description of the transaction.
341
C<$description> is a description of the transaction.
Lines 351-357 should be the empty string. Link Here
351
#
359
#
352
360
353
sub manualinvoice {
361
sub manualinvoice {
354
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
362
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment ) = @_;
355
    my $manager_id = C4::Context->userenv->{'number'};
363
    my $manager_id = C4::Context->userenv->{'number'};
356
    my $dbh      = C4::Context->dbh;
364
    my $dbh      = C4::Context->dbh;
357
    my $notifyid = 0;
365
    my $notifyid = 0;
Lines 404-419 sub manualinvoice { Link Here
404
        $desc .= " " . $itemnum;
412
        $desc .= " " . $itemnum;
405
        my $sth = $dbh->prepare(
413
        my $sth = $dbh->prepare(
406
            "INSERT INTO  accountlines
414
            "INSERT INTO  accountlines
407
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id)
415
                        (borrowernumber, accountno, date, time, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, meansofpayment)
408
        VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)");
416
        VALUES (?, ?, now(), CURRENT_TIME, ?,?, ?,?,?,?,?,?,?)");
409
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr;
417
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $meansofpayment) || return $sth->errstr;
410
  } else {
418
  } else {
411
    my $sth=$dbh->prepare("INSERT INTO  accountlines
419
    my $sth=$dbh->prepare("INSERT INTO  accountlines
412
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)
420
            (borrowernumber, accountno, date, time, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, meansofpayment)
413
            VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"
421
            VALUES (?, ?, now(), CURRENT_TIME, ?, ?, ?, ?,?,?,?,?)"
414
        );
422
        );
415
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
423
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
416
            $amountleft, $notifyid, $note, $manager_id );
424
            $amountleft, $notifyid, $note, $manager_id, $meansofpayment );
417
    }
425
    }
418
    return 0;
426
    return 0;
419
}
427
}
Lines 465-474 sub fixcredit { Link Here
465
            $newamtos   = $accdata->{'amountoutstanding'} - $amountleft;
473
            $newamtos   = $accdata->{'amountoutstanding'} - $amountleft;
466
            $amountleft = 0;
474
            $amountleft = 0;
467
        }
475
        }
468
        my $thisacct = $accdata->{accountno};
476
        my $thisacct = $accdata->{id};
469
        my $usth     = $dbh->prepare(
477
        my $usth     = $dbh->prepare(
470
            "UPDATE accountlines SET amountoutstanding= ?
478
            "UPDATE accountlines SET amountoutstanding= ?
471
     WHERE (borrowernumber = ?) AND (accountno=?)"
479
            WHERE (id=?)"
472
        );
480
        );
473
        $usth->execute( $newamtos, $borrowernumber, $thisacct );
481
        $usth->execute( $newamtos, $borrowernumber, $thisacct );
474
        $usth->finish;
482
        $usth->finish;
Lines 504-515 sub fixcredit { Link Here
504
            $newamtos   = $accdata->{'amountoutstanding'} - $amountleft;
512
            $newamtos   = $accdata->{'amountoutstanding'} - $amountleft;
505
            $amountleft = 0;
513
            $amountleft = 0;
506
        }
514
        }
507
        my $thisacct = $accdata->{accountno};
515
        my $thisacct = $accdata->{id};
508
        my $usth     = $dbh->prepare(
516
        my $usth     = $dbh->prepare(
509
            "UPDATE accountlines SET amountoutstanding= ?
517
            "UPDATE accountlines SET amountoutstanding= ?
510
     WHERE (borrowernumber = ?) AND (accountno=?)"
518
     WHERE (id=?)"
511
        );
519
        );
512
        $usth->execute( $newamtos, $borrowernumber, $thisacct );
520
        $usth->execute( $newamtos, $thisacct );
513
        $usth->finish;
521
        $usth->finish;
514
        $usth = $dbh->prepare(
522
        $usth = $dbh->prepare(
515
            "INSERT INTO accountoffsets
523
            "INSERT INTO accountoffsets
Lines 557-563 sub refund { Link Here
557
    );
565
    );
558
    $sth->execute($borrowernumber);
566
    $sth->execute($borrowernumber);
559
567
560
    #  print $amountleft;
561
    # offset transactions
568
    # offset transactions
562
    while ( ( $accdata = $sth->fetchrow_hashref ) and ( $amountleft < 0 ) ) {
569
    while ( ( $accdata = $sth->fetchrow_hashref ) and ( $amountleft < 0 ) ) {
563
        if ( $accdata->{'amountoutstanding'} > $amountleft ) {
570
        if ( $accdata->{'amountoutstanding'} > $amountleft ) {
Lines 569-581 sub refund { Link Here
569
            $amountleft = 0;
576
            $amountleft = 0;
570
        }
577
        }
571
578
572
        #     print $amountleft;
579
        my $thisacct = $accdata->{id};
573
        my $thisacct = $accdata->{accountno};
574
        my $usth     = $dbh->prepare(
580
        my $usth     = $dbh->prepare(
575
            "UPDATE accountlines SET amountoutstanding= ?
581
            "UPDATE accountlines SET amountoutstanding= ?
576
     WHERE (borrowernumber = ?) AND (accountno=?)"
582
             WHERE (id=?)"
577
        );
583
        );
578
        $usth->execute( $newamtos, $borrowernumber, $thisacct );
584
        $usth->execute( $newamtos, $thisacct );
579
        $usth->finish;
585
        $usth->finish;
580
        $usth = $dbh->prepare(
586
        $usth = $dbh->prepare(
581
            "INSERT INTO accountoffsets
587
            "INSERT INTO accountoffsets
Lines 608-617 sub getcharges { Link Here
608
}
614
}
609
615
610
sub ModNote {
616
sub ModNote {
611
    my ( $borrowernumber, $accountno, $note ) = @_;
617
    my ( $accountlineid, $note ) = @_;
612
    my $dbh = C4::Context->dbh;
618
    my $dbh = C4::Context->dbh;
613
    my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE borrowernumber = ? AND accountno = ?');
619
    my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE id = ?');
614
    $sth->execute( $note, $borrowernumber, $accountno );
620
    $sth->execute( $note, $accountlineid );
621
}
622
623
624
sub ModMeansOfPayment {
625
    my ( $accountlineid, $meansofpayment ) = @_;
626
    my $dbh = C4::Context->dbh;
627
    my $sth = $dbh->prepare('UPDATE accountlines SET meansofpayment = ? WHERE id = ?');
628
    $sth->execute( $meansofpayment, $accountlineid );
629
}
630
631
sub ModManagerId {
632
    my ( $accountlineid, $manager_id ) = @_;
633
    my $dbh = C4::Context->dbh;
634
    my $sth = $dbh->prepare('UPDATE accountlines SET manager_id = ? WHERE id = ?');
635
    $sth->execute( $manager_id, $accountlineid );
636
}
637
638
sub getMeansOfPaymentList {
639
	my ($selectedoption) = @_;
640
	my $dbh  = C4::Context->dbh;
641
	my $sth = $dbh->prepare( "SELECT * FROM `systempreferences` WHERE variable='MeansOfPayment'" );
642
	$sth->execute();
643
	my @options;
644
	my $booloption=0;
645
	while ( my $data = $sth->fetchrow_hashref ) {
646
	foreach my $option ( split( /\|/, $data->{'value'} ) ) {
647
            my $selected = '';
648
            if($option eq $selectedoption)
649
            {
650
            	$selected = ' selected="selected"';
651
            	$booloption=1;
652
            }
653
            push @options, { option => $option, selected => $selected };
654
        }
655
	}
656
	if($booloption==0 && $selectedoption ne "")
657
	{
658
		push @options, { option => $selectedoption, selected => ' selected="selected"' };
659
	}
660
    $sth->finish;
661
    return \@options;
615
}
662
}
616
663
617
sub getcredits {
664
sub getcredits {
Lines 656-675 sub getrefunds { Link Here
656
}
703
}
657
704
658
sub ReversePayment {
705
sub ReversePayment {
659
  my ( $borrowernumber, $accountno ) = @_;
706
  my ( $accountlineid ) = @_;
660
  my $dbh = C4::Context->dbh;
707
  my $dbh = C4::Context->dbh;
661
  
708
  
662
  my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE borrowernumber = ? AND accountno = ?');
709
  my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE id=?');
663
  $sth->execute( $borrowernumber, $accountno );
710
  $sth->execute( $accountlineid );
664
  my $row = $sth->fetchrow_hashref();
711
  my $row = $sth->fetchrow_hashref();
665
  my $amount_outstanding = $row->{'amountoutstanding'};
712
  my $amount_outstanding = $row->{'amountoutstanding'};
666
  
713
  
667
  if ( $amount_outstanding <= 0 ) {
714
  if ( $amount_outstanding <= 0 ) {
668
    $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');
715
    $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE id = ?');
669
    $sth->execute( $borrowernumber, $accountno );
716
    $sth->execute( $accountlineid );
670
  } else {
717
  } else {
671
    $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');
718
    $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE id = ?');
672
    $sth->execute( $borrowernumber, $accountno );
719
    $sth->execute( $accountlineid );
673
  }
720
  }
674
}
721
}
675
722
(-)a/C4/Circulation.pm (-9 / +7 lines)
Lines 1788-1794 sub _FixOverduesOnReturn { Link Here
1788
    return 0 unless $data;    # no warning, there's just nothing to fix
1788
    return 0 unless $data;    # no warning, there's just nothing to fix
1789
1789
1790
    my $uquery;
1790
    my $uquery;
1791
    my @bind = ($borrowernumber, $item, $data->{'accountno'});
1791
    my @bind = ($data->{'id'});
1792
    if ($exemptfine) {
1792
    if ($exemptfine) {
1793
        $uquery = "update accountlines set accounttype='FFOR', amountoutstanding=0";
1793
        $uquery = "update accountlines set accounttype='FFOR', amountoutstanding=0";
1794
        if (C4::Context->preference("FinesLog")) {
1794
        if (C4::Context->preference("FinesLog")) {
Lines 1808-1814 sub _FixOverduesOnReturn { Link Here
1808
    } else {
1808
    } else {
1809
        $uquery = "update accountlines set accounttype='F' ";
1809
        $uquery = "update accountlines set accounttype='F' ";
1810
    }
1810
    }
1811
    $uquery .= " where (borrowernumber = ?) and (itemnumber = ?) and (accountno = ?)";
1811
    $uquery .= " where (id = ?)";
1812
    my $usth = $dbh->prepare($uquery);
1812
    my $usth = $dbh->prepare($uquery);
1813
    return $usth->execute(@bind);
1813
    return $usth->execute(@bind);
1814
}
1814
}
Lines 1850-1858 sub _FixAccountForLostAndReturned { Link Here
1850
        $amountleft = $data->{'amountoutstanding'} - $amount;   # Um, isn't this the same as ZERO?  We just tested those two things are ==
1850
        $amountleft = $data->{'amountoutstanding'} - $amount;   # Um, isn't this the same as ZERO?  We just tested those two things are ==
1851
    }
1851
    }
1852
    my $usth = $dbh->prepare("UPDATE accountlines SET accounttype = 'LR',amountoutstanding='0'
1852
    my $usth = $dbh->prepare("UPDATE accountlines SET accounttype = 'LR',amountoutstanding='0'
1853
        WHERE (borrowernumber = ?)
1853
        WHERE (id = ?) ");
1854
        AND (itemnumber = ?) AND (accountno = ?) ");
1854
    $usth->execute($data->{'id'});      # We might be adjusting an account for some OTHER borrowernumber now.  Not the one we passed in.  
1855
    $usth->execute($data->{'borrowernumber'},$itemnumber,$acctno);      # We might be adjusting an account for some OTHER borrowernumber now.  Not the one we passed in.  
1856
    #check if any credit is left if so writeoff other accounts
1855
    #check if any credit is left if so writeoff other accounts
1857
    my $nextaccntno = getnextacctno($data->{'borrowernumber'});
1856
    my $nextaccntno = getnextacctno($data->{'borrowernumber'});
1858
    $amountleft *= -1 if ($amountleft < 0);
1857
    $amountleft *= -1 if ($amountleft < 0);
Lines 1871-1882 sub _FixAccountForLostAndReturned { Link Here
1871
                $newamtos = $accdata->{'amountoutstanding'} - $amountleft;
1870
                $newamtos = $accdata->{'amountoutstanding'} - $amountleft;
1872
                $amountleft = 0;
1871
                $amountleft = 0;
1873
            }
1872
            }
1874
            my $thisacct = $accdata->{'accountno'};
1873
            my $thisacct = $accdata->{'id'};
1875
            # FIXME: move prepares outside while loop!
1874
            # FIXME: move prepares outside while loop!
1876
            my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ?
1875
            my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ?
1877
                    WHERE (borrowernumber = ?)
1876
                    WHERE (id = ?)");
1878
                    AND (accountno=?)");
1877
            $usth->execute($newamtos,'$thisacct');    # FIXME: '$thisacct' is a string literal!
1879
            $usth->execute($newamtos,$data->{'borrowernumber'},'$thisacct');    # FIXME: '$thisacct' is a string literal!
1880
            $usth = $dbh->prepare("INSERT INTO accountoffsets
1878
            $usth = $dbh->prepare("INSERT INTO accountoffsets
1881
                (borrowernumber, accountno, offsetaccount,  offsetamount)
1879
                (borrowernumber, accountno, offsetaccount,  offsetamount)
1882
                VALUES
1880
                VALUES
(-)a/installer/data/mysql/en/mandatory/sysprefs.sql (+1 lines)
Lines 298-300 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
298
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the Staff client','','free');
298
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the Staff client','','free');
299
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', '0', 'Create searches on all subdivisions for subject tracings.','1','YesNo');
299
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', '0', 'Create searches on all subdivisions for subject tracings.','1','YesNo');
300
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('StaffAuthorisedValueImages','1','',NULL,'YesNo');
300
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('StaffAuthorisedValueImages','1','',NULL,'YesNo');
301
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MeansOfPayment','Undefined|Cash|Cheque|Bank card|Credit transfer|Direct debit','Define means of payment for borrowers payments','Undefined|Cash|Cheque|Bank card|Credit transfer|Direct debit','free');
(-)a/installer/data/mysql/kohastructure.sql (+3 lines)
Lines 2279-2288 CREATE TABLE `messages` ( Link Here
2279
2279
2280
DROP TABLE IF EXISTS `accountlines`;
2280
DROP TABLE IF EXISTS `accountlines`;
2281
CREATE TABLE `accountlines` (
2281
CREATE TABLE `accountlines` (
2282
  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
2282
  `borrowernumber` int(11) NOT NULL default 0,
2283
  `borrowernumber` int(11) NOT NULL default 0,
2283
  `accountno` smallint(6) NOT NULL default 0,
2284
  `accountno` smallint(6) NOT NULL default 0,
2284
  `itemnumber` int(11) default NULL,
2285
  `itemnumber` int(11) default NULL,
2285
  `date` date default NULL,
2286
  `date` date default NULL,
2287
  `time` time default NULL,
2286
  `amount` decimal(28,6) default NULL,
2288
  `amount` decimal(28,6) default NULL,
2287
  `description` mediumtext,
2289
  `description` mediumtext,
2288
  `dispute` mediumtext,
2290
  `dispute` mediumtext,
Lines 2294-2299 CREATE TABLE `accountlines` ( Link Here
2294
  `notify_level` int(2) NOT NULL default 0,
2296
  `notify_level` int(2) NOT NULL default 0,
2295
  `note` text NULL default NULL,
2297
  `note` text NULL default NULL,
2296
  `manager_id` int(11) NULL,
2298
  `manager_id` int(11) NULL,
2299
  `meansofpayment` text NULL default NULL;
2297
  KEY `acctsborridx` (`borrowernumber`),
2300
  KEY `acctsborridx` (`borrowernumber`),
2298
  KEY `timeidx` (`timestamp`),
2301
  KEY `timeidx` (`timestamp`),
2299
  KEY `itemnumber` (`itemnumber`),
2302
  KEY `itemnumber` (`itemnumber`),
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +11 lines)
Lines 4166-4172 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
4166
    SetVersion ($DBversion);
4166
    SetVersion ($DBversion);
4167
}
4167
}
4168
4168
4169
$DBversion = 'XXX';
4169
$DBversion = '3.03.00.036';
4170
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4170
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4171
    $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
4171
    $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
4172
    $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
4172
    $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
Lines 4174-4179 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4174
    SetVersion($DBversion);
4174
    SetVersion($DBversion);
4175
}
4175
}
4176
4176
4177
$DBversion = '3.03.00.037';
4178
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4179
    $dbh->do("ALTER TABLE `accountlines` ADD `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
4180
    $dbh->do("ALTER TABLE `accountlines` ADD `time` TIME DEFAULT NULL AFTER `date`");
4181
    $dbh->do("ALTER TABLE `accountlines` ADD `meansofpayment` text NULL default NULL");
4182
    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MeansOfPayment', 'Undefined|Cash|Cheque|Bank card|Credit transfer|Direct debit', 'Define means of payment for borrowers payments', 'Undefined|Cash|Cheque|Bank card|Credit transfert|Direct debit', 'free')");
4183
    print "Upgrade to $DBversion done (adding id, time, and meansofpayment fields in accountlines table; and adding MeansOfPayment system preference";
4184
    SetVersion($DBversion);
4185
}
4186
4177
=head1 FUNCTIONS
4187
=head1 FUNCTIONS
4178
4188
4179
=head2 DropAllForeignKeys($table)
4189
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.numeric.js (+128 lines)
Line 0 Link Here
1
/*
2
 *
3
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
4
 * Licensed under the MIT License:
5
 * http://www.opensource.org/licenses/mit-license.php
6
 * 
7
 * Version 1.0
8
 * Demo: http://www.texotela.co.uk/code/jquery/numeric/
9
 *
10
 * $LastChangedDate: 2007-05-29 11:31:36 +0100 (Tue, 29 May 2007) $
11
 * $Rev: 2005 $
12
 */
13
 
14
/*
15
 * Allows only valid characters to be entered into input boxes.
16
 * Note: does not validate that the final text is a valid number
17
 * (that could be done by another script, or server-side)
18
 *
19
 * @name     numeric
20
 * @param    decimal      Decimal separator (e.g. '.' or ',' - default is '.')
21
 * @param    callback     A function that runs if the number is not valid (fires onblur)
22
 * @author   Sam Collett (http://www.texotela.co.uk)
23
 * @example  $(".numeric").numeric();
24
 * @example  $(".numeric").numeric(",");
25
 * @example  $(".numeric").numeric(null, callback);
26
 *
27
 */
28
jQuery.fn.numeric = function(decimal, callback)
29
{
30
	decimal = decimal || ".";
31
	callback = typeof callback == "function" ? callback : function(){};
32
	this.keypress(
33
		function(e)
34
		{
35
			var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
36
			// allow enter/return key (only when in an input box)
37
			if(key == 13 && this.nodeName.toLowerCase() == "input")
38
			{
39
				return true;
40
			}
41
			else if(key == 13)
42
			{
43
				return false;
44
			}
45
			var allow = false;
46
			// allow Ctrl+A
47
			if((e.ctrlKey && key == 97 /* firefox */) || (e.ctrlKey && key == 65) /* opera */) return true;
48
			// allow Ctrl+X (cut)
49
			if((e.ctrlKey && key == 120 /* firefox */) || (e.ctrlKey && key == 88) /* opera */) return true;
50
			// allow Ctrl+C (copy)
51
			if((e.ctrlKey && key == 99 /* firefox */) || (e.ctrlKey && key == 67) /* opera */) return true;
52
			// allow Ctrl+Z (undo)
53
			if((e.ctrlKey && key == 122 /* firefox */) || (e.ctrlKey && key == 90) /* opera */) return true;
54
			// allow or deny Ctrl+V (paste), Shift+Ins
55
			if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */
56
			|| (e.shiftKey && key == 45)) return true;
57
			// if a number was not pressed
58
			if(key < 48 || key > 57)
59
			{
60
				/* '-' only allowed at start */
61
				if(key == 45 && this.value.length == 0) return true;
62
				/* only one decimal separator allowed */
63
				if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) != -1)
64
				{
65
					allow = false;
66
				}
67
				// check for other keys that have special purposes
68
				if(
69
					key != 8 /* backspace */ &&
70
					key != 9 /* tab */ &&
71
					key != 13 /* enter */ &&
72
					key != 35 /* end */ &&
73
					key != 36 /* home */ &&
74
					key != 37 /* left */ &&
75
					key != 39 /* right */ &&
76
					key != 46 /* del */
77
				)
78
				{
79
					allow = false;
80
				}
81
				else
82
				{
83
					// for detecting special keys (listed above)
84
					// IE does not support 'charCode' and ignores them in keypress anyway
85
					if(typeof e.charCode != "undefined")
86
					{
87
						// special keys have 'keyCode' and 'which' the same (e.g. backspace)
88
						if(e.keyCode == e.which && e.which != 0)
89
						{
90
							allow = true;
91
						}
92
						// or keyCode != 0 and 'charCode'/'which' = 0
93
						else if(e.keyCode != 0 && e.charCode == 0 && e.which == 0)
94
						{
95
							allow = true;
96
						}
97
					}
98
				}
99
				// if key pressed is the decimal and it is not already in the field
100
				if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) == -1)
101
				{
102
					allow = true;
103
				}
104
			}
105
			else
106
			{
107
				allow = true;
108
			}
109
			return allow;
110
		}
111
	)
112
	.blur(
113
		function()
114
		{
115
			var val = jQuery(this).val();
116
			if(val != "")
117
			{
118
				var re = new RegExp("^\\d+$|\\d*" + decimal + "\\d+");
119
				if(!re.exec(val))
120
				{
121
					callback.apply(this);
122
				}
123
			}
124
		}
125
	);
126
	return this;
127
}
128
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl (-8 / +39 lines)
Lines 1-6 Link Here
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2
<title>Koha &rsaquo; Patrons &rsaquo; Account for <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --></title>
2
<title>Koha &rsaquo; Patrons &rsaquo; Account for <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --></title>
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
5
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.pager.js"></script>
6
<script type="text/javascript" id="js">$(document).ready(function() {
7
	$("#table_boracount").tablesorter({
8
		sortList: [[0,0]],
9
	}).tablesorterPager({container: $("#pagertable_boracount"),positionFixed: false,size: 20});
10
}); </script>
4
</head>
11
</head>
5
<body>
12
<body>
6
<!-- TMPL_INCLUDE NAME="header.inc" -->
13
<!-- TMPL_INCLUDE NAME="header.inc" -->
Lines 26-57 Link Here
26
</ul>
33
</ul>
27
<div class="tabs-container">
34
<div class="tabs-container">
28
<!-- The table with the account items -->
35
<!-- The table with the account items -->
29
<table>
36
<span id="pagertable_boracount" class="pager">
30
  <tr>
37
	<form class="formpager">&nbsp;<strong>page(s)</strong>&nbsp;:
38
		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/first.png" class="first"/>
39
		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/prev.png" class="prev"/>
40
		<input type="text" size="5" class="pagedisplay"/>
41
		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/next.png" class="next"/>
42
		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/last.png" class="last"/>
43
		, entries/page : 
44
		<select class="pagesize">
45
        	<option value="10">10</option>
46
			<option selected="selected" value="20">20</option>
47
			<option value="30">30</option>
48
			<option value="40">40</option>
49
			<option value="50">50</option>
50
			<option value="100">100</option>
51
		</select>
52
	</form>
53
</span>
54
<table id="table_boracount">
55
  <thead>
31
  	<th>Date</th>
56
  	<th>Date</th>
57
  	<th style="padding:0.2em 14px">n°</th>
58
  	<th>Means of payment</th>
32
    <th>Description of charges</th>
59
    <th>Description of charges</th>
33
    <th>Note</th>
60
    <th>Note</th>
34
    <th>Amount</th>
61
    <th>Amount</th>
35
    <th>Outstanding</th>
62
    <th>Outstanding</th>
63
    <th>Manager</th>
36
    <!-- TMPL_IF NAME="reverse_col" -->
64
    <!-- TMPL_IF NAME="reverse_col" -->
37
    <th>&nbsp;</th>
65
    <th>&nbsp;</th>
38
    <!-- /TMPL_IF -->
66
    <!-- /TMPL_IF -->
39
    <th>Print</th>
67
    <th>Print</th>
40
  </tr>
68
  </thead>
41
69
42
	<!-- FIXME: Shouldn't hardcode dollar signs, since Euro or Pound might be needed -->
70
	<!-- FIXME: Shouldn't hardcode dollar signs, since Euro or Pound might be needed -->
43
  <!-- TMPL_LOOP NAME="accounts" -->
71
  <!-- TMPL_LOOP NAME="accounts" -->
44
72
45
   <!-- TMPL_IF NAME="__odd__" --><tr><!-- TMPL_ELSE --><tr class="highlight"><!-- /TMPL_IF -->
73
   <!-- TMPL_IF NAME="__odd__" --><tr><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
46
      <td><!-- TMPL_VAR NAME="date" --></td>
74
      <td><!-- TMPL_VAR NAME="date" --> <!-- TMPL_VAR NAME="time" --></td>
75
      <td><!-- TMPL_VAR NAME="accountno" --></td>
76
      <td><!-- TMPL_VAR NAME="meansofpayment" --></td>
47
      <td><!-- TMPL_VAR NAME="description" -->&nbsp;<!-- TMPL_IF NAME="itemnumber" --><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">View item</a>&nbsp;<!-- /TMPL_IF --><!-- TMPL_IF NAME="printtitle" --> <!-- TMPL_VAR NAME="title" escape="html" --><!-- /TMPL_IF --></td>
77
      <td><!-- TMPL_VAR NAME="description" -->&nbsp;<!-- TMPL_IF NAME="itemnumber" --><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">View item</a>&nbsp;<!-- /TMPL_IF --><!-- TMPL_IF NAME="printtitle" --> <!-- TMPL_VAR NAME="title" escape="html" --><!-- /TMPL_IF --></td>
48
      <td><!-- TMPL_VAR NAME="note" --></td>
78
      <td><!-- TMPL_VAR NAME="note" --></td>
49
      <!-- TMPL_IF NAME="amountcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amount" --></td>
79
      <!-- TMPL_IF NAME="amountcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amount" --></td>
50
      <!-- TMPL_IF NAME="amountoutstandingcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amountoutstanding" --></td>
80
      <!-- TMPL_IF NAME="amountoutstandingcredit" --><td class="credit"><!-- TMPL_ELSE --><td class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="amountoutstanding" --></td>
81
    <td><!-- TMPL_VAR NAME="manager_details" --></td>
51
    <!-- TMPL_IF NAME="reverse_col" -->
82
    <!-- TMPL_IF NAME="reverse_col" -->
52
      <td>
83
      <td>
53
	<!-- TMPL_IF NAME="payment" -->
84
	<!-- TMPL_IF NAME="payment" -->
54
		<a href="boraccount.pl?action=reverse&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;accountno=<!-- TMPL_VAR NAME="accountno" -->">Reverse</a>
85
        <a href="boraccount.pl?action=reverse&borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&accountno=<!-- TMPL_VAR NAME="accountno" -->&accountlineid=<!-- TMPL_VAR NAME="id" -->">Reverse</a>
55
	<!-- TMPL_ELSE -->
86
	<!-- TMPL_ELSE -->
56
		&nbsp;
87
		&nbsp;
57
	<!-- /TMPL_IF -->
88
	<!-- /TMPL_IF -->
Lines 69-76 Link Here
69
  <!-- /TMPL_LOOP -->
100
  <!-- /TMPL_LOOP -->
70
<tfoot>
101
<tfoot>
71
  <tr>
102
  <tr>
72
    <td colspan="4">Total due</td>
103
    <td colspan="6">Total due</td>
73
    <!-- TMPL_IF NAME="totalcredit" --><td colspan="2" class="credit"><!-- TMPL_ELSE --><td colspan="2" class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="total" --></td>
104
    <!-- TMPL_IF NAME="totalcredit" --><td colspan="3" class="credit"><!-- TMPL_ELSE --><td colspan="3" class="debit"><!-- /TMPL_IF --><!-- TMPL_VAR NAME="total" --></td>
74
  </tr>
105
  </tr>
75
  </tfoot>
106
  </tfoot>
76
</table>
107
</table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl (-1 / +27 lines)
Lines 1-6 Link Here
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2
<title>Koha &rsaquo; Borrowers &rsaquo; Create Manual Credit</title>
2
<title>Koha &rsaquo; Borrowers &rsaquo; Create Manual Credit</title>
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.numeric.js"></script>
5
<script type="text/javascript">
6
$(function(){$("input.numeric_only").numeric();});
7
</script>
8
<script type="text/javascript">
9
function amountchange(value)
10
{
11
	if(value<0)
12
	{
13
		value=0-value;
14
		document.getElementById("amount").value=value;
15
	}
16
}
17
</script>
4
<script type="text/javascript">
18
<script type="text/javascript">
5
//<![CDATA[
19
//<![CDATA[
6
$(document).ready(function(){
20
$(document).ready(function(){
Lines 44-50 $(document).ready(function(){ Link Here
44
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
58
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
45
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
59
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
46
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
60
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
47
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
61
	<li><label for="meansofpayment">Means of payment: </label>
62
	<select name="meansofpayment" id="meansofpayment">
63
<!-- TMPL_LOOP NAME="meansofpaymentoptions" -->
64
        		<!-- TMPL_IF Name="selected" -->
65
        <option value="<!-- TMPL_VAR NAME="option" -->" selected="selected">
66
        <!-- TMPL_ELSE -->
67
        <option value="<!-- TMPL_VAR NAME="option" -->">
68
        <!-- /TMPL_IF -->
69
    <!-- TMPL_VAR NAME="option" --></option>
70
<!-- /TMPL_LOOP -->
71
</select>
72
	</li>
73
	<li><label for="amount">Amount: </label><input type="text" class="numeric_only" name="amount" id="amount" onKeyUp="amountchange(this.value)" /> Example: 5.00</li>
48
</ol></fieldset>
74
</ol></fieldset>
49
75
50
<fieldset class="action"><input type="submit" name="add" value="Add Credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset>
76
<fieldset class="action"><input type="submit" name="add" value="Add Credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl (-1 / +29 lines)
Lines 1-6 Link Here
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2
<title>Koha &rsaquo; Borrowers &rsaquo; Create Manual Invoice</title>
2
<title>Koha &rsaquo; Borrowers &rsaquo; Create Manual Invoice</title>
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.numeric.js"></script>
5
<script type="text/javascript">
6
$(function(){$("input.numeric_only").numeric();});
7
</script>
8
<script type="text/javascript">
9
function amountchange(value)
10
{
11
	if(value<0)
12
	{
13
		value=0-value;
14
		document.getElementById("amount").value=value;
15
	}
16
}
17
</script>
4
<script type="text/javascript">
18
<script type="text/javascript">
5
//<![CDATA[
19
//<![CDATA[
6
$(document).ready(function(){
20
$(document).ready(function(){
Lines 68-74 type_fees['<!-- TMPL_VAR NAME="authorised_value" -->'] = "<!-- TMPL_VAR NAME="li Link Here
68
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
82
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
69
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
83
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
70
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
84
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
71
	<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
85
	<li><label for="meansofpayment">Means of payment: </label>
86
	
87
	
88
	<select name="meansofpayment" id="meansofpayment">
89
<!-- TMPL_LOOP NAME="meansofpaymentoptions" -->
90
        		<!-- TMPL_IF Name="selected" -->
91
        <option value="<!-- TMPL_VAR NAME="option" -->" selected="selected">
92
        <!-- TMPL_ELSE -->
93
        <option value="<!-- TMPL_VAR NAME="option" -->">
94
        <!-- /TMPL_IF -->
95
    <!-- TMPL_VAR NAME="option" --></option>
96
<!-- /TMPL_LOOP -->
97
</select>
98
	</li>
99
	<li><label for="amount">Amount: </label><input type="text" class="numeric_only" name="amount" id="amount" onKeyUp="amountchange(this.value)" /> Example: 5.00</li>
72
	</ol></fieldset>
100
	</ol></fieldset>
73
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset>
101
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset>
74
</form>
102
</form>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl (-5 / +60 lines)
Lines 1-6 Link Here
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2
<title>Koha &rsaquo; Patrons &rsaquo; Pay Fines for  <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --></title>
2
<title>Koha &rsaquo; Patrons &rsaquo; Pay Fines for  <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --></title>
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
3
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.numeric.js"></script>
5
<script type="text/javascript">
6
$(function(){$("input.numeric_only").numeric();});
7
</script>
8
<script type="text/javascript">
9
function payfinechange(value,accountlineid)
10
{
11
	if(value=="pp")
12
	{
13
		document.getElementById("partpaymentamount"+accountlineid).readOnly=false;
14
	}
15
	else
16
	{
17
		document.getElementById("partpaymentamount"+accountlineid).readOnly=true;
18
	}
19
}
20
21
function partpaymentchange(value,accountlineid,amountoutstanding)
22
{
23
	if(value>amountoutstanding)
24
	{
25
		document.getElementById("partpaymentamount"+accountlineid).value=amountoutstanding;
26
	}
27
	if(value<0)
28
	{
29
		value=0-value;
30
		document.getElementById("partpaymentamount"+accountlineid).value=value;
31
	}
32
}
33
</script>
34
4
</head>
35
</head>
5
<body>
36
<body>
6
<!-- TMPL_INCLUDE NAME="header.inc" -->
37
<!-- TMPL_INCLUDE NAME="header.inc" -->
Lines 31-38 Link Here
31
<table>
62
<table>
32
<tr>
63
<tr>
33
	<th>Fines &amp; Charges</th>
64
	<th>Fines &amp; Charges</th>
65
    <th>Means of payment</th>
34
	<th>Description</th>
66
	<th>Description</th>
35
    <th>Note</th>
67
    <th>Note</th>
68
    <th>Part payment</th>
36
	<th>Account Type</th>
69
	<th>Account Type</th>
37
	<th>Notify id</th>
70
	<th>Notify id</th>
38
	<th>Level</th>
71
	<th>Level</th>
Lines 43-54 Link Here
43
<!-- TMPL_LOOP name="allfile" -->
76
<!-- TMPL_LOOP name="allfile" -->
44
	<!-- TMPL_LOOP name="loop_pay" -->
77
	<!-- TMPL_LOOP name="loop_pay" -->
45
<tr>
78
<tr>
46
	<td>
79
    <td><input type="hidden" name="accountlineid<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="accountlineid" -->" />
80
	
47
	<!-- TMPL_IF NAME="net_balance" -->
81
	<!-- TMPL_IF NAME="net_balance" -->
48
	<select name="payfine<!-- TMPL_VAR name="i" -->">
82
	<select name="payfine<!-- TMPL_VAR name="i" -->" onChange="payfinechange(this.value,<!-- TMPL_VAR name="i" -->)">
49
	<option value="no">Unpaid</option>
83
	<option value="no">Unpaid</option>
50
	<option value="yes">Paid</option>
84
	<option value="yes">Paid</option>
51
	<option value="wo">Writeoff</option>
85
	<option value="wo">Writeoff</option>
86
	<option value="pp">Part payment</option>
52
	</select>
87
	</select>
53
	<!-- /TMPL_IF -->
88
	<!-- /TMPL_IF -->
54
	<input type="hidden" name="itemnumber<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="itemnumber" -->" />
89
	<input type="hidden" name="itemnumber<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="itemnumber" -->" />
Lines 61-66 Link Here
61
	<input type="hidden" name="notify_level<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="notify_level" -->" />
96
	<input type="hidden" name="notify_level<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="notify_level" -->" />
62
	<input type="hidden" name="totals<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="totals" -->" />
97
	<input type="hidden" name="totals<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="totals" -->" />
63
	</td>
98
	</td>
99
	<td>
100
	<!-- TMPL_IF NAME="net_balance" -->
101
	<select name="meansofpayment<!-- TMPL_VAR name="i" -->" id="meansofpayment<!-- TMPL_VAR name="i" -->">
102
<!-- TMPL_LOOP NAME="meansofpaymentoptions" -->
103
		<!-- TMPL_IF Name="selected" -->
104
        <option value="<!-- TMPL_VAR NAME="option" -->" selected="selected">
105
        <!-- TMPL_ELSE -->
106
        <option value="<!-- TMPL_VAR NAME="option" -->">
107
        <!-- /TMPL_IF -->
108
    <!-- TMPL_VAR NAME="option" --></option>
109
<!-- /TMPL_LOOP -->
110
</select><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="meansofpayment" -->
111
	<!-- /TMPL_IF -->
112
	</td>
64
	<td><!-- TMPL_VAR name="description" --> <!-- TMPL_VAR name="title" escape="html" --></td>
113
	<td><!-- TMPL_VAR name="description" --> <!-- TMPL_VAR name="title" escape="html" --></td>
65
    <td>
114
    <td>
66
        <!-- TMPL_IF NAME="net_balance" -->
115
        <!-- TMPL_IF NAME="net_balance" -->
Lines 69-74 Link Here
69
        <!-- TMPL_VAR name="note" -->
118
        <!-- TMPL_VAR name="note" -->
70
        <!-- TMPL_IF NAME="net_balance" -->" /><!-- /TMPL_IF -->
119
        <!-- TMPL_IF NAME="net_balance" -->" /><!-- /TMPL_IF -->
71
    </td>
120
    </td>
121
	<td>
122
	<!-- TMPL_IF NAME="net_balance" -->
123
	<input type="text" class="numeric_only" readOnly="true" id="partpaymentamount<!-- TMPL_VAR name="i" -->" name="partpaymentamount<!-- TMPL_VAR name="i" -->" value="
124
	<!-- /TMPL_IF -->
125
	<!-- TMPL_VAR name="partpaymentamount" -->
126
	<!-- TMPL_IF NAME="net_balance" -->" onKeyUp="partpaymentchange(this.value,<!-- TMPL_VAR name="i" -->,<!-- TMPL_VAR name="amountoutstanding" -->)" /><!-- /TMPL_IF -->
127
	</td>
72
	<td><!-- TMPL_VAR name="accounttype" --></td>
128
	<td><!-- TMPL_VAR name="accounttype" --></td>
73
	<td><!-- TMPL_VAR name="notify_id" --></td>
129
	<td><!-- TMPL_VAR name="notify_id" --></td>
74
	<td><!-- TMPL_VAR name="notify_level" --></td>
130
	<td><!-- TMPL_VAR name="notify_level" --></td>
Lines 78-91 Link Here
78
<!-- /TMPL_LOOP  -->
134
<!-- /TMPL_LOOP  -->
79
<!-- TMPL_IF  NAME="total"-->
135
<!-- TMPL_IF  NAME="total"-->
80
<tr>
136
<tr>
81
137
	<td colspan="9">Sub Total <!-- TMPL_VAR name="notify" --></td>
82
	<td colspan="7">Sub Total</td>
83
	<td><!-- TMPL_VAR name="total" --></td>
138
	<td><!-- TMPL_VAR name="total" --></td>
84
</tr>
139
</tr>
85
<!--/TMPL_IF-->
140
<!--/TMPL_IF-->
86
<!-- /TMPL_LOOP  -->
141
<!-- /TMPL_LOOP  -->
87
<tr>
142
<tr>
88
	<td colspan="7">Total Due</td>
143
	<td colspan="9">Total Due</td>
89
	<td><!-- TMPL_VAR name="total" --></td>
144
	<td><!-- TMPL_VAR name="total" --></td>
90
</tr>
145
</tr>
91
</table>
146
</table>
(-)a/kohaversion.pl (-1 / +1 lines)
Lines 16-22 the kohaversion is divided in 4 parts : Link Here
16
use strict;
16
use strict;
17
17
18
sub kohaversion {
18
sub kohaversion {
19
    our $VERSION = '3.03.00.035';
19
    our $VERSION = '3.03.00.037';
20
    # version needs to be set this way
20
    # version needs to be set this way
21
    # so that it can be picked up by Makefile.PL
21
    # so that it can be picked up by Makefile.PL
22
    # during install
22
    # during install
(-)a/members/boraccount.pl (-1 / +9 lines)
Lines 52-58 my $action = $input->param('action') || ''; Link Here
52
my $data=GetMember('borrowernumber' => $borrowernumber);
52
my $data=GetMember('borrowernumber' => $borrowernumber);
53
53
54
if ( $action eq 'reverse' ) {
54
if ( $action eq 'reverse' ) {
55
  ReversePayment( $borrowernumber, $input->param('accountno') );
55
  ReversePayment( $input->param('accountlineid') );
56
}
56
}
57
57
58
if ( $data->{'category_type'} eq 'C') {
58
if ( $data->{'category_type'} eq 'C') {
Lines 90-95 foreach my $accountline ( @{$accts}) { Link Here
90
    if ($accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU'){
90
    if ($accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU'){
91
        $accountline->{printtitle} = 1;
91
        $accountline->{printtitle} = 1;
92
    }
92
    }
93
    
94
    if ( $accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU' ) {
95
        $accountline->{printtitle} = 1;
96
    }
97
    if ( $accountline->{manager_id} ne '' ) {
98
       my $datamanager = GetMember( 'borrowernumber' => $accountline->{manager_id} );
99
    	$accountline->{manager_details}=$datamanager->{'firstname'}." ".$datamanager->{'surname'};
100
    }
93
}
101
}
94
102
95
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
103
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
(-)a/members/mancredit.pl (-1 / +3 lines)
Lines 48-57 if ($add){ Link Here
48
        my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
48
        my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
49
        my $desc    = $input->param('desc');
49
        my $desc    = $input->param('desc');
50
        my $note    = $input->param('note');
50
        my $note    = $input->param('note');
51
	    my $meansofpayment    = $input->param('meansofpayment');
51
        my $amount  = $input->param('amount') || 0;
52
        my $amount  = $input->param('amount') || 0;
52
        $amount = -$amount;
53
        $amount = -$amount;
53
        my $type = $input->param('type');
54
        my $type = $input->param('type');
54
        manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
55
        manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment );
55
        print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
56
        print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
56
    }
57
    }
57
} else {
58
} else {
Lines 94-98 if ($add){ Link Here
94
		    branchname => GetBranchName($data->{'branchcode'}),
95
		    branchname => GetBranchName($data->{'branchcode'}),
95
		    is_child        => ($data->{'category_type'} eq 'C'),
96
		    is_child        => ($data->{'category_type'} eq 'C'),
96
        );
97
        );
98
    $template->param( 'meansofpaymentoptions' => getMeansOfPaymentList() );
97
    output_html_with_http_headers $input, $cookie, $template->output;
99
    output_html_with_http_headers $input, $cookie, $template->output;
98
}
100
}
(-)a/members/maninvoice.pl (-1 / +4 lines)
Lines 50-56 if ($add){ Link Here
50
        my $amount=$input->param('amount');
50
        my $amount=$input->param('amount');
51
        my $type=$input->param('type');
51
        my $type=$input->param('type');
52
        my $note    = $input->param('note');
52
        my $note    = $input->param('note');
53
        my $error   = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
53
        my $meansofpayment = $input->param('meansofpayment');
54
        my $error   = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment );
54
        if ($error) {
55
        if ($error) {
55
            my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
56
            my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
56
                {   template_name   => "members/maninvoice.tmpl",
57
                {   template_name   => "members/maninvoice.tmpl",
Lines 65-70 if ($add){ Link Here
65
                $template->param( 'ITEMNUMBER' => 1 );
66
                $template->param( 'ITEMNUMBER' => 1 );
66
            }
67
            }
67
            $template->param( 'ERROR' => $error );
68
            $template->param( 'ERROR' => $error );
69
	        $template->param( 'meansofpaymentoptions' => getMeansOfPaymentList() );
68
            output_html_with_http_headers $input, $cookie, $template->output;
70
            output_html_with_http_headers $input, $cookie, $template->output;
69
        } else {
71
        } else {
70
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
72
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
Lines 122-126 if ($add){ Link Here
122
		branchname => GetBranchName($data->{'branchcode'}),
124
		branchname => GetBranchName($data->{'branchcode'}),
123
		is_child        => ($data->{'category_type'} eq 'C'),
125
		is_child        => ($data->{'category_type'} eq 'C'),
124
    );
126
    );
127
    $template->param( 'meansofpaymentoptions' => getMeansOfPaymentList() );
125
    output_html_with_http_headers $input, $cookie, $template->output;
128
    output_html_with_http_headers $input, $cookie, $template->output;
126
}
129
}
(-)a/members/pay.pl (-31 / +55 lines)
Lines 41-46 use C4::Overdues; Link Here
41
use C4::Branch; # GetBranches
41
use C4::Branch; # GetBranches
42
42
43
my $input = new CGI;
43
my $input = new CGI;
44
my $lastinsertid = 0;
44
45
45
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
    {
47
    {
Lines 53-58 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
53
    }
54
    }
54
);
55
);
55
56
57
my $manager_id = C4::Context->userenv->{'number'};
56
my $borrowernumber = $input->param('borrowernumber');
58
my $borrowernumber = $input->param('borrowernumber');
57
if ( $borrowernumber eq '' ) {
59
if ( $borrowernumber eq '' ) {
58
    $borrowernumber = $input->param('borrowernumber0');
60
    $borrowernumber = $input->param('borrowernumber0');
Lines 70-95 my @names = $input->param; Link Here
70
my %inp;
72
my %inp;
71
my $check = 0;
73
my $check = 0;
72
for ( my $i = 0 ; $i < @names ; $i++ ) {
74
for ( my $i = 0 ; $i < @names ; $i++ ) {
73
    my $temp = $input->param( $names[$i] );
75
	if(defined($input->param( $names[ $i + 1 ] )))
74
    if ( $temp eq 'wo' ) {
76
	{
75
        $inp{ $names[$i] } = $temp;
77
	    if(defined($input->param( "payfine".$input->param( $names[ $i + 1 ] ) )))
76
        $check = 1;
78
	    {
77
    }
79
	    	my $accountlineid      = $input->param( $names[ $i + 1 ] );#7
78
    if ( $temp eq 'yes' ) {
80
		    my $temp = $input->param( "payfine".$accountlineid );
79
81
		    if ( $temp eq 'wo' ) {
80
# FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline
82
		        $inp{ $names[$i] } = $temp;
81
        my $amount         = $input->param( $names[ $i + 4 ] );
83
		        $check = 1;
82
        my $borrowernumber = $input->param( $names[ $i + 5 ] );
84
		    }
83
        my $accountno      = $input->param( $names[ $i + 6 ] );
85
		    if ( $temp eq 'yes' ) {
84
        makepayment( $borrowernumber, $accountno, $amount, $user, $branch );
86
				#my $accountlineid = $input->param( $names[ $i + 1 ] );#7
85
        $check = 2;
87
		        # FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline
86
    }
88
		        my $amount = $input->param( "amount".$accountlineid );#4
87
    if ( $temp eq 'no'||$temp eq 'yes'||$temp eq 'wo') {
89
		        my $borrowernumber = $input->param( "borrowernumber".$accountlineid );#5
88
        my $borrowernumber = $input->param( $names[ $i + 5 ] );
90
		        my $accountno = $input->param( "accountno".$accountlineid );#6
89
        my $accountno      = $input->param( $names[ $i + 6 ] );
91
		        my $note = $input->param( "note".$accountlineid );#12
90
        my $note     = $input->param( $names[ $i + 10 ] );
92
		        my $meansofpayment = $input->param( "meansofpayment".$accountlineid );#11
91
        ModNote( $borrowernumber, $accountno, $note );
93
		        #$accountnoupdated = getnextacctno($borrowernumber);
92
    }
94
		        $lastinsertid = makepayment( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, 0 );
95
		        $check = 2;
96
		    }
97
		    elsif($temp eq 'pp')
98
		    {
99
		    	#my $accountlineid      = $input->param( $names[ $i +1 ] );#7
100
		    	my $amount         = $input->param( "amount".$accountlineid );#4
101
		        my $borrowernumber = $input->param( "borrowernumber".$accountlineid );#5
102
		        my $accountno      = $input->param( "accountno".$accountlineid );#6
103
		        my $note     = $input->param( "note".$accountlineid );#12
104
		        my $meansofpayment     = $input->param( "meansofpayment".$accountlineid );#11
105
		        my $partpaymentamount         = $input->param( "partpaymentamount".$accountlineid );#13
106
		    	$lastinsertid = makepayment( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, $partpaymentamount);
107
		        $check = 2;
108
		    }
109
	    }
110
	}
93
}
111
}
94
112
95
my $total = $input->param('total') || '';
113
my $total = $input->param('total') || '';
Lines 113-119 if ( $check == 0 ) { Link Here
113
            if ( $accts->[$i]{'amountoutstanding'} != 0 ) {
131
            if ( $accts->[$i]{'amountoutstanding'} != 0 ) {
114
                $accts->[$i]{'amount'}            += 0.00;
132
                $accts->[$i]{'amount'}            += 0.00;
115
                $accts->[$i]{'amountoutstanding'} += 0.00;
133
                $accts->[$i]{'amountoutstanding'} += 0.00;
116
                $line{i}           = $j . "" . $i;
134
                $line{i}                 = $accts->[$i]{'id'};
135
                $line{accountlineid}     = $accts->[$i]{'id'};
117
                $line{itemnumber}  = $accts->[$i]{'itemnumber'};
136
                $line{itemnumber}  = $accts->[$i]{'itemnumber'};
118
                $line{accounttype} = $accts->[$i]{'accounttype'};
137
                $line{accounttype} = $accts->[$i]{'accounttype'};
119
                $line{amount}      = sprintf( "%.2f", $accts->[$i]{'amount'} );
138
                $line{amount}      = sprintf( "%.2f", $accts->[$i]{'amount'} );
Lines 123-128 if ( $check == 0 ) { Link Here
123
                $line{accountno}      = $accts->[$i]{'accountno'};
142
                $line{accountno}      = $accts->[$i]{'accountno'};
124
                $line{description}    = $accts->[$i]{'description'};
143
                $line{description}    = $accts->[$i]{'description'};
125
                $line{note}           = $accts->[$i]{'note'};
144
                $line{note}           = $accts->[$i]{'note'};
145
                $line{meansofpaymentoptions} = getMeansOfPaymentList($accts->[$i]{'meansofpayment'});
146
                $line{meansofpayment} = $accts->[$i]{'meansofpayment'};
126
                $line{title}          = $accts->[$i]{'title'};
147
                $line{title}          = $accts->[$i]{'title'};
127
                $line{notify_id}      = $accts->[$i]{'notify_id'};
148
                $line{notify_id}      = $accts->[$i]{'notify_id'};
128
                $line{notify_level}   = $accts->[$i]{'notify_level'};
149
                $line{notify_level}   = $accts->[$i]{'notify_level'};
Lines 197-203 else { Link Here
197
        my $itemno    = $input->param("itemnumber$value");
218
        my $itemno    = $input->param("itemnumber$value");
198
        my $amount    = $input->param("amount$value");
219
        my $amount    = $input->param("amount$value");
199
        my $accountno = $input->param("accountno$value");
220
        my $accountno = $input->param("accountno$value");
200
        writeoff( $borrowernumber, $accountno, $itemno, $accounttype, $amount );
221
        my $accountlineid = $input->param("accountlineid$value");
222
        writeoff( $borrowernumber, $accountno, $itemno, $accounttype, $amount, $accountlineid );
201
    }
223
    }
202
    $borrowernumber = $input->param('borrowernumber');
224
    $borrowernumber = $input->param('borrowernumber');
203
    print $input->redirect(
225
    print $input->redirect(
Lines 205-218 else { Link Here
205
}
227
}
206
228
207
sub writeoff {
229
sub writeoff {
208
    my ( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount ) = @_;
230
    my ( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount, $accountlineid ) = @_;
209
    my $user = $input->remote_user;
231
    my $user = $input->remote_user;
210
    my $dbh  = C4::Context->dbh;
232
    my $dbh  = C4::Context->dbh;
211
    undef $itemnum unless $itemnum; # if no item is attached to fine, make sure to store it as a NULL
233
    undef $itemnum unless $itemnum; # if no item is attached to fine, make sure to store it as a NULL
212
    my $sth =
234
    my $sth = $dbh->prepare("
213
      $dbh->prepare(
235
        UPDATE accountlines SET amountoutstanding = 0
214
"Update accountlines set amountoutstanding=0 where accountno=? and borrowernumber=?"
236
        WHERE id = ?
215
      );
237
    ");
216
    $sth->execute( $accountnum, $borrowernumber );
238
    $sth->execute( $accountnum, $borrowernumber );
217
    $sth->finish;
239
    $sth->finish;
218
    $sth = $dbh->prepare("select max(accountno) from accountlines");
240
    $sth = $dbh->prepare("select max(accountno) from accountlines");
Lines 220-229 sub writeoff { Link Here
220
    my $account = $sth->fetchrow_hashref;
242
    my $account = $sth->fetchrow_hashref;
221
    $sth->finish;
243
    $sth->finish;
222
    $account->{'max(accountno)'}++;
244
    $account->{'max(accountno)'}++;
223
    $sth = $dbh->prepare(
245
    $sth = $dbh->prepare("
224
"insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
246
        INSERT INTO accountlines (borrowernumber,accountno,itemnumber,
225
						values (?,?,?,now(),?,'Writeoff','W')"
247
                                  date,time,amount,description,accounttype,
226
    );
248
                                  manager_id)
249
		VALUES (?,?,?,now(),CURRENT_TIME,?,'Writeoff','W',?)
250
    ");
227
    $sth->execute( $borrowernumber, $account->{'max(accountno)'},
251
    $sth->execute( $borrowernumber, $account->{'max(accountno)'},
228
        $itemnum, $amount );
252
        $itemnum, $amount );
229
    $sth->finish;
253
    $sth->finish;
(-)a/t/db_dependent/lib/KohaTest/Members/GetMemberDetails.pm (-6 / +5 lines)
Lines 24-30 retrieval. Link Here
24
24
25
sub startup_create_detailed_borrower : Test( startup => 2 ) {
25
sub startup_create_detailed_borrower : Test( startup => 2 ) {
26
    my $self = shift;
26
    my $self = shift;
27
    my ( $description, $type, $amount, $user );
27
    my ( $description, $type, $amount, $note, $meansofpayment );
28
28
29
    my $memberinfo = {
29
    my $memberinfo = {
30
        surname      => 'surname' . $self->random_string(),
30
        surname      => 'surname' . $self->random_string(),
Lines 50-60 sub startup_create_detailed_borrower : Test( startup => 2 ) { Link Here
50
    $description = 'Test account';
50
    $description = 'Test account';
51
    $type        = 'M';
51
    $type        = 'M';
52
    $amount      = 5.00;
52
    $amount      = 5.00;
53
    $user        = '';
53
    $note        = '';
54
    $meansofpayment = '';
54
55
55
    my $acct_added =
56
    my $acct_added = C4::Accounts::manualinvoice( $borrowernumber, undef,
56
      C4::Accounts::manualinvoice( $borrowernumber, undef, $description, $type, $amount,
57
        $description, $type, $amount, $note, $meansofpayment );
57
        $user );
58
58
59
    ok( $acct_added == 0, 'added account for borrower' );
59
    ok( $acct_added == 0, 'added account for borrower' );
60
60
61
- 

Return to bug 5905