| 
      
            Lines 93-99
          sub recordpayment {
      
      
        Link Here
      
     | 
  
        
          | 93 | 
              my $dbh        = C4::Context->dbh;  | 
          93 | 
              my $dbh        = C4::Context->dbh;  | 
        
        
          | 94 | 
              my $newamtos   = 0;  | 
          94 | 
              my $newamtos   = 0;  | 
        
        
          | 95 | 
              my $accdata    = "";  | 
          95 | 
              my $accdata    = "";  | 
        
          
            
              | 96 | 
                  my $branch     = C4::Context->userenv->{'branch'}; | 
              96 | 
                  my $branch = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; | 
            
        
          | 97 | 
              my $amountleft = $data;  | 
          97 | 
              my $amountleft = $data;  | 
        
        
          | 98 | 
              my $manager_id = 0;  | 
          98 | 
              my $manager_id = 0;  | 
        
        
          | 99 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
          99 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
        
  
    | 
      
            Lines 146-158
          sub recordpayment {
      
      
        Link Here
      
     | 
  
        
          | 146 | 
              # create new line  | 
          146 | 
              # create new line  | 
        
        
          | 147 | 
              my $usth = $dbh->prepare(  | 
          147 | 
              my $usth = $dbh->prepare(  | 
        
        
          | 148 | 
                  "INSERT INTO accountlines  | 
          148 | 
                  "INSERT INTO accountlines  | 
        
          
            
              | 149 | 
                (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id)  | 
              149 | 
                (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,branchcode)  | 
            
            
              | 150 | 
                VALUES (?,?,now(),?,'',?,?,?)"  | 
              150 | 
                VALUES (?,?,now(),?,'',?,?,?,?)"  | 
            
        
          | 151 | 
              );  | 
          151 | 
              );  | 
        
        
          | 152 | 
           | 
          152 | 
           | 
        
        
          | 153 | 
              my $paytype = "Pay";  | 
          153 | 
              my $paytype = "Pay";  | 
        
        
          | 154 | 
              $paytype .= $sip_paytype if defined $sip_paytype;  | 
          154 | 
              $paytype .= $sip_paytype if defined $sip_paytype;  | 
        
          
            
              | 155 | 
                  $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $paytype, 0 - $amountleft, $manager_id );  | 
              155 | 
                  $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, $paytype, 0 - $amountleft, $manager_id, $branch );  | 
            
        
          | 156 | 
              $usth->finish;  | 
          156 | 
              $usth->finish;  | 
        
        
          | 157 | 
           | 
          157 | 
           | 
        
        
          | 158 | 
              UpdateStats({ | 
          158 | 
              UpdateStats({ | 
        
  
    | 
      
            Lines 241-250
          sub makepayment {
      
      
        Link Here
      
     | 
  
        
          | 241 | 
                  my $ins =   | 
          241 | 
                  my $ins =   | 
        
        
          | 242 | 
                      $dbh->prepare(   | 
          242 | 
                      $dbh->prepare(   | 
        
        
          | 243 | 
                          "INSERT   | 
          243 | 
                          "INSERT   | 
        
          
            
              | 244 | 
                                  INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note)  | 
              244 | 
                                  INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note, branchcode)  | 
            
            
              | 245 | 
                                  VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?)"  | 
              245 | 
                                  VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?, ?)"  | 
            
        
          | 246 | 
                      );  | 
          246 | 
                      );  | 
        
          
            
              | 247 | 
                      $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); | 
              247 | 
                      my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; | 
            
            
               | 
               | 
              248 | 
                      $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note, $branchcode); | 
            
        
          | 248 | 
              }  | 
          249 | 
              }  | 
        
        
          | 249 | 
           | 
          250 | 
           | 
        
        
          | 250 | 
              if ( C4::Context->preference("FinesLog") ) { | 
          251 | 
              if ( C4::Context->preference("FinesLog") ) { | 
        
  
    | 
      
            Lines 367-376
          sub chargelostitem{
      
      
        Link Here
      
     | 
  
        
          | 367 | 
                  #  process (or person) to update it, since we don't handle any defaults for replacement prices.  | 
          368 | 
                  #  process (or person) to update it, since we don't handle any defaults for replacement prices.  | 
        
        
          | 368 | 
                  my $accountno = getnextacctno($borrowernumber);  | 
          369 | 
                  my $accountno = getnextacctno($borrowernumber);  | 
        
        
          | 369 | 
                  my $sth2=$dbh->prepare("INSERT INTO accountlines | 
          370 | 
                  my $sth2=$dbh->prepare("INSERT INTO accountlines | 
        
          
            
              | 370 | 
                      (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id)  | 
              371 | 
                      (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id,branchcode)  | 
            
            
              | 371 | 
                      VALUES (?,?,now(),?,?,'L',?,?,?)");  | 
              372 | 
                      VALUES (?,?,now(),?,?,'L',?,?,?,?)");  | 
            
            
              | 372 | 
                      $sth2->execute($borrowernumber,$accountno,$amount,  | 
              373 | 
                      my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; | 
            
            
              | 373 | 
                      $description,$amount,$itemnumber,$manager_id);  | 
              374 | 
                      $sth2->execute( $borrowernumber, $accountno, $amount, $description,  | 
            
            
               | 
               | 
              375 | 
                          $amount, $itemnumber, $manager_id, $branchcode );  | 
            
        
          | 374 | 
           | 
          376 | 
           | 
        
        
          | 375 | 
                  if ( C4::Context->preference("FinesLog") ) { | 
          377 | 
                  if ( C4::Context->preference("FinesLog") ) { | 
        
        
          | 376 | 
                      logaction("FINES", 'CREATE', $borrowernumber, Dumper({ | 
          378 | 
                      logaction("FINES", 'CREATE', $borrowernumber, Dumper({ | 
        
  
    | 
      
            Lines 419-424
          sub manualinvoice {
      
      
        Link Here
      
     | 
  
        
          | 419 | 
              my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;  | 
          421 | 
              my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;  | 
        
        
          | 420 | 
              my $manager_id = 0;  | 
          422 | 
              my $manager_id = 0;  | 
        
        
          | 421 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
          423 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
        
            
               | 
               | 
              424 | 
                  my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; | 
            
        
          | 422 | 
              my $dbh      = C4::Context->dbh;  | 
          425 | 
              my $dbh      = C4::Context->dbh;  | 
        
        
          | 423 | 
              my $notifyid = 0;  | 
          426 | 
              my $notifyid = 0;  | 
        
        
          | 424 | 
              my $insert;  | 
          427 | 
              my $insert;  | 
        
  
    | 
      
            Lines 438-453
          sub manualinvoice {
      
      
        Link Here
      
     | 
  
        
          | 438 | 
                  $desc .= ' ' . $itemnum;  | 
          441 | 
                  $desc .= ' ' . $itemnum;  | 
        
        
          | 439 | 
                  my $sth = $dbh->prepare(  | 
          442 | 
                  my $sth = $dbh->prepare(  | 
        
        
          | 440 | 
                      'INSERT INTO  accountlines  | 
          443 | 
                      'INSERT INTO  accountlines  | 
        
          
            
              | 441 | 
                                      (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id)  | 
              444 | 
                                      (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, branchcode)  | 
            
            
              | 442 | 
                      VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)');  | 
              445 | 
                      VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?,?)');  | 
            
            
              | 443 | 
                   $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr;  | 
              446 | 
                   $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $branchcode) || return $sth->errstr;  | 
            
        
          | 444 | 
            } else { | 
          447 | 
            } else { | 
        
        
          | 445 | 
              my $sth=$dbh->prepare("INSERT INTO  accountlines | 
          448 | 
              my $sth=$dbh->prepare("INSERT INTO  accountlines | 
        
          
            
              | 446 | 
                          (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)  | 
              449 | 
                          (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, branchcode)  | 
            
            
              | 447 | 
                          VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"  | 
              450 | 
                          VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?,?)"  | 
            
        
          | 448 | 
                  );  | 
          451 | 
                  );  | 
        
        
          | 449 | 
                  $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,  | 
          452 | 
                  $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,  | 
        
          
            
              | 450 | 
                          $amountleft, $notifyid, $note, $manager_id );  | 
              453 | 
                          $amountleft, $notifyid, $note, $manager_id, $branchcode );  | 
            
        
          | 451 | 
              }  | 
          454 | 
              }  | 
        
        
          | 452 | 
           | 
          455 | 
           | 
        
        
          | 453 | 
              if ( C4::Context->preference("FinesLog") ) { | 
          456 | 
              if ( C4::Context->preference("FinesLog") ) { | 
        
  
    | 
      
            Lines 597-603
          sub recordpayment_selectaccts {
      
      
        Link Here
      
     | 
  
        
          | 597 | 
              my $dbh        = C4::Context->dbh;  | 
          600 | 
              my $dbh        = C4::Context->dbh;  | 
        
        
          | 598 | 
              my $newamtos   = 0;  | 
          601 | 
              my $newamtos   = 0;  | 
        
        
          | 599 | 
              my $accdata    = q{}; | 
          602 | 
              my $accdata    = q{}; | 
        
          
            
              | 600 | 
                  my $branch     = C4::Context->userenv->{branch}; | 
              603 | 
                  my $branch = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; | 
            
        
          | 601 | 
              my $amountleft = $amount;  | 
          604 | 
              my $amountleft = $amount;  | 
        
        
          | 602 | 
              my $manager_id = 0;  | 
          605 | 
              my $manager_id = 0;  | 
        
        
          | 603 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
          606 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
        
  
    | 
      
            Lines 652-660
          sub recordpayment_selectaccts {
      
      
        Link Here
      
     | 
  
        
          | 652 | 
           | 
          655 | 
           | 
        
        
          | 653 | 
              # create new line  | 
          656 | 
              # create new line  | 
        
        
          | 654 | 
              $sql = 'INSERT INTO accountlines ' .  | 
          657 | 
              $sql = 'INSERT INTO accountlines ' .  | 
        
          
            
              | 655 | 
                  '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note) ' .  | 
              658 | 
                  '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note, branchcode) ' .  | 
            
            
              | 656 | 
                  q|VALUES (?,?,now(),?,'','Pay',?,?,?)|;  | 
              659 | 
                  q|VALUES (?,?,now(),?,'','Pay',?,?,?,?)|;  | 
            
            
              | 657 | 
                  $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, $branch ); | 
            
        
          | 658 | 
              UpdateStats({ | 
          661 | 
              UpdateStats({ | 
        
        
          | 659 | 
                          branch => $branch,  | 
          662 | 
                          branch => $branch,  | 
        
        
          | 660 | 
                          type => 'payment',  | 
          663 | 
                          type => 'payment',  | 
        
  
    | 
      
            Lines 698-704
          sub makepartialpayment {
      
      
        Link Here
      
     | 
  
        
          | 698 | 
                  'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);  | 
          701 | 
                  'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);  | 
        
        
          | 699 | 
              my $new_outstanding = $data->{amountoutstanding} - $amount; | 
          702 | 
              my $new_outstanding = $data->{amountoutstanding} - $amount; | 
        
        
          | 700 | 
           | 
          703 | 
           | 
        
          
            
              | 701 | 
                  my $update = 'UPDATE  accountlines SET amountoutstanding = ?  WHERE   accountlines_id = ? ';  | 
              704 | 
                  my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? ';  | 
            
        
          | 702 | 
              $dbh->do( $update, undef, $new_outstanding, $accountlines_id);  | 
          705 | 
              $dbh->do( $update, undef, $new_outstanding, $accountlines_id);  | 
        
        
          | 703 | 
           | 
          706 | 
           | 
        
        
          | 704 | 
              if ( C4::Context->preference("FinesLog") ) { | 
          707 | 
              if ( C4::Context->preference("FinesLog") ) { | 
        
  
    | 
      
            Lines 715-726
          sub makepartialpayment {
      
      
        Link Here
      
     | 
  
        
          | 715 | 
              }  | 
          718 | 
              }  | 
        
        
          | 716 | 
           | 
          719 | 
           | 
        
        
          | 717 | 
              # create new line  | 
          720 | 
              # create new line  | 
        
          
            
              | 718 | 
                  my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '  | 
              721 | 
                  my $insert = q{ | 
            
            
              | 719 | 
                  .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '  | 
              722 | 
                      INSERT INTO accountlines (  | 
            
            
              | 720 | 
                  . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';  | 
              723 | 
                          borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber, manager_id, note, branchcode  | 
            
            
              | 721 | 
               | 
              724 | 
                      ) VALUES (  | 
            
            
              | 722 | 
                  $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,  | 
              725 | 
                          ?, ?, NOW(), ?, ?, ?, 0, ?, ?, ?, ?  | 
            
            
              | 723 | 
                      "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); | 
              726 | 
                      )  | 
            
            
               | 
               | 
              727 | 
                  };  | 
            
            
              | 728 | 
               | 
            
            
              | 729 | 
                  $dbh->do(  | 
            
            
              | 730 | 
                      $insert,         undef,  | 
            
            
              | 731 | 
                      $borrowernumber, $nextaccntno,  | 
            
            
              | 732 | 
                      $amount,         "Payment, thanks - $user",  | 
            
            
              | 733 | 
                      'Pay',           $data->{'itemnumber'}, | 
            
            
              | 734 | 
                      $manager_id,     $payment_note,  | 
            
            
              | 735 | 
                      C4::Context->userenv->{'branch'} | 
            
            
              | 736 | 
                  );  | 
            
        
          | 724 | 
           | 
          737 | 
           | 
        
        
          | 725 | 
              UpdateStats({ | 
          738 | 
              UpdateStats({ | 
        
        
          | 726 | 
                          branch => $user,  | 
          739 | 
                          branch => $user,  |