From: Saurabh Batra Date: Wed, 14 Oct 2015 13:38:23 +0000 (+0530) Subject: extracted getBatchSummary to a new function for testing X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=973a1687bc713f3fc9b7ee04ac0e587ab987d333;p=civicrm-core.git extracted getBatchSummary to a new function for testing --- diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index 2c374f9d74..f7a9a00dc4 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -518,13 +518,20 @@ class CRM_Financial_Page_AJAX { public static function getBatchSummary() { $batchID = CRM_Utils_Type::escape($_REQUEST['batchID'], 'String'); $params = array('id' => $batchID); - $batchInfo = CRM_Batch_BAO_Batch::retrieve($params, $value); + + $batchSummary = makeBatchSummary($batchID, $params); + + CRM_Utils_JSON::output($batchSummary); + } + + public static function makeBatchSummary($batchID, $params) { + $batchInfo = CRM_Batch_BAO_Batch::retrieve($params, $value); $batchTotals = CRM_Batch_BAO_Batch::batchTotals(array($batchID)); - $batchSummary = array( + $batchSummary = array( 'created_by' => CRM_Contact_BAO_Contact::displayName($batchInfo->created_id), - 'status' => CRM_Core_OptionGroup::getLabel('batch_status', $batchInfo->status_id), + 'status' => CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'batch_status_id', $batchInfo->status_id), 'description' => $batchInfo->description, - 'payment_instrument' => CRM_Core_OptionGroup::getLabel('payment_instrument', $batchInfo->payment_instrument_id), + 'payment_instrument' => CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'payment_instrument_id', $batchInfo->payment_instrument_id), 'item_count' => $batchInfo->item_count, 'assigned_item_count' => $batchTotals[$batchID]['item_count'], 'total' => CRM_Utils_Money::format($batchInfo->total), @@ -532,7 +539,6 @@ class CRM_Financial_Page_AJAX { 'opened_date' => CRM_Utils_Date::customFormat($batchInfo->created_date), ); - CRM_Utils_JSON::output($batchSummary); + return $batchSummary; } - }