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

(-)a/C4/Circulation.pm (-9 / +9 lines)
Lines 2157-2165 sub _FixAccountForLostAndReturned { Link Here
2157
    $amountleft *= -1 if ($amountleft > 0);
2157
    $amountleft *= -1 if ($amountleft > 0);
2158
    my $desc = "Item Returned " . $item_id;
2158
    my $desc = "Item Returned " . $item_id;
2159
    $usth = $dbh->prepare("INSERT INTO accountlines
2159
    $usth = $dbh->prepare("INSERT INTO accountlines
2160
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
2160
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,branchcode)
2161
        VALUES (?,?,now(),?,?,'CR',?)");
2161
        VALUES (?,?,now(),?,?,'CR',?,?)");
2162
    $usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft);
2162
    $usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft,C4::Context->userenv->{'branch'});
2163
    if ($borrowernumber) {
2163
    if ($borrowernumber) {
2164
        # FIXME: same as query above.  use 1 sth for both
2164
        # FIXME: same as query above.  use 1 sth for both
2165
        $usth = $dbh->prepare("INSERT INTO accountoffsets
2165
        $usth = $dbh->prepare("INSERT INTO accountoffsets
Lines 2567-2578 sub AddRenewal { Link Here
2567
        $sth = $dbh->prepare(
2567
        $sth = $dbh->prepare(
2568
                "INSERT INTO accountlines
2568
                "INSERT INTO accountlines
2569
                    (date, borrowernumber, accountno, amount, manager_id,
2569
                    (date, borrowernumber, accountno, amount, manager_id,
2570
                    description,accounttype, amountoutstanding, itemnumber)
2570
                    description,accounttype, amountoutstanding, itemnumber, branch)
2571
                    VALUES (now(),?,?,?,?,?,?,?,?)"
2571
                    VALUES (now(),?,?,?,?,?,?,?,?,?)"
2572
        );
2572
        );
2573
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2573
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2574
            "Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
2574
            "Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
2575
            'Rent', $charge, $itemnumber );
2575
            'Rent', $charge, $itemnumber, C4::Context->userenv->{'branch'} );
2576
    }
2576
    }
2577
    # Log the renewal
2577
    # Log the renewal
2578
    UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber, undef, $item->{'ccode'});
2578
    UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber, undef, $item->{'ccode'});
Lines 2728-2738 sub AddIssuingCharge { Link Here
2728
        INSERT INTO accountlines
2728
        INSERT INTO accountlines
2729
            (borrowernumber, itemnumber, accountno,
2729
            (borrowernumber, itemnumber, accountno,
2730
            date, amount, description, accounttype,
2730
            date, amount, description, accounttype,
2731
            amountoutstanding, manager_id)
2731
            amountoutstanding, manager_id, branchcode)
2732
        VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?)
2732
        VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?,?)
2733
    ";
2733
    ";
2734
    my $sth = $dbh->prepare($query);
2734
    my $sth = $dbh->prepare($query);
2735
    $sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id );
2735
    $sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id, C4::Context->userenv->{'branch'} );
2736
    $sth->finish;
2736
    $sth->finish;
2737
}
2737
}
2738
2738
(-)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