extractContactsForUpdateFromParsedCsvExcel method
bulk imports cannot deduce country dial code, avoid adding another column or a dodgy logic, nobody cares similiarly they cannot deduce check country code solidly enough
Implementation
List<ContactWeebi> extractContactsForUpdateFromParsedCsvExcel() {
final contactsList = <ContactWeebi>[];
for (var i = 0; i < length; i++) {
final row = this[i];
final street = row[4] != null ? row[4].toString().trim() : '';
final code = row[5] != null ? row[5].toString().trim() : '';
final city = row[6] != null ? row[6].toString().trim() : '';
final address = (street.isNotEmpty || city.isNotEmpty || code.isNotEmpty)
? Address(
street: street, city: city, code: code, country: Country.empty)
: Address.empty;
final now = DateTime.now();
final herder = ContactWeebi(
id: 0, // will be updated after if match
creationDate: now, // will be updated after if match
updateDate: now,
status: true,
statusUpdateDate: now,
firstName: row[0] != null ? row[0].toString().trim() : '',
lastName: row[1] != null ? row[1].toString().trim() : '',
phone: Phone(0, row[2] == null ? '' : row[2].toString().trim()),
mail: row[3] != null ? row[3].toString().trim() : '',
addressFull: address,
categories:
row[7] != null ? [row[7].toString().trim()] : const <String>[],
// TODO handle them in import
isClient: false,
isSupplier: false,
);
contactsList.add(herder);
}
return contactsList;
}