OpenPay (1 crate, ~2940 LOC, 40 tests)
op-statements Statement generation + reconciliation + fee accounting.
Render targets: PDF (template), CSV, JSON, 94-char
NACHA fixed-width. ISO 20022 camt.053 with full
BkToCstmrStmt envelope (GrpHdr/Stmt/Bal/Ntry). BAI2
with 01/02/03/16/49/98/99 records. MT940/MT942
SWIFT with :20:/:25:/:28C:/:60F:/:61:/:86:/:62F:
+ :90C:/:90D: counters. FeeBucket (interchange/scheme/
acquirer/fx/settlement-network/bnpl) + FeeSchedule
with bps + flat rules. Cadence (daily/weekly/monthly/
custom). Two-tier Reconciler (external_id → window
heuristic).
Smart Byte (1 crate, 3032 LOC, 39 tests)
smart-byte-activitypub ActivityPub W3C Rec (2018). AS2 vocab + Public
addressing; Actor (Person/Application/Group/
Organization/Service) with publicKey + shared-inbox;
Object (Note/Article/Image/Video/Tombstone) with
Mastodon extensions (sensitive, CW summary,
conversation, blurhash); 12 Activity types
(Create/Update/Delete/Follow/Accept/Reject/Announce/
Like/Undo/Move/Block/Flag) with side-effect rules;
OrderedCollection + Page; Webfinger (RFC 7033);
HTTP Signatures (cavage draft-12 + RFC 9421);
SHA-256 Digest; Ed25519 sign/verify.
EOC (1 crate, 2759 LOC, 20 tests)
eoc-observability OpenTelemetry-compatible tracing + metrics + logs.
W3C tracecontext + baggage. Span / SpanKind / Status.
Samplers: AlwaysOn/Off/RatioBased/ParentBased. Sync
BatchSpanProcessor + Exporter trait. Counter / Gauge /
Histogram. Prometheus text exposition (HELP/TYPE/
_bucket/_sum/_count/+Inf). StatsD / DogStatsD lines.
GenAI semconv (gen_ai.{operation,system,request.*,
response.*,usage.*}) + EOC extensions (eoc.joules.*,
eoc.co2e_grams, eoc.cost.usd). USD + gCO2e attribution
with PUE. LangSmith + LangFuse export adapters.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
64 lines
2 KiB
Rust
64 lines
2 KiB
Rust
//! Integration: build a multi-line statement and render to CSV.
|
|
|
|
use op_core::{Currency, Money};
|
|
use op_statements::{
|
|
Cadence, Csv, FeeBucket, FeeLine, RenderTarget, Statement, StatementLine, StatementLineKind,
|
|
};
|
|
|
|
#[test]
|
|
fn csv_statement_renders_three_lines() {
|
|
let periods = Cadence::Daily.enumerate(0, 0, 86_399).expect("periods");
|
|
let period = periods.into_iter().next().expect("at least one period");
|
|
|
|
let mut s = Statement::new("STMT-CSV-1", "MERCHANT-42", period, Currency::USD)
|
|
.expect("statement")
|
|
.with_opening(Money::from_minor(2_500, Currency::USD))
|
|
.expect("opening");
|
|
|
|
s.push_line(StatementLine::new(
|
|
"ln-1",
|
|
StatementLineKind::GrossCapture,
|
|
Money::from_minor(10_000, Currency::USD),
|
|
100,
|
|
))
|
|
.expect("push 1");
|
|
|
|
s.push_line(
|
|
StatementLine::new(
|
|
"ln-2",
|
|
StatementLineKind::Fee,
|
|
Money::from_minor(320, Currency::USD),
|
|
101,
|
|
)
|
|
.with_fee(FeeLine::new(
|
|
FeeBucket::Acquirer,
|
|
Money::from_minor(320, Currency::USD),
|
|
))
|
|
.with_external_id("ord-1"),
|
|
)
|
|
.expect("push 2");
|
|
|
|
s.push_line(StatementLine::new(
|
|
"ln-3",
|
|
StatementLineKind::Refund,
|
|
Money::from_minor(500, Currency::USD),
|
|
102,
|
|
))
|
|
.expect("push 3");
|
|
|
|
s.aggregate().expect("aggregate");
|
|
|
|
let out = Csv.render(&s).expect("render");
|
|
assert!(out.starts_with("line_id,kind,currency,amount_minor"));
|
|
assert!(out.contains("ln-1,gross_capture,USD,10000,100,"));
|
|
assert!(out.contains("ln-2,fee,USD,320,101,ord-1"));
|
|
assert!(out.contains("ln-3,refund,USD,500,102,"));
|
|
|
|
let primary = s.primary_aggregate();
|
|
assert_eq!(primary.opening.minor_units, 2_500);
|
|
assert_eq!(primary.gross_volume.minor_units, 10_000);
|
|
assert_eq!(primary.refunds.minor_units, 500);
|
|
assert_eq!(primary.fees.minor_units, 320);
|
|
// 2500 + 10000 - 500 - 320 = 11680
|
|
assert_eq!(primary.ending.minor_units, 11_680);
|
|
}
|