| 
      
            Lines 92-98
          sub recordpayment {
      
      
        Link Here
      
     | 
  
        
          | 92 | 
              my $dbh        = C4::Context->dbh;  | 
          92 | 
              my $dbh        = C4::Context->dbh;  | 
        
        
          | 93 | 
              my $newamtos   = 0;  | 
          93 | 
              my $newamtos   = 0;  | 
        
        
          | 94 | 
              my $accdata    = "";  | 
          94 | 
              my $accdata    = "";  | 
        
          
            
              | 95 | 
                  my $branch     = C4::Context->userenv->{'branch'}; | 
              95 | 
                  my $branch     = C4::Context->userenv ?  | 
            
            
               | 
               | 
              96 | 
                                       C4::Context->userenv->{'branch'} : undef; | 
            
        
          | 96 | 
              my $amountleft = $data;  | 
          97 | 
              my $amountleft = $data;  | 
        
        
          | 97 | 
              my $manager_id = 0;  | 
          98 | 
              my $manager_id = 0;  | 
        
        
          | 98 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
          99 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
        
  
    | 
      
            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,branchcode)  | 
            
            
              | 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, $branch );  | 
            
        
          | 158 | 
              $usth->finish;  | 
          159 | 
              $usth->finish;  | 
        
        
          | 159 | 
           | 
          160 | 
           | 
        
        
          | 160 | 
              UpdateStats({ | 
          161 | 
              UpdateStats({ | 
        
  
    | 
      
            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, branchcode)  | 
            
            
              | 247 | 
                                  VALUES ( ?, ?, now(), ?, ?, '', 'Pay', 0, ?, ?)"  | 
              248 | 
                                  VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?, ?)"  | 
            
        
          | 248 | 
                      );  | 
          249 | 
                      );  | 
        
          
            
              | 249 | 
                      $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); | 
              250 | 
                      my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; | 
            
            
               | 
               | 
              251 | 
                      $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note, $branchcode); | 
            
        
          | 250 | 
              }  | 
          252 | 
              }  | 
        
        
          | 251 | 
           | 
          253 | 
           | 
        
        
          | 252 | 
              if ( C4::Context->preference("FinesLog") ) { | 
          254 | 
              if ( C4::Context->preference("FinesLog") ) { | 
        
  
    | 
      
            Lines 369-378
          sub chargelostitem{
      
      
        Link Here
      
     | 
  
        
          | 369 | 
                  #  process (or person) to update it, since we don't handle any defaults for replacement prices.  | 
          371 | 
                  #  process (or person) to update it, since we don't handle any defaults for replacement prices.  | 
        
        
          | 370 | 
                  my $accountno = getnextacctno($borrowernumber);  | 
          372 | 
                  my $accountno = getnextacctno($borrowernumber);  | 
        
        
          | 371 | 
                  my $sth2=$dbh->prepare("INSERT INTO accountlines | 
          373 | 
                  my $sth2=$dbh->prepare("INSERT INTO accountlines | 
        
          
            
              | 372 | 
                      (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id)  | 
              374 | 
                      (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id,branchcode)  | 
            
            
              | 373 | 
                      VALUES (?,?,now(),?,?,'L',?,?,?)");  | 
              375 | 
                      VALUES (?,?,now(),?,?,'L',?,?,?,?)");  | 
            
            
              | 374 | 
                      $sth2->execute($borrowernumber,$accountno,$amount,  | 
              376 | 
                      my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; | 
            
            
              | 375 | 
                      $description,$amount,$itemnumber,$manager_id);  | 
              377 | 
                      $sth2->execute( $borrowernumber, $accountno, $amount, $description,  | 
            
            
               | 
               | 
              378 | 
                          $amount, $itemnumber, $manager_id, $branchcode );  | 
            
        
          | 376 | 
           | 
          379 | 
           | 
        
        
          | 377 | 
                  if ( C4::Context->preference("FinesLog") ) { | 
          380 | 
                  if ( C4::Context->preference("FinesLog") ) { | 
        
        
          | 378 | 
                      logaction("FINES", 'CREATE', $borrowernumber, Dumper({ | 
          381 | 
                      logaction("FINES", 'CREATE', $borrowernumber, Dumper({ | 
        
  
    | 
      
            Lines 421-426
          sub manualinvoice {
      
      
        Link Here
      
     | 
  
        
          | 421 | 
              my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;  | 
          424 | 
              my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;  | 
        
        
          | 422 | 
              my $manager_id = 0;  | 
          425 | 
              my $manager_id = 0;  | 
        
        
          | 423 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
          426 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
        
            
               | 
               | 
              427 | 
                  my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; | 
            
        
          | 424 | 
              my $dbh      = C4::Context->dbh;  | 
          428 | 
              my $dbh      = C4::Context->dbh;  | 
        
        
          | 425 | 
              my $notifyid = 0;  | 
          429 | 
              my $notifyid = 0;  | 
        
        
          | 426 | 
              my $insert;  | 
          430 | 
              my $insert;  | 
        
  
    | 
      
            Lines 440-455
          sub manualinvoice {
      
      
        Link Here
      
     | 
  
        
          | 440 | 
                  $desc .= ' ' . $itemnum;  | 
          444 | 
                  $desc .= ' ' . $itemnum;  | 
        
        
          | 441 | 
                  my $sth = $dbh->prepare(  | 
          445 | 
                  my $sth = $dbh->prepare(  | 
        
        
          | 442 | 
                      'INSERT INTO  accountlines  | 
          446 | 
                      'INSERT INTO  accountlines  | 
        
          
            
              | 443 | 
                                      (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id)  | 
              447 | 
                                      (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, branchcode)  | 
            
            
              | 444 | 
                      VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)');  | 
              448 | 
                      VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?,?)');  | 
            
            
              | 445 | 
                   $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr;  | 
              449 | 
                   $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $branchcode) || return $sth->errstr;  | 
            
        
          | 446 | 
            } else { | 
          450 | 
            } else { | 
        
        
          | 447 | 
              my $sth=$dbh->prepare("INSERT INTO  accountlines | 
          451 | 
              my $sth=$dbh->prepare("INSERT INTO  accountlines | 
        
          
            
              | 448 | 
                          (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)  | 
              452 | 
                          (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, branchcode)  | 
            
            
              | 449 | 
                          VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"  | 
              453 | 
                          VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?,?)"  | 
            
        
          | 450 | 
                  );  | 
          454 | 
                  );  | 
        
        
          | 451 | 
                  $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,  | 
          455 | 
                  $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,  | 
        
          
            
              | 452 | 
                          $amountleft, $notifyid, $note, $manager_id );  | 
              456 | 
                          $amountleft, $notifyid, $note, $manager_id, $branchcode );  | 
            
        
          | 453 | 
              }  | 
          457 | 
              }  | 
        
        
          | 454 | 
           | 
          458 | 
           | 
        
        
          | 455 | 
              if ( C4::Context->preference("FinesLog") ) { | 
          459 | 
              if ( C4::Context->preference("FinesLog") ) { | 
        
  
    | 
      
            Lines 599-605
          sub recordpayment_selectaccts {
      
      
        Link Here
      
     | 
  
        
          | 599 | 
              my $dbh        = C4::Context->dbh;  | 
          603 | 
              my $dbh        = C4::Context->dbh;  | 
        
        
          | 600 | 
              my $newamtos   = 0;  | 
          604 | 
              my $newamtos   = 0;  | 
        
        
          | 601 | 
              my $accdata    = q{}; | 
          605 | 
              my $accdata    = q{}; | 
        
          
            
              | 602 | 
                  my $branch     = C4::Context->userenv->{branch}; | 
              606 | 
                  my $branch     = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; | 
            
        
          | 603 | 
              my $amountleft = $amount;  | 
          607 | 
              my $amountleft = $amount;  | 
        
        
          | 604 | 
              my $manager_id = 0;  | 
          608 | 
              my $manager_id = 0;  | 
        
        
          | 605 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
          609 | 
              $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; | 
        
  
    | 
      
            Lines 654-662
          sub recordpayment_selectaccts {
      
      
        Link Here
      
     | 
  
        
          | 654 | 
           | 
          658 | 
           | 
        
        
          | 655 | 
              # create new line  | 
          659 | 
              # create new line  | 
        
        
          | 656 | 
              $sql = 'INSERT INTO accountlines ' .  | 
          660 | 
              $sql = 'INSERT INTO accountlines ' .  | 
        
          
            
              | 657 | 
                  '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note) ' .  | 
              661 | 
                  '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note,branchcode) ' .  | 
            
            
              | 658 | 
                  q|VALUES (?,?,now(),?,'','Pay',?,?,?)|;  | 
              662 | 
                  q|VALUES (?,?,now(),?,'','Pay',?,?,?,?)|;  | 
            
            
              | 659 | 
                  $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note ); | 
              663 | 
                  $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note, $branch ); | 
            
        
          | 660 | 
              UpdateStats({ | 
          664 | 
              UpdateStats({ | 
        
        
          | 661 | 
                          branch => $branch,  | 
          665 | 
                          branch => $branch,  | 
        
        
          | 662 | 
                          type => 'payment',  | 
          666 | 
                          type => 'payment',  | 
        
  
    | 
      
            Lines 700-706
          sub makepartialpayment {
      
      
        Link Here
      
     | 
  
        
          | 700 | 
                  'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);  | 
          704 | 
                  'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);  | 
        
        
          | 701 | 
              my $new_outstanding = $data->{amountoutstanding} - $amount; | 
          705 | 
              my $new_outstanding = $data->{amountoutstanding} - $amount; | 
        
        
          | 702 | 
           | 
          706 | 
           | 
        
          
            
              | 703 | 
                  my $update = 'UPDATE  accountlines SET amountoutstanding = ?  WHERE   accountlines_id = ? ';  | 
              707 | 
                  my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? ';  | 
            
        
          | 704 | 
              $dbh->do( $update, undef, $new_outstanding, $accountlines_id);  | 
          708 | 
              $dbh->do( $update, undef, $new_outstanding, $accountlines_id);  | 
        
        
          | 705 | 
           | 
          709 | 
           | 
        
        
          | 706 | 
              if ( C4::Context->preference("FinesLog") ) { | 
          710 | 
              if ( C4::Context->preference("FinesLog") ) { | 
        
  
    | 
      
            Lines 718-728
          sub makepartialpayment {
      
      
        Link Here
      
     | 
  
        
          | 718 | 
           | 
          722 | 
           | 
        
        
          | 719 | 
              # create new line  | 
          723 | 
              # create new line  | 
        
        
          | 720 | 
              my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '  | 
          724 | 
              my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '  | 
        
          
            
              | 721 | 
                  .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '  | 
              725 | 
                  .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note, branchcode) '  | 
            
            
              | 722 | 
                  . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';  | 
              726 | 
                  . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?, ?)';  | 
            
        
          | 723 | 
           | 
          727 | 
           | 
        
        
          | 724 | 
              $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,  | 
          728 | 
              $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,  | 
        
          
            
              | 725 | 
                      '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); | 
              729 | 
                      '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note, C4::Context->userenv->{'branch'}); | 
            
        
          | 726 | 
           | 
          730 | 
           | 
        
        
          | 727 | 
              UpdateStats({ | 
          731 | 
              UpdateStats({ | 
        
        
          | 728 | 
                  branch => $branch,  | 
          732 | 
                  branch => $branch,  |