Merged changes from stable branch up to 2.3.12
[fa-stable.git] / purchasing / supplier_payment.php
index b28259e44b3fe90200a1e1d9ff51756c9810f089..e40fb8f2b772149ce3704941259dde19ed756188 100644 (file)
@@ -57,11 +57,6 @@ if (isset($_POST['_DatePaid_changed'])) {
   $Ajax->activate('_ex_rate');
 }
 
-if (list_updated('supplier_id') || list_updated('bank_account')) {
-  $_SESSION['alloc']->read();
-  $_POST['memo_'] = $_POST['amount'] = '';
-  $Ajax->activate('alloc_tbl');
-}
 //----------------------------------------------------------------------------------------
 
 if (!isset($_POST['bank_account'])) { // first page call
@@ -210,6 +205,8 @@ function check_inputs()
                return false;
        }
 
+       if (!db_has_currency_rates(get_supplier_currency($_POST['supplier_id']), $_POST['DatePaid'], true))
+               return false;
        $_SESSION['alloc']->amount = -input_num('amount');
 
        if (isset($_POST["TotalNumberOfAllocs"]))
@@ -272,6 +269,12 @@ start_form();
 
     supplier_list_row(_("Payment To:"), 'supplier_id', null, false, true);
 
+       if (list_updated('supplier_id') || list_updated('bank_account')) {
+         $_SESSION['alloc']->read();
+         $_POST['memo_'] = $_POST['amount'] = '';
+         $Ajax->activate('alloc_tbl');
+       }
+
        set_global_supplier($_POST['supplier_id']);
 
        if (!list_updated('bank_account'))