total fee updates when a case fee is deleted
This commit is contained in:
parent
02715bdc44
commit
92bce34fb1
@ -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) {
|
||||
|
@ -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}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user