Advertisement
Guest User

Untitled

a guest
May 13th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. getProductsInfo(daylyDate: Date, fromDate: Date, toDate: Date): Observable < ProductInfo[] > {
  2.     return this.getProductsLeftovers(fromDate)
  3.       .map(restOvers => new Map(restOvers.map(x => [x.productTypeId, x] as[number, ProductLeftoverResponse])))
  4.       .flatMap(restOversMap => this.getDaylyBatches(daylyDate)
  5.         .map(dayBatches => new Map(dayBatches.map(x => [x.productTypeId, x] as[number, ProductBatchResponse])))
  6.         .flatMap(dayBatchesMap => this.getMonthlyBatches(fromDate, toDate)
  7.           .map(monthBatches => new Map(monthBatches.map(x => [x.productTypeId, x] as[number, ProductBatchResponse])))
  8.           .flatMap(monthBatchesMap => this.getProductsLeftovers(toDate)
  9.             .map(currentOvers => new Map(currentOvers.map(x => [x.productTypeId, x] as[number, ProductLeftoverResponse])))
  10.             .flatMap(currentOversMap => this.getProductsChecks()
  11.               .map(checks => new Map(checks.map(x => [x.productTypeId, x] as[number, ProductCheckResponse])))
  12.               .flatMap(checksMap => this.getProductTypes()
  13.                 .flatMap(types => from(types)
  14.                   .map(type => {
  15.                     const info: ProductInfo = {
  16.                       type,
  17.                       restLeftover: restOversMap.get(type.id) || <ProductLeftoverResponse>{},
  18.                       dayBatch: dayBatchesMap.get(type.id) || <ProductBatchResponse>{},
  19.                       monthBatch: monthBatchesMap.get(type.id) || <ProductBatchResponse>{},
  20.                       currentLeftover: currentOversMap.get(type.id) || <ProductLeftoverResponse>{},
  21.                       productCheck: checksMap.get(type.id) || <ProductCheckResponse>{}
  22.                     }
  23.                     return info;
  24.                   }))))))).toArray();
  25.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement