1 function allocate_all(doc) {
2 var amount = get_amount('amount'+doc);
3 var unallocated = get_amount('un_allocated'+doc);
4 var total = get_amount('total_allocated', 1);
5 var left = get_amount('left_to_allocate', 1);
7 if(unallocated<amount) amount = unallocated;
8 if((unallocated-amount)<=left){
9 left-=unallocated-amount;
10 total+=unallocated-amount;
17 price_format('amount'+doc, amount, user.pdec);
18 price_format('left_to_allocate', left, user.pdec, 1);
19 price_format('total_allocated', total, user.pdec, 1);
21 function allocate_none(doc) {
22 amount = get_amount('amount'+doc);
23 left = get_amount('left_to_allocate', 1);
24 total = get_amount('total_allocated', 1);
25 price_format('left_to_allocate',amount+left, user.pdec, 1);
26 price_format('amount'+doc, 0, user.pdec);
27 price_format('total_allocated', total-amount, user.pdec, 1);