[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/C4 Acquisition.pm
From: |
Mason James |
Subject: |
[Koha-cvs] koha/C4 Acquisition.pm |
Date: |
Wed, 12 Jul 2006 14:26:13 +0000 |
CVSROOT: /sources/koha
Module name: koha
Changes by: Mason James <sushi> 06/07/12 14:26:13
Modified files:
C4 : Acquisition.pm
Log message:
removed hardcoded 'next budget date' from neworder(), now rolls over to
01-07 next year.
i think a future improvement will be to look up the next budget
record's end-date for that bookfundi, rather than just assuming its '01-07'.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Acquisition.pm?cvsroot=koha&r1=1.37&r2=1.38
Patches:
Index: Acquisition.pm
===================================================================
RCS file: /sources/koha/koha/C4/Acquisition.pm,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- Acquisition.pm 12 Jul 2006 13:52:28 -0000 1.37
+++ Acquisition.pm 12 Jul 2006 14:26:13 -0000 1.38
@@ -23,13 +23,14 @@
use C4::Date;
use MARC::Record;
use C4::Suggestions;
+use Time::localtime;
# use C4::Biblio;
use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.37 $' =~ /\d+/g; shift(@v) . "." . join(
"_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.38 $' =~ /\d+/g; shift(@v) . "." . join(
"_", map { sprintf "%03d", $_ } @v ); };
# used in reciveorder subroutine
# to provide library specific handling
@@ -219,49 +220,61 @@
$invoice, $sort1, $sort2
)
= @_;
- my $sth;
- my $dbh;
+
+ my $year = localtime->year() + 1900;
+ my $month = localtime->mon() + 1; # months starts at 0, add 1
+
if ( !$budget || $budget eq 'now' ) {
- $sth = $dbh->prepare(
- "INSERT INTO aqorders
- (biblionumber,title,basketno,quantity,listprice,notes,
-
biblioitemnumber,rrp,ecost,gst,unitprice,subscription,sort1,sort2,budgetdate,entrydate)
- VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,now(),now() )"
- );
- $sth->execute(
- $bibnum, $title, $basketno, $quantity, $listprice,
- $notes, $bibitemnum, $rrp, $ecost, $gst,
- $cost, $sub, $sort1, $sort2
- );
+ $budget = "now()";
+ }
+
+ # if month is july or more, budget start is 1 jul, next year.
+ elsif ( $month >= '7' ) {
+ ++$year; # add 1 to year , coz its next year
+ $budget = "'$year-07-01'";
}
else {
- ##FIXME HARDCODED DATE.
- $budget = "'2006-07-01'";
- $sth = $dbh->prepare(
- "INSERT INTO aqorders
- (biblionumber,title,basketno,quantity,listprice,notes,
+ # START OF NEW BUDGET, 1ST OF JULY, THIS YEAR
+ $budget = "'$year-07-01'";
+ }
+
+ if ( $sub eq 'yes' ) {
+ $sub = 1;
+ }
+ else {
+ $sub = 0;
+ }
+
+ # if $basket empty, it's also a new basket, create it
+ unless ($basketno) {
+ $basketno = newbasket( $booksellerid, $authorisedby );
+ }
+
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(
+ "insert into aqorders
+ ( biblionumber,title,basketno,quantity,listprice,notes,
biblioitemnumber,rrp,ecost,gst,unitprice,subscription,sort1,sort2,budgetdate,entrydate)
- VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,now() )"
+ values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,$budget,now() )"
);
+
$sth->execute(
$bibnum, $title, $basketno, $quantity, $listprice,
$notes, $bibitemnum, $rrp, $ecost, $gst,
- $cost, $sub, $sort1, $sort2, $budget
+ $cost, $sub, $sort1, $sort2
);
-
- }
$sth->finish;
#get ordnum MYSQL dependant, but $dbh->last_insert_id returns null
my $ordnum = $dbh->{'mysql_insertid'};
$sth = $dbh->prepare(
- "INSERT INTO aqorderbreakdown (ordernumber,bookfundid) VALUES
+ "insert into aqorderbreakdown (ordernumber,bookfundid) values
(?,?)"
);
$sth->execute( $ordnum, $bookfund );
$sth->finish;
- return $basketno;
+ return ( $basketno, $ordnum );
}
=item delorder