Verified Commit 401a8e93 authored by JonGold's avatar JonGold

populate custom fields; handle reference number; post to Civi Journal; pass...

populate custom fields; handle reference number; post to Civi Journal; pass account name to batching hook
parent 5e04ae76
...@@ -92,14 +92,14 @@ class CRM_Syncintacct_API { ...@@ -92,14 +92,14 @@ class CRM_Syncintacct_API {
$journalLineEntry->setTransactionAmount($entry['AMOUNT']); $journalLineEntry->setTransactionAmount($entry['AMOUNT']);
$this->_setMetaData($journalLineEntry, $entry); $this->_setMetaData($journalLineEntry, $entry);
$journalLineEntry->setMemo($entry['DESCRIPTION']); $journalLineEntry->setMemo($entry['DESCRIPTION']);
$customFields = new CustomAllocationSplit($entry['customfields']); $journalLineEntry->setCustomFields($entry['customfields']);
$journalLineEntry->setCustomAllocationSplits($customFields);
return $journalLineEntry; return $journalLineEntry;
} }
public function createGLBatch($GLBatch) { public function createGLBatch($GLBatch) {
$journalEntry = new JournalEntryCreate(); $journalEntry = new JournalEntryCreate();
$journalEntry->setJournalSymbol('GJ'); $journalEntry->setJournalSymbol('CIVI');
$journalEntry->setReferenceNumber($GLBatch['REFERENCENO']);
$journalEntry->setPostingDate($GLBatch['BATCH_DATE']); $journalEntry->setPostingDate($GLBatch['BATCH_DATE']);
$journalEntry->setDescription($GLBatch['BATCH_TITLE']); $journalEntry->setDescription($GLBatch['BATCH_TITLE']);
$journalEntry->setAction('Draft'); $journalEntry->setAction('Draft');
......
...@@ -96,9 +96,11 @@ class CRM_Syncintacct_Util { ...@@ -96,9 +96,11 @@ class CRM_Syncintacct_Util {
public static function formatGLBatchParams($dao, $batchID) { public static function formatGLBatchParams($dao, $batchID) {
$batch = civicrm_api3('Batch', 'getsingle', ['id' => $batchID]); $batch = civicrm_api3('Batch', 'getsingle', ['id' => $batchID]);
$GLBatch = [ $GLBatch = [
'JOURNAL' => 'CIVIBATCH' . $batchID, 'JOURNAL' => 'TEST',
'BATCH_DATE' => new DateTime($batch['created_date']), 'BATCH_DATE' => new DateTime($batch['created_date']),
'BATCH_TITLE' => $batch['title'], 'BATCH_TITLE' => $batch['title'],
// REFERENCENO should be "October 2018" if running in November 2018.
'REFERENCENO' => "CiviCRM - " . (new DateTime('first day of last month'))->format('F Y'),
'ENTRIES' => [], 'ENTRIES' => [],
]; ];
$queryResults = []; $queryResults = [];
...@@ -107,7 +109,9 @@ class CRM_Syncintacct_Util { ...@@ -107,7 +109,9 @@ class CRM_Syncintacct_Util {
$accountName = $dao->credit_account ? $dao->credit_account_name : $dao->from_credit_account_name; $accountName = $dao->credit_account ? $dao->credit_account_name : $dao->from_credit_account_name;
$accountID = $dao->credit_account ? $dao->credit_account_id : $dao->from_credit_account_id; $accountID = $dao->credit_account ? $dao->credit_account_id : $dao->from_credit_account_id;
$values = self::getAccountDataByCode($accountID); $values = self::getAccountDataByCode($accountID);
// Items in lowercase are for bundling purposes, they aren't part of the Intacct spec.
$GLBatch['ENTRIES'][] = [ $GLBatch['ENTRIES'][] = [
'account_name' => $accountName,
'ACCOUNTNO' => $dao->credit_account ?: $dao->from_credit_account, 'ACCOUNTNO' => $dao->credit_account ?: $dao->from_credit_account,
'ACCOUNTID' => $accountID, 'ACCOUNTID' => $accountID,
'CURRENCY' => $dao->currency, 'CURRENCY' => $dao->currency,
...@@ -119,14 +123,15 @@ class CRM_Syncintacct_Util { ...@@ -119,14 +123,15 @@ class CRM_Syncintacct_Util {
'LOCATION' => $values['location'], 'LOCATION' => $values['location'],
'PROJECTID' => $values['project_id'], 'PROJECTID' => $values['project_id'],
'customfields' => [ 'customfields' => [
'batch_id' => $batchID, 'CIVICRM_BATCH_ID' => $batchID,
'financial_trxn_id' => $dao->financial_trxn_id, 'FINANCIAL_TRXN_ID' => $dao->financial_trxn_id,
'financial_item_id' => $dao->financial_item_id, 'FINANCIAL_ITEM_ID' => $dao->financial_item_id,
'url' => CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&id={$dao->entity_id}&cid={$dao->contact_id}&action=view", TRUE), 'CIVICRM_URL' => CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&id={$dao->entity_id}&cid={$dao->contact_id}&action=view", TRUE),
] ]
]; ];
$values = self::getAccountDataByCode($dao->to_account_id); $values = self::getAccountDataByCode($dao->to_account_id);
$GLBatch['ENTRIES'][] = [ $GLBatch['ENTRIES'][] = [
'account_name' => $accountName,
'ACCOUNTNO' => $dao->to_account_code, 'ACCOUNTNO' => $dao->to_account_code,
'ACCOUNTID' => $dao->to_account_id, 'ACCOUNTID' => $dao->to_account_id,
'CURRENCY' => $dao->currency, 'CURRENCY' => $dao->currency,
...@@ -138,10 +143,10 @@ class CRM_Syncintacct_Util { ...@@ -138,10 +143,10 @@ class CRM_Syncintacct_Util {
'PROJECTID' => $values['project_id'], 'PROJECTID' => $values['project_id'],
'CONTRIBUTION_AMOUNT' => $dao->contribution_amount, 'CONTRIBUTION_AMOUNT' => $dao->contribution_amount,
'customfields' => [ 'customfields' => [
'batch_id' => $batchID, 'CIVICRM_BATCH_ID' => $batchID,
'financial_trxn_id' => $dao->financial_trxn_id, 'FINANCIAL_TRXN_ID' => $dao->financial_trxn_id,
'financial_item_id' => $dao->financial_item_id, 'FINANCIAL_ITEM_ID' => $dao->financial_item_id,
'url' => CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&id={$dao->entity_id}&cid={$dao->contact_id}&action=view", TRUE), 'CIVICRM_URL' => CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&id={$dao->entity_id}&cid={$dao->contact_id}&action=view", TRUE),
], ],
]; ];
$queryResults[] = get_object_vars($dao); $queryResults[] = get_object_vars($dao);
...@@ -175,10 +180,10 @@ class CRM_Syncintacct_Util { ...@@ -175,10 +180,10 @@ class CRM_Syncintacct_Util {
'LOCATION' => $values['location'], 'LOCATION' => $values['location'],
'PROJECTID' => $values['project_id'], 'PROJECTID' => $values['project_id'],
'customfields' => [ 'customfields' => [
'batch_id' => $batchID, 'CIVICRM_BATCH_ID' => $batchID,
'financial_trxn_id' => $dao->financial_trxn_id, 'FINANCIAL_TRXN_ID' => $dao->financial_trxn_id,
'financial_item_id' => $dao->financial_item_id, 'FINANCIAL_ITEM_ID' => $dao->financial_item_id,
'url' => CRM_Utils_System::url('civicrm/contact/view/grant', "reset=1&id={$dao->entity_id}&cid={$dao->contact_id}&action=view", TRUE), 'CIVICRM_URL' => CRM_Utils_System::url('civicrm/contact/view/grant', "reset=1&id={$dao->entity_id}&cid={$dao->contact_id}&action=view", TRUE),
] ]
]; ];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment