extractCalibresOfArticlesForUpdateFromParsedCsvExcel method
Implementation
List<CalibreWeebi<ArticleRetail>>
extractCalibresOfArticlesForUpdateFromParsedCsvExcel() {
final linesList = <CalibreWeebi<ArticleRetail>>[];
for (var i = 0; i < length; i++) // avoid header
{
final now = DateTime.now();
final table = this[i];
final newArticle = ArticleRetail(
creationDate: now, // will be updated after if match
calibreId: 0, // will be updated after if match
id: 1,
designation: table[0] != null ? '${table[0]}' : '',
price: table[1] != null
? table[1].runtimeType == num
? table[1]
: num.tryParse(table[1])
: 0,
cost: table[2] != null
? table[2].runtimeType == num
? table[2]
: num.tryParse(table[2])
: 0,
unitsInOnePiece: 1.0,
barcodeEAN: table[3] != null ? '${table[3]}' : '',
);
final newLine = CalibreWeebi<ArticleRetail>(
creationDate: now,
updateDate: now,
kind: ArticleKind.retail,
id: 0,
title: table[0] != null ? '${table[0]}' : '',
status: true,
statusUpdateDate: DateTime.now(),
stockUnit: StockUnit.unit,
articles: [newArticle],
);
linesList.add(newLine);
}
return linesList;
}