LCOV - code coverage report
Current view: top level - lib/_classes/structure - invoice_app_data.dart Coverage Total Hit
Test: lcov.info Lines: 60.9 % 46 28
Test Date: 2026-12-05 10:50:38 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/herald/app_locale.dart';
       5              : import 'package:app_finance/_classes/storage/app_data.dart';
       6              : import 'package:app_finance/_classes/structure/abstract_app_data.dart';
       7              : import 'package:app_finance/_mixins/storage_mixin.dart';
       8              : import 'package:material_ui/material_ui.dart';
       9              : import 'package:flutter_currency_picker/flutter_currency_picker.dart';
      10              : import 'package:intl/intl.dart';
      11              : 
      12              : class InvoiceAppData extends AbstractAppData with StorageMixin {
      13              :   String account;
      14              :   String? accountFrom;
      15              :   List<String> tags;
      16              : 
      17            2 :   InvoiceAppData({
      18              :     required super.title,
      19              :     required this.account,
      20              :     this.accountFrom,
      21              :     super.uuid,
      22              :     super.details,
      23              :     super.description,
      24              :     super.color,
      25              :     super.currency,
      26              :     super.updatedAt,
      27              :     super.createdAt,
      28              :     super.createdAtFormatted,
      29              :     super.hidden,
      30              :     super.payment,
      31              :     List<String>? tags,
      32            2 :   }) : tags = tags ?? [];
      33              : 
      34            2 :   @override
      35              :   String getClassName() => 'InvoiceAppData';
      36              : 
      37            2 :   @override
      38              :   AppDataType getType() => AppDataType.invoice;
      39              : 
      40            2 :   @override
      41              :   InvoiceAppData clone() {
      42            2 :     return InvoiceAppData(
      43            2 :       account: account,
      44            2 :       accountFrom: accountFrom,
      45            2 :       uuid: super.uuid,
      46            2 :       title: super.title,
      47            2 :       details: super.details,
      48            2 :       description: super.description,
      49            2 :       color: super.color,
      50            2 :       currency: super.currency,
      51            2 :       createdAt: super.createdAt,
      52            2 :       hidden: super.hidden,
      53            2 :       payment: super.payment,
      54            4 :       tags: [...tags],
      55              :     );
      56              :   }
      57              : 
      58            0 :   factory InvoiceAppData.fromJson(Map<String, dynamic> json) {
      59            0 :     return InvoiceAppData(
      60            0 :       uuid: json['uuid'],
      61            0 :       title: json['title'],
      62            0 :       account: json['account'],
      63            0 :       accountFrom: json['accountFrom'],
      64            0 :       details: 0.0 + (json['details'] ?? 0),
      65            0 :       description: json['description'],
      66            0 :       color: json['color'] != null ? MaterialColor(json['color'], const <int, Color>{}) : null,
      67            0 :       currency: CurrencyProvider.find(json['currency']),
      68            0 :       createdAt: DateTime.parse(json['createdAt']),
      69            0 :       updatedAt: DateTime.parse(json['updatedAt']),
      70            0 :       hidden: json['hidden'],
      71            0 :       payment: json['payment'],
      72            0 :       tags: (json['tags'] as List<dynamic>?)?.cast<String>(),
      73              :     );
      74              :   }
      75              : 
      76            2 :   @override
      77            2 :   Map<String, dynamic> toJson() => {
      78            2 :         ...super.toJson(),
      79            4 :         'account': account,
      80            4 :         'accountFrom': accountFrom,
      81            4 :         'tags': tags,
      82              :       };
      83              : 
      84            0 :   String get detailsFormatted => (super.details as double).toCurrency(currency: currency, withPattern: false);
      85              : 
      86            2 :   @override
      87            6 :   String get description => DateFormat.MMMMd(AppLocale.code).format(super.createdAt);
      88              : 
      89            2 :   @override
      90            8 :   IconData? get icon => getState().getByUuid(account).icon;
      91              : 
      92            0 :   String get accountNamed => getState().getByUuid(account).title;
      93              : 
      94            0 :   String? get accountFromNamed => accountFrom != null ? getState().getByUuid(accountFrom!).title : null;
      95              : }
        

Generated by: LCOV version 2.0-1