-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b58e1a
commit 66e3525
Showing
44 changed files
with
1,111 additions
and
471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Expense.swift | ||
// Data | ||
// | ||
// Created by Amisha Italiya on 20/03/24. | ||
// | ||
|
||
import FirebaseFirestore | ||
|
||
public struct Expense: Codable { | ||
|
||
@DocumentID public var id: String? // Automatically generated ID by Firestore | ||
|
||
let name: String | ||
let amount: Double | ||
let date: Timestamp | ||
let paidBy: String | ||
let splitTo: [String] // Reference to user ids involved in the split | ||
let groupId: String | ||
let splitType: SplitType | ||
|
||
public init(name: String, amount: Double, date: Timestamp, paidBy: String, | ||
splitTo: [String], groupId: String, splitType: SplitType = .equally) { | ||
self.name = name | ||
self.amount = amount | ||
self.date = date | ||
self.paidBy = paidBy | ||
self.splitTo = splitTo | ||
self.groupId = groupId | ||
self.splitType = splitType | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case name | ||
case amount | ||
case date | ||
case paidBy = "paid_by" | ||
case splitTo = "split_to" | ||
case groupId = "group_id" | ||
case splitType = "split_type" | ||
} | ||
} | ||
|
||
public enum SplitType: String, Codable { | ||
case equally | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// ExpenseRepository.swift | ||
// Data | ||
// | ||
// Created by Amisha Italiya on 20/03/24. | ||
// | ||
|
||
import Combine | ||
import FirebaseFirestoreInternal | ||
|
||
public class ExpenseRepository: ObservableObject { | ||
|
||
@Inject private var store: ExpenseStore | ||
|
||
private var cancelable = Set<AnyCancellable>() | ||
|
||
public func addExpense(expense: Expense, completion: @escaping (String?) -> Void) { | ||
store.addExpense(expense: expense, completion: completion) | ||
} | ||
|
||
public func deleteExpense(id: String) -> AnyPublisher<Void, ServiceError> { | ||
store.deleteExpense(id: id) | ||
} | ||
} |
Oops, something went wrong.