diff --git a/lib/app/settings/import_csv.dart b/lib/app/settings/import_csv.dart index d86727ee..2b81aa04 100644 --- a/lib/app/settings/import_csv.dart +++ b/lib/app/settings/import_csv.dart @@ -293,8 +293,6 @@ class _ImportCSVPageState extends State { Widget build(BuildContext context) { final t = Translations.of(context); - print("csv data: $csvData"); - return Scaffold( appBar: AppBar(title: Text(t.backup.import.manual_import.title)), body: Stepper( diff --git a/lib/app/stats/widgets/finance_health_details.dart b/lib/app/stats/widgets/finance_health_details.dart index b5594bd6..c415d90f 100644 --- a/lib/app/stats/widgets/finance_health_details.dart +++ b/lib/app/stats/widgets/finance_health_details.dart @@ -113,9 +113,8 @@ class _FinanceHealthDetailsState extends State { title: t.financial_health.months_without_income.title, subtitle: t.financial_health.months_without_income.subtitle, - text: '${financeHealthData.monthsWithoutIncome == null ? t.financial_health.months_without_income.insufficient_data : t.financial_health.months_without_income.text( - n: financeHealthData.monthsWithoutIncome!.round(), - )}\n\n${t.financial_health.months_without_income.suggestion}', + text: + '${financeHealthData.getMonthsWithoutIncomeResume(context)}\n\n${t.financial_health.months_without_income.suggestion}', index: 0), buildExpansionPanel( attrScore: financeHealthData.savingPercentageScore, diff --git a/lib/core/services/finance_health_service.dart b/lib/core/services/finance_health_service.dart index 41f0e61c..b5d17526 100644 --- a/lib/core/services/finance_health_service.dart +++ b/lib/core/services/finance_health_service.dart @@ -162,6 +162,29 @@ class FinanceHealthData { return t.financial_health.review.very_good(context: genderContext); } } + + String getMonthsWithoutIncomeResume(BuildContext context) { + final t = Translations.of(context); + + if (monthsWithoutIncome == null) { + return t.financial_health.months_without_income.insufficient_data; + } + + if (monthsWithoutIncome == 0) { + return t.financial_health.months_without_income.text_zero; + } + + if (monthsWithoutIncome == 1) { + return t.financial_health.months_without_income.text_one; + } + + if (monthsWithoutIncome! > 999) { + return t.financial_health.months_without_income.text_infinite; + } + + return t.financial_health.months_without_income + .text_other(n: monthsWithoutIncome!.toStringAsFixed(0)); + } } class FinanceHealthService { @@ -193,7 +216,7 @@ class FinanceHealthService { ) .map((event) => max(event, 0)), (numberOfTransactions, balance, expense, initialMoney) { - if (numberOfTransactions < 4) { + if (numberOfTransactions < 4 || expense == 0) { return null; } diff --git a/lib/i18n/strings_en.json b/lib/i18n/strings_en.json index d65306c3..31f32338 100644 --- a/lib/i18n/strings_en.json +++ b/lib/i18n/strings_en.json @@ -188,11 +188,10 @@ "monthsWithoutIncome": { "title": "Survival rate", "subtitle": "Given your balance, amount of time you could go without income", - "text": { - "zero": "You couldn't survive a month without income at this rate of expenses!", - "one": "You could barely survive approximately a month without income at this rate of expenses!", - "other": "You could survive approximately {{ n }} months without income at this rate of spending." - }, + "text.zero": "You couldn't survive a month without income at this rate of expenses!", + "text.one": "You could barely survive approximately a month without income at this rate of expenses!", + "text.other": "You could survive approximately {{ n }} months without income at this rate of spending.", + "text.infinite": "You could survive approximately all your life without income at this rate of spending.", "suggestion": "Remember that it is advisable to always keep this ratio above 5 months at least. If you see that you do not have a sufficient savings cushion, reduce unnecessary expenses.", "insufficient_data": "It looks like we don't have enough expenses to calculate how many months you could survive without income. Enter a few transactions and come back here to check your financial health" }, diff --git a/lib/i18n/strings_es.json b/lib/i18n/strings_es.json index fb49e25f..65e7ab49 100644 --- a/lib/i18n/strings_es.json +++ b/lib/i18n/strings_es.json @@ -192,11 +192,10 @@ "monthsWithoutIncome": { "title": "Ratio de supervivencia", "subtitle": "Dado tu saldo, cantidad de tiempo que podrías pasar sin ingresos", - "text": { - "zero": "No podrías sobrevivir ni un mes sin ingresos con este ritmo de gastos!", - "one": "Apenas podrías sobrevivir aproximadatemente un mes sin ingresos con este ritmo de gastos!", - "other": "Podrías sobrevivir aproximadamente {{ n }} meses sin ingresos manteniendo este ritmo de gastos." - }, + "text.zero": "¡No podrías sobrevivir un mes sin ingresos con este ritmo de gastos!", + "text.one": "¡Apenas podrías sobrevivir aproximadamente un mes sin ingresos con este ritmo de gastos!", + "text.other": "Podrías sobrevivir aproximadamente {{ n }} meses sin ingresos a este ritmo de gasto.", + "text.infinite": "Podrías sobrevivir aproximadamente casi toda tu vida sin ingresos a este ritmo de gasto.", "suggestion": "Recuerda que es recomendable mantener este ratio siempre por encima de 5 meses como mínimo. Si ves que no tienes un colchon de ahorro suficiente, reduce los gastos no necesarios.", "insufficient_data": "Parece que no tenemos gastos suficientes para calcular cuantos meses podrías sobrevivir sin ingresos. Introduce unas pocas transacciones y regresa aquí para consultar tu salud financiera" }, diff --git a/lib/i18n/translations.g.dart b/lib/i18n/translations.g.dart index 8d66c3e4..99525fe5 100644 --- a/lib/i18n/translations.g.dart +++ b/lib/i18n/translations.g.dart @@ -4,9 +4,9 @@ /// To regenerate, run: `dart run slang` /// /// Locales: 2 -/// Strings: 1031 (515 per locale) +/// Strings: 1033 (516 per locale) /// -/// Built on 2024-03-19 at 22:39 UTC +/// Built on 2024-04-30 at 17:28 UTC // coverage:ignore-file // ignore_for_file: type=lint @@ -710,11 +710,10 @@ class _TranslationsFinancialHealthMonthsWithoutIncomeEn { // Translations String get title => 'Survival rate'; String get subtitle => 'Given your balance, amount of time you could go without income'; - String text({required num n}) => (_root.$meta.cardinalResolver ?? PluralResolvers.cardinal('en'))(n, - zero: 'You couldn\'t survive a month without income at this rate of expenses!', - one: 'You could barely survive approximately a month without income at this rate of expenses!', - other: 'You could survive approximately ${n} months without income at this rate of spending.', - ); + String get text_zero => 'You couldn\'t survive a month without income at this rate of expenses!'; + String get text_one => 'You could barely survive approximately a month without income at this rate of expenses!'; + String text_other({required Object n}) => 'You could survive approximately ${n} months without income at this rate of spending.'; + String get text_infinite => 'You could survive approximately all your life without income at this rate of spending.'; String get suggestion => 'Remember that it is advisable to always keep this ratio above 5 months at least. If you see that you do not have a sufficient savings cushion, reduce unnecessary expenses.'; String get insufficient_data => 'It looks like we don\'t have enough expenses to calculate how many months you could survive without income. Enter a few transactions and come back here to check your financial health'; } @@ -1945,11 +1944,10 @@ class _TranslationsFinancialHealthMonthsWithoutIncomeEs implements _Translations // Translations @override String get title => 'Ratio de supervivencia'; @override String get subtitle => 'Dado tu saldo, cantidad de tiempo que podrías pasar sin ingresos'; - @override String text({required num n}) => (_root.$meta.cardinalResolver ?? PluralResolvers.cardinal('es'))(n, - zero: 'No podrías sobrevivir ni un mes sin ingresos con este ritmo de gastos!', - one: 'Apenas podrías sobrevivir aproximadatemente un mes sin ingresos con este ritmo de gastos!', - other: 'Podrías sobrevivir aproximadamente ${n} meses sin ingresos manteniendo este ritmo de gastos.', - ); + @override String get text_zero => '¡No podrías sobrevivir un mes sin ingresos con este ritmo de gastos!'; + @override String get text_one => '¡Apenas podrías sobrevivir aproximadamente un mes sin ingresos con este ritmo de gastos!'; + @override String text_other({required Object n}) => 'Podrías sobrevivir aproximadamente ${n} meses sin ingresos a este ritmo de gasto.'; + @override String get text_infinite => 'Podrías sobrevivir aproximadamente casi toda tu vida sin ingresos a este ritmo de gasto.'; @override String get suggestion => 'Recuerda que es recomendable mantener este ratio siempre por encima de 5 meses como mínimo. Si ves que no tienes un colchon de ahorro suficiente, reduce los gastos no necesarios.'; @override String get insufficient_data => 'Parece que no tenemos gastos suficientes para calcular cuantos meses podrías sobrevivir sin ingresos. Introduce unas pocas transacciones y regresa aquí para consultar tu salud financiera'; } @@ -2806,11 +2804,10 @@ extension on Translations { case 'financial_health.review.descr.very_bad': return 'Hmm, your financial health is far below what it should be. Explore the rest of the charts to learn more about your finances'; case 'financial_health.months_without_income.title': return 'Survival rate'; case 'financial_health.months_without_income.subtitle': return 'Given your balance, amount of time you could go without income'; - case 'financial_health.months_without_income.text': return ({required num n}) => (_root.$meta.cardinalResolver ?? PluralResolvers.cardinal('en'))(n, - zero: 'You couldn\'t survive a month without income at this rate of expenses!', - one: 'You could barely survive approximately a month without income at this rate of expenses!', - other: 'You could survive approximately ${n} months without income at this rate of spending.', - ); + case 'financial_health.months_without_income.text_zero': return 'You couldn\'t survive a month without income at this rate of expenses!'; + case 'financial_health.months_without_income.text_one': return 'You could barely survive approximately a month without income at this rate of expenses!'; + case 'financial_health.months_without_income.text_other': return ({required Object n}) => 'You could survive approximately ${n} months without income at this rate of spending.'; + case 'financial_health.months_without_income.text_infinite': return 'You could survive approximately all your life without income at this rate of spending.'; case 'financial_health.months_without_income.suggestion': return 'Remember that it is advisable to always keep this ratio above 5 months at least. If you see that you do not have a sufficient savings cushion, reduce unnecessary expenses.'; case 'financial_health.months_without_income.insufficient_data': return 'It looks like we don\'t have enough expenses to calculate how many months you could survive without income. Enter a few transactions and come back here to check your financial health'; case 'financial_health.savings_percentage.title': return 'Savings percentage'; @@ -3400,11 +3397,10 @@ extension on _TranslationsEs { case 'financial_health.review.descr.very_bad': return 'Mmm, tu salud financera esta muy por debajo de lo que debería. Trata de ver donde esta el problema gracias a los distintos gráficos y estadisticas que te proporcionamos'; case 'financial_health.months_without_income.title': return 'Ratio de supervivencia'; case 'financial_health.months_without_income.subtitle': return 'Dado tu saldo, cantidad de tiempo que podrías pasar sin ingresos'; - case 'financial_health.months_without_income.text': return ({required num n}) => (_root.$meta.cardinalResolver ?? PluralResolvers.cardinal('es'))(n, - zero: 'No podrías sobrevivir ni un mes sin ingresos con este ritmo de gastos!', - one: 'Apenas podrías sobrevivir aproximadatemente un mes sin ingresos con este ritmo de gastos!', - other: 'Podrías sobrevivir aproximadamente ${n} meses sin ingresos manteniendo este ritmo de gastos.', - ); + case 'financial_health.months_without_income.text_zero': return '¡No podrías sobrevivir un mes sin ingresos con este ritmo de gastos!'; + case 'financial_health.months_without_income.text_one': return '¡Apenas podrías sobrevivir aproximadamente un mes sin ingresos con este ritmo de gastos!'; + case 'financial_health.months_without_income.text_other': return ({required Object n}) => 'Podrías sobrevivir aproximadamente ${n} meses sin ingresos a este ritmo de gasto.'; + case 'financial_health.months_without_income.text_infinite': return 'Podrías sobrevivir aproximadamente casi toda tu vida sin ingresos a este ritmo de gasto.'; case 'financial_health.months_without_income.suggestion': return 'Recuerda que es recomendable mantener este ratio siempre por encima de 5 meses como mínimo. Si ves que no tienes un colchon de ahorro suficiente, reduce los gastos no necesarios.'; case 'financial_health.months_without_income.insufficient_data': return 'Parece que no tenemos gastos suficientes para calcular cuantos meses podrías sobrevivir sin ingresos. Introduce unas pocas transacciones y regresa aquí para consultar tu salud financiera'; case 'financial_health.savings_percentage.title': return 'Porcentaje de ahorro';