Answers.Body: <p>This is not an elegant solution by any means.  But it does work.  So there's that.</p>
  
  <p>To start, I copied the Bookkeeping transactions report from here (sites\all\modules\contrib\civicrm\CRM\Report\Form\Contribute) and renamed it Reconcile.php and placed the new file in my custom PHP folder so I wouldn't be adjusting the original report.</p>
  
  <p>I renamed the class on line 35 to <code>CRM_Report_Form_Contribute_Reconcile</code> so the class name and file name match.</p>
  
  <p>My report does not require both the Receive Date and Transaction Date columns, so I re-purposed the Transaction Date column. (Truthfully, I would rather have been able to add a column for this, instead of re-purposing an existing one... but alas, I didn't know how). In the <code>function __construct()</code>, under <code>'civicrm_financial_trxn'</code> <code>'fields'</code>, I changed the <code>'title'</code> of <code>'trxn_date'</code> to 'Est Deposit Date'.  Approx line 299:</p>
  
  <pre><code>'trxn_date' =&gt; array(
    'title' =&gt; ts('Est Deposit Date'),
    'default' =&gt; TRUE,
    'type' =&gt; CRM_Utils_Type::T_DATE,
  ),
  </code></pre>
  
  <p>I also changed the title in the <code>'filters'</code> section so that the UI would match.</p>
  
  <p>Then in <code>'function select()'</code>, I added another <code>case</code> to the <code>switch ($fieldName)</code> (which begins approx line 371). Our payment instrument 1 is credit/debit cards. Our payment instrument 2 is ACH/EFT.</p>
  
  <pre><code>//adjust Transaction Date column to yield adjusted dates for Estimated Deposit Date
  case 'trxn_date':
    $select[] = " CASE 
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 1 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 1
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 1 DAY)
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 1 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 6
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 3 DAY)
  
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 1
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 10 DAY)
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 2
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 9 DAY)
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 3
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 8 DAY)
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 4
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 7 DAY)
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 5
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 6 DAY)
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 6
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 5 DAY)
       WHEN {$this-&gt;_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date) = 7
       THEN DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 4 DAY)
  
       ELSE DATE_ADD({$this-&gt;_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 2 DAY)
       END AS civicrm_financial_trxn_trxn_date ";
  break;
  </code></pre>
  
  <p>I'd be curious to hear and learn how others might have tackled this. I know I could have done this as an extension, but that would have been more work for me at this point.  Maybe if I learned the extension system better it wouldn't be more work in the future.  :-)  I also initially tried finding a solution in Drupal Views, but I couldn't sort out how to add days to a date within the Views ecosystem.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-22T19:08:11.823Z
Answers.LastActivityDate: 2016-11-22T19:08:11.823Z
Answers.UserDisplayName: Allen Hutchison
Body: <p>Our Treasurer has asked for a report that will help him reconcile the monthly bank statement more efficiently. As with most financial services vendors, our vendor (iATS) has a delay between the transaction date (or receive date in Civi) and the day the money is actually deposited into our organization's bank account.  This creates an extra step for our treasurer as he has to line up the transaction dates in Civi to the deposit dates on the bank statement.</p>
  
  <p>iATS has the added wrinkle that credit/debit card transactions are deposited on a different schedule than ACH/EFT transactions.  <strong>How can I create a column in the CiviContribute Bookkeeping Transactions report that will give an estimated deposit date for each donation based on what type of payment instrument was used and what day of the week the transaction took place?</strong></p>
  
  <p>For reference, iATS deposits transactions on this schedule:</p>
  
  <ul>
  <li>Credit/Debit cards - 1-2 business days, rolling; to be safe, the default on the report will be 2 business days unless the transaction happens on a Friday-Sunday; then it will be the following Monday.</li>
  <li>ACH/EFT - each Sunday through Saturday is deposited on the following Wednesday.</li>
  </ul>
  
  <p>Civi 4.6.20, Drupal 7</p>
  
Tags: <civicontribute><civireport><developer><mysql>
Title: CiviReport - Add days to Transaction Date for Estimated Deposit Date
ThreadText: # CiviReport - Add days to Transaction Date for Estimated Deposit Date
  
  (Asked by: username_0 on 2016-11-22)
  
  Our Treasurer has asked for a report that will help him reconcile the monthly bank statement more efficiently. As with most financial services vendors, our vendor (iATS) has a delay between the transaction date (or receive date in Civi) and the day the money is actually deposited into our organization's bank account. This creates an extra step for our treasurer as he has to line up the transaction dates in Civi to the deposit dates on the bank statement.
  
  iATS has the added wrinkle that credit/debit card transactions are deposited on a different schedule than ACH/EFT transactions. **How can I create a column in the CiviContribute Bookkeeping Transactions report that will give an estimated deposit date for each donation based on what type of payment instrument was used and what day of the week the transaction took place?**
  
  For reference, iATS deposits transactions on this schedule:
  
  * Credit/Debit cards - 1-2 business days, rolling; to be safe, the default on the report will be 2 business days unless the transaction happens on a Friday-Sunday; then it will be the following Monday.
  * ACH/EFT - each Sunday through Saturday is deposited on the following Wednesday.
  
  Civi 4.6.20, Drupal 7
  
  **Tags:** civicontribute, civireport, developer, mysql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-11-22. Score: 2
  
  This is not an elegant solution by any means.  But it does work.  So there's that.
  To start, I copied the Bookkeeping transactions report from here (sites\all\modules\contrib\civicrm\CRM\Report\Form\Contribute) and renamed it Reconcile.php and placed the new file in my custom PHP folder so I wouldn't be adjusting the original report.
  I renamed the class on line 35 to CRM_Report_Form_Contribute_Reconcile so the class name and file name match.
  My report does not require both the Receive Date and Transaction Date columns, so I re-purposed the Transaction Date column. (Truthfully, I would rather have been able to add a column for this, instead of re-purposing an existing one... but alas, I didn't know how). In the function __construct(), under 'civicrm_financial_trxn' 'fields', I changed the 'title' of 'trxn_date' to 'Est Deposit Date'.  Approx line 299:
  'trxn_date' => array(
    'title' => ts('Est Deposit Date'),
    'default' => TRUE,
    'type' => CRM_Utils_Type::T_DATE,
  ),
  
  I also changed the title in the 'filters' section so that the UI would match.
  Then in 'function select()', I added another case to the switch ($fieldName) (which begins approx line 371). Our payment instrument 1 is credit/debit cards. Our payment instrument 2 is ACH/EFT.
  //adjust Transaction Date column to yield adjusted dates for Estimated Deposit Date
  case 'trxn_date':
    $select[] = " CASE 
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 1 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 1
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 1 DAY)
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 1 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 6
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 3 DAY)
  
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 1
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 10 DAY)
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 2
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 9 DAY)
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 3
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 8 DAY)
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 4
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 7 DAY)
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 5
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 6 DAY)
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 6
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 5 DAY)
       WHEN {$this->_aliases['civicrm_financial_trxn']}.payment_instrument_id = 2 AND DAYOFWEEK({$this->_aliases['civicrm_financial_trxn']}.trxn_date) = 7
       THEN DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 4 DAY)
  
       ELSE DATE_ADD({$this->_aliases['civicrm_financial_trxn']}.trxn_date, INTERVAL 2 DAY)
       END AS civicrm_financial_trxn_trxn_date ";
  break;
  
  I'd be curious to hear and learn how others might have tackled this. I know I could have done this as an extension, but that would have been more work for me at this point.  Maybe if I learned the extension system better it wouldn't be more work in the future.  :-)  I also initially tried finding a solution in Drupal Views, but I couldn't sort out how to add days to a date within the Views ecosystem.
  
  
  ---
  
  