Пример #1
0
  public void test_should_include_transfer_splits_into_blotter_for_account() {
    // regular transactions and transfers
    TransactionBuilder.withDb(db).dateTime(date(2012, 2, 8)).account(a1).amount(1000).create();
    TransactionBuilder.withDb(db).dateTime(date(2012, 2, 8)).account(a2).amount(200).create();
    assertAccountBlotter(a1, 1000);
    assertAccountBlotter(a2, 200);
    assertAccountBlotterTotal(a1, date(2012, 2, 1), date(2012, 2, 7), 0);
    assertAccountBlotterTotal(a1, date(2012, 2, 1), date(2012, 2, 8), 1000);
    assertAccountBlotterTotal(a2, date(2012, 2, 8), date(2012, 2, 9), 200);

    // regular transfer
    TransferBuilder.withDb(db)
        .dateTime(date(2012, 2, 9))
        .fromAccount(a1)
        .fromAmount(-100)
        .toAccount(a2)
        .toAmount(50)
        .create();
    assertAccountBlotter(a1, -100, 1000);
    assertAccountBlotter(a2, 50, 200);
    assertAccountBlotterTotal(a1, date(2012, 2, 1), date(2012, 2, 9), 900);
    assertAccountBlotterTotal(a2, date(2012, 2, 8), date(2012, 2, 9), 250);

    // regular split
    TransactionBuilder.withDb(db)
        .dateTime(date(2012, 2, 10))
        .account(a1)
        .amount(-500)
        .withSplit(categoriesMap.get("A1"), -200)
        .withSplit(categoriesMap.get("A1"), -300)
        .create();
    assertAccountBlotter(a1, -500, -100, 1000);
    assertAccountBlotter(a2, 50, 200);
    assertAccountBlotterTotal(a1, date(2012, 2, 1), date(2012, 2, 10), 400);
    assertAccountBlotterTotal(a1, date(2012, 2, 9), date(2012, 2, 10), -600);
    assertAccountBlotterTotal(a2, date(2012, 2, 1), date(2012, 2, 9), 250);

    // transfer split
    TransactionBuilder.withDb(db)
        .dateTime(date(2012, 2, 11))
        .account(a2)
        .amount(-120)
        .withSplit(categoriesMap.get("B"), -20)
        .withTransferSplit(a1, -100, 200)
        .create();
    assertAccountBlotter(a1, 200, -500, -100, 1000);
    assertAccountBlotter(a2, -120, 50, 200);
    assertAccountBlotterTotal(a1, date(2012, 2, 1), date(2012, 2, 12), 600);
    assertAccountBlotterTotal(a2, date(2012, 2, 1), date(2012, 2, 12), 130);
  }
Пример #2
0
  public void test_should_verify_running_balance_on_blotter_for_account() {
    // regular transactions and transfers
    TransactionBuilder.withDb(db).account(a1).amount(1000).create();
    TransactionBuilder.withDb(db).account(a2).amount(200).create();
    assertRunningBalance(a1, 1000);
    assertRunningBalance(a2, 200);
    assertTotals(1000, 200);

    // regular transfer
    TransferBuilder.withDb(db).fromAccount(a1).fromAmount(-100).toAccount(a2).toAmount(50).create();
    assertRunningBalance(a1, 900, 1000);
    assertRunningBalance(a2, 250, 200);
    assertTotals(900, 250);

    // regular split
    TransactionBuilder.withDb(db)
        .account(a1)
        .amount(-500)
        .withSplit(categoriesMap.get("A1"), -200)
        .withSplit(categoriesMap.get("A1"), -300)
        .create();
    assertRunningBalance(a1, 400, 900, 1000);
    assertRunningBalance(a2, 250, 200);
    assertTotals(400, 250);

    // transfer split
    TransactionBuilder.withDb(db)
        .account(a2)
        .amount(-120)
        .withSplit(categoriesMap.get("B"), -20)
        .withTransferSplit(a1, -100, 200)
        .create();
    assertRunningBalance(a1, 600, 400, 900, 1000);
    assertRunningBalance(a2, 130, 250, 200);
    assertTotals(600, 130);
  }