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

(-)a/C4/Accounts.pm (-16 / +17 lines)
Lines 25-30 use C4::Stats; Link Here
25
use C4::Members;
25
use C4::Members;
26
use C4::Circulation qw(ReturnLostItem);
26
use C4::Circulation qw(ReturnLostItem);
27
use C4::Log qw(logaction);
27
use C4::Log qw(logaction);
28
use C4::Koha qw(GetKohaAuthorisedValueLib);
28
29
29
use Data::Dumper qw(Dumper);
30
use Data::Dumper qw(Dumper);
30
31
Lines 88-94 will be credited to the next one. Link Here
88
sub recordpayment {
89
sub recordpayment {
89
90
90
    #here we update the account lines
91
    #here we update the account lines
91
    my ( $borrowernumber, $data, $sip_paytype, $payment_note ) = @_;
92
    my ( $borrowernumber, $data, $sip_paytype, $payment_note, $paymentmode ) = @_;
92
    my $dbh        = C4::Context->dbh;
93
    my $dbh        = C4::Context->dbh;
93
    my $newamtos   = 0;
94
    my $newamtos   = 0;
94
    my $accdata    = "";
95
    my $accdata    = "";
Lines 148-160 sub recordpayment { Link Here
148
    # create new line
149
    # create new line
149
    my $usth = $dbh->prepare(
150
    my $usth = $dbh->prepare(
150
        "INSERT INTO accountlines
151
        "INSERT INTO accountlines
151
  (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id, note)
152
  (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id, note, paymentmode)
152
  VALUES (?,?,now(),?,'',?,?,?,?)"
153
  VALUES (?,?,now(),?,'',?,?,?,?,?)"
153
    );
154
    );
154
155
155
    my $paytype = "Pay";
156
    my $paytype = "Pay";
156
    $paytype .= $sip_paytype if defined $sip_paytype;
157
    $paytype .= $sip_paytype if defined $sip_paytype;
157
    $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $paytype, 0 - $amountleft, $manager_id, $payment_note );
158
    $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $paytype, 0 - $amountleft, $manager_id, $payment_note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode) );
158
    $usth->finish;
159
    $usth->finish;
159
160
160
    UpdateStats({
161
    UpdateStats({
Lines 204-210 sub makepayment { Link Here
204
    #here we update both the accountoffsets and the account lines
205
    #here we update both the accountoffsets and the account lines
205
    #updated to check, if they are paying off a lost item, we return the item
206
    #updated to check, if they are paying off a lost item, we return the item
206
    # from their card, and put a note on the item record
207
    # from their card, and put a note on the item record
207
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
208
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note, $paymentmode ) = @_;
208
    my $dbh = C4::Context->dbh;
209
    my $dbh = C4::Context->dbh;
209
    my $manager_id = 0;
210
    my $manager_id = 0;
210
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
211
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
Lines 243-252 sub makepayment { Link Here
243
        my $ins = 
244
        my $ins = 
244
            $dbh->prepare( 
245
            $dbh->prepare( 
245
                "INSERT 
246
                "INSERT 
246
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note)
247
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note, paymentmode)
247
                    VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?)"
248
                    VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?, ?)"
248
            );
249
            );
249
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note);
250
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode));
250
    }
251
    }
251
252
252
    if ( C4::Context->preference("FinesLog") ) {
253
    if ( C4::Context->preference("FinesLog") ) {
Lines 594-600 will be credited to the next one. Link Here
594
=cut
595
=cut
595
596
596
sub recordpayment_selectaccts {
597
sub recordpayment_selectaccts {
597
    my ( $borrowernumber, $amount, $accts, $note ) = @_;
598
    my ( $borrowernumber, $amount, $accts, $note, $paymentmode ) = @_;
598
599
599
    my $dbh        = C4::Context->dbh;
600
    my $dbh        = C4::Context->dbh;
600
    my $newamtos   = 0;
601
    my $newamtos   = 0;
Lines 654-662 sub recordpayment_selectaccts { Link Here
654
655
655
    # create new line
656
    # create new line
656
    $sql = 'INSERT INTO accountlines ' .
657
    $sql = 'INSERT INTO accountlines ' .
657
    '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note) ' .
658
    '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note,paymentmode) ' .
658
    q|VALUES (?,?,now(),?,'','Pay',?,?,?)|;
659
    q|VALUES (?,?,now(),?,'','Pay',?,?,?,?)|;
659
    $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note );
660
    $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode) );
660
    UpdateStats({
661
    UpdateStats({
661
                branch => $branch,
662
                branch => $branch,
662
                type => 'payment',
663
                type => 'payment',
Lines 684-690 sub recordpayment_selectaccts { Link Here
684
# makepayment needs to be fixed to handle partials till then this separate subroutine
685
# makepayment needs to be fixed to handle partials till then this separate subroutine
685
# fills in
686
# fills in
686
sub makepartialpayment {
687
sub makepartialpayment {
687
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
688
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note, $paymentmode ) = @_;
688
    my $manager_id = 0;
689
    my $manager_id = 0;
689
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
690
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
690
    if (!$amount || $amount < 0) {
691
    if (!$amount || $amount < 0) {
Lines 718-728 sub makepartialpayment { Link Here
718
719
719
    # create new line
720
    # create new line
720
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
721
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
721
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
722
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note, paymentmode) '
722
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
723
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?,?)';
723
724
724
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
725
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
725
        '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
726
        '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode));
726
727
727
    UpdateStats({
728
    UpdateStats({
728
        branch => $branch,
729
        branch => $branch,
(-)a/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.perl (+14 lines)
Line 0 Link Here
1
#! /usr/bin/perl
2
3
use strict;
4
use warnings;
5
use C4::Context;
6
my $dbh=C4::Context->dbh;
7
8
### Payment mode
9
10
$dbh->do("alter table accountlines add column paymentmode text not null");
11
$dbh->do("insert into authorised_values (category, authorised_value, lib, lib_opac) values('PAYMODE','CASH','Cash', 'Cash')");
12
$dbh->do("insert into authorised_values (category, authorised_value, lib, lib_opac) values('PAYMODE','CC','Credit Card', 'Credit Card')");
13
$dbh->do("insert into authorised_values (category, authorised_value, lib, lib_opac) values('PAYMODE','DEBIG','Debit', 'Debit')");
14
print "bug5620 - add mode of payment";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (+2 lines)
Lines 64-69 $(document).ready(function() { Link Here
64
          <th class="title-string">Date</th>
64
          <th class="title-string">Date</th>
65
          <th>Description of charges</th>
65
          <th>Description of charges</th>
66
          <th>Note</th>
66
          <th>Note</th>
67
          <th>Payment mode</th>
67
          <th>Amount</th>
68
          <th>Amount</th>
68
          <th>Outstanding</th>
69
          <th>Outstanding</th>
69
          [% IF ( reverse_col ) %]
70
          [% IF ( reverse_col ) %]
Lines 104-109 $(document).ready(function() { Link Here
104
        [%- IF account.description %], [% account.description %][% END %]
105
        [%- IF account.description %], [% account.description %][% END %]
105
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.title |html %]</a>[% END %]</td>
106
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.title |html %]</a>[% END %]</td>
106
      <td>[% account.note | html_line_break %]</td>
107
      <td>[% account.note | html_line_break %]</td>
108
      <td>[% account.paymentmode %]</td>
107
      [% IF ( account.amountcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount %]</td>
109
      [% IF ( account.amountcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount %]</td>
108
      [% IF ( account.amountoutstandingcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding %]</td>
110
      [% IF ( account.amountoutstandingcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding %]</td>
109
      <td class="actions">
111
      <td class="actions">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+18 lines)
Lines 147-152 function moneyFormat(textObj) { Link Here
147
            <!-- default to paying all -->
147
            <!-- default to paying all -->
148
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payindivfine.paid)"/>
148
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payindivfine.paid)"/>
149
    </li>
149
    </li>
150
    <li>
151
        <label for="paymentmode">Payment mode: </label>
152
        <select name="paymentmode" id="paymentmode">
153
            [% FOREACH paymentmode IN paymentmodes %]
154
                <option value="[% paymentmode.authorised_value %]">[% paymentmode.lib %]</option>
155
            [% END %]
156
        </select>
157
    </li>
158
150
</ol>
159
</ol>
151
</fieldset>
160
</fieldset>
152
161
Lines 212-217 function moneyFormat(textObj) { Link Here
212
        <!-- default to paying all -->
221
        <!-- default to paying all -->
213
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payfine.paid)"/>
222
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payfine.paid)"/>
214
    </li>
223
    </li>
224
     <li>
225
         <label for="paymentmode">Payment mode: </label>
226
         <select name="paymentmode" id="paymentmode">
227
             [% FOREACH paymentmode IN paymentmodes %]
228
                 <option value="[% paymentmode.authorised_value %]">[% paymentmode.lib %]</option>
229
             [% END %]
230
         </select>
231
     </li>
232
215
    <li>
233
    <li>
216
        <label for="selected_accts_notes">Note: </label>
234
        <label for="selected_accts_notes">Note: </label>
217
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
235
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
(-)a/members/paycollect.pl (-5 / +16 lines)
Lines 44-49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
44
    }
44
    }
45
);
45
);
46
46
47
# get authorised values with category of PAYMODE
48
my @paymentmodes;
49
my $dbh = C4::Context->dbh;
50
my $sth = $dbh->prepare('SELECT * FROM authorised_values WHERE category = "PAYMODE"');
51
$sth->execute();
52
while ( my $row = $sth->fetchrow_hashref() ) {
53
    push @paymentmodes, $row;
54
}
55
$template->param( paymentmodes => \@paymentmodes );
56
57
47
# get borrower details
58
# get borrower details
48
my $borrowernumber = $input->param('borrowernumber');
59
my $borrowernumber = $input->param('borrowernumber');
49
my $borrower       = GetMember( borrowernumber => $borrowernumber );
60
my $borrower       = GetMember( borrowernumber => $borrowernumber );
Lines 53-58 my $branch = C4::Context->userenv->{'branch'}; Link Here
53
64
54
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
65
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
55
my $total_paid = $input->param('paid');
66
my $total_paid = $input->param('paid');
67
my $paymentmode = $input->param('paymentmode');
56
68
57
my $individual   = $input->param('pay_individual');
69
my $individual   = $input->param('pay_individual');
58
my $writeoff     = $input->param('writeoff_individual');
70
my $writeoff     = $input->param('writeoff_individual');
Lines 110-119 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
110
        if ($individual) {
122
        if ($individual) {
111
            if ( $total_paid == $total_due ) {
123
            if ( $total_paid == $total_due ) {
112
                makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user,
124
                makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user,
113
                    $branch, $payment_note );
125
                    $branch, $payment_note, $paymentmode );
114
            } else {
126
            } else {
115
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
127
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
116
                    $user, $branch, $payment_note );
128
                    $user, $branch, $payment_note, $paymentmode );
117
            }
129
            }
118
            print $input->redirect(
130
            print $input->redirect(
119
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
131
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
Lines 124-133 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
124
                }
136
                }
125
                my @acc = split /,/, $select;
137
                my @acc = split /,/, $select;
126
                my $note = $input->param('selected_accts_notes');
138
                my $note = $input->param('selected_accts_notes');
127
                recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note );
139
                recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note, $paymentmode );
128
            } else {
140
            } else {
129
                my $note = $input->param('selected_accts_notes');
141
                my $note = $input->param('selected_accts_notes');
130
                recordpayment( $borrowernumber, $total_paid, '', $note );
142
                recordpayment( $borrowernumber, $total_paid, '', $note, $paymentmode );
131
            }
143
            }
132
144
133
# recordpayment does not return success or failure so lets redisplay the boraccount
145
# recordpayment does not return success or failure so lets redisplay the boraccount
134
- 

Return to bug 5620