phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r5345 - in phpcompta/trunk: . include sql


From: phpcompta-dev
Subject: [Phpcompta-dev] r5345 - in phpcompta/trunk: . include sql
Date: Tue, 13 Aug 2013 03:14:15 +0200 (CEST)

Author: danydb
Date: 2013-08-13 03:14:15 +0200 (Tue, 13 Aug 2013)
New Revision: 5345

Modified:
   phpcompta/trunk/
   phpcompta/trunk/include/class_acc_ledger.php
   phpcompta/trunk/include/constant.php
   phpcompta/trunk/include/export_ledger_csv.php
   phpcompta/trunk/sql/upgrade.sql
Log:
Bug #0000873: Si achat utilisant le poste comptable dans DEP_PRIV alors le 
mettre en d?\195?\169pense privee


Property changes on: phpcompta/trunk
___________________________________________________________________
Name: svnmerge-integrated
   - /phpcompta/tags/rel660:1-5340
   + /phpcompta/tags/rel660:1-5342

Modified: phpcompta/trunk/include/class_acc_ledger.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger.php        2013-08-12 23:21:58 UTC 
(rev 5344)
+++ phpcompta/trunk/include/class_acc_ledger.php        2013-08-13 01:14:15 UTC 
(rev 5345)
@@ -511,11 +511,11 @@
 
        /** @brief  Get simplified row from ledger
         *
-        * @paramfrom periode
-        * @paramto periode
-        * @paramp_limit starting line
-        * @paramp_offset number of lines
-        * @paramtrunc if data must be truncated (pdf export)
+        * @param p_from periode
+        * @param p_to periode
+        * @param p_limit starting line
+        * @param p_offset number of lines
+        * @param trunc if data must be truncated (pdf export)
         *
         * \return an Array with the asked data
         */
@@ -1093,7 +1093,8 @@
                                $fiche_def_id = $fiche->get_fiche_def_ref_id();
                                // Customer or supplier
                                if ($fiche_def_id == FICHE_TYPE_CLIENT ||
-                                               $fiche_def_id == 
FICHE_TYPE_FOURNISSEUR)
+                                               $fiche_def_id == 
FICHE_TYPE_FOURNISSEUR
+                                        ||$fiche_def_id == FICHE_TYPE_ADM_TAX)
                                {
                                        $p_array['TVAC'] = $code['j_montant'];
 
@@ -1104,6 +1105,11 @@
                                                $p_array['reversed'] = true;
                                                $p_array['TVAC']*=-1;
                                        }
+                                       if ($fiche_def_id == FICHE_TYPE_ADM_TAX 
&& $code['j_debit'] == 'f')
+                                       {
+                                               $p_array['reversed'] = true;
+                                               $p_array['TVAC']*=-1;
+                                       }
                                        if ($fiche_def_id == 
FICHE_TYPE_FOURNISSEUR && $code['j_debit'] == 't')
                                        {
                                                $p_array['reversed'] = true;
@@ -1115,7 +1121,9 @@
                                        // if we use the ledger ven / ach for 
others card than supplier and customer
                                        if ($fiche_def_id != FICHE_TYPE_VENTE &&
                                                        $fiche_def_id != 
FICHE_TYPE_ACH_MAR &&
-                                                       $fiche_def_id != 
FICHE_TYPE_ACH_SER)
+                                                       $fiche_def_id != 
FICHE_TYPE_ACH_SER  &&
+                                                       $fiche_def_id != 
FICHE_TYPE_ACH_MAT
+                                           )                                   
             
                                        {
                                                $p_array['TVAC'] = 
$code['j_montant'];
 
@@ -1173,7 +1181,7 @@
                                $p_array['dep_priv'] = $dep_priv;
                        }
                }
-               $p_array['TVAC'] = sprintf('% 10.2f', $p_array['TVAC'] - 
$dep_priv);
+               $p_array['TVAC'] = sprintf('% 10.2f', $p_array['TVAC'] );
                $p_array['HTVA'] = sprintf('% 10.2f', $p_array['TVAC'] - 
$p_array['AMOUNT_TVA']);
                $r = "";
                $a_tva_amount = array();

Modified: phpcompta/trunk/include/constant.php
===================================================================
--- phpcompta/trunk/include/constant.php        2013-08-12 23:21:58 UTC (rev 
5344)
+++ phpcompta/trunk/include/constant.php        2013-08-13 01:14:15 UTC (rev 
5345)
@@ -179,6 +179,7 @@
 define ("FICHE_TYPE_ADM_TAX",14);
 define ("FICHE_TYPE_ACH_MAR",2);
 define ("FICHE_TYPE_ACH_SER",3);
+define ("FICHE_TYPE_ACH_MAT",7);
 
 
 define ('JS_INFOBULLE','

Modified: phpcompta/trunk/include/export_ledger_csv.php
===================================================================
--- phpcompta/trunk/include/export_ledger_csv.php       2013-08-12 23:21:58 UTC 
(rev 5344)
+++ phpcompta/trunk/include/export_ledger_csv.php       2013-08-13 01:14:15 UTC 
(rev 5345)
@@ -33,7 +33,6 @@
 
 require_once('class_database.php');
 require_once("class_acc_ledger.php");
-$cn=new Database($gDossier);
 
 
 require_once ('class_user.php');
@@ -145,16 +144,17 @@
                 $col_tva.='"Tva '.$line_tva['tva_label'].'";';
             }
         }
-        echo 
'"Date";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";'.$col_tva.'"TVAC"'."\n\r";
+        echo 
'"Date";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";privé;'.$col_tva.'"TVAC"'."\n\r";
         foreach ($Row as $line)
         {
-            printf('"%s";"%s";"%s";"%s";"%s";%s;',
+            printf('"%s";"%s";"%s";"%s";"%s";%s;%s;',
                    $line['date'],
                    $line['num'],
                    $Jrn->get_tiers($line['jrn_def_type'],$line['jr_id']),
                    $line['comment'],
                    $line['jr_internal'],
-                   nb($line['HTVA']));
+                   nb($line['HTVA']),
+                   nb($line['dep_priv']));
             $a_tva_amount=array();
             foreach ($line['TVA'] as $lineTVA)
             {

Modified: phpcompta/trunk/sql/upgrade.sql
===================================================================
--- phpcompta/trunk/sql/upgrade.sql     2013-08-12 23:21:58 UTC (rev 5344)
+++ phpcompta/trunk/sql/upgrade.sql     2013-08-13 01:14:15 UTC (rev 5345)
@@ -0,0 +1,63 @@
+-- si la fiche utilise le code DEPENSE PRIVEE alors ajout dans QP_DEP_PRIV
+with m as (select qp_id, qp_price from quant_purchase join fiche_detail on 
(qp_fiche=f_id and ad_id=5) where ad_value in (select p_value from parm_code 
where p_code='DEP_PRIV'))
+update quant_purchase as e set qp_dep_priv=(select qp_price from m where 
m.qp_id=e.qp_id);
+-- évite les valeurs nulles dans quant_purchase
+update quant_purchase set qp_dep_priv = 0 where qp_dep_priv is null;
+-- update script insert_quant_purchase
+
+CREATE OR REPLACE FUNCTION comptaproc.insert_quant_purchase(p_internal text, 
p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, 
p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, 
p_nd_tva_recup numeric, p_dep_priv numeric, p_client character varying, 
p_tva_sided numeric)
+  RETURNS void AS
+$BODY$
+declare
+        fid_client integer;
+        fid_good   integer;
+        account_priv    account_type;
+        fid_good_account account_type;
+begin
+       select p_value into account_priv from parm_code where p_code='DEP_PRIV';
+       
+        select f_id into fid_client from
+                fiche_detail where ad_id=23 and ad_value=upper(trim(p_client));
+        select f_id into fid_good from
+                 fiche_detail where ad_id=23 and ad_value=upper(trim(p_fiche));
+        select ad_value into fid_good_account from fiche_detail where ad_id=5 
and f_id=fid_good;
+
+        if account_priv = fid_good_account then
+               p_dep_priv=p_price;
+       end if;
+       
+        insert into quant_purchase
+                (qp_internal,
+                j_id,
+                qp_fiche,
+                qp_quantite,
+                qp_price,
+                qp_vat,
+                qp_vat_code,
+                qp_nd_amount,
+                qp_nd_tva,
+                qp_nd_tva_recup,
+                qp_supplier,
+                qp_dep_priv,
+                qp_vat_sided)
+        values
+                (p_internal,
+                p_j_id,
+                fid_good,
+                p_quant,
+                p_price,
+                p_vat,
+                p_vat_code,
+                p_nd_amount,
+                p_nd_tva,
+                p_nd_tva_recup,
+                fid_client,
+                p_dep_priv,
+                p_tva_sided);
+        return;
+end;
+ $BODY$
+  LANGUAGE plpgsql;
+
+
+



---
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]