phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r692 - trunk/transform/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r692 - trunk/transform/include
Date: Fri, 7 Feb 2014 22:04:46 +0100 (CET)

Author: danydb
Date: 2014-02-07 22:04:46 +0100 (Fri, 07 Feb 2014)
New Revision: 692

Modified:
   trunk/transform/include/class_transform_client.php
Log:
Amount with 2 decimal

Modified: trunk/transform/include/class_transform_client.php
===================================================================
--- trunk/transform/include/class_transform_client.php  2014-02-07 20:03:54 UTC 
(rev 691)
+++ trunk/transform/include/class_transform_client.php  2014-02-07 21:04:46 UTC 
(rev 692)
@@ -54,25 +54,39 @@
     function compute_value($p_declarant)
     {
         global $cn;
-        $this->correct_data($p_declarant);
-        $this->array = $cn->get_array('select * from transform.intervat_client 
where d_id=$1', array($p_declarant));
+        $this->array = $cn->get_array("select * from transform.intervat_client 
+                where 
+                d_id=$1 and
+                coalesce(c_comment,'') = ''"
+                , array($p_declarant));
         $this->nb = count($this->array);
         
-        $this->vat_amount_sum = $cn->get_value('select 
sum(c_amount_vat::numeric) from 
-            transform.intervat_client where d_id=$1',array($p_declarant));
+        $this->vat_amount_sum = $cn->get_value("
+            select sum(c_amount_vat::numeric) from 
+            transform.intervat_client where d_id=$1 and
+                coalesce(c_comment,'') = ''",array($p_declarant));
         
-        $this->turnoversum = $cn->get_value('select 
sum(c_amount_novat::numeric) from 
-            transform.intervat_client where d_id=$1',array($p_declarant));
+        $this->turnoversum = $cn->get_value("select 
sum(c_amount_novat::numeric) from 
+            transform.intervat_client where d_id=$1 and
+                coalesce(c_comment,'') = ''",array($p_declarant));
     }
-    private function correct_data($p_declarant)
+    private function correct_comment()
     {
-        global $cn;
-        $cn->exec_sql("update transform.intervat_client set 
c_amount_vat=replace(c_amount_vat,',','.'),
-            c_amount_novat=replace(c_amount_novat,',','.') where 
d_id=$1",array($p_declarant));
+        $this->c_vatnumber=str_replace('BE','',$this->c_vatnumber);
+        $this->c_vatnumber=str_replace(',','',$this->c_vatnumber);
+        $this->c_vatnumber=str_replace('.','',$this->c_vatnumber);
+        $this->c_vatnumber=str_replace('-','',$this->c_vatnumber);
     }
+    private function correct_amount()
+    {
+        $this->c_amount_novat=  str_replace(',', '.', $this->c_amount_novat);
+        $this->c_amount_vat=  str_replace(',', '.', $this->c_amount_vat);
+    }
     function set_comment()
     {
         $this->c_comment="";
+        $this->correct_comment();
+        $this->correct_amount();
         if ( ! preg_match('/^[0-9]{10}/', $this->c_vatnumber))
         {
             $this->c_comment=_('Numéro de tva incorrect');



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