Skip to content

Commit

Permalink
refactoring: Slide Statements
Browse files Browse the repository at this point in the history
chapter 1: Refactoring: A First Example -> Decomposing the statement Function -> Removing Total Volume Credits
  • Loading branch information
hamedsh committed Jul 12, 2021
1 parent 46f10e7 commit 3944aff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion chapter_1/statement.py
Expand Up @@ -41,12 +41,12 @@ def volume_credits_for(self, a_performance: Dict[str, Any]) -> int:
def statement(self, invoice: Dict[str, Any], plays: Dict[str, Any]) -> str:
self.plays = plays
total_amount: int = 0
volume_credits: int = 0
result = f'Statement for {invoice["customer"]}\n'

for perf in invoice["performances"]:
result += f' {self.play_for(perf)["name"]}: {Statement.usd(self.amount_for(perf))} ({perf["audience"]} seats)\n'
total_amount += self.amount_for(perf)
volume_credits: int = 0
for perf in invoice["performances"]:
volume_credits += self.volume_credits_for(perf)
result += f'Amount owed is {Statement.usd(total_amount)}\n'
Expand Down

0 comments on commit 3944aff

Please sign in to comment.