How to reduce code size?
getAlreadySaved(goal: GoalModel): number {
if (goal.status && goal.status.investedAmount && !goal.status.pendingIncoming && !goal.status.pendingOutgoing) {
return goal.status.investedAmount;
} else if (goal.status && goal.status.investedAmount && goal.status.pendingIncoming && !goal.status.pendingOutgoing) {
return goal.status.investedAmount + goal.status.pendingIncoming;
} else if (goal.status && goal.status.investedAmount && !goal.status.pendingIncoming && goal.status.pendingOutgoing) {
return goal.status.investedAmount - goal.status.pendingOutgoing;
} else if (goal.status && goal.status.investedAmount && goal.status.pendingIncoming && goal.status.pendingOutgoing) {
return goal.status.investedAmount + goal.status.pendingIncoming - goal.status.pendingOutgoing;
} else {
return 0;
}
}