Skip to content

Commit

Permalink
BTHAB-185: Update invoicing/payment statuses when creating a payment
Browse files Browse the repository at this point in the history
  • Loading branch information
erawat committed Sep 20, 2023
1 parent b20b4a6 commit 167e6fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions CRM/Civicase/Hook/Post/CreateSalesOrderContribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ class CRM_Civicase_Hook_Post_CreateSalesOrderContribution {
* Object reference.
*/
public function run($op, $objectName, $objectId, &$objectRef) {
if (!$this->shouldRun($op, $objectName)) {
return;
}

$salesOrderId = CRM_Utils_Request::retrieve('sales_order', 'Integer');
if (empty($salesOrderId)) {
$salesOrderId = $this->getQuotationID($objectId)['Opportunity_Details.Quotation'];
}

if (!$this->shouldRun($op, $objectName, $salesOrderId)) {
if (empty($salesOrderId)) {
return;
}

Expand Down Expand Up @@ -65,14 +69,12 @@ public function run($op, $objectName, $objectId, &$objectRef) {
* The operation being performed.
* @param string $objectName
* Object name.
* @param string $salesOrderId
* The sales order that triggered the contribution (if any).
*
* @return bool
* returns a boolean to determine if hook will run or not.
*/
private function shouldRun($op, $objectName, $salesOrderId) {
return strtolower($objectName) == 'contribution' && !empty($salesOrderId) && $op == 'create';
private function shouldRun($op, $objectName) {
return strtolower($objectName) == 'contribution' && $op == 'create';
}

/**
Expand Down
1 change: 1 addition & 0 deletions civicase.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function civicase_civicrm_validateForm($formName, &$fields, &$files, &$form, &$e
*/
function civicase_civicrm_post($op, $objectName, $objectId, &$objectRef) {
$hooks = [
new CRM_Civicase_Hook_Post_CaseSalesOrderPayment(),
new CRM_Civicase_Hook_Post_CreateSalesOrderContribution(),
new CRM_Civicase_Hook_Post_PopulateCaseCategoryForCaseType(),
new CRM_Civicase_Hook_Post_CaseCategoryCustomGroupSaver(),
Expand Down

0 comments on commit 167e6fa

Please sign in to comment.