phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4940 - phpcompta/trunk/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4940 - phpcompta/trunk/include
Date: Tue, 19 Jun 2012 15:17:18 +0200 (CEST)

Author: danydb
Date: 2012-06-19 15:17:18 +0200 (Tue, 19 Jun 2012)
New Revision: 4940

Modified:
   phpcompta/trunk/include/class_acc_ledger_purchase.php
   phpcompta/trunk/include/class_acc_ledger_sold.php
   phpcompta/trunk/include/class_stock_goods.php
Log:
0000641: Nettoyage fichier stock

Modified: phpcompta/trunk/include/class_acc_ledger_purchase.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_purchase.php       2012-06-19 
13:01:33 UTC (rev 4939)
+++ phpcompta/trunk/include/class_acc_ledger_purchase.php       2012-06-19 
13:17:18 UTC (rev 4940)
@@ -41,6 +41,7 @@
 require_once('class_itva_popup.php');
 require_once('class_acc_ledger_info.php');
 require_once('class_acc_ledger_fin.php');
+require_once 'class_stock_goods.php';
 
 /*!\brief Handle the ledger of purchase,
  *
@@ -472,7 +473,7 @@
                 // always save quantity but in withStock we can find
                 // what card need a stock management
                 if ( $g_parameter->MY_STOCK='Y')
-                    
InsertStockGoods($this->db,$j_id,${'e_march'.$i},$nNeg*${'e_quant'.$i},'d',$repo)
 ;
+                    
Stock_Goods::insert_goods(array('db'=>$this->db,'j_id'=>$j_id,'goods'=>${'e_march'.$i},'quant'=>$nNeg*${'e_quant'.$i},'dir'=>'d','repo'=>$repo))
 ;
 
                 if ( $g_parameter->MY_ANALYTIC != "nu" )
                 {

Modified: phpcompta/trunk/include/class_acc_ledger_sold.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_sold.php   2012-06-19 13:01:33 UTC 
(rev 4939)
+++ phpcompta/trunk/include/class_acc_ledger_sold.php   2012-06-19 13:17:18 UTC 
(rev 4940)
@@ -350,11 +350,12 @@
                        {"e_quant".$i
                        }
                        <0)?-1:1;
-
+                
                 // always save quantity but in withStock we can find
                 // what card need a stock management
                 if ( $g_parameter->MY_STOCK='Y')
-                    
InsertStockGoods($this->db,$j_id,${'e_march'.$i},$nNeg*${'e_quant'.$i},'c',$repo)
 ;
+                    
Stock_Goods::insert_goods(array('db'=>$this->db,'j_id'=>$j_id,'goods'=>${'e_march'.$i},'quant'=>$nNeg*${'e_quant'.$i},'dir'=>'c','repo'=>$repo))
 ;
+                    
 
                 if ( $g_parameter->MY_ANALYTIC != "nu" )
                 {

Modified: phpcompta/trunk/include/class_stock_goods.php
===================================================================
--- phpcompta/trunk/include/class_stock_goods.php       2012-06-19 13:01:33 UTC 
(rev 4939)
+++ phpcompta/trunk/include/class_stock_goods.php       2012-06-19 13:17:18 UTC 
(rev 4940)
@@ -121,7 +121,48 @@
                        throw $exc;
                }
        }
+        /**
+         * Insert into stock_goods from ACH and VEN
+         * @param type $p_array KEY : db => database conx, j_id => 
jrnx.j_id,goods=> f_id of the goods 
+         * 'quant' => quantity ,'dir'=> d or c (c for sales OUT and d for 
purchase IN),'repo'=>r_id of the
+         * repository (stock_repository.r_id
+         */
+        static function insert_goods(&$p_cn,$p_array)
+        {
+            global $g_user;
+            if ($g_user->can_write_repo($p_depot) == false)
+                return false;
 
+            // Retrieve the good account for stock
+            $code = new Fiche($p_cn);
+            $code->get_by_qcode($p_good);
+            $code_marchandise = $code->strAttribut(ATTR_DEF_STOCK);
+            if ($code_marchandise == NOTFOUND || $code_marchandise=='')
+                return false;
+
+            $exercice = $g_user->get_exercice();
+
+            if ($exercice == 0)
+                throw new Exception('Annee invalide erreur');
+
+            $Res = $p_cn->exec_sql("insert into stock_goods (
+                            j_id,
+                            f_id,
+                            sg_code,
+                            sg_quantity,
+                            sg_type,sg_exercice,r_id ) values 
($1,$2,$3,$4,$5,$6,$7)", array(
+                $p_array['j_id'],
+                $code->id,
+                $code_marchandise,
+                $p_array['quant'],
+                $p_array['dir'],
+                $exercice,
+                $p_array['repo']
+                    )
+            );
+           return $Res;
+    }
+
 }
 
 ?>



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

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