From cbff36d51c050cad33a43961690faebcaea27f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20K=C3=B6tte?= Date: Sun, 6 Jun 2021 00:32:41 -0700 Subject: [PATCH] Use date of last posting to determine month Sheets often include forgotten postings from prior month, therefore it is better to use the month of the latest posting to determine the month of the sheet --- Sources/SwiftBeanCountSheetSync/Syncer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftBeanCountSheetSync/Syncer.swift b/Sources/SwiftBeanCountSheetSync/Syncer.swift index ee16844..b65e0e4 100644 --- a/Sources/SwiftBeanCountSheetSync/Syncer.swift +++ b/Sources/SwiftBeanCountSheetSync/Syncer.swift @@ -95,7 +95,7 @@ public class GenericSyncer { } func ledgerTransactionForCorrectMonth(ledgerTransactions: [Transaction], sheetTransactions: [Transaction]) -> [Transaction] { - let date = sheetTransactions.first?.metaData.date ?? Date() + let date = sheetTransactions.last?.metaData.date ?? Date() return ledgerTransactions.filter { Calendar.current.isDate(date, equalTo: $0.metaData.date, toGranularity: .month) }