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

(-)a/C4/Accounts.pm (-22 / +51 lines)
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
        $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note,  C4::Context->userenv->{'branch'});
248
    }
248
    }
249
249
250
    if ( C4::Context->preference("FinesLog") ) {
250
    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.
367
        #  process (or person) to update it, since we don't handle any defaults for replacement prices.
368
        my $accountno = getnextacctno($borrowernumber);
368
        my $accountno = getnextacctno($borrowernumber);
369
        my $sth2=$dbh->prepare("INSERT INTO accountlines
369
        my $sth2=$dbh->prepare("INSERT INTO accountlines
370
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id)
370
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id,branchcode)
371
        VALUES (?,?,now(),?,?,'L',?,?,?)");
371
        VALUES (?,?,now(),?,?,'L',?,?,?,?)");
372
        $sth2->execute($borrowernumber,$accountno,$amount,
372
        my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
373
        $description,$amount,$itemnumber,$manager_id);
373
        $sth2->execute( $borrowernumber, $accountno, $amount, $description,
374
            $amount, $itemnumber, $manager_id, $branchcode );
374
375
375
        if ( C4::Context->preference("FinesLog") ) {
376
        if ( C4::Context->preference("FinesLog") ) {
376
            logaction("FINES", 'CREATE', $borrowernumber, Dumper({
377
            logaction("FINES", 'CREATE', $borrowernumber, Dumper({
Lines 419-424 sub manualinvoice { Link Here
419
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
420
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
420
    my $manager_id = 0;
421
    my $manager_id = 0;
421
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
422
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
423
    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
422
    my $dbh      = C4::Context->dbh;
424
    my $dbh      = C4::Context->dbh;
423
    my $notifyid = 0;
425
    my $notifyid = 0;
424
    my $insert;
426
    my $insert;
Lines 438-453 sub manualinvoice { Link Here
438
        $desc .= ' ' . $itemnum;
440
        $desc .= ' ' . $itemnum;
439
        my $sth = $dbh->prepare(
441
        my $sth = $dbh->prepare(
440
            'INSERT INTO  accountlines
442
            'INSERT INTO  accountlines
441
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id)
443
                        (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, branchcode)
442
        VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)');
444
        VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?,?)');
443
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr;
445
     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id, $branchcode) || return $sth->errstr;
444
  } else {
446
  } else {
445
    my $sth=$dbh->prepare("INSERT INTO  accountlines
447
    my $sth=$dbh->prepare("INSERT INTO  accountlines
446
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)
448
            (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, branchcode)
447
            VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"
449
            VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?,?)"
448
        );
450
        );
449
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
451
        $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
450
            $amountleft, $notifyid, $note, $manager_id );
452
            $amountleft, $notifyid, $note, $manager_id, $branchcode );
451
    }
453
    }
452
454
453
    if ( C4::Context->preference("FinesLog") ) {
455
    if ( C4::Context->preference("FinesLog") ) {
Lines 651-656 sub recordpayment_selectaccts { Link Here
651
    }
653
    }
652
654
653
    # create new line
655
    # create new line
656
<<<<<<< HEAD
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) ' .
656
    q|VALUES (?,?,now(),?,'','Pay',?,?,?)|;
659
    q|VALUES (?,?,now(),?,'','Pay',?,?,?)|;
Lines 662-667 sub recordpayment_selectaccts { Link Here
662
                borrowernumber => $borrowernumber,
665
                borrowernumber => $borrowernumber,
663
                accountno => $nextaccntno}
666
                accountno => $nextaccntno}
664
    );
667
    );
668
=======
669
    $sql = q{
670
        INSERT INTO accountlines (
671
            borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, manager_id, note, branchcode
672
        ) VALUES (
673
            ?, ?, NOW(), ?, 'Payment,thanks', 'Pay', ?, ?, ?, ?
674
        )
675
    };
676
    $dbh->do(
677
        $sql, {}, $borrowernumber,
678
        $nextaccntno, 0 - $amount, 0 - $amountleft,
679
        $manager_id,  $note,       $branch
680
    );
681
682
    UpdateStats( $branch, 'payment', $amount, '', '', '', $borrowernumber, $nextaccntno );
683
>>>>>>> Bug 7595 - Add branchcode to accountlines
665
684
666
    if ( C4::Context->preference("FinesLog") ) {
685
    if ( C4::Context->preference("FinesLog") ) {
667
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
686
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
Lines 698-704 sub makepartialpayment { Link Here
698
        'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);
717
        'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);
699
    my $new_outstanding = $data->{amountoutstanding} - $amount;
718
    my $new_outstanding = $data->{amountoutstanding} - $amount;
700
719
701
    my $update = 'UPDATE  accountlines SET amountoutstanding = ?  WHERE   accountlines_id = ? ';
720
    my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? ';
702
    $dbh->do( $update, undef, $new_outstanding, $accountlines_id);
721
    $dbh->do( $update, undef, $new_outstanding, $accountlines_id);
703
722
704
    if ( C4::Context->preference("FinesLog") ) {
723
    if ( C4::Context->preference("FinesLog") ) {
Lines 715-726 sub makepartialpayment { Link Here
715
    }
734
    }
716
735
717
    # create new line
736
    # create new line
718
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
737
    my $insert = q{
719
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
738
        INSERT INTO accountlines (
720
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
739
            borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber, manager_id, note, branchcode
721
740
        ) VALUES (
722
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, $amount,
741
            ?, ?, NOW(), ?, ?, ?, 0, ?, ?, ?, ?
723
        "Payment, thanks - $user", 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
742
        )
743
    };
744
745
    $dbh->do(
746
        $insert,         undef,
747
        $borrowernumber, $nextaccntno,
748
        $amount,         "Payment, thanks - $user",
749
        'Pay',           $data->{'itemnumber'},
750
        $manager_id,     $payment_note,
751
        C4::Context->userenv->{'branch'}
752
    );
724
753
725
    UpdateStats({
754
    UpdateStats({
726
                branch => $user,
755
                branch => $user,
(-)a/C4/Circulation.pm (-9 / +9 lines)
Lines 2286-2294 sub _FixAccountForLostAndReturned { Link Here
2286
    $amountleft *= -1 if ($amountleft > 0);
2286
    $amountleft *= -1 if ($amountleft > 0);
2287
    my $desc = "Item Returned " . $item_id;
2287
    my $desc = "Item Returned " . $item_id;
2288
    $usth = $dbh->prepare("INSERT INTO accountlines
2288
    $usth = $dbh->prepare("INSERT INTO accountlines
2289
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
2289
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,branchcode)
2290
        VALUES (?,?,now(),?,?,'CR',?)");
2290
        VALUES (?,?,now(),?,?,'CR',?,?)");
2291
    $usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft);
2291
    $usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft,C4::Context->userenv->{'branch'});
2292
    if ($borrowernumber) {
2292
    if ($borrowernumber) {
2293
        # FIXME: same as query above.  use 1 sth for both
2293
        # FIXME: same as query above.  use 1 sth for both
2294
        $usth = $dbh->prepare("INSERT INTO accountoffsets
2294
        $usth = $dbh->prepare("INSERT INTO accountoffsets
Lines 2748-2759 sub AddRenewal { Link Here
2748
        $sth = $dbh->prepare(
2748
        $sth = $dbh->prepare(
2749
                "INSERT INTO accountlines
2749
                "INSERT INTO accountlines
2750
                    (date, borrowernumber, accountno, amount, manager_id,
2750
                    (date, borrowernumber, accountno, amount, manager_id,
2751
                    description,accounttype, amountoutstanding, itemnumber)
2751
                    description,accounttype, amountoutstanding, itemnumber, branch)
2752
                    VALUES (now(),?,?,?,?,?,?,?,?)"
2752
                    VALUES (now(),?,?,?,?,?,?,?,?,?)"
2753
        );
2753
        );
2754
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2754
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2755
            "Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
2755
            "Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
2756
            'Rent', $charge, $itemnumber );
2756
            'Rent', $charge, $itemnumber, C4::Context->userenv->{'branch'} );
2757
    }
2757
    }
2758
2758
2759
    # Send a renewal slip according to checkout alert preferencei
2759
    # Send a renewal slip according to checkout alert preferencei
Lines 2993-3003 sub AddIssuingCharge { Link Here
2993
        INSERT INTO accountlines
2993
        INSERT INTO accountlines
2994
            (borrowernumber, itemnumber, accountno,
2994
            (borrowernumber, itemnumber, accountno,
2995
            date, amount, description, accounttype,
2995
            date, amount, description, accounttype,
2996
            amountoutstanding, manager_id)
2996
            amountoutstanding, manager_id, branchcode)
2997
        VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?)
2997
        VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?,?)
2998
    ";
2998
    ";
2999
    my $sth = $dbh->prepare($query);
2999
    my $sth = $dbh->prepare($query);
3000
    $sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id );
3000
    $sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id, C4::Context->userenv->{'branch'} );
3001
}
3001
}
3002
3002
3003
=head2 GetTransfers
3003
=head2 GetTransfers
(-)a/C4/Overdues.pm (-3 / +4 lines)
Lines 598-608 sub UpdateFine { Link Here
598
		my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
598
		my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
599
		my $desc = ($type ? "$type " : '') . "$title $due";	# FIXEDME, avoid whitespace prefix on empty $type
599
		my $desc = ($type ? "$type " : '') . "$title $due";	# FIXEDME, avoid whitespace prefix on empty $type
600
		my $query = "INSERT INTO accountlines
600
		my $query = "INSERT INTO accountlines
601
		    (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno)
601
                  (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno,branchcode)
602
			    VALUES (?,?,now(),?,?,'FU',?,?,?)";
602
                           VALUES (?,?,now(),?,?,'FU',?,?,?,?)";
603
		my $sth2 = $dbh->prepare($query);
603
		my $sth2 = $dbh->prepare($query);
604
		$debug and print STDERR "UpdateFine query: $query\nw/ args: $borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno\n";
604
		$debug and print STDERR "UpdateFine query: $query\nw/ args: $borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno\n";
605
        $sth2->execute($borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno);
605
        my $branch = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
606
        $sth2->execute($borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno, $branchcode);
606
    }
607
    }
607
    # logging action
608
    # logging action
608
    &logaction(
609
    &logaction(
(-)a/C4/Reserves.pm (-3 / +3 lines)
Lines 178-190 sub AddReserve { Link Here
178
        my $nextacctno = &getnextacctno( $borrowernumber );
178
        my $nextacctno = &getnextacctno( $borrowernumber );
179
        my $query      = qq/
179
        my $query      = qq/
180
        INSERT INTO accountlines
180
        INSERT INTO accountlines
181
            (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
181
            (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,branchcode)
182
        VALUES
182
        VALUES
183
            (?,?,now(),?,?,'Res',?)
183
            (?,?,now(),?,?,'Res',?,?)
184
    /;
184
    /;
185
        my $usth = $dbh->prepare($query);
185
        my $usth = $dbh->prepare($query);
186
        $usth->execute( $borrowernumber, $nextacctno, $fee,
186
        $usth->execute( $borrowernumber, $nextacctno, $fee,
187
            "Reserve Charge - $title", $fee );
187
            "Reserve Charge - $title", $fee, C4::Context->userenv->{'branch'} );
188
    }
188
    }
189
189
190
    #if ($const eq 'a'){
190
    #if ($const eq 'a'){
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2723-2728 CREATE TABLE `accountlines` ( Link Here
2723
  `notify_level` int(2) NOT NULL default 0,
2723
  `notify_level` int(2) NOT NULL default 0,
2724
  `note` text NULL default NULL,
2724
  `note` text NULL default NULL,
2725
  `manager_id` int(11) NULL,
2725
  `manager_id` int(11) NULL,
2726
  `branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
2726
  PRIMARY KEY (`accountlines_id`),
2727
  PRIMARY KEY (`accountlines_id`),
2727
  KEY `acctsborridx` (`borrowernumber`),
2728
  KEY `acctsborridx` (`borrowernumber`),
2728
  KEY `timeidx` (`timestamp`),
2729
  KEY `timeidx` (`timestamp`),
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +6 lines)
Lines 8610-8615 if ( CheckVersion($DBversion) ) { Link Here
8610
        ('OverdueNoticeCalendar',0,'Take calendar into consideration when working out sending overdue notices','YesNo')
8610
        ('OverdueNoticeCalendar',0,'Take calendar into consideration when working out sending overdue notices','YesNo')
8611
    ");
8611
    ");
8612
    print "Upgrade to $DBversion done (Bug 12529 - Adding a syspref to allow the overdue notices to consider the calendar when generating notices)\n";
8612
    print "Upgrade to $DBversion done (Bug 12529 - Adding a syspref to allow the overdue notices to consider the calendar when generating notices)\n";
8613
}
8614
8615
$DBversion = "3.17.00.XXX";
8616
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8617
    $dbh->do("ALTER TABLE accountlines ADD branchcode VARCHAR( 10 ) NULL DEFAULT NULL AFTER manager_id");
8618
    print "Upgrade to $DBversion done (Added column branchcode to accountlines)\n";
8613
    SetVersion($DBversion);
8619
    SetVersion($DBversion);
8614
}
8620
}
8615
8621
8616
- 

Return to bug 7595