Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions contributor_tasks/bank-interest-legacy-java7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM --platform=linux/amd64 ghcr.io/laude-institute/t-bench/python-3-13:20250620

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*

ENV JAVA_HOME=/opt/jdk7
ENV PATH="$JAVA_HOME/bin:$PATH"

ARG ZULU7_URL=https://cdn.azul.com/zulu/bin/zulu7.56.0.11-ca-jdk7.0.352-linux_x64.tar.gz
ARG ZULU7_SHA256=8a7387c1ed151474301b6553c6046f865dc6c1e1890bcf106acc2780c55727c8
RUN mkdir -p /opt/zulu7 \
&& curl -fsSL "$ZULU7_URL" -o /tmp/zulu7.tgz \
&& echo "$ZULU7_SHA256 /tmp/zulu7.tgz" | sha256sum -c - \
&& tar -xzf /tmp/zulu7.tgz -C /opt/zulu7 \
&& rm /tmp/zulu7.tgz \
&& JDK_DIR="$(find /opt/zulu7 -mindepth 1 -maxdepth 1 -type d -name 'zulu7*' | head -n 1)" \
&& test -n "$JDK_DIR" \
&& rm -rf /opt/jdk7 \
&& ln -s "$JDK_DIR" /opt/jdk7 \
&& ln -sf /opt/jdk7/bin/java /usr/local/bin/java \
&& ln -sf /opt/jdk7/bin/javac /usr/local/bin/javac \
&& ln -sf /opt/jdk7/bin/jar /usr/local/bin/jar

RUN pip install --no-cache-dir pytest==8.4.2

WORKDIR /app

RUN mkdir -p /opt/legacy-lib \
&& curl -fsSL -o /opt/legacy-lib/h2-1.3.176.jar https://repo1.maven.org/maven2/com/h2database/h2/1.3.176/h2-1.3.176.jar \
&& true

COPY data ./data

CMD ["bash"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
account_id,opened_at,start_balance,base_apr,promo_apr,promo_days,tier_threshold,tier_apr,currency,fee_plan
A1001,2024-02-01,10000.00,0.01000,0.00500,29,5000.00,0.00200,USD,PLAN_A
A1002,2020-01-01,5000.00,0.00800,0.00000,0,5000.00,0.00100,USD,PLAN_B
A1003,2023-12-01,-10.00,0.02000,0.00000,0,10000.00,0.00500,EUR,PLAN_A
A1004,2023-01-01,36500.00,0.01005,0.00000,0,999999.00,0.00000,USD,PLAN_C
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024-03-01
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fee_plan,applies_to,flat_fee,pct_fee,min_fee,max_fee
PLAN_A,DEBIT,0.50,0.005,0.25,5.00
PLAN_B,ALL,0.10,0.002,0.10,2.00
PLAN_C,CREDIT,0.25,0.001,0.25,1.00
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pivot
GBP
EUR
19 changes: 19 additions & 0 deletions contributor_tasks/bank-interest-legacy-java7/data/fx_rates.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rate_date,from_ccy,to_ccy,rate
2024-01-01,USD,EUR,0.9000
2024-01-01,EUR,USD,1.1111
2024-02-01,USD,EUR,0.9100
2024-02-01,EUR,USD,1.0989
2024-03-01,USD,EUR,0.9200
2024-03-01,EUR,USD,1.0870
2024-02-01,JPY,EUR,0.0065
2024-03-01,JPY,EUR,0.0066
2024-02-01,USD,GBP,0.7900
2024-03-01,USD,GBP,0.8000
2024-02-01,GBP,JPY,190.00
2024-03-01,GBP,JPY,188.00
2024-02-01,JPY,USD,0.0067
2024-03-01,USD,JPY,150.00
2024-02-01,CAD,GBP,0.5800
2024-03-01,GBP,CAD,1.7200
2024-02-01,CAD,EUR,0.6700
2024-03-01,EUR,CAD,1.4900
21 changes: 21 additions & 0 deletions contributor_tasks/bank-interest-legacy-java7/data/transactions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
tx_id,account_id,effective_date,amount,currency,status,reversal_of
T001,A1001,2024-03-01,-2000.00,USD,POSTED,
T002,A1001,2024-03-02,-500.00,EUR,POSTED,
T003,A1001,2024-02-28,100.00,USD,PENDING,
T004,A1002,2024-02-15,50.00,USD,POSTED,
T004,A1002,2024-02-15,50.00,USD,POSTED,
T005,A1002,2024-02-16,-20.00,USD,POSTED,
T006,A1002,2024-02-20,20.00,USD,POSTED,T005
T007,A1003,2024-03-01,10.00,USD,POSTED,
T008,A1003,2024-03-01,-10.00,EUR,POSTED,NOPE
T009,A1004,2024-01-15,1000.00,EUR,POSTED,
T010,A1004,2024-03-01,-1000.00,USD,POSTED,T009
T011,A1002,2024-03-01,5.00,USD,POSTED,
T012,A1002,2024-03-05,5.00,USD,POSTED,
T013,A1001,2024-02-10,30.00,GBP,POSTED,
T014,A1001,2024-03-01,-10000.00,JPY,POSTED,
T015,A1002,2024-03-01,100.00,CAD,POSTED,
T016,A9999,2024-03-01,25.00,USD,POSTED,
T016,A1001,2024-03-01,25.00,USD,POSTED,
T017,A1003,2024-03-01,-15.00,USD,POSTED,T018
T018,A1003,2024-03-01,15.00,USD,POSTED,
12 changes: 12 additions & 0 deletions contributor_tasks/bank-interest-legacy-java7/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
client:
build:
dockerfile: Dockerfile
image: ${T_BENCH_TASK_DOCKER_CLIENT_IMAGE_NAME}
container_name: ${T_BENCH_TASK_DOCKER_CLIENT_CONTAINER_NAME}
command: [ "sh", "-c", "sleep infinity" ]
environment:
- TEST_DIR=${T_BENCH_TEST_DIR}
volumes:
- ${T_BENCH_TASK_LOGS_PATH}:${T_BENCH_CONTAINER_LOGS_PATH}
- ${T_BENCH_TASK_AGENT_LOGS_PATH}:${T_BENCH_CONTAINER_AGENT_LOGS_PATH}
3 changes: 3 additions & 0 deletions contributor_tasks/bank-interest-legacy-java7/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -euo pipefail
pytest $TEST_DIR/test_outputs.py -v -rA
382 changes: 382 additions & 0 deletions contributor_tasks/bank-interest-legacy-java7/solution.sh

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions contributor_tasks/bank-interest-legacy-java7/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
instruction: |-
Old nightly batch for Java 7. Put BankBatchJob in /app/job.jar, compile to Java 7 bytecode, and run it. Running it again on the same day should give the same results.

Inputs are in /app/data:
- accounts.csv
- transactions.csv
- biz_date.txt
- fx_rates.csv
- fx_pivots.csv
- fee_rules.csv

Outputs are in /app/output:
- interest.csv, LF + trailing newline.
Account, business date, end-of-day balance, annual percentage rate (APR), and daily interest.
apr 6dp, eod_balance, and daily_interest 2dp, sorted by account_id.
- exceptions.csv, LF + trailing newline.
Title: row_num, tx_id, and reason.
Row_num is 1-based data row.
- stats.json is single-line JSON without newlines.
Business date, accounts, valid_txs, skipped_txs, total_interest, and report_md5.
report_md5 is md5 of interest.csv bytes. total_interest=2dp.
- bankdb.h2.db H2 database with ACCOUNTS and TXNS (row_num 1..N).
There is one row in RUN_AUDIT: jdbc_url, biz_date, accounts, valid_txs, skipped_txs, and report_md5.

Use these reasons in file order:
- REVERSED (both rows if reversal_of points to any tx_id in file, even if referenced row appears later)
- REVERSAL_MISSING
- FX_MISSING (before FX)
- AFTER_BIZ_DATE
- status!=POSTED (use status)
- DUPLICATE (any tx_id after first appearance, even if first row was invalid)

For FX, use latest rate_date <= effective_date. If direct and reverse exist, choose the newer one; if tied, use direct. reverse 1/rate (HALF_EVEN 10dp). If no direct/reverse, try fx_pivots.csv in order: solve each leg the same way, multiply, round HALF_EVEN 10dp (skip pivots equal to from/to). The first pivot wins; if not, FX_MISSING.
Fees: First, change currency to account's. fee = flat fee + percentage fee * abs(amount), rounded to nearest half-even 2dp and limited to [min_fee,max_fee]. adjusted = amount - fee, rounded Half-even 2dp. This applies to DEBIT, CREDIT, and ALL fee plans. eod_balance = start_balance + sum(valid adjusted), rounded to two decimal places. If eod_balance is greater than or equal to tier_threshold, APR = base_apr + tier_apr + promo_apr (if promo_days > 0 and days_since_opened_at < promo_days; opened_at = day 0).
Interest uses principal = max(eod_balance,0). daily_interest_raw = principal * apr/365 (HALF_EVEN 10dp). interest.csv rounds daily_interest_raw to two decimal places. total_interest is sum(daily_interest_raw, keep 10dp) rounded to 2dp.

Don't touch /app/data. H2 1.3 DB2 mode; user sa has a blank password. JDBC URL must be a single literal string that starts with "jdbc:h2:" and has "MODE=DB2" and "/app/output/bankdb" in it. Use at runtime is required. Java 7-only bytecode

difficulty: hard
category: legacy
tags:
- java
- legacy
- banking
parser_name: pytest
max_agent_timeout_sec: 300.0
max_test_timeout_sec: 120.0
run_tests_in_same_shell: false
expert_time_estimate_min: 20
junior_time_estimate_min: 40
Loading