delete dead code

This commit is contained in:
Emil Lerch 2026-07-25 11:07:08 -07:00
parent dcd5885fcc
commit 1bea4d621a
Signed by: lobo
GPG key ID: A7B62D657EF764F8
2 changed files with 9 additions and 81 deletions

View file

@ -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.

View file

@ -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::<date>,type::<t>,amount:num:<n>,
/// from::<a>,to::<b>,dest_lot::<dl>[,note::<n>]`. 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);