/** * Delete a transaction, only if it belongs to the user * @param Transaction $transaction * @return Response * @throws \Exception */ public function destroy(Transaction $transaction) { $transaction->delete(); //Reverse the automatic insertion into savings if it is an income expense if ($transaction->type === 'income') { $savings = Savings::forCurrentUser()->first(); $savings->decrease($this->savingsRepository->calculateAmountToSubtract($transaction)); } return $this->responseNoContent(); }