Collapse All | Expand All

 Lines 72-78 Lines 113-124 Lines 144-150 Lines 165-171 patron. sub recordpayment { sub recordpayment { sub makepayment { (-)a/C4/Accounts.pm (-58 / +56 lines) 72 72 73 `Record payment by a patron. C<\$borrowernumber> is the patron's` 73 `Record payment by a patron. C<\$borrowernumber> is the patron's` 74 `borrower number. C<\$payment> is a floating-point number, giving the` 74 `borrower number. C<\$payment> is a floating-point number, giving the` 75 `amount that was paid. ` 75 `amount that was paid.` 76 76 77 `Amounts owed are paid off oldest first. That is, if the patron has a` 77 `Amounts owed are paid off oldest first. That is, if the patron has a` 78 `\$1 fine from Feb. 1, another \$1 fine from Mar. 1, and makes a payment` 78 `\$1 fine from Feb. 1, another \$1 fine from Mar. 1, and makes a payment` 113 ` \$newamtos = \$accdata->{'amountoutstanding'} - \$amountleft;` 113 ` \$newamtos = \$accdata->{'amountoutstanding'} - \$amountleft;` 114 ` \$amountleft = 0;` 114 ` \$amountleft = 0;` 115 ` }` 115 ` }` 116 ` my \$thisacct = \$accdata->{accountno};` 116 ` my \$thisacct = \$accdata->{accountlinesid};` 117 ` my \$usth = \$dbh->prepare(` 117 ` my \$usth = \$dbh->prepare(` 118 ` "UPDATE accountlines SET amountoutstanding= ?` 118 ` "UPDATE accountlines SET amountoutstanding= ?` 119 ` WHERE (borrowernumber = ?) AND (accountno=?)"` 119 ` WHERE (accountlinesid = ?)"` 120 ` );` 120 ` );` 121 ` \$usth->execute( \$newamtos, \$borrowernumber, \$thisacct );` 121 ` \$usth->execute( \$newamtos, \$thisacct );` 122 ` \$usth->finish;` 122 ` \$usth->finish;` 123 `# \$usth = \$dbh->prepare(` 123 `# \$usth = \$dbh->prepare(` 124 `# "INSERT INTO accountoffsets` 124 `# "INSERT INTO accountoffsets` 144 144 145 `=head2 makepayment` 145 `=head2 makepayment` 146 146 147 ` &makepayment(\$borrowernumber, \$acctnumber, \$amount, \$branchcode);` 147 ` &makepayment(\$accountlinesid, \$borrowernumber, \$acctnumber, \$amount, \$branchcode);` 148 148 149 `Records the fact that a patron has paid off the entire amount he or` 149 `Records the fact that a patron has paid off the entire amount he or` 150 `she owes.` 150 `she owes.` 165 ` #here we update both the accountoffsets and the account lines` 165 ` #here we update both the accountoffsets and the account lines` 166 ` #updated to check, if they are paying off a lost item, we return the item` 166 ` #updated to check, if they are paying off a lost item, we return the item` 167 ` # from their card, and put a note on the item record` 167 ` # from their card, and put a note on the item record` 168 ` my ( \$borrowernumber, \$accountno, \$amount, \$user, \$branch ) = @_;` 168 ` my ( \$accountlinesid, \$borrowernumber, \$accountno, \$amount, \$user, \$branch ) = @_;` 169 ` my \$dbh = C4::Context->dbh;` 169 ` my \$dbh = C4::Context->dbh;` 170 ` my \$manager_id = 0;` 170 ` my \$manager_id = 0;` 171 ` \$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; ` 171 ` \$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; ` 173 ` # begin transaction` 173 ` # begin transaction` 174 ` my \$nextaccntno = getnextacctno(\$borrowernumber);` 174 ` my \$nextaccntno = getnextacctno(\$borrowernumber);` 175 ` my \$newamtos = 0;` 175 ` my \$newamtos = 0;` 176 ` my \$sth =` 176 ` my \$sth = \$dbh->prepare("SELECT * FROM accountlines WHERE accountlinesid=?");` 177 ` \$dbh->prepare(` 177 ` \$sth->execute( \$accountlinesid );` 178 ` "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?");` 179 ` \$sth->execute( \$borrowernumber, \$accountno );` 180 ` my \$data = \$sth->fetchrow_hashref;` 178 ` my \$data = \$sth->fetchrow_hashref;` 181 ` \$sth->finish;` 179 ` \$sth->finish;` 182 180 185 ` \$dbh->prepare(` 183 ` \$dbh->prepare(` 186 ` "UPDATE accountlines` 184 ` "UPDATE accountlines` 187 ` SET amountoutstanding = 0, description = 'Payment,thanks'` 185 ` SET amountoutstanding = 0, description = 'Payment,thanks'` 188 ` WHERE borrowernumber = ?` 186 ` WHERE accountlinesid = ?` 189 ` AND accountno = ?` 190 ` "` 187 ` "` 191 ` );` 188 ` );` 192 ` \$udp->execute(\$borrowernumber, \$accountno );` 189 ` \$udp->execute(\$accountlinesid);` 193 ` \$udp->finish;` 190 ` \$udp->finish;` 194 ` }else{` 191 ` }else{` 195 ` my \$udp = ` 192 ` my \$udp = ` 196 ` \$dbh->prepare(` 193 ` \$dbh->prepare(` 197 ` "UPDATE accountlines` 194 ` "UPDATE accountlines` 198 ` SET amountoutstanding = 0` 195 ` SET amountoutstanding = 0` 199 ` WHERE borrowernumber = ?` 196 ` WHERE accountlinesid = ?` 200 ` AND accountno = ?` 201 ` "` 197 ` "` 202 ` );` 198 ` );` 203 ` \$udp->execute(\$borrowernumber, \$accountno );` 199 ` \$udp->execute(\$accountlinesid);` 204 ` \$udp->finish;` 200 ` \$udp->finish;` 205 201 206 ` # create new line` 202 ` # create new line` 227 ` if ( \$data->{'accounttype'} eq 'Rep' || \$data->{'accounttype'} eq 'L' ) {` 223 ` if ( \$data->{'accounttype'} eq 'Rep' || \$data->{'accounttype'} eq 'L' ) {` 228 ` C4::Circulation::ReturnLostItem( \$borrowernumber, \$data->{'itemnumber'} );` 224 ` C4::Circulation::ReturnLostItem( \$borrowernumber, \$data->{'itemnumber'} );` 229 ` }` 225 ` }` 226 ` my \$sthr = \$dbh->prepare("SELECT max(accountlinesid) AS lastinsertid FROM accountlines");` 227 ` \$sthr->execute();` 228 ` my \$datalastinsertid = \$sthr->fetchrow_hashref;` 229 ` \$sthr->finish;` 230 ` return \$datalastinsertid->{'lastinsertid'};` 230 `}` 231 `}` 231 232 232 `=head2 getnextacctno` 233 `=head2 getnextacctno` 254 255 255 `=head2 fixaccounts (removed)` 256 `=head2 fixaccounts (removed)` 256 257 257 ` &fixaccounts(\$borrowernumber, \$accountnumber, \$amount);` 258 ` &fixaccounts(\$accountlinesid, \$borrowernumber, \$accountnumber, \$amount);` 258 259 259 `#'` 260 `#'` 260 `# FIXME - I don't understand what this function does.` 261 `# FIXME - I don't understand what this function does.` 261 `sub fixaccounts {` 262 `sub fixaccounts {` 262 ` my ( \$borrowernumber, \$accountno, \$amount ) = @_;` 263 ` my ( \$accountlinesid, \$borrowernumber, \$accountno, \$amount ) = @_;` 263 ` my \$dbh = C4::Context->dbh;` 264 ` my \$dbh = C4::Context->dbh;` 264 ` my \$sth = \$dbh->prepare(` 265 ` my \$sth = \$dbh->prepare(` 265 ` "SELECT * FROM accountlines WHERE borrowernumber=?` 266 ` "SELECT * FROM accountlines WHERE accountlinesid=?"` 266 ` AND accountno=?"` 267 ` );` 267 ` );` 268 ` \$sth->execute( \$borrowernumber, \$accountno );` 268 ` \$sth->execute( \$accountlinesid );` 269 ` my \$data = \$sth->fetchrow_hashref;` 269 ` my \$data = \$sth->fetchrow_hashref;` 270 270 271 ` # FIXME - Error-checking` 271 ` # FIXME - Error-checking` 277 ` UPDATE accountlines` 277 ` UPDATE accountlines` 278 ` SET amount = '\$amount',` 278 ` SET amount = '\$amount',` 279 ` amountoutstanding = '\$outstanding'` 279 ` amountoutstanding = '\$outstanding'` 280 ` WHERE borrowernumber = \$borrowernumber` 280 ` WHERE accountlinesid = \$accountlinesid` 281 ` AND accountno = \$accountno` 282 `EOT` 281 `EOT` 283 ` # FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args.` 282 ` # FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args.` 284 `}` 283 `}` 456 ` \$newamtos = \$accdata->{'amountoutstanding'} - \$amountleft;` 455 ` \$newamtos = \$accdata->{'amountoutstanding'} - \$amountleft;` 457 ` \$amountleft = 0;` 456 ` \$amountleft = 0;` 458 ` }` 457 ` }` 459 ` my \$thisacct = \$accdata->{accountno};` 458 ` my \$thisacct = \$accdata->{accountlinesid};` 460 ` my \$usth = \$dbh->prepare(` 459 ` my \$usth = \$dbh->prepare(` 461 ` "UPDATE accountlines SET amountoutstanding= ?` 460 ` "UPDATE accountlines SET amountoutstanding= ?` 462 ` WHERE (borrowernumber = ?) AND (accountno=?)"` 461 ` WHERE (accountlinesid = ?)"` 463 ` );` 462 ` );` 464 ` \$usth->execute( \$newamtos, \$borrowernumber, \$thisacct );` 463 ` \$usth->execute( \$newamtos, \$thisacct );` 465 ` \$usth->finish;` 464 ` \$usth->finish;` 466 ` \$usth = \$dbh->prepare(` 465 ` \$usth = \$dbh->prepare(` 467 ` "INSERT INTO accountoffsets` 466 ` "INSERT INTO accountoffsets` 495 ` \$newamtos = \$accdata->{'amountoutstanding'} - \$amountleft;` 494 ` \$newamtos = \$accdata->{'amountoutstanding'} - \$amountleft;` 496 ` \$amountleft = 0;` 495 ` \$amountleft = 0;` 497 ` }` 496 ` }` 498 ` my \$thisacct = \$accdata->{accountno};` 497 ` my \$thisacct = \$accdata->{accountlinesid};` 499 ` my \$usth = \$dbh->prepare(` 498 ` my \$usth = \$dbh->prepare(` 500 ` "UPDATE accountlines SET amountoutstanding= ?` 499 ` "UPDATE accountlines SET amountoutstanding= ?` 501 ` WHERE (borrowernumber = ?) AND (accountno=?)"` 500 ` WHERE (accountlinesid = ?)"` 502 ` );` 501 ` );` 503 ` \$usth->execute( \$newamtos, \$borrowernumber, \$thisacct );` 502 ` \$usth->execute( \$newamtos, \$thisacct );` 504 ` \$usth->finish;` 503 ` \$usth->finish;` 505 ` \$usth = \$dbh->prepare(` 504 ` \$usth = \$dbh->prepare(` 506 ` "INSERT INTO accountoffsets` 505 ` "INSERT INTO accountoffsets` 561 ` }` 560 ` }` 562 561 563 ` # print \$amountleft;` 562 ` # print \$amountleft;` 564 ` my \$thisacct = \$accdata->{accountno};` 563 ` my \$thisacct = \$accdata->{accountlinesid};` 565 ` my \$usth = \$dbh->prepare(` 564 ` my \$usth = \$dbh->prepare(` 566 ` "UPDATE accountlines SET amountoutstanding= ?` 565 ` "UPDATE accountlines SET amountoutstanding= ?` 567 ` WHERE (borrowernumber = ?) AND (accountno=?)"` 566 ` WHERE (accountlinesid = ?)"` 568 ` );` 567 ` );` 569 ` \$usth->execute( \$newamtos, \$borrowernumber, \$thisacct );` 568 ` \$usth->execute( \$newamtos, \$thisacct );` 570 ` \$usth->finish;` 569 ` \$usth->finish;` 571 ` \$usth = \$dbh->prepare(` 570 ` \$usth = \$dbh->prepare(` 572 ` "INSERT INTO accountoffsets` 571 ` "INSERT INTO accountoffsets` 599 `}` 598 `}` 600 599 601 `sub ModNote {` 600 `sub ModNote {` 602 ` my ( \$borrowernumber, \$accountno, \$note ) = @_;` 601 ` my ( \$accountlinesid, \$note ) = @_;` 603 ` my \$dbh = C4::Context->dbh;` 602 ` my \$dbh = C4::Context->dbh;` 604 ` my \$sth = \$dbh->prepare('UPDATE accountlines SET note = ? WHERE borrowernumber = ? AND accountno = ?');` 603 ` my \$sth = \$dbh->prepare('UPDATE accountlines SET note = ? WHERE accountlinesid = ?');` 605 ` \$sth->execute( \$note, \$borrowernumber, \$accountno );` 604 ` \$sth->execute( \$note, \$accountlinesid );` 606 `}` 605 `}` 607 606 608 `sub getcredits {` 607 `sub getcredits {` 647 `}` 646 `}` 648 647 649 `sub ReversePayment {` 648 `sub ReversePayment {` 650 ` my ( \$borrowernumber, \$accountno ) = @_;` 649 ` my ( \$accountlinesid ) = @_;` 651 ` my \$dbh = C4::Context->dbh;` 650 ` my \$dbh = C4::Context->dbh;` 652 ` ` 651 653 ` my \$sth = \$dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE borrowernumber = ? AND accountno = ?');` 652 ` my \$sth = \$dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE accountlinesid = ?');` 654 ` \$sth->execute( \$borrowernumber, \$accountno );` 653 ` \$sth->execute( \$accountlinesid );` 655 ` my \$row = \$sth->fetchrow_hashref();` 654 ` my \$row = \$sth->fetchrow_hashref();` 656 ` my \$amount_outstanding = \$row->{'amountoutstanding'};` 655 ` my \$amount_outstanding = \$row->{'amountoutstanding'};` 657 ` ` 656 658 ` if ( \$amount_outstanding <= 0 ) {` 657 ` if ( \$amount_outstanding <= 0 ) {` 659 ` \$sth = \$dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');` 658 ` \$sth = \$dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE accountlinesid = ?');` 660 ` \$sth->execute( \$borrowernumber, \$accountno );` 659 ` \$sth->execute( \$accountlinesid );` 661 ` } else {` 660 ` } else {` 662 ` \$sth = \$dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');` 661 ` \$sth = \$dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE accountlinesid = ?');` 663 ` \$sth->execute( \$borrowernumber, \$accountno );` 662 ` \$sth->execute( \$accountlinesid );` 664 ` }` 663 ` }` 665 `}` 664 `}` 666 665 667 `=head2 recordpayment_selectaccts` 666 `=head2 recordpayment_selectaccts` 703 702 704 ` # offset transactions` 703 ` # offset transactions` 705 ` my \$sth = \$dbh->prepare('UPDATE accountlines SET amountoutstanding= ? ' .` 704 ` my \$sth = \$dbh->prepare('UPDATE accountlines SET amountoutstanding= ? ' .` 706 ` 'WHERE (borrowernumber = ?) AND (accountno=?)');` 705 ` 'WHERE accountlinesid=?');` 707 ` for my \$accdata ( @{\$rows} ) {` 706 ` for my \$accdata ( @{\$rows} ) {` 708 ` if (\$amountleft == 0) {` 707 ` if (\$amountleft == 0) {` 709 ` last;` 708 ` last;` 716 ` \$newamtos = \$accdata->{amountoutstanding} - \$amountleft;` 715 ` \$newamtos = \$accdata->{amountoutstanding} - \$amountleft;` 717 ` \$amountleft = 0;` 716 ` \$amountleft = 0;` 718 ` }` 717 ` }` 719 ` my \$thisacct = \$accdata->{accountno};` 718 ` my \$thisacct = \$accdata->{accountlinesid};` 720 ` \$sth->execute( \$newamtos, \$borrowernumber, \$thisacct );` 719 ` \$sth->execute( \$newamtos, \$thisacct );` 721 ` }` 720 ` }` 722 721 723 ` # create new line` 722 ` # create new line` 732 `# makepayment needs to be fixed to handle partials till then this separate subroutine` 731 `# makepayment needs to be fixed to handle partials till then this separate subroutine` 733 `# fills in` 732 `# fills in` 734 `sub makepartialpayment {` 733 `sub makepartialpayment {` 735 ` my ( \$borrowernumber, \$accountno, \$amount, \$user, \$branch ) = @_;` 734 ` my ( \$accountlinesid, \$borrowernumber, \$accountno, \$amount, \$user, \$branch ) = @_;` 736 ` my \$manager_id = 0;` 735 ` my \$manager_id = 0;` 737 ` \$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;` 736 ` \$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;` 738 ` if (!\$amount || \$amount < 0) {` 737 ` if (!\$amount || \$amount < 0) {` 744 ` my \$newamtos = 0;` 743 ` my \$newamtos = 0;` 745 744 746 ` my \$data = \$dbh->selectrow_hashref(` 745 ` my \$data = \$dbh->selectrow_hashref(` 747 ` 'SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?',undef,\$borrowernumber,\$accountno);` 746 ` 'SELECT * FROM accountlines WHERE accountlinesid=?',undef,\$accountlinesid);` 748 ` my \$new_outstanding = \$data->{amountoutstanding} - \$amount;` 747 ` my \$new_outstanding = \$data->{amountoutstanding} - \$amount;` 749 748 750 ` my \$update = 'UPDATE accountlines SET amountoutstanding = ? WHERE borrowernumber = ? '` 749 ` my \$update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlinesid = ? ';` 751 ` . ' AND accountno = ?';` 750 ` \$dbh->do( \$update, undef, \$new_outstanding, \$accountlinesid);` 752 ` \$dbh->do( \$update, undef, \$new_outstanding, \$borrowernumber, \$accountno);` 753 751 754 ` # create new line` 752 ` # create new line` 755 ` my \$insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '` 753 ` my \$insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '`
 Lines 1894-1900 Lines 1914-1920 Lines 1957-1965 Lines 1978-1989 sub _FixOverduesOnReturn { sub _FixOverduesOnReturn { sub _FixAccountForLostAndReturned { sub _FixAccountForLostAndReturned { (-)a/C4/Circulation.pm (-9 / +7 lines) 1894 ` return 0 unless \$data; # no warning, there's just nothing to fix` 1894 ` return 0 unless \$data; # no warning, there's just nothing to fix` 1895 1895 1896 ` my \$uquery;` 1896 ` my \$uquery;` 1897 ` my @bind = (\$borrowernumber, \$item, \$data->{'accountno'});` 1897 ` my @bind = (\$data->{'accountlinesid'});` 1898 ` if (\$exemptfine) {` 1898 ` if (\$exemptfine) {` 1899 ` \$uquery = "update accountlines set accounttype='FFOR', amountoutstanding=0";` 1899 ` \$uquery = "update accountlines set accounttype='FFOR', amountoutstanding=0";` 1900 ` if (C4::Context->preference("FinesLog")) {` 1900 ` if (C4::Context->preference("FinesLog")) {` 1914 ` } else {` 1914 ` } else {` 1915 ` \$uquery = "update accountlines set accounttype='F' ";` 1915 ` \$uquery = "update accountlines set accounttype='F' ";` 1916 ` }` 1916 ` }` 1917 ` \$uquery .= " where (borrowernumber = ?) and (itemnumber = ?) and (accountno = ?)";` 1917 ` \$uquery .= " where (accountlinesid = ?)";` 1918 ` my \$usth = \$dbh->prepare(\$uquery);` 1918 ` my \$usth = \$dbh->prepare(\$uquery);` 1919 ` return \$usth->execute(@bind);` 1919 ` return \$usth->execute(@bind);` 1920 `}` 1920 `}` 1957 ` \$amountleft = \$data->{'amountoutstanding'} - \$amount; # Um, isn't this the same as ZERO? We just tested those two things are ==` 1957 ` \$amountleft = \$data->{'amountoutstanding'} - \$amount; # Um, isn't this the same as ZERO? We just tested those two things are ==` 1958 ` }` 1958 ` }` 1959 ` my \$usth = \$dbh->prepare("UPDATE accountlines SET accounttype = 'LR',amountoutstanding='0'` 1959 ` my \$usth = \$dbh->prepare("UPDATE accountlines SET accounttype = 'LR',amountoutstanding='0'` 1960 ` WHERE (borrowernumber = ?)` 1960 ` WHERE (accountlinesid = ?)");` 1961 ` AND (itemnumber = ?) AND (accountno = ?) ");` 1961 ` \$usth->execute(\$data->{'accountlinesid'}); # We might be adjusting an account for some OTHER borrowernumber now. Not the one we passed in. ` 1962 ` \$usth->execute(\$data->{'borrowernumber'},\$itemnumber,\$acctno); # We might be adjusting an account for some OTHER borrowernumber now. Not the one we passed in. ` 1963 ` #check if any credit is left if so writeoff other accounts` 1962 ` #check if any credit is left if so writeoff other accounts` 1964 ` my \$nextaccntno = getnextacctno(\$data->{'borrowernumber'});` 1963 ` my \$nextaccntno = getnextacctno(\$data->{'borrowernumber'});` 1965 ` \$amountleft *= -1 if (\$amountleft < 0);` 1964 ` \$amountleft *= -1 if (\$amountleft < 0);` 1978 ` \$newamtos = \$accdata->{'amountoutstanding'} - \$amountleft;` 1977 ` \$newamtos = \$accdata->{'amountoutstanding'} - \$amountleft;` 1979 ` \$amountleft = 0;` 1978 ` \$amountleft = 0;` 1980 ` }` 1979 ` }` 1981 ` my \$thisacct = \$accdata->{'accountno'};` 1980 ` my \$thisacct = \$accdata->{'accountlinesid'};` 1982 ` # FIXME: move prepares outside while loop!` 1981 ` # FIXME: move prepares outside while loop!` 1983 ` my \$usth = \$dbh->prepare("UPDATE accountlines SET amountoutstanding= ?` 1982 ` my \$usth = \$dbh->prepare("UPDATE accountlines SET amountoutstanding= ?` 1984 ` WHERE (borrowernumber = ?)` 1983 ` WHERE (accountlinesid = ?)");` 1985 ` AND (accountno=?)");` 1984 ` \$usth->execute(\$newamtos,'\$thisacct'); # FIXME: '\$thisacct' is a string literal!` 1986 ` \$usth->execute(\$newamtos,\$data->{'borrowernumber'},'\$thisacct'); # FIXME: '\$thisacct' is a string literal!` 1987 ` \$usth = \$dbh->prepare("INSERT INTO accountoffsets` 1985 ` \$usth = \$dbh->prepare("INSERT INTO accountoffsets` 1988 ` (borrowernumber, accountno, offsetaccount, offsetamount)` 1986 ` (borrowernumber, accountno, offsetaccount, offsetamount)` 1989 ` VALUES` 1987 ` VALUES`
 Lines 2457-2462 Lines 2472-2477 CREATE TABLE `messages` ( -- circulation messages left via the patron's check ou CREATE TABLE `accountlines` ( (-)a/installer/data/mysql/kohastructure.sql (+2 lines) 2457 2457 2458 `DROP TABLE IF EXISTS `accountlines`;` 2458 `DROP TABLE IF EXISTS `accountlines`;` 2459 `CREATE TABLE `accountlines` (` 2459 `CREATE TABLE `accountlines` (` 2460 ` `accountlinesid` int(11) NOT NULL AUTO_INCREMENT,` 2460 ` `borrowernumber` int(11) NOT NULL default 0,` 2461 ` `borrowernumber` int(11) NOT NULL default 0,` 2461 ` `accountno` smallint(6) NOT NULL default 0,` 2462 ` `accountno` smallint(6) NOT NULL default 0,` 2462 ` `itemnumber` int(11) default NULL,` 2463 ` `itemnumber` int(11) default NULL,` 2472 ` `notify_level` int(2) NOT NULL default 0,` 2473 ` `notify_level` int(2) NOT NULL default 0,` 2473 ` `note` text NULL default NULL,` 2474 ` `note` text NULL default NULL,` 2474 ` `manager_id` int(11) NULL,` 2475 ` `manager_id` int(11) NULL,` 2476 ` PRIMARY KEY (`accountlinesid`),` 2475 ` KEY `acctsborridx` (`borrowernumber`),` 2477 ` KEY `acctsborridx` (`borrowernumber`),` 2476 ` KEY `timeidx` (`timestamp`),` 2478 ` KEY `timeidx` (`timestamp`),` 2477 ` KEY `itemnumber` (`itemnumber`),` 2479 ` KEY `itemnumber` (`itemnumber`),`
 Lines 5308-5313 if (C4::Context->preference("Version") < TransformToNum(\$DBversion)) { (-)a/installer/data/mysql/updatedatabase.pl (+7 lines) 5308 ` SetVersion (\$DBversion);` 5308 ` SetVersion (\$DBversion);` 5309 `}` 5309 `}` 5310 5310 5311 `\$DBversion = "XXX";` 5312 `if ( C4::Context->preference("Version") < TransformToNum(\$DBversion) ) {` 5313 ` \$dbh->do("ALTER TABLE `accountlines` ADD `accountlinesid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");` 5314 ` print "Upgrade to \$DBversion done (adding accountlinesid field in accountlines table)\n";` 5315 ` SetVersion(\$DBversion);` 5316 `}` 5317 5311 `=head1 FUNCTIONS` 5318 `=head1 FUNCTIONS` 5312 5319 5313 `=head2 TableExists(\$table)` 5320 `=head2 TableExists(\$table)`
 Lines 51-57 Lines 59-67 (-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-3 / +3 lines) 51 ` [% IF ( reverse_col ) %]` 51 ` [% IF ( reverse_col ) %]` 52 `
` 52 ` ` 53 ` [% IF ( account.payment ) %]` 53 ` [% IF ( account.payment ) %]` 54 ` Reverse` 54 ` Reverse` 55 ` [% ELSE %]` 55 ` [% ELSE %]` 56 `  ` 56 `  ` 57 ` [% END %]` 57 ` [% END %]` 59 ` [% END %]` 59 ` [% END %]` 60 `` 60 `` 61 ` [% IF ( account.payment ) %]` 61 ` [% IF ( account.payment ) %]` 62 ` Print` 62 ` Print` 63 ` [% ELSE %]` 63 ` [% ELSE %]` 64 ` Print` 64 ` Print` 65 ` [% END %]` 65 ` [% END %]` 66 `
` 66 ` ` 67 ` ` 67 ` `
 Lines 73-78 (-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (+1 lines) 73 ` ` 73 ` ` 74 ` ` 74 ` ` 75 ` ` 75 ` ` 76 ` ` 76 ` ` 77 ` ` 77 ` ` 78 ` ` 78 ` ` 79 ` `
 Lines 102-107 Lines 157-162 function moneyFormat(textObj) { function moneyFormat(textObj) { (-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+2 lines) 102 ` ` 102 ` ` 103 ` ` 103 ` ` 104 ` ` 104 ` ` 105 ` ` 105 ` ` 106 ` ` 106 107 107 `
` 108 `
` 157 ` ` 158 ` ` 158 ` ` 159 ` ` 159 ` ` 160 ` ` 161 ` ` 160 ` ` 162 ` ` 161 ` ` 163 ` ` 162 `
` 164 `
`
 Lines 53-59 my \$action = \$input->param('action') || ''; (-)a/members/boraccount.pl (-1 / +1 lines) 53 `my \$data=GetMember('borrowernumber' => \$borrowernumber);` 53 `my \$data=GetMember('borrowernumber' => \$borrowernumber);` 54 54 55 `if ( \$action eq 'reverse' ) {` 55 `if ( \$action eq 'reverse' ) {` 56 ` ReversePayment( \$borrowernumber, \$input->param('accountno') );` 56 ` ReversePayment( \$input->param('accountlinesid') );` 57 `}` 57 `}` 58 58 59 `if ( \$data->{'category_type'} eq 'C') {` 59 `if ( \$data->{'category_type'} eq 'C') {`
 Lines 83-93 Lines 106-111 Lines 167-172 Lines 184-190 my \$writeoff_all = \$input->param('woall'); # writeoff all fines add_accounts_to_template(); sub redirect_to_paycollect { sub writeoff_all { (-)a/members/pay.pl (-3 / +42 lines) 83 `if (\$writeoff_all) {` 83 `if (\$writeoff_all) {` 84 ` writeoff_all(@names);` 84 ` writeoff_all(@names);` 85 `} elsif (\$writeoff_item) {` 85 `} elsif (\$writeoff_item) {` 86 ` my \$accountno = \$input->param('accountno');` 86 ` my \$accountlinesid = \$input->param('accountlinesid');` 87 ` my \$itemno = \$input->param('itemnumber');` 87 ` my \$itemno = \$input->param('itemnumber');` 88 ` my \$account_type = \$input->param('accounttype');` 88 ` my \$account_type = \$input->param('accounttype');` 89 ` my \$amount = \$input->param('amountoutstanding');` 89 ` my \$amount = \$input->param('amountoutstanding');` 90 ` WriteOffFee( \$borrowernumber, \$accountno, \$itemno, \$account_type, \$amount, \$branch );` 90 ` WriteOffFee( \$borrowernumber, \$accountlinesid, \$itemno, \$account_type, \$amount, \$branch );` 91 `}` 91 `}` 92 92 93 `for (@names) {` 93 `for (@names) {` 106 106 107 `output_html_with_http_headers \$input, \$cookie, \$template->output;` 107 `output_html_with_http_headers \$input, \$cookie, \$template->output;` 108 108 109 `sub writeoff {` 110 ` my ( \$accountlinesid, \$itemnum, \$accounttype, \$amount ) = @_;` 111 ` my \$manager_id = 0;` 112 ` \$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;` 113 114 ` # if no item is attached to fine, make sure to store it as a NULL` 115 ` \$itemnum ||= undef;` 116 ` get_writeoff_sth();` 117 ` \$writeoff_sth->execute( \$accountlinesid );` 118 119 ` my \$acct = getnextacctno(\$borrowernumber);` 120 ` \$add_writeoff_sth->execute( \$borrowernumber, \$acct, \$itemnum, \$amount, \$manager_id );` 121 122 ` UpdateStats( \$branch, 'writeoff', \$amount, q{}, q{}, q{}, \$borrowernumber );` 123 124 ` return;` 125 `}` 109 126 110 `sub add_accounts_to_template {` 127 `sub add_accounts_to_template {` 111 128 167 ` \$redirect .= get_for_redirect( 'itemnumber', "itemnumber\$line_no", 0 );` 184 ` \$redirect .= get_for_redirect( 'itemnumber', "itemnumber\$line_no", 0 );` 168 ` \$redirect .= get_for_redirect( 'notify_id', "notify_id\$line_no", 0 );` 185 ` \$redirect .= get_for_redirect( 'notify_id', "notify_id\$line_no", 0 );` 169 ` \$redirect .= get_for_redirect( 'notify_level', "notify_level\$line_no", 0 );` 186 ` \$redirect .= get_for_redirect( 'notify_level', "notify_level\$line_no", 0 );` 187 ` \$redirect .= get_for_redirect( 'accountlinesid', "accountlinesid\$line_no", 0 );` 170 ` \$redirect .= '&remote_user=';` 188 ` \$redirect .= '&remote_user=';` 171 ` \$redirect .= \$user;` 189 ` \$redirect .= \$user;` 172 ` return print \$input->redirect(\$redirect);` 190 ` return print \$input->redirect(\$redirect);` 184 ` my \$itemno = \$input->param("itemnumber\$value");` 202 ` my \$itemno = \$input->param("itemnumber\$value");` 185 ` my \$amount = \$input->param("amountoutstanding\$value");` 203 ` my \$amount = \$input->param("amountoutstanding\$value");` 186 ` my \$accountno = \$input->param("accountno\$value");` 204 ` my \$accountno = \$input->param("accountno\$value");` 187 ` WriteOffFee( \$borrowernumber, \$accountno, \$itemno, \$accounttype, \$amount, \$branch );` 205 ` my \$accountlinesid = \$input->param("accountlinesid\$value");` 206 ` WriteOffFee( \$borrowernumber, \$accountlinesid, \$itemno, \$accounttype, \$amount, \$branch );` 188 ` }` 207 ` }` 189 ` }` 208 ` }` 190 209 250 ` print \$input->redirect(\$redirect);` 269 ` print \$input->redirect(\$redirect);` 251 ` return;` 270 ` return;` 252 `}` 271 `}` 272 273 `sub get_writeoff_sth {` 274 275 ` # lets prepare these statement handles only once` 276 ` if (\$writeoff_sth) {` 277 ` return;` 278 ` } else {` 279 ` my \$dbh = C4::Context->dbh;` 280 281 ` # Do we need to validate accounttype` 282 ` my \$sql = 'Update accountlines set amountoutstanding=0 '` 283 ` . 'WHERE accountlinesid=?';` 284 ` \$writeoff_sth = \$dbh->prepare(\$sql);` 285 ` my \$insert =` 286 `q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,manager_id)}` 287 ` . q{values (?,?,?,now(),?,'Writeoff','W',?)};` 288 ` \$add_writeoff_sth = \$dbh->prepare(\$insert);` 289 ` }` 290 ` return;` 291 `}`
 Lines 56-62 Lines 64-69 Lines 75-80 Lines 101-110 my \$writeoff = \$input->param('writeoff_individual'); if ( \$individual || \$writeoff ) { if ( \$individual || \$writeoff ) { if ( \$total_paid and \$total_paid ne '0.00' ) { (-)a/members/paycollect.pl (-3 / +5 lines) 56 `my \$select_lines = \$input->param('selected');` 56 `my \$select_lines = \$input->param('selected');` 57 `my \$select = \$input->param('selected_accts');` 57 `my \$select = \$input->param('selected_accts');` 58 `my \$accountno;` 58 `my \$accountno;` 59 59 `my \$accountlinesid;` 60 `if ( \$individual || \$writeoff ) {` 60 `if ( \$individual || \$writeoff ) {` 61 ` if (\$individual) {` 61 ` if (\$individual) {` 62 ` \$template->param( pay_individual => 1 );` 62 ` \$template->param( pay_individual => 1 );` 64 ` \$template->param( writeoff_individual => 1 );` 64 ` \$template->param( writeoff_individual => 1 );` 65 ` }` 65 ` }` 66 ` my \$accounttype = \$input->param('accounttype');` 66 ` my \$accounttype = \$input->param('accounttype');` 67 ` \$accountlinesid = \$input->param('accountlinesid');` 67 ` my \$amount = \$input->param('amount');` 68 ` my \$amount = \$input->param('amount');` 68 ` my \$amountoutstanding = \$input->param('amountoutstanding');` 69 ` my \$amountoutstanding = \$input->param('amountoutstanding');` 69 ` \$accountno = \$input->param('accountno');` 70 ` \$accountno = \$input->param('accountno');` 75 ` \$total_due = \$amountoutstanding;` 76 ` \$total_due = \$amountoutstanding;` 76 ` \$template->param(` 77 ` \$template->param(` 77 ` accounttype => \$accounttype,` 78 ` accounttype => \$accounttype,` 79 ` accountlinesid => \$accountlinesid,` 78 ` accountno => \$accountno,` 80 ` accountno => \$accountno,` 79 ` amount => \$amount,` 81 ` amount => \$amount,` 80 ` amountoutstanding => \$amountoutstanding,` 82 ` amountoutstanding => \$amountoutstanding,` 101 ` } else {` 103 ` } else {` 102 ` if (\$individual) {` 104 ` if (\$individual) {` 103 ` if ( \$total_paid == \$total_due ) {` 105 ` if ( \$total_paid == \$total_due ) {` 104 ` makepayment( \$borrowernumber, \$accountno, \$total_paid, \$user,` 106 ` makepayment( \$accountlinesid, \$borrowernumber, \$accountno, \$total_paid, \$user,` 105 ` \$branch );` 107 ` \$branch );` 106 ` } else {` 108 ` } else {` 107 ` makepartialpayment( \$borrowernumber, \$accountno, \$total_paid,` 109 ` makepartialpayment( \$accountlinesid, \$borrowernumber, \$accountno, \$total_paid,` 108 ` \$user, \$branch );` 110 ` \$user, \$branch );` 109 ` }` 111 ` }` 110 ` print \$input->redirect(` 112 ` print \$input->redirect(`
 Lines 48-53 my (\$template, \$loggedinuser, \$cookie) (-)a/members/printinvoice.pl (-1 / +1 lines) 48 `my \$borrowernumber=\$input->param('borrowernumber');` 48 `my \$borrowernumber=\$input->param('borrowernumber');` 49 `my \$action = \$input->param('action') || '';` 49 `my \$action = \$input->param('action') || '';` 50 `my \$accountno = \$input->param('accountno');` 50 `my \$accountno = \$input->param('accountno');` 51 `my \$accountlinesid = \$input->param('accountlinesid');` 51 52 52 `#get borrower details` 53 `#get borrower details` 53 `my \$data=GetMember('borrowernumber' => \$borrowernumber);` 54 `my \$data=GetMember('borrowernumber' => \$borrowernumber);` 54 `- `