noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
compute.js
Go to the documentation of this file.
00001 /*
00002  *   This file is part of NOALYSS.
00003  *
00004  *   NOALYSS is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation; either version 2 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   NOALYSS is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with NOALYSS; if not, write to the Free Software
00016  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 /*!\file
00019  *\brief common function for accountancy module
00020  */
00021 function checkTotal()
00022 {
00023     var ie4=false;
00024     if ( document.all )
00025     {
00026         ie4=true;
00027     }// Ajouter getElementById par document.all[str]
00028     var total_deb=0.0;
00029     var total_cred=0.0;
00030 
00031 
00032     var nb_item_id=document.getElementById('nb_item');
00033     if ( ! nb_item_id )
00034     {
00035         return;
00036     }
00037     var nb_item=nb_item_id.value;
00038 
00039     for (var i=0;i <nb_item ;i++)
00040     {
00041         var doc_amount=document.getElementById("e_account"+i+"_amount");
00042         if ( ! doc_amount )
00043         {
00044             return;
00045         }
00046         var side=document.getElementsByName("e_account"+i+"_type");
00047         if ( ! side )
00048         {
00049             return;
00050         }
00051         var amount=parseFloat(doc_amount.value);
00052 
00053         if ( isNaN(amount) == true)
00054         {
00055             amount=0.0;
00056         }
00057         for (var e=0;e<side.length;e++)
00058         {
00059             if ( side[e].checked == true)
00060             {
00061                 //      alert('checked !!! '+side[e].value);
00062                 deb=side[e].value;
00063             }
00064         }
00065         if ( deb == 'c' )
00066         {
00067             total_cred+=amount;
00068         }
00069         if ( deb == 'd' )
00070         {
00071             total_deb+=amount;
00072         }
00073 
00074         //    alert("amount ="+i+"="+amount+" cred/deb = "+deb+"total d/b"+total_deb+"/"+total_cred);
00075     }
00076 
00077 
00078 
00079     r_total_cred=Math.round(total_cred*100)/100;
00080     r_total_deb=Math.round(total_deb*100)/100;
00081     document.getElementById('totalDeb').innerHTML=r_total_deb;
00082     document.getElementById('totalCred').innerHTML=r_total_cred;
00083 
00084     if ( r_total_deb != r_total_cred )
00085     {
00086         document.getElementById("totalDiff").style.color="red";
00087         document.getElementById("totalDiff").style.fontWeight="bold";
00088         document.getElementById("totalDiff").innerHTML="Différence";
00089         diff=total_deb-total_cred;
00090         diff=Math.round(diff*100)/100;
00091         document.getElementById("totalDiff").innerHTML=diff;
00092 
00093     }
00094     else
00095         {
00096             document.getElementById("totalDiff").innerHTML="0.0";
00097         }
00098 }
00099 
 All Data Structures Namespaces Files Functions Variables Enumerations