Commit cded2ebf authored by saurabhbatra's avatar saurabhbatra

Comment fixes and function clean-up for CRM/Financial directory.

parent bc8fbabd
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
......@@ -104,14 +102,6 @@ class CRM_Financial_BAO_ExportFormat {
return 'txt';
}
/**
* Override this if appropriate.
* @return null
*/
public function getTemplateFileName() {
return NULL;
}
/**
* @return object
*/
......@@ -150,7 +140,7 @@ class CRM_Financial_BAO_ExportFormat {
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);
......@@ -204,7 +194,7 @@ class CRM_Financial_BAO_ExportFormat {
$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(
......@@ -235,14 +225,14 @@ class CRM_Financial_BAO_ExportFormat {
* @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;
}
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
......@@ -38,8 +36,12 @@
*/
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',
......@@ -58,7 +60,7 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
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) {
......@@ -66,9 +68,6 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
$this->$func();
}
// now do general journal entries
$this->exportTRANS();
$this->output($fileName);
}
......@@ -243,13 +242,4 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
return 'csv';
}
public function exportACCNT() {
}
public function exportCUST() {
}
public function exportTRANS() {
}
}
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
......@@ -38,12 +36,18 @@
*/
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',
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAccount {
......@@ -121,7 +119,7 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco
* @param int $financialAccountId
*/
public static function del($financialAccountId) {
//checking if financial type is present
// checking if financial type is present
$check = FALSE;
//check dependencies
......@@ -144,7 +142,7 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco
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();
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem {
......@@ -209,7 +207,7 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem {
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);
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
......@@ -144,7 +142,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
// 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();
......@@ -166,7 +164,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
}
}
//delete from financial Type table
// delete from financial Type table
$financialType->delete();
$entityFinancialType = new CRM_Financial_DAO_EntityFinancialAccount();
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFinancialAccount {
......@@ -107,12 +105,12 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin
*
*/
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'),
......@@ -146,7 +144,7 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin
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);
......
......@@ -433,7 +433,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
) {
return $result;
}
//FIXME:
if ($component == 'membership') {
$sql = "
SELECT cr.payment_processor_id as ppID1, cp.payment_processor as ppID2, con.is_test
......@@ -459,7 +459,7 @@ INNER JOIN civicrm_contribution con ON ( mp.contribution_id = con.id )
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'));
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentProcessorType {
......@@ -54,7 +52,7 @@ class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentPr
* @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) {
......
......@@ -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;
......@@ -77,8 +74,6 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form {
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
if ($this->_batchStatusId == 2) {
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
......@@ -64,8 +62,6 @@ 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);
......@@ -73,7 +69,7 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {
// 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');
......@@ -96,7 +92,7 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {
$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) {
......@@ -112,8 +108,6 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
// this mean it's a batch action
......@@ -151,8 +145,6 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {
/**
* Process the form after the input has been submitted and validated.
*
* @return void
*/
public function postProcess() {
if (!$this->_exportFormat) {
......
......@@ -29,13 +29,10 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
* This class generates form components for Financial Account
*
*/
class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
......@@ -49,8 +46,6 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess() {
parent::preProcess();
......@@ -76,8 +71,6 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
......@@ -175,10 +168,7 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
/**
* Set default values for the form.
* the default values are retrieved from the database
*
*
* @return void
* the default values are retrieved from the database.
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
......@@ -190,8 +180,6 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
/**
* Process the form submission.
*
* @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
......
......@@ -29,13 +29,10 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
* This class generates form components for Accounting Batch
*
*/
class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
......@@ -48,8 +45,6 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess() {
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
......@@ -84,8 +79,6 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
......@@ -124,7 +117,7 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
$batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
//unset exported status
// unset exported status
$exportedStatusId = CRM_Utils_Array::key('Exported', $batchStatus);
unset($batchStatus[$exportedStatusId]);
$this->add('select', 'status_id', ts('Batch Status'), array('' => ts('- select -')) + $batchStatus, TRUE);
......@@ -150,10 +143,7 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
/**
* Set default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
* the default values are retrieved from the database.
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
......@@ -203,8 +193,6 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
/**
* Process the form submission.
*
* @return void
*/
public function postProcess() {
$session = CRM_Core_Session::singleton();
......@@ -244,7 +232,7 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
//create activity.
// create activity.
$activityParams = array(
'activity_type_id' => array_search($activityTypeName, $activityTypes),
'subject' => $batch->title . "- Batch",
......
......@@ -29,20 +29,15 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
* This class generates form components for Financial Type
*
*/
class CRM_Financial_Form_FinancialType extends CRM_Contribute_Form {
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
......@@ -77,8 +72,6 @@ class CRM_Financial_Form_FinancialType extends CRM_Contribute_Form {
/**
* Process the form submission.
*
* @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
......
......@@ -29,13 +29,10 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
* This class generates form components for Financial Type Account
*
*/
class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form {
......@@ -69,8 +66,6 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form {
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess() {
$this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this);
......@@ -120,8 +115,6 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form {
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
......@@ -142,10 +135,10 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form {
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->assign('aid', $this->_id);
//hidden field to catch the group id in profile
// hidden field to catch the group id in profile
$this->add('hidden', 'financial_type_id', $this->_aid);
//hidden field to catch the field id in profile
// hidden field to catch the field id in profile
$this->add('hidden', 'account_type_id', $this->_id);
}
$AccountTypeRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
......@@ -302,8 +295,6 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form {
/**
* Process the form submission.
*
* @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
......
......@@ -29,8 +29,10 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
* @todo Add comments if possible.
*/
class CRM_Financial_Form_Search extends CRM_Core_Form {
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
......@@ -56,14 +54,14 @@ class CRM_Financial_Page_AJAX {
}
else {
$financialAccountType = array(
'5' => 5, //expense
'3' => 1, //AR relation
'1' => 3, //revenue
'5' => 5, // expense
'3' => 1, // AR relation
'1' => 3, // revenue
'6' => 1, // asset
'7' => 4, //cost of sales
'8' => 1, //premium inventory
'9' => 3, //discount account is
'10' => 2, //sales tax liability
'7' => 4, // cost of sales
'8' => 1, // premium inventory
'9' => 3, // discount account is
'10' => 2, // sales tax liability
);
$financialAccountType = CRM_Utils_Array::value($_GET['_value'], $financialAccountType);
$result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
/**
......@@ -55,13 +53,6 @@ class CRM_Financial_Page_Batch extends CRM_Core_Page_Basic {
return 'CRM_Batch_BAO_Batch';
}
/**
* Get action Links.
*
*/
public function &links() {
}
/**
* Get name of edit form.
*
......@@ -96,8 +87,6 @@ class CRM_Financial_Page_Batch extends CRM_Core_Page_Basic {
/**