herderReportStockArtCalibre method
List<ReportStockArtCalibre>
herderReportStockArtCalibre(
- int herderId,
- List<
CalibreAbstract< products,ArticleRawAbstract> > - DateRange dateRange,
- List<
ReportStockArtCalibre> emptyReportStockCalibres,
Implementation
List<ReportStockArtCalibre> herderReportStockArtCalibre(
int herderId,
List<CalibreAbstract> products,
DateRange dateRange,
List<ReportStockArtCalibre> emptyReportStockCalibres,
) {
forEach((c) {
if (c.contactId == herderId &&
(c.closingRange.start.isAfter(dateRange.start) ||
c.closingRange.start.isAtSameMomentAs(dateRange.start)) &&
(c.closingRange.end.isBefore(dateRange.end) ||
c.closingRange.end.isAtSameMomentAs(dateRange.end))) {
for (var p in products) {
if (c.articleCalibres.any((i) => i.id == p.id)) {
// NOT any products can be both bought & sold
// so we SUM ALL movements
emptyReportStockCalibres
.firstWhere((reportStockP) => reportStockP.id == p.id)
.finalQtCl +=
c.articleCalibres
.firstWhere((clsoingStockP) => clsoingStockP.id == p.id)
.finalQtCl;
} else {
print('closings do not fit requirements');
}
}
}
});
return emptyReportStockCalibres;
}