LCOV - code coverage report
Current view: top level - _classes/structure - bill_app_data.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 11 40 27.5 %
Date: 2024-10-04 11:08:31 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:flutter/material.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             : 
      17           1 :   BillAppData({
      18             :     required this.account,
      19             :     required this.category,
      20             :     super.uuid,
      21             :     super.title = '',
      22             :     super.details,
      23             :     super.currency,
      24             :     super.updatedAt,
      25             :     super.createdAt,
      26             :     super.createdAtFormatted,
      27             :     super.hidden,
      28             :   });
      29             : 
      30           0 :   @override
      31             :   String getClassName() => 'BillAppData';
      32             : 
      33           0 :   @override
      34             :   AppDataType getType() => AppDataType.bills;
      35             : 
      36           1 :   @override
      37             :   BillAppData clone() {
      38           1 :     return BillAppData(
      39           1 :       uuid: super.uuid,
      40           1 :       account: account,
      41           1 :       category: category,
      42           1 :       title: super.title,
      43           1 :       details: super.details,
      44           1 :       currency: super.currency,
      45           1 :       createdAt: super.createdAt,
      46           1 :       hidden: super.hidden,
      47             :     );
      48             :   }
      49             : 
      50           0 :   factory BillAppData.fromJson(Map<String, dynamic> json) {
      51           0 :     return BillAppData(
      52           0 :       uuid: json['uuid'],
      53           0 :       account: json['account'],
      54           0 :       category: json['category'],
      55           0 :       title: json['title'],
      56           0 :       details: 0.0 + json['details'],
      57           0 :       currency: CurrencyProvider.find(json['currency']),
      58           0 :       updatedAt: DateTime.parse(json['updatedAt']),
      59           0 :       createdAt: DateTime.parse(json['createdAt']),
      60           0 :       hidden: json['hidden'],
      61             :     );
      62             :   }
      63             : 
      64           0 :   @override
      65           0 :   Map<String, dynamic> toJson() => {
      66           0 :         ...super.toJson(),
      67           0 :         'account': account,
      68           0 :         'category': category,
      69             :       };
      70             : 
      71           0 :   String get detailsFormatted => (super.details as double).toCurrency(currency: currency, withPattern: false);
      72             : 
      73           0 :   @override
      74             :   String get description {
      75           0 :     AccountAppData? type = getState().getByUuid(account);
      76           0 :     return super.createdAt.monthDay() + (type != null ? ' (${type.title})' : '');
      77             :   }
      78             : 
      79           0 :   String get accountNamed => getState().getByUuid(account)?.title ?? '?';
      80             : 
      81           0 :   @override
      82             :   MaterialColor? get color {
      83           0 :     BudgetAppData? budget = getState().getByUuid(category);
      84           0 :     return budget?.color;
      85             :   }
      86             : 
      87           0 :   @override
      88             :   IconData? get icon {
      89           0 :     BudgetAppData? budget = getState().getByUuid(category);
      90           0 :     return budget?.icon;
      91             :   }
      92             : }

Generated by: LCOV version 1.14