phpcompta-dev
[Top][All Lists]
Advanced

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

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


From: phpcompta-dev
Subject: [Phpcompta-dev] r4871 - phpcompta/trunk/include
Date: Sat, 9 Jun 2012 15:51:28 +0200 (CEST)

Author: danydb
Date: 2012-06-09 15:51:27 +0200 (Sat, 09 Jun 2012)
New Revision: 4871

Modified:
   phpcompta/trunk/include/class_acc_account_ledger.php
   phpcompta/trunk/include/class_fiche.php
   phpcompta/trunk/include/export_fiche_balance_csv.php
   phpcompta/trunk/include/export_fiche_balance_pdf.php
   phpcompta/trunk/include/export_gl_csv.php
   phpcompta/trunk/include/export_gl_pdf.php
   phpcompta/trunk/include/impress_fiche.inc.php
   phpcompta/trunk/include/impress_gl_comptes.inc.php
Log:
0000566: Harmoniser les soldes cumul?\195?\169es

Modified: phpcompta/trunk/include/class_acc_account_ledger.php
===================================================================
--- phpcompta/trunk/include/class_acc_account_ledger.php        2012-06-08 
09:25:01 UTC (rev 4870)
+++ phpcompta/trunk/include/class_acc_account_ledger.php        2012-06-09 
13:51:27 UTC (rev 4871)
@@ -365,7 +365,7 @@
                if ( $old_exercice != '')
                  {
                    $progress=bcsub($sum_deb,$sum_cred);
-
+                       $side=" ".$this->get_amount_side($progress);
                    echo "<TR style=\"font-weight:bold\">".
                      "<TD></TD>".
                      td('').
@@ -373,7 +373,7 @@
                      "<TD>Totaux</TD>".
                      "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
                      "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
-                     td(nbm(abs($progress)),'style="text-align:right"').
+                     td(nbm(abs($progress)).$side,'style="text-align:right"').
                      td('').
                      "</TR>";
                    $sum_cred=0;
@@ -383,6 +383,7 @@
                  }
              }
            $progress=bcadd($progress,$tmp_diff);
+               $side="&nbsp;".$this->get_amount_side($progress);
            $sum_cred=bcadd($sum_cred,$op['cred_montant']);
            $sum_deb=bcadd($sum_deb,$op['deb_montant']);
                if ($idx%2 == 0) $class='class="odd"'; else $class=' 
class="even"';
@@ -395,7 +396,7 @@
              "<TD>".h($op['description'])."</TD>".
              "<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
              "<TD 
style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
-             td(nbm(abs($progress)),'style="text-align:right"').
+             td(nbm(abs($progress)).$side,'style="text-align:right"').
 
              td($let,' style="color:red;text-align:right"').
              "</TR>";
@@ -403,19 +404,19 @@
         }
         echo '<tfoot>';
         $solde_type=($sum_deb>$sum_cred)?"solde débiteur":"solde créditeur";
-        $diff=abs(bcsub($sum_deb,$sum_cred));
-
+        $diff=bcsub($sum_deb,$sum_cred);
+               $side="&nbsp;".$this->get_amount_side($diff);
         echo "<TR style=\"font-weight:bold\">".
         "<TD >Totaux</TD><td></td>".
         "<TD ></TD>".
         "<TD></TD>".
          "<TD  style=\"text-align:right\">".nbm($sum_deb)."</TD>".
          "<TD  style=\"text-align:right\">".nbm($sum_cred)."</TD>".
-         "<TD style=\"text-align:right\">".nbm($diff)."</TD>".
+         "<TD style=\"text-align:right\">".nbm(abs($diff)).$side."</TD>".
 
         "</TR>";
        echo   "<tr><TD>$solde_type</TD><td></td>".
-         "<TD style=\"text-align:right\">".nbm($diff)."</TD>".
+         "<TD style=\"text-align:right\">".nbm(abs($diff))."</TD>".
         "</TR>";
         echo '</tfoot>';
         echo '</tbody>';
@@ -424,7 +425,20 @@
 
         return;
     }
-
+       /**
+        * return the letter C if amount is > 0, D if < 0 or =
+        * @param type $p_amount
+        * @return string
+        */
+       function get_amount_side($p_amount)
+               {
+                       if ($p_amount == 0)
+                               return "=";
+                       if ($p_amount < 0)
+                               return "C";
+                       if ($p_amount > 0)
+                               return "D";
+               }
     /*!
      * \brief Display HTML Table Header (button)
      *

Modified: phpcompta/trunk/include/class_fiche.php
===================================================================
--- phpcompta/trunk/include/class_fiche.php     2012-06-08 09:25:01 UTC (rev 
4870)
+++ phpcompta/trunk/include/class_fiche.php     2012-06-09 13:51:27 UTC (rev 
4871)
@@ -1347,7 +1347,7 @@
                if ($old_exercice != '' )
                  {
                    $progress=bcsub($sum_deb,$sum_cred);
-
+                       $side="&nbsp;".$this->get_amount_side($progress);
                    echo "<TR  style=\"font-weight:bold\">".
                      "<TD></TD>".
                      td('').
@@ -1355,7 +1355,7 @@
                      "<TD>Totaux</TD>".
                      "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
                      "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
-                     td(nbm(abs($progress)),'style="text-align:right"').
+                     td(nbm(abs($progress)).$side,'style="text-align:right"').
                      td('').
                      "</TR>";
                    $sum_cred=0;
@@ -1364,6 +1364,7 @@
                  }
              }
             $progress=bcadd($progress,$tmp_diff);
+                       $side="&nbsp;".$this->get_amount_side($progress);
            $sum_cred=bcadd($sum_cred,$op['cred_montant']);
            $sum_deb=bcadd($sum_deb,$op['deb_montant']);
                if ($idx%2 == 0) $class='class="odd"'; else $class=' 
class="even"';
@@ -1376,7 +1377,7 @@
             "<TD>".h($op['description'])."</TD>".
             "<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
              "<TD 
style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
-             td(nbm(abs($progress)),'style="text-align:right"').
+             td(nbm(abs($progress)).$side,'style="text-align:right"').
             td($let,' style="color:red;text-align:right"').
             "</TR>";
            $old_exercice=$op['p_exercice'];
@@ -1894,7 +1895,20 @@
         $this->cn->exec_sql("insert into jnt_fic_attr (fd_id,ad_id,jnt_order) 
select $1,ad_id,100 from fiche_detail where f_id=$2 and ad_id not in (select 
ad_id from jnt_fic_attr where fd_id=$3)",array($p_fdid,$this->id,$p_fdid));
         $this->cn->commit();
     }
-
+       /**
+        * return the letter C if amount is > 0, D if < 0 or =
+        * @param type $p_amount
+        * @return string
+        */
+       function get_amount_side($p_amount)
+       {
+               if ($p_amount == 0)
+                       return "=";
+               if ($p_amount < 0)
+                       return "C";
+               if ($p_amount > 0)
+                       return "D";
+       }
     static function test_me()
     {
         $cn=new Database(dossier::id());

Modified: phpcompta/trunk/include/export_fiche_balance_csv.php
===================================================================
--- phpcompta/trunk/include/export_fiche_balance_csv.php        2012-06-08 
09:25:01 UTC (rev 4870)
+++ phpcompta/trunk/include/export_fiche_balance_csv.php        2012-06-09 
13:51:27 UTC (rev 4871)
@@ -98,6 +98,7 @@
        {
                $afiche[0] = array('fd_id' => $_REQUEST['cat']);
        }
+       $fic=new Fiche($cn);
        for ($e = 0; $e < count($afiche); $e++)
        {
                $array = Fiche::get_fiche_def($cn, $afiche[$e]['fd_id'], 
'name_asc');
@@ -142,6 +143,7 @@
                                _('Débit'),
                                _('Crébit'),
                                _('Prog.'),
+                               _('D/C'),
                                _('Let.'),
                                        _("Diff Let."));
                        printf("\n");
@@ -159,7 +161,7 @@
                                if ($row['j_debit'] == 't')
                                {
                                        printf("%s;",nb($row['j_montant']));
-                                       $amount_deb+=$row['j_montant'];
+                                       
$amount_deb=bcadd($amount_deb,$row['j_montant']);
                                        $prog = bcadd($prog, $row['j_montant']);
                                        printf (";");
                                }
@@ -167,10 +169,10 @@
                                {
                                        printf(";");
                                        printf("%s;",nb($row['j_montant']));
-                                       $amount_cred+=$row['j_montant'];
+                                       
$amount_cred=bcadd($amount_cred,$row['j_montant']);
                                        $prog = bcsub($prog, $row['j_montant']);
                                }
-                               printf ("%s;",nb($prog));
+                               printf 
("%s;\"%s\";",abs(nb($prog)),$fic->get_amount_side($prog));
                                if ($row['letter'] != -1)
                                {
                                        printf('"%s";',$row['letter']);
@@ -187,8 +189,8 @@
                        else
                                $msg="soldé";
 
-                       printf(';;;"%s";%s;%s;%s',
-                                       
$msg,nb($amount_deb),nb($amount_cred),nb($prog));
+                       printf(';;;"%s";%s;%s;%s;"%s"',
+                                       
$msg,nb($amount_deb),nb($amount_cred),nb(abs($prog)),$fic->get_amount_side($prog));
                        printf("\n");
                }
        }

Modified: phpcompta/trunk/include/export_fiche_balance_pdf.php
===================================================================
--- phpcompta/trunk/include/export_fiche_balance_pdf.php        2012-06-08 
09:25:01 UTC (rev 4870)
+++ phpcompta/trunk/include/export_fiche_balance_pdf.php        2012-06-09 
13:51:27 UTC (rev 4871)
@@ -143,7 +143,7 @@
        {
                $afiche[0] = array('fd_id' => $_REQUEST['cat']);
        }
-
+       $fic=new Fiche($cn);
        for ($e = 0; $e < count($afiche); $e++)
        {
                $array = Fiche::get_fiche_def($cn,$afiche[$e]['fd_id'] , 
'name_asc');
@@ -154,14 +154,14 @@
                {
                        continue;
                }
-               $tab = array(13, 25, 55, 20, 20, 12, 20);
-               $align = array('L', 'L', 'L', 'R', 'R', 'R', 'R');
+               $tab = array(12, 20, 10,78, 20, 20, 10, 20);
+               $align = array('L', 'C', 'L', 'L', 'R','R', 'R', 'R');
 
                foreach ($array as $row_fiche)
                {
-                       $row = new Fiche($cn, $row_fiche['f_id']);
+                       $fic = new Fiche($cn, $row_fiche['f_id']);
                        $letter = new Lettering_Card($cn);
-                       $letter->set_parameter('quick_code', 
$row->strAttribut(ATTR_DEF_QUICKCODE));
+                       $letter->set_parameter('quick_code', 
$fic->strAttribut(ATTR_DEF_QUICKCODE));
                        $letter->set_parameter('start', $_GET['start']);
                        $letter->set_parameter('end', $_GET['end']);
                        // all
@@ -195,15 +195,17 @@
 
                        $pdf->Cell($tab[0], 7, 'Date');
                        $pdf->Cell($tab[1], 7, 'ref');
-                       $pdf->Cell($tab[1], 7, 'Int.');
-                       $pdf->Cell($tab[2], 7, 'Comm');
-                       $pdf->Cell(40, 7, 'Montant', 0, 0, 'C');
-                       $pdf->Cell($tab[5], 7, 'Let.', 0, 0, 'R');
-                       $pdf->Cell($tab[6], 7, 'Diff. Let.', 0, 0, 'R');
+                       $pdf->Cell($tab[2], 7, 'Int.');
+                       $pdf->Cell($tab[3], 7, 'Comm');
+                       $pdf->Cell($tab[4], 7, 'Montant', 0, 0, 'C');
+                       $pdf->Cell($tab[5], 7, 'Prog.', 0, 0, 'R');
+                       $pdf->Cell($tab[6], 7, 'Let.', 0, 0, 'R');
+                       $pdf->Cell($tab[7], 7, 'Diff. Let.', 0, 0, 'R');
                        $pdf->ln();
 
                        $amount_deb = 0;
                        $amount_cred = 0;
+                       $prog=0;
                        for ($i = 0; $i < count($letter->content); $i++)
                        {
                                if ($i % 2 == 0)
@@ -222,40 +224,44 @@
 
                                $pdf->Cell($tab[0], 4, $str_date, 0, 0, 
$align[0], $fill);
                                $pdf->Cell($tab[1], 4, $row['jr_pj_number'], 0, 
0, $align[1], $fill);
-                               $pdf->Cell($tab[1], 4, $row['jr_internal'], 0, 
0, $align[1], $fill);
-                               $pdf->Cell($tab[2], 4, $row['jr_comment'], 0, 
0, $align[2], $fill);
+                               $pdf->LongLine($tab[2], 4, $row['jr_internal'], 
0, $align[1], $fill);
+                               $pdf->LongLine($tab[3], 4, $row['jr_comment'], 
0,  $align[2], $fill);
                                if ($row['j_debit'] == 't')
                                {
-                                       $pdf->Cell($tab[3], 4, 
sprintf('%10.2f', $row['j_montant']), 0, 0, $align[4], $fill);
+                                       $prog=bcadd($prog,$row['j_montant']);
+                                       $pdf->Cell($tab[4], 4, sprintf('%s D', 
nbm($row['j_montant'])), 0, 0, $align[4], $fill);
                                        $amount_deb+=$row['j_montant'];
-                                       $pdf->Cell($tab[4], 4, "", 0, 0, 'C', 
$fill);
+                                       $str_prog=sprintf("%s 
%s",nbm(abs($prog)),$fic->get_amount_side($prog));
+                                       $pdf->Cell($tab[5], 4, $str_prog, 0, 0, 
$align[5], $fill);
                                }
                                else
                                {
-                                       $pdf->Cell($tab[3], 4, "", 0, 0, 'C', 
$fill);
-                                       $pdf->Cell($tab[4], 4, 
sprintf('%10.2f', $row['j_montant']), 0, 0, $align[4], $fill);
+                                       $prog=bcsub($prog,$row['j_montant']);
+                                       $pdf->Cell($tab[4], 4, sprintf('%s C', 
nbm($row['j_montant'])), 0, 0, $align[4], $fill);
                                        $amount_cred+=$row['j_montant'];
+                                       $str_prog=sprintf("%s 
%s",nbm(abs($prog)),$fic->get_amount_side($prog));
+                                       $pdf->Cell($tab[5], 4, $str_prog, 0, 0, 
$align[5], $fill);
                                }
                                if ($row['letter'] != -1)
                                {
-                                       $pdf->Cell($tab[5], 4, $row['letter'], 
0, 0, $align[5], $fill);
+                                       $pdf->Cell($tab[6], 4, $row['letter'], 
0, 0, $align[6], $fill);
                                        // get sum for this lettering
 
-                                       $pdf->Cell($tab[6], 4, sprintf('%.2f', 
$row['letter_diff']), '0', '0', 'R', $fill);
+                                       $pdf->Cell($tab[7], 4, sprintf('%s', 
nbm($row['letter_diff'])), '0', '0', $align[7], $fill);
                                }
                                else
-                                       $pdf->Cell($tab[5], 4, "", 0, 0, 'R', 
$fill);
+                                       $pdf->Cell($tab[6], 4, "", 0, 0, 'R', 
$fill);
                                $pdf->Ln();
                        }
                        $pdf->SetFillColor(0, 0, 0);
                        $pdf->SetFont('DejaVuCond', 'B', 8);
-                       $debit = sprintf('Debit  : % 12.2f', $amount_deb);
-                       $credit = sprintf('Credit : % 12.2f', $amount_cred);
+                       $debit = sprintf('Debit  : %s', nbm($amount_deb));
+                       $credit = sprintf('Credit : %s', nbm($amount_cred));
                        if ($amount_deb > $amount_cred)
                                $s = 'solde débiteur';
                        else
                                $s = 'solde crediteur';
-                       $solde = sprintf('%s  : % 12.2f', $s, 
(abs(round($amount_cred - $amount_deb, 2))));
+                       $solde = sprintf('%s  : %s', $s, 
nbm(abs(round($amount_cred - $amount_deb, 2))));
 
                        $pdf->Cell(0, 6, $debit, 0, 0, 'R');
                        $pdf->ln(4);

Modified: phpcompta/trunk/include/export_gl_csv.php
===================================================================
--- phpcompta/trunk/include/export_gl_csv.php   2012-06-08 09:25:01 UTC (rev 
4870)
+++ phpcompta/trunk/include/export_gl_csv.php   2012-06-09 13:51:27 UTC (rev 
4871)
@@ -61,7 +61,7 @@
 {
   $cond_poste='';
   $sql="select pcm_val from tmp_pcmn ";
-    if ($from_poste != '') 
+    if ($from_poste != '')
       {
        $cond_poste = '  where ';
        $cond_poste .=' pcm_val >= upper 
(\''.Database::escape_string($from_poste).'\')';
@@ -69,7 +69,7 @@
 
     if ( $to_poste != '')
       {
-       if  ( $cond_poste == '') 
+       if  ( $cond_poste == '')
          {
            $cond_poste =  ' where pcm_val <= upper 
(\''.Database::escape_string($to_poste).'\')';
          }
@@ -100,10 +100,10 @@
 
 foreach ($a_poste as $poste)
 {
- 
 
+
   $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
-  
+
   $array1=$Poste->get_row_date($from_periode,$to_periode,$l,$s);
   // don't print empty account
   if ( count($array1) == 0 )
@@ -149,12 +149,12 @@
 
         if ($detail['cred_montant'] > 0)
         {
-            $solde   += $detail['cred_montant'];
+            $solde   -= $detail['cred_montant'];
             $solde_c += $detail['cred_montant'];
         }
         if ($detail['deb_montant'] > 0)
         {
-            $solde   -= $detail['deb_montant'];
+            $solde   += $detail['deb_montant'];
             $solde_d += $detail['deb_montant'];
         }
 
@@ -164,7 +164,8 @@
         echo $detail['jr_pj_number'].";";
         echo ($detail['deb_montant']  > 0 ? nb($detail['deb_montant'])  : 
'').";";
         echo ($detail['cred_montant'] > 0 ? nb($detail['cred_montant']) : 
'').";";
-        echo nb($solde).";";
+        echo nb(abs($solde)).";";
+               echo $Poste->get_amount_side($solde);
         printf("\n");
 
     }

Modified: phpcompta/trunk/include/export_gl_pdf.php
===================================================================
--- phpcompta/trunk/include/export_gl_pdf.php   2012-06-08 09:25:01 UTC (rev 
4870)
+++ phpcompta/trunk/include/export_gl_pdf.php   2012-06-09 13:51:27 UTC (rev 
4871)
@@ -139,17 +139,17 @@
 
         if ($detail['cred_montant'] > 0)
         {
-            $solde   += $detail['cred_montant'];
+            $solde   -= $detail['cred_montant'];
             $solde_c += $detail['cred_montant'];
         }
         if ($detail['deb_montant'] > 0)
         {
-            $solde   -= $detail['deb_montant'];
+            $solde   += $detail['deb_montant'];
             $solde_d += $detail['deb_montant'];
         }
 
         $i = 0;
-
+               $side=" ".$Poste->get_amount_side($solde);
         $pdf->Cell($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, 0, 
$lor[$i]);
         $i++;
         $pdf->Cell($width[$i], 6, $detail['jr_internal'], 0, 0, $lor[$i]);
@@ -165,7 +165,7 @@
         $i++;
         $pdf->Cell($width[$i], 6, ($detail['cred_montant'] > 0 ? nbm( 
$detail['cred_montant']) : ''), 0, 0, $lor[$i]);
         $i++;
-        $pdf->Cell($width[$i], 6, nbm( $solde), 0, 0, $lor[$i]);
+        $pdf->Cell($width[$i], 6, nbm(abs( $solde)).$side, 0, 0, $lor[$i]);
         $i++;
         $pdf->Ln();
 

Modified: phpcompta/trunk/include/impress_fiche.inc.php
===================================================================
--- phpcompta/trunk/include/impress_fiche.inc.php       2012-06-08 09:25:01 UTC 
(rev 4870)
+++ phpcompta/trunk/include/impress_fiche.inc.php       2012-06-09 13:51:27 UTC 
(rev 4871)
@@ -244,7 +244,7 @@
 }
 echo $export_csv;
 echo $export_pdf;
-
+$fiche=new Fiche($cn);
 for ($e = 0; $e < count($afiche); $e++)
 {
        $array = Fiche::get_fiche_def($cn, $afiche[$e]['fd_id'], 'name_asc');
@@ -322,7 +322,8 @@
                                $amount_cred+=$row['j_montant'];
                                $prog = bcsub($prog, $row['j_montant']);
                        }
-                       echo td(nbm($prog), 'style="text-align:right"');
+                       $side="&nbsp;".$fiche->get_amount_side($prog);
+                       echo td(nbm($prog).$side, 'style="text-align:right"');
                        if ($row['letter'] != -1)
                                {
                                $span_error="";
@@ -337,11 +338,11 @@
                echo '<table>';
                echo '<tr>';
                echo td(_('Debit'));
-               echo td($amount_deb, ' 
style="font-weight:bold;text-align:right"');
+               echo td(nbm($amount_deb), ' 
style="font-weight:bold;text-align:right"');
                echo '</tr>';
                echo '<tr>';
                echo td(_('Credit'));
-               echo td($amount_cred, ' 
style="font-weight:bold;text-align:right"');
+               echo td(nbm($amount_cred), ' 
style="font-weight:bold;text-align:right"');
                echo '</tr>';
                echo '<tr>';
                if ($amount_deb > $amount_cred)
@@ -349,7 +350,7 @@
                else
                        $s = 'solde crediteur';
                echo td($s);
-               echo td(abs(round($amount_cred - $amount_deb, 2)), ' 
style="font-weight:bold;text-align:right"');
+               echo td(nbm(abs(round($amount_cred - $amount_deb, 2))), ' 
style="font-weight:bold;text-align:right"');
                echo '</tr>';
                echo '</table>';
        }

Modified: phpcompta/trunk/include/impress_gl_comptes.inc.php
===================================================================
--- phpcompta/trunk/include/impress_gl_comptes.inc.php  2012-06-08 09:25:01 UTC 
(rev 4870)
+++ phpcompta/trunk/include/impress_gl_comptes.inc.php  2012-06-09 13:51:27 UTC 
(rev 4871)
@@ -207,14 +207,15 @@
 
             if ($detail['cred_montant'] > 0)
             {
-             $solde=bcadd($solde, $detail['cred_montant']);
+             $solde=bcsub($solde, $detail['cred_montant']);
              $solde_c=bcadd($solde_c,$detail['cred_montant']);
             }
             if ($detail['deb_montant'] > 0)
             {
-             $solde   = bcsub($solde,$detail['deb_montant']);
+             $solde   = bcadd($solde,$detail['deb_montant']);
              $solde_d = bcadd($solde_d,$detail['deb_montant']);
             }
+                       $side="&nbsp;".$Poste->get_amount_side($solde);
            $letter=($detail['letter']!=-1)?hi($detail['letter']):'';
             echo '<tr>
             <td>'.$detail['j_date_fmt'].'</td>
@@ -223,7 +224,7 @@
             <td>'.$detail['jr_pj_number'].'</td>
             <td align="right">'.($detail['deb_montant']  > 0 ? 
nbm($detail['deb_montant'])  : '').'</td>
             <td align="right">'.($detail['cred_montant'] > 0 ? 
nbm($detail['cred_montant']) : '').'</td>
-            <td align="right">'.nbm($solde).'</td>
+            <td align="right">'.nbm(abs($solde)).$side.'</td>
             <td  style="text-align:right;color:red">'.$letter.'</td>
             </tr>';
         }



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