[lms-commits] CVS update of lms/bin (lms-payments)

LMS CVS cvs w lms.org.pl
Pon, 27 Wrz 2010, 15:16:48 CEST


Date: Monday, September 27, 2010 @ 15:16:48
Author: alec
Path: /cvsroot/lms/bin

Modified: lms-payments

- allow setting assignment period for disposable liabilities
- don't remove disposable liabilities immediately after accounting, use specified delay like with non-disposable liabilities


Diff URLs:
http://cvs.lms.org.pl/viewvc/Development/lms/bin/lms-payments.diff?&r1=1.125&r2=1.126


Index: lms/bin/lms-payments
diff -u lms/bin/lms-payments:1.125 lms/bin/lms-payments:1.126
--- lms/bin/lms-payments:1.125	Mon Jun 28 15:36:05 2010
+++ lms/bin/lms-payments	Mon Sep 27 15:16:48 2010
@@ -20,7 +20,7 @@
 #  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 #  USA.
 #
-#  $Id: lms-payments,v 1.125 2010/06/28 13:36:05 alec Exp $
+#  $Id: lms-payments,v 1.126 2010/09/27 13:16:48 alec Exp $
 
 use strict;
 use DBI;
@@ -360,15 +360,15 @@
 	LEFT JOIN liabilities l ON (a.liabilityid = l.id)
 	LEFT JOIN divisions d ON (d.id = c.divisionid)
 	WHERE c.status = 3
-		AND (a.period = ".DAY." 
-			OR (a.period = ".WEEK." AND at = $weekday) 
-			OR (a.period = ".MONTH." AND at = $dom) 
-			OR (a.period = ".QUARTER." AND at = $quarter) 
-			OR (a.period = ".HALFYEAR." AND at = $halfyear) 
-			OR (a.period = ".YEAR." AND at = $yearday) 
-			OR (a.period = ".DISPOSABLE." AND at = $today)) 
-		AND (a.datefrom <= $currtime OR a.datefrom = 0)
-		AND (a.dateto > $currtime OR a.dateto = 0)
+		AND ((a.period = ".DISPOSABLE." AND at = $today)
+		    OR ((a.period = ".DAY."
+			    OR (a.period = ".WEEK." AND at = $weekday)
+    			OR (a.period = ".MONTH." AND at = $dom)
+	    		OR (a.period = ".QUARTER." AND at = $quarter)
+		    	OR (a.period = ".HALFYEAR." AND at = $halfyear)
+			    OR (a.period = ".YEAR." AND at = $yearday))
+		        AND (a.datefrom <= $currtime OR a.datefrom = 0)
+		        AND (a.dateto > $currtime OR a.dateto = 0)))
 	ORDER BY a.customerid, a.invoice, a.paytype, a.numberplanid, value DESC");
 $dbq->execute();
 
@@ -572,11 +572,6 @@
 
 		print STDERR "CID:$uid\tVAL:$assign->{'value'}\tDESC:$desc\n" if not $quiet;
 
-		if ($assign->{'liabilityid'} && $assign->{'period'} == DISPOSABLE) #remove liability
-		{
-			$dbase->do("DELETE FROM liabilities WHERE id = $assign->{'liabilityid'}");
-		}
-
 		# settlements accounting
 		if ($assign->{'settlement'} && $assign->{'datefrom'})
 		{
@@ -685,16 +680,12 @@
 }
 $dbq->finish();
 
-$dbq = $dbase->prepare("SELECT liabilityid AS id FROM assignments
-		WHERE dateto < $utsfmt - 86400 * 30 AND dateto != 0 AND liabilityid != 0");
-$dbq->execute();
-while(my $row = $dbq->fetchrow_hashref())
-{
-	$dbase->do("DELETE FROM liabilities WHERE id = $row->{'id'}");
-}
-$dbq->finish();
-
-$dbase->do("DELETE FROM assignments WHERE dateto < $utsfmt - 86400 * 30 AND dateto != 0");
-$dbase->do("DELETE FROM assignments WHERE at = $today");
+# delete old assignments
+$dbase->do("DELETE FROM liabilities WHERE id IN (
+    SELECT liabilityid FROM assignments
+    WHERE dateto < $utsfmt - 86400 * 30 AND dateto != 0 AND at < $today - 86400 * 30
+	    AND liabilityid != 0)");
+$dbase->do("DELETE FROM assignments
+    WHERE dateto < $utsfmt - 86400 * 30 AND dateto != 0 AND at < $today - 86400 * 30");
 
 $dbase->disconnect();



Więcej informacji o liście lms-commits