LCOV - code coverage report
Current view: top level - lib/_classes/structure - transaction_log_data.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 3 19 15.8 %
Date: 2024-10-04 11:09:33 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 'dart:convert';
       5             : 
       6             : import 'package:flutter_currency_picker/flutter_currency_picker.dart';
       7             : 
       8             : class TransactionLogData<T> {
       9             :   final String name;
      10             :   final T changedFrom;
      11             :   final T changedTo;
      12             :   final String? ref;
      13             :   final DateTime _time;
      14             :   Currency? currency;
      15             : 
      16           1 :   TransactionLogData({
      17             :     DateTime? timestamp,
      18             :     required this.name,
      19             :     this.ref,
      20             :     this.currency,
      21             :     required this.changedFrom,
      22             :     required this.changedTo,
      23           0 :   }) : _time = timestamp ?? DateTime.now();
      24             : 
      25           2 :   DateTime get timestamp => _time;
      26             : 
      27           8 :   double get delta => (double.tryParse(changedTo.toString()) ?? 0.0) - (double.tryParse(changedFrom.toString()) ?? 0.0);
      28             : 
      29           0 :   TransactionLogData clone() {
      30           0 :     return TransactionLogData(
      31           0 :       name: name,
      32           0 :       changedFrom: changedFrom,
      33           0 :       changedTo: changedTo,
      34           0 :       ref: ref,
      35           0 :       timestamp: timestamp,
      36           0 :       currency: currency,
      37             :     );
      38             :   }
      39             : 
      40           0 :   @override
      41             :   String toString() {
      42           0 :     return json.encode({
      43           0 :       'ref': ref,
      44           0 :       'timestamp': timestamp.toString(),
      45           0 :       'changedFrom': changedFrom,
      46           0 :       'changedTo': changedTo,
      47           0 :       'currency': currency?.code,
      48             :     });
      49             :   }
      50             : }

Generated by: LCOV version 1.14