[0004212] Work Order Entry: fixed error when voided WO refence is reused.
[fa-stable.git] / js / reconcile.js
1 /**********************************************************************
2     Copyright (C) FrontAccounting, LLC.
3         Released under the terms of the GNU General Public License, GPL, 
4         as published by the Free Software Foundation, either version 3 
5         of the License, or (at your option) any later version.
6     This program is distributed in the hope that it will be useful,
7     but WITHOUT ANY WARRANTY; without even the implied warranty of
8     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
9     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ***********************************************************************/
11 function focus_amount(i) {
12     save_focus(i);
13         i.setAttribute('_last', get_amount(i.name));
14 }
15
16 function blur_amount(i) {
17         var change = get_amount(i.name);
18
19         price_format(i.name, change, user.pdec);
20         change = change-i.getAttribute('_last');
21         if (i.name=='beg_balance')
22                 change = -change;
23
24         price_format('difference', get_amount('difference',1,1)+change, user.pdec, 1);
25 }
26
27 var balances = {
28         '.amount': function(e) {
29                 e.onblur = function() {
30                         blur_amount(this);
31                   };
32                 e.onfocus = function() {
33                         focus_amount(this);
34                 };
35         }
36 }
37
38 Behaviour.register(balances);