-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from TiagoDvl/feature/63_-_Edit_Quick_Expense
[63] Stable Implementation for Expenses
- Loading branch information
Showing
35 changed files
with
1,354 additions
and
142 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
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
26 changes: 26 additions & 0 deletions
26
sdk/src/main/java/br/com/tick/sdk/database/converters/LatLngConverter.kt
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,26 @@ | ||
package br.com.tick.sdk.database.converters | ||
|
||
import androidx.room.TypeConverter | ||
import com.google.android.gms.maps.model.LatLng | ||
|
||
class LatLngConverter { | ||
|
||
companion object { | ||
const val LAT_LNG_SPLITTER = "|" | ||
} | ||
|
||
@TypeConverter | ||
fun toString(location: LatLng?): String? { | ||
if (location == null) return null | ||
|
||
return "${location.latitude}$LAT_LNG_SPLITTER${location.longitude}" | ||
} | ||
|
||
@TypeConverter | ||
fun fromString(location: String?): LatLng? { | ||
if (location == null) return null | ||
|
||
val locationFromString = location.split(LAT_LNG_SPLITTER) | ||
return LatLng(locationFromString[0].toDouble(), locationFromString[1].toDouble()) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -14,4 +14,4 @@ class LocalDateConverter { | |
fun fromLong(value: Long): LocalDate { | ||
return LocalDate.ofEpochDay(value) | ||
} | ||
} | ||
} |
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
6 changes: 5 additions & 1 deletion
6
sdk/src/main/java/br/com/tick/sdk/domain/CategorizedExpense.kt
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
package br.com.tick.sdk.domain | ||
|
||
import android.net.Uri | ||
import com.google.android.gms.maps.model.LatLng | ||
import java.time.LocalDate | ||
|
||
data class CategorizedExpense( | ||
val expenseId: Int, | ||
val name: String, | ||
val expenseValue: Double, | ||
val date: LocalDate, | ||
val category: ExpenseCategory | ||
val category: ExpenseCategory, | ||
val location: LatLng?, | ||
val picture: Uri? | ||
) |
23 changes: 22 additions & 1 deletion
23
...main/java/br/com/tick/sdk/repositories/categorizedexpense/CategorizedExpenseRepository.kt
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 |
---|---|---|
@@ -1,16 +1,37 @@ | ||
package br.com.tick.sdk.repositories.categorizedexpense | ||
|
||
import android.net.Uri | ||
import br.com.tick.sdk.domain.CategorizedExpense | ||
import com.google.android.gms.maps.model.LatLng | ||
import kotlinx.coroutines.flow.Flow | ||
import java.time.LocalDate | ||
|
||
interface CategorizedExpenseRepository { | ||
|
||
suspend fun addExpense(categoryId: Int, name: String, value: Double, expenseDate: LocalDate) | ||
suspend fun addExpense( | ||
categoryId: Int, | ||
name: String, | ||
value: Double, | ||
expenseDate: LocalDate, | ||
location: LatLng? = null, | ||
photoUri: Uri? = null | ||
) | ||
|
||
suspend fun updateExpense( | ||
expenseId: Int, | ||
categoryId: Int, | ||
name: String, | ||
value: Double, | ||
expenseDate: LocalDate, | ||
location: LatLng? = null, | ||
photoUri: Uri? = null | ||
) | ||
|
||
suspend fun removeExpense(expenseId: Int) | ||
|
||
fun getCategorizedExpenses(): Flow<List<CategorizedExpense>> | ||
|
||
suspend fun getAccountingCycleExpenses(): Flow<List<CategorizedExpense>> | ||
|
||
fun getCategorizedExpense(expenseId: Int): Flow<CategorizedExpense> | ||
} |
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
Oops, something went wrong.