[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11870] property: adjust calculation of fictive perio
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11870] property: adjust calculation of fictive periods |
Date: |
Wed, 26 Mar 2014 10:13:01 +0000 |
Revision: 11870
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11870
Author: sigurdne
Date: 2014-03-26 10:13:01 +0000 (Wed, 26 Mar 2014)
Log Message:
-----------
property: adjust calculation of fictive periods
Modified Paths:
--------------
trunk/property/inc/class.soworkorder.inc.php
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2014-03-26 09:07:23 UTC
(rev 11869)
+++ trunk/property/inc/class.soworkorder.inc.php 2014-03-26 10:13:01 UTC
(rev 11870)
@@ -1852,6 +1852,106 @@
}
}
+ $sql = "SELECT periode, amount AS actual_cost,
periodization, periodization_start"
+ . " FROM fm_workorder {$this->join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . " WHERE order_id = '{$order_id}' ORDER BY periode
ASC";
+ $this->db->query($sql, __LINE__, __FILE__);
+ $orders_paid_or_pending = array();
+ $orders_paid_or_pending_temp = array();
+// _debug_array($sql);die();
+ while($this->db->next_record())
+ {
+ $_periode = $this->db->f('periode');
+ $periode = $_periode ? $_periode :
'dummy';
+
+ //strange...
+ if($periode == 'dummy')
+ {
+
$orders_paid_or_pending_temp[date('Ym')]['actual_cost'] +=
$this->db->f('actual_cost');
+
$orders_paid_or_pending_temp[date('Ym')]['periode'] = date('Ym');
+
$orders_paid_or_pending_temp[date('Ym')]['periodization'] =
$this->db->f('periodization');
+
$orders_paid_or_pending_temp[date('Ym')]['periodization_start'] =
$this->db->f('periodization_start');
+ }
+ else
+ {
+ $orders_paid_or_pending_temp[$periode]
= array
+ (
+ 'periode'
=> $periode,
+ 'periodization'
=> (int) $this->db->f('periodization'),
+ 'periodization_start' =>
$this->db->f('periodization_start'),
+ );
+
$orders_paid_or_pending_temp[$periode]['actual_cost'] +=
$this->db->f('actual_cost');
+
+ }
+ }
+// _debug_array($orders_paid_or_pending_temp);die();
+ foreach($orders_paid_or_pending_temp as $entry)
+ {
+ if($entry['periodization'])
+ {
+ $periodization_start =
$entry['periodization_start'] ? $entry['periodization_start'] :
$entry['periodization'];
+
+ $periodization_start_year =
(int) substr($periodization_start, 0, 4);
+ $periodization_start_month =
(int) substr($periodization_start, -2);
+
+ $sql = "SELECT month, value, dividend,
divisor"
+ . " FROM fm_eco_periodization_outline
WHERE periodization_id = {$entry['periodization']} ORDER BY month ASC";
+ $this->db->query($sql, __LINE__,
__FILE__);
+
+ $periodization_outline = array();
+
+ while($this->db->next_record())
+ {
+ $periodization_outline[] = array
+ (
+ 'month' =>
$this->db->f('month'),
+ 'value' =>
$this->db->f('value'),
+ 'dividend' =>
$this->db->f('dividend'),
+ 'divisor' =>
$this->db->f('divisor')
+ );
+ }
+ if(!$periodization_outline)
+ {
+ $periodization_outline[] = array
+ (
+ 'month' => 1,
+ 'value' => 100,
+ );
+ }
+
+ foreach($periodization_outline as
$outline)
+ {
+ if($outline['dividend'] &&
$outline['divisor'])
+ {
+ $partial_actual_cost =
$entry['actual_cost'] * $outline['dividend'] / $outline['divisor'];
+ }
+ else
+ {
+ $partial_actual_cost =
$entry['actual_cost'] * $outline['value'] / 100;
+ }
+
+ $_period_month = (int)
$periodization_start_month + (int) $outline['month'] - 1;
+
+ $_future_year_count =
floor(($_period_month - 1) / 12);
+
+ $_periodization_start_year =
$periodization_start_year + $_future_year_count;
+
+ $_month = $_period_month -
($_future_year_count * 12);
+
+ $orders_paid_or_pending[] =
array
+ (
+ 'periode'
=> sprintf("%s%02d", $_periodization_start_year, $_month),
+ 'actual_cost' =>
$partial_actual_cost,
+ 'periodization' =>
$entry['periodization'],
+ );
+ }
+ }
+ else
+ {
+ $orders_paid_or_pending[] = $entry;
+ }
+ }
+// _debug_array($orders_paid_or_pending);die();
/**
* Fiktiv periodisering over 12 mnd med startperiode
for inneværende mnd for løpende som ikke er periodisert
* Hopper over historiske år.
@@ -1892,7 +1992,7 @@
$order_budget[$_period] =
$_budget;
$active_period[$_period] =
$active_period[$_period] ? 2 : 0;
-
+
if($current_paid_period &&
$current_paid_period < (int) date('Ym'))
{
$_current_month = (int)
substr($current_paid_period, -2);
@@ -1906,6 +2006,16 @@
$_current_month =
date('n'); // Numeric representation of a month, without leading zeros 1
through 12
}
+ foreach($orders_paid_or_pending
as $_paid_or_pending)
+ {
+
if((int)$_paid_or_pending['periode'] > (int)$_period &&
(int)$_paid_or_pending['periode'] < (int)sprintf("%s%02d", $_budget['year'],
$_current_month))
+ {
+ $_current_month
= (int) substr($_paid_or_pending['periode'], -2);
+ break;
+ }
+ }
+ unset($_paid_or_pending);
+
$_sum_year_combined_cost =
$sum_year_combined_cost[$_budget['year']];
@@ -1970,107 +2080,10 @@
$closed_period[$period] = (int)
$this->db->f('closed');
}
}
- //_debug_array($_start_period_remainig);
- $sql = "SELECT periode, amount AS actual_cost,
periodization, periodization_start"
- . " FROM fm_workorder {$this->join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
- . " WHERE order_id = '{$order_id}' ORDER BY periode
ASC";
- $this->db->query($sql, __LINE__, __FILE__);
- $orders_paid_or_pending = array();
- $orders_paid_or_pending_temp = array();
-// _debug_array($sql);die();
- while($this->db->next_record())
- {
- $_periode = $this->db->f('periode');
- $periode = $_periode ? $_periode :
'dummy';
+//_debug_array($order_budget);die();
+//_debug_array($_start_period_remainig);die();
- //strange...
- if($periode == 'dummy')
- {
-
$orders_paid_or_pending_temp[date('Ym')]['actual_cost'] +=
$this->db->f('actual_cost');
-
$orders_paid_or_pending_temp[date('Ym')]['periode'] = date('Ym');
-
$orders_paid_or_pending_temp[date('Ym')]['periodization'] =
$this->db->f('periodization');
-
$orders_paid_or_pending_temp[date('Ym')]['periodization_start'] =
$this->db->f('periodization_start');
- }
- else
- {
- $orders_paid_or_pending_temp[$periode]
= array
- (
- 'periode'
=> $periode,
- 'periodization'
=> (int) $this->db->f('periodization'),
- 'periodization_start' =>
$this->db->f('periodization_start'),
- );
-
$orders_paid_or_pending_temp[$periode]['actual_cost'] +=
$this->db->f('actual_cost');
-
- }
- }
-// _debug_array($orders_paid_or_pending_temp);die();
- foreach($orders_paid_or_pending_temp as $entry)
- {
- if($entry['periodization'])
- {
- $periodization_start =
$entry['periodization_start'] ? $entry['periodization_start'] :
$entry['periodization'];
-
- $periodization_start_year =
(int) substr($periodization_start, 0, 4);
- $periodization_start_month =
(int) substr($periodization_start, -2);
-
- $sql = "SELECT month, value, dividend,
divisor"
- . " FROM fm_eco_periodization_outline
WHERE periodization_id = {$entry['periodization']} ORDER BY month ASC";
- $this->db->query($sql, __LINE__,
__FILE__);
-
- $periodization_outline = array();
-
- while($this->db->next_record())
- {
- $periodization_outline[] = array
- (
- 'month' =>
$this->db->f('month'),
- 'value' =>
$this->db->f('value'),
- 'dividend' =>
$this->db->f('dividend'),
- 'divisor' =>
$this->db->f('divisor')
- );
- }
- if(!$periodization_outline)
- {
- $periodization_outline[] = array
- (
- 'month' => 1,
- 'value' => 100,
- );
- }
-
- foreach($periodization_outline as
$outline)
- {
- if($outline['dividend'] &&
$outline['divisor'])
- {
- $partial_actual_cost =
$entry['actual_cost'] * $outline['dividend'] / $outline['divisor'];
- }
- else
- {
- $partial_actual_cost =
$entry['actual_cost'] * $outline['value'] / 100;
- }
-
- $_period_month = (int)
$periodization_start_month + (int) $outline['month'] - 1;
-
- $_future_year_count =
floor(($_period_month - 1) / 12);
-
- $_periodization_start_year =
$periodization_start_year + $_future_year_count;
-
- $_month = $_period_month -
($_future_year_count * 12);
-
- $orders_paid_or_pending[] =
array
- (
- 'periode'
=> sprintf("%s%02d", $_periodization_start_year, $_month),
- 'actual_cost' =>
$partial_actual_cost,
- 'periodization' =>
$entry['periodization'],
- );
- }
- }
- else
- {
- $orders_paid_or_pending[] = $entry;
- }
- }
-
+//_debug_array($orders_paid_or_pending);die();
foreach($orders_paid_or_pending as
$_orders_paid_or_pending)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11870] property: adjust calculation of fictive periods,
Sigurd Nes <=