Skip to content
Snippets Groups Projects
Commit 1e0f9b7f authored by Pradeep Nayak's avatar Pradeep Nayak
Browse files

Merge pull request #122 from pradpnayak/RG-125

Rg 125
parents 0d29923d 6e1d5ec8
No related branches found
No related tags found
No related merge requests found
......@@ -762,9 +762,17 @@ function grantprograms_civicrm_post($op, $objectName, $objectId, &$objectRef) {
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
$params['to_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($objectRef->financial_type_id, $relationTypeId);
$statusID = array_search('Completed', $contributionStatuses);
$financialItemStatusID = array_search('Paid', $financialItemStatus);
$createItem = FALSE;
}
elseif ($objectRef->status_id == array_search('Withdrawn', $status)) {
$params['to_financial_account_id'] = CRM_Core_DAO::singleValueQuery("SELECT to_financial_account_id FROM civicrm_financial_trxn cft
INNER JOIN civicrm_entity_financial_trxn ecft ON ecft.financial_trxn_id = cft.id
WHERE ecft.entity_id = {$objectRef->id} and ecft.entity_table = 'civicrm_grant'
ORDER BY cft.id DESC LIMIT 1");
$statusID = array_search('Cancelled', $contributionStatuses);
$financialItemStatusID = array_search('Unpaid', $financialItemStatus);
$amount = -$amount;
}
if (CRM_Utils_Array::value('to_financial_account_id', $params)) {
//build financial transaction params
$trxnParams = array(
......@@ -970,4 +978,4 @@ function grantprograms_define($extensionsDir) {
fwrite($file, "\ndefine('PAY_GRANTS', 5);\ndefine('DELETE_GRANTS', 1);\n\n?>");
fclose($file);
return;
}
\ No newline at end of file
}
......@@ -41,7 +41,7 @@ SELECT @OGId10 := id FROM civicrm_option_group WHERE name = 'type_of_course_prov
INSERT INTO `civicrm_custom_field` (`custom_group_id`, `name`, `label`, `data_type`, `html_type`, `default_value`, `is_required`, `is_searchable`, `is_search_range`, `weight`, `help_pre`, `help_post`, `mask`, `attributes`, `javascript`, `is_active`, `is_view`, `options_per_line`, `text_length`, `start_date_years`, `end_date_years`, `date_format`, `time_format`, `note_columns`, `note_rows`, `column_name`, `option_group_id`, `filter`) VALUES
(@EInfoGId, 'NEI_Predominant_clinical_area_of_practice', 'Predominant clinical area of practice', 'String', 'Select', NULL, 0, 0, 0, 40, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'predominant_clinical_area_of_pra', @OGId1, NULL),
(@EInfoGId, 'NEI_Employment_status', 'NEI Employment status', 'String', 'Select', NULL, 0, 0, 0, 56, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'nei_employment_status', @OGId2, NULL),
(@EInfoGId, 'NEI_If_you_are_NOT_EMPLOYED_indicate_how_you_are_actively_seeking_em', 'If you are NOT EMPLOYED, indicate how you are actively seeking employment', 'String', 'Select', NULL, 0, 0, 0, 65, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'if_you_are_not_employed_indicate', @OGId3, NULL),
(@EInfoGId, 'NEI_If_you_are_NOT_EMPLOYED_indicate_how_you_are_', 'If you are NOT EMPLOYED, indicate how you are actively seeking employment', 'String', 'Select', NULL, 0, 0, 0, 65, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'if_you_are_not_employed_indicate', @OGId3, NULL),
(@EInfoGId, 'NEI_Other', 'Other', 'String', 'Text', NULL, 0, 0, 0, 71, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'other', NULL, NULL),
(@EInfoGId, 'NEI_Employer_name', 'Employer name', 'String', 'Text', NULL, 0, 0, 0, 77, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'employer_name', NULL, NULL),
(@EInfoGId, 'NEI_Province_of_employment', 'Province of employment', 'String', 'Select', NULL, 0, 0, 0, 82, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'province_of_employment', @OGId4, NULL),
......@@ -64,7 +64,7 @@ INSERT INTO `civicrm_custom_field` (`custom_group_id`, `name`, `label`, `data_ty
(@CInfoGId, 'NEI_Course_conference_code', 'Course/conference code', 'String', 'Text', NULL, 0, 0, 0, 67, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'course_conference_code', NULL, NULL),
(@CInfoGId, 'NEI_Course_conference_name', 'Course/conference name', 'String', 'Text', NULL, 0, 0, 0, 72, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'course_conference_name', NULL, NULL),
(@CInfoGId, 'NEI_Course_conference_provider', 'Course/conference provider', 'String', 'Text', NULL, 0, 0, 0, 79, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'course_conference_provider', NULL, NULL),
(@CInfoGId, 'NEI_How_will_this_course_enhance_the_nursing_care_you_provide_in_Ont', 'How will this course enhance the nursing care you provide in Ontario?', 'String', 'Select', NULL, 0, 0, 0, 83, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'how_will_this_course_enhance_the', @OGId9, NULL),
(@CInfoGId, 'NEI_How_will_this_course_enhance_the_nursing_care', 'How will this course enhance the nursing care you provide in Ontario?', 'String', 'Select', NULL, 0, 0, 0, 83, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'how_will_this_course_enhance_the', @OGId9, NULL),
(@CInfoGId, 'NEI_Proof_of_completion', 'Proof of completion', 'File', 'File', NULL, 0, 0, 0, 90, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'proof_of_completion', NULL, NULL),
(@CInfoGId, 'NEI_Proof_of_payment', 'Proof of payment', 'File', 'File', NULL, 0, 0, 0, 98, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'proof_of_payment', NULL, NULL),
(@CInfoGId, 'NEI_Type_of_Course_Provider', 'Type of Course Provider', 'String', 'Select', NULL, 0, 0, 0, 128, NULL, NULL, NULL, NULL, NULL, 1, 0, NULL, 255, NULL, NULL, NULL, NULL, 60, 4, 'type_of_course_provider', @OGId10, NULL),
......
......@@ -101,7 +101,7 @@ ALTER TABLE `civicrm_grant_program`
-- add columns to civicrm_grant
ALTER TABLE `civicrm_grant`
ADD `grant_program_id` INT( 10 ) UNSIGNED NOT NULL COMMENT 'Grant Program ID of grant program record given grant belongs to.' AFTER `contact_id`,
ADD `grant_rejected_reason_id` INT( 10 ) UNSIGNED NOT NULL COMMENT 'Id of Grant Rejected Reason.' AFTER `status_id` ,
ADD `grant_rejected_reason_id` INT( 10 ) UNSIGNED NULL DEFAULT NULL COMMENT 'Id of Grant Rejected Reason.' AFTER `status_id` ,
ADD `assessment` VARCHAR( 655 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER `grant_rejected_reason_id`;
--
......@@ -205,23 +205,33 @@ SET @opv7 := '';
SELECT @opGId := id FROM civicrm_option_group WHERE name = 'grant_status';
-- option values
SELECT @opv1 := id FROM civicrm_option_value WHERE name = 'Approved' AND option_group_id = @opGId;
SELECT @opv2 := id FROM civicrm_option_value WHERE name = 'Rejected' AND option_group_id = @opGId;
UPDATE `civicrm_option_value` SET label = 'Awaiting Information', weight = 2 WHERE name = 'Awaiting Information' AND option_group_id = @opGId;
UPDATE `civicrm_option_value` SET weight = 5 WHERE name = 'Paid' AND option_group_id = @opGId;
UPDATE `civicrm_option_value` SET weight = 7 WHERE name = 'Withdrawn' AND option_group_id = @opGId;
UPDATE `civicrm_option_value` SET label = 'Ineligible', name = 'Ineligible', weight = 6 WHERE name = 'Rejected' AND id = @opv2;
UPDATE `civicrm_option_value` SET label = 'Eligible', name = 'Eligible', weight = 3 WHERE name = 'Approved' OR name = 'Granted' AND option_group_id = @opGId;
UPDATE `civicrm_option_value` SET label = 'Submitted', name = 'Submitted'WHERE name = 'Pending' AND option_group_id = @opGId;
SELECT @opv3 := id FROM civicrm_option_value WHERE name = 'Awaiting Information' AND option_group_id = @opGId;
SELECT @opv4 := id FROM civicrm_option_value WHERE name = 'Withdrawn' AND option_group_id = @opGId;
SELECT @opv5 := id FROM civicrm_option_value WHERE name = 'Paid' AND option_group_id = @opGId;
SELECT @opv6 := id FROM civicrm_option_value WHERE name = 'Eligible' AND option_group_id = @opGId;
SELECT @opv7 := id FROM civicrm_option_value WHERE name = 'Approved for Payment' AND option_group_id = @opGId;
SELECT @opv8 := id FROM civicrm_option_value WHERE name = 'Ineligible' AND option_group_id = @opGId;
SELECT @opv10 := id FROM civicrm_option_value WHERE name = 'Submitted' AND option_group_id = @opGId;
UPDATE `civicrm_option_value` SET weight = 7 WHERE id = @opv4;
UPDATE `civicrm_option_value` SET label = 'Ineligible', name = 'Ineligible', weight = 6 WHERE id = @opv2;
UPDATE `civicrm_option_value` SET label = 'Eligible', name = 'Eligible', weight = 3 WHERE id = @opv1;
UPDATE `civicrm_option_value` SET label = 'Awaiting Information', weight = 2 WHERE id = @opv3;
UPDATE `civicrm_option_value` SET weight = 5 WHERE id = @opv5;
SELECT @gtype := id FROM civicrm_option_group WHERE name = 'grant_type';
INSERT IGNORE INTO `civicrm_option_value` (`id`, `option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `domain_id`, `visibility_id`)
VALUES
(@opv7, @opGId, 'Approved for Payment', '7', 'Approved for Payment', NULL, 0, 0, 4, NULL, 0, 1, 1, NULL, NULL, NULL);
(@opv7, @opGId, 'Approved for Payment', '7', 'Approved for Payment', NULL, 0, 0, 4, NULL, 0, 1, 1, NULL, NULL, NULL),
(@opv3, @opGId, 'Awaiting Information', 5, 'Awaiting Information', NULL, 0, 0, 2, NULL, 0, 1, 1, NULL, NULL, NULL),
(@opv8, @opGId, 'Ineligible', 3, 'Ineligible', NULL, 0, 0, 4, NULL, 0, 1, 1, NULL, NULL, NULL),
(@opv5, @opGId, 'Paid', 4, 'Paid', NULL, 0, 0, 5, NULL, 0, 1, 1, NULL, NULL, NULL),
(@opv10, @opGId, 'Submitted', 1, 'Submitted', NULL, 0, 0, 1, NULL, 0, 1, 1, NULL, NULL, NULL),
(@opv4, @opGId, 'Withdrawn', 6, 'Withdrawn', NULL, 0, 0, 7, NULL, 0, 1, 1, NULL, NULL, NULL),
('', @gtype, 'NEI Grant', 6, 'NEI Grant', NULL, 0, 0, 7, NULL, 0, 1, 1, NULL, 1, NULL);
-- reason_grant_ineligible
SET @opGId := '';
......@@ -279,4 +289,43 @@ SELECT @weight := MAX(weight) FROM civicrm_navigation WHERE parent_id = @parent
INSERT INTO `civicrm_navigation` (`domain_id`, `label`, `name`, `url`, `permission`, `permission_operator`, `parent_id`, `is_active`, `has_separator`, `weight`) VALUES
(1, 'Find Grant Payments', 'Find Grant Payments', 'civicrm/grant/payment/search&reset=1', 'access CiviGrant', 'AND', @parentId2, 1, 1, @weight = @weight + 1),
(1, 'New Grant Program', 'New Grant Program', 'civicrm/grant_program?action=add&reset=1', 'access CiviCRM,access CiviGrant,edit grants', 'AND', @parentId2, 1, 0, @weight = @weight + 1),
(1, 'Grant Programs', 'Grant Programs', 'civicrm/grant_program&reset=1', 'access CiviGrant,administer CiviCRM', 'AND', @parentId1, 1, NULL, 2);
\ No newline at end of file
(1, 'Grant Programs', 'Grant Programs', 'civicrm/grant_program&reset=1', 'access CiviGrant,administer CiviCRM', 'AND', @parentId1, 1, NULL, 2);
-- Accounting integration RG-125
SELECT @contactId := contact_id FROM civicrm_domain WHERE id = 1;
SELECT @option_group_id_arel := max(id) from civicrm_option_group where name = 'account_relationship';
SELECT @weight := max(weight) from civicrm_option_value where option_group_id = @option_group_id_arel;
SET @weight := @weight + 1;
SELECT @option_value_rel_id_exp := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Expense Account is';
SELECT @option_value_rel_id_as := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Asset Account is';
INSERT INTO
`civicrm_option_value` (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_arel, 'Accounts Payable Account is', @weight, 'Accounts Payable Account is', NULL, 0, 0, @weight, 'Accounts Payable Account is', 0, 1, 1, 2, NULL);
SELECT @financialAccount := id FROM civicrm_financial_account WHERE name = 'NEI Grant';
SELECT @depositAccount := id FROM civicrm_financial_account WHERE name = 'Deposit Bank Account';
SELECT @accountPayable := id FROM civicrm_financial_account WHERE name = 'Accounts Payable';
INSERT IGNORE INTO civicrm_financial_account (id, name, contact_id, is_header_account, financial_account_type_id, accounting_code, account_type_code, is_active)
VAlUES (@financialAccount, 'NEI Grant', @contactId, 0, 5, 5555, 'EXP', 1);
SET @financialAccountID := LAST_INSERT_ID();
INSERT INTO civicrm_financial_type (name, is_deductible, is_reserved, is_active)
VALUES ('NEI Grant', 0, 0, 1);
SET @financialTypeID := LAST_INSERT_ID();
INSERT INTO civicrm_entity_financial_account (entity_table, entity_id, account_relationship, financial_account_id)
-- Expense account
VALUES('civicrm_financial_type', @financialTypeID, @option_value_rel_id_exp, IFNULL(@financialAccount, @financialAccountID)),
-- Asset Account of
('civicrm_financial_type', @financialTypeID, @option_value_rel_id_as, @depositAccount),
-- Account Payable
('civicrm_financial_type', @financialTypeID, @weight, @accountPayable);
......@@ -25,3 +25,16 @@
* Toronto, ON
* Canada M5T 2C7
*/
-- Accounting integration
SELECT @option_group_id_arel := max(id) from civicrm_option_group where name = 'account_relationship';
DELETE FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Accounts Payable';
SELECT @financialType := id FROM civicrm_financial_type WHERE name = 'NEI Grant';
DELETE FROM civicrm_entity_financial_account WHERE entity_table = 'civicrm_financial_type' AND entity_id = @financialType;
DELETE FROM civicrm_financial_account WHERE name = 'NEI Grant';
DELETE FROM civicrm_financial_type WHERE name = 'NEI Grant';
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment