total fee updates when a case fee is deleted

This commit is contained in:
naomi 2022-04-21 12:15:00 +01:00
parent 02715bdc44
commit 92bce34fb1
2 changed files with 7 additions and 1 deletions

View File

@ -126,7 +126,8 @@ function opencase_cases_oc_case_fee_insert(Drupal\opencase_cases\entity\OCCaseFe
}
function opencase_cases_oc_case_fee_delete(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->subtractFromTotalFee($case_fee->amount->value);
}
function opencase_cases_entity_base_field_info($entity_type) {

View File

@ -227,6 +227,11 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
$this->save();
}
public function subtractFromTotalFee(string $amountToSubtract): void {
$this->set('total_fee', $this->total_fee->value - $amountToSubtract);
$this->save();
}
/**
* {@inheritdoc}
*/