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 {
$journalLineEntry->setTransactionAmount($entry['AMOUNT']);
$this->_setMetaData($journalLineEntry, $entry);
$journalLineEntry->setMemo($entry['DESCRIPTION']);
$customFields = new CustomAllocationSplit($entry['customfields']);
$journalLineEntry->setCustomAllocationSplits($customFields);
$journalLineEntry->setCustomFields($entry['customfields']);
return $journalLineEntry;
}
public function createGLBatch($GLBatch) {
$journalEntry = new JournalEntryCreate();
$journalEntry->setJournalSymbol('GJ');
$journalEntry->setJournalSymbol('CIVI');
$journalEntry->setReferenceNumber($GLBatch['REFERENCENO']);
$journalEntry->setPostingDate($GLBatch['BATCH_DATE']);
$journalEntry->setDescription($GLBatch['BATCH_TITLE']);
$journalEntry->setAction('Draft');
......
......@@ -96,9 +96,11 @@ class CRM_Syncintacct_Util {
public static function formatGLBatchParams($dao, $batchID) {
$batch = civicrm_api3('Batch', 'getsingle', ['id' => $batchID]);
$GLBatch = [
'JOURNAL' => 'CIVIBATCH' . $batchID,
'JOURNAL' => 'TEST',
'BATCH_DATE' => new DateTime($batch['created_date']),
'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' => [],
];
$queryResults = [];
......@@ -107,7 +109,9 @@ class CRM_Syncintacct_Util {
$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;
$values = self::getAccountDataByCode($accountID);
// Items in lowercase are for bundling purposes, they aren't part of the Intacct spec.
$GLBatch['ENTRIES'][] = [
'account_name' => $accountName,
'ACCOUNTNO' => $dao->credit_account ?: $dao->from_credit_account,
'ACCOUNTID' => $accountID,
'CURRENCY' => $dao->currency,
......@@ -119,14 +123,15 @@ class CRM_Syncintacct_Util {
'LOCATION' => $values['location'],
'PROJECTID' => $values['project_id'],
'customfields' => [
'batch_id' => $batchID,
'financial_trxn_id' => $dao->financial_trxn_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_BATCH_ID' => $batchID,
'FINANCIAL_TRXN_ID' => $dao->financial_trxn_id,
'FINANCIAL_ITEM_ID' => $dao->financial_item_id,
'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);
$GLBatch['ENTRIES'][] = [
'account_name' => $accountName,
'ACCOUNTNO' => $dao->to_account_code,
'ACCOUNTID' => $dao->to_account_id,
'CURRENCY' => $dao->currency,
......@@ -138,10 +143,10 @@ class CRM_Syncintacct_Util {
'PROJECTID' => $values['project_id'],
'CONTRIBUTION_AMOUNT' => $dao->contribution_amount,
'customfields' => [
'batch_id' => $batchID,
'financial_trxn_id' => $dao->financial_trxn_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_BATCH_ID' => $batchID,
'FINANCIAL_TRXN_ID' => $dao->financial_trxn_id,
'FINANCIAL_ITEM_ID' => $dao->financial_item_id,
'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);
......@@ -175,10 +180,10 @@ class CRM_Syncintacct_Util {
'LOCATION' => $values['location'],
'PROJECTID' => $values['project_id'],
'customfields' => [
'batch_id' => $batchID,
'financial_trxn_id' => $dao->financial_trxn_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_BATCH_ID' => $batchID,
'FINANCIAL_TRXN_ID' => $dao->financial_trxn_id,
'FINANCIAL_ITEM_ID' => $dao->financial_item_id,
'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