diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b82835e..2051b59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,7 +85,7 @@ jobs: uses: swift-actions/setup-swift@v2.1.0 - name: Install SwiftLint run: | - curl -L https://github.com/realm/SwiftLint/releases/download/0.54.0/swiftlint_linux.zip -o swiftlint.zip + curl -L https://github.com/realm/SwiftLint/releases/download/0.57.0/swiftlint_linux.zip -o swiftlint.zip unzip swiftlint.zip -d swiftlint ./swiftlint/swiftlint --version - name: Run SwiftLint diff --git a/Sources/SwiftBeanCountTax/TaxCalculator.swift b/Sources/SwiftBeanCountTax/TaxCalculator.swift index 92246c3..786bc58 100644 --- a/Sources/SwiftBeanCountTax/TaxCalculator.swift +++ b/Sources/SwiftBeanCountTax/TaxCalculator.swift @@ -131,8 +131,8 @@ public enum TaxCalculator { return try issuers.compactMap { issuer throws -> TaxSlip? in let issuerTaxSlipRelevantAccounts = taxSlipRelevantAccounts.filter { $0.metaData[MetaDataKeys.issuer] ?? "" == issuer } // collect all transactions which have a posting to a split account AND an account for this issuer - var splitTransactions = taxYearTransactions.filter { $0.postings.contains { issuerTaxSlipRelevantAccounts.map { $0.name }.contains($0.accountName) } - && $0.postings.contains { splitAccounts.map { $0.0 }.contains($0.accountName.fullName) } + var splitTransactions = taxYearTransactions.filter { $0.postings.contains { issuerTaxSlipRelevantAccounts.map(\.name).contains($0.accountName) } + && $0.postings.contains { splitAccounts.map(\.0).contains($0.accountName.fullName) } } let entries = issuerTaxSlipRelevantAccounts.flatMap { account -> [TaxSlipEntry] in let postings = taxYearTransactions.flatMap { $0.postings.filter { $0.accountName == account.name } } @@ -146,10 +146,10 @@ public enum TaxCalculator { // split accounts entries.append(contentsOf: splitAccounts.compactMap { splitAccount -> TaxSlipEntry? in // filter splitTransactions for transactions for the current account, and get the posting to the split account - let splitPostings = splitTransactions.filter { [account.name.fullName, splitAccount.0].allSatisfy($0.postings.map { $0.accountName.fullName }.contains) } + let splitPostings = splitTransactions.filter { [account.name.fullName, splitAccount.0].allSatisfy($0.postings.map(\.accountName.fullName).contains) } .flatMap { $0.postings.filter { $0.accountName.fullName == splitAccount.0 } } // rmove the processed transactions - otherwise when a transaction has multiple accounts and a split account, it would be counted multiple times - splitTransactions.removeAll { [account.name.fullName, splitAccount.0].allSatisfy($0.postings.map { $0.accountName.fullName }.contains) } + splitTransactions.removeAll { [account.name.fullName, splitAccount.0].allSatisfy($0.postings.map(\.accountName.fullName).contains) } if let (value, originalValue) = getValues(commodity: commodity, postings: splitPostings) { return TaxSlipEntry(symbol: symbol, name: name, box: splitAccount.1, value: value, originalValue: originalValue) } diff --git a/Sources/SwiftBeanCountTax/TaxSlip.swift b/Sources/SwiftBeanCountTax/TaxSlip.swift index 10c114d..3090e96 100644 --- a/Sources/SwiftBeanCountTax/TaxSlip.swift +++ b/Sources/SwiftBeanCountTax/TaxSlip.swift @@ -111,7 +111,7 @@ public struct TaxSlip: Identifiable { /// Boxes which have a value on the slip public var boxes: [String] { - Array(Set(entries.map { $0.box })).sorted(by: boxNumberSort) + Array(Set(entries.map(\.box))).sorted(by: boxNumberSort) } /// If a slip is split by symbols (e.g. stocks), this contains the list of symbols, otherwise is is empty @@ -166,7 +166,7 @@ extension TaxSlipRow: CustomStringConvertible { } public var description: String { - "\(displayName != nil ? "\(displayName!):\n" : "")\(values.sorted(by: rowValueBoxNumberSort).map { $0.description }.joined(separator: "\n") )" + "\(displayName != nil ? "\(displayName!):\n" : "")\(values.sorted(by: rowValueBoxNumberSort).map(\.description).joined(separator: "\n") )" } } @@ -193,7 +193,7 @@ extension TaxSlip: CustomStringConvertible { } public var description: String { - "\(header)\n\(rows.map { $0.description }.joined(separator: "\n"))\(symbols.isEmpty ? "" : "\nSum:\n\(sumRow.description)")" + "\(header)\n\(rows.map(\.description).joined(separator: "\n"))\(symbols.isEmpty ? "" : "\nSum:\n\(sumRow.description)")" } }