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

(-)a/C4/Circulation.pm (-9 / +9 lines)
Lines 2165-2173 sub _FixAccountForLostAndReturned { Link Here
2165
    $amountleft *= -1 if ($amountleft > 0);
2165
    $amountleft *= -1 if ($amountleft > 0);
2166
    my $desc = "Item Returned " . $item_id;
2166
    my $desc = "Item Returned " . $item_id;
2167
    $usth = $dbh->prepare("INSERT INTO accountlines
2167
    $usth = $dbh->prepare("INSERT INTO accountlines
2168
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
2168
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,branchcode)
2169
        VALUES (?,?,now(),?,?,'CR',?)");
2169
        VALUES (?,?,now(),?,?,'CR',?,?)");
2170
    $usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft);
2170
    $usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft,C4::Context->userenv->{'branch'});
2171
    if ($borrowernumber) {
2171
    if ($borrowernumber) {
2172
        # FIXME: same as query above.  use 1 sth for both
2172
        # FIXME: same as query above.  use 1 sth for both
2173
        $usth = $dbh->prepare("INSERT INTO accountoffsets
2173
        $usth = $dbh->prepare("INSERT INTO accountoffsets
Lines 2575-2586 sub AddRenewal { Link Here
2575
        $sth = $dbh->prepare(
2575
        $sth = $dbh->prepare(
2576
                "INSERT INTO accountlines
2576
                "INSERT INTO accountlines
2577
                    (date, borrowernumber, accountno, amount, manager_id,
2577
                    (date, borrowernumber, accountno, amount, manager_id,
2578
                    description,accounttype, amountoutstanding, itemnumber)
2578
                    description,accounttype, amountoutstanding, itemnumber, branch)
2579
                    VALUES (now(),?,?,?,?,?,?,?,?)"
2579
                    VALUES (now(),?,?,?,?,?,?,?,?,?)"
2580
        );
2580
        );
2581
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2581
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2582
            "Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
2582
            "Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
2583
            'Rent', $charge, $itemnumber );
2583
            'Rent', $charge, $itemnumber, C4::Context->userenv->{'branch'} );
2584
    }
2584
    }
2585
2585
2586
    # Send a renewal slip according to checkout alert preferencei
2586
    # Send a renewal slip according to checkout alert preferencei
Lines 2757-2767 sub AddIssuingCharge { Link Here
2757
        INSERT INTO accountlines
2757
        INSERT INTO accountlines
2758
            (borrowernumber, itemnumber, accountno,
2758
            (borrowernumber, itemnumber, accountno,
2759
            date, amount, description, accounttype,
2759
            date, amount, description, accounttype,
2760
            amountoutstanding, manager_id)
2760
            amountoutstanding, manager_id, branchcode)
2761
        VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?)
2761
        VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?,?)
2762
    ";
2762
    ";
2763
    my $sth = $dbh->prepare($query);
2763
    my $sth = $dbh->prepare($query);
2764
    $sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id );
2764
    $sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id, C4::Context->userenv->{'branch'} );
2765
    $sth->finish;
2765
    $sth->finish;
2766
}
2766
}
2767
2767
(-)a/C4/Overdues.pm (-103 / +3 lines)
Lines 48-59 BEGIN { Link Here
48
        &GetNotifyId
48
        &GetNotifyId
49
        &NumberNotifyId
49
        &NumberNotifyId
50
        &AmountNotify
50
        &AmountNotify
51
        &UpdateAccountLines
52
        &UpdateFine
51
        &UpdateFine
53
        &GetOverdueDelays
52
        &GetOverdueDelays
54
        &GetOverduerules
53
        &GetOverduerules
55
        &GetFine
54
        &GetFine
56
        &CreateItemAccountLine
57
        &ReplacementCost2
55
        &ReplacementCost2
58
        
56
        
59
        &CheckItemNotify
57
        &CheckItemNotify
Lines 602-612 sub UpdateFine { Link Here
602
		my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
600
		my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
603
		my $desc = ($type ? "$type " : '') . "$title $due";	# FIXEDME, avoid whitespace prefix on empty $type
601
		my $desc = ($type ? "$type " : '') . "$title $due";	# FIXEDME, avoid whitespace prefix on empty $type
604
		my $query = "INSERT INTO accountlines
602
		my $query = "INSERT INTO accountlines
605
		    (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno)
603
                  (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno,branchcode)
606
			    VALUES (?,?,now(),?,?,'FU',?,?,?)";
604
                           VALUES (?,?,now(),?,?,'FU',?,?,?,?)";
607
		my $sth2 = $dbh->prepare($query);
605
		my $sth2 = $dbh->prepare($query);
608
		$debug and print STDERR "UpdateFine query: $query\nw/ args: $borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno\n";
606
		$debug and print STDERR "UpdateFine query: $query\nw/ args: $borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno\n";
609
        $sth2->execute($borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno);
607
        $sth2->execute($borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno, C4::Context->userenv->{'branch'});
610
    }
608
    }
611
    # logging action
609
    # logging action
612
    &logaction(
610
    &logaction(
Lines 865-968 sub GetNotifyId { Link Here
865
    return ($notify_id);
863
    return ($notify_id);
866
}
864
}
867
865
868
=head2 CreateItemAccountLine
869
870
    () = &CreateItemAccountLine($borrowernumber, $itemnumber, $date, $amount,
871
                               $description, $accounttype, $amountoutstanding, 
872
                               $timestamp, $notify_id, $level);
873
874
update the account lines with file number or with file level
875
876
C<$items> is a reference-to-hash whose keys are all of the fields
877
from the items tables of the Koha database. Thus,
878
879
C<$itemnumber> contains the item number
880
881
C<$borrowernumber> contains the borrower number
882
883
C<$date> contains the date of the day
884
885
C<$amount> contains item price
886
887
C<$description> contains the descritpion of accounttype 
888
889
C<$accounttype> contains the account type
890
891
C<$amountoutstanding> contains the $amountoutstanding 
892
893
C<$timestamp> contains the timestamp with time and the date of the day
894
895
C<$notify_id> contains the file number
896
897
C<$level> contains the file level
898
899
=cut
900
901
sub CreateItemAccountLine {
902
    my (
903
        $borrowernumber, $itemnumber,  $date,              $amount,
904
        $description,    $accounttype, $amountoutstanding, $timestamp,
905
        $notify_id,      $level
906
    ) = @_;
907
    my $dbh         = C4::Context->dbh;
908
    my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
909
    my $query       = "INSERT into accountlines
910
         (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,amountoutstanding,timestamp,notify_id,notify_level)
911
          VALUES
912
             (?,?,?,?,?,?,?,?,?,?,?)";
913
914
    my $sth = $dbh->prepare($query);
915
    $sth->execute(
916
        $borrowernumber, $nextaccntno,       $itemnumber,
917
        $date,           $amount,            $description,
918
        $accounttype,    $amountoutstanding, $timestamp,
919
        $notify_id,      $level
920
    );
921
}
922
923
=head2 UpdateAccountLines
924
925
    () = &UpdateAccountLines($notify_id,$notify_level,$borrowernumber,$itemnumber);
926
927
update the account lines with file number or with file level
928
929
C<$items> is a reference-to-hash whose keys are all of the fields
930
from the items tables of the Koha database. Thus,
931
932
C<$itemnumber> contains the item number
933
934
C<$notify_id> contains the file number
935
936
C<$notify_level> contains the file level
937
938
C<$borrowernumber> contains the borrowernumber
939
940
=cut
941
942
sub UpdateAccountLines {
943
    my ( $notify_id, $notify_level, $borrowernumber, $itemnumber ) = @_;
944
    my $query;
945
    if ( $notify_id eq '' ) {
946
        $query = qq|UPDATE accountlines
947
    SET  notify_level=?
948
    WHERE borrowernumber=? AND itemnumber=?
949
    AND (accounttype='FU' or accounttype='O')|;
950
    } else {
951
        $query = qq|UPDATE accountlines
952
     SET notify_id=?, notify_level=?
953
   WHERE borrowernumber=?
954
    AND itemnumber=?
955
    AND (accounttype='FU' or accounttype='O')|;
956
    }
957
958
    my $sth = C4::Context->dbh->prepare($query);
959
    if ( $notify_id eq '' ) {
960
        $sth->execute( $notify_level, $borrowernumber, $itemnumber );
961
    } else {
962
        $sth->execute( $notify_id, $notify_level, $borrowernumber, $itemnumber );
963
    }
964
}
965
966
=head2 GetItems
866
=head2 GetItems
967
867
968
    ($items) = &GetItems($itemnumber);
868
    ($items) = &GetItems($itemnumber);
(-)a/C4/Reserves.pm (-4 / +3 lines)
Lines 175-187 sub AddReserve { Link Here
175
        my $nextacctno = &getnextacctno( $borrowernumber );
175
        my $nextacctno = &getnextacctno( $borrowernumber );
176
        my $query      = qq/
176
        my $query      = qq/
177
        INSERT INTO accountlines
177
        INSERT INTO accountlines
178
            (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
178
            (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,branchcode)
179
        VALUES
179
        VALUES
180
            (?,?,now(),?,?,'Res',?)
180
            (?,?,now(),?,?,'Res',?,?)
181
    /;
181
    /;
182
        my $usth = $dbh->prepare($query);
182
        my $usth = $dbh->prepare($query);
183
        $usth->execute( $borrowernumber, $nextacctno, $fee,
183
        $usth->execute( $borrowernumber, $nextacctno, $fee,
184
            "Reserve Charge - $title", $fee );
184
            "Reserve Charge - $title", $fee, C4::Context->userenv->{'branch'} );
185
    }
185
    }
186
186
187
    #if ($const eq 'a'){
187
    #if ($const eq 'a'){
188
- 

Return to bug 7595