3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2017
37 class CRM_Batch_BAO_Batch
extends CRM_Batch_DAO_Batch
{
40 * Cache for the current batch object.
42 static $_batch = NULL;
45 * Not sure this is the best way to do this. Depends on how exportFinancialBatch() below gets called.
46 * Maybe a parameter to that function is better.
48 static $_exportFormat = NULL;
53 * @param array $params
58 public static function create(&$params) {
60 $batchId = CRM_Utils_Array
::value('id', $params);
63 $params['name'] = CRM_Utils_String
::titleToVar($params['title']);
65 CRM_Utils_Hook
::pre($op, 'Batch', $batchId, $params);
66 $batch = new CRM_Batch_DAO_Batch();
67 $batch->copyValues($params);
70 CRM_Utils_Hook
::post($op, 'Batch', $batch->id
, $batch);
76 * Retrieve the information about the batch.
78 * @param array $params
79 * (reference ) an assoc array of name/value pairs.
80 * @param array $defaults
81 * (reference ) an assoc array to hold the flattened values.
84 * CRM_Batch_BAO_Batch object on success, null otherwise
86 public static function retrieve(&$params, &$defaults) {
87 $batch = new CRM_Batch_DAO_Batch();
88 $batch->copyValues($params);
89 if ($batch->find(TRUE)) {
90 CRM_Core_DAO
::storeValues($batch, $defaults);
97 * Get profile id associated with the batch type.
99 * @param int $batchTypeId
103 * $profileId profile id
105 public static function getProfileId($batchTypeId) {
106 //retrieve the profile specific to batch type
107 switch ($batchTypeId) {
110 //batch profile used for pledges
111 $profileName = "contribution_batch_entry";
115 //batch profile used for memberships
116 $profileName = "membership_batch_entry";
120 // get and return the profile id
121 return CRM_Core_DAO
::getFieldValue('CRM_Core_BAO_UFGroup', $profileName, 'id', 'name');
125 * Generate batch name.
130 public static function generateBatchName() {
131 $sql = "SELECT max(id) FROM civicrm_batch";
132 $batchNo = CRM_Core_DAO
::singleValueQuery($sql) +
1;
133 return ts('Batch %1', array(1 => $batchNo)) . ': ' . date('Y-m-d');
137 * Delete batch entry.
139 * @param int $batchId
144 public static function deleteBatch($batchId) {
145 // delete entry from batch table
146 CRM_Utils_Hook
::pre('delete', 'Batch', $batchId, CRM_Core_DAO
::$_nullArray);
147 $batch = new CRM_Batch_DAO_Batch();
148 $batch->id
= $batchId;
150 CRM_Utils_Hook
::post('delete', 'Batch', $batch->id
, $batch);
155 * wrapper for ajax batch selector.
157 * @param array $params
158 * Associated array for params record id.
161 * associated array of batch list
163 public static function getBatchListSelector(&$params) {
165 $params['offset'] = ($params['page'] - 1) * $params['rp'];
166 $params['rowCount'] = $params['rp'];
167 $params['sort'] = CRM_Utils_Array
::value('sortBy', $params);
170 $batches = self
::getBatchList($params);
172 // get batch totals for open batches
173 $fetchTotals = array();
174 $batchStatus = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
175 $batchStatus = array(
176 array_search('Open', $batchStatus),
177 array_search('Reopened', $batchStatus),
179 if ($params['context'] == 'financialBatch') {
180 foreach ($batches as $id => $batch) {
181 if (in_array($batch['status_id'], $batchStatus)) {
182 $fetchTotals[] = $id;
186 $totals = self
::batchTotals($fetchTotals);
189 $params['total'] = self
::getBatchCount($params);
191 // format params and add links
192 $batchList = array();
194 foreach ($batches as $id => $value) {
196 if ($params['context'] == 'financialBatch') {
197 $batch['check'] = $value['check'];
199 $batch['batch_name'] = $value['title'];
200 $batch['total'] = '';
201 $batch['payment_instrument'] = $value['payment_instrument'];
202 $batch['item_count'] = CRM_Utils_Array
::value('item_count', $value);
203 $batch['type'] = CRM_Utils_Array
::value('batch_type', $value);
204 if (!empty($value['total'])) {
206 $batch['total'] = CRM_Utils_Money
::format($value['total'], $value['currency']);
209 // Compare totals with actuals
210 if (isset($totals[$id])) {
211 $batch['item_count'] = self
::displayTotals($totals[$id]['item_count'], $batch['item_count']);
212 $batch['total'] = self
::displayTotals(CRM_Utils_Money
::format($totals[$id]['total']), $batch['total']);
214 $batch['status'] = $value['batch_status'];
215 $batch['created_by'] = $value['created_by'];
216 $batch['links'] = $value['action'];
217 $batchList[$id] = $batch;
223 * Get list of batches.
225 * @param array $params
226 * Associated array for params.
230 public static function getBatchList(&$params) {
231 $apiParams = self
::whereClause($params);
233 if (!empty($params['rowCount']) && is_numeric($params['rowCount'])
234 && is_numeric($params['offset']) && $params['rowCount'] > 0
236 $apiParams['options'] = array('offset' => $params['offset'], 'limit' => $params['rowCount']);
238 $apiParams['options']['sort'] = 'id DESC';
239 if (!empty($params['sort'])) {
240 $apiParams['options']['sort'] = CRM_Utils_Type
::escape($params['sort'], 'String');
257 "payment_instrument_id",
258 "created_id.sort_name",
261 $apiParams['return'] = $return;
262 $batches = civicrm_api3('Batch', 'get', $apiParams);
263 $obj = new CRM_Batch_BAO_Batch();
264 if (!empty($params['context'])) {
265 $links = $obj->links($params['context']);
268 $links = $obj->links();
271 $batchTypes = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'type_id');
272 $batchStatus = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'status_id');
273 $batchStatusByName = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
274 $paymentInstrument = CRM_Contribute_PseudoConstant
::paymentInstrument();
277 foreach ($batches['values'] as $values) {
279 $action = array_sum(array_keys($newLinks));
281 if ($values['status_id'] == array_search('Closed', $batchStatusByName) && $params['context'] != 'financialBatch') {
284 elseif ($params['context'] == 'financialBatch') {
285 $values['check'] = "<input type='checkbox' id='check_" .
289 "' value='1' data-status_id='" .
290 $values['status_id'] . "' class='select-row'></input>";
292 switch ($batchStatusByName[$values['status_id']]) {
295 CRM_Utils_Array
::remove($newLinks, 'reopen', 'download');
299 CRM_Utils_Array
::remove($newLinks, 'close', 'edit', 'download');
303 CRM_Utils_Array
::remove($newLinks, 'close', 'edit', 'reopen', 'export');
305 if (!CRM_Batch_BAO_Batch
::checkBatchPermission('edit', $values['created_id'])) {
306 CRM_Utils_Array
::remove($newLinks, 'edit');
308 if (!CRM_Batch_BAO_Batch
::checkBatchPermission('close', $values['created_id'])) {
309 CRM_Utils_Array
::remove($newLinks, 'close', 'export');
311 if (!CRM_Batch_BAO_Batch
::checkBatchPermission('reopen', $values['created_id'])) {
312 CRM_Utils_Array
::remove($newLinks, 'reopen');
314 if (!CRM_Batch_BAO_Batch
::checkBatchPermission('export', $values['created_id'])) {
315 CRM_Utils_Array
::remove($newLinks, 'export', 'download');
317 if (!CRM_Batch_BAO_Batch
::checkBatchPermission('delete', $values['created_id'])) {
318 CRM_Utils_Array
::remove($newLinks, 'delete');
321 if (!empty($values['type_id'])) {
322 $values['batch_type'] = $batchTypes[$values['type_id']];
324 $values['batch_status'] = $batchStatus[$values['status_id']];
325 $values['created_by'] = $values['created_id.sort_name'];
326 $values['payment_instrument'] = '';
327 if (!empty($values['payment_instrument_id'])) {
328 $values['payment_instrument'] = $paymentInstrument[$values['payment_instrument_id']];
330 $tokens = array('id' => $values['id'], 'status' => $values['status_id']);
331 if ($values['status_id'] == array_search('Exported', $batchStatusByName)) {
332 $aid = CRM_Core_PseudoConstant
::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Export Accounting Batch');
333 $activityParams = array('source_record_id' => $values['id'], 'activity_type_id' => $aid);
334 $exportActivity = CRM_Activity_BAO_Activity
::retrieve($activityParams, $val);
335 $fid = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_EntityFile', $exportActivity->id
, 'file_id', 'entity_id');
336 $tokens = array_merge(array('eid' => $exportActivity->id
, 'fid' => $fid), $tokens);
338 $values['action'] = CRM_Core_Action
::formLink(
344 'batch.selector.row',
349 $values['currency'] = CRM_Core_DAO
::singleValueQuery("
350 SELECT GROUP_CONCAT(DISTINCT ft.currency)
351 FROM civicrm_batch batch
352 JOIN civicrm_entity_batch eb
353 ON batch.id = eb.batch_id
354 JOIN civicrm_financial_trxn ft
355 ON eb.entity_id = ft.id
358 ", array(1 => array($values['id'], 'Positive')));
359 $results[$values['id']] = $values;
366 * Get count of batches.
368 * @param array $params
369 * Associated array for params.
371 * @return null|string
373 public static function getBatchCount(&$params) {
374 $apiParams = self
::whereClause($params);
375 return civicrm_api3('Batch', 'getCount', $apiParams);
379 * Format where clause for getting lists of batches.
381 * @param array $params
382 * Associated array for params.
386 public static function whereClause($params) {
388 // Exclude data-entry batches
389 $batchStatus = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
390 if (empty($params['status_id'])) {
391 $clauses['status_id'] = array('NOT IN' => array("Data Entry"));
408 "payment_instrument_id",
409 "created_id.sort_name",
412 if (!CRM_Core_Permission
::check("view all manual batches")) {
413 if (CRM_Core_Permission
::check("view own manual batches")) {
414 $loggedInContactId = CRM_Core_Session
::singleton()->get('userID');
415 $params['created_id'] = $loggedInContactId;
418 $params['created_id'] = 0;
421 foreach ($return as $field) {
422 if (!isset($params[$field])) {
425 $value = CRM_Utils_Type
::escape($params[$field], 'String', FALSE);
426 if (in_array($field, array('name', 'title', 'description', 'created_id.sort_name'))) {
427 $clauses[$field] = array('LIKE' => "%{$value}%");
429 elseif ($field == 'status_id' && $value == array_search('Open', $batchStatus)) {
430 $clauses['status_id'] = array('IN' => array("Open", 'Reopened'));
433 $clauses[$field] = $value;
440 * Define action links.
442 * @param null $context
445 * array of action links
447 public function links($context = NULL) {
448 if ($context == 'financialBatch') {
450 'transaction' => array(
451 'name' => ts('Transactions'),
452 'url' => 'civicrm/batchtransaction',
453 'qs' => 'reset=1&bid=%%id%%',
454 'title' => ts('View/Add Transactions to Batch'),
457 'name' => ts('Edit'),
458 'url' => 'civicrm/financial/batch',
459 'qs' => 'reset=1&action=update&id=%%id%%&context=1',
460 'title' => ts('Edit Batch'),
463 'name' => ts('Close'),
464 'title' => ts('Close Batch'),
466 'extra' => 'rel="close"',
469 'name' => ts('Export'),
470 'title' => ts('Export Batch'),
472 'extra' => 'rel="export"',
475 'name' => ts('Re-open'),
476 'title' => ts('Re-open Batch'),
478 'extra' => 'rel="reopen"',
481 'name' => ts('Delete'),
482 'title' => ts('Delete Batch'),
484 'extra' => 'rel="delete"',
487 'name' => ts('Download'),
488 'url' => 'civicrm/file',
489 'qs' => 'reset=1&id=%%fid%%&eid=%%eid%%',
490 'title' => ts('Download Batch'),
496 CRM_Core_Action
::COPY
=> array(
497 'name' => ts('Enter records'),
498 'url' => 'civicrm/batch/entry',
499 'qs' => 'id=%%id%%&reset=1',
500 'title' => ts('Batch Data Entry'),
502 CRM_Core_Action
::UPDATE
=> array(
503 'name' => ts('Edit'),
504 'url' => 'civicrm/batch',
505 'qs' => 'action=update&id=%%id%%&reset=1',
506 'title' => ts('Edit Batch'),
508 CRM_Core_Action
::DELETE
=> array(
509 'name' => ts('Delete'),
510 'url' => 'civicrm/batch',
511 'qs' => 'action=delete&id=%%id%%',
512 'title' => ts('Delete Batch'),
523 * all batches excluding batches with data entry in progress
525 public static function getBatches() {
526 $dataEntryStatusId = CRM_Core_PseudoConstant
::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Data Entry');
527 $query = "SELECT id, title
529 WHERE item_count >= 1
530 AND status_id != {$dataEntryStatusId}
534 $dao = CRM_Core_DAO
::executeQuery($query);
535 while ($dao->fetch()) {
536 $batches[$dao->id
] = $dao->title
;
543 * Calculate sum of all entries in a batch.
544 * Used to validate and update item_count and total when closing an accounting batch
546 * @param array $batchIds
549 public static function batchTotals($batchIds) {
550 $totals = array_fill_keys($batchIds, array('item_count' => 0, 'total' => 0));
552 $sql = "SELECT eb.batch_id, COUNT(tx.id) AS item_count, SUM(tx.total_amount) AS total
553 FROM civicrm_entity_batch eb
554 INNER JOIN civicrm_financial_trxn tx ON tx.id = eb.entity_id AND eb.entity_table = 'civicrm_financial_trxn'
555 WHERE eb.batch_id IN (" . implode(',', $batchIds) . ")
556 GROUP BY eb.batch_id";
557 $dao = CRM_Core_DAO
::executeQuery($sql);
558 while ($dao->fetch()) {
559 $totals[$dao->batch_id
] = (array) $dao;
567 * Format markup for comparing two totals.
575 public static function displayTotals($actual, $expected) {
576 $class = 'actual-value';
577 if ($expected && $expected != $actual) {
578 $class .= ' crm-error';
580 $actualTitle = ts('Current Total');
581 $output = "<span class='$class' title='$actualTitle'>$actual</span>";
583 $expectedTitle = ts('Expected Total');
584 $output .= " / <span class='expected-value' title='$expectedTitle'>$expected</span>";
590 * Function for exporting financial accounts, currently we support CSV and IIF format
591 * @see http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Specifications+-++Batches#CiviAccountsSpecifications-Batches-%C2%A0Overviewofimplementation
593 * @param array $batchIds
594 * Associated array of batch ids.
595 * @param string $exportFormat
597 * @param bool $downloadFile
598 * Download export file?.
600 public static function exportFinancialBatch($batchIds, $exportFormat, $downloadFile) {
601 if (empty($batchIds)) {
602 CRM_Core_Error
::fatal(ts('No batches were selected.'));
605 if (empty($exportFormat)) {
606 CRM_Core_Error
::fatal(ts('No export format selected.'));
609 self
::$_exportFormat = $exportFormat;
611 // Instantiate appropriate exporter based on user-selected format.
612 $exporterClass = "CRM_Financial_BAO_ExportFormat_" . self
::$_exportFormat;
613 if (class_exists($exporterClass)) {
614 $exporter = new $exporterClass();
617 CRM_Core_Error
::fatal("Could not locate exporter: $exporterClass");
620 $exporter->_isDownloadFile
= $downloadFile;
621 foreach ($batchIds as $batchId) {
622 // export only batches whose status is set to Exported.
623 $result = civicrm_api3('Batch', 'getcount', array(
625 'status_id' => "Exported",
630 $export[$batchId] = $exporter->generateExportQuery($batchId);
633 $exporter->makeExport($export);
638 * @param array $batchIds
641 public static function closeReOpen($batchIds = array(), $status) {
642 $batchStatus = CRM_Core_PseudoConstant
::get('CRM_Batch_DAO_Batch', 'status_id');
643 $params['status_id'] = CRM_Utils_Array
::key($status, $batchStatus);
644 $session = CRM_Core_Session
::singleton();
645 $params['modified_date'] = date('YmdHis');
646 $params['modified_id'] = $session->get('userID');
647 foreach ($batchIds as $key => $value) {
648 $params['id'] = $ids['batchID'] = $value;
649 self
::create($params, $ids);
651 $url = CRM_Utils_System
::url('civicrm/financial/financialbatches', "reset=1&batchStatus={$params['status_id']}");
652 CRM_Utils_System
::redirect($url);
656 * Retrieve financial items assigned for a batch.
658 * @param int $entityID
659 * @param array $returnValues
660 * @param bool $notPresent
661 * @param array $params
662 * @param bool $getCount
664 * @return CRM_Core_DAO
666 public static function getBatchFinancialItems($entityID, $returnValues, $notPresent = NULL, $params = NULL, $getCount = FALSE) {
668 if (!empty($params['rowCount']) &&
669 $params['rowCount'] > 0
671 $limit = " LIMIT {$params['offset']}, {$params['rowCount']} ";
674 // action is taken depending upon the mode
675 $select = 'civicrm_financial_trxn.id ';
676 if (!empty($returnValues)) {
677 $select .= " , " . implode(' , ', $returnValues);
680 $orderBy = " ORDER BY civicrm_financial_trxn.id";
681 if (!empty($params['sort'])) {
682 $orderBy = ' ORDER BY ' . CRM_Utils_Type
::escape($params['sort'], 'String');
685 $from = "civicrm_financial_trxn
686 INNER JOIN civicrm_entity_financial_trxn ON civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id
687 INNER JOIN civicrm_contribution ON (civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id
688 AND civicrm_entity_financial_trxn.entity_table='civicrm_contribution')
689 LEFT JOIN civicrm_entity_batch ON civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'
690 AND civicrm_entity_batch.entity_id = civicrm_financial_trxn.id
691 LEFT JOIN civicrm_financial_type ON civicrm_financial_type.id = civicrm_contribution.financial_type_id
692 LEFT JOIN civicrm_contact contact_a ON contact_a.id = civicrm_contribution.contact_id
693 LEFT JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id = civicrm_contribution.id
696 $searchFields = array(
699 'contribution_page_id',
700 'payment_instrument_id',
701 'contribution_trxn_id',
702 'contribution_source',
703 'contribution_currency_type',
704 'contribution_pay_later',
705 'contribution_recurring',
707 'contribution_thankyou_date_is_not_null',
708 'contribution_receipt_date_is_not_null',
709 'contribution_pcp_made_through_id',
710 'contribution_pcp_display_in_roll',
711 'contribution_date_relative',
712 'contribution_amount_low',
713 'contribution_amount_high',
714 'contribution_in_honor_of',
717 'contribution_date_relative',
718 'contribution_date_high',
719 'contribution_date_low',
720 'contribution_check_number',
721 'contribution_status_id',
724 foreach ($searchFields as $field) {
725 if (isset($params[$field])) {
726 $values[$field] = $params[$field];
727 if ($field == 'sort_name') {
728 $from .= " LEFT JOIN civicrm_contact contact_b ON contact_b.id = civicrm_contribution.contact_id
729 LEFT JOIN civicrm_email ON contact_b.id = civicrm_email.contact_id";
731 if ($field == 'contribution_in_honor_of') {
732 $from .= " LEFT JOIN civicrm_contact contact_b ON contact_b.id = civicrm_contribution.contact_id";
734 if ($field == 'contact_tags') {
735 $from .= " LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-{$params[$field]}` ON `civicrm_entity_tag-{$params[$field]}`.entity_id = contact_a.id";
737 if ($field == 'group') {
738 $from .= " LEFT JOIN civicrm_group_contact `civicrm_group_contact-{$params[$field]}` ON contact_a.id = `civicrm_group_contact-{$params[$field]}`.contact_id ";
740 if ($field == 'contribution_date_relative') {
741 $relativeDate = explode('.', $params[$field]);
742 $date = CRM_Utils_Date
::relativeToAbsolute($relativeDate[0], $relativeDate[1]);
743 $values['contribution_date_low'] = $date['from'];
744 $values['contribution_date_high'] = $date['to'];
746 $searchParams = CRM_Contact_BAO_Query
::convertFormValues($values);
747 // @todo the use of defaultReturnProperties means the search will be inefficient
748 // as slow-unneeded properties are included.
749 $query = new CRM_Contact_BAO_Query($searchParams,
750 CRM_Contribute_BAO_Query
::defaultReturnProperties(CRM_Contact_BAO_Query
::MODE_CONTRIBUTE
,
752 ), NULL, FALSE, FALSE, CRM_Contact_BAO_Query
::MODE_CONTRIBUTE
754 if ($field == 'contribution_date_high' ||
$field == 'contribution_date_low') {
755 $query->dateQueryBuilder($params[$field], 'civicrm_contribution', 'contribution_date', 'receive_date', 'Contribution Date');
759 if (!empty($query->_where
[0])) {
760 $where = implode(' AND ', $query->_where
[0]) .
761 " AND civicrm_entity_batch.batch_id IS NULL ";
762 $where = str_replace('civicrm_contribution.payment_instrument_id', 'civicrm_financial_trxn.payment_instrument_id', $where);
766 $where = " civicrm_entity_batch.batch_id = {$entityID} ";
769 $where = " civicrm_entity_batch.batch_id IS NULL ";
784 $result = CRM_Core_DAO
::executeQuery($sql);
790 * @param string $batchIds
795 public static function getBatchNames($batchIds) {
796 $query = 'SELECT id, title
798 WHERE id IN (' . $batchIds . ')';
801 $dao = CRM_Core_DAO
::executeQuery($query);
802 while ($dao->fetch()) {
803 $batches[$dao->id
] = $dao->title
;
809 * Function get batch statuses.
811 * @param string $batchIds
816 public static function getBatchStatuses($batchIds) {
817 $query = 'SELECT id, status_id
819 WHERE id IN (' . $batchIds . ')';
822 $dao = CRM_Core_DAO
::executeQuery($query);
823 while ($dao->fetch()) {
824 $batches[$dao->id
] = $dao->status_id
;
830 * Function to check permission for batch.
832 * @param string $action
833 * @param int $batchCreatedId
834 * batch created by contact id
838 public static function checkBatchPermission($action, $batchCreatedId = NULL) {
839 if (CRM_Core_Permission
::check("{$action} all manual batches")) {
842 if (CRM_Core_Permission
::check("{$action} own manual batches")) {
843 $loggedInContactId = CRM_Core_Session
::singleton()->get('userID');
844 if ($batchCreatedId == $loggedInContactId) {
847 elseif (CRM_Utils_System
::isNull($batchCreatedId)) {