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

(-)a/C4/Accounts.pm (-6 / +8 lines)
Lines 718-734 sub makepartialpayment { Link Here
718
    }
718
    }
719
719
720
    # create new line
720
    # create new line
721
    my $payment = 0 - $amount;
721
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
722
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
722
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
723
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
723
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
724
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
724
725
725
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
726
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $payment,
726
        '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
727
        '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
727
728
728
    UpdateStats({
729
    UpdateStats({
729
                branch => $user,
730
                branch => $user,
730
                type => 'payment',
731
                type => 'payment',
731
                amount => $amount,
732
                amount => $payment,
732
                borrowernumber => $borrowernumber,
733
                borrowernumber => $borrowernumber,
733
                accountno => $accountno}
734
                accountno => $accountno}
734
    );
735
    );
Lines 738-744 sub makepartialpayment { Link Here
738
            action            => 'create_payment',
739
            action            => 'create_payment',
739
            borrowernumber    => $user,
740
            borrowernumber    => $user,
740
            accountno         => $nextaccntno,
741
            accountno         => $nextaccntno,
741
            amount            => 0 - $amount,
742
            amount            => $payment,
742
            accounttype       => 'Pay',
743
            accounttype       => 'Pay',
743
            itemnumber        => $data->{'itemnumber'},
744
            itemnumber        => $data->{'itemnumber'},
744
            accountlines_paid => [ $data->{'accountlines_id'} ],
745
            accountlines_paid => [ $data->{'accountlines_id'} ],
Lines 800-813 sub WriteOffFee { Link Here
800
    ";
801
    ";
801
    $sth = $dbh->prepare( $query );
802
    $sth = $dbh->prepare( $query );
802
    my $acct = getnextacctno($borrowernumber);
803
    my $acct = getnextacctno($borrowernumber);
803
    $sth->execute( $borrowernumber, $acct, $itemnum, $amount, $manager_id, $payment_note );
804
    my $payment = 0 - $amount;
805
    $sth->execute( $borrowernumber, $acct, $itemnum, $payment, $manager_id, $payment_note );
804
806
805
    if ( C4::Context->preference("FinesLog") ) {
807
    if ( C4::Context->preference("FinesLog") ) {
806
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
808
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
807
            action            => 'create_writeoff',
809
            action            => 'create_writeoff',
808
            borrowernumber    => $borrowernumber,
810
            borrowernumber    => $borrowernumber,
809
            accountno         => $acct,
811
            accountno         => $acct,
810
            amount            => 0 - $amount,
812
            amount            => $payment,
811
            accounttype       => 'W',
813
            accounttype       => 'W',
812
            itemnumber        => $itemnum,
814
            itemnumber        => $itemnum,
813
            accountlines_paid => [ $accountlines_id ],
815
            accountlines_paid => [ $accountlines_id ],
Lines 818-824 sub WriteOffFee { Link Here
818
    UpdateStats({
820
    UpdateStats({
819
                branch => $branch,
821
                branch => $branch,
820
                type => 'writeoff',
822
                type => 'writeoff',
821
                amount => $amount,
823
                amount => $payment,
822
                borrowernumber => $borrowernumber}
824
                borrowernumber => $borrowernumber}
823
    );
825
    );
824
826
(-)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 53-63 my $branch = GetBranch( $input, GetBranches() ); Link Here
53
53
54
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
54
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
55
my $total_paid = $input->param('paid');
55
my $total_paid = $input->param('paid');
56
my $total_collected = $input->param('collected');
56
57
57
my $individual   = $input->param('pay_individual');
58
my $individual   = $input->param('pay_individual');
58
my $writeoff     = $input->param('writeoff_individual');
59
my $writeoff     = $input->param('writeoff_individual');
59
my $select_lines = $input->param('selected');
60
my $select       = ($input->param('selected') || $input->param('selected_accts'));
60
my $select       = $input->param('selected_accts');
61
my $payment_note = uri_unescape $input->param('payment_note');
61
my $payment_note = uri_unescape $input->param('payment_note');
62
my $accountno;
62
my $accountno;
63
my $accountlines_id;
63
my $accountlines_id;
Lines 91-110 if ( $individual || $writeoff ) { Link Here
91
        notify_level      => $notify_level,
91
        notify_level      => $notify_level,
92
        payment_note    => $payment_note,
92
        payment_note    => $payment_note,
93
    );
93
    );
94
} elsif ($select_lines) {
94
} elsif ($select) {
95
    $total_due = $input->param('amt');
95
    $total_due = ($input->param('amt') || $input->param('total'));
96
    $template->param(
96
    $template->param(
97
        selected_accts => $select_lines,
97
        selected_accts => $select,
98
        amt            => $total_due,
98
        amt            => $total_due,
99
        selected_accts_notes => $input->param('notes'),
99
        selected_accts_notes => $input->param('notes'),
100
    );
100
    );
101
}
101
}
102
102
103
if ( $total_paid and $total_paid ne '0.00' ) {
103
if ( $total_paid and $total_paid ne '0.00' ) {
104
    if ( $total_paid < 0 or $total_paid > $total_due ) {
104
    if ( $total_paid < 0 ) {
105
        $template->param(
105
        $template->param(
106
            error_over => 1,
106
            error_negative => 1,
107
            total_due => $total_due
107
        );
108
    }
109
    elsif (($total_collected - $total_paid) < 0) {
110
        $template->param(
111
            error_collected_less => 1,
112
        );
113
    }
114
    elsif ($total_paid > $total_due) {
115
        $template->param(
116
            amount_paid => sprintf('%.2f', $total_due),
117
            amount_collected => sprintf('%.2f', $total_collected),
118
            give_change => sprintf('%.2f',($total_collected-$total_due))
119
        );
120
    }
121
    elsif ($total_paid < $total_due and $total_collected ne $total_paid) {
122
         $template->param(
123
            amount_paid => sprintf('%.2f', $total_paid),
124
            amount_collected => sprintf('%.2f', $total_collected),
125
            give_change => sprintf('%.2f',($total_collected-$total_paid))
108
        );
126
        );
109
    } else {
127
    } else {
110
        if ($individual) {
128
        if ($individual) {
111
- 

Return to bug 11373