[Koha-patches] [PATCH] [followup](bug #3348) Budget and funds broken
Nahuel ANGELINETTI
nahuel.angelinetti at biblibre.com
Thu Oct 8 16:37:39 CEST 2009
This patch, fix the way to detect closed baskets or not. The way to calculate budget and funds and the spent detail.
---
C4/Acquisition.pm | 6 ++++--
C4/Bookfund.pm | 27 +++++++++++++--------------
acqui/parcel.pl | 2 +-
acqui/spent.pl | 2 +-
4 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index bf8253b..6924953 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -206,13 +206,15 @@ sub GetPendingOrders {
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
WHERE booksellerid=?
- AND (quantity > quantityreceived OR quantityreceived is NULL)
AND datecancellationprinted IS NULL
AND (to_days(now())-to_days(closedate) < 180 OR closedate IS NULL)
";
if($closed){
- $strsth .= " AND closedate IS NOT NULL ";
+ $strsth .= "
+ AND (quantity > quantityreceived OR quantityreceived is NULL)
+ AND closedate IS NOT NULL ";
}
+ warn $strsth;
## FIXME Why 180 days ???
my @query_params = ( $supplierid );
if ( C4::Context->preference("IndependantBranches") ) {
diff --git a/C4/Bookfund.pm b/C4/Bookfund.pm
index 15cbd31..7f6633c 100644
--- a/C4/Bookfund.pm
+++ b/C4/Bookfund.pm
@@ -222,17 +222,18 @@ sub GetBookFundBreakdown {
# do a query for spent totals.
my $query = "
- Select distinct quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived
- as qrev,subscription,title,itype as itemtype,aqorders.biblionumber,aqorders.booksellerinvoicenumber,
+ Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived
+ as qrev,subscription,title,itemtype,aqorders.biblionumber,aqorders.booksellerinvoicenumber,
quantity-quantityreceived as tleft,
aqorders.ordernumber
- as ordnum,entrydate,budgetdate,aqbasket.booksellerid,aqbasket.basketno
- from aqorders
- inner join aqorderbreakdown on aqorderbreakdown.ordernumber = aqorders.ordernumber
- inner join aqbasket on aqbasket.basketno = aqorders.basketno
- left join items on items.biblionumber=aqorders.biblionumber
- where bookfundid=?
- and (datereceived >= ? and datereceived < ?)
+ as ordnum,entrydate,budgetdate,booksellerid,aqbasket.basketno
+ from aqorderbreakdown,aqbasket,aqorders
+ left join biblioitems on biblioitems.biblioitemnumber=aqorders.biblioitemnumber
+ where bookfundid=? and
+ aqorders.ordernumber=aqorderbreakdown.ordernumber and
+ aqorders.basketno=aqbasket.basketno
+ and (
+ (datereceived >= ? and datereceived < ?))
and (datecancellationprinted is NULL or
datecancellationprinted='0000-00-00')
and (closedate >= ? and closedate < ?)
@@ -243,11 +244,9 @@ sub GetBookFundBreakdown {
my ($spent) = 0;
while ( my $data = $sth->fetchrow_hashref ) {
if($data->{datereceived}){
- if ( $data->{'subscription'} == 1 ) {
- $spent += $data->{'quantity'} * $data->{'unitprice'};
- }
- else {
- $spent += ( $data->{'unitprice'} ) * ($data->{'qrev'}?$data->{'qrev'}:0);
+ my $recv = $data->{'qrev'};
+ if ( $recv > 0 ) {
+ $spent += $recv * $data->{'unitprice'};
}
}
}
diff --git a/acqui/parcel.pl b/acqui/parcel.pl
index 3a5cd07..8d60498 100755
--- a/acqui/parcel.pl
+++ b/acqui/parcel.pl
@@ -146,7 +146,7 @@ for (my $i = 0 ; $i < $countlines ; $i++) {
$tototal += $total;
}
-my $pendingorders = GetPendingOrders($supplierid, 0, 1);
+my $pendingorders = GetPendingOrders($supplierid, "", 1);
my $countpendings = scalar @$pendingorders;
# pending orders totals
diff --git a/acqui/spent.pl b/acqui/spent.pl
index d7a19a7..ee890fd 100755
--- a/acqui/spent.pl
+++ b/acqui/spent.pl
@@ -43,7 +43,7 @@ my $query =
and (datecancellationprinted is NULL or
datecancellationprinted='0000-00-00')
and (closedate >= ? and closedate < ?)
-
+ ORDER BY datereceived
";
my $sth = $dbh->prepare($query);
$sth->execute( $bookfund, $start, $end, $start, $end);
--
1.6.0.4
More information about the Koha-patches
mailing list