+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016 |
+ | Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
public function preProcess() {
// Check permission for action.
if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
+ // @todo replace with throw new CRM_Core_Exception().
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
else {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1, TRUE, TRUE);
}
+ // wtf?
empty($lineItem) ? NULL : $this->_lineItems[] = $lineItem;
}
- $this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems);
+ $this->assign('lineItem', empty($lineItem) ? FALSE : array($lineItem));
// Set title
if ($this->_mode && $this->_id) {
$defaults['fee_amount'] = CRM_Utils_Money::format($defaults['fee_amount'], NULL, '%a');
}
- if (isset($defaults['net_amount'])) {
- $defaults['net_amount'] = CRM_Utils_Money::format($defaults['net_amount'], NULL, '%a');
- }
-
if ($this->_contributionType) {
$defaults['financial_type_id'] = $this->_contributionType;
}
$paymentInstrument = FALSE;
if (!$this->_mode) {
+ $checkPaymentID = array_search('Check', CRM_Contribute_PseudoConstant::paymentInstrument('name'));
$paymentInstrument = $this->add('select', 'payment_instrument_id',
ts('Payment Method'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
- TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
+ TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);")
);
}
if ($this->_online) {
$this->assign('hideCalender', TRUE);
}
- $checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']);
+ $checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['contribution_check_number']);
$this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->addDateTime('cancel_date', ts('Cancelled / Refunded Date'), FALSE, array('formatType' => 'activityDateTime'));
if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) {
$sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
- // For taxable contribution we need to deduct taxable amount from
- // (net amount + fee amount) before comparing it with total amount
- if (!empty($self->_values['tax_amount'])) {
- $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($self->_id);
- if (!(CRM_Utils_Array::value('membership', $componentDetails) ||
- CRM_Utils_Array::value('participant', $componentDetails))
- ) {
- $sum = CRM_Utils_Money::format($sum - $self->_values['tax_amount'], NULL, '%a');
- }
- }
if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
$errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount');
}
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID) {
- $softIDs = array();
+
$pId = $contribution = $isRelatedId = FALSE;
$this->_params = $submittedValues;
$this->beginPostProcess();
}
if (!isset($submittedValues['total_amount'])) {
- $submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values);
+ $submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values) - CRM_Utils_Array::value('tax_amount', $this->_values);
}
$this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
}
$taxRate = array();
$getTaxDetails = FALSE;
- if ($action & CRM_Core_Action::ADD) {
- $line = $lineItem;
- }
- elseif ($action & CRM_Core_Action::UPDATE) {
- $line = $this->_lineItems;
- }
- foreach ($line as $key => $value) {
+
+ foreach ($lineItem as $key => $value) {
foreach ($value as $v) {
if (isset($taxRate[(string) CRM_Utils_Array::value('tax_rate', $v)])) {
$taxRate[(string) $v['tax_rate']] = $taxRate[(string) $v['tax_rate']] + CRM_Utils_Array::value('tax_amount', $v);