Total fee now updates when a new fee is added
This commit is contained in:
parent
4ab621100f
commit
02715bdc44
@ -121,7 +121,8 @@ function opencase_cases_oc_case_fee_update(Drupal\opencase_cases\entity\OCCaseFe
|
||||
}
|
||||
|
||||
function opencase_cases_oc_case_fee_insert(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
||||
opencase_cases_update_total_fee_for_case_belonging_to_case_fee($case_fee);
|
||||
$case = $case_fee->getCase();
|
||||
$case->addToTotalFee($case_fee->amount->value);
|
||||
}
|
||||
|
||||
function opencase_cases_oc_case_fee_delete(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
|
||||
|
@ -222,6 +222,10 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addToTotalFee(float $amountToAdd): void {
|
||||
$this->set('total_fee', $this->total_fee->value + $amountToAdd);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -190,6 +190,10 @@ class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCase():\Drupal\opencase_cases\Entity\OCCase {
|
||||
return \Drupal\opencase_cases\Entity\OCCase::load($this->oc_case->target_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user