[0004212] Work Order Entry: fixed error when voided WO refence is reused.
[fa-stable.git] / js / payalloc.js
index 7bdd991483cac7f689082799c4ae30785006cbf8..a711e603cb40daf97dcc8924cefb339c5714eabd 100644 (file)
@@ -14,8 +14,12 @@ function focus_alloc(i) {
 }
 
 function blur_alloc(i) {
-       var change = get_amount(i.name);
-               price_format(i.name, change, user.pdec);                
+               var change = get_amount(i.name);
+               
+               if (i.name != 'amount' && i.name != 'charge' && i.name != 'discount')
+                       change = Math.min(change, get_amount('maxval'+i.name.substr(6), 1))
+
+               price_format(i.name, change, user.pdec);
                if (i.name != 'amount' && i.name != 'charge') {
                        if (change<0) change = 0;
                        change = change-i.getAttribute('_last');
@@ -52,12 +56,20 @@ function allocate_none(doc) {
 
 var allocations = {
        '.amount': function(e) {
-               e.onblur = function() {
-                       blur_alloc(this);
+               if(e.name == 'allocated_amount' || e.name == 'bank_amount')
+               {
+                 e.onblur = function() {
+                       var dec = this.getAttribute("dec");
+                       price_format(this.name, get_amount(this.name), dec);
                  };
-               e.onfocus = function() {
-                       focus_alloc(this);
-               };
+               } else {
+                       e.onblur = function() {
+                               blur_alloc(this);
+                       };
+                       e.onfocus = function() {
+                               focus_alloc(this);
+                       };
+               }
        }
 }