Skip to content

Commit 5a8b1a5

Browse files
committed
Merge branch 'develop'
2 parents 1509465 + c5bcb5b commit 5a8b1a5

14 files changed

+1059
-345
lines changed

android/build.gradle.foss

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
buildscript {
2+
ext.kotlin_version = '1.3.72'
3+
repositories {
4+
google()
5+
jcenter()
6+
}
7+
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:3.6.2'
10+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11+
}
12+
}
13+
14+
allprojects {
15+
repositories {
16+
google()
17+
jcenter()
18+
}
19+
}
20+
21+
rootProject.buildDir = '../build'
22+
subprojects {
23+
project.buildDir = "${rootProject.buildDir}/${project.name}"
24+
}
25+
subprojects {
26+
project.evaluationDependsOn(':app')
27+
}
28+
29+
task clean(type: Delete) {
30+
delete rootProject.buildDir
31+
}

lib/constants.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const double kLighterOpacity = .6;
125125
const int kMaxNumberOfCompanies = 10;
126126
const int kMaxNumberOfHistory = 50;
127127
const int kMaxRecordsPerApiPage = 5000;
128-
const int kMaxPostSeconds = 120;
128+
const int kMaxPostSeconds = 30;
129129
const int kMillisecondsToRefreshData = 1000 * 60 * 15; // 15 minutes
130130
const int kUpdatedAtBufferSeconds = 600;
131131
const int kMillisecondsToRefreshActivities = 1000 * 60 * 60 * 24; // 1 day

lib/data/models/import_model.dart

+71-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:built_collection/built_collection.dart';
22
import 'package:built_value/built_value.dart';
33
import 'package:built_value/serializer.dart';
44
import 'package:flutter/foundation.dart';
5+
import 'package:invoiceninja_flutter/data/models/entities.dart';
56

67
part 'import_model.g.dart';
78

@@ -19,31 +20,48 @@ abstract class PreImportResponse
1920

2021
String get hash;
2122

22-
BuiltList<BuiltList<String>> get headers;
23+
BuiltMap<String,PreImportResponseEntityDetails> get mappings;
24+
25+
static Serializer<PreImportResponse> get serializer =>
26+
_$preImportResponseSerializer;
27+
}
28+
29+
abstract class PreImportResponseEntityDetails
30+
implements Built<PreImportResponseEntityDetails, PreImportResponseEntityDetailsBuilder> {
31+
factory PreImportResponseEntityDetails() {
32+
return _$PreImportResponseEntityDetails._();
33+
}
34+
35+
PreImportResponseEntityDetails._();
36+
37+
@override
38+
@memoized
39+
int get hashCode;
2340

2441
BuiltList<String> get available;
42+
BuiltList<BuiltList<String>> get headers;
2543

2644
BuiltList<String> get fields1 =>
2745
headers.isEmpty ? BuiltList<String>() : headers[0];
2846

2947
BuiltList<String> get fields2 =>
3048
headers.length < 2 ? BuiltList<String>() : headers[1];
3149

32-
static Serializer<PreImportResponse> get serializer =>
33-
_$preImportResponseSerializer;
50+
static Serializer<PreImportResponseEntityDetails> get serializer =>
51+
_$preImportResponseEntityDetailsSerializer;
3452
}
3553

3654
abstract class ImportRequest
3755
implements Built<ImportRequest, ImportRequestBuilder> {
3856
factory ImportRequest({
3957
@required String hash,
40-
@required String entityType,
58+
@required String importType,
4159
@required bool skipHeader,
42-
@required BuiltMap<int, String> columnMap,
60+
@required BuiltMap<String, BuiltMap<int, String>> columnMap,
4361
}) {
4462
return _$ImportRequest._(
4563
hash: hash,
46-
entityType: entityType,
64+
importType: importType,
4765
skipHeader: skipHeader,
4866
columnMap: columnMap,
4967
);
@@ -57,14 +75,58 @@ abstract class ImportRequest
5775

5876
String get hash;
5977

60-
@BuiltValueField(wireName: 'entity_type')
61-
String get entityType;
78+
@BuiltValueField(wireName: 'import_type')
79+
String get importType;
6280

6381
@BuiltValueField(wireName: 'skip_header')
6482
bool get skipHeader;
6583

6684
@BuiltValueField(wireName: 'column_map')
67-
BuiltMap<int, String> get columnMap;
85+
BuiltMap<String, BuiltMap<int, String>> get columnMap;
86+
87+
// This needed so the builder factory for BuiltMap<int, String> is auto-created.
88+
@nullable
89+
@BuiltValueField(wireName: 'dummy_field')
90+
BuiltMap<int, String> get dummy;
6891

6992
static Serializer<ImportRequest> get serializer => _$importRequestSerializer;
7093
}
94+
95+
class ImportType extends EnumClass {
96+
const ImportType._(String name) : super(name);
97+
98+
static Serializer<ImportType> get serializer => _$importTypeSerializer;
99+
100+
static const ImportType csv = _$csv;
101+
static const ImportType freshbooks = _$freshbooks;
102+
static const ImportType invoice2go = _$invoice2go;
103+
104+
static const ImportType invoicely = _$invoicely;
105+
static const ImportType waveaccounting = _$waveaccounting;
106+
static const ImportType zoho = _$zoho;
107+
108+
static BuiltSet<ImportType> get values => _$typeValues;
109+
110+
List<String> get uploadParts {
111+
switch (this) {
112+
case ImportType.csv:
113+
return [
114+
EntityType.client.toString(),
115+
EntityType.invoice.toString(),
116+
EntityType.payment.toString(),
117+
EntityType.product.toString(),
118+
EntityType.vendor.toString(),
119+
EntityType.expense.toString(),
120+
];
121+
case ImportType.freshbooks:
122+
return [
123+
EntityType.client.toString(),
124+
EntityType.payment.toString(),
125+
];
126+
default:
127+
return [];
128+
}
129+
}
130+
131+
static ImportType valueOf(String name) => _$typeValueOf(name);
132+
}

0 commit comments

Comments
 (0)