-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/deleted_changes #175
Closed
Closed
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3194021
add analytics ui
Elen-B cfab2ee
add item_analytics_plan layout for recyclerview
Elen-B f2b76b1
add models for Analytics, stateFlow for catching user actions
Elen-B 235d6e2
set click listeners for buttons due to AnalyticsUiState at AnalyticsF…
Elen-B e272c5f
add rendering total amount at AnalyticFragment, percents by category …
Elen-B 36e9997
add rendering progress at AnalyticsFragment
Elen-B 67f3e9c
tune recyclerView at AnalyticFragment
Elen-B a7bd51a
fill subcategory summaries in recyclerView as AnalyticFragment
Elen-B 44a9468
add ViewHolder for plan category at AnalyticsFragment
Elen-B 35cb55e
fix bug with showing previous image using ViewHolder
Elen-B 86c7737
refactor fillSubcategories() to use binding
Elen-B 2a1d53d
refactor CategorySummaryDiffUtilCallback - compare items by id in fun…
Elen-B 2c897d5
Merge branch 'dev' of github.com:CashAdv/CashADV into feature/105-mai…
Elen-B b5afc92
refactor getCategoryCurrencyTextColor() to an extension function for …
Elen-B 1bb1d8b
add singleton MoneyFormatter instead of extension BigDecimal.formatAm…
Elen-B ccad1e0
delete redundant file
Elen-B File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
245 changes: 245 additions & 0 deletions
245
app/src/main/java/app/cashadvisor/analytics/presentation/MockData.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,245 @@ | ||
package app.cashadvisor.analytics.presentation | ||
|
||
import app.cashadvisor.analytics.presentation.model.Account | ||
import app.cashadvisor.analytics.presentation.model.AnalyticType | ||
import app.cashadvisor.analytics.presentation.model.CategorySummary | ||
import app.cashadvisor.analytics.presentation.model.SubcategorySummary | ||
import app.cashadvisor.analytics.presentation.model.User | ||
import java.math.BigDecimal | ||
import java.util.Date | ||
|
||
object MockData { | ||
fun getCategorySummaryList(beginDate: Date, endDate: Date) = categorySummaryList //emptyList<CategorySummary>()// | ||
} | ||
|
||
|
||
val categorySummaryList :List<CategorySummary> = listOf ( | ||
// Доходы факт | ||
CategorySummary( | ||
id = 3, | ||
name = "Зарплата", | ||
analyticType = AnalyticType.INCOME, | ||
planned = false, | ||
amount = BigDecimal.valueOf(75000.00), | ||
subcategoryList = listOf( | ||
SubcategorySummary( | ||
name = "Перевод", | ||
amount = BigDecimal.valueOf(50000.00) | ||
), | ||
SubcategorySummary( | ||
name = "Отпускные", | ||
amount = BigDecimal.valueOf(20000.00) | ||
), | ||
SubcategorySummary( | ||
name = "Премия", | ||
amount = BigDecimal.valueOf(5000.00) | ||
), | ||
) | ||
), | ||
CategorySummary( | ||
id = 4, | ||
name = "Наставничество", | ||
analyticType = AnalyticType.INCOME, | ||
planned = false, | ||
amount = BigDecimal.valueOf(20000.00), | ||
subcategoryList = listOf( | ||
SubcategorySummary( | ||
name = "Перевод", | ||
amount = BigDecimal.valueOf(20000.00) | ||
), | ||
) | ||
), | ||
|
||
// Расходы факт | ||
CategorySummary( | ||
id = 22, | ||
name = "Еда", | ||
analyticType = AnalyticType.EXPENSE, | ||
planned = false, | ||
amount = BigDecimal.valueOf(7563.00), | ||
subcategoryList = listOf( | ||
SubcategorySummary( | ||
name = "Продукты", | ||
amount = BigDecimal.valueOf(7245.00) | ||
), | ||
SubcategorySummary( | ||
name = "Ресторан", | ||
amount = BigDecimal.valueOf(318.00) | ||
), | ||
) | ||
), | ||
CategorySummary( | ||
id = 18, | ||
name = "Развлечения", | ||
analyticType = AnalyticType.EXPENSE, | ||
planned = false, | ||
amount = BigDecimal.valueOf(533.00), | ||
subcategoryList = listOf( | ||
SubcategorySummary( | ||
name = "Телеграм премиум", | ||
amount = BigDecimal.valueOf(299.00) | ||
), | ||
SubcategorySummary( | ||
name = "Яндекс плюс", | ||
amount = BigDecimal.valueOf(199.00) | ||
), | ||
SubcategorySummary( | ||
name = "Whouse", | ||
amount = BigDecimal.valueOf(35.00) | ||
), | ||
) | ||
), | ||
// Фонд благосостояния факт | ||
CategorySummary( | ||
id = 25, | ||
name = "Инвестиции", | ||
analyticType = AnalyticType.SAVING, | ||
planned = false, | ||
amount = BigDecimal.valueOf(15000.00), | ||
subcategoryList = listOf( | ||
SubcategorySummary( | ||
name = "Акции", | ||
amount = BigDecimal.valueOf(10000.00) | ||
), | ||
SubcategorySummary( | ||
name = "Облигации", | ||
amount = BigDecimal.valueOf(5000.00) | ||
), | ||
SubcategorySummary( | ||
name = "Даньги аыврало ыварыл фыдалфыжал фываолдыва", | ||
amount = BigDecimal.valueOf(0.00) | ||
), | ||
) | ||
), | ||
CategorySummary( | ||
id = 2, | ||
name = "Накопления", | ||
analyticType = AnalyticType.SAVING, | ||
planned = false, | ||
amount = BigDecimal.valueOf(30000.00), | ||
subcategoryList = listOf( | ||
SubcategorySummary( | ||
name = "фин подушка", | ||
amount = BigDecimal.valueOf(25000.00) | ||
), | ||
SubcategorySummary( | ||
name = "Амортизация", | ||
amount = BigDecimal.valueOf(5000.00) | ||
), | ||
) // List<SubcategorySummary> | ||
), | ||
CategorySummary( | ||
id = 24, | ||
name = "Валюта", | ||
analyticType = AnalyticType.SAVING, | ||
planned = false, | ||
amount = BigDecimal.valueOf(0.00), | ||
subcategoryList = listOf( | ||
SubcategorySummary( | ||
name = "USD", | ||
amount = BigDecimal.valueOf(0.00) | ||
), | ||
) // List<SubcategorySummary> | ||
), | ||
// Доходы план | ||
CategorySummary( | ||
id = 3, | ||
name = "Зарплата", | ||
analyticType = AnalyticType.INCOME, | ||
planned = true, | ||
amount = BigDecimal.valueOf(75000.00), | ||
completePercent = 100.0, | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
CategorySummary( | ||
id = 4, | ||
name = "Наставничество", | ||
analyticType = AnalyticType.INCOME, | ||
planned = true, | ||
amount = BigDecimal.valueOf(25000.00), | ||
completePercent = 80.0, | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
|
||
// Расходы план | ||
CategorySummary( | ||
id = 22, | ||
name = "Еда", | ||
analyticType = AnalyticType.EXPENSE, | ||
planned = true, | ||
amount = BigDecimal.valueOf(20000.00), | ||
completePercent = 80.0, | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
CategorySummary( | ||
id = 17, | ||
name = "Техника", | ||
analyticType = AnalyticType.EXPENSE, | ||
planned = true, | ||
amount = BigDecimal.valueOf(10000.00), | ||
completePercent = 00.0, | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
CategorySummary( | ||
id = 18, | ||
name = "Развлечения", | ||
analyticType = AnalyticType.EXPENSE, | ||
planned = true, | ||
amount = BigDecimal.valueOf(10000.00), | ||
completePercent = 10.0, | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
CategorySummary( | ||
id = 12, | ||
name = "Транспорт", | ||
analyticType = AnalyticType.EXPENSE, | ||
planned = true, | ||
amount = BigDecimal.valueOf(5000.00), | ||
completePercent = 0.0, | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
CategorySummary( | ||
id = 19, | ||
name = "Прочее", | ||
analyticType = AnalyticType.EXPENSE, | ||
planned = true, | ||
amount = BigDecimal.valueOf(5000.00), | ||
completePercent = 0.0, | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
// Фонд благосостояния план | ||
/* CategorySummary( | ||
id = 25, | ||
name = "Инвестиции", | ||
analyticType = AnalyticType.SAVING, | ||
planned = true, | ||
amount = BigDecimal.valueOf(15000.00), | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
CategorySummary( | ||
id = 2, | ||
name = "Накопления", | ||
analyticType = AnalyticType.SAVING, | ||
planned = true, | ||
amount = BigDecimal.valueOf(30000.00), | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
), | ||
CategorySummary( | ||
id = 24, | ||
name = "Валюта", | ||
analyticType = AnalyticType.SAVING, | ||
planned = true, | ||
amount = BigDecimal.valueOf(0.00), | ||
subcategoryList = listOf() // List<SubcategorySummary> | ||
),*/ | ||
) | ||
|
||
val account = Account( | ||
amount = BigDecimal.valueOf(8600000.00) | ||
) | ||
|
||
val user = User( | ||
id = 100, | ||
name = "Андрей", | ||
lastName = "Иванов" | ||
) |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/app/cashadvisor/analytics/presentation/Utils.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,28 @@ | ||
package app.cashadvisor.analytics.presentation | ||
|
||
import java.math.BigDecimal | ||
import java.text.NumberFormat | ||
import java.util.Calendar | ||
import java.util.Date | ||
|
||
fun Date.getLastDayOfMonth() : Date { | ||
avanisimov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val current = Calendar.getInstance() | ||
val lastDay = Calendar.getInstance() | ||
lastDay.set(current.get(Calendar.YEAR), current.get(Calendar.MONTH), | ||
current.getActualMaximum(Calendar.DATE)) | ||
return lastDay.time | ||
} | ||
|
||
fun Date.getFirstDayOfMonth() : Date { | ||
val current = Calendar.getInstance() | ||
val firstDay = Calendar.getInstance() | ||
firstDay.set(current.get(Calendar.YEAR), current.get(Calendar.MONTH), 1) | ||
return firstDay.time | ||
} | ||
|
||
fun BigDecimal.formatAmount() : String { | ||
avanisimov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val formatter = NumberFormat.getNumberInstance() | ||
formatter.minimumFractionDigits = 2 | ||
formatter.maximumFractionDigits = 2 | ||
return formatter.format(this) | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/app/cashadvisor/analytics/presentation/model/Account.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,8 @@ | ||
package app.cashadvisor.analytics.presentation.model | ||
|
||
import java.math.BigDecimal | ||
|
||
data class Account( | ||
val amount: BigDecimal, | ||
val currency: String? = null, | ||
) |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/app/cashadvisor/analytics/presentation/model/AnalyticType.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,17 @@ | ||
package app.cashadvisor.analytics.presentation.model | ||
|
||
enum class AnalyticType(val value: Int) { | ||
INCOME(0), | ||
EXPENSE(1), | ||
SAVING(2); | ||
|
||
companion object { | ||
fun of(value: Int): AnalyticType { | ||
return when (value) { | ||
0 -> INCOME | ||
1 -> EXPENSE | ||
else -> SAVING | ||
} | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/app/cashadvisor/analytics/presentation/model/CategorySummary.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,13 @@ | ||
package app.cashadvisor.analytics.presentation.model | ||
|
||
import java.math.BigDecimal | ||
|
||
data class CategorySummary( | ||
val id: Long, | ||
val name: String, | ||
val analyticType: AnalyticType, | ||
val planned: Boolean, | ||
val amount: BigDecimal, | ||
val completePercent: Double? = null, | ||
val subcategoryList: List<SubcategorySummary>?, | ||
) |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/app/cashadvisor/analytics/presentation/model/FilterParams.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,23 @@ | ||
package app.cashadvisor.analytics.presentation.model | ||
|
||
import app.cashadvisor.analytics.presentation.getFirstDayOfMonth | ||
import app.cashadvisor.analytics.presentation.getLastDayOfMonth | ||
import java.util.Date | ||
|
||
data class FilterParams( | ||
val beginDate: Date, | ||
val endDate: Date, | ||
val analyticType: AnalyticType, | ||
val planned: Boolean | ||
) { | ||
|
||
companion object { | ||
fun getDefault(): FilterParams { | ||
return FilterParams( | ||
beginDate = Date().getFirstDayOfMonth(), | ||
endDate = Date().getLastDayOfMonth(), | ||
analyticType = AnalyticType.INCOME, | ||
planned = false) | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/app/cashadvisor/analytics/presentation/model/SubcategorySummary.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,8 @@ | ||
package app.cashadvisor.analytics.presentation.model | ||
|
||
import java.math.BigDecimal | ||
|
||
data class SubcategorySummary( | ||
val name: String, | ||
val amount: BigDecimal, | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/app/cashadvisor/analytics/presentation/model/User.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,8 @@ | ||
package app.cashadvisor.analytics.presentation.model | ||
|
||
data class User( | ||
val id: Long, | ||
val name: String, | ||
val lastName: String, | ||
val avatarUrl: String? = null, | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это ни на что не влияет?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
надо делать нормальные моки.