CRM-19800, added test
authorPradeep Nayak <pradpnayak@gmail.com>
Sun, 25 Dec 2016 19:17:41 +0000 (00:47 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Mon, 2 Jan 2017 08:32:09 +0000 (14:02 +0530)
----------------------------------------
* CRM-19800: Incorrect Amount recorded in civicrm_financial_trxn table
  https://issues.civicrm.org/jira/browse/CRM-19800

tests/phpunit/CRM/Contribute/BAO/ContributionTest.php

index 54dc980092d89a80b76097e7487bda46a6cc76e4..d2f13ef4159bc8ff28fc5a5b8ee156a51961e003 100644 (file)
@@ -1038,4 +1038,35 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
     }
   }
 
+  /**
+   * Test recording of amount with comma separator.
+   */
+  public function testCommaSeparatorAmount() {
+    $contactId = $this->individualCreate();
+
+    $params = array(
+      'contact_id' => $contactId,
+      'currency' => 'USD',
+      'financial_type_id' => 1,
+      'contribution_status_id' => 8,
+      'payment_instrument_id' => 1,
+      'receive_date' => '20080522000000',
+      'receipt_date' => '20080522000000',
+      'total_amount' => '20000.00',
+      'partial_payment_total' => '20,000.00',
+      'partial_amount_pay' => '8,000.00',
+    );
+
+    $contribution = CRM_Contribute_BAO_Contribution::create($params);
+    $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'DESC');
+    $financialTrxn = $this->callAPISuccessGetSingle(
+      'FinancialTrxn',
+      array(
+        'id' => $lastFinancialTrxnId['financialTrxnId'],
+        'return' => array('total_amount'),
+      )
+    );
+    $this->assertEquals($financialTrxn['total_amount'], 8000, 'Invalid Tax amount.');
+  }
+
 }