fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10740] property: budget handling


From: Sigurd Nes
Subject: [Fmsystem-commits] [10740] property: budget handling
Date: Fri, 01 Feb 2013 09:22:25 +0000

Revision: 10740
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10740
Author:   sigurdne
Date:     2013-02-01 09:22:23 +0000 (Fri, 01 Feb 2013)
Log Message:
-----------
property: budget handling

Modified Paths:
--------------
    trunk/property/inc/class.soproject.inc.php
    trunk/property/inc/class.uiproject.inc.php

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2013-01-31 15:11:34 UTC (rev 
10739)
+++ trunk/property/inc/class.soproject.inc.php  2013-02-01 09:22:23 UTC (rev 
10740)
@@ -2586,6 +2586,7 @@
 
                        $id = (int) $id;
                        $year = (int) $year;
+                       $latest_year = (int)$budget['latest_year'];
                        $this->db->query("SELECT periodization_id, 
project_type_id FROM fm_project WHERE id = {$id}",__LINE__,__FILE__);
                        $this->db->next_record();
                        $periodization_id = $this->db->f('periodization_id');
@@ -2593,21 +2594,39 @@
 
                        if($project_type_id == 2) // investment
                        {
-//get active sum..
-throw new Exception('property_soproject::transfer_budget() - FIXME:get active 
sum..');
-                               $transferred = $this->update_budget($id, 
$budget['latest_year'], $periodization_id, $budget['obligation'], false, 
'subtract');
+                               // total budget
+                               $this->db->query("SELECT budget FROM 
fm_project_budget WHERE project_id = {$id} AND year = 
{$latest_year}",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $last_budget = $this->db->f('budget');
+                               if(!$last_budget)
+                               {
+                                       throw new 
Exception('property_soproject::transfer_budget() - no budget to transfer for 
this investment project: ' . $id);
+                               }
+
+                               //paid last year
+                               $this->db->query("SELECT sum(amount) as paid 
FROM fm_project"
+                               . " {$this->join} fm_workorder ON fm_project.id 
= fm_workorder.project_id"
+                               . " {$this->join} 
fm_orders_paid_or_pending_view ON fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id"
+                               . " WHERE periode > {$latest_year}00 AND 
periode < {$latest_year}13 AND fm_project.id = {$id}",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $paid_last_year = $this->db->f('paid');
+                               
+                               $subtract = $last_budget - $paid_last_year;
+//_debug_array($subtract);die();
+                               $transferred = $this->update_budget($id, 
$latest_year, $periodization_id, $subtract, false, 'subtract');                 
               
+
+                               $new_budget = $last_budget - $paid_last_year;
+                               $this->update_budget($id, $year, 
$periodization_id, $new_budget, true, 'update', true);
                        }
-
-                       if($project_type_id == 1)//operation
+                       else if($project_type_id == 1)//operation
                        {
                                $this->db->query("UPDATE fm_project_budget SET 
active = 0 WHERE project_id = {$id}",__LINE__,__FILE__);
+                               if($budget['budget_amount'])
+                               {
+                                       $this->update_budget($id, $year, 
$periodization_id, (int)$budget['budget_amount'], true, 'update', true);
+                               }
                        }                       
-
-                       if($budget['budget_amount'])
-                       {
-                               $this->update_budget($id, $year, 
$periodization_id, (int)$budget['budget_amount'], true, 'update', true);
-                       }
-                       
+               
                        $this->db->transaction_commit();
                }
 

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2013-01-31 15:11:34 UTC (rev 
10739)
+++ trunk/property/inc/class.uiproject.inc.php  2013-02-01 09:22:23 UTC (rev 
10740)
@@ -2394,7 +2394,7 @@
                                $_obligation = '';
                                $entry['new_budget'] = '';
 
-                               if($entry['project_type_id'] != 3)
+                               if($entry['project_type_id'] == 1) // operation
                                {
                                        $_obligation = 0;
                                        $_order = 0;
@@ -2429,6 +2429,16 @@
                                                
                                        }
                                }
+                               else if ($entry['project_type_id'] == 2)
+                               {
+                                       $entry['new_budget'] = 'auto';
+                                       $entry['new_budget'] .= "<input 
type='hidden' class='myValuesForPHP' id='{$entry['id']}::latest_year' 
name='{$entry['id']}::latest_year' value='{$entry['latest_year']}'></input>";
+                               }
+                               else if ($entry['project_type_id'] == 3)
+                               {
+                                       $entry['budget'] = '';
+                               }
+
                                $entry['obligation'] = $_obligation;
                        }
 




reply via email to

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