how to avoid if conditions,
- by kumar kasimala
Hi all,
can anyone suggest best way to avoid most if conditions? I have below code, I want avoid most of cases if conditions, how to do it ? any solution is great help;
if (adjustment.adjustmentAccount.isIncrease) {
if (adjustment.increaseVATLine) {
if (adjustment.vatItem.isSalesType) {
entry2.setDebit(adjustment.total);
entry2.setCredit(0d);
} else {
entry2.setCredit(adjustment.total);
entry2.setDebit(0d);
}
} else {
if (adjustment.vatItem.isSalesType) {
entry2.setCredit(adjustment.total);
entry2.setDebit(0d);
} else {
entry2.setDebit(adjustment.total);
entry2.setCredit(0d);
}
}
} else {
if (adjustment.increaseVATLine) {
if (adjustment.vatItem.isSalesType) {
entry2.setCredit(adjustment.total);
entry2.setDebit(0d);
} else {
entry2.setDebit(adjustment.total);
entry2.setCredit(0d);
}
} else {
if (adjustment.vatItem.isSalesType) {
entry2.setDebit(adjustment.total);
entry2.setCredit(0d);
} else {
entry2.setCredit(adjustment.total);
entry2.setDebit(0d);
}
}