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

(-)a/C4/Accounts.pm (-12 / +13 lines)
Lines 26-31 use C4::Members; Link Here
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 Koha::Account;
28
use Koha::Account;
29
use C4::Koha qw(GetKohaAuthorisedValueLib);
29
30
30
use Data::Dumper qw(Dumper);
31
use Data::Dumper qw(Dumper);
31
32
Lines 90-96 sub makepayment { Link Here
90
    #here we update both the accountoffsets and the account lines
91
    #here we update both the accountoffsets and the account lines
91
    #updated to check, if they are paying off a lost item, we return the item
92
    #updated to check, if they are paying off a lost item, we return the item
92
    # from their card, and put a note on the item record
93
    # from their card, and put a note on the item record
93
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
94
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note, $paymentmode ) = @_;
94
    my $dbh = C4::Context->dbh;
95
    my $dbh = C4::Context->dbh;
95
    my $manager_id = 0;
96
    my $manager_id = 0;
96
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
97
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
Lines 129-138 sub makepayment { Link Here
129
        my $ins = 
130
        my $ins = 
130
            $dbh->prepare( 
131
            $dbh->prepare( 
131
                "INSERT 
132
                "INSERT 
132
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note)
133
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note, paymentmode)
133
                    VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?)"
134
                    VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?, ?)"
134
            );
135
            );
135
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note);
136
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode));
136
    }
137
    }
137
138
138
    if ( C4::Context->preference("FinesLog") ) {
139
    if ( C4::Context->preference("FinesLog") ) {
Lines 480-486 will be credited to the next one. Link Here
480
=cut
481
=cut
481
482
482
sub recordpayment_selectaccts {
483
sub recordpayment_selectaccts {
483
    my ( $borrowernumber, $amount, $accts, $note ) = @_;
484
    my ( $borrowernumber, $amount, $accts, $note, $paymentmode ) = @_;
484
485
485
    my $dbh        = C4::Context->dbh;
486
    my $dbh        = C4::Context->dbh;
486
    my $newamtos   = 0;
487
    my $newamtos   = 0;
Lines 540-548 sub recordpayment_selectaccts { Link Here
540
541
541
    # create new line
542
    # create new line
542
    $sql = 'INSERT INTO accountlines ' .
543
    $sql = 'INSERT INTO accountlines ' .
543
    '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note) ' .
544
    '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note,paymentmode) ' .
544
    q|VALUES (?,?,now(),?,'','Pay',?,?,?)|;
545
    q|VALUES (?,?,now(),?,'','Pay',?,?,?,?)|;
545
    $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note );
546
    $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode) );
546
    UpdateStats({
547
    UpdateStats({
547
                branch => $branch,
548
                branch => $branch,
548
                type => 'payment',
549
                type => 'payment',
Lines 570-576 sub recordpayment_selectaccts { Link Here
570
# makepayment needs to be fixed to handle partials till then this separate subroutine
571
# makepayment needs to be fixed to handle partials till then this separate subroutine
571
# fills in
572
# fills in
572
sub makepartialpayment {
573
sub makepartialpayment {
573
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
574
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note, $paymentmode ) = @_;
574
    my $manager_id = 0;
575
    my $manager_id = 0;
575
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
576
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
576
    if (!$amount || $amount < 0) {
577
    if (!$amount || $amount < 0) {
Lines 604-614 sub makepartialpayment { Link Here
604
605
605
    # create new line
606
    # create new line
606
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
607
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
607
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
608
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note, paymentmode) '
608
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
609
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?,?)';
609
610
610
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
611
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
611
        '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
612
        '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note, GetKohaAuthorisedValueLib('PAYMODE', $paymentmode));
612
613
613
    UpdateStats({
614
    UpdateStats({
614
        branch => $branch,
615
        branch => $branch,
(-)a/C4/Koha.pm (-15 / +16 lines)
Lines 1042-1062 Returns undef if no authorised value category is defined for the kohafield. Link Here
1042
=cut
1042
=cut
1043
1043
1044
sub GetKohaAuthorisedValues {
1044
sub GetKohaAuthorisedValues {
1045
  my ($kohafield,$fwcode,$opac) = @_;
1045
    my ($kohafield,$fwcode,$opac, $category) = @_;
1046
  $fwcode='' unless $fwcode;
1046
    $fwcode='' unless $fwcode;
1047
  my %values;
1047
    my %values;
1048
  my $dbh = C4::Context->dbh;
1048
    my $dbh = C4::Context->dbh;
1049
  my $avcode = GetAuthValCode($kohafield,$fwcode);
1049
    my $avcode = GetAuthValCode($kohafield,$fwcode);
1050
  if ($avcode) {  
1050
    $avcode = $category unless ($avcode);
1051
	my $sth = $dbh->prepare("select authorised_value, lib, lib_opac from authorised_values where category=? ");
1051
    if ($avcode) {
1052
   	$sth->execute($avcode);
1052
        my $sth = $dbh->prepare("select authorised_value, lib, lib_opac from authorised_values where category=? ");
1053
	while ( my ($val, $lib, $lib_opac) = $sth->fetchrow_array ) { 
1053
        $sth->execute($avcode);
1054
		$values{$val} = ($opac && $lib_opac) ? $lib_opac : $lib;
1054
        while ( my ($val, $lib, $lib_opac) = $sth->fetchrow_array ) {
1055
   	}
1055
            $values{$val} = ($opac && $lib_opac) ? $lib_opac : $lib;
1056
   	return \%values;
1056
        }
1057
  } else {
1057
        return \%values;
1058
	return;
1058
    } else {
1059
  }
1059
        return;
1060
    }
1060
}
1061
}
1061
1062
1062
=head2 GetKohaAuthorisedValuesFromField
1063
=head2 GetKohaAuthorisedValuesFromField
(-)a/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql (+6 lines)
Line 0 Link Here
1
ALTER table accountlines ADD COLUMN paymentmode TEXT NOT NULL;
2
INSERT INTO  authorised_values (category, authorised_value, lib, lib_opac) VALUES 
3
('PAYMODE','CASH','Cash', 'Cash'),
4
('PAYMODE','CC','Credit Card', 'Credit Card'),
5
('PAYMODE','DEBIG','Debit', 'Debit');
6
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2685-2690 CREATE TABLE `accountlines` ( Link Here
2685
  `notify_level` int(2) NOT NULL default 0,
2685
  `notify_level` int(2) NOT NULL default 0,
2686
  `note` text NULL default NULL,
2686
  `note` text NULL default NULL,
2687
  `manager_id` int(11) NULL,
2687
  `manager_id` int(11) NULL,
2688
  `paymentmode` text COLLATE utf8_unicode_ci NOT NULL,
2688
  PRIMARY KEY (`accountlines_id`),
2689
  PRIMARY KEY (`accountlines_id`),
2689
  KEY `acctsborridx` (`borrowernumber`),
2690
  KEY `acctsborridx` (`borrowernumber`),
2690
  KEY `timeidx` (`timestamp`),
2691
  KEY `timeidx` (`timestamp`),
(-)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 105-110 $(document).ready(function() { Link Here
105
        [%- IF account.description %], [% account.description %][% END %]
106
        [%- IF account.description %], [% account.description %][% END %]
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>
107
        &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>
107
      <td>[% account.note | html_line_break %]</td>
108
      <td>[% account.note | html_line_break %]</td>
109
      <td>[% account.paymentmode %]</td>
108
      [% IF ( account.amountcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amount %]</td>
110
      [% 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.amountoutstandingcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding %]</td>
111
      [% IF ( account.amountoutstandingcredit ) %]<td class="credit" style="text-align: right;">[% ELSE %]<td class="debit" style="text-align: right;">[% END %][% account.amountoutstanding %]</td>
110
      <td class="actions">
112
      <td class="actions">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+18 lines)
Lines 148-153 function moneyFormat(textObj) { Link Here
148
            <!-- default to paying all -->
148
            <!-- default to paying all -->
149
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payindivfine.paid)"/>
149
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payindivfine.paid)"/>
150
    </li>
150
    </li>
151
    <li>
152
        <label for="paymentmode">Payment mode: </label>
153
        <select name="paymentmode" id="paymentmode">
154
            [% FOREACH paymentmode IN paymentmodes %]
155
                <option value="[% paymentmode.authorised_value %]">[% paymentmodes.paymentmode %]</option>
156
            [% END %]
157
        </select>
158
    </li>
159
151
</ol>
160
</ol>
152
</fieldset>
161
</fieldset>
153
162
Lines 213-218 function moneyFormat(textObj) { Link Here
213
        <!-- default to paying all -->
222
        <!-- default to paying all -->
214
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payfine.paid)"/>
223
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" onchange="moneyFormat(document.payfine.paid)"/>
215
    </li>
224
    </li>
225
     <li>
226
         <label for="paymentmode">Payment mode: </label>
227
         <select name="paymentmode" id="paymentmode">
228
             [% FOREACH paymentmode IN paymentmodes %]
229
                 <option value="[% paymentmode.authorised_value %]">[% paymentmode.lib %]</option>
230
             [% END %]
231
         </select>
232
     </li>
233
216
    <li>
234
    <li>
217
        <label for="selected_accts_notes">Note: </label>
235
        <label for="selected_accts_notes">Note: </label>
218
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
236
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
(-)a/members/paycollect.pl (-4 / +15 lines)
Lines 46-51 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
46
    }
46
    }
47
);
47
);
48
48
49
# get authorised values with category of PAYMODE
50
my @paymentmodes;
51
my $paymentmodesHash = GetKohaAuthorisedValues('', '', '', 'PAYMODE');
52
foreach my $key (keys %$paymentmodesHash) {
53
    push @paymentmodes, {'authorised_value' => $key,
54
                         'lib'              => $paymentmodesHash->{$key}};
55
}
56
$template->param( paymentmodes => \@paymentmodes );
57
58
49
# get borrower details
59
# get borrower details
50
my $borrowernumber = $input->param('borrowernumber');
60
my $borrowernumber = $input->param('borrowernumber');
51
my $borrower       = GetMember( borrowernumber => $borrowernumber );
61
my $borrower       = GetMember( borrowernumber => $borrowernumber );
Lines 55-60 my $branch = C4::Context->userenv->{'branch'}; Link Here
55
65
56
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
66
my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
57
my $total_paid = $input->param('paid');
67
my $total_paid = $input->param('paid');
68
my $paymentmode = $input->param('paymentmode');
58
69
59
my $individual   = $input->param('pay_individual');
70
my $individual   = $input->param('pay_individual');
60
my $writeoff     = $input->param('writeoff_individual');
71
my $writeoff     = $input->param('writeoff_individual');
Lines 113-122 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
113
        if ($individual) {
124
        if ($individual) {
114
            if ( $total_paid == $total_due ) {
125
            if ( $total_paid == $total_due ) {
115
                makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user,
126
                makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user,
116
                    $branch, $payment_note );
127
                    $branch, $payment_note, $paymentmode );
117
            } else {
128
            } else {
118
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
129
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
119
                    $user, $branch, $payment_note );
130
                    $user, $branch, $payment_note, $paymentmode );
120
            }
131
            }
121
            print $input->redirect(
132
            print $input->redirect(
122
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
133
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
Lines 127-137 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
127
                }
138
                }
128
                my @acc = split /,/, $select;
139
                my @acc = split /,/, $select;
129
                my $note = $input->param('selected_accts_notes');
140
                my $note = $input->param('selected_accts_notes');
130
                recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note );
141
                recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note, $paymentmode );
131
            } else {
142
            } else {
132
                my $note = $input->param('selected_accts_notes');
143
                my $note = $input->param('selected_accts_notes');
133
                Koha::Account->new( { patron_id => $borrowernumber } )
144
                Koha::Account->new( { patron_id => $borrowernumber } )
134
                  ->pay( { amount => $total_paid, note => $note } );
145
                  ->pay( { amount => $total_paid, note => $note } );
146
                recordpayment( $borrowernumber, $total_paid, '', $note, $paymentmode );
135
            }
147
            }
136
148
137
            print $input->redirect(
149
            print $input->redirect(
138
- 

Return to bug 5620