Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix https://issues.civicrm.org/jira/browse/CRM-19149 #8982

Merged
merged 5 commits into from
Sep 16, 2016
Merged

fix https://issues.civicrm.org/jira/browse/CRM-19149 #8982

merged 5 commits into from
Sep 16, 2016

Conversation

wahyukodar
Copy link
Contributor

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@totten
Copy link
Member

totten commented Sep 5, 2016

jenkins, ok to test

@JoeMurray
Copy link
Contributor

@wahyukodar please fix failing tests
@pradpnayak please QA

@seamuslee001
Copy link
Contributor

seamuslee001 commented Sep 6, 2016

@wahyukodar Wahyu can you please do git rebase -i core repo alias/master and only pick commits for this PR

@wahyukodar
Copy link
Contributor Author

@seamuslee001 Hi, can you help me what command to write on the terminal?

@seamuslee001
Copy link
Contributor

@wahyukodar Wahyu

What you want to do is in your terminal cd to the civicrm root.
Then do git fetch alias for civicrm core repo if you have it otherwise add another origin civicrm pointing to civicrm core

then do git rebase -i civirepo-alias/master and then follow the prompts. as per the docs here https://git-scm.com/docs/git-rebase

@wahyukodar
Copy link
Contributor Author

@seamuslee001 Hi, I'm done git rebase, but it's still fail test.. Alert in jenkins "No report files were found. Configuration error".. What should I do?

@seamuslee001
Copy link
Contributor

@wahyukodar can you do another git rebase but when you get the list of commits ONLY include the ones relevant to this Pull and no merge commits.

@wahyukodar
Copy link
Contributor Author

@seamuslee001 , when I run git rebase -i civirepo/master, I get

pick 122250e fix issue https://issues.civicrm.org/jira/browse/CRM-19149
pick 34f6cee CRM-19275 - DB Error on adding priceset when deferred revenue setting is enabled
pick b97c9c4 English grammar edit
pick b86587c CRM-19290 Fix date creation in Karma test
pick c151a36 fix issue https://issues.civicrm.org/jira/browse/CRM-19149
pick 0aa19c5 CRM-19290 Fix date creation in Karma test
pick 8d88ae4 fix https://issues.civicrm.org/jira/browse/CRM-19149
pick d84d83f fix https://issues.civicrm.org/jira/browse/CRM-19149
pick 6861dfe fix https://issues.civicrm.org/jira/browse/CRM-19149
pick 5db0520 fixed unit test
pick c67d5d7 fixed unit test

@seamuslee001
Copy link
Contributor

ok so what you want to do is to do

pick 122250e fix issue https://issues.civicrm.org/jira/browse/CRM-19149
#pick 34f6cee CRM-19275 - DB Error on adding priceset when deferred revenue setting is enabled
#pick b97c9c4 English grammar edit
#pick b86587c CRM-19290 Fix date creation in Karma test
pick c151a36 fix issue https://issues.civicrm.org/jira/browse/CRM-19149
#pick 0aa19c5 CRM-19290 Fix date creation in Karma test
pick 8d88ae4 fix https://issues.civicrm.org/jira/browse/CRM-19149
pick d84d83f fix https://issues.civicrm.org/jira/browse/CRM-19149
pick 6861dfe fix https://issues.civicrm.org/jira/browse/CRM-19149
pick 5db0520 fixed unit test
pick c67d5d7 fixed unit test

@seamuslee001
Copy link
Contributor

so add in the # where i have suggested and then do git push origin master -f

@wahyukodar
Copy link
Contributor Author

I can't push, this log my terminal

Wahyu-MacBook-Air:civicrm-core wahyu$ git push origin master -f
Everything up-to-date
Wahyu-MacBook-Air:civicrm-core wahyu$ git status
interactive rebase in progress; onto 87881da
Last commands done (4 commands done):
pick 8d88ae4 fix https://issues.civicrm.org/jira/browse/CRM-19149
pick d84d83f fix https://issues.civicrm.org/jira/browse/CRM-19149
(see more in file .git/rebase-merge/done)
Next commands to do (3 remaining commands):
pick 6861dfe fix https://issues.civicrm.org/jira/browse/CRM-19149
pick 5db0520 fixed unit test
(use "git rebase --edit-todo" to view and edit)
You are currently rebasing branch 'master' on '87881da'.
(all conflicts fixed: run "git rebase --continue")

nothing to commit, working directory clean

@seamuslee001
Copy link
Contributor

ok do git commit --allow-empty and then git rebase --continue

@wahyukodar
Copy link
Contributor Author

git rebase --continue error

git commit --allow-empty
[detached HEAD e723092] fix https://issues.civicrm.org/jira/browse/CRM-19149
Date: Sun Sep 4 17:47:21 2016 +0700
Wahyu-MacBook-Air:civicrm-core wahyu$ git rebase --continue
error: could not apply 6861dfe... fix https://issues.civicrm.org/jira/browse/CRM-19149

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Could not apply 6861dfe... fix https://issues.civicrm.org/jira/browse/CRM-19149

@seamuslee001
Copy link
Contributor

ok now do git mergetool and you should see some errors like <<< etc and remove and fix merge and then do git rebase --continue

@seamuslee001
Copy link
Contributor

nice work @wahyukodar :-)

@wahyukodar
Copy link
Contributor Author

@seamuslee001 Thank you very much.. :)

@tamarmeir
Copy link

Tested, looks good, see screen shot of accounting batch:

negative_contribution_edit_1

Note, however, that the financial transaction still shown with the contribution is the original one for check even after updating the payment method to credit card - not sure why I'm not seeing the other two financial transactions
negative_contribution_edit_2

Looking at civicrm_financial_trx via api explorer, I also noticed that the positive transaction (id = 94) with payment instrument id = 4 is still showing a negative net amount - not sure what that would impact but I'm thinking for consistency's sake, it would be good if the net amount was updated as well:

{

"is_error":0,
"version":3,
"count":3,
"values":[{
    "id":"94",
    "to_financial_account_id":"6",
    "trxn_date":"2016-09-08 17:18:00",
    "total_amount":"-100.00",
    "fee_amount":"0.00",
    "net_amount":"-100.00",
    "currency":"USD",
    "is_payment":"1",
    "status_id":"1",
    "payment_instrument_id":"4"
},
{
    "id":"95",
    "to_financial_account_id":"12",
    "trxn_date":"2016-09-08 17:18:00",
    "total_amount":"100.00",
    "fee_amount":"0.00",
    "net_amount":"-100.00",
    "currency":"USD",
    "is_payment":"1",
    "status_id":"1",
    "payment_instrument_id":"4"
},
{
    "id":"96",
    "to_financial_account_id":"12",
    "trxn_date":"2016-09-08 17:18:00",
    "total_amount":"-100.00",
    "fee_amount":"0.00",
    "net_amount":"-100.00",
    "currency":"USD",
    "is_payment":"1",
    "status_id":"1",
    "payment_instrument_id":"1"
}]

}

Thanks in advance for your time in working on this and happy to test once the above is remedied or if you feel that a separate ticket should be created, please let me now and I will do so.

Thanks!

seamuslee001 and others added 2 commits September 9, 2016 20:13
Fix up errors in to_account_id and ensure that financial_item is enti…
@seamuslee001
Copy link
Contributor

@tamarmeir with the latest commits i think your problems are fixed

@tamarmeir
Copy link

Almost there - financial transactions associated with contribution look good:

negative_contribution_edit_1a

But api explore is still showing issues with the net amount of the financial transactions created upon editing - this time, it's the negative credit card transaction (id = 96) that shows a positive amount in the "net amount" field:

"is_error":0,
"version":3,
"count":3,
"values":[{
    "id":"94",
    "to_financial_account_id":"6",
    "trxn_date":"2016-09-14 23:02:00",
    "total_amount":"-100.00",
    "fee_amount":"0.00",
    "net_amount":"-100.00",
    "currency":"USD",
    "is_payment":"1",
    "status_id":"1",
    "payment_instrument_id":"4"
},
{
    "id":"95",
    "to_financial_account_id":"6",
    "trxn_date":"2016-09-14 23:02:00",
    "total_amount":"100.00",
    "fee_amount":"0.00",
    "net_amount":"100.00",
    "currency":"USD",
    "is_payment":"1",
    "status_id":"1",
    "payment_instrument_id":"4"
},
{
    "id":"96",
    "to_financial_account_id":"12",
    "trxn_date":"2016-09-14 23:02:00",
    "total_amount":"-100.00",
    "fee_amount":"0.00",
    "net_amount":"100.00",
    "currency":"USD",
    "is_payment":"1",
    "status_id":"1",
    "payment_instrument_id":"1"
}]

}

$params['trxnParams']['to_financial_account_id'] = $params['to_financial_account_id'];
$params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
if ($params['total_amount'] < 0) {
$params['trxnParams']['net_amount'] = $params['trxnParams']['total_amount'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wahyukodar Wahyu could you move this line up to L3645 i.e. just after the elseif, That should then solve the last issue found by Tamar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 3645? are you sure?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wahyukodar good pickup i mean L3465 :-) reads closer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will move thi

$params['trxnParams']['net_amount'] = $params['trxnParams']['total_amount'];
@seamuslee001

to L3465? Right?

@tamarmeir
Copy link

Houston, we have lift off with the financial transactions! Not sure why there is a result of "All checks failed" in the last merge build - I will leave it to you, though since you have effectively resolved this issue with the last changes made.

Thanks and kind regards,
Tamar

@seamuslee001
Copy link
Contributor

@totten @monishdeb I think this can be merged now tested pretty thoroughly

@yashodha
Copy link
Contributor

Jenkins test this please

@yashodha
Copy link
Contributor

unrelated failure

@yashodha yashodha merged commit c5d6e3d into civicrm:master Sep 16, 2016
$prevFinancialItem = CRM_Financial_BAO_FinancialItem::getPreviousFinancialItem($fieldValues['id']);
if (!CRM_Utils_Rule::currencyCode($trxn->currency)) {
$trxn->currency = CRM_Core_Config::singleton()->defaultCurrency;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think line 3611-3613 is not required.

'entity_id' => $prevFinancialItem->id,
'financial_trxn_id' => $trxn->id,
'amount' => $trxn->total_amount,
'currency' => $trxn->currency,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

civicrm_entity_financial_trxn doesn't have currency column.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is as per

$entityFinancialTrxnParams

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, its not required in either of the place. Can you remove them as cruft?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure I'll do a tidy up PR

);
$entityTrxn = new CRM_Financial_DAO_EntityFinancialTrxn();
$entityTrxn->copyValues($entityFinancialTrxnParams);
$entityTrxn->save();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not using api here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably better idea

@@ -3592,6 +3604,28 @@ public static function updateFinancialAccounts(&$params, $context = NULL, $skipT
}
}
}
if ($context == 'changePaymentInstrument') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pradpnayak all this is doing is adding in a linkage back to the financial_item without it the display on the contribution tab does not show all financial_trxns

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, agreed. Can you please update the wiki and also inform @JoeMurray about the changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure will give it a shot @pradpnayak

else {
$params['trxnParams']['to_financial_account_id'] = $params['to_financial_account_id'];
$params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
}
}
}
Copy link
Contributor

@pradpnayak pradpnayak Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 line 3474-3481 and 3484-3492 looks duplicate. Can we re-write line from 3472-3492 as
if (!empty($lastFinancialTrxnId['financialTrxnId'])) {
if ($params['total_amount'] != $params['trxnParams']['total_amount']) {
$params['trxnParams']['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $lastFinancialTrxnId['financialTrxnId'], 'to_financial_account_id');
$params['trxnParams']['payment_instrument_id'] = $params['prevContribution']->payment_instrument_id;
}
else {
$params['trxnParams']['to_financial_account_id'] = $params['to_financial_account_id'];
$params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pradpnayak see followup pr #9055

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants