Permalink
Browse files

Add balance assertion based on #39 (comment)

  • Loading branch information...
testacount1 committed Mar 6, 2017
1 parent 50d526a commit c467c6ead4a722ba5706f30e0f1cce26a77c2d1b
Showing with 38 additions and 26 deletions.
  1. +35 −23 FY2013/2012-06.beancount
  2. +2 −2 FY2013/FY2013.beancount
  3. +1 −1 test.py
View
@@ -1,8 +1,8 @@
; Set up for our zeroeth payday!
; ==============================
-2012-06-01 open Assets:Escrow:New-Alliance USD
- ; Assets:Operations:New-Alliance is already open, in FY2013.beancount
+2012-06-01 open Assets:New-Alliance:Escrow USD
+ ; Assets:New-Alliance:Operations is already open, in FY2013.beancount
; Samurai was our first payment processor.
2012-06-01 open Assets:Escrow:Samurai USD
@@ -28,20 +28,20 @@
Liabilities:Escrow -2.96 USD
2012-06-04 * "Samurai settled with us. We expected 3.30, but saw 7.56: an overpayment of 4.26."
- Assets:Escrow:New-Alliance 2.96 USD
- Assets:Operations:New-Alliance 0.34 USD
- Assets:Operations:New-Alliance 4.26 USD
+ Assets:New-Alliance:Escrow 2.96 USD
+ Assets:New-Alliance:Operations 0.34 USD
+ Assets:New-Alliance:Operations 4.26 USD
Income:Errors:Samurai -4.26 USD
Assets:Operations:Samurai -0.34 USD
Assets:Escrow:Samurai -2.96 USD
2012-06-04 * "Samurai withdrew funds."
Expenses:Fees:Samurai 0.08 USD
- Assets:Operations:New-Alliance -0.08 USD
+ Assets:New-Alliance:Operations -0.08 USD
2012-06-04 * "Samurai withdrew more funds for some reason."
Expenses:Fees:Samurai 31.35 USD
- Assets:Operations:New-Alliance -31.35 USD
+ Assets:New-Alliance:Operations -31.35 USD
; Gittip Payday 1
@@ -54,22 +54,22 @@
Liabilities:Escrow -23.17 USD
2012-06-11 * "Samurai settled AMEX charges with us. We expected 0.61, and we saw 0.61."
- Assets:Escrow:New-Alliance 0.48 USD
- Assets:Operations:New-Alliance 0.13 USD
+ Assets:New-Alliance:Escrow 0.48 USD
+ Assets:New-Alliance:Operations 0.13 USD
Assets:Operations:Samurai -0.13 USD
Assets:Escrow:Samurai -0.48 USD
2012-06-11 * "Samurai settled VISA/MC. We expected 24.67, but saw 24.11: an underpayment of 0.56."
- Assets:Escrow:New-Alliance 22.69 USD
- Assets:Operations:New-Alliance 1.98 USD
+ Assets:New-Alliance:Escrow 22.69 USD
+ Assets:New-Alliance:Operations 1.98 USD
Expenses:Errors:Samurai 0.56 USD
- Assets:Operations:New-Alliance -0.56 USD
+ Assets:New-Alliance:Operations -0.56 USD
Assets:Operations:Samurai -1.98 USD
Assets:Escrow:Samurai -22.69 USD
2012-06-11 * "Samurai withdrew funds."
Expenses:Fees:Samurai 2.00 USD
- Assets:Operations:New-Alliance -2.00 USD
+ Assets:New-Alliance:Operations -2.00 USD
; Gittip Payday 2
@@ -91,17 +91,17 @@
Assets:Escrow:Cash 1.50 USD
Equity:Owners:Chad-Whitacre -1.50 USD
2012-06-15 * "Let's bleed off the excess escrow over to operations(!?)."
- Assets:Operations:New-Alliance 1.50 USD
- Assets:Escrow:New-Alliance -1.50 USD
+ Assets:New-Alliance:Operations 1.50 USD
+ Assets:New-Alliance:Escrow -1.50 USD
2012-06-15 * "Now we can do the payout ..."
Liabilities:Escrow 1.50 USD
Assets:Escrow:Cash -1.50 USD
2012-06-18 * "Samurai settled with us. We expected 2.05, but saw 2.01: an underpayment of 0.04."
- Assets:Escrow:New-Alliance 1.36 USD
- Assets:Operations:New-Alliance 0.69 USD
+ Assets:New-Alliance:Escrow 1.36 USD
+ Assets:New-Alliance:Operations 0.69 USD
Expenses:Errors:Samurai 0.04 USD
- Assets:Operations:New-Alliance -0.04 USD
+ Assets:New-Alliance:Operations -0.04 USD
Assets:Operations:Samurai -0.69 USD
Assets:Escrow:Samurai -1.36 USD
@@ -122,7 +122,7 @@
Assets:Operations:Stripe -0.32 USD
2012-06-22 * "Stripe settled the net to us."
- Assets:Operations:New-Alliance 0.22 USD
+ Assets:New-Alliance:Operations 0.22 USD
Assets:Operations:Stripe -0.22 USD
@@ -144,8 +144,8 @@
Liabilities:Escrow -20.67 USD
2012-06-28 * "Stripe settled the net to us."
- Assets:Escrow:New-Alliance 20.67 USD
- Assets:Operations:New-Alliance 0.30 USD
+ Assets:New-Alliance:Escrow 20.67 USD
+ Assets:New-Alliance:Operations 0.30 USD
Expenses:Fees:Stripe 4.32 USD
Assets:Operations:Stripe -4.32 USD
Assets:Operations:Stripe -0.30 USD
@@ -175,13 +175,25 @@
Income:IHasAMoney -2.92 USD
2012-06-18 * "Samurai settled with us."
- Assets:Operations:New-Alliance 2.92 USD
+ Assets:New-Alliance:Operations 2.92 USD
Assets:Operations:Samurai -2.92 USD
2012-06-25 * "We charged a user via Samurai."
Assets:Operations:Samurai 2.99 USD
Income:IHasAMoney -2.99 USD
2012-06-25 * "Samurai settled with us."
- Assets:Operations:New-Alliance 2.99 USD
+ Assets:New-Alliance:Operations 2.99 USD
Assets:Operations:Samurai -2.99 USD
+
+; aggregate account used for balance assertion
+2012-06-01 open Assets:New-Alliance USD
+
+; NOTE: all the dates are 1 day after which is shown in the bank statement
+; and only the last record in a day is checked
+2012-06-05 balance Assets:New-Alliance 78.58 USD
+2012-06-12 balance Assets:New-Alliance 101.30 USD
+2012-06-19 balance Assets:New-Alliance 106.23 USD
+2012-06-23 balance Assets:New-Alliance 106.45 USD
+2012-06-26 balance Assets:New-Alliance 109.44 USD
+2012-06-29 balance Assets:New-Alliance 130.41 USD
View
@@ -1,11 +1,11 @@
; Fiat lux!
; =========
-2012-06-01 open Assets:Operations:New-Alliance USD
+2012-06-01 open Assets:New-Alliance:Operations USD
2012-06-01 open Equity:Owners:Chad-Whitacre USD
2012-06-01 * "Opening Balance"
- Assets:Operations:New-Alliance 102.45 USD
+ Assets:New-Alliance:Operations 102.45 USD
Equity:Owners:Chad-Whitacre -102.45 USD
include "2012-06.beancount"
View
@@ -31,7 +31,7 @@ def test_escrow_balances():
escrow_assets = escrow_liability = D(0)
for account, amount, currency in report_balances():
- if account.startswith('Assets:Escrow:'):
+ if (account.startswith('Assets:') and account.endswith(':Escrow')) or (account.startswith('Assets:Escrow:')):
escrow_assets += D(amount)
if account.startswith('Liabilities:Escrow'):
escrow_liability += D(amount)

0 comments on commit c467c6e

Please sign in to comment.