Skip to content

Commit

Permalink
Merge pull request #3 from eileenmcnaughton/karing
Browse files Browse the repository at this point in the history
Resolve immediate issues with test & add checks for mail content (sin…
  • Loading branch information
KarinG authored Mar 9, 2017
2 parents 335c41e + f1662cb commit 5c138fc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
14 changes: 5 additions & 9 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,11 @@ public function preProcess() {
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 : $lineItem);

// Set title
if ($this->_mode && $this->_id) {
Expand Down Expand Up @@ -1432,7 +1433,7 @@ public function testSubmit($params, $action, $creditCardMode = NULL) {
* @throws \Exception
*/
protected function submit($submittedValues, $action, $pledgePaymentID) {
$softIDs = array();

$pId = $contribution = $isRelatedId = FALSE;
$this->_params = $submittedValues;
$this->beginPostProcess();
Expand Down Expand Up @@ -1797,13 +1798,8 @@ protected function invoicingPostProcessHook($submittedValues, $action, $lineItem
}
$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);
Expand Down
26 changes: 23 additions & 3 deletions tests/phpunit/CRM/Contribute/Form/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,12 @@ public function testSubmitWithOutSaleTax() {
$this->assertTrue(empty($lineItem['tax_amount']));
}

/**
* Create a contribution & then edit it via backoffice form, checking tax.
*
* @throws \Exception
*/
public function testReSubmitSaleTax() {
// KG I need to do an Edit of a View Contribution
$this->enableTaxAndInvoicing();
$this->relationForFinancialTypeWithFinancialAccount($this->_financialTypeId);
$form = new CRM_Contribute_Form_Contribution();
Expand All @@ -875,10 +879,12 @@ public function testReSubmitSaleTax() {
'return' => array('tax_amount', 'total_amount', 'net_amount', 'financial_type_id', 'receive_date', 'payment_instrument_id'),
)
);
$this->assertEquals(110, $contribution['total_amount']);
$this->assertEquals(10, $contribution['tax_amount']);

$test = 1;
$mut = new CiviMailUtils($this, TRUE);
$form->testSubmit(array(
'contribution_id' => $contribution['id'],
'id' => $contribution['id'],
'total_amount' => $contribution['total_amount'],
'net_amount' => $contribution['net_amount'],
'tax_amount' => $contribution['tax_amount'],
Expand All @@ -887,6 +893,9 @@ public function testReSubmitSaleTax() {
'payment_instrument_id' => $contribution['payment_instrument_id'],
'price_set_id' => 0,
'check_number' => 12345,
'contribution_status_id' => 1,
'is_email_receipt' => 1,
'from_email_address' => 'demo@example.com',
),
CRM_Core_Action::UPDATE
);
Expand All @@ -895,7 +904,18 @@ public function testReSubmitSaleTax() {
'contact_id' => $this->_individualId,
)
);
$strings = array(
'Financial Type: Donation',
'Amount before Tax : $ 110.00',
'Sales Tax 10.00% : $ 11.00',
'Total Tax Amount : $ 11.00',
'Total Amount : $ 121.00',
'Date Received: April 21st, 2015',
'Paid By: Check',
'Check Number: 12345',
);

$mut->checkMailLog($strings);
$this->assertEquals(110, $contribution['total_amount']);
$this->assertEquals(10, $contribution['tax_amount']);
$this->callAPISuccessGetCount('FinancialTrxn', array(), 1);
Expand Down

0 comments on commit 5c138fc

Please sign in to comment.