fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [11212] property: periodization transition


From: Sigurd Nes
Subject: [Fmsystem-commits] [11212] property: periodization transition
Date: Thu, 27 Jun 2013 18:52:53 +0000

Revision: 11212
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11212
Author:   sigurdne
Date:     2013-06-27 18:52:52 +0000 (Thu, 27 Jun 2013)
Log Message:
-----------
property: periodization transition

Modified Paths:
--------------
    trunk/property/inc/class.boinvoice.inc.php
    trunk/property/inc/export/default/Basware_X114

Modified: trunk/property/inc/class.boinvoice.inc.php
===================================================================
--- trunk/property/inc/class.boinvoice.inc.php  2013-06-27 13:24:14 UTC (rev 
11211)
+++ trunk/property/inc/class.boinvoice.inc.php  2013-06-27 18:52:52 UTC (rev 
11212)
@@ -266,15 +266,28 @@
                                $_lag_hour = 
(int)$period_transition[$current_month]['hour'];
                                $_lag_seconds = ($_lag_day * 24 * 3600) + 
($_lag_hour * 3600);
                        }
+                       else if(isset($period_transition[13]))
+                       {
+                               $_lag_day = (int)$period_transition[13]['day'];
+                               $_lag_hour = 
(int)$period_transition[13]['hour'];
+                               $_lag_seconds = ($_lag_day * 24 * 3600) + 
($_lag_hour * 3600);
+                       }
+                       else
+                       {
+                               $_lag                   = date('n') == 1 ? 17 : 
7;//6 days into next month, 16 days into next year
+                               $_lag_seconds   = $_lag * 24 * 3600;
+                       }
                        
+                       $_lag_seconds -= phpgwapi_datetime::user_timezone();
+                       
 //_debug_array($period_transition);                    
                        $time = time();
+                       $timestamp_at_start_month =  mktime( $hour = 0, $minute 
= 0, $second = 0, $month = date("n"), $day = 0, $year = date("Y") );
 
-                       $_lag = date('n') == 1 ? 17 : 7;//6 days into next 
month, 16 days into next year
 
-                       if ( date('j',$time) < $_lag ) //Day of the month 
without leading zeros
+                       if(($time - $timestamp_at_start_month) < $_lag_seconds)
                        {
-                               $time = $time - ($_lag * 24 * 3600);
+                               $time = $time - $_lag_seconds;                  
                        }
 
                        $month = date('n', $time);

Modified: trunk/property/inc/export/default/Basware_X114
===================================================================
--- trunk/property/inc/export/default/Basware_X114      2013-06-27 13:24:14 UTC 
(rev 11211)
+++ trunk/property/inc/export/default/Basware_X114      2013-06-27 18:52:52 UTC 
(rev 11212)
@@ -43,6 +43,7 @@
                protected $connection = false;
                protected $global_lock = false;
                protected $orders_affected = array();
+               protected $min_period;
 
                function  __construct()
                {
@@ -65,6 +66,52 @@
                        {
                                $this->cleanup_old();
                        }
+
+                       $sogeneric              = 
CreateObject('property.sogeneric','period_transition');
+                       $period_config                  = 
$sogeneric->read(array('allrows' => true));
+                       
+                       $period_transition = array();
+                       foreach($period_config as $entry)
+                       {
+                               $period_transition[$entry['month']] = $entry;
+                       }
+
+                       $current_month = date('n');
+                       
+                       if(isset($period_transition[$current_month]))
+                       {
+                               $_lag_day = 
(int)$period_transition[$current_month]['day'];
+                               $_lag_hour = 
(int)$period_transition[$current_month]['hour'];
+                               $_lag_seconds = ($_lag_day * 24 * 3600) + 
($_lag_hour * 3600);
+                       }
+                       else if(isset($period_transition[13]))
+                       {
+                               $_lag_day = (int)$period_transition[13]['day'];
+                               $_lag_hour = 
(int)$period_transition[13]['hour'];
+                               $_lag_seconds = ($_lag_day * 24 * 3600) + 
($_lag_hour * 3600);
+                       }
+                       else
+                       {
+                               $_lag                   = date('n') == 1 ? 17 : 
7;//6 days into next month, 16 days into next year
+                               $_lag_seconds   = $_lag * 24 * 3600;
+                       }
+                       
+                       $_lag_seconds -= phpgwapi_datetime::user_timezone();
+                       
+//_debug_array($period_transition);                    
+                       $time = time();
+                       $timestamp_at_start_month =  mktime( $hour = 0, $minute 
= 0, $second = 0, $month = date("n"), $day = 0, $year = date("Y") );
+
+                       if(($time - $timestamp_at_start_month) < $_lag_seconds)
+                       {
+                               $time = $time - $_lag_seconds;                  
+                       }
+
+                       $month = date('n', $time);
+                       $year = date('Y',$time);
+                       
+                       $this->min_period = sprintf("%s%02d",$year,$month);
+
                }
 
                protected function cleanup_old()
@@ -713,7 +760,14 @@
 
                        if ( $oRsBilag[0]['periode'] )
                        {
-                               $periode = $oRsBilag[0]['periode'];
+                               if((int)$this->min_period < 
(int)$oRsBilag[0]['periode'])
+                               {
+                                       $periode = $this->min_period;
+                               }
+                               else
+                               {
+                                       $periode = $oRsBilag[0]['periode'];
+                               }
                        }
                        else if 
(isset($this->config->config_data['export']['dato_aarsavslutning']) && time() < 
$this->config->config_data['export']['dato_aarsavslutning'] )
                        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]