Improve calculation, display transponed value
authorJoey Schulze <joey@infodrom.org>
Fri, 28 Sep 2018 22:53:12 +0000 (00:53 +0200)
committerJoey Schulze <joey@infodrom.org>
Fri, 28 Sep 2018 22:53:12 +0000 (00:53 +0200)
src/InfoCon/buch/reimbursement.wml

index a436e51..ded63da 100644 (file)
@@ -24,6 +24,7 @@ Titel <input type="text" id="title" name="title" value="" size="20" title="Optio
     }
 ?>
 Zwischensumme <input type="text" id="subtotal" value="" size="5" style="background: #ececec;text-align:right;" readonly> &euro;
+&nbsp;&nbsp;&nbsp;<input type="text" id="subtotal_tr" value="" size="5" style="background: #ececec;text-align:right;" readonly> &euro;
 <p><input type="submit" class="button" value="Bezahlen" onclick="return send_request()"> <input type="reset" class="button" value="Reset"><p>
 </form>
 
@@ -34,17 +35,20 @@ function cb_change()
 {
     var subtotal = $('input#subtotal').val();
     if (typeof subtotal == 'string' && !subtotal.length) subtotal = 0;
-    else subtotal = parseFloat(subtotal) * 100;
+    else subtotal = parseInt((parseFloat(subtotal) * 100).toString());
 
     if ($(this).prop('checked'))
-       subtotal += parseFloat($(this).attr('price'));
+       subtotal += parseInt($(this).attr('price'));
     else
-       subtotal -= parseFloat($(this).attr('price'));
+       subtotal -= parseInt($(this).attr('price'));
 
-    if (subtotal == 0)
+    if (subtotal == 0) {
        $('input#subtotal').val('');
-    else
+       $('input#subtotal_tr').val('');
+    } else {
        $('input#subtotal').val(subtotal / 100);
+       $('input#subtotal_tr').val((subtotal * -1 / 100).toString().replace('.', ','));
+    }
 }
 
 function send_request()