File size: 3,472 Bytes
622387b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -uxo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd /workspace
git config --global --add safe.directory /workspace
mkdir -p /logs/verifier
git checkout ea95d2eee7e194aef2375e7b5804fb481efeff80 -- tests/test_demat_units.py || true
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
diff --git a/tests/test_demat_units.py b/tests/test_demat_units.py
index 556b227..83653d7 100644
--- a/tests/test_demat_units.py
+++ b/tests/test_demat_units.py
@@ -281,6 +281,50 @@ class TestCDSLHelpers:
         # value is consistent with balance * nav
         assert abs(mf.balance * mf.nav - mf.value) <= Decimal("0.01")
 
+    def test_mf_holdings_pnl_identity_full_row(self):
+        """Full distrib row: profit and return% at the tail."""
+        block = _block(
+            _cell("EXFND - Example Fund", 22, 90),
+            _cell("INF000A01001", 192, 230),
+            _cell("12345", 273, 300),
+            _cell("DIRECT", 320, 360),
+            _cell("100.000", 380, 410),
+            _cell("25.0000", 430, 460),
+            _cell("2000.00", 480, 510),
+            _cell("2500.00", 530, 560),
+            _cell("0.10", 570, 590),
+            _cell("0", 600, 620),
+            _cell("500.00", 630, 650),
+            _cell("25.00", 660, 680),
+        )
+        mf = cdsl_p._parse_mf_holdings_row(block, {})
+        assert mf is not None
+        assert mf.pnl == Decimal("500.00")
+        assert mf.return_ == Decimal("25.00")
+
+    def test_mf_holdings_return_only_tail(self):
+        """1684130326 geometry: no printed profit; return% must not land in pnl."""
+        block = _block(
+            _cell("32Z - Aditya Birla Sun Life Corporate Bond Fund - ", 21.5, 90),
+            _cell("INF209K01S38", 112.3, 230),
+            _cell("1040936382", 167.2, 300),
+            _cell("DIRECT", 219.0, 360),
+            _cell("ARN\x02", 222.8, 380),
+            _cell("11.343", 269.4, 410),
+            _cell("95.6053", 299.6, 460),
+            _cell("1,000.00", 348.1, 510),
+            _cell("1,084.45", 398.1, 560),
+            _cell("0", 469.1, 590),
+            _cell(".31", 507.9, 620),
+            _cell("0", 574.1, 650),
+        )
+        mf = cdsl_p._parse_mf_holdings_row(block, {})
+        assert mf is not None
+        assert mf.value == Decimal("1084.45")
+        assert mf.total_cost == Decimal("1000.00")
+        assert mf.pnl is None
+        assert mf.return_ == Decimal("0.31")
+
 
 # ---------------------------------------------------------------- NSDL
 

EOF_R2E_TEST_PATCH
R2E_APPLY_RC=$?
if [ "$R2E_APPLY_RC" -ne 0 ]; then
  echo "0.000000" > /logs/verifier/reward.txt
  printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
  echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
  exit 0
fi
( python -m pytest -v tests/test_demat_units.py ) > /logs/verifier/test_output.log 2>&1
TEST_EXIT_CODE=$?
cat /logs/verifier/test_output.log
python3 "$SCRIPT_DIR/verifier.py" --log /logs/verifier/test_output.log --f2p "$SCRIPT_DIR/f2p.json" --p2p "$SCRIPT_DIR/p2p.json" --test-cmds 'python -m pytest -v tests/test_demat_units.py' --exit-code "$TEST_EXIT_CODE" --out-dir /logs/verifier || { [ "$TEST_EXIT_CODE" -eq 0 ] && echo "1.0" > /logs/verifier/reward.txt || echo "0.0" > /logs/verifier/reward.txt; }
git checkout ea95d2eee7e194aef2375e7b5804fb481efeff80 -- tests/test_demat_units.py || true
exit 0