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

(-)a/C4/Accounts.pm (-31 / +60 lines)
Lines 145-154 sub recordpayment { Link Here
145
    # create new line
145
    # create new line
146
    my $usth = $dbh->prepare(
146
    my $usth = $dbh->prepare(
147
        "INSERT INTO accountlines
147
        "INSERT INTO accountlines
148
  (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id)
148
  (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,branchcode)
149
  VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?)"
149
  VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?,?)"
150
    );
150
    );
151
    $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $manager_id );
151
152
    $usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft, $manager_id, $branch );
152
153
153
    UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno );
154
    UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno );
154
155
Lines 230-243 sub makepayment { Link Here
230
        my $payment = 0 - $amount;
231
        my $payment = 0 - $amount;
231
        $payment_note //= "";
232
        $payment_note //= "";
232
        
233
        
233
        my $ins = 
234
        my $ins = $dbh->prepare(q{
234
            $dbh->prepare( 
235
            INSERT INTO accountlines (
235
                "INSERT 
236
                borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note, branchcode
236
                    INTO accountlines (borrowernumber, accountno, date, amount, itemnumber, description, accounttype, amountoutstanding, manager_id, note)
237
            ) VALUES ( 
237
                    VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)"
238
                ?, ?, NOW(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?, ?
238
            );
239
            )
239
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note);
240
        });
240
        $ins->finish;
241
        $ins->execute(
242
            $borrowernumber, 
243
            $nextaccntno, 
244
            $payment,
245
            $data->{'itemnumber'}, 
246
            $manager_id, 
247
            $payment_note,
248
            C4::Context->userenv->{'branch'} 
249
        );
241
    }
250
    }
242
251
243
    if ( C4::Context->preference("FinesLog") ) {
252
    if ( C4::Context->preference("FinesLog") ) {
Lines 360-369 sub chargelostitem{ Link Here
360
        #  process (or person) to update it, since we don't handle any defaults for replacement prices.
369
        #  process (or person) to update it, since we don't handle any defaults for replacement prices.
361
        my $accountno = getnextacctno($borrowernumber);
370
        my $accountno = getnextacctno($borrowernumber);
362
        my $sth2=$dbh->prepare("INSERT INTO accountlines
371
        my $sth2=$dbh->prepare("INSERT INTO accountlines
363
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id)
372
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id,branchcode)
364
        VALUES (?,?,now(),?,?,'L',?,?,?)");
373
        VALUES (?,?,now(),?,?,'L',?,?,?,?)");
365
        $sth2->execute($borrowernumber,$accountno,$amount,
374
        $sth2->execute($borrowernumber,$accountno,$amount,
366
        $description,$amount,$itemnumber,$manager_id);
375
        $description,$amount,$itemnumber,$manager_id,C4::Context->userenv->{'branch'});
367
        $sth2->finish;
376
        $sth2->finish;
368
377
369
        if ( C4::Context->preference("FinesLog") ) {
378
        if ( C4::Context->preference("FinesLog") ) {
Lines 413-418 sub manualinvoice { Link Here
413
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
422
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
414
    my $manager_id = 0;
423
    my $manager_id = 0;
415
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
424
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
425
    my $branchcode = C4::Context->userenv->{'branch'};
416
    my $dbh      = C4::Context->dbh;
426
    my $dbh      = C4::Context->dbh;
417
    my $notifyid = 0;
427
    my $notifyid = 0;
418
    my $insert;
428
    my $insert;
Lines 463-478 sub manualinvoice { Link Here
463
        $desc .= ' ' . $itemnum;
473
        $desc .= ' ' . $itemnum;
464
        my $sth = $dbh->prepare(
474
        my $sth = $dbh->prepare(
465
            'INSERT INTO  accountlines
475
            'INSERT INTO  accountlines
466
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id)
476
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, branchcode)
467
        VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)');
477
        VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?,?)');
468
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr;
478
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $branchcode) || return $sth->errstr;
469
  } else {
479
  } else {
470
    my $sth=$dbh->prepare("INSERT INTO  accountlines
480
    my $sth=$dbh->prepare("INSERT INTO  accountlines
471
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)
481
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, branchcode)
472
            VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"
482
            VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?,?)"
473
        );
483
        );
474
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
484
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
475
            $amountleft, $notifyid, $note, $manager_id );
485
            $amountleft, $notifyid, $note, $manager_id, $branchcode );
476
    }
486
    }
477
487
478
    if ( C4::Context->preference("FinesLog") ) {
488
    if ( C4::Context->preference("FinesLog") ) {
Lines 848-857 sub recordpayment_selectaccts { Link Here
848
    }
858
    }
849
859
850
    # create new line
860
    # create new line
851
    $sql = 'INSERT INTO accountlines ' .
861
    $sql = q{
852
    '(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding,manager_id,note) ' .
862
        INSERT INTO accountlines ( 
853
    q|VALUES (?,?,now(),?,'Payment,thanks','Pay',?,?,?)|;
863
            borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, manager_id, note, branchcode
854
    $dbh->do($sql,{},$borrowernumber, $nextaccntno, 0 - $amount, 0 - $amountleft, $manager_id, $note );
864
        ) VALUES (
865
            ?, ?, NOW(), ?, 'Payment,thanks', 'Pay', ?, ?, ?, ?
866
        )
867
    };
868
    $dbh->do(
869
        $sql, {}, $borrowernumber,
870
        $nextaccntno, 0 - $amount, 0 - $amountleft,
871
        $manager_id,  $note,       $branch
872
    );
873
855
    UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno );
874
    UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno );
856
875
857
    if ( C4::Context->preference("FinesLog") ) {
876
    if ( C4::Context->preference("FinesLog") ) {
Lines 889-895 sub makepartialpayment { Link Here
889
        'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);
908
        'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);
890
    my $new_outstanding = $data->{amountoutstanding} - $amount;
909
    my $new_outstanding = $data->{amountoutstanding} - $amount;
891
910
892
    my $update = 'UPDATE  accountlines SET amountoutstanding = ?  WHERE   accountlines_id = ? ';
911
    my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? ';
893
    $dbh->do( $update, undef, $new_outstanding, $accountlines_id);
912
    $dbh->do( $update, undef, $new_outstanding, $accountlines_id);
894
913
895
    if ( C4::Context->preference("FinesLog") ) {
914
    if ( C4::Context->preference("FinesLog") ) {
Lines 906-917 sub makepartialpayment { Link Here
906
    }
925
    }
907
926
908
    # create new line
927
    # create new line
909
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
928
    my $insert = q{
910
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
929
        INSERT INTO accountlines (
911
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
930
            borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber, manager_id, note, branchcode
912
931
        ) VALUES (
913
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
932
            ?, ?, NOW(), ?, ?, ?, 0, ?, ?, ?, ?
914
        "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
933
        )
934
    };
935
936
    $dbh->do(
937
        $insert,         undef,
938
        $borrowernumber, $nextaccntno,
939
        $amount,         "Payment, thanks - $user",
940
        'Pay',           $data->{'itemnumber'},
941
        $manager_id,     $payment_note,
942
        C4::Context->userenv->{'branch'}
943
    );
915
944
916
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
945
    UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno );
917
946
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2636-2641 CREATE TABLE `accountlines` ( Link Here
2636
  `notify_level` int(2) NOT NULL default 0,
2636
  `notify_level` int(2) NOT NULL default 0,
2637
  `note` text NULL default NULL,
2637
  `note` text NULL default NULL,
2638
  `manager_id` int(11) NULL,
2638
  `manager_id` int(11) NULL,
2639
  `branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
2639
  PRIMARY KEY (`accountlines_id`),
2640
  PRIMARY KEY (`accountlines_id`),
2640
  KEY `acctsborridx` (`borrowernumber`),
2641
  KEY `acctsborridx` (`borrowernumber`),
2641
  KEY `timeidx` (`timestamp`),
2642
  KEY `timeidx` (`timestamp`),
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +7 lines)
Lines 7067-7072 if ( CheckVersion($DBversion) ) { Link Here
7067
    SetVersion($DBversion);
7067
    SetVersion($DBversion);
7068
}
7068
}
7069
7069
7070
$DBversion = "3.13.00.XXX";
7071
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7072
    $dbh->do("ALTER TABLE accountlines ADD branchcode VARCHAR( 10 ) NULL DEFAULT NULL AFTER manager_id");
7073
    print "Upgrade to $DBversion done (Added column branchcode to accountlines)\n";
7074
    SetVersion($DBversion);
7075
}
7076
7070
=head1 FUNCTIONS
7077
=head1 FUNCTIONS
7071
7078
7072
=head2 TableExists($table)
7079
=head2 TableExists($table)
7073
- 

Return to bug 7595