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:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user