Skip to content

Instantly share code, notes, and snippets.

@geakstr
Last active July 18, 2019 11:35
Show Gist options
  • Save geakstr/885d8ac4d17fca71c1bcee3620384ab9 to your computer and use it in GitHub Desktop.
Save geakstr/885d8ac4d17fca71c1bcee3620384ab9 to your computer and use it in GitHub Desktop.
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