diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-22 20:42:27 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-22 20:42:27 +0800 |
| commit | 248b50c8fd057c87a852f8306fc4585905880abc (patch) | |
| tree | 254102f8891e2fa6c62a2bef31bf13be720c5a91 /tests | |
| parent | 75523a0f99ad86fd5cd01ef36f2091e6b670bf9d (diff) | |
| download | fund-lab-248b50c8fd057c87a852f8306fc4585905880abc.tar.gz | |
Fetch latest fund NAV via ETF endpoint so T-day subscriptions can confirm (3d-38)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/FundLab.Api.Tests/CashReconciliationTests.fs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/FundLab.Api.Tests/CashReconciliationTests.fs b/tests/FundLab.Api.Tests/CashReconciliationTests.fs index b9b024a..fa14bff 100644 --- a/tests/FundLab.Api.Tests/CashReconciliationTests.fs +++ b/tests/FundLab.Api.Tests/CashReconciliationTests.fs @@ -542,3 +542,47 @@ type CashReconciliationTests(fixture: PostgresFixture) = Assert.Equal(-520.00m, internalTotal) Assert.Equal(3880.00m, externalTotal + internalTotal) Assert.Equal(0.00m, (repository().GetCashReconciliation fundId |> Result.defaultWith failwith).Difference) + + [<Fact>] + member _.``a subscription confirmed at the 2026-09-22 nav date reconciles to zero``() = + let fundId = createFund 10000.00m + let code = seedInstrument () + let tradeDate = DateOnly(2026, 9, 22) + insertQuoteOnDate code 1.327m tradeDate + + let order = + match + repository().CreateSubscriptionOrder( + fixture.Key "cash-tday-order", + fundId, + { FundCode = code; Amount = 1000.00m; FeeAmount = 0m }, + tradeDate + ) + with + | SubscriptionOrderWriteResult.OrderCreated order -> order + | other -> failwithf "unexpected subscription order result: %A" other + + match + repository().ConfirmSubscriptionOrder( + fixture.Key "cash-tday-confirm", + fundId, + order.Id + ) + with + | SubscriptionConfirmResult.OrderConfirmed confirmed -> + match confirmed.ConfirmedQuote with + | Some quote -> + Assert.Equal(tradeDate, quote.NavDate) + Assert.Equal(1.327m, quote.Nav) + | None -> failwith "confirmed quote evidence missing" + | other -> failwithf "unexpected subscription confirm: %A" other + + let status, body = reconciliation fundId + Assert.Equal(200, status) + Assert.Contains("\"openingCash\":\"10000.00\"", body) + Assert.Contains("\"difference\":\"0.00\"", body) + Assert.Equal(1, eventCount body "subscription") + + // the confirmed subscription is an external outflow that fully explains cash + let subscriptionNet = sourceNet body "subscription" + Assert.True(subscriptionNet < 0m, sprintf "expected subscription outflow, got %M" subscriptionNet) |
