noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 10/10: Task #0001904: Previsions et budgets A


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 10/10: Task #0001904: Previsions et budgets Ajout montant initial and estimation cumulée pour avoir évolution passif/actif
Date: Sun, 28 Mar 2021 09:22:06 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit b00558ee26ee265c0ebe43c6254e5eb22336d469
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Mar 28 15:21:47 2021 +0200

    Task #0001904: Previsions et budgets
    Ajout montant initial and estimation cumulée pour avoir évolution 
passif/actif
---
 include/class/anticipation.class.php            |  3 +-
 include/class/forecast_item_mtable.class.php    |  2 +
 include/database/forecast_item_sql.class.php    | 62 ++++++++++----------
 include/sql/patch/upgrade153.sql                |  2 +
 include/template/anticipation-display.php       | 77 +++++++++++++++++--------
 include/template/forecast_item_mtable-input.php | 13 +++++
 6 files changed, 103 insertions(+), 56 deletions(-)

diff --git a/include/class/anticipation.class.php 
b/include/class/anticipation.class.php
index 67360c1..a8abf88 100644
--- a/include/class/anticipation.class.php
+++ b/include/class/anticipation.class.php
@@ -220,7 +220,8 @@ EOF;
         for ($j = 0; $j < count($aCat); $j++) {
             
             // Item of the category, estimation for a specific month
-            $aItem[$j] = $this->cn->get_array('select 
fi_card,fi_account,fi_text,fi_amount,fi_debit 
+            $aItem[$j] = $this->cn->get_array('select 
fi_card,fi_account,fi_text,fi_amount,fi_debit ,
+                fi_amount_initial
                    from forecast_item where fc_id=$1  and fi_pid=0 order by 
fi_order ', 
                     array($aCat[$j]['fc_id']));
             
diff --git a/include/class/forecast_item_mtable.class.php 
b/include/class/forecast_item_mtable.class.php
index f659134..cbb4364 100644
--- a/include/class/forecast_item_mtable.class.php
+++ b/include/class/forecast_item_mtable.class.php
@@ -187,6 +187,8 @@ class Forecast_Item_MTable extends Manage_Table_SQL
         $object_sql->setp("fi_amount",$http->post('fi_amount',"number"));
         $object_sql->setp("fi_pid",$http->post('fi_pid',"number"));
         $object_sql->setp("fi_debit",$http->post('fi_debit'));
+        
$object_sql->setp("fi_amount_initial",$http->post("fi_amount_initial","number"));
+        
         $card=trim($http->post("fi_card"));
         if ( $card !="") {
             $f_id=$object_sql->cn->get_value("select f_id from fiche_detail 
where ad_value=upper($1) and ad_id=23",[$card]);
diff --git a/include/database/forecast_item_sql.class.php 
b/include/database/forecast_item_sql.class.php
index a86063a..0bafd8c 100644
--- a/include/database/forecast_item_sql.class.php
+++ b/include/database/forecast_item_sql.class.php
@@ -18,9 +18,8 @@
  *   along with NOALYSS; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-require_once NOALYSS_INCLUDE . '/lib/noalyss_sql.class.php';
-require_once NOALYSS_INCLUDE . '/class/database.class.php';
-
+require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
+require_once NOALYSS_INCLUDE.'/class/database.class.php';
 
 /**
  * class_forecast_item_sql.php
@@ -31,47 +30,48 @@ require_once NOALYSS_INCLUDE . '/class/database.class.php';
 class Forecast_Item_SQL extends Noalyss_SQL
 {
 
-    function __construct(DatabaseCore $p_cn, $p_id = -1)
+    function __construct(DatabaseCore $p_cn, $p_id=-1)
     {
-        $this->table = "public.forecast_item";
-        $this->primary_key = "fi_id";
+        $this->table="public.forecast_item";
+        $this->primary_key="fi_id";
         /*
          * List of columns
          */
-        $this->name = array(
-            "fi_id" => "fi_id"
-        , "fi_text" => "fi_text"
-        , "fi_account" => "fi_account"
-        , "fi_card" => "fi_card"
-        , "fi_order" => "fi_order"
-        , "fc_id" => "fc_id"
-        , "fi_amount" => "fi_amount"
-        , "fi_debit" => "fi_debit"
-        , "fi_pid" => "fi_pid"
+        $this->name=array(
+            "fi_id"=>"fi_id"
+            , "fi_text"=>"fi_text"
+            , "fi_account"=>"fi_account"
+            , "fi_card"=>"fi_card"
+            , "fi_order"=>"fi_order"
+            , "fc_id"=>"fc_id"
+            , "fi_amount"=>"fi_amount"
+            , "fi_debit"=>"fi_debit"
+            , "fi_pid"=>"fi_pid"
+            , "fi_amount_initial"=>"fi_amount_initial"
         );
         /*
          * Type of columns
          */
-        $this->type = array(
-            "fi_id" => "numeric"
-        , "fi_text" => "text"
-        , "fi_account" => "text"
-        , "fi_card" => "numeric"
-        , "fi_order" => "numeric"
-        , "fc_id" => "numeric"
-        , "fi_amount" => "numeric"
-        , "fi_debit" => "char"
-        , "fi_pid" => "numeric"
+        $this->type=array(
+            "fi_id"=>"numeric"
+            , "fi_text"=>"text"
+            , "fi_account"=>"text"
+            , "fi_card"=>"numeric"
+            , "fi_order"=>"numeric"
+            , "fc_id"=>"numeric"
+            , "fi_amount"=>"numeric"
+            , "fi_debit"=>"char"
+            , "fi_pid"=>"numeric"
+            , "fi_amount_initial"=>"numeric"
         );
 
 
-        $this->default = array(
-            "fi_id" => "auto"
+        $this->default=array(
+            "fi_id"=>"auto"
         );
 
-        $this->date_format = "DD.MM.YYYY";
+        $this->date_format="DD.MM.YYYY";
         parent::__construct($p_cn, $p_id);
     }
 
-
-}
\ No newline at end of file
+}
diff --git a/include/sql/patch/upgrade153.sql b/include/sql/patch/upgrade153.sql
index 03a2766..82ae3b0 100644
--- a/include/sql/patch/upgrade153.sql
+++ b/include/sql/patch/upgrade153.sql
@@ -1,5 +1,7 @@
 begin ;
 alter table forecast_cat rename to forecast_category;
 alter table forecast_category  alter f_id set not null;
+alter table forecast_item add fi_amount_initial numeric(20,4);
+alter table forecast_item alter fi_amount_initial set default 0;
 insert into version (val,v_description) values (154,'Rewriting of FORECAST');
 commit;
\ No newline at end of file
diff --git a/include/template/anticipation-display.php 
b/include/template/anticipation-display.php
index 393df5a..203a5dc 100644
--- a/include/template/anticipation-display.php
+++ b/include/template/anticipation-display.php
@@ -7,7 +7,7 @@ Période du <?php echo $str_start?> à <?php echo $str_end;?>
 <?php if (count($aItem[$i])==0) continue;?>
 <fieldset>
 <legend>
-<?php echo 
$aCat[$i]['fc_desc'];$tot_cat_estm=0;$tot_cat_real=0;$tot_cum_real=0;?>
+<?php echo 
$aCat[$i]['fc_desc'];$tot_cat_estm=0;$tot_cat_real=0;$tot_cum_real=0;$tot_cum_estm=[];?>
 </legend>
 
 <?php for ($e=0;$e<count($aItem[$i]);$e++):?>
@@ -39,9 +39,14 @@ Période du <?php echo $str_start?> à <?php echo $str_end;?>
 <td style="text-align:right;">
 <?php
 $amount=$aItem[$i][$e]['fi_amount'];
+$amount_initial=0;
+// -- if first periode , get the initial amou
+if ( $h == 0 ) {
+    $amount_initial=$aItem[$i][$e]['fi_amount_initial'];
+}
 if (count($aPerMonth[$i]) != 0 ){
        for ($x=0;$x<count($aPerMonth[$i]);$x++) {
-            if (DEBUGNOALYSS>2) {
+            if (DEBUGNOALYSS>1) {
                 printf (" \$aItem [$i] [$e] = %s",$aItem[$i][$e]['fi_amount']);
                 echo  p("\$aPeriode[$h]['p_id']==\$aPerMonth[$i][$x]['fi_pid'] 
".
                         
$aPeriode[$h]['p_id']."==".$aPerMonth[$i][$x]['fi_pid'] );
@@ -85,10 +90,11 @@ if (count($aPerMonth[$i]) != 0 ){
                 }
        }
 }
+$amount=bcadd($amount,$amount_initial);
 $estm[$i][$e][$h]=$amount;
 echo nbm( $amount);
-
 $tot_estm=bcadd($tot_estm,$amount);
+$tot_cum_estm[$h]=$tot_estm;
 $tot_cat_estm=bcadd($amount,$tot_cat_estm);
 ?>
 
@@ -99,13 +105,15 @@ $tot_cat_estm=bcadd($amount,$tot_cat_estm);
 </td>
 </tr>
 
+
 <tr>
 <td>
 <?php echo _('Réel');$tot=0;?>
 </td>
 <?php for ($h=0;$h<count($aPeriode);$h++):?>
 <td align="right">
-   <?php echo nbm(  
$aReal[$i][$e][$h]);$tot_cat_real=bcadd($tot_cat_real,$aReal[$i][$e][$h]);
+   <?php echo nbm(  $aReal[$i][$e][$h]);
+   $tot_cat_real=bcadd($tot_cat_real,$aReal[$i][$e][$h]);
    $tot=bcadd($tot,$aReal[$i][$e][$h]);?>
 </td>
 <?php endfor;?>
@@ -113,24 +121,40 @@ $tot_cat_estm=bcadd($amount,$tot_cat_estm);
 <?php echo nbm( $tot);?>
 </td>
 </tr>
-               <tr>
-                       <td>
-                                               <?php echo _('Total réel');
-
-                                               $tot_cat_real = 0;
-                                               ?>
-                                       </td>
-                               <?php for ($h = 0; $h < count($aPeriode); 
$h++):?>
-                               <td align="right">
-                               <?php
-                               $tot_cat_real = bcadd($tot_cat_real, 
$aReal[$i][$e][$h]);
-                               
$tot_cum_real=bcadd($tot_cum_real,$aReal[$i][$e][$h]);
-                               echo nbm($tot_cat_real);
-                       ?>
-                       </td>
-                               <?php endfor;?>
-
-               </tr>
+<tr>
+    <td>
+        <?=_('Total estimé')?>
+    </td>
+    <?php
+    /// row about cum. estimate amount
+     for ($h=0;$h<count($aPeriode);$h++):
+    ?>
+    <td class="num">
+        <?=nbm($tot_cum_estm[$h])?>
+    </td>
+    <?php
+     endfor;
+    ?>
+</tr>
+
+<tr>
+        <td>
+            <?php echo _('Total réel');
+
+            $tot_cat_real = 0;
+            ?>
+        </td>
+            <?php for ($h = 0; $h < count($aPeriode); $h++):?>
+            <td align="right">
+            <?php
+            $tot_cat_real = bcadd($tot_cat_real, $aReal[$i][$e][$h]);
+            $tot_cum_real=bcadd($tot_cum_real,$aReal[$i][$e][$h]);
+            echo nbm($tot_cat_real);
+    ?>
+        </td>
+                <?php endfor;?>
+
+</tr>
 <tr>
 <td>
 <?php echo _('Différence');?>
@@ -139,7 +163,8 @@ $tot_cat_estm=bcadd($amount,$tot_cat_estm);
 
     <?php
  $diff= bcsub( $aReal[$i][$e][$h],$estm[$i][$e][$h]);
-if ( ($aItem[$i][$e]['fi_debit'] == 'C' && $diff < 0) || 
($aItem[$i][$e]['fi_debit'] == 'D' && $diff > 0))
+if (       ( $aItem[$i][$e]['fi_card']!="" && $aItem[$i][$e]['fi_debit'] == 
'C' && $diff < 0) 
+        || ($aItem[$i][$e]['fi_card'] && $aItem[$i][$e]['fi_debit'] == 'D' && 
$diff > 0))
   {
     echo '<td style="text-align:right;background-color:red;color:white">';
   }
@@ -147,10 +172,14 @@ else if ($diff==0)
   {
     echo '<td style="text-align:right;">';
   }
-else
+elseif ( $aItem[$i][$e]['fi_account']!="" && $diff > 0 )
   {
     echo '<td style="text-align:right;background-color:green;color:white">';
   }
+  elseif ( $aItem[$i][$e]['fi_account']!="" && $diff < 0 ) {
+    echo '<td style="text-align:right;background-color:red;color:white">';
+      
+  }
 
 echo nbm( $diff);
 ?>
diff --git a/include/template/forecast_item_mtable-input.php 
b/include/template/forecast_item_mtable-input.php
index 4a72c98..b133da5 100644
--- a/include/template/forecast_item_mtable-input.php
+++ b/include/template/forecast_item_mtable-input.php
@@ -98,6 +98,11 @@ $isDebit->selected=$object->getp("fi_debit");
 $isPeriode = new ISelect('fi_pid');
 $isPeriode->value = $aPeriode;
 $isPeriode->selected = $object->getp("fi_pid");
+
+$amount_initial= new INum("fi_amount_initial");
+$amount_initial->value=$object->getp("fi_amount_initial");
+$amount_initial->value=($amount_initial->value=='')?0:$amount_initial->value;
+
 ?>
 <table style="width:50rem">
     <tr>
@@ -146,5 +151,13 @@ $isPeriode->selected = $object->getp("fi_pid");
         <td><?= _("Montant") ?></td>
         <td><?= $amount->input(); ?></td>
     </tr>
+    <tr>
+        <td>
+            <?=_("Montant initial")?>
+        </td>
+        <td>
+            <?=$amount_initial->input()?>
+        </td>
+    </tr>
 
 </table>



reply via email to

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