Created
September 10, 2018 22:49
-
-
Save JRobsonJr/197c821b68207f44a561f9664049306b to your computer and use it in GitHub Desktop.
Refactoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
private void substractWithDiscount(final Money money, int discount) { | |
account.substract(Money.newInstance( | |
money.getAmount() + money.getAmount() * account.overdraftFee() * discount, | |
money.getCurrency())); | |
} | |
@Override | |
public void withdraw(final Money money) { | |
if (account.isOverdraft) { | |
if (account.getType().isPremium()) { | |
substractWithDiscount(money, companyOverdraftDiscount / 2); | |
} else { | |
substractWithDiscount(money, companyOverdraftDiscount); | |
} | |
} else { | |
account.substract(Money.newInstance(money.getAmount(), money.getCurrency())); | |
} | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment