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

(-)a/C4/Accounts.pm (-22 / +25 lines)
Lines 135-144 sub recordpayment { Link Here
135
    # create new line
135
    # create new line
136
    my $usth = $dbh->prepare(
136
    my $usth = $dbh->prepare(
137
        "INSERT INTO accountlines
137
        "INSERT INTO accountlines
138
  (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id)
138
  (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,branchcode)
139
  VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)"
139
  VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?,?)"
140
    );
140
    );
141
    $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $manager_id );
141
    $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $manager_id, $branch );
142
    $usth->finish;
142
    $usth->finish;
143
    UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno );
143
    UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno );
144
    $sth->finish;
144
    $sth->finish;
Lines 207-216 sub makepayment { Link Here
207
        my $ins = 
207
        my $ins = 
208
            $dbh->prepare( 
208
            $dbh->prepare( 
209
                "INSERT 
209
                "INSERT 
210
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id)
210
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, branchcode)
211
                    VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?)"
211
                    VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)"
212
            );
212
            );
213
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id);
213
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, C4::Context->userenv->{'branch'});
214
        $ins->finish;
214
        $ins->finish;
215
    }
215
    }
216
216
Lines 309-318 sub chargelostitem{ Link Here
309
        #  process (or person) to update it, since we don't handle any defaults for replacement prices.
309
        #  process (or person) to update it, since we don't handle any defaults for replacement prices.
310
        my $accountno = getnextacctno($borrowernumber);
310
        my $accountno = getnextacctno($borrowernumber);
311
        my $sth2=$dbh->prepare("INSERT INTO accountlines
311
        my $sth2=$dbh->prepare("INSERT INTO accountlines
312
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id)
312
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id,branchcode)
313
        VALUES (?,?,now(),?,?,'L',?,?,?)");
313
        VALUES (?,?,now(),?,?,'L',?,?,?,?)");
314
        $sth2->execute($borrowernumber,$accountno,$amount,
314
        $sth2->execute($borrowernumber,$accountno,$amount,
315
        $description,$amount,$itemnumber,$manager_id);
315
        $description,$amount,$itemnumber,$manager_id,C4::Context->userenv->{'branch'});
316
        $sth2->finish;
316
        $sth2->finish;
317
    # FIXME: Log this ?
317
    # FIXME: Log this ?
318
    }
318
    }
Lines 348-353 sub manualinvoice { Link Here
348
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
348
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
349
    my $manager_id = 0;
349
    my $manager_id = 0;
350
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
350
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
351
    my $branchcode = C4::Context->userenv->{'branch'};
351
    my $dbh      = C4::Context->dbh;
352
    my $dbh      = C4::Context->dbh;
352
    my $notifyid = 0;
353
    my $notifyid = 0;
353
    my $insert;
354
    my $insert;
Lines 398-413 sub manualinvoice { Link Here
398
        $desc .= ' ' . $itemnum;
399
        $desc .= ' ' . $itemnum;
399
        my $sth = $dbh->prepare(
400
        my $sth = $dbh->prepare(
400
            'INSERT INTO  accountlines
401
            'INSERT INTO  accountlines
401
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id)
402
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, branchcode)
402
        VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)');
403
        VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?,?)');
403
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr;
404
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $branchcode) || return $sth->errstr;
404
  } else {
405
  } else {
405
    my $sth=$dbh->prepare("INSERT INTO  accountlines
406
    my $sth=$dbh->prepare("INSERT INTO  accountlines
406
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)
407
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, branchcode)
407
            VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"
408
            VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?,?)"
408
        );
409
        );
409
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
410
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
410
            $amountleft, $notifyid, $note, $manager_id );
411
            $amountleft, $notifyid, $note, $manager_id, $branchcode );
411
    }
412
    }
412
    return 0;
413
    return 0;
413
}
414
}
Lines 727-735 sub recordpayment_selectaccts { Link Here
727
728
728
    # create new line
729
    # create new line
729
    $sql = 'INSERT INTO accountlines ' .
730
    $sql = 'INSERT INTO accountlines ' .
730
    '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id) ' .
731
    '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,branchcode) ' .
731
    q|VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)|;
732
    q|VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)|;
732
    $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id );
733
    $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $branch );
733
    UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno );
734
    UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno );
734
    return;
735
    return;
735
}
736
}
Lines 752-767 sub makepartialpayment { Link Here
752
        'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);
753
        'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);
753
    my $new_outstanding = $data->{amountoutstanding} - $amount;
754
    my $new_outstanding = $data->{amountoutstanding} - $amount;
754
755
755
    my $update = 'UPDATE  accountlines SET amountoutstanding = ?  WHERE   accountlines_id = ? ';
756
    my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? ';
756
    $dbh->do( $update, undef, $new_outstanding, $accountlines_id);
757
    $dbh->do( $update, undef, $new_outstanding, $accountlines_id);
757
758
758
    # create new line
759
    # create new line
759
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
760
    my $insert = "
760
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id) '
761
        INSERT INTO accountlines (borrowernumber, accountno, date, amount,
761
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?)';
762
        description, accounttype, amountoutstanding, itemnumber, manager_id, branchcode)
763
        VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)
764
    ";
762
765
763
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
766
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
764
        "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id);
767
        "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, C4::Context->userenv->{'branch'});
765
768
766
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
769
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
767
770
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2504-2509 CREATE TABLE `accountlines` ( Link Here
2504
  `notify_level` int(2) NOT NULL default 0,
2504
  `notify_level` int(2) NOT NULL default 0,
2505
  `note` text NULL default NULL,
2505
  `note` text NULL default NULL,
2506
  `manager_id` int(11) NULL,
2506
  `manager_id` int(11) NULL,
2507
  `branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
2507
  PRIMARY KEY (`accountlines_id`),
2508
  PRIMARY KEY (`accountlines_id`),
2508
  KEY `acctsborridx` (`borrowernumber`),
2509
  KEY `acctsborridx` (`borrowernumber`),
2509
  KEY `timeidx` (`timestamp`),
2510
  KEY `timeidx` (`timestamp`),
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +7 lines)
Lines 5953-5958 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5953
}
5953
}
5954
5954
5955
5955
5956
$DBversion = "3.09.00.XXX";
5957
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5958
    $dbh->do("ALTER TABLE accountlines ADD branchcode VARCHAR( 10 ) NULL DEFAULT NULL AFTER manager_id");
5959
    print "Upgrade to $DBversion done (Added column branchcode to accountlines)\n";
5960
    SetVersion($DBversion);
5961
}
5962
5956
=head1 FUNCTIONS
5963
=head1 FUNCTIONS
5957
5964
5958
=head2 TableExists($table)
5965
=head2 TableExists($table)
5959
- 

Return to bug 7595