[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10994] Property: budget handling
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10994] Property: budget handling |
Date: |
Sun, 17 Mar 2013 13:47:39 +0000 |
Revision: 10994
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10994
Author: sigurdne
Date: 2013-03-17 13:47:39 +0000 (Sun, 17 Mar 2013)
Log Message:
-----------
Property: budget handling
Modified Paths:
--------------
trunk/property/inc/class.sobudget.inc.php
trunk/property/inc/class.soproject.inc.php
trunk/property/inc/class.soworkorder.inc.php
Modified: trunk/property/inc/class.sobudget.inc.php
===================================================================
--- trunk/property/inc/class.sobudget.inc.php 2013-03-16 14:32:31 UTC (rev
10993)
+++ trunk/property/inc/class.sobudget.inc.php 2013-03-17 13:47:39 UTC (rev
10994)
@@ -650,7 +650,7 @@
$_taxcode[$this->db->f('id')] =
$this->db->f('percent');
}
- $sql = "SELECT DISTINCT fm_workorder.id AS id,
fm_location1.mva,"
+ $sql = "SELECT DISTINCT fm_workorder.id AS id,
fm_location1.mva,project_id,"
. " fm_b_account.{$b_account_field} AS
b_account, district_id, fm_workorder.ecodimb"
. " FROM fm_workorder"
. " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
@@ -659,16 +659,25 @@
. " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
. " {$_join_district}"
. " {$this->join} fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
- . " {$filtermethod_order}{$filtermethod}
{$querymethod} {$where} {$filtermethod_direction}";
+ . " {$filtermethod_order}{$filtermethod}
{$querymethod} {$where} {$filtermethod_direction}"
+ . " ORDER BY fm_workorder.id ASC";
// _debug_array($sql);
//die();
$this->db->query($sql,__LINE__,__FILE__);
$_temp_paid_info = array();
+$projects = array();
+
while ($this->db->next_record())
{
+
$_id = $this->db->f('id');
+
+
+$projects[$this->db->f('project_id')] = 0;
+$projects2[$_id] = $this->db->f('project_id');
+
$_temp_paid_info[$_id] = array
(
'actual_cost' => 0,
@@ -678,58 +687,64 @@
'b_account'
=> $this->db->f('b_account'),
);
}
+ksort($projects);
+//_debug_array(count($projects2));
+//_debug_array($projects2);
$soworkorder = CreateObject('property.soworkorder');
+ $sum_actual_cost = 0;
+ $actual_cost = array();
+ $sum_obligation_cost = 0;
+ $obligations = array();
+ $sum_hits = 0;
+
+ $sum_hits = count($_temp_paid_info);
+
foreach ($_temp_paid_info as $order_id => &$order_info)
{
$order_budget =
$soworkorder->get_budget($order_id);
foreach($order_budget as $budget)
{
- if($budget['year'] == $year &&
$budget['active'])
+ if($budget['year'] == $year)
{
+$projects3[$projects2[$order_id]]['actual_cost']+= $budget['actual_cost'];
+$projects3[$projects2[$order_id]]['combined_cost']+= $budget['sum_orders'];
+$projects3[$projects2[$order_id]]['budget']+= $budget['budget'];
+$projects3[$projects2[$order_id]]['obligation']+= $budget['sum_oblications'];
+
$order_info['actual_cost']
+= $budget['actual_cost'];
$order_info['combined_cost']
+= $budget['sum_orders'];
$order_info['budget']
+= $budget['budget'];
$order_info['obligation']
+= $budget['sum_oblications'];
- }
- }
- }
- reset($_temp_paid_info);
- $sum_actual_cost = 0;
- $actual_cost = array();
- $sum_obligation_cost = 0;
- $obligations = array();
- $sum_hits = 0;
+ $sum_obligation_cost +=
$budget['sum_oblications'];
+
$obligations[$order_info['b_account']][$order_info['district_id']][$order_info['ecodimb']]
+= $budget['sum_oblications'];
- $sum_hits = count($_temp_paid_info);
- foreach ($_temp_paid_info as $order_id => $order_info)
- {
- $_combined_cost = $order_info['combined_cost'];
+ $_taxfactor = 1 +
($_taxcode[(int)$order_info['mva']]/100);
+ $_actual_cost =
round($order_info['actual_cost']/$_taxfactor);
- $_taxfactor = 1 +
($_taxcode[(int)$order_info['mva']]/100);
- $_actual_cost =
round($order_info['actual_cost']/$_taxfactor);
- $_obligation = $order_info['obligation'];
+//_debug_array($_test);
- $sum_obligation_cost += $_obligation;
-
$obligations[$order_info['b_account']][$order_info['district_id']][$order_info['ecodimb']]
+= $_obligation;
+ $sum_actual_cost +=
$_actual_cost;
+
$actual_cost[$order_info['b_account']][$order_info['district_id']][$order_info['ecodimb']]
+= $_actual_cost;
-//_debug_array($_test);
-
$hits[$order_info['b_account']][$order_info['district_id']][$order_info['ecodimb']]
+= 1;
- $accout_info[$order_info['b_account']] = true;
- $district[$order_info['district_id']] = true;
- $ecodimb[$order_info['ecodimb']] = true;
- $sum_actual_cost += $_actual_cost;
-
$actual_cost[$order_info['b_account']][$order_info['district_id']][$order_info['ecodimb']]
+= $_actual_cost;
- }
+ }
+
$hits[$order_info['b_account']][$order_info['district_id']][$order_info['ecodimb']]
+= 1;
+ $accout_info[$order_info['b_account']]
= true;
+ $district[$order_info['district_id']] =
true;
+ $ecodimb[$order_info['ecodimb']] = true;
-//_debug_array($_temp_paid_info);
+ }
+ }
+//_debug_array($projects3);
+
+
// _debug_array($obligations);
//----------- ad hoc order
Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php 2013-03-16 14:32:31 UTC (rev
10993)
+++ trunk/property/inc/class.soproject.inc.php 2013-03-17 13:47:39 UTC (rev
10994)
@@ -731,15 +731,11 @@
$budget =
$this->get_budget($project['project_id']);
foreach($budget as $entry)
{
- if($entry['active'])
- {
- $project['actual_cost']
+= $entry['actual_cost'];
- }
-
if ($filter_year &&
$filter_year != 'all')
{
if($entry['year'] ==
$filter_year)
{
+
$project['actual_cost'] += $entry['actual_cost'];
$project['combined_cost'] += $entry['sum_orders'];
$project['budget'] += $entry['budget'];
$project['obligation'] += $entry['sum_oblications'];
@@ -747,6 +743,8 @@
}
else
{
+ $project['actual_cost']
+= $entry['actual_cost'];
+
if($entry['active'])
{
$project['combined_cost'] += $entry['sum_orders'];
@@ -870,7 +868,7 @@
$filter_year = '';
if($year)
{
- $filter_year = "AND fm_workorder_budget.year =
{$year}";
+ $filter_year = "AND (fm_workorder_budget.year =
{$year} OR fm_workorder_status.closed IS NOT NULL)";
}
$this->db->query("SELECT DISTINCT fm_workorder.id AS
workorder_id, fm_workorder.title, fm_workorder.vendor_id,
fm_workorder.addition,"
@@ -2164,12 +2162,18 @@
$period = $budget_entry['period'];
$year = $budget_entry['year'];
+ $_found_actual_cost = false;
+ if(isset($project_budget[$period]))
+ {
+
$_orders[$period]['actual_cost'] += $budget_entry['actual_cost'];
+ $_found_actual_cost = true;
+ }
+
$_found = false;
if(isset($project_budget[$period]) &&
!$budget_entry['closed_order'])
{
//_debug_array($_order_id);
//_debug_array($budget_entry);
-
$_orders[$period]['actual_cost'] += $budget_entry['actual_cost'];
$_orders[$period]['sum_oblications'] += $budget_entry['sum_oblications'];
$_orders[$period]['sum_orders']
+= $budget_entry['sum_orders'];
$_found = true;
@@ -2181,7 +2185,11 @@
$_period = $year .
sprintf("%02s", $i);
if(isset($project_budget[$_period]))
{
-
$_orders[$_period]['actual_cost'] += $budget_entry['actual_cost'];
+
if(!$_found_actual_cost)
+ {
+
$_orders[$_period]['actual_cost'] += $budget_entry['actual_cost'];
+
$_found_actual_cost = true;
+ }
$_orders[$_period]['sum_oblications'] += $budget_entry['sum_oblications'];
$_orders[$_period]['sum_orders'] += $budget_entry['sum_orders'];
@@ -2191,6 +2199,10 @@
}
}
+ if(!$_found_actual_cost)
+ {
+
$_orders[$period]['actual_cost'] += $budget_entry['actual_cost'];
+ }
if(!$_found)
{
$_orders[$period]['actual_cost'] += $budget_entry['actual_cost'];
@@ -2198,7 +2210,6 @@
$_orders[$period]['sum_orders']
+= $budget_entry['sum_orders'];
}
}
-
}
$sort_period = array();
//_debug_array($_orders);
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2013-03-16 14:32:31 UTC
(rev 10993)
+++ trunk/property/inc/class.soworkorder.inc.php 2013-03-17 13:47:39 UTC
(rev 10994)
@@ -619,7 +619,7 @@
if ($filter_year && $filter_year != 'all')
{
$filter_year = (int)$filter_year;
- $filtermethod .= " $where
(fm_workorder_budget.year={$filter_year})";
+ $filtermethod .= " $where
(fm_workorder_budget.year={$filter_year} OR fm_workorder_status.closed IS
NULL)";
$where= 'AND';
}
@@ -794,15 +794,11 @@
$order_budget =
$this->get_budget($workorder['workorder_id']);
foreach($order_budget as $entry)
{
- if($entry['active'])
- {
- $workorder['actual_cost'] +=
$entry['actual_cost'];
- }
-
if ($filter_year && $filter_year !=
'all')
{
if($entry['year'] ==
$filter_year)
{
+
$workorder['actual_cost'] += $entry['actual_cost'];
$workorder['combined_cost'] += $entry['sum_orders'];
$workorder['budget'] +=
$entry['budget'];
$workorder['obligation'] += $entry['sum_oblications'];
@@ -810,6 +806,8 @@
}
else
{
+ $workorder['actual_cost'] +=
$entry['actual_cost'];
+
if($entry['active'])
{
$workorder['combined_cost'] += $entry['sum_orders'];
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10994] Property: budget handling,
Sigurd Nes <=