Skip to content

Commit

Permalink
Merge pull request #523 from lyskouski/BF-522
Browse files Browse the repository at this point in the history
[#522] [BF] Charts corruption
  • Loading branch information
lyskouski authored Nov 29, 2024
2 parents c7099f2 + e6fba5e commit db398b9
Show file tree
Hide file tree
Showing 25 changed files with 149 additions and 10 deletions.
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_يمكن الاطلاع على القائمة الكاملة للتحديثات من خلال عنصر التنقل "حول" الموجود على زر "تلميحات"._

### 5.9.2
- تصحيح الرسوم البيانية: فئة سباق الأعمدة، والميزانية السنوية المحدودة

### 5.9.1
- إصلاح نموذج استيراد OFX

### 5.9.0
- إضافة المدفوعات المتكررة
- تحسين استيراد OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_az.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_Yeniləmələrin tam siyahısına "İpucu" düyməsindəki "Haqqında" naviqasiya elementi vasitəsilə baxmaq olar._

### 5.9.2
- Düzəliş qrafikləri: bar irqi kateqoriyası, büdcə ytd

### 5.9.1
- OFX idxalı üçün düzəliş forması

### 5.9.0
- Təkrarlanan ödənişlərin əlavə edilməsi
- OFX idxalının təkmilləşdirilməsi
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_be.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_Поўны спіс абнаўленьняў можна праглядзець у навігацыйным пункце «Аб дадатку» на кнопцы «Падказкі»._

### 5.9.2
- Карэкціроўка графікаў: гістаграма па катэгорыях, бюджэт ytd

### 5.9.1
- Выпраўленьне формы для імпарту OFX

### 5.9.0
- Даданьне перыядычных плацяжоў
- Паляпшэньне імпарту OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_be_EU.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_Poŭny spis abnaŭlieńniaŭ možna prahliadzieć u navihacyjnym punkcie «Ab Dadatku» na knopcy «Padkazki»._

### 5.9.2
- Karekciroŭka hrafikaŭ: katehoryja bar honki, biudžet ytd

### 5.9.1
- Vypraŭlieńnie formy dlia impartu OFX

### 5.9.0
- Dadańnie pieryjadyčnych placiažoŭ
- Paliapšeńnie impartu OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_Die vollständige Liste der Updates kann über den Navigationspunkt "Über" auf der Schaltfläche "Hinweise" eingesehen werden._

### 5.9.2
- Korrektur der Diagramme: Balken Rennen Kategorie, Budget ytd

### 5.9.1
- Korrektur des Formulars für OFX-Import

### 5.9.0
- Hinzufügen von wiederkehrenden Zahlungen
- Verbesserung des OFX-Imports
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_The full list of updates can be viewed via the "About" navigation item on the "Hints" button._

### 5.9.2
- Correcting charts: bar race category, budget ytd

### 5.9.1
- Fixing form for OFX import

### 5.9.0
- Adding Recurring Payments
- Improving OFX import
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_La lista completa de actualizaciones puede consultarse en el menú "Acerca de" del botón "Sugerencias"._

### 5.9.2
- Corrección de gráficos: categoría de carrera de barras, presupuesto ytd

### 5.9.1
- Corrección de formulario para importación OFX

### 5.9.0
- Adición de pagos periódicos
- Mejora de la importación OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_fa.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_لیست کامل به روز رسانی ها را می توان از طریق آیتم پیمایش "درباره" در دکمه "نکات" مشاهده کرد._

### 5.9.2
- تصحیح نمودارها: دسته مسابقه میله ای، بودجه ytd

### 5.9.1
- رفع فرم برای واردات OFX

### 5.9.0
- اضافه کردن پرداخت های مکرر
- بهبود واردات OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_La liste complète des mises à jour peut être consultée via l'élément de navigation "À propos" du bouton "Conseils"._

### 5.9.2
- Correction des graphiques : bar race category, budget ytd

### 5.9.1
- Correction du formulaire pour l'importation OFX

### 5.9.0
- Ajout de paiements récurrents
- Amélioration de l'importation OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_hi.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_अपडेट की पूरी सूची "संकेत" बटन पर "अबाउट" नेविगेशन आइटम के माध्यम से देखी जा सकती है।_

### 5.9.2
- चार्ट को सही करना: बार रेस श्रेणी, बजट वर्ष

### 5.9.1
- OFX आयात के लिए फ़ॉर्म को ठीक करना

### 5.9.0
- आवर्ती भुगतान जोड़ना
- OFX आयात में सुधार
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_it.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
_L'elenco completo degli aggiornamenti può essere consultato tramite la voce di navigazione “Informazioni” del
pulsante “Suggerimenti”._

### 5.9.2
- Correzione dei grafici: categoria di gara a barre, bilancio annuale

### 5.9.1
- Correzione del modulo per l'importazione di OFX

### 5.9.0
- Aggiunta di pagamenti ricorrenti
- Miglioramento dell'importazione OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

更新の完全なリストは、「ヒント」ボタンの「バージョン情報」ナビゲーショ ンアイテムから見ることができます。

### 5.9.2
- チャートの修正:バーレースカテゴリー、予算YTD

### 5.9.1
- OFX インポート用フォームの修正

### 5.9.0
- 定期支払いの追加
- OFXインポートの改善
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

전체 업데이트 목록은 '힌트' 버튼의 '정보' 탐색 항목을 통해 확인할 수 있습니다.

### 5.9.2
- 차트 수정: 바 레이스 카테고리, 예산 ytd

### 5.9.1
- OFX 가져오기 양식 수정

### 5.9.0
- 정기결제 추가
- OFX 가져오기 개선
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_De volledige lijst met updates kan worden bekeken via het navigatie-item “Over” op de knop “Hints”._

### 5.9.2
- Grafieken corrigeren: bar race categorie, budget ytd

### 5.9.1
- Formulier voor OFX import repareren

### 5.9.0
- Terugkerende betalingen toevoegen
- OFX import verbeteren
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Pełną listę aktualizacji można wyświetlić za pomocą elementu nawigacyjnego "O aplikacji" na przycisku "Wskazówki".

### 5.9.2
- Poprawianie wykresów: kategoria wyścigu słupkowego, budżet od początku roku

### 5.9.1
- Poprawki formularza dla importu OFX

### 5.9.0
- Dodawanie płatności cyklicznych
- Ulepszenie importu OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_A lista completa de actualizações pode ser consultada através do item de navegação "Acerca" no botão "Sugestões".

### 5.9.2
- Correção de gráficos: categoria de corrida de barras, orçamento anual

### 5.9.1
- Correção do formulário para importação OFX

### 5.9.0
- Adição de pagamentos recorrentes
- Melhorar a importação OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_pt_BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_A lista completa de atualizações pode ser visualizada no item de navegação "Sobre" no botão "Dicas".

### 5.9.2
- Correção de gráficos: categoria de corrida de barras, orçamento anual

### 5.9.1
- Correção do formulário para importação OFX

### 5.9.0
- Adição de pagamentos recorrentes
- Aprimoramento da importação OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_Güncellemelerin tam listesi “İpuçları” düğmesindeki “Hakkında” gezinti öğesi aracılığıyla görüntülenebilir._

### 5.9.2
- Düzeltme grafikleri: çubuk yarış kategorisi, bütçe ytd

### 5.9.1
- OFX içe aktarma için form düzeltme

### 5.9.0
- Yinelenen Ödemeler Ekleme
- OFX içe aktarımını iyileştirme
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_uk.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_Повний список оновлень можна переглянути за допомогою пункту навігації "Про додаток" на кнопці "Підказки"._

### 5.9.2
- Виправлення діаграм: категорія бар'єрної гонки, бюджет ytd

### 5.9.1
- Виправлення форми для імпорту OFX

### 5.9.0
- Додавання періодичних платежів
- Покращення імпорту OFX
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_uz.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_Yangilanishlarning toʻliq roʻyxatini “Maslahat” tugmasidagi “Haqida” navigatsiya bandi orqali koʻrish mumkin._

### 5.9.2
- Tuzatish jadvallari: bar poygasi toifasi, byudjet ytd

### 5.9.1
- OFX importi uchun tuzatish shakli

### 5.9.0
- Takroriy to'lovlarni qo'shish
- OFX importini yaxshilash
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

更新的完整列表可通过 "提示 "按钮上的 "关于 "导航项查看。

### 5.9.2
- 更正图表:条形竞赛类别、预算年度

### 5.9.1
- 修正导入 OFX 的表格

### 5.9.0
- 添加经常性付款
- 改进 OFX 导入
Expand Down
6 changes: 6 additions & 0 deletions assets/l10n/upgrade_zh_TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

_完整的更新清單可透過「關於」導覽項目中的「提示」按鈕查看。_

### 5.9.2
- 更正圖表:條狀賽馬類別、預算年度

### 5.9.1
- 修正 OFX 匯入的表格

### 5.9.0
- 新增循環付款
- 改善 OFX 匯入
Expand Down
3 changes: 2 additions & 1 deletion lib/charts/bar_race_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class BarRaceChart extends StatelessWidget {
final rnd = Random();
for (int i = 0; i < data.length; i++) {
final key = data[i].dy + rnd.nextDouble();
plot[key] = ChartData([data[i]], color: categories[i].color ?? Colors.grey, helper: categories[i]);
final id = data[i].dx.toInt();
plot[key] = ChartData([data[i]], color: categories[id].color ?? Colors.grey, helper: categories[id]);
}
int idx = plot.values.length;
return plot.values.map((e) {
Expand Down
4 changes: 3 additions & 1 deletion lib/charts/data/data_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

import 'dart:collection';

import 'package:app_finance/_classes/herald/app_start_of_month.dart';
import 'package:app_finance/_classes/structure/bill_app_data.dart';
import 'package:app_finance/_classes/structure/budget_app_data.dart';
import 'package:app_finance/_classes/structure/currency/exchange.dart';
import 'package:app_finance/_classes/structure/interface_app_data.dart';
import 'package:app_finance/_classes/structure/transaction_log_data.dart';
import 'package:app_finance/_ext/date_time_ext.dart';
import 'package:app_finance/charts/interface/ohlc_data.dart';
import 'package:flutter/material.dart';

Expand All @@ -27,7 +29,7 @@ class DataHandler {
}

static List<Offset> getAmountGroupedByMonth(List<InterfaceAppData> scope, {required Exchange exchange}) {
fn(item) => DateTime(item.createdAt.year, item.createdAt.month).millisecondsSinceEpoch.toDouble();
fn(item) => (item.createdAt as DateTime).getStartingDay(AppStartOfMonth.get()).millisecondsSinceEpoch.toDouble();
return _getGroupedAmount(scope, fn, exchange: exchange);
}

Expand Down
20 changes: 12 additions & 8 deletions lib/components/widgets/budget_ytd_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import 'dart:math';

import 'package:app_finance/_classes/herald/app_design.dart';
import 'package:app_finance/_classes/herald/app_locale.dart';
import 'package:app_finance/_classes/herald/app_start_of_month.dart';
import 'package:app_finance/_classes/storage/app_data.dart';
import 'package:app_finance/_classes/storage/history_data.dart';
import 'package:app_finance/_classes/structure/bill_app_data.dart';
import 'package:app_finance/_classes/structure/budget_app_data.dart';
import 'package:app_finance/_classes/structure/currency/exchange.dart';
import 'package:app_finance/_configs/theme_helper.dart';
import 'package:app_finance/_ext/build_context_ext.dart';
import 'package:app_finance/_ext/date_time_ext.dart';
import 'package:app_finance/charts/column_chart.dart';
import 'package:app_finance/charts/data/data_handler.dart';
import 'package:app_finance/charts/interface/chart_data.dart';
Expand All @@ -24,27 +26,29 @@ class BudgetYtdChart extends StatelessWidget {
const BudgetYtdChart({super.key});

List<BudgetAppData> getBudgetHistory(AppData store) {
final current = DateTime(DateTime.now().year, DateTime.now().month);
final endLastYear = DateTime(current.year - 1, 12, 31);
final day = AppStartOfMonth.get();
final current = DateTime.now().getStartingDay(day);
final endLastYear = DateTime(current.year, current.month - 12, day);
final budgets = store.getList(AppDataType.budgets).cast<BudgetAppData>();
final exchange = Exchange(store: store);
final budgetsAmount =
budgets.fold(0.0, (v, e) => v + exchange.reform(e.amountLimit, e.currency, exchange.getDefaultCurrency()));
final budgetHistory = HistoryData.getMultiLog(budgets).expand((e) => e!).toList();
final budgetList = [];
for (DateTime date = DateTime(current.year, current.month + 1);
for (DateTime date = DateTime(current.year, current.month + 1, day);
date.isAfter(endLastYear);
date = DateTime(date.year, date.month - 1)) {
final delta =
budgetHistory.where((e) => e.timestamp.isAfter(date)).fold(0.0, (v, e) => v - e.changedTo + e.changedFrom);
date = DateTime(date.year, date.month - 1, day)) {
final delta = budgetHistory.where((e) => e.timestamp.isAfter(date)).fold(
0.0, (v, e) => v - exchange.reform(e.changedTo - e.changedFrom, e.currency, exchange.getDefaultCurrency()));
budgetList.add(BudgetAppData(title: '', createdAt: date, amountLimit: budgetsAmount + delta));
}
return budgetList.cast();
}

List<ChartData> getData(AppData store) {
final currentYear = DateTime(DateTime.now().year);
final prevYear = DateTime(currentYear.year - 1);
final day = AppStartOfMonth.get();
final currentYear = DateTime(DateTime.now().year).getStartingDay(day);
final prevYear = DateTime(currentYear.year - 1).getStartingDay(day);
final bills = store.getStream<BillAppData>(AppDataType.bills, filter: (e) => e.createdAt.isBefore(prevYear));
final exchange = Exchange(store: store);
return [
Expand Down

0 comments on commit db398b9

Please sign in to comment.