LCOV - code coverage report
Current view: top level - lib/_classes/structure - bill_app_data.dart Coverage Total Hit
Test: lcov.info Lines: 70.0 % 50 35
Test Date: 2026-11-14 15:08:11 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2023 The terCAD team. All rights reserved.
       2              : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3              : 
       4              : import 'package:app_finance/_classes/structure/abstract_app_data.dart';
       5              : import 'package:app_finance/_classes/structure/account_app_data.dart';
       6              : import 'package:app_finance/_classes/structure/budget_app_data.dart';
       7              : import 'package:app_finance/_classes/storage/app_data.dart';
       8              : import 'package:app_finance/_ext/date_time_ext.dart';
       9              : import 'package:app_finance/_mixins/storage_mixin.dart';
      10              : import 'package:material_ui/material_ui.dart';
      11              : import 'package:flutter_currency_picker/flutter_currency_picker.dart';
      12              : 
      13              : class BillAppData extends AbstractAppData with StorageMixin {
      14              :   String account;
      15              :   String category;
      16              :   double exchangeAccount;
      17              :   double exchangeCategory;
      18              :   bool hasChild;
      19              :   String? childOf;
      20              : 
      21            1 :   BillAppData({
      22              :     required this.account,
      23              :     required this.category,
      24              :     super.uuid,
      25              :     super.title = '',
      26              :     super.details,
      27              :     super.currency,
      28              :     super.updatedAt,
      29              :     super.createdAt,
      30              :     super.createdAtFormatted,
      31              :     super.hidden,
      32              :     super.payment,
      33              :     this.exchangeAccount = 1.0,
      34              :     this.exchangeCategory = 1.0,
      35              :     this.hasChild = false,
      36              :     this.childOf,
      37              :   });
      38              : 
      39            1 :   @override
      40              :   String getClassName() => 'BillAppData';
      41              : 
      42            1 :   @override
      43              :   AppDataType getType() => AppDataType.bills;
      44              : 
      45            1 :   @override
      46              :   BillAppData clone() {
      47            1 :     return BillAppData(
      48            1 :       uuid: super.uuid,
      49            1 :       account: account,
      50            1 :       category: category,
      51            1 :       title: super.title,
      52            1 :       details: super.details,
      53            1 :       currency: super.currency,
      54            1 :       createdAt: super.createdAt,
      55            1 :       hidden: super.hidden,
      56            1 :       payment: super.payment,
      57            1 :       exchangeAccount: exchangeAccount,
      58            1 :       exchangeCategory: exchangeCategory,
      59            1 :       hasChild: hasChild,
      60            1 :       childOf: childOf,
      61              :     );
      62              :   }
      63              : 
      64            0 :   factory BillAppData.fromJson(Map<String, dynamic> json) {
      65            0 :     return BillAppData(
      66            0 :       uuid: json['uuid'],
      67            0 :       account: json['account'],
      68            0 :       category: json['category'],
      69            0 :       title: json['title'],
      70            0 :       details: 0.0 + json['details'],
      71            0 :       currency: CurrencyProvider.find(json['currency']),
      72            0 :       updatedAt: DateTime.parse(json['updatedAt']),
      73            0 :       createdAt: DateTime.parse(json['createdAt']),
      74            0 :       hidden: json['hidden'],
      75            0 :       payment: json['payment'],
      76            0 :       hasChild: json['hasChild'] ?? false,
      77            0 :       childOf: json['childOf'],
      78              :     );
      79              :   }
      80              : 
      81            1 :   @override
      82            1 :   Map<String, dynamic> toJson() => {
      83            1 :         ...super.toJson(),
      84            2 :         'account': account,
      85            2 :         'category': category,
      86            2 :         'hasChild': hasChild,
      87            2 :         'childOf': childOf,
      88              :       };
      89              : 
      90            4 :   String get detailsFormatted => (super.details as double).toCurrency(currency: currency, withPattern: false);
      91              : 
      92            1 :   @override
      93              :   String get description {
      94            3 :     AccountAppData? type = getState().getByUuid(account);
      95            5 :     return super.createdAt.monthDay() + (type != null ? ' (${type.title})' : '');
      96              :   }
      97              : 
      98            0 :   String get accountNamed => getState().getByUuid(account)?.title ?? '?';
      99              : 
     100            1 :   @override
     101              :   MaterialColor? get color {
     102            3 :     BudgetAppData? budget = getState().getByUuid(category);
     103            1 :     return budget?.color;
     104              :   }
     105              : 
     106            1 :   @override
     107              :   IconData? get icon {
     108            3 :     BudgetAppData? budget = getState().getByUuid(category);
     109            1 :     return budget?.icon;
     110              :   }
     111              : }
        

Generated by: LCOV version 2.0-1