noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
compute_direct.js
Go to the documentation of this file.
1/*
2 * This file is part of NOALYSS.
3 *
4 * NOALYSS is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * NOALYSS is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with NOALYSS; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18/**
19 * @file
20 *common function for "Ecriture directe"
21 */
22/**
23 * Compute the sum of the debit and credit of the operation in the input screen for misceallenous operation
24 * Call CurrencyComputeMisc to update the amount in default currency for DEB (domid = default_currency_deb)
25 * and CRED ( domid = default_currency_cred),
26 * @returns {Boolean} true if ok
27 */
28function checkTotalDirect()
29{
30 var ie4=false;
31 if ( document.all )
32 {
33 ie4=true;
34 }// Ajouter getElementById par document.all[str]
35 var total_deb=0.0;
36 var total_cred=0.0;
37
38
39 var nb_item_id=document.getElementById('nb_item');
40 if ( ! nb_item_id )
41 {
42 return;
43 }
44
45 var nb_item=nb_item_id.value;
46
47 for (var i=0;i <nb_item ;i++)
48 {
49 var doc_amount=document.getElementById("amount"+i);
50 if ( ! doc_amount )
51 {
52 return;
53 }
54 var side=document.getElementsByName("ck"+i);
55 if ( ! side )
56 {
57 return;
58 }
59 var amount=parseFloat(doc_amount.value);
60
61 if ( isNaN(amount) == true)
62 {
63 amount=0.0;
64 }
65 for (var e=0;e<side.length;e++)
66 {
67 if ( side[e].checked == true)
68 {
69 // alert_box('checked !!! '+side[e].value);
70 total_deb+=amount;
71 }
72 else
73 {
74 total_cred+=amount;
75 }
76 }
77
78 // alert_box("amount ="+i+"="+amount+" cred/deb = "+deb+"total d/b"+total_deb+"/"+total_cred);
79 }
80
81
82
83 r_total_cred=Math.round(total_cred*100)/100;
84 r_total_deb=Math.round(total_deb*100)/100;
85 document.getElementById('totalDeb').innerHTML=r_total_deb;
86 document.getElementById('totalCred').innerHTML=r_total_cred;
87 // Currency , update the amount in default currency for DEB (domid = default_currency_deb)
88 // and CRED ( domid = default_currency_cred),
89 CurrencyComputeMisc('p_currency_rate','p_currency_euro');
90
91 var diff=0;
92 if ( r_total_deb != r_total_cred )
93 {
94 document.getElementById("totalDiff").style.color="red";
95 document.getElementById("totalDiff").style.fontWeight="bold";
96 document.getElementById("totalDiff").innerHTML="Différence";
97 diff=total_deb-total_cred;
98 diff=Math.round(diff*100)/100;
99 document.getElementById("totalDiff").innerHTML=diff;
100 return false;
101
102 }
103 else
104 {
105 document.getElementById("totalDiff").innerHTML="0.0";
106 return true;
107 }
108}
109function controleBalance()
110{
111 if ( checkTotalDirect() == true ) { return true;}
112 else {
113 smoke.alert(content[58]);
114 return false;
115 }
116}