Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
a90b7451
Commit
a90b7451
authored
3 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
#2577
Fix regression - payment edit to new type failing
parent
68e15fa4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Financial/Form/PaymentEdit.php
+19
-7
19 additions, 7 deletions
CRM/Financial/Form/PaymentEdit.php
with
19 additions
and
7 deletions
CRM/Financial/Form/PaymentEdit.php
+
19
−
7
View file @
a90b7451
...
...
@@ -30,6 +30,15 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form {
*/
protected
$_contributionID
;
/**
* Get the related contribution id.
*
* @return int
*/
public
function
getContributionID
():
int
{
return
$this
->
_contributionID
;
}
/**
* The variable which holds the information of a financial transaction
*
...
...
@@ -129,7 +138,7 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form {
$errors
=
[];
// if Credit Card is chosen and pan_truncation is not NULL ensure that it's value is numeric else throw validation error
if
(
CRM_Core_PseudoConstant
::
getName
(
'CRM_Financial_DAO_FinancialTrxn'
,
'payment_instrument_id'
,
$fields
[
'payment_instrument_id'
])
==
'Credit Card'
&&
if
(
CRM_Core_PseudoConstant
::
getName
(
'CRM_Financial_DAO_FinancialTrxn'
,
'payment_instrument_id'
,
$fields
[
'payment_instrument_id'
])
==
=
'Credit Card'
&&
!
empty
(
$fields
[
'pan_truncation'
])
&&
!
CRM_Utils_Rule
::
numeric
(
$fields
[
'pan_truncation'
])
)
{
...
...
@@ -141,8 +150,10 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form {
/**
* Process the form submission.
*
* @throws \CiviCRM_API3_Exception
*/
public
function
postProcess
()
{
public
function
postProcess
()
:
void
{
$params
=
[
'id'
=>
$this
->
_id
,
'payment_instrument_id'
=>
$this
->
_submitValues
[
'payment_instrument_id'
],
...
...
@@ -151,20 +162,20 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form {
];
$paymentInstrumentName
=
CRM_Core_PseudoConstant
::
getName
(
'CRM_Financial_DAO_FinancialTrxn'
,
'payment_instrument_id'
,
$params
[
'payment_instrument_id'
]);
if
(
$paymentInstrumentName
==
'Credit Card'
)
{
if
(
$paymentInstrumentName
==
=
'Credit Card'
)
{
$params
[
'card_type_id'
]
=
$this
->
_submitValues
[
'card_type_id'
]
??
NULL
;
$params
[
'pan_truncation'
]
=
$this
->
_submitValues
[
'pan_truncation'
]
??
NULL
;
}
elseif
(
$paymentInstrumentName
==
'Check'
)
{
elseif
(
$paymentInstrumentName
==
=
'Check'
)
{
$params
[
'check_number'
]
=
$this
->
_submitValues
[
'check_number'
]
??
NULL
;
}
$this
->
submit
(
$params
);
$contactId
=
CRM_Core_DAO
::
getFieldValue
(
'CRM_Contribute_DAO_Contribution'
,
$this
->
_c
ontributionID
,
'contact_id'
);
$contactId
=
CRM_Core_DAO
::
getFieldValue
(
'CRM_Contribute_DAO_Contribution'
,
$this
->
getC
ontributionID
()
,
'contact_id'
);
$url
=
CRM_Utils_System
::
url
(
"civicrm/contact/view/contribution"
,
"reset=1&action=update&id=
{
$this
->
_c
ontributionID
}
&cid=
{
$contactId
}
&context=contribution"
"reset=1&action=update&id={
"
.
$this
->
getC
ontributionID
()
.
"
}&cid=
{
$contactId
}
&context=contribution"
);
CRM_Core_Session
::
singleton
()
->
pushUserContext
(
$url
);
}
...
...
@@ -192,6 +203,7 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form {
$newFinancialTrxn
[
'to_financial_account_id'
]
=
CRM_Financial_BAO_FinancialTypeAccount
::
getInstrumentFinancialAccount
(
$submittedValues
[
'payment_instrument_id'
]);
$newFinancialTrxn
[
'total_amount'
]
=
$this
->
_values
[
'total_amount'
];
$newFinancialTrxn
[
'currency'
]
=
$this
->
_values
[
'currency'
];
$newFinancialTrxn
[
'contribution_id'
]
=
$this
->
getContributionID
();
civicrm_api3
(
'Payment'
,
'create'
,
$newFinancialTrxn
);
}
else
{
...
...
@@ -199,7 +211,7 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form {
civicrm_api3
(
'FinancialTrxn'
,
'create'
,
$submittedValues
);
}
CRM_Financial_BAO_Payment
::
updateRelatedContribution
(
$submittedValues
,
$this
->
_c
ontributionID
);
CRM_Financial_BAO_Payment
::
updateRelatedContribution
(
$submittedValues
,
$this
->
getC
ontributionID
()
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment