[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9028] property: calculation on obligations
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [9028] property: calculation on obligations |
Date: |
Thu, 22 Mar 2012 14:25:48 +0000 |
Revision: 9028
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9028
Author: sigurdne
Date: 2012-03-22 14:25:47 +0000 (Thu, 22 Mar 2012)
Log Message:
-----------
property: calculation on obligations
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 2012-03-22 11:49:03 UTC (rev
9027)
+++ trunk/property/inc/class.sobudget.inc.php 2012-03-22 14:25:47 UTC (rev
9028)
@@ -803,6 +803,7 @@
$_taxcode[$this->db->f('id')] =
$this->db->f('percent');
}
+//-------start check paid-----------
$sql = "SELECT fm_b_account.{$b_account_field} as
{$b_account_field}, district_id, sum(godkjentbelop) as actual_cost,dimb,mvakode"
. " FROM fm_ecobilagoverf"
. " {$this->join} fm_b_account ON
fm_ecobilagoverf.spbudact_code =fm_b_account.id"
@@ -826,6 +827,34 @@
$ecodimb[(int)$this->db->f('dimb')] = true;
}
+//-------end check paid-----------
+
+//-------start check active invoices-----------
+ $sql = "SELECT fm_b_account.{$b_account_field} as
{$b_account_field}, district_id, sum(godkjentbelop) as actual_cost,dimb,mvakode"
+ . " FROM fm_ecobilag"
+ . " {$this->join} fm_b_account ON
fm_ecobilag.spbudact_code =fm_b_account.id"
+ . " {$this->join} fm_location1 ON
fm_ecobilag.loc1 = fm_location1.loc1"
+ . " {$this->join} fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
+ . " {$this->join} fm_workorder ON
fm_ecobilag.pmwrkord_code = fm_workorder.id"
+ . " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
+ . " WHERE (periode >= 0 AND periode <=
$end_periode OR periode IS NULL) {$filtermethod}"
+ . " GROUP BY fm_b_account.{$b_account_field},
district_id, dimb, mvakode";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mvakode')]/100);
+ $_actual_cost =
round($this->db->f('actual_cost')/$_taxfactor);
+ $sum_actual_cost += $_actual_cost;
+
$actual_cost[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
+= $_actual_cost;
+ $accout_info[$this->db->f($b_account_field)] =
true;
+ $district[(int)$this->db->f('district_id')] =
true;
+ $ecodimb[(int)$this->db->f('dimb')] = true;
+ }
+
+//-------end check active invoices-----------
+
// start service agreements
$filtermethod = " fm_s_agreement_budget.year = $year";
@@ -849,8 +878,6 @@
$where = 'AND';
}
-
-
$sql = "SELECT sum(budget) as budget,
count(fm_s_agreement.id) as hits, fm_b_account.{$b_account_field} as
{$b_account_field}, fm_s_agreement_budget.ecodimb"
. " FROM fm_s_agreement"
. " {$this->join} fm_s_agreement_budget ON
fm_s_agreement.id = fm_s_agreement_budget.agreement_id"
@@ -876,6 +903,7 @@
}
+//-------start check paid-----------
$sql = "SELECT fm_b_account.{$b_account_field} as
{$b_account_field}, sum(fm_ecobilagoverf.godkjentbelop) as
actual_cost,fm_s_agreement_budget.ecodimb"
. " FROM fm_ecobilagoverf"
@@ -901,7 +929,59 @@
$ecodimb[(int)$this->db->f('dimb')] = true;
}
+//-------end check paid-----------
+//-------start check active invoices-----------
+
+ $filtermethod = '';
+ $where = 'WHERE';
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where
fm_s_agreement.category = " . (int)$cat_id;
+ $where = 'AND';
+ }
+
+ if ($grouping > 0)
+ {
+ $filtermethod .= " $where
fm_b_account.category='$grouping' ";
+ $where = 'AND';
+ }
+
+ if ($dimb_id > 0)
+ {
+ $filtermethod .= " $where
fm_s_agreement_budget.ecodimb={$dimb_id}";
+ $where = 'AND';
+ }
+
+
+
+ $sql = "SELECT fm_b_account.{$b_account_field} as
{$b_account_field}, sum(fm_ecobilag.godkjentbelop) as
actual_cost,fm_s_agreement_budget.ecodimb"
+ . " FROM fm_ecobilag"
+ . " {$this->join} fm_b_account ON
fm_ecobilag.spbudact_code =fm_b_account.id"
+ . " {$this->join} fm_s_agreement ON
fm_ecobilag.pmwrkord_code = fm_s_agreement.id"
+ . " {$this->join} fm_s_agreement_budget ON
fm_s_agreement.id = fm_s_agreement_budget.agreement_id"
+ . " {$filtermethod}"
+ . " GROUP BY fm_b_account.{$b_account_field},
ecodimb";
+//_debug_array($sql);
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $_actual_cost =
round($this->db->f('actual_cost'));
+ $_account_value =
$this->db->f($b_account_field);
+ $_dimb = (int)$this->db->f('ecodimb');
+
+ $sum_actual_cost += $_actual_cost;
+
$actual_cost[$_account_value][$_dummy_district][$_dimb] += $_actual_cost;
+
$obligations[$_account_value][$_dummy_district][$_dimb] -= $_actual_cost;
+ $accout_info[$_account_value] = true;
+ $district[$_dummy_district] = true;
+ $ecodimb[(int)$this->db->f('dimb')] = true;
+ }
+
+
+//-------end check active invoices-----------
// end service agreements
$this->sum_budget_cost = $sum_budget_cost;
$this->sum_obligation_cost = $sum_obligation_cost;
Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php 2012-03-22 11:49:03 UTC (rev
9027)
+++ trunk/property/inc/class.soproject.inc.php 2012-03-22 14:25:47 UTC (rev
9028)
@@ -706,13 +706,26 @@
}
$project['combined_cost'] +=
($_sum - $__actual_cost);
- if($project['combined_cost'] < 0)
- {
- $project['combined_cost'] = 0;
- }
$project['actual_cost'] +=
$_actual_cost;
$project['billable_hours'] +=
(int)$this->db->f('billable_hours');
}
+
+ $sql_workder = 'SELECT godkjentbelop AS
actual_cost'
+ . " FROM fm_ecobilag {$this->join} fm_workorder
ON fm_ecobilag.pmwrkord_code = fm_workorder.id"
+ . " WHERE fm_workorder.project_id =
'{$project['project_id']}'";
+
+ $this->db->query($sql_workder);
+ while ($this->db->next_record())
+ {
+ $_actual_cost =
(int)$this->db->f('actual_cost');
+ $project['combined_cost'] +=
($_sum - $_actual_cost);
+ $project['actual_cost'] +=
$_actual_cost;
+ }
+
+ if($project['combined_cost'] < 0)
+ {
+ $project['combined_cost'] = 0;
+ }
}
$_datatype = array();
@@ -1513,6 +1526,15 @@
$year = substr(
$this->db->f('periode'), 0, 4 );
$cost_info[$year]['actual_cost'] +=
$this->db->f('actual_cost');
}
+
+ $sql = "SELECT sum(godkjentbelop) AS
actual_cost, periode FROM fm_ecobilag WHERE pmwrkord_code = '{$order}' GROUP BY
periode ORDER BY periode ASC ";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $year = substr(
$this->db->f('periode'), 0, 4 );
+ $cost_info[$year]['actual_cost'] +=
$this->db->f('actual_cost');
+ }
+
}
$config = CreateObject('phpgwapi.config','property');
@@ -1566,6 +1588,13 @@
{
$cost_info[$year]['sum_orders'] -=
$this->db->f('amount');
}
+
+ $sql = "SELECT godkjentbelop as amount FROM
fm_ecobilag WHERE pmwrkord_code = '{$order['order_id']}'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $cost_info[$year]['sum_orders'] -=
$this->db->f('amount');
+ }
}
$sort_year = array();
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2012-03-22 11:49:03 UTC
(rev 9027)
+++ trunk/property/inc/class.soworkorder.inc.php 2012-03-22 14:25:47 UTC
(rev 9028)
@@ -687,6 +687,22 @@
$workorder['loc' . ($m+1)] =
$location[$m];
$workorder['query_location']['loc' .
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
}
+
+ $sql_workder = 'SELECT godkjentbelop AS
actual_cost'
+ . " FROM fm_ecobilag WHERE pmwrkord_code =
'{$workorder['workorder_id']}'";
+
+ $this->db->query($sql_workder);
+ while ($this->db->next_record())
+ {
+ $_actual_cost =
(int)$this->db->f('actual_cost');
+ $workorder['combined_cost'] -=
$_actual_cost;
+ $workorder['actual_cost'] +=
$_actual_cost;
+ }
+
+ if($workorder['combined_cost'] < 0)
+ {
+ $workorder['combined_cost'] = 0;
+ }
}
return $workorder_list;
@@ -1087,8 +1103,19 @@
$old_billable_hours =
$this->db->f('billable_hours');
$old_approved = $this->db->f('approved');
- if ($this->db->f('calculation') > 0)
+ if
(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['currency']))
{
+ $workorder['contract_sum'] =
str_ireplace($GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],'',$workorder['contract_sum']);
+ }
+
+ $workorder['contract_sum'] =
str_replace(array(' ',','),array('','.'),$workorder['contract_sum']);
+
+ if ( abs((int)$workorder['contract_sum']) > 0)
+ {
+ $combined_cost =
(int)$workorder['contract_sum'];
+ }
+ else if ($this->db->f('calculation') > 0)
+ {
$calculation = $this->db->f('calculation');
$config =
CreateObject('phpgwapi.config','property');
$config->read_repository();
@@ -1115,13 +1142,6 @@
$paid = 2;
}
- if
(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['currency']))
- {
- $workorder['contract_sum'] =
str_ireplace($GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],'',$workorder['contract_sum']);
- }
- $workorder['contract_sum'] =
str_replace(array(' ',','),array('','.'),$workorder['contract_sum']);
-
-
$value_set = array
(
'title' =>
$workorder['title'],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9028] property: calculation on obligations,
Sigurd Nes <=