From b94af63395d1784c54d10548f59478a05f460828 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 20 Sep 2012 10:17:04 -0400 Subject: [PATCH] Bug 7595 - Add branchcode to accountlines - Followup --- C4/Circulation.pm | 18 ++++---- C4/Overdues.pm | 106 +--------------------------------------------------- C4/Reserves.pm | 6 +- 3 files changed, 15 insertions(+), 115 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 71fe20f..9872334 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2165,9 +2165,9 @@ sub _FixAccountForLostAndReturned { $amountleft *= -1 if ($amountleft > 0); my $desc = "Item Returned " . $item_id; $usth = $dbh->prepare("INSERT INTO accountlines - (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding) - VALUES (?,?,now(),?,?,'CR',?)"); - $usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft); + (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,branchcode) + VALUES (?,?,now(),?,?,'CR',?,?)"); + $usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft,C4::Context->userenv->{'branch'}); if ($borrowernumber) { # FIXME: same as query above. use 1 sth for both $usth = $dbh->prepare("INSERT INTO accountoffsets @@ -2575,12 +2575,12 @@ sub AddRenewal { $sth = $dbh->prepare( "INSERT INTO accountlines (date, borrowernumber, accountno, amount, manager_id, - description,accounttype, amountoutstanding, itemnumber) - VALUES (now(),?,?,?,?,?,?,?,?)" + description,accounttype, amountoutstanding, itemnumber, branch) + VALUES (now(),?,?,?,?,?,?,?,?,?)" ); $sth->execute( $borrowernumber, $accountno, $charge, $manager_id, "Renewal of Rental Item $item->{'title'} $item->{'barcode'}", - 'Rent', $charge, $itemnumber ); + 'Rent', $charge, $itemnumber, C4::Context->userenv->{'branch'} ); } # Send a renewal slip according to checkout alert preferencei @@ -2757,11 +2757,11 @@ sub AddIssuingCharge { INSERT INTO accountlines (borrowernumber, itemnumber, accountno, date, amount, description, accounttype, - amountoutstanding, manager_id) - VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?) + amountoutstanding, manager_id, branchcode) + VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?,?) "; my $sth = $dbh->prepare($query); - $sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id ); + $sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id, C4::Context->userenv->{'branch'} ); $sth->finish; } diff --git a/C4/Overdues.pm b/C4/Overdues.pm index ac66c36..e363817 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -48,12 +48,10 @@ BEGIN { &GetNotifyId &NumberNotifyId &AmountNotify - &UpdateAccountLines &UpdateFine &GetOverdueDelays &GetOverduerules &GetFine - &CreateItemAccountLine &ReplacementCost2 &CheckItemNotify @@ -602,11 +600,11 @@ sub UpdateFine { my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber); my $desc = ($type ? "$type " : '') . "$title $due"; # FIXEDME, avoid whitespace prefix on empty $type my $query = "INSERT INTO accountlines - (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno) - VALUES (?,?,now(),?,?,'FU',?,?,?)"; + (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno,branchcode) + VALUES (?,?,now(),?,?,'FU',?,?,?,?)"; my $sth2 = $dbh->prepare($query); $debug and print STDERR "UpdateFine query: $query\nw/ args: $borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno\n"; - $sth2->execute($borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno); + $sth2->execute($borrowernumber, $itemnum, $amount, $desc, $amount, $amount, $nextaccntno, C4::Context->userenv->{'branch'}); } # logging action &logaction( @@ -865,104 +863,6 @@ sub GetNotifyId { return ($notify_id); } -=head2 CreateItemAccountLine - - () = &CreateItemAccountLine($borrowernumber, $itemnumber, $date, $amount, - $description, $accounttype, $amountoutstanding, - $timestamp, $notify_id, $level); - -update the account lines with file number or with file level - -C<$items> is a reference-to-hash whose keys are all of the fields -from the items tables of the Koha database. Thus, - -C<$itemnumber> contains the item number - -C<$borrowernumber> contains the borrower number - -C<$date> contains the date of the day - -C<$amount> contains item price - -C<$description> contains the descritpion of accounttype - -C<$accounttype> contains the account type - -C<$amountoutstanding> contains the $amountoutstanding - -C<$timestamp> contains the timestamp with time and the date of the day - -C<$notify_id> contains the file number - -C<$level> contains the file level - -=cut - -sub CreateItemAccountLine { - my ( - $borrowernumber, $itemnumber, $date, $amount, - $description, $accounttype, $amountoutstanding, $timestamp, - $notify_id, $level - ) = @_; - my $dbh = C4::Context->dbh; - my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber); - my $query = "INSERT into accountlines - (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,amountoutstanding,timestamp,notify_id,notify_level) - VALUES - (?,?,?,?,?,?,?,?,?,?,?)"; - - my $sth = $dbh->prepare($query); - $sth->execute( - $borrowernumber, $nextaccntno, $itemnumber, - $date, $amount, $description, - $accounttype, $amountoutstanding, $timestamp, - $notify_id, $level - ); -} - -=head2 UpdateAccountLines - - () = &UpdateAccountLines($notify_id,$notify_level,$borrowernumber,$itemnumber); - -update the account lines with file number or with file level - -C<$items> is a reference-to-hash whose keys are all of the fields -from the items tables of the Koha database. Thus, - -C<$itemnumber> contains the item number - -C<$notify_id> contains the file number - -C<$notify_level> contains the file level - -C<$borrowernumber> contains the borrowernumber - -=cut - -sub UpdateAccountLines { - my ( $notify_id, $notify_level, $borrowernumber, $itemnumber ) = @_; - my $query; - if ( $notify_id eq '' ) { - $query = qq|UPDATE accountlines - SET notify_level=? - WHERE borrowernumber=? AND itemnumber=? - AND (accounttype='FU' or accounttype='O')|; - } else { - $query = qq|UPDATE accountlines - SET notify_id=?, notify_level=? - WHERE borrowernumber=? - AND itemnumber=? - AND (accounttype='FU' or accounttype='O')|; - } - - my $sth = C4::Context->dbh->prepare($query); - if ( $notify_id eq '' ) { - $sth->execute( $notify_level, $borrowernumber, $itemnumber ); - } else { - $sth->execute( $notify_id, $notify_level, $borrowernumber, $itemnumber ); - } -} - =head2 GetItems ($items) = &GetItems($itemnumber); diff --git a/C4/Reserves.pm b/C4/Reserves.pm index a380bf0..f3e8ead 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -175,13 +175,13 @@ sub AddReserve { my $nextacctno = &getnextacctno( $borrowernumber ); my $query = qq/ INSERT INTO accountlines - (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding) + (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,branchcode) VALUES - (?,?,now(),?,?,'Res',?) + (?,?,now(),?,?,'Res',?,?) /; my $usth = $dbh->prepare($query); $usth->execute( $borrowernumber, $nextacctno, $fee, - "Reserve Charge - $title", $fee ); + "Reserve Charge - $title", $fee, C4::Context->userenv->{'branch'} ); } #if ($const eq 'a'){ -- 1.7.2.5