From 1bea4d621a0c27c817523bd438fee3f8eec81042 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Sat, 25 Jul 2026 11:07:08 -0700 Subject: [PATCH] delete dead code --- src/analytics/analysis.zig | 12 ------ src/models/transaction_log.zig | 78 ++++------------------------------ 2 files changed, 9 insertions(+), 81 deletions(-) diff --git a/src/analytics/analysis.zig b/src/analytics/analysis.zig index 019530d..b6b18ea 100644 --- a/src/analytics/analysis.zig +++ b/src/analytics/analysis.zig @@ -254,18 +254,6 @@ pub const AccountMap = struct { return null; } - /// Return all entries matching a given institution. - pub fn entriesForInstitution(self: AccountMap, institution: []const u8) []const AccountTaxEntry { - var count: usize = 0; - for (self.entries) |e| { - if (e.institution) |inst| { - if (std.mem.eql(u8, inst, institution)) count += 1; - } - } - if (count == 0) return &.{}; - return self.entries; - } - /// Is cash-balance movement on `account` treated as a real /// contribution (vs. internal noise) for the attribution total? /// Defaults to false when the account isn't in the map. diff --git a/src/models/transaction_log.zig b/src/models/transaction_log.zig index 6f52ea2..33f8a8a 100644 --- a/src/models/transaction_log.zig +++ b/src/models/transaction_log.zig @@ -53,8 +53,9 @@ //! destination share-addition, per-symbol. //! - No historical reconstruction - forward-looking only. //! -//! See `REPORT.md` ยง5 for the full usage guide and -//! `src/commands/contributions.zig` for the classifier integration. +//! See `docs/reference/config/transaction-log-srf.md` for the full +//! usage guide and `src/commands/contributions.zig` for the classifier +//! integration. const std = @import("std"); const builtin = @import("builtin"); @@ -201,31 +202,6 @@ pub const TransactionLog = struct { } self.allocator.free(self.transfers); } - - /// Return transfers whose `transfer` date falls within `[start, end]` - /// inclusive. The returned slice is allocator-owned - caller must - /// free it. - /// - /// Works only because `parseTransactionLogFile` preserves file - /// order. If callers ever need chronological ordering regardless - /// of file layout, sort on the way out instead of on the way in - - /// file order is sometimes meaningful for a human reviewer - /// (grouping related records together). - pub fn transfersInWindow( - self: *const TransactionLog, - allocator: std.mem.Allocator, - start: Date, - end: Date, - ) ![]const TransferRecord { - var out: std.ArrayList(TransferRecord) = .empty; - errdefer out.deinit(allocator); - for (self.transfers) |r| { - if (r.transfer.days < start.days) continue; - if (r.transfer.days > end.days) continue; - try out.append(allocator, r); - } - return try out.toOwnedSlice(allocator); - } }; /// Parse `data` (the contents of a `transaction_log.srf` file) into a @@ -238,6 +214,11 @@ pub const TransactionLog = struct { /// only hard errors are allocator failures and SRF-level parse errors /// that prevent the iterator from starting at all. /// +/// Records come out in **file order**, deliberately not sorted by date. +/// File order is often meaningful to a human reviewer - related records +/// get grouped together - and any consumer that needs chronological +/// ordering can sort on the way out. Pinned by a test below. +/// /// The SRF record layout is `transfer::,type::,amount:num:, /// from::,to::,dest_lot::
[,note::]`. SRF's /// `fields.to(TransferRecord)` does the coercion: each key matches a @@ -677,47 +658,6 @@ test "parseTransactionLogFile: malformed record skipped, subsequent record survi try testing.expectEqual(@as(f64, 3000), log.transfers[0].amount); } -test "transfersInWindow: inclusive on both ends" { - var log = try parseTransactionLogFile(testing.allocator, - \\#!srfv1 - \\transfer::2026-04-30,type::cash,amount:num:100,from::Acct A,to::Acct B,dest_lot::cash - \\transfer::2026-05-01,type::cash,amount:num:200,from::Acct A,to::Acct B,dest_lot::cash - \\transfer::2026-05-15,type::cash,amount:num:300,from::Acct A,to::Acct B,dest_lot::cash - \\transfer::2026-05-31,type::cash,amount:num:400,from::Acct A,to::Acct B,dest_lot::cash - \\transfer::2026-06-01,type::cash,amount:num:500,from::Acct A,to::Acct B,dest_lot::cash - \\ - ); - defer log.deinit(); - - const slice = try log.transfersInWindow( - testing.allocator, - Date.fromYmd(2026, 5, 1), - Date.fromYmd(2026, 5, 31), - ); - defer testing.allocator.free(slice); - try testing.expectEqual(@as(usize, 3), slice.len); - try testing.expectEqual(@as(f64, 200), slice[0].amount); - try testing.expectEqual(@as(f64, 300), slice[1].amount); - try testing.expectEqual(@as(f64, 400), slice[2].amount); -} - -test "transfersInWindow: empty window returns empty slice" { - var log = try parseTransactionLogFile(testing.allocator, - \\#!srfv1 - \\transfer::2026-05-01,type::cash,amount:num:100,from::Acct A,to::Acct B,dest_lot::cash - \\ - ); - defer log.deinit(); - - const slice = try log.transfersInWindow( - testing.allocator, - Date.fromYmd(2027, 1, 1), - Date.fromYmd(2027, 12, 31), - ); - defer testing.allocator.free(slice); - try testing.expectEqual(@as(usize, 0), slice.len); -} - test "parseTransactionLogFile: preserves file order (not sorted)" { var log = try parseTransactionLogFile(testing.allocator, \\#!srfv1 @@ -728,7 +668,7 @@ test "parseTransactionLogFile: preserves file order (not sorted)" { ); defer log.deinit(); try testing.expectEqual(@as(usize, 3), log.transfers.len); - // File order preserved - see `transfersInWindow` docstring for why. + // File order preserved, NOT date-sorted - see the parser's docstring. try testing.expectEqual(@as(f64, 3), log.transfers[0].amount); try testing.expectEqual(@as(f64, 1), log.transfers[1].amount); try testing.expectEqual(@as(f64, 2), log.transfers[2].amount);