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

(-)a/C4/Accounts.pm (-28 / +41 lines)
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 $branchcode = 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 $branchcode = 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,
(-)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