LCOV - code coverage report
Current view: top level - _classes/integration - integration_record.dart Coverage Total Hit
Test: lcov.info Lines: 100.0 % 9 9
Test Date: 2026-12-05 10:48:47 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2026 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/math/budget_prediction.dart';
       5              : import 'package:app_finance/_classes/structure/bill_app_data.dart';
       6              : import 'package:app_finance/_classes/structure/interface_app_data.dart';
       7              : import 'package:app_finance/_classes/structure/invoice_app_data.dart';
       8              : import 'package:flutter_currency_picker/flutter_currency_picker.dart';
       9              : 
      10              : typedef IntegrationImportResult = ({int added, int skipped, int pending});
      11              : 
      12              : class IntegrationRecord {
      13           14 :   static InterfaceAppData toAppData({
      14              :     required double amount,
      15              :     required String? currency,
      16              :     required DateTime date,
      17              :     required String title,
      18              :     required String account,
      19              :     required String category,
      20              :     BudgetPrediction? prediction,
      21              :   }) {
      22           13 :     final code = currency != null ? CurrencyProvider.find(currency) : null;
      23           14 :     if (amount < 0) {
      24           14 :       final bill = BillAppData(
      25              :         account: account,
      26              :         category: category,
      27              :         title: title,
      28           14 :         details: amount.abs(),
      29              :         currency: code,
      30              :         createdAt: date,
      31              :         updatedAt: date,
      32              :         hidden: false,
      33              :       );
      34            2 :       final categories = prediction?.predict(bill) ?? const [];
      35           14 :       if (categories.isNotEmpty) {
      36            4 :         bill.category = categories.first;
      37              :       }
      38              :       return bill;
      39              :     }
      40           13 :     return InvoiceAppData(
      41              :       account: account,
      42              :       title: title,
      43              :       details: amount,
      44              :       currency: code,
      45              :       createdAt: date,
      46              :       updatedAt: date,
      47              :       hidden: false,
      48              :     );
      49              :   }
      50              : }
        

Generated by: LCOV version 2.0-1