$financialTypeAccount->find(TRUE);
}
$financialTypeAccount->copyValues($params);
- self::validateRelationship($financialTypeAccount);
+ $valid = self::validateRelationship($financialTypeAccount);
+ if (!$valid) {
+ return FALSE;
+ }
$financialTypeAccount->save();
return $financialTypeAccount;
}
* @param int $financialTypeAccountId
* @param int $accountId
*
+ * @return bool
*/
public static function del($financialTypeAccountId, $accountId = NULL) {
// check if financial type is present
$params = array(
1 => $accountRelationships[$financialTypeAccount->account_relationship],
);
- throw new Exception(ts("This financial account cannot have '%1' relationship.", $params));
+ CRM_Core_Session::setStatus(ts('This financial account cannot have \'%1\' relationship.', $params), ts('Error'), 'error');
+ return FALSE;
}
+ return TRUE;
}
}
$params['entity_id'] = $this->_aid;
}
$financialTypeAccount = CRM_Financial_BAO_FinancialTypeAccount::add($params, $ids);
- CRM_Core_Session::setStatus(ts('The financial type Account has been saved.'));
+ if ($financialTypeAccount) {
+ CRM_Core_Session::setStatus(ts('The financial type Account has been saved.'));
+ }
}
$buttonName = $this->controller->getButtonName();
$financialAccountType->entity_id = array_search('Member Dues', $financialType);
$financialAccountType->account_relationship = array_search('Credit/Contra Revenue Account is', $accountRelationships);
$financialAccountType->financial_account_id = array_search('Liability', $financialAccount);
- try {
- CRM_Financial_BAO_FinancialTypeAccount::validateRelationship($financialAccountType);
- $this->fail("Missed expected exception");
- }
- catch (Exception $e) {
- $this->assertTrue(TRUE, 'Received expected exception');
- $this->assertEquals($e->getMessage(), "This financial account cannot have 'Credit/Contra Revenue Account is' relationship.");
- }
+ $valid = CRM_Financial_BAO_FinancialTypeAccount::validateRelationship($financialAccountType);
+ $this->assertFalse($valid);
}
/**