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) {
17 var id = i.name.substr(6)
18 var unallocated = get_amount('un_allocated'+id);
20 var cur = Math.max(Math.min(get_amount(i.name), unallocated), 0);
22 price_format(i.name, cur, user.pdec);
23 price_format('left'+id, unallocated-cur, user.pdec, 1);
27 function update_totals() {
31 for (var i=0; i<docs.length; i++) {
32 amount += get_amount('amount'+docs[i])
33 if (document.getElementsByName('early_disc'+docs[i])[0].checked
34 && (get_amount('un_allocated'+docs[i]) == get_amount('amount'+docs[i])))
35 discount += get_amount('early_disc'+docs[i]);
37 console.info(discount);
38 price_format('amount', amount-discount, user.pdec);
39 price_format('discount', discount, user.pdec, 1);
43 function allocate_all(doc) {
44 var unallocated = get_amount('un_allocated'+doc);
45 price_format('amount'+doc, unallocated, user.pdec);
46 price_format('left'+doc, 0, user.pdec, 1);
50 function allocate_none(doc) {
51 var unallocated = get_amount('un_allocated'+doc);
52 price_format('amount'+doc, 0, user.pdec);
53 price_format('left'+doc, unallocated, user.pdec, 1);
59 '.amount': function(e) {
60 if(e.name == 'allocated_amount' || e.name == 'bank_amount')
62 e.onblur = function() {
63 var dec = this.getAttribute("dec");
64 price_format(this.name, get_amount(this.name), dec);
67 e.onblur = function() {
70 e.onfocus = function() {
75 '.check':function(e) {
76 e.onclick = function() {
82 Behaviour.register(allocations);