From f7fb5615144165b9e250575b30657af49200b841 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 11 Apr 2017 18:24:15 +1200 Subject: [PATCH] Towards CRM-20392 fix receive_date to use date_picker This might not have been necessary in the end - https://github.com/civicrm/civicrm-packages/pull/178 seems like the fix for the breakage, but we should be making this change on every form we touch in order to get rid of code complexity. --- CRM/Contribute/BAO/Contribution.php | 1 + CRM/Contribute/Form/AdditionalPayment.php | 15 +++++---------- CRM/Core/DAO/AllCoreTables.data.php | 2 +- CRM/Financial/DAO/FinancialTrxn.php | 6 +++++- .../CRM/Contribute/Form/AdditionalPayment.tpl | 10 +++++----- xml/schema/Financial/FinancialTrxn.xml | 4 ++++ 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 04abf8642a..2f759741f0 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3899,6 +3899,7 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']}) $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' ")); $trxnsData['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($contributionDAO->financial_type_id, $relationTypeId); + // @todo remove deprecated fn call. $trxnsData['status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name'); // record the entry $financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnsData); diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index b6cee86c1b..7815e1352d 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -192,12 +192,8 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $defaults = array_merge($defaults, $billingDefaults); } - if (empty($defaults['trxn_date']) && empty($defaults['trxn_date_time'])) { - list($defaults['trxn_date'], $defaults['trxn_date_time']) - = CRM_Utils_Date::setDateDefaults( - CRM_Utils_Array::value('register_date', $defaults), - 'activityDateTime' - ); + if (empty($defaults['trxn_date'])) { + $defaults['trxn_date'] = date('Y-m-d H:i:s'); } if ($this->_refund) { @@ -299,9 +295,8 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $this->add('textarea', 'receipt_text', ts('Confirmation Message')); - // add various dates $dateLabel = ($this->_refund) ? ts('Refund Date') : ts('Date Received'); - $this->addDateTime('trxn_date', $dateLabel, FALSE, array('formatType' => 'activityDateTime')); + $this->addField('trxn_date', array('entity' => 'FinancialTrxn', 'label' => $dateLabel, 'context' => 'Contribution'), FALSE, FALSE); if ($this->_contactId && $this->_id) { if ($this->_component == 'event') { @@ -395,7 +390,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract ) ); } - $submittedValues['trxn_date'] = CRM_Utils_Date::processDate($submittedValues['trxn_date'], $submittedValues['trxn_date_time']); + if ($this->_mode) { // process credit card $this->assign('contributeMode', 'direct'); @@ -533,7 +528,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract ); if (!empty($this->_params['trxn_date'])) { - $this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['trxn_date'], $this->_params['trxn_date_time']); + $this->_params['receive_date'] = $this->_params['trxn_date']; } if (empty($this->_params['invoice_id'])) { diff --git a/CRM/Core/DAO/AllCoreTables.data.php b/CRM/Core/DAO/AllCoreTables.data.php index 0488ea6ce5..94f90424a2 100644 --- a/CRM/Core/DAO/AllCoreTables.data.php +++ b/CRM/Core/DAO/AllCoreTables.data.php @@ -24,7 +24,7 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ */ -// (GenCodeChecksum:53f1cd5e913b2f82abfc7097127caafc) +// (GenCodeChecksum:de6dc96f4442bc90970f8e8c26b1c802) return array( 'CRM_Core_DAO_AddressFormat' => array( 'name' => 'AddressFormat', diff --git a/CRM/Financial/DAO/FinancialTrxn.php b/CRM/Financial/DAO/FinancialTrxn.php index ba5d1961b9..a9d9ab0791 100644 --- a/CRM/Financial/DAO/FinancialTrxn.php +++ b/CRM/Financial/DAO/FinancialTrxn.php @@ -30,7 +30,7 @@ * * Generated from xml/schema/CRM/Financial/FinancialTrxn.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:68f0081011769a1c3286c7d7a74324e3) + * (GenCodeChecksum:505b36cf7c6c052f88ab1ca0f0fc82a0) */ require_once 'CRM/Core/DAO.php'; require_once 'CRM/Utils/Type.php'; @@ -240,6 +240,10 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO { 'entity' => 'FinancialTrxn', 'bao' => 'CRM_Financial_DAO_FinancialTrxn', 'localizable' => 0, + 'html' => array( + 'type' => 'Select Date', + 'formatType' => 'activityDateTime', + ) , ) , 'total_amount' => array( 'name' => 'total_amount', diff --git a/templates/CRM/Contribute/Form/AdditionalPayment.tpl b/templates/CRM/Contribute/Form/AdditionalPayment.tpl index 268da6ac62..2c7cb20796 100644 --- a/templates/CRM/Contribute/Form/AdditionalPayment.tpl +++ b/templates/CRM/Contribute/Form/AdditionalPayment.tpl @@ -109,13 +109,13 @@ - - + {if $showCheckNumber || !$isOnline} @@ -126,7 +126,7 @@ {/if} - + {if $email and $outBound_option != 2} @@ -148,9 +148,9 @@ {$form.receipt_text.html|crmAddClass:huge} - {$form.fee_amount.html|crmMoney:$currency:'XXX':'YYY'}
+
- {$form.net_amount.html|crmMoney:$currency:'':1}
+
{$form.trxn_date.label}{include file="CRM/common/jcalendar.tpl" elementName=trxn_date}
+
{$form.trxn_date.html}
{ts}The date this payment was received.{/ts}
{$form.payment_instrument_id.label}{$form.payment_instrument_id.html} {help id="payment_instrument_id"}{$form.payment_instrument_id.html} {help id="payment_instrument_id"}
{$form.trxn_id.label}{$form.trxn_id.html} {help id="id-trans_id"}{$form.trxn_id.html} {help id="id-trans_id"}
{$form.fee_amount.label}
{$form.fee_amount.label}{$form.fee_amount.html|crmMoney:$currency:'XXX':'YYY'}
{ts}Processing fee for this transaction (if applicable).{/ts}
{$form.net_amount.label}
{$form.net_amount.label}{$form.net_amount.html|crmMoney:$currency:'':1}
{ts}Net value of the payment (Total Amount minus Fee).{/ts}
diff --git a/xml/schema/Financial/FinancialTrxn.xml b/xml/schema/Financial/FinancialTrxn.xml index e6f31fd132..84deead46d 100644 --- a/xml/schema/Financial/FinancialTrxn.xml +++ b/xml/schema/Financial/FinancialTrxn.xml @@ -94,6 +94,10 @@ NULL date transaction occurred 1.3 + + Select Date + activityDateTime + trxn_type -- 2.25.1