Skip to content

Commit

Permalink
fix: customer accounts have credit balances
Browse files Browse the repository at this point in the history
  • Loading branch information
emschwartz committed Jun 24, 2024
1 parent 96cbcb2 commit 8841f2e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion exercises/012_debits_credits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tb "create_accounts id=$BANK code=10 ledger=120,
id=$CUSTOMER code=10 ledger=120;"

# And let's say that at some earlier point, the customer deposited $100 into the bank.
tb "create_transfers id=12000 debit_account_id=$CUSTOMER credit_account_id=$BANK amount=100 ledger=120 code=10;"
tb "create_transfers id=12000 debit_account_id=$BANK credit_account_id=$CUSTOMER amount=100 ledger=120 code=10;"

# Now, the customer wants to withdraw $20 from the bank.
# Which account should be debited and which should be credited?
Expand Down
8 changes: 4 additions & 4 deletions exercises/016_balance_limits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ BANK=1600
CUSTOMER=1601

# We're going to create the CUSTOMER account with the flag that ensures that its
# credits do not exceed its debits.
# debits do not exceed its credits.
tb "create_accounts id=$BANK code=10 ledger=160,
id=$CUSTOMER code=10 ledger=160 flags=credits_must_not_exceed_debits;"
id=$CUSTOMER code=10 ledger=160 flags=debits_must_not_exceed_credits;"

# Let's create a transfer where the customer deposits $100 into the bank.
tb "create_transfers id=16000 debit_account_id=$CUSTOMER credit_account_id=$BANK amount=100 ledger=160 code=10;"
tb "create_transfers id=16000 debit_account_id=$BANK credit_account_id=$CUSTOMER amount=100 ledger=160 code=10;"

# Now, the customer wants to withdraw money fromt the bank.
# But they're trying to withdraw too much! Can you fix the amount so this transfer succeeds?
tb "create_transfers id=16001 debit_account_id=$BANK credit_account_id=$CUSTOMER amount=200 ledger=160 code=10;"
tb "create_transfers id=16001 debit_account_id=$CUSTOMER credit_account_id=$BANK amount=200 ledger=160 code=10;"
6 changes: 3 additions & 3 deletions patches/012_debits_credits.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/exercises/012_debits_credits.sh b/exercises/012_debits_credits.sh
index 0cfa945..01c7fbf 100755
index 7568bd6..a239020 100755
--- a/exercises/012_debits_credits.sh
+++ b/exercises/012_debits_credits.sh
@@ -26,7 +26,7 @@ tb "create_transfers id=12000 debit_account_id=$CUSTOMER credit_account_id=$BANK
@@ -26,7 +26,7 @@ tb "create_transfers id=12000 debit_account_id=$BANK credit_account_id=$CUSTOMER

# Now, the customer wants to withdraw $20 from the bank.
# Which account should be debited and which should be credited?
-tb "create_transfers id=12001 debit_account_id=${???} credit_account_id=${???} amount=20 ledger=120 code=10;"
+tb "create_transfers id=12001 debit_account_id=$BANK credit_account_id=$CUSTOMER amount=20 ledger=120 code=10;"
+tb "create_transfers id=12001 debit_account_id=${CUSTOMER} credit_account_id=${BANK} amount=20 ledger=120 code=10;"

# For developers who are new to accounting, debits and credits can be a bit confusing.
# You can read more debits and credits in our primer on financial accounting:
8 changes: 4 additions & 4 deletions patches/016_balance_limits.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
diff --git a/exercises/016_balance_limits.sh b/exercises/016_balance_limits.sh
index a5d695c..5805d01 100755
index 03a1d5a..f345426 100755
--- a/exercises/016_balance_limits.sh
+++ b/exercises/016_balance_limits.sh
@@ -22,4 +22,4 @@ tb "create_transfers id=16000 debit_account_id=$CUSTOMER credit_account_id=$BANK
@@ -22,4 +22,4 @@ tb "create_transfers id=16000 debit_account_id=$BANK credit_account_id=$CUSTOMER

# Now, the customer wants to withdraw money fromt the bank.
# But they're trying to withdraw too much! Can you fix the amount so this transfer succeeds?
-tb "create_transfers id=16001 debit_account_id=$BANK credit_account_id=$CUSTOMER amount=200 ledger=160 code=10;"
+tb "create_transfers id=16001 debit_account_id=$BANK credit_account_id=$CUSTOMER amount=100 ledger=160 code=10;"
-tb "create_transfers id=16001 debit_account_id=$CUSTOMER credit_account_id=$BANK amount=200 ledger=160 code=10;"
+tb "create_transfers id=16001 debit_account_id=$CUSTOMER credit_account_id=$BANK amount=100 ledger=160 code=10;"

0 comments on commit 8841f2e

Please sign in to comment.