Skip to content

Commit

Permalink
Merge pull request #7011 from saurabhbatra96/comment-fixes-financial
Browse files Browse the repository at this point in the history
Comment fixes and function clean-up for CRM/Financial directory.
  • Loading branch information
eileenmcnaughton committed Oct 21, 2015
2 parents 39981e4 + cded2eb commit cae582a
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 182 deletions.
18 changes: 4 additions & 14 deletions CRM/Financial/BAO/ExportFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/

/**
Expand Down Expand Up @@ -104,14 +102,6 @@ public function getFileExtension() {
return 'txt';
}

/**
* Override this if appropriate.
* @return null
*/
public function getTemplateFileName() {
return NULL;
}

/**
* @return object
*/
Expand Down Expand Up @@ -150,7 +140,7 @@ public static function format($s, $type = 'string') {

public function initiateDownload() {
$config = CRM_Core_Config::singleton();
//zip files if more than one.
// zip files if more than one.
if (count($this->_downloadFile) > 1) {
$zip = $config->customFileUploadDir . 'Financial_Transactions_' . date('YmdHis') . '.zip';
$result = $this->createZip($this->_downloadFile, $zip, TRUE);
Expand Down Expand Up @@ -204,7 +194,7 @@ public static function createActivityExport($batchIds, $fileName) {
$subject .= ' ' . ts('Count') . '[' . $values['item_count'] . '],';
}

//create activity.
// create activity.
$subject .= ' ' . ts('Batch') . '[' . $values['title'] . ']';
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
$activityParams = array(
Expand Down Expand Up @@ -235,14 +225,14 @@ public static function createActivityExport($batchIds, $fileName) {
* @return bool
*/
public function createZip($files = array(), $destination = NULL, $overwrite = FALSE) {
//if the zip file already exists and overwrite is false, return false
// if the zip file already exists and overwrite is false, return false
if (file_exists($destination) && !$overwrite) {
return FALSE;
}
$valid_files = array();
if (is_array($files)) {
foreach ($files as $file) {
//make sure the file exists
// make sure the file exists
if (file_exists($file)) {
$validFiles[] = $file;
}
Expand Down
24 changes: 7 additions & 17 deletions CRM/Financial/BAO/ExportFormat/CSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/

/**
* @link http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Specifications+-++Batches#CiviAccountsSpecifications-Batches-%C2%A0Overviewofimplementation
*/
class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat {

// For this phase, we always output these records too so that there isn't data referenced in the journal entries that isn't defined anywhere.
// Possibly in the future this could be selected by the user.
/**
* For this phase, we always output these records too so that there isn't data
* referenced in the journal entries that isn't defined anywhere.
*
* Possibly in the future this could be selected by the user.
*/
public static $complementaryTables = array(
'ACCNT',
'CUST',
Expand All @@ -58,17 +60,14 @@ public function __construct() {
public function export($exportParams) {
$export = parent::export($exportParams);

// Save the file in the public directory
// Save the file in the public directory.
$fileName = self::putFile($export);

foreach (self::$complementaryTables as $rct) {
$func = "export{$rct}";
$this->$func();
}

// now do general journal entries
$this->exportTRANS();

$this->output($fileName);
}

Expand Down Expand Up @@ -243,13 +242,4 @@ public function getFileExtension() {
return 'csv';
}

public function exportACCNT() {
}

public function exportCUST() {
}

public function exportTRANS() {
}

}
16 changes: 10 additions & 6 deletions CRM/Financial/BAO/ExportFormat/IIF.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,25 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/

/**
* @link http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Specifications+-++Batches#CiviAccountsSpecifications-Batches-%C2%A0Overviewofimplementation
*/
class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat {

// Tab character. Some people's editors replace tabs with spaces so I'm scared to use actual tabs.
// Can't set it here using chr() because static. Same thing if a const. So it's set in constructor.
/**
* Tab character. Some people's editors replace tabs with spaces so I'm scared to use actual tabs.
* Can't set it here using chr() because static. Same thing if a const. So it's set in constructor.
*/
static $SEPARATOR;

// For this phase, we always output these records too so that there isn't data referenced in the journal entries that isn't defined anywhere.
// Possibly in the future this could be selected by the user.
/**
* For this phase, we always output these records too so that there isn't data
* referenced in the journal entries that isn't defined anywhere.
*
* Possibly in the future this could be selected by the user.
*/
public static $complementaryTables = array(
'ACCNT',
'CUST',
Expand Down
6 changes: 2 additions & 4 deletions CRM/Financial/BAO/FinancialAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAccount {

Expand Down Expand Up @@ -121,7 +119,7 @@ public static function add(&$params, &$ids = array()) {
* @param int $financialAccountId
*/
public static function del($financialAccountId) {
//checking if financial type is present
// checking if financial type is present
$check = FALSE;

//check dependencies
Expand All @@ -144,7 +142,7 @@ public static function del($financialAccountId) {
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialAccount', "reset=1&action=browse"));
}

//delete from financial Type table
// delete from financial Type table
$financialAccount = new CRM_Financial_DAO_FinancialAccount();
$financialAccount->id = $financialAccountId;
$financialAccount->delete();
Expand Down
4 changes: 1 addition & 3 deletions CRM/Financial/BAO/FinancialItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem {

Expand Down Expand Up @@ -209,7 +207,7 @@ public static function createEntityTrxn($params) {
public static function retrieveEntityFinancialTrxn($params, $maxId = FALSE) {
$financialItem = new CRM_Financial_DAO_EntityFinancialTrxn();
$financialItem->copyValues($params);
//retrieve last entry from civicrm_entity_financial_trxn
// retrieve last entry from civicrm_entity_financial_trxn
if ($maxId) {
$financialItem->orderBy('id DESC');
$financialItem->limit(1);
Expand Down
6 changes: 2 additions & 4 deletions CRM/Financial/BAO/FinancialType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {

Expand Down Expand Up @@ -144,7 +142,7 @@ public static function del($financialTypeId) {
// tables to ingore checks for financial_type_id
$ignoreTables = array('CRM_Financial_DAO_EntityFinancialAccount');

//TODO: if (!$financialType->find(true)) {
// TODO: if (!$financialType->find(true)) {

// ensure that we have no objects that have an FK to this financial type id TODO: that cannot be null
$occurrences = $financialType->findReferences();
Expand All @@ -166,7 +164,7 @@ public static function del($financialTypeId) {
}
}

//delete from financial Type table
// delete from financial Type table
$financialType->delete();

$entityFinancialType = new CRM_Financial_DAO_EntityFinancialAccount();
Expand Down
8 changes: 3 additions & 5 deletions CRM/Financial/BAO/FinancialTypeAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFinancialAccount {

Expand Down Expand Up @@ -107,12 +105,12 @@ public static function add(&$params, &$ids = NULL) {
*
*/
public static function del($financialTypeAccountId, $accountId = NULL) {
//checking if financial type is present
// check if financial type is present
$check = FALSE;
$relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');

$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'entity_id');
//check dependencies
// check dependencies
// FIXME more table containing financial_type_id to come
$dependency = array(
array('Contribute', 'Contribution'),
Expand Down Expand Up @@ -146,7 +144,7 @@ public static function del($financialTypeAccountId, $accountId = NULL) {
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialType/accounts', "reset=1&action=browse&aid={$accountId}"));
}

//delete from financial Type table
// delete from financial Type table
$financialType = new CRM_Financial_DAO_EntityFinancialAccount();
$financialType->id = $financialTypeAccountId;
$financialType->find(TRUE);
Expand Down
4 changes: 2 additions & 2 deletions CRM/Financial/BAO/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public static function getProcessorForEntity($entityID, $component = 'contribute
) {
return $result;
}
//FIXME:

if ($component == 'membership') {
$sql = "
SELECT cr.payment_processor_id as ppID1, cp.payment_processor as ppID2, con.is_test
Expand All @@ -459,7 +459,7 @@ public static function getProcessorForEntity($entityID, $component = 'contribute
WHERE cr.id = %1";
}

//we are interesting in single record.
// We are interested in a single record.
$sql .= ' LIMIT 1';

$params = array(1 => array($entityID, 'Integer'));
Expand Down
4 changes: 1 addition & 3 deletions CRM/Financial/BAO/PaymentProcessorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentProcessorType {

Expand All @@ -54,7 +52,7 @@ public function __construct() {
* @param array $defaults
* (reference ) an assoc array to hold the flattened values.
*
* @return CRM_Core_BAO_LocaationType|null
* @return CRM_Core_BAO_LocationType|null
* object on success, null otherwise
*/
public static function retrieve(&$params, &$defaults) {
Expand Down
5 changes: 0 additions & 5 deletions CRM/Financial/Form/BatchTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/

/**
* This class generates form components for Financial Type
*
*/
class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form {
static $_links = NULL;
Expand Down Expand Up @@ -77,8 +74,6 @@ public function preProcess() {

/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
if ($this->_batchStatusId == 2) {
Expand Down
12 changes: 2 additions & 10 deletions CRM/Financial/Form/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/

/**
Expand Down Expand Up @@ -64,16 +62,14 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {

/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);

// this mean it's a batch action
if (!$this->_id) {
if (!empty($_GET['batch_id'])) {
//validate batch ids
// validate batch ids
$batchIds = explode(',', $_GET['batch_id']);
foreach ($batchIds as $batchId) {
CRM_Utils_Type::validate($batchId, 'Positive');
Expand All @@ -96,7 +92,7 @@ public function preProcess() {
$allBatchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
$this->_exportStatusId = CRM_Utils_Array::key('Exported', $allBatchStatus);

//check if batch status is valid, do not allow exported batches to export again
// check if batch status is valid, do not allow exported batches to export again
$batchStatus = CRM_Batch_BAO_Batch::getBatchStatuses($this->_batchIds);

foreach ($batchStatus as $batchStatusId) {
Expand All @@ -112,8 +108,6 @@ public function preProcess() {

/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
// this mean it's a batch action
Expand Down Expand Up @@ -151,8 +145,6 @@ public function buildQuickForm() {

/**
* Process the form after the input has been submitted and validated.
*
* @return void
*/
public function postProcess() {
if (!$this->_exportFormat) {
Expand Down
Loading

0 comments on commit cae582a

Please sign in to comment.