LCOV - code coverage report
Current view: top level - _classes/structure - currency_app_data.dart Coverage Total Hit
Test: lcov.info Lines: 6.2 % 32 2
Test Date: 2026-11-14 15:03:01 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/storage/app_data.dart';
       6              : import 'package:app_finance/_ext/date_time_ext.dart';
       7              : import 'package:flutter_currency_picker/flutter_currency_picker.dart';
       8              : 
       9              : class CurrencyAppData extends AbstractAppData {
      10              :   Currency? currencyFrom;
      11              : 
      12            2 :   CurrencyAppData({
      13              :     super.title = '',
      14              :     super.uuid = '',
      15              :     super.details = 1.0,
      16              :     super.description,
      17              :     this.currencyFrom,
      18              :     super.currency,
      19              :     super.hidden,
      20              :     super.updatedAt,
      21              :     super.createdAt,
      22              :   }) {
      23            6 :     super.description = DateTime.now().toString();
      24              :   }
      25              : 
      26            0 :   @override
      27              :   String getClassName() => 'CurrencyAppData';
      28              : 
      29            0 :   @override
      30              :   AppDataType getType() => AppDataType.currencies;
      31              : 
      32            0 :   @override
      33              :   CurrencyAppData clone() {
      34            0 :     return CurrencyAppData(
      35            0 :       title: super.title,
      36            0 :       uuid: super.uuid,
      37            0 :       details: super.details,
      38            0 :       currency: super.currency,
      39            0 :       currencyFrom: currencyFrom,
      40            0 :       hidden: super.hidden,
      41              :     );
      42              :   }
      43              : 
      44            0 :   factory CurrencyAppData.fromJson(Map<String, dynamic> json) {
      45            0 :     return CurrencyAppData(
      46            0 :       title: json['title'],
      47            0 :       uuid: json['uuid'],
      48            0 :       details: 0.0 + json['details'],
      49            0 :       updatedAt: DateTime.parse(json['updatedAt']),
      50            0 :       createdAt: DateTime.parse(json['createdAt']),
      51            0 :       currency: CurrencyProvider.find(json['currency']),
      52            0 :       currencyFrom: CurrencyProvider.find(json['currencyFrom']),
      53            0 :       hidden: json['hidden'],
      54              :     );
      55              :   }
      56              : 
      57            0 :   @override
      58            0 :   Map<String, dynamic> toJson() => {
      59            0 :         ...super.toJson(),
      60            0 :         'currencyFrom': currencyFrom?.code,
      61              :       };
      62              : 
      63            0 :   String get detailsFormatted => (super.details as double).toCurrency(currency: currency, withPattern: false);
      64              : 
      65            0 :   String get descriptionFormatted => DateTime.parse(super.description ?? '').yMEd();
      66              : 
      67            0 :   @override
      68            0 :   String get title => '${currencyFrom?.code ?? '?'} -> ${currency?.code ?? '?'}';
      69              : 
      70            0 :   @override
      71            0 :   String get uuid => '${currencyFrom?.code ?? '?'}-${currency?.code ?? '?'}';
      72              : }
        

Generated by: LCOV version 2.0-1