Idk, updated something

This commit is contained in:
William Brawner 2023-12-08 23:01:07 -07:00
parent 3c40566094
commit 4b65d7417f
Signed by: wbrawner
GPG key ID: 8FF12381C6C90D35
2 changed files with 27 additions and 19 deletions

View file

@ -17,26 +17,31 @@ public struct Budget: Identifiable, Hashable, Codable {
public struct BudgetOverview: Equatable {
public let budget: Budget
public let balance: Int
public var maxValue: Float {
get {
return Float(max(
max(expectedIncome, actualIncome),
max(expectedExpenses, actualExpenses)
))
}
}
public var expectedIncome: Int
public var actualIncome: Int
public var expectedExpenses: Int
public var actualExpenses: Int
public let transactionCount: Int
public let categories: [Category]
public var expectedIncome: Float
public var actualIncome: Float
public var expectedExpenses: Float
public var actualExpenses: Float
public init(budget: Budget, balance: Int, expectedIncome: Int = 0, actualIncome: Int = 0, expectedExpenses: Int = 0, actualExpenses: Int = 0) {
public init(
budget: Budget,
balance: Int,
categories: [Category],
transactionCount: Int,
expectedIncome: Int = 0,
actualIncome: Int = 0,
expectedExpenses: Int = 0,
actualExpenses: Int = 0
) {
self.budget = budget
self.balance = balance
self.expectedIncome = expectedIncome
self.actualIncome = actualIncome
self.expectedExpenses = expectedExpenses
self.actualExpenses = actualExpenses
self.categories = categories
self.transactionCount = transactionCount
self.expectedIncome = Float(expectedIncome) / 100.0
self.actualIncome = Float(actualIncome) / 100.0
self.expectedExpenses = Float(expectedExpenses) / 100.0
self.actualExpenses = Float(actualExpenses) / 100.0
}
}

View file

@ -272,7 +272,7 @@ public class RequestHelper {
var combinedEndPoint = endPoint
if (queries != nil) {
for (key, values) in queries! {
for value in values {
for value in values {
let separator = combinedEndPoint.contains("?") ? "&" : "?"
combinedEndPoint += separator + key + "=" + value
}
@ -392,6 +392,9 @@ public class RequestHelper {
return try self.decoder.decode(ResultType.self, from: data)
} catch {
print("error decoding json: \(error)")
if let data = data {
print(String(decoding: data, as: UTF8.self))
}
throw NetworkError.jsonParsingFailed(error)
}
}