Last active
July 18, 2019 11:35
-
-
Save geakstr/885d8ac4d17fca71c1bcee3620384ab9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
createBill = (amount) { | |
return Bill({ | |
amount: amount, | |
}); | |
} | |
createCheck = (account, bill) { | |
return Check({ | |
accountId: account.id, | |
billId: bill.id | |
}); | |
} | |
withdrawal = (account, bill) { | |
return Account({ | |
...account, | |
balance: account.balance - bill.amount | |
}); | |
} | |
PaymentService { | |
Check pay(account, amount) { | |
bill = createBill(amount); | |
check = createCheck(account, bill); | |
account = withdrawal(account, bill); | |
account.save(); | |
bill.save(); | |
check.save(); | |
return check; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment