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

[REF] Rename balanceTrxnParams variable to paymentTrxnParams #15535

Merged
merged 1 commit into from
Oct 18, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Rename a variable to be less misleading

Before

Variable called $balanceTrxnParams

After

Variable called $paymentTrxnParams

Technical Details

This array needs some fixes but I wanted to rename the parameter first as balanceTrxnParams is misleading.

The parameters are for the financial_trxn entry corresponding to the payment

Comments

This array needs some fixes but I wanted to rename the parameter first as balanceTrxnParams is misleading.

The parameters are for the financial_trxn entry corresponding to the payment
@civibot
Copy link

civibot bot commented Oct 18, 2019

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

test this please

@mattwire
Copy link
Contributor

@seamuslee001 @eileenmcnaughton This got merged a little fast! In this case I believe balanceTrxnParams is the correct term as it's referencing a specific accounting principle (Stripe also has balance transactions). There are various functions / variables in CiviCRM referencing balanceTrxn(s) specifically and renaming this one creates inconsistency (and confusion with the "Payment" entity in CiviCRM). Can we revert this pending discussion? @JoeMurray @monishdeb

@seamuslee001
Copy link
Contributor

@mattwire i believe the newer variable name is correct as we are in the payment.create function effectively and there isn't anything in this code that is about balance transactions.

@mattwire
Copy link
Contributor

@seamuslee001 But that array of params is specifically being passed to CRM_Core_BAO_FinancialTrxn::create() which takes $balanceTrxnParams as it's parameter. In CRM_Core_BAO_FinancialTrxn there is a function getBalanceTrxnAmt and most references in core to FinancialTrxn use the term balanceTrxn. I think that balanceTrxn (there are two financialTrxns per payment), but if we did decide to change it we should change it everywhere for consistency.

@seamuslee001
Copy link
Contributor

@mattwire we should be evaluating each thing separately. also just because one function has a variable named y doesn't mean everything that calls that function needs to use the same names. In the context of doing a payment create it feels more obvious straight forward calling them the Payment Transaction Params rather than balance trxn params. In the context of doing payment.create what does balanceTrxnParams even mean hence even Eileen getting confused

@mattwire
Copy link
Contributor

@seamuslee001 Understood, but the civicrm_financial_trxn does not represent a payment but a "transfer of balance" (in this case from external via a payment to CiviCRM). The payment itself is a collection of financial entities that are wrapped by the Payment entity. I really need @JoeMurray to weigh in here as he understands this area better than all of us!

@eileenmcnaughton
Copy link
Contributor Author

@mattwire the params relate to the row being added to civicrm_financial_trxn that represents a payment.

It is not an accounting entry creating a balance transaction - which would happen in other cases where we are debiting one account & crediting another - you can see 'is_payment' is part of the array of values.

The goal on the Payment api is to get to the point where a specific type of financial trxn that clearly maps to the real world concept of a 'Payment' can be interacted with as it's own entity without people having to go deep into the financials & in this case making it clear that was is happening is we are inserting a payment is desirable

@eileenmcnaughton
Copy link
Contributor Author

Tangentally CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt uses 'balance' in a different way again - in that case it refers to the outstanding balance on the order/contribution

$balanceTrxnParams is otherwise used in BAO_Contribution::recordFinancialAccounts - in 2 places. One is a disused deprecated function. The other is kinda unclear. The implication is it is creating a 'balanceTrxn' for the unpaid balance - ie. putting it against accounts receivable. I'm not sure that is actually the case though :-( It doesn't seem like the thing to say we should be copying to me

@JoeMurray
Copy link
Contributor

JoeMurray commented Oct 22, 2019

Sorry I am late replying. Without looking over the code I would just comment on possible historical reasons for that as a name. When partial payments were first added the only supported use case was paying off the balance of the contribution still owed on an event registration. Now we support any payment on any contribution.

@eileenmcnaughton
Copy link
Contributor Author

Thanks @JoeMurray that makes sense

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

Successfully merging this pull request may close these issues.

4 participants