Private
Public Access
1
0

Fix Unspecified DateTime kind for PostgreSQL timestamptz columns

DateOnly.ToDateTime() produces Kind=Unspecified which Npgsql rejects
for timestamptz. Specify UTC kind on Plaid transaction dates and add
a safety net in BankSyncService for all parsed dates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-08 17:02:02 -05:00
parent 9d6a006045
commit 5e7c664896
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -442,7 +442,7 @@ public class BankSyncService : IBankSyncService
{ {
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
AccountId = linkedAccount.AccountId!.Value, AccountId = linkedAccount.AccountId!.Value,
Date = parsed.Date, Date = DateTime.SpecifyKind(parsed.Date, DateTimeKind.Utc),
Amount = parsed.Amount, Amount = parsed.Amount,
PayeeId = matchedPayee?.Id, PayeeId = matchedPayee?.Id,
PayeeName = parsed.PayeeName, PayeeName = parsed.PayeeName,
@@ -168,7 +168,7 @@ public class PlaidSyncProvider : IAccountSyncProvider
Success = true, Success = true,
Transactions = allTransactions.Select(t => new ParsedTransaction Transactions = allTransactions.Select(t => new ParsedTransaction
{ {
Date = t.Date?.ToDateTime(TimeOnly.MinValue) ?? DateTime.UtcNow, Date = DateTime.SpecifyKind(t.Date?.ToDateTime(TimeOnly.MinValue) ?? DateTime.UtcNow, DateTimeKind.Utc),
Amount = (decimal)(t.Amount ?? 0) * -1, // Plaid uses positive for debits Amount = (decimal)(t.Amount ?? 0) * -1, // Plaid uses positive for debits
PayeeName = t.MerchantName ?? t.Name, PayeeName = t.MerchantName ?? t.Name,
Memo = t.Name, Memo = t.Name,