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

(-)a/C4/Accounts.pm (-5 / +7 lines)
Lines 696-706 sub makepartialpayment { Link Here
696
    }
696
    }
697
697
698
    # create new line
698
    # create new line
699
    my $payment = 0 - $amount;
699
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
700
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
700
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
701
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
701
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
702
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
702
703
703
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
704
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $payment,
704
        "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
705
        "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
705
706
706
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
707
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
Lines 710-716 sub makepartialpayment { Link Here
710
            action            => 'create_payment',
711
            action            => 'create_payment',
711
            borrowernumber    => $user,
712
            borrowernumber    => $user,
712
            accountno         => $nextaccntno,
713
            accountno         => $nextaccntno,
713
            amount            => 0 - $amount,
714
            amount            => $payment,
714
            accounttype       => 'Pay',
715
            accounttype       => 'Pay',
715
            itemnumber        => $data->{'itemnumber'},
716
            itemnumber        => $data->{'itemnumber'},
716
            accountlines_paid => [ $data->{'accountlines_id'} ],
717
            accountlines_paid => [ $data->{'accountlines_id'} ],
Lines 772-785 sub WriteOffFee { Link Here
772
    ";
773
    ";
773
    $sth = $dbh->prepare( $query );
774
    $sth = $dbh->prepare( $query );
774
    my $acct = getnextacctno($borrowernumber);
775
    my $acct = getnextacctno($borrowernumber);
775
    $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note );
776
    my $payment = 0 - $amount;
777
    $sth->execute( $borrowernumber, $acct, $itemnum, $payment, $manager_id, $payment_note );
776
778
777
    if ( C4::Context->preference("FinesLog") ) {
779
    if ( C4::Context->preference("FinesLog") ) {
778
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
780
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
779
            action            => 'create_writeoff',
781
            action            => 'create_writeoff',
780
            borrowernumber    => $borrowernumber,
782
            borrowernumber    => $borrowernumber,
781
            accountno         => $acct,
783
            accountno         => $acct,
782
            amount            => 0 - $amount,
784
            amount            => $payment,
783
            accounttype       => 'W',
785
            accounttype       => 'W',
784
            itemnumber        => $itemnum,
786
            itemnumber        => $itemnum,
785
            accountlines_paid => [ $accountlines_id ],
787
            accountlines_paid => [ $accountlines_id ],
Lines 787-793 sub WriteOffFee { Link Here
787
        }));
789
        }));
788
    }
790
    }
789
791
790
    UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber );
792
    UpdateStats( $branch, 'writeoff', $payment, q{}, q{}, q{}, $borrowernumber );
791
793
792
}
794
}
793
795
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (-17 / +71 lines)
Lines 3-15 Link Here
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type= "text/javascript">
4
<script type= "text/javascript">
5
//<![CDATA[
5
//<![CDATA[
6
$(document).ready(function() {
7
    $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
8
});
9
//]]>
10
</script>
11
<script type= "text/javascript">
12
//<![CDATA[
13
function moneyFormat(textObj) {
6
function moneyFormat(textObj) {
14
    var newValue = textObj.value;
7
    var newValue = textObj.value;
15
    var decAmount = "";
8
    var decAmount = "";
Lines 58-63 function moneyFormat(textObj) { Link Here
58
51
59
    textObj.value = dolAmount + "." + decAmount;
52
    textObj.value = dolAmount + "." + decAmount;
60
}
53
}
54
55
$(document).ready(function() {
56
    $('#payform, #woindivfine').preventDoubleFormSubmit();
57
});
61
//]]>
58
//]]>
62
</script>
59
</script>
63
</head>
60
</head>
Lines 91-104 function moneyFormat(textObj) { Link Here
91
    </li>
88
    </li>
92
</ul>
89
</ul>
93
<div class="tabs-container">
90
<div class="tabs-container">
94
[% IF ( error_over ) %]
91
[% IF (error_negative) %]
95
    <div id="error_message" class="dialog alert">
92
    <div id="error_message" class="dialog alert">
96
    You must pay a value less than or equal to [% total_due | format('%.2f') %].
93
        <span>The amount paid can't be negative!</span>
97
    </div>
94
    </div>
98
[% END %]
95
[% END %]
99
96
97
[% IF (error_collected_less) %]
98
    <div id="error_message" class="dialog alert">
99
        <span>The amount collected can't be lower than the amount paid!</span>
100
    </div>
101
[% END %]
102
103
[% UNLESS (writeoff_individual) %]
104
    <form name="payform" id="payform" action="/cgi-bin/koha/members/paycollect.pl" method="post">
105
[% END %]
106
107
[% IF (give_change) %]
108
    <div id="change_message" class="dialog message">
109
        <span>The amount collected is greater than the total amount paid.</span><br />
110
        <strong>Change to give back: [% give_change %]</strong><br /><br />
111
        <input type="submit" name="submitbutton" value="Confirm payment" />
112
        <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a>
113
     </div>
114
[% END %]
115
100
[% IF ( pay_individual ) %]
116
[% IF ( pay_individual ) %]
101
    <form name="payindivfine" id="payindivfine" onsubmit="return validatePayment(this);" method="post" action="/cgi-bin/koha/members/paycollect.pl">
102
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
117
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
103
    <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual %]" />
118
    <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual %]" />
104
    <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber %]" />
119
    <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber %]" />
Lines 140-151 function moneyFormat(textObj) { Link Here
140
</table>
155
</table>
141
156
142
<ol>
157
<ol>
143
158
    [% IF ( give_change ) %]
144
    <li>
159
    <li>
145
        <label for="paid">Collect from patron: </label>
160
        <label for="paid">Amount paid:</label>
146
            <!-- default to paying all -->
161
        <input type="hidden" name="paid" id="paid" value="[% amount_paid %]" />
147
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payindivfine.paid)"/>
162
        <input type="hidden" name="collected" id="collected" value="[% amount_paid %]" />
163
        [% amount_paid %]
148
    </li>
164
    </li>
165
    <li>
166
        <label>Collect from patron:</label>
167
        [% amount_collected %]
168
    </li>
169
    <li>
170
        <label>Change to give back:</label>
171
        [% give_change %]
172
    </li>
173
    [% ELSE %]
174
    <li>
175
        <label for="paid">Amount paid :</label>
176
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payform.paid)"/>
177
        [% amount_paid %]
178
    </li>
179
    <li>
180
        <label for="collected">Collect from patron:</label>
181
        <input name="collected" id="collected" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payform.collected)" />
182
    </li>
183
    [% END %]
149
</ol>
184
</ol>
150
</fieldset>
185
</fieldset>
151
186
Lines 194-200 function moneyFormat(textObj) { Link Here
194
    </form>
229
    </form>
195
[% ELSE %]
230
[% ELSE %]
196
231
197
    <form name="payfine" id="payfine" onsubmit="return validatePayment(this);" method="post" action="/cgi-bin/koha/members/paycollect.pl">
198
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
232
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
199
    <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts %]" />
233
    <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts %]" />
200
    <input type="hidden" name="total" id="total" value="[% total %]" />
234
    <input type="hidden" name="total" id="total" value="[% total %]" />
Lines 206-216 function moneyFormat(textObj) { Link Here
206
            <span class="label">Total amount outstanding: </span>
240
            <span class="label">Total amount outstanding: </span>
207
            <span class="debit">[% total | format('%.2f') %]</span>
241
            <span class="debit">[% total | format('%.2f') %]</span>
208
        </li>
242
        </li>
243
    [% IF ( give_change ) %]
244
    <li>
245
        <label for="paid">Amount paid:</label>
246
        <!-- default to paying all -->
247
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payform.paid)"/>
248
    </li>
249
    <li>
250
        <label>Collect from patron:</label>
251
        [% amount_collected %]
252
    </li>
253
    <li>
254
        <label>Change to give back:</label>
255
        [% give_change %]
256
    </li>
257
    [% ELSE %]
258
    <li>
259
        <label for="paid">Amount paid :</label>
260
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payform.paid)" />
261
    </li>
209
    <li>
262
    <li>
210
        <label for="paid">Collect from patron: </label>
263
        <label for="collected">Collect from patron:</label>
211
        <!-- default to paying all -->
264
        <!-- default to paying all -->
212
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payfine.paid)"/>
265
        <input name="collected" id="collected" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payform.collected)"/>
213
    </li>
266
    </li>
267
    [% END %]
214
    <li>
268
    <li>
215
        <label for="selected_accts_notes">Note: </label>
269
        <label for="selected_accts_notes">Note: </label>
216
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
270
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
(-)a/members/paycollect.pl (-9 / +26 lines)
Lines 51-61 my $branch = GetBranch( $input, GetBranches() ); Link Here
51
51
52
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
52
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
53
my $total_paid = $input->param('paid');
53
my $total_paid = $input->param('paid');
54
my $total_collected = $input->param('collected');
54
55
55
my $individual   = $input->param('pay_individual');
56
my $individual   = $input->param('pay_individual');
56
my $writeoff     = $input->param('writeoff_individual');
57
my $writeoff     = $input->param('writeoff_individual');
57
my $select_lines = $input->param('selected');
58
my $select       = ($input->param('selected') || $input->param('selected_accts'));
58
my $select       = $input->param('selected_accts');
59
my $payment_note = uri_unescape $input->param('payment_note');
59
my $payment_note = uri_unescape $input->param('payment_note');
60
my $accountno;
60
my $accountno;
61
my $accountlines_id;
61
my $accountlines_id;
Lines 89-108 if ( $individual || $writeoff ) { Link Here
89
        notify_level      => $notify_level,
89
        notify_level      => $notify_level,
90
        payment_note    => $payment_note,
90
        payment_note    => $payment_note,
91
    );
91
    );
92
} elsif ($select_lines) {
92
} elsif ($select) {
93
    $total_due = $input->param('amt');
93
    $total_due = ($input->param('amt') || $input->param('total'));
94
    $template->param(
94
    $template->param(
95
        selected_accts => $select_lines,
95
        selected_accts => $select,
96
        amt            => $total_due,
96
        amt            => $total_due,
97
        selected_accts_notes => $input->param('notes'),
97
        selected_accts_notes => $input->param('notes'),
98
    );
98
    );
99
}
99
}
100
100
101
if ( $total_paid and $total_paid ne '0.00' ) {
101
if ( $total_paid and $total_paid ne '0.00' ) {
102
    if ( $total_paid < 0 or $total_paid > $total_due ) {
102
    if ( $total_paid < 0 ) {
103
        $template->param( 
104
            error_negative => 1,
105
        );
106
    }
107
    elsif (($total_collected - $total_paid) < 0) {
108
        $template->param( 
109
            error_collected_less => 1,
110
        );
111
    }
112
    elsif ($total_paid > $total_due) {
103
        $template->param(
113
        $template->param(
104
            error_over => 1,
114
            amount_paid => sprintf('%.2f', $total_due),
105
            total_due => $total_due
115
            amount_collected => sprintf('%.2f', $total_collected),
116
            give_change => sprintf('%.2f',($total_collected-$total_due))
117
        );
118
    }
119
    elsif ($total_paid < $total_due and $total_collected ne $total_paid) {
120
         $template->param(
121
            amount_paid => sprintf('%.2f', $total_paid),
122
            amount_collected => sprintf('%.2f', $total_collected),
123
            give_change => sprintf('%.2f',($total_collected-$total_paid))
106
        );
124
        );
107
    } else {
125
    } else {
108
        if ($individual) {
126
        if ($individual) {
109
- 

Return to bug 11373