Skip to content

Commit

Permalink
- [x] Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
PG-Momik committed Jan 24, 2025
1 parent 9ba7996 commit 75e695c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/IATI/Services/ElementCompleteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ public function checkIfRecipientCountryElementCompleted($activity): bool
})['total'];

if ($firstGroupTotalPercentage === 100.0) {
return $countryStatus;
return true;
}

return false;
Expand Down
23 changes: 6 additions & 17 deletions app/Observers/TransactionObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __construct()
*/
public function updateActivityElementStatus($transaction, bool $changeUpdatedAt = true): void
{
logger('transaction observer called');
$activityObj = $transaction->activity;
$elementStatus = $activityObj->element_status;

Expand All @@ -56,23 +57,10 @@ public function updateActivityElementStatus($transaction, bool $changeUpdatedAt
$isSectorFilledInTransactionLevel = $transactionService->checkIfTransactionHasElementDefined($activityObj, 'sector');
$isSectorCompleteInTransactionLevel = $this->elementCompleteService->isSectorElementCompletedInTransaction($transaction->activity);

/*
* Basically performing AND operations in the switch case.
*/
switch([
$isSectorFilledInActivityLevel,
$isSectorCompletedInActivityLevel,
$isSectorFilledInTransactionLevel,
$isSectorCompleteInTransactionLevel,
]) {
case [false, false, true, true]:
case [false, true, true, true]:
case [true, true, false, false]:
$elementStatus['sector'] = true;
break;
default:
$elementStatus['sector'] = false;
break;
$elementStatus['sector'] = false;

if (($isSectorFilledInActivityLevel && $isSectorCompletedInActivityLevel) || ($isSectorFilledInTransactionLevel && $isSectorCompleteInTransactionLevel)) {
$elementStatus['sector'] = true;
}

$recipientRegionOrCountryIsCompleteInActivity = $this->elementCompleteService->isRecipientCountryElementCompleted($activityObj) || $this->elementCompleteService->isRecipientRegionElementCompleted($activityObj);
Expand Down Expand Up @@ -125,6 +113,7 @@ public function created(Transaction $transaction): void
*/
public function updated(Transaction $transaction): void
{
logger('ypdated call jula');
$this->updateActivityElementStatus($transaction);
$this->resetActivityStatus($transaction);
$this->setTransactionDefaultValues($transaction);
Expand Down

0 comments on commit 75e695c

Please sign in to comment.