lineQuantityOutDash method

  1. @action
Observable<double> lineQuantityOutDash(
  1. int productId,
  2. DateRange range
)

Implementation

@action
Observable<double> lineQuantityOutDash(int productId, DateRange range) {
  final double stockCount = tickets
      .where((t) => t.status == true)
      .where((t) => t.date.isAfter(range.start))
      .where((t) => t.date.isBefore(range.end))
      .where((t) =>
          t.ticketType == TicketType.sell ||
          t.ticketType == TicketType.sellDeferred ||
          t.ticketType == TicketType.stockOut)
      .fold(
        0.0,
        (val, t) =>
            val +
            t.items.where((i) => i.article.calibreId == productId).fold(
                0.0,
                (val, i) => i.article.kind == ArticleKind.retail
                    ? val +
                        (i.quantity *
                            (i.article as ArticleRetailOnTicket)
                                .unitsInOnePiece)
                    : val + i.quantity),
      );
  return Observable(stockCount);
}