Skip to content

Commit

Permalink
Merge pull request #3 from dpradeep/VAT-366-New
Browse files Browse the repository at this point in the history
VAT-366 Handle database entry(lineitem creation etc) of tax amounts
  • Loading branch information
kurund committed May 22, 2014
2 parents dae066a + d91b8b3 commit 06a079d
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,9 @@ public function postProcess() {
}
$params['line_item'] = $lineItem;
$params['payment_processor_id'] = $params['payment_processor'] = CRM_Utils_Array::value('id', $this->_paymentProcessor);
if (CRM_Utils_Array::value('tax_amount', $submittedValues)) {
$params['tax_amount'] = $submittedValues['tax_amount'];
}
//create contribution.
if ($isQuickConfig) {
$params['is_quick_config'] = 1;
Expand Down
2 changes: 2 additions & 0 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public function preProcess() {

$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $this->get('amount');
$this->_params['tax_amount'] = $this->get('tax_amount');

$this->_useForMember = $this->get('useForMember');

Expand Down Expand Up @@ -1193,6 +1194,7 @@ static function processContribution(
'receive_date' => (CRM_Utils_Array::value('receive_date', $params)) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'),
'non_deductible_amount' => $nonDeductibleAmount,
'total_amount' => $params['amount'],
'tax_amount' => $params['tax_amount'],
'amount_level' => CRM_Utils_Array::value('amount_level', $params),
'invoice_id' => $params['invoiceID'],
'currency' => $params['currencyID'],
Expand Down
7 changes: 7 additions & 0 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,10 @@ public function postProcess() {
}
}

if (CRM_Utils_Array::value('tax_amount', $this->_params)) {
$contributionParams['tax_amount'] = $this->_params['tax_amount'];
}

if ($this->_single) {
if (empty($ids)) {
$ids = array();
Expand Down Expand Up @@ -1445,6 +1449,9 @@ public function postProcess() {
($params['status_id'] != array_search('Partially paid', $participantStatus))
) {
$line['unit_price'] = $line['line_total'] = $params['total_amount'];
if (!empty($params['tax_amount'])) {
$line['unit_price'] = $line['unit_price'] - $params['tax_amount'];
}
}
$lineItem[$this->_priceSetId][$lineKey] = $line;
}
Expand Down
2 changes: 2 additions & 0 deletions CRM/Event/Form/Registration/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function preProcess() {
$this->_lineItem = $this->get('lineItem');

$this->_params = $this->get('params');
$this->_params[0]['tax_amount'] = $this->get('tax_amount');

$this->_params[0]['is_pay_later'] = $this->get('is_pay_later');
$this->assign('is_pay_later', $this->_params[0]['is_pay_later']);
Expand Down Expand Up @@ -853,6 +854,7 @@ static function processContribution(&$form, $params, $result, $contactID,
$form->_values['event']['financial_type_id'] : $params['financial_type_id'],
'receive_date' => $now,
'total_amount' => $params['amount'],
'tax_amount' => $params['tax_amount'],
'amount_level' => $params['amount_level'],
'invoice_id' => $params['invoiceID'],
'currency' => $params['currencyID'],
Expand Down
3 changes: 3 additions & 0 deletions CRM/Event/Form/Registration/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,9 @@ public function postProcess() {
else {
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
if ($params['tax_amount']) {
$this->set('tax_amount', $params['tax_amount']);
}
$this->set('lineItem', array($lineItem));
$this->set('lineItemParticipantsCount', array($primaryParticipantCount));
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -2725,7 +2725,7 @@ static function recordMembershipContribution( &$params, $ids = array()) {
$recordContribution = array(
'contact_id', 'total_amount', 'receive_date', 'financial_type_id',
'payment_instrument_id', 'trxn_id', 'invoice_id', 'is_test',
'contribution_status_id', 'check_number', 'campaign_id', 'is_pay_later',
'contribution_status_id', 'check_number', 'campaign_id', 'is_pay_later', 'tax_amount'
);
foreach ($recordContribution as $f) {
$contributionParams[$f] = CRM_Utils_Array::value($f, $params);
Expand Down
3 changes: 3 additions & 0 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,9 @@ public function postProcess() {
if ($priceSetId) {
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'],
$this->_params, $lineItem[$priceSetId]);
if (CRM_Utils_Array::value('tax_amount', $this->_params)) {
$params['tax_amount'] = $this->_params['tax_amount'];
}
$params['total_amount'] = CRM_Utils_Array::value('amount', $this->_params);
$submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues);
if (!empty($lineItem[$priceSetId])) {
Expand Down
12 changes: 12 additions & 0 deletions xml/schema/Contribute/Contribution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,18 @@
<type>Select</type>
</html>
</field>
<field>
<name>tax_amount</name>
<type>decimal</type>
<import>true</import>
<headerPattern>/tax(.?am(ou)?nt)?/i</headerPattern>
<dataPattern>/^\d+(\.\d{2})?$/</dataPattern>
<comment>Total tax amount of this contribution.</comment>
<add>4.5</add>
<html>
<type>Text</type>
</html>
</field>
<foreignKey>
<name>campaign_id</name>
<table>civicrm_campaign</table>
Expand Down
12 changes: 12 additions & 0 deletions xml/schema/Price/LineItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,17 @@
<type>Text</type>
</html>
</field>
<field>
<name>tax_amount</name>
<type>decimal</type>
<import>true</import>
<headerPattern>/tax(.?am(ou)?nt)?/i</headerPattern>
<dataPattern>/^\d+(\.\d{2})?$/</dataPattern>
<comment>tax of each item</comment>
<add>4.5</add>
<html>
<type>Text</type>
</html>
</field>
</table>

0 comments on commit 06a079d

Please sign in to comment.