@@ -, +, @@ --- C4/Accounts.pm | 12 ++- .../prog/en/modules/members/paycollect.tt | 88 ++++++++++++++++---- members/paycollect.pl | 34 ++++++-- 3 files changed, 104 insertions(+), 30 deletions(-) --- a/C4/Accounts.pm +++ a/C4/Accounts.pm @@ -696,11 +696,12 @@ sub makepartialpayment { } # create new line + my $payment = 0 - $amount; my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' . 'description, accounttype, amountoutstanding, itemnumber, manager_id, note) ' . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)'; - $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, + $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $payment, "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); @@ -710,7 +711,7 @@ sub makepartialpayment { action => 'create_payment', borrowernumber => $user, accountno => $nextaccntno, - amount => 0 - $amount, + amount => $payment, accounttype => 'Pay', itemnumber => $data->{'itemnumber'}, accountlines_paid => [ $data->{'accountlines_id'} ], @@ -772,14 +773,15 @@ sub WriteOffFee { "; $sth = $dbh->prepare( $query ); my $acct = getnextacctno($borrowernumber); - $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note ); + my $payment = 0 - $amount; + $sth->execute( $borrowernumber, $acct, $itemnum, $payment, $manager_id, $payment_note ); if ( C4::Context->preference("FinesLog") ) { logaction("FINES", 'CREATE',$borrowernumber,Dumper({ action => 'create_writeoff', borrowernumber => $borrowernumber, accountno => $acct, - amount => 0 - $amount, + amount => $payment, accounttype => 'W', itemnumber => $itemnum, accountlines_paid => [ $accountlines_id ], @@ -787,7 +789,7 @@ sub WriteOffFee { })); } - UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); + UpdateStats( $branch, 'writeoff', $payment, q{}, q{}, q{}, $borrowernumber ); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -3,13 +3,6 @@ [% INCLUDE 'doc-head-close.inc' %] - @@ -91,14 +88,32 @@ function moneyFormat(textObj) {
-[% IF ( error_over ) %] +[% IF (error_negative) %]
- You must pay a value less than or equal to [% total_due | format('%.2f') %]. + The amount paid can't be negative!
[% END %] +[% IF (error_collected_less) %] +
+ The amount collected can't be lower than the amount paid! +
+[% END %] + +[% UNLESS (writeoff_individual) %] +
+[% END %] + +[% IF (give_change) %] +
+ The amount collected is greater than the total amount paid.
+ Change to give back: [% give_change %]

+ + Cancel +
+[% END %] + [% IF ( pay_individual ) %] - @@ -140,12 +155,32 @@ function moneyFormat(textObj) {
    - + [% IF ( give_change ) %]
  1. - - - + + + + [% amount_paid %]
  2. +
  3. + + [% amount_collected %] +
  4. +
  5. + + [% give_change %] +
  6. + [% ELSE %] +
  7. + + + [% amount_paid %] +
  8. +
  9. + + +
  10. + [% END %]
@@ -194,7 +229,6 @@ function moneyFormat(textObj) {
[% ELSE %] -
@@ -206,11 +240,31 @@ function moneyFormat(textObj) { Total amount outstanding: [% total | format('%.2f') %] + [% IF ( give_change ) %] +
  • + + + +
  • +
  • + + [% amount_collected %] +
  • +
  • + + [% give_change %] +
  • + [% ELSE %] +
  • + + +
  • - + - +
  • + [% END %]
  • --- a/members/paycollect.pl +++ a/members/paycollect.pl @@ -51,11 +51,11 @@ my $branch = GetBranch( $input, GetBranches() ); my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber); my $total_paid = $input->param('paid'); +my $total_collected = $input->param('collected'); my $individual = $input->param('pay_individual'); my $writeoff = $input->param('writeoff_individual'); -my $select_lines = $input->param('selected'); -my $select = $input->param('selected_accts'); +my $select = ($input->param('selected') || $input->param('selected_accts')); my $payment_note = uri_unescape $input->param('payment_note'); my $accountno; my $accountlines_id; @@ -89,20 +89,38 @@ if ( $individual || $writeoff ) { notify_level => $notify_level, payment_note => $payment_note, ); -} elsif ($select_lines) { - $total_due = $input->param('amt'); +} elsif ($select) { + $total_due = ($input->param('amt') || $input->param('total')); $template->param( - selected_accts => $select_lines, + selected_accts => $select, amt => $total_due, selected_accts_notes => $input->param('notes'), ); } if ( $total_paid and $total_paid ne '0.00' ) { - if ( $total_paid < 0 or $total_paid > $total_due ) { + if ( $total_paid < 0 ) { + $template->param( + error_negative => 1, + ); + } + elsif (($total_collected - $total_paid) < 0) { + $template->param( + error_collected_less => 1, + ); + } + elsif ($total_paid > $total_due) { $template->param( - error_over => 1, - total_due => $total_due + amount_paid => sprintf('%.2f', $total_due), + amount_collected => sprintf('%.2f', $total_collected), + give_change => sprintf('%.2f',($total_collected-$total_due)) + ); + } + elsif ($total_paid < $total_due and $total_collected ne $total_paid) { + $template->param( + amount_paid => sprintf('%.2f', $total_paid), + amount_collected => sprintf('%.2f', $total_collected), + give_change => sprintf('%.2f',($total_collected-$total_paid)) ); } else { if ($individual) { --