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