Generate and pretty print a random ledger

korrat
May 10, 2024, 12:40 PM
MDFNA7OGXTDA2ILFFN2NOX6PRQKK2OJAGILDZDEEH7MBSR6BMP6QC

Dependencies

  • [2] 37UTZL2G Align signs within one column
  • [3] ILUKKAPN Implement Arbitrary for core data types behind a feature flag
  • [4] SJ6AFVZL remove const configuration in favor of runtime config
  • [5] 5S4MZHL5 pretty print decimals using icu
  • [6] QRIJE4AQ add a simple pretty printer for beancount directives
  • [7] 2JBFREZG enable additional warnings
  • [8] HMWEY23D Move core data types back into beancount-types
  • [9] HNSHOQVH Implement Directive with enum_dispatch
  • [10] KBSTC23N Clean up testing using new builder methods on types
  • [11] XQHYMSDY Add importer for Union Investment transactions
  • [12] E2DDQ4MX Define inheritable lints configuration
  • [13] MDRERLJH Upgrade dependencies
  • [14] R7S2CWF7 Add type for account segments
  • [15] 72AIO2FZ Upgrade dependencies
  • [16] ONRIF4V7 add basic snapshot test for pretty printer
  • [17] NSWL54NM allow deriving pretty printing config from a set of directives
  • [18] SLTVZLYX Upgrade dependencies
  • [19] ND7GASJ4 track current column position when writing
  • [20] A35XMWPS Restructure workspace
  • [21] GUNI4ZUI use larger numbers in test
  • [22] 4W4CDACX Upgrade dependencies
  • [*] YDK6X6PP add a library of important types for beancount
  • [*] UESS5YZE migrate dependencies into workspace manifest
  • [*] 6MR76MLL Replace build script with cargo-px
  • [*] I2P2FTLE add basic parser for german decimals
  • [*] UO34MAAG Refactor CSV-based Importers
  • [*] 2Z4EGCWQ Update dependencies
  • [*] HFKQ4E7I Upgrade dependencies

Change contents

  • edit in beancount/types/Cargo.toml at line 39
    [4.26][4.2197:2197]()
  • edit in beancount/pretty-printer/tests/snapshotting.rs at line 3
    [4.22599]
    [4.235]
    use arbitrary::Arbitrary as _;
    use arbitrary::Unstructured;
  • replacement in beancount/pretty-printer/tests/snapshotting.rs at line 7
    [4.105][4.105:196](),[4.196][4.81396:81428](),[4.81428][4.226:260](),[4.226][4.226:260](),[4.308][4.308:338](),[4.338][4.0:43]()
    use beancount_types::Account;
    use beancount_types::Amount;
    use beancount_types::Commodity;
    use beancount_types::Directive;
    use beancount_types::Transaction;
    use rust_decimal_macros::dec;
    use tap::Tap as _;
    use time::macros::date;
    [4.105]
    [4.338]
    use rand::prelude::RngCore as _;
    use rand::SeedableRng as _;
    use testresult::TestResult;
  • replacement in beancount/pretty-printer/tests/snapshotting.rs at line 12
    [4.347][4.347:381](),[4.381][4.44:83](),[4.83][4.83:433](),[4.433][2.56:247](),[2.247][4.433:732](),[4.433][4.433:732]()
    fn pretty_printed_transaction() {
    let directives = [Directive::from(
    Transaction::on(date!(2022 - 03 - 07)).tap_mut(|transaction| {
    let commodity = Commodity::try_from("EUR").unwrap();
    transaction
    .build_posting(Account::try_from("Assets:Checking").unwrap(), |posting| {
    posting.set_amount(Amount::new(dec!(-10000.00), commodity));
    })
    .build_posting(Account::try_from("Assets:Investment").unwrap(), |posting| {
    posting.set_amount(Amount::new(dec!(-3000.00), commodity));
    })
    .build_posting(Account::try_from("Assets:Wallet").unwrap(), |posting| {
    posting.set_amount(Amount::new(dec!(9000.00), commodity));
    })
    .build_posting(Account::try_from("Expenses:Banking:Fees").unwrap(), |_| {});
    }),
    )];
    [4.347]
    [4.1214]
    fn pretty_print_full_ledger() -> TestResult {
    const RNG_SEED: [u8; 32] = [
    63, 207, 120, 21, 179, 129, 192, 241, 29, 100, 39, 165, 125, 38, 239, 72, 43, 102, 215, 22,
    64, 154, 60, 220, 200, 112, 167, 114, 20, 119, 166, 85,
    ];
    const ARBITRARY_SEED_SIZE: usize = 2 << 10;
    const PRINTER_BUFFER_SIZE: usize = 1024;
    let mut rng = rand::rngs::SmallRng::from_seed(RNG_SEED);
    let mut buffer = [0; ARBITRARY_SEED_SIZE];
    rng.fill_bytes(&mut buffer);
    let mut u = Unstructured::new(&buffer);
    let directives: Vec<_> = <_>::arbitrary(&mut u)?;
  • replacement in beancount/pretty-printer/tests/snapshotting.rs at line 28
    [4.1277][4.381:429](),[4.381][4.381:429]()
    let mut buffer = Vec::with_capacity(1_024);
    [4.1277]
    [4.1278]
    let mut buffer = Vec::with_capacity(PRINTER_BUFFER_SIZE);
  • replacement in beancount/pretty-printer/tests/snapshotting.rs at line 31
    [4.508][4.1349:1401]()
    printer.print_directives(&directives).unwrap();
    [4.508]
    [4.1575]
    printer.print_directives(&directives)?;
  • replacement in beancount/pretty-printer/tests/snapshotting.rs at line 34
    [4.1632][4.81429:81468]()
    insta::assert_snapshot!(formatted)
    [4.1632]
    [4.1679]
    insta::assert_snapshot!(formatted);
    Ok(())
  • file deletion: snapshotting__pretty_printed_transaction.snap (---r------)
    [4.1703][4.1705:1774](),[4.1774][4.1775:1775]()
    ---
    source: common/beancount-pretty-printer/tests/snapshotting.rs
    expression: formatted
    ---
    2022-03-07 *
    Assets:Checking -10,000.00 EUR
    Assets:Wallet 9,000.00 EUR
    Expenses:Banking:Fees
    Assets:Investment - 3,000.00 EUR
  • file addition: snapshotting__pretty_print_full_ledger.snap (----------)
    [4.1703]
    ---
    source: beancount/pretty-printer/tests/snapshotting.rs
    expression: formatted
    ---
    -3888-04-27 * ""
    1755-03-22 close Assets:Y4su4NuttnC:4XBPpxfNc5F9tci-Z99X:EunhF8F7ohnYMbRpBthqxIESGNjUBj:XSo35AQQ:22CfeSTBZBMr3W
    1740-09-14 close Expenses:ELCGOeoBh8T6MggNJYhjLUl0V53JpA
  • replacement in beancount/pretty-printer/Cargo.toml at line 21
    [4.941][4.6967:7001]()
    beancount-types.path = "../types"
    [4.941]
    [4.5283]
    beancount-types.workspace = true
  • edit in beancount/pretty-printer/Cargo.toml at line 40
    [25.873]
    [26.2236]
    arbitrary.workspace = true
  • edit in beancount/pretty-printer/Cargo.toml at line 42
    [26.2273]
    [4.1874]
    rand.workspace = true
  • edit in beancount/pretty-printer/Cargo.toml at line 45
    [26.2311]
    [26.2311]
    testresult.workspace = true
  • edit in beancount/pretty-printer/Cargo.toml at line 47
    [26.2348]
    [dev-dependencies.beancount-types]
    features = ["arbitrary"]
    workspace = true
  • edit in Cargo.toml at line 78
    [4.800]
    [4.1322]
    testresult = "0.4.0"
  • edit in Cargo.toml at line 132
    [28.37812]
    [28.37812]
    [workspace.dependencies.rand]
    features = ["small_rng"]
    version = "0.8.5"
  • edit in Cargo.lock at line 443
    [4.5545]
    [4.5545]
    "arbitrary",
  • edit in Cargo.lock at line 454
    [4.4197]
    [4.7723]
    "rand",
  • edit in Cargo.lock at line 460
    [29.492]
    [30.1735]
    "testresult",
  • edit in Cargo.lock at line 3119
    [4.57546]
    [4.57546]
    "arbitrary",
  • edit in Cargo.lock at line 3692
    [4.72185]
    [4.72185]
    [[package]]
    name = "testresult"
    version = "0.4.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "d72e255c0541f86589b0287139b70bd941a197ea4cea8fd8f87afe9c965a99e4"
  • edit in Cargo.lock at line 5015
    [4.106038][3.8917:8917](),[4.12193][4.1741:1754]()
    [[package]]
  • resolve order conflict in Cargo.lock at line 5015
    [4.106038]