Skip to content

Commit

Permalink
Add coderabbit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-amisha-i committed Jan 16, 2025
1 parent e0f054e commit 2b116f0
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 970 deletions.
2 changes: 1 addition & 1 deletion Data/Data/Model/Currency/Currencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@
"code": "MOP",
"name": "Macanese Pataca",
"symbol": "P",
"region": "M"
"region": "MO"
},
{
"code": "MRU",
Expand Down
8 changes: 5 additions & 3 deletions Data/Data/Model/Currency/Currency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public struct Currency: Decodable, Hashable {
public let symbol: String
public let region: String

public static var defaultCurrency = Currency(code: "INR", name: "Indian Rupee", symbol: "", region: "IN")

public init(code: String, name: String, symbol: String, region: String) {
self.code = code
self.name = name
Expand All @@ -25,17 +27,17 @@ public struct Currency: Decodable, Hashable {
return allCurrencies
}

public static func getCurrencyFromCode(_ code: String) -> Currency {
public static func getCurrencyFromCode(_ code: String?) -> Currency {
let allCurrencies = getAllCurrencies()
let currency = allCurrencies.first(where: { $0.code == code }) ?? Currency(code: "INR", name: "Indian Rupee", symbol: "", region: "IN")
let currency = allCurrencies.first(where: { $0.code == code }) ?? defaultCurrency
return currency
}

public static func getCurrentLocalCurrency() -> Currency {
let allCurrencies = getAllCurrencies()
let currentLocal = Locale.current.region?.identifier
let currency = allCurrencies.first(where: { $0.region == currentLocal }) ??
(allCurrencies.first ?? Currency(code: "INR", name: "Indian Rupee", symbol: "", region: "IN"))
(allCurrencies.first ?? defaultCurrency)
return currency
}
}
11 changes: 6 additions & 5 deletions Data/Data/Model/Expense.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public struct Expense: Codable, Hashable, Identifiable {
public var name: String
public var amount: Double
public var category: String? = "General"
public var currencyCode: String? = "INR"
public var currencyCode: String? = Currency.defaultCurrency.code
public var date: Timestamp
public let addedBy: String
public var updatedAt: Timestamp?
Expand All @@ -29,10 +29,11 @@ public struct Expense: Codable, Hashable, Identifiable {
public var participants: [String]? = [] // List of user ids, Used for searching expenses by user
public var isActive: Bool

public init(groupId: String, name: String, amount: Double, category: String = "General", currencyCode: String = "INR",
date: Timestamp, addedBy: String, updatedAt: Timestamp? = nil, updatedBy: String? = nil, note: String? = nil,
imageUrl: String? = nil, splitType: SplitType, splitTo: [String], splitData: [String: Double]? = nil,
paidBy: [String: Double], participants: [String], isActive: Bool = true) {
public init(groupId: String, name: String, amount: Double, category: String = "General",
currencyCode: String = Currency.defaultCurrency.code, date: Timestamp, addedBy: String,
updatedAt: Timestamp? = nil, updatedBy: String? = nil, note: String? = nil, imageUrl: String? = nil,
splitType: SplitType, splitTo: [String], splitData: [String: Double]? = nil, paidBy: [String: Double],
participants: [String], isActive: Bool = true) {
self.groupId = groupId
self.name = name
self.amount = amount
Expand Down
4 changes: 2 additions & 2 deletions Data/Data/Model/Groups.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public struct Groups: Codable, Identifiable {
public let createdAt: Timestamp
public var updatedAt: Timestamp
public var hasExpenses: Bool
public var defaultCurrency: String? = "INR"
public var defaultCurrency: String? = Currency.defaultCurrency.code
public var isActive: Bool

public init(name: String, type: GroupType = .splitExpense, createdBy: String, updatedBy: String? = nil,
imageUrl: String? = nil, members: [String], initialBalance: Double = 0.0, balances: [GroupMemberBalance],
createdAt: Timestamp = Timestamp(), updatedAt: Timestamp = Timestamp(), hasExpenses: Bool = false,
currencyCode: String = "INR", isActive: Bool = true) {
currencyCode: String = Currency.defaultCurrency.code, isActive: Bool = true) {
self.name = name
self.type = type
self.createdBy = createdBy
Expand Down
6 changes: 3 additions & 3 deletions Data/Data/Model/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct Transactions: Codable, Hashable, Identifiable {
public var date: Timestamp
public let addedBy: String
public var amount: Double
public var currencyCode: String? = "INR"
public var currencyCode: String? = Currency.defaultCurrency.code
public var updatedBy: String?
public var note: String?
public var reason: String?
Expand All @@ -25,8 +25,8 @@ public struct Transactions: Codable, Hashable, Identifiable {
public var isActive: Bool

public init(payerId: String, receiverId: String, date: Timestamp, addedBy: String, amount: Double,
currencyCode: String? = "INR", updatedBy: String? = nil, note: String? = nil, reason: String? = nil,
imageUrl: String? = nil, updatedAt: Timestamp? = nil, isActive: Bool = true) {
currencyCode: String? = Currency.defaultCurrency.code, updatedBy: String? = nil, note: String? = nil,
reason: String? = nil, imageUrl: String? = nil, updatedAt: Timestamp? = nil, isActive: Bool = true) {
self.payerId = payerId
self.receiverId = receiverId
self.date = date
Expand Down
2 changes: 1 addition & 1 deletion Data/Data/Repository/CommentRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class CommentRepository {
let payerName = (user.id == transaction.payerId && memberId == transaction.payerId) ?
(user.id == transaction.addedBy ? "You" : "you") :
(memberId == transaction.payerId) ? "you" : members.payer.nameWithLastInitial

let receiverName = (memberId == transaction.receiverId) ? "you" : (memberId == transaction.receiverId) ? "you" : members.receiver.nameWithLastInitial

context = ActivityLogContext(group: group, transaction: transaction, comment: comment,
Expand Down
4 changes: 0 additions & 4 deletions Splito.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
D88721452B9B2C78009DC5BE /* GroupListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D88721442B9B2C78009DC5BE /* GroupListView.swift */; };
D88721472B9B2C97009DC5BE /* GroupListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D88721462B9B2C97009DC5BE /* GroupListViewModel.swift */; };
D888EA722D2BB41F0003284B /* ExpensesSearchRouteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D888EA712D2BB4180003284B /* ExpensesSearchRouteView.swift */; };
D888EA752D3141460003284B /* Currencies.json in Resources */ = {isa = PBXBuildFile; fileRef = D888EA742D31413C0003284B /* Currencies.json */; };
D889F5B92B7A521F008C6A43 /* SplashView.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D889F5B82B7A521F008C6A43 /* SplashView.storyboard */; };
D89684452B722D3400D5F721 /* SplitoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89684442B722D3400D5F721 /* SplitoApp.swift */; };
D89684492B722D3700D5F721 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D89684482B722D3700D5F721 /* Assets.xcassets */; };
Expand Down Expand Up @@ -233,7 +232,6 @@
D88721442B9B2C78009DC5BE /* GroupListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupListView.swift; sourceTree = "<group>"; };
D88721462B9B2C97009DC5BE /* GroupListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupListViewModel.swift; sourceTree = "<group>"; };
D888EA712D2BB4180003284B /* ExpensesSearchRouteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExpensesSearchRouteView.swift; sourceTree = "<group>"; };
D888EA742D31413C0003284B /* Currencies.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Currencies.json; sourceTree = "<group>"; };
D889F5B82B7A521F008C6A43 /* SplashView.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = SplashView.storyboard; sourceTree = "<group>"; };
D89684412B722D3400D5F721 /* Splito.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Splito.app; sourceTree = BUILT_PRODUCTS_DIR; };
D89684442B722D3400D5F721 /* SplitoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitoApp.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -671,7 +669,6 @@
children = (
D89684482B722D3700D5F721 /* Assets.xcassets */,
D889F5B82B7A521F008C6A43 /* SplashView.storyboard */,
D888EA742D31413C0003284B /* Currencies.json */,
);
path = Resource;
sourceTree = "<group>";
Expand Down Expand Up @@ -924,7 +921,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D888EA752D3141460003284B /* Currencies.json in Resources */,
D896844C2B722D3700D5F721 /* Preview Assets.xcassets in Resources */,
D89684492B722D3700D5F721 /* Assets.xcassets in Resources */,
D889F5B92B7A521F008C6A43 /* SplashView.storyboard in Resources */,
Expand Down
7 changes: 2 additions & 5 deletions Splito/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
},
" %@ settled up" : {

},
" ₹ 0.00" : {

},
" commented on" : {
"extractionState" : "manual"
Expand Down Expand Up @@ -550,7 +547,7 @@
"no balance" : {

},
"No country found for \"%@\"!" : {
"No currency found for \"%@\"!" : {

},
"No email address" : {
Expand Down Expand Up @@ -1074,4 +1071,4 @@
}
},
"version" : "1.0"
}
}
Loading

0 comments on commit 2b116f0

Please sign in to comment.