store: read no confirmed units as 0

This commit is contained in:
shum committed 2026-10-22 13:43:53 +00:00
1 parent c259e63827
commit 154bedd630
2 files changed
+7 -1

No files matched your search

@@ -1034,7 +1034,7 @@ pendingCase =
" CASE WHEN" <> uncreditedMoney <> " THEN " <> literal LPUncredited
<> " WHEN COALESCE(p.amount, 0) = 0 AND (p.crypto_paid IS NOT NULL OR p.paid_in_full = 1) THEN " <> literal LPConfirming
<> " WHEN" <> cardInvoice <> " AND COALESCE(p.amount, 0) > p.confirmed_amount THEN " <> literal LPUnconfirmed
<> " WHEN p.received_units > p.confirmed_units THEN " <> literal LPUnconfirmed
<> " WHEN p.received_units > COALESCE(p.confirmed_units, 0) THEN " <> literal LPUnconfirmed
<> " WHEN" <> cryptoInvoice <> " AND p.received_units IS NULL AND COALESCE(p.amount, 0) > 0 THEN " <> literal LPUncounted
<> " END"
where
@@ -81,6 +81,7 @@ namesBalancesTests = describe "StoreService names: balances" $ do
it "tells each case of pending money and selects confirmed money not all credited, by the order whatever the invoice's status" testLateScans
it "leaves 0.1 and 0.2 BTC credited against 0.3 confirmed neither pending nor selected" testExactUnits
it "tells confirmed money not credited as such while its cents still read 0, as Monero's can" testConfirmedBeforeCents
it "reads crypto received with no confirmed figure as unconfirmed" testNoConfirmedFigure
it "alerts on pending money past the cutoff once, again only when more arrives, claimed by one of two instances" testLateAlerts
it "alerts again on money that could not be counted in units when more of it arrives" testUncountedAlertRepeats
describe "turns" $ do
@@ -647,6 +648,11 @@ testConfirmedBeforeCents = withServiceStore $ \st -> do
withTransaction st (\db -> latePending db (InvoiceId "inv-x")) `shouldReturn` Just LPUncredited
withTransaction st uncreditedLateInvoices `shouldReturn` [InvoiceId "inv-x"]
testNoConfirmedFigure :: IO ()
testNoConfirmedFigure = withServiceStore $ \st -> do
closedWith st "x" False (cryptoPaid 300000 0) {pConfirmedUnits = Nothing} t0
withTransaction st (\db -> latePending db (InvoiceId "inv-x")) `shouldReturn` Just LPUnconfirmed
testLateAlerts :: IO ()
testLateAlerts = withServiceStore $ \st -> do
closedWith st "old" False (cryptoPaid 300000 0) t0