Changed supplier payment to accept amount in foreign currency instead of exchange...
authorMaxime Bourget <bmx007@gmail.com>
Thu, 2 May 2013 21:24:10 +0000 (22:24 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 8 May 2013 05:33:37 +0000 (07:33 +0200)
js/payalloc.js
purchasing/supplier_payment.php

index a1cbc09ec3334f9c8cf548a69c42c2473f42d5c5..1bd818c1864fc27859e0ae86c1f9f0dd7fb821c9 100644 (file)
@@ -56,12 +56,20 @@ function allocate_none(doc) {
 
 var allocations = {
        '.amount': function(e) {
-               e.onblur = function() {
-                       blur_alloc(this);
+               if(e.name == 'allocated_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);
+                       };
+               }
        }
 }
 
index 9bd3559f4b13596e9b888e4230e9ad0fb0efff94..dd2a09d46cb8ed3e978792093ac76db215ca840b 100644 (file)
@@ -226,7 +226,11 @@ function handle_add_payment()
        if ($comp_currency != $bank_currency && $bank_currency != $supp_currency)
                $rate = 0;
        else
+       {
                $rate = input_num('_ex_rate');
+               $supplier_amount = input_num('allocated_amount'); 
+                       if($supplier_amount) $rate = input_num('amount')/$supplier_amount;
+       }
 
        $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'],
                $_POST['bank_account'], input_num('amount'), input_num('discount'), 
@@ -297,7 +301,7 @@ start_form();
        $bank_currency = get_bank_account_currency($_POST['bank_account']);
        if ($bank_currency != $supplier_currency) 
        {
-               exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid'], true);
+               amount_row("Supplier Amount:", 'allocated_amount', null, '', $supplier_currency, 2);
        }
 
        amount_row(_("Bank Charge:"), 'charge');