[0004212] Work Order Entry: fixed error when voided WO refence is reused.
[fa-stable.git] / js / budget.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_budget(i) {
12     save_focus(i);
13         i.setAttribute('_last', get_amount(i.name));
14 }
15
16 function blur_budget(i) {
17         var amount = get_amount(i.name);
18         var total = get_amount('Total', 1);
19         
20         price_format(i.name, amount, 0);
21         price_format('Total', total+amount-i.getAttribute('_last'), 0, 1, 1);
22 }
23
24
25 var budget_calc = {
26         '.amount': function(e) {
27                 e.onblur = function() {
28                         blur_budget(this);
29                   };
30                 e.onfocus = function() {
31                         focus_budget(this);
32                 };
33         }
34 }
35
36 Behaviour.register(budget_calc);