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_alloc(i) {
13 i.setAttribute('_last', get_amount(i.name));
16 function blur_alloc(i) {
18 var last = +i.getAttribute('_last')
19 var left = get_amount('left_to_allocate', 1);
20 var cur = Math.min(get_amount(i.name), get_amount('maxval'+i.name.substr(6), 1), last+left)
22 price_format(i.name, cur, user.pdec);
25 var total = get_amount('total_allocated', 1)+change;
28 price_format('left_to_allocate', left, user.pdec, 1, 1);
29 price_format('total_allocated', total, user.pdec, 1, 1);
32 function allocate_all(doc) {
33 var amount = get_amount('amount'+doc);
34 var unallocated = get_amount('un_allocated'+doc);
35 var total = get_amount('total_allocated', 1);
36 var left = get_amount('left_to_allocate', 1);
37 total -= (amount-unallocated);
38 left += (amount-unallocated);
45 price_format('amount'+doc, amount, user.pdec);
46 price_format('left_to_allocate', left, user.pdec, 1,1);
47 price_format('total_allocated', total, user.pdec, 1, 1);
50 function allocate_none(doc) {
51 amount = get_amount('amount'+doc);
52 left = get_amount('left_to_allocate', 1);
53 total = get_amount('total_allocated', 1);
54 price_format('left_to_allocate',amount+left, user.pdec, 1, 1);
55 price_format('amount'+doc, 0, user.pdec);
56 price_format('total_allocated', total-amount, user.pdec, 1, 1);
60 '.amount': function(e) {
61 e.onblur = function() {
64 e.onfocus = function() {
70 Behaviour.register(allocations);