summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/FundLab.Api.Tests/CashReconciliationTests.fs44
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)