Batch Data Entry screens do not require payment instrument
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 26 May 2015 07:06:24 +0000 (12:36 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 26 May 2015 07:06:24 +0000 (12:36 +0530)
CRM/Batch/Form/Entry.php

index 13d0534301355c935e42ae7b5ca9b7e39724aa16..334ff90d69b0b2a008f269802e834785a82af6ee 100755 (executable)
@@ -280,14 +280,18 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
   public static function formRule($params, $files, $self) {
     $errors = array();
     $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
+    $fields = array(
+      'total_amount' => 'Amount',
+      'financial_type' => 'Financial Type',
+      'payment_instrument' => 'Paid By',
+    );
 
     //CRM-16480 if contact is selected, validate financial type and amount field.
     foreach ($params['field'] as $key => $value) {
-      if (!empty($params['primary_contact_id'][$key]) && empty($value['total_amount'])) {
-        $errors["field[$key][total_amount]"] = ts('Amount is a required field.');
-      }
-      if (!empty($params['primary_contact_id'][$key]) && empty($value['financial_type'])) {
-        $errors["field[$key][financial_type]"] = ts('Financial Type is a required field.');
+      foreach($fields as $field => $label) {
+        if (!empty($params['primary_contact_id'][$key]) && empty($value[$field])) {
+          $errors["field[$key][$field]"] = ts("$label is a required field.");
+        }
       }
     }