feat: savings tab, fix pull-to-refresh, beautiful modals, fix signing
This commit is contained in:
70
PulseHealth/Models/SavingsModels.swift
Normal file
70
PulseHealth/Models/SavingsModels.swift
Normal file
@@ -0,0 +1,70 @@
|
||||
import Foundation
|
||||
|
||||
struct SavingsCategory: Codable, Identifiable {
|
||||
let id: Int
|
||||
var name: String
|
||||
var description: String?
|
||||
var isDeposit: Bool?
|
||||
var isCredit: Bool?
|
||||
var isAccount: Bool?
|
||||
var isRecurring: Bool?
|
||||
var isMulti: Bool?
|
||||
var isClosed: Bool?
|
||||
var currentAmount: Double?
|
||||
var depositAmount: Double?
|
||||
var interestRate: Double?
|
||||
var depositStartDate: String?
|
||||
var depositEndDate: String?
|
||||
var recurringAmount: Double?
|
||||
|
||||
var icon: String {
|
||||
if isDeposit == true { return "percent" }
|
||||
if isAccount == true { return "building.columns.fill" }
|
||||
if isRecurring == true { return "arrow.clockwise" }
|
||||
return "banknote.fill"
|
||||
}
|
||||
|
||||
var color: String {
|
||||
if isDeposit == true { return "ffa502" }
|
||||
if isAccount == true { return "7c3aed" }
|
||||
if isRecurring == true { return "00d4aa" }
|
||||
return "8888aa"
|
||||
}
|
||||
|
||||
var typeLabel: String {
|
||||
if isDeposit == true { return "Вклад \(Int(interestRate ?? 0))%" }
|
||||
if isAccount == true { return "Счёт" }
|
||||
if isRecurring == true { return "Накопления" }
|
||||
return "Копилка"
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, name, description
|
||||
case isDeposit = "is_deposit"
|
||||
case isCredit = "is_credit"
|
||||
case isAccount = "is_account"
|
||||
case isRecurring = "is_recurring"
|
||||
case isMulti = "is_multi"
|
||||
case isClosed = "is_closed"
|
||||
case currentAmount = "current_amount"
|
||||
case depositAmount = "deposit_amount"
|
||||
case interestRate = "interest_rate"
|
||||
case depositStartDate = "deposit_start_date"
|
||||
case depositEndDate = "deposit_end_date"
|
||||
case recurringAmount = "recurring_amount"
|
||||
}
|
||||
}
|
||||
|
||||
struct SavingsStats: Codable {
|
||||
var totalBalance: Double?
|
||||
var totalDeposits: Double?
|
||||
var totalWithdrawals: Double?
|
||||
var categoriesCount: Int?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case totalBalance = "total_balance"
|
||||
case totalDeposits = "total_deposits"
|
||||
case totalWithdrawals = "total_withdrawals"
|
||||
case categoriesCount = "categories_count"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user