Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added advantage description #16

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
33d0b51
Added advantage description
Edzelopez Mar 23, 2020
91e70dc
add entity files
monishdeb Mar 23, 2020
36dc51c
More changes to accomodate description of advantage
Edzelopez Mar 23, 2020
6365893
Added advantage fields to receipt
Edzelopez Mar 23, 2020
ff5c886
Added advantage fields to contribution view
Edzelopez Mar 23, 2020
3423a82
Modified saving of advantage field
Edzelopez Mar 24, 2020
0792615
Fixed issues with description of advantage field
Edzelopez Apr 14, 2020
b399ea3
Bug fixes
Edzelopez Apr 14, 2020
77ae057
Fixed currency formatter
Edzelopez Apr 15, 2020
1c50f94
Fixed typo
Edzelopez Apr 17, 2020
fa9191a
Added auto increment to column
Edzelopez Apr 17, 2020
b9b1604
Add missing financial type to 'In-kind' fund
monishdeb Apr 20, 2020
28e6bdf
remove cost-of-sales financial account for In-Kind fund
monishdeb Apr 20, 2020
ee5e340
Fix Upgrade process and create inkind financial type and custom field…
seamuslee001 Apr 21, 2020
9161ad7
Fix upgrade code and add in setting of the account code for the reven…
seamuslee001 Apr 21, 2020
574ee68
Quote the new Accounting Code
seamuslee001 Apr 21, 2020
94a4c2a
get rid of CostOfSales GL account assignment to In-kind fund
monishdeb Apr 21, 2020
6a25012
Added auto increment to install file
Edzelopez Apr 22, 2020
422ad61
CRM-373 additional fixes
Edzelopez Apr 23, 2020
ff1b2fc
Fixed page layouts
Edzelopez Apr 23, 2020
13e181c
Fixed appraiser address
Edzelopez Apr 24, 2020
d2d441a
Reduced string length for appraiser address
Edzelopez Apr 28, 2020
678e209
Fixed address string
Edzelopez May 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CRM/Cdntaxreceipts/BAO/CdnAdvantage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
use CRM_Cdntaxreceipts_ExtensionUtil as E;

class CRM_Cdntaxreceipts_BAO_CdnAdvantage extends CRM_Cdntaxreceipts_DAO_CdnAdvantage {

/**
* Create a new CdnAdvantage based on array-data
*
* @param array $params key-value pairs
* @return CRM_Cdntaxreceipts_DAO_CdnAdvantage|NULL
*
public static function create($params) {
$className = 'CRM_Cdntaxreceipts_DAO_CdnAdvantage';
$entityName = 'CdnAdvantage';
$hook = empty($params['id']) ? 'create' : 'edit';

CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);

return $instance;
} */

}
186 changes: 186 additions & 0 deletions CRM/Cdntaxreceipts/DAO/CdnAdvantage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?php

/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from /Users/monish/src/civi-extensions/CDNTaxReceipts/xml/schema/CRM/Cdntaxreceipts/CdnAdvantage.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:8f2f9a909d8d4bddeb38db84b7b21d56)
*/

/**
* Database access object for the CdnAdvantage entity.
*/
class CRM_Cdntaxreceipts_DAO_CdnAdvantage extends CRM_Core_DAO {

/**
* Static instance to hold the table name.
*
* @var string
*/
public static $_tableName = 'cdntaxreceipts_advantage';

/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var bool
*/
public static $_log = TRUE;

/**
* Unique CdnAdvantage ID
*
* @var int
*/
public $id;

/**
* Contribution ID
*
* @var int
*/
public $contribution_id;

/**
* Advantage Description
*
* @var string
*/
public $advantage_description;

/**
* Class constructor.
*/
public function __construct() {
$this->__table = 'cdntaxreceipts_advantage';
parent::__construct();
}

/**
* Returns foreign keys and entity references.
*
* @return array
* [CRM_Core_Reference_Interface]
*/
public static function getReferenceColumns() {
if (!isset(Civi::$statics[__CLASS__]['links'])) {
Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
}
return Civi::$statics[__CLASS__]['links'];
}

/**
* Returns all the column names of this table
*
* @return array
*/
public static function &fields() {
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
Civi::$statics[__CLASS__]['fields'] = [
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'description' => ts('Unique CdnAdvantage ID'),
'required' => TRUE,
'where' => 'cdntaxreceipts_advantage.id',
'table_name' => 'cdntaxreceipts_advantage',
'entity' => 'CdnAdvantage',
'bao' => 'CRM_Cdntaxreceipts_DAO_CdnAdvantage',
'localizable' => 0,
],
'contribution_id' => [
'name' => 'contribution_id',
'type' => CRM_Utils_Type::T_INT,
'description' => ts('Contribution ID'),
'where' => 'cdntaxreceipts_advantage.contribution_id',
'table_name' => 'cdntaxreceipts_advantage',
'entity' => 'CdnAdvantage',
'bao' => 'CRM_Cdntaxreceipts_DAO_CdnAdvantage',
'localizable' => 0,
],
'advantage_description' => [
'name' => 'advantage_description',
'type' => CRM_Utils_Type::T_STRING,
'description' => ts('Description of Advantage'),
'where' => 'cdntaxreceipts_advantage.advantage_description',
'table_name' => 'cdntaxreceipts_advantage',
'entity' => 'CdnAdvantage',
'bao' => 'CRM_Cdntaxreceipts_DAO_CdnAdvantage',
'localizable' => 1,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
return Civi::$statics[__CLASS__]['fields'];
}

/**
* Return a mapping from field-name to the corresponding key (as used in fields()).
*
* @return array
* Array(string $name => string $uniqueName).
*/
public static function &fieldKeys() {
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
}
return Civi::$statics[__CLASS__]['fieldKeys'];
}

/**
* Returns the names of this table
*
* @return string
*/
public static function getTableName() {
return self::$_tableName;
}

/**
* Returns if this table needs to be logged
*
* @return bool
*/
public function getLog() {
return self::$_log;
}

/**
* Returns the list of fields that can be imported
*
* @param bool $prefix
*
* @return array
*/
public static function &import($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'cdntaxreceipts_advantage', $prefix, []);
return $r;
}

/**
* Returns the list of fields that can be exported
*
* @param bool $prefix
*
* @return array
*/
public static function &export($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'cdntaxreceipts_advantage', $prefix, []);
return $r;
}

/**
* Returns the list of indices
*
* @param bool $localize
*
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}

}
41 changes: 40 additions & 1 deletion CRM/Cdntaxreceipts/Upgrader.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use CRM_Cdntaxreceipts_ExtensionUtil as E;

/**
* Collection of upgrade steps
*/
Expand Down Expand Up @@ -68,7 +70,7 @@ public function upgrade_1321() {
CRM_Core_DAO::executeQuery('ALTER TABLE cdntaxreceipts_log ADD email_opened datetime NULL');
CRM_Core_DAO::executeQuery('CREATE INDEX contribution_id ON cdntaxreceipts_log_contributions (contribution_id)');
return TRUE;
}
}

public function upgrade_1322() {
$this->ctx->log->info('Applying update 1322: Message Templates');
Expand All @@ -89,6 +91,43 @@ public function upgrade_1410() {
return TRUE;
}

public function upgrade_1510() {
$this->ctx->log->info('Applying update 1510: Adding gift advantage description table and adding missing financial accounts to "In-Kind" fund ');
$sql = "CREATE TABLE IF NOT EXISTS cdntaxreceipts_advantage (
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
contribution_id int(10) UNSIGNED NOT NULL,
advantage_description varchar(255) DEFAULT NULL,
PRIMARY KEY (id),
INDEX contribution_id (contribution_id)
)";
CRM_Core_DAO::executeQuery($sql);

// add missing GL account to In-kind fund
require_once 'CRM/Financial/DAO/FinancialType.php';
$financialType = new CRM_Financial_DAO_FinancialType();
$financialType->name = 'In-kind';

if ($financialType->find(TRUE)) {
E::createDefaultFinancialAccounts($financialType);
// Set the GL Account code to match master
$revenueAccountTypeID = array_search('Revenue', CRM_Core_OptionGroup::values('financial_account_type', FALSE, FALSE, FALSE, NULL, 'name'));
if ($revenueAccountTypeID) {
CRM_Core_DAO::executeQuery("UPDATE civicrm_financial_account fa
INNER JOIN civicrm_entity_financial_account efa ON efa.financial_account_id = fa.id
SET fa.accounting_code = '4300'
efa.entity_table = 'civicrm_financial_type' AND fa.financial_account_type_id = %1 AND efa.entity_id = %2", [
1 => [$revenueAccountTypeID, 'Positive'],
2 => [$financialType->id, 'Positive'],
]);
}
}
else {
// Create Inkind financial type and fields
cdntaxreceipts_configure_inkind_fields();
}

return TRUE;
}

function _create_message_template($email_message, $email_subject) {

Expand Down
47 changes: 47 additions & 0 deletions api/v3/CdnAdvantage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
use CRM_Cdntaxreceipts_ExtensionUtil as E;

/**
* CdnAdvantage.create API specification (optional)
* This is used for documentation and validation.
*
* @param array $spec description of fields supported by this API call
* @return void
* @see http://wiki.civicrm.org/confluence/display/CRMDOC/API+Architecture+Standards
*/
function _civicrm_api3_cdn_advantage_create_spec(&$spec) {
// $spec['some_parameter']['api.required'] = 1;
}

/**
* CdnAdvantage.create API
*
* @param array $params
* @return array API result descriptor
* @throws API_Exception
*/
function civicrm_api3_cdn_advantage_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}

/**
* CdnAdvantage.delete API
*
* @param array $params
* @return array API result descriptor
* @throws API_Exception
*/
function civicrm_api3_cdn_advantage_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}

/**
* CdnAdvantage.get API
*
* @param array $params
* @return array API result descriptor
* @throws API_Exception
*/
function civicrm_api3_cdn_advantage_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
Loading