noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 08/10: Task #1076 - ANC : comptabilité analy


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 08/10: Task #1076 - ANC : comptabilité analytique et montants négatifs Negative amount are supposed to be used only for sale and purchase, for bank a fee is always on the debit and a product on the credit.
Date: Tue, 30 Dec 2014 10:31:32 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 59916811eecfa0799a16176db0b9c5a5296bf1cb
Author: Dany De Bontridder <address@hidden>
Date:   Wed Dec 24 13:58:24 2014 +0100

    Task #1076 - ANC : comptabilité analytique et montants négatifs
    Negative amount are supposed to be used only for sale and purchase, for 
bank a fee is always on the debit and a product on the credit.
---
 include/class_acc_ledger_fin.php      |    2 +-
 include/class_acc_ledger_purchase.php |    4 ++--
 include/class_acc_ledger_sold.php     |    2 +-
 include/class_anc_operation.php       |   29 ++++++++++++++++++++++++-----
 4 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php
index bbea164..21edd7e 100644
--- a/include/class_acc_ledger_fin.php
+++ b/include/class_acc_ledger_fin.php
@@ -921,7 +921,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
                                        $op->oa_group = 
$this->db->get_next_seq("s_oa_group"); /* for analytic */
                                        $op->j_id = $j_id;
                                        $op->oa_date = $e_date;
-                                       $op->oa_debit = ($amount < 0 ) ? 't' : 
'f';
+                                       $op->oa_debit = 'f';
                                        $op->oa_description = 
sql_string($comment);
                                        $op->save_form_plan($_POST, $i, $j_id);
                                }
diff --git a/include/class_acc_ledger_purchase.php 
b/include/class_acc_ledger_purchase.php
index 8a0e674..a0c6530 100644
--- a/include/class_acc_ledger_purchase.php
+++ b/include/class_acc_ledger_purchase.php
@@ -399,7 +399,7 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
                 $op->j_id=$j_id;
                 $op->oa_date=$p_acc_operation->date;
 
-                $op->oa_debit=($p_nd_amount->nd_vat > 0 )?'t':'f';
+                $op->oa_debit='t';
                 $op->oa_description=sql_string('ND_TVA');
                 $op->oa_jrnx_id_source=$source_j_id;
                 
$op->save_form_plan_vat_nd($_POST,$idx,$j_id,$p_nd_amount->nd_vat,$p_acc_operation->jrnx_id);
@@ -438,7 +438,7 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
                 $op->j_id=$j_id;
                 $op->oa_date=$p_acc_operation->date;
 
-                $op->oa_debit=($p_nd_amount->nd_ded_vat > 0 )?'t':'f';
+                $op->oa_debit='t';
                 $op->oa_description=sql_string('DED_TVA ');
                 $op->oa_jrnx_id_source=$source_j_id;
                 
$op->save_form_plan_vat_nd($_POST,$idx,$j_id,$p_nd_amount->nd_ded_vat);
diff --git a/include/class_acc_ledger_sold.php 
b/include/class_acc_ledger_sold.php
index 4449a73..8495eff 100644
--- a/include/class_acc_ledger_sold.php
+++ b/include/class_acc_ledger_sold.php
@@ -355,7 +355,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
                     $op->oa_group = $group;
                     $op->j_id = $j_id;
                     $op->oa_date = $e_date;
-                    $op->oa_debit = ($amount < 0 ) ? 't' : 'f';
+                    $op->oa_debit = 'f';
                     $op->oa_description = sql_string($e_comm);
                     $op->save_form_plan($_POST, $i, $j_id);
                 }
diff --git a/include/class_anc_operation.php b/include/class_anc_operation.php
index 6fa9278..011d7f7 100644
--- a/include/class_anc_operation.php
+++ b/include/class_anc_operation.php
@@ -788,13 +788,20 @@ class Anc_Operation
         extract($p_array);
         for ($i = 0; $i < count($op); $i++)
         {
-            /* clean jrnx */
+            /* clean operation_analytique */
             $this->db->exec_sql('delete from operation_analytique where 
j_id=$1', array($op[$i]));
 
             /* get missing data for adding */
-            $a_missing = $this->db->get_array("select 
to_char(jr_date,'DD.MM.YYYY') as mdate,j_montant,j_debit,jr_comment from jrnx 
join jrn on (j_grpt=jr_grpt_id) where j_id=$1", array($op[$i]));
+            $a_missing = $this->db->get_array("select 
to_char(jr_date,'DD.MM.YYYY') 
+                    as mdate,j_montant,j_debit,jr_comment ,j_poste
+                    from jrnx join jrn on (j_grpt=jr_grpt_id) where j_id=$1", 
array($op[$i]));
             $missing = $a_missing[0];
-            $this->oa_debit = $missing['j_debit'];
+            $poste=substr(trim($missing['j_poste']),0,1);
+            if ( $poste == 6 || $poste == 7)  {
+                $this->oa_debit = ($poste == 6) ?'t':'f';
+            }else {
+                $this->oa_debit=$missing['j_debit'];
+            }
             $this->oa_description = $missing['jr_comment'];
             $this->j_id = $op[$i];
             $group = $this->db->get_next_seq("s_oa_group"); /* for analytic */
@@ -814,7 +821,7 @@ class Anc_Operation
                     /* get missing data for adding */
                     $a_missing_vat = $this->db->get_array("select 
to_char(jr_date,'DD.MM.YYYY') as mdate,j_montant,j_debit,jr_comment from jrnx 
join jrn on (j_grpt=jr_grpt_id) where j_id=$1", array($a_nd[$e]['j_id']));
                     $missing_vat = $a_missing_vat[0];
-                    $this->oa_debit = $missing_vat['j_debit'];
+                    $this->oa_debit = 't';
                     $this->oa_description = $missing_vat['jr_comment'];
                     $this->j_id = $op[$i];
                     $group = $this->db->get_next_seq("s_oa_group"); /* for 
analytic */
@@ -857,9 +864,21 @@ class Anc_Operation
         $result['hplan']=$hplan;
         /* Add the amount */
         $idx_pa=0;
+        $jrn_def=$this->db->get_value('select jrn_def_type from jrnx join 
jrn_def on (j_jrn_def=jrn_def_id) where j_id=$1',array($this->j_id));
         for ($i=0;$i < count($p_array);$i++)
         {
-            
$val[$p_line][$p_array[$i]->oa_row]=($p_array[$i]->oa_positive=='Y')?$p_array[$i]->oa_amount:($p_array[$i]->oa_amount*(-1));
+            
+            /*
+             * For the bank, negatif are always on the debit and positif on 
the credit
+             */
+            if ( $jrn_def != 'FIN')
+            {
+                
$val[$p_line][$p_array[$i]->oa_row]=($p_array[$i]->oa_positive=='Y')?$p_array[$i]->oa_amount:($p_array[$i]->oa_amount*(-1));
+            }
+            else
+            {
+                $val[$p_line][$p_array[$i]->oa_row]=$p_array[$i]->oa_amount;
+            }
         }
         $result['val']=$val;
         return $result;



reply via email to

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