Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getProductsInfo(daylyDate: Date, fromDate: Date, toDate: Date): Observable < ProductInfo[] > {
- return this.getProductsLeftovers(fromDate)
- .map(restOvers => new Map(restOvers.map(x => [x.productTypeId, x] as[number, ProductLeftoverResponse])))
- .flatMap(restOversMap => this.getDaylyBatches(daylyDate)
- .map(dayBatches => new Map(dayBatches.map(x => [x.productTypeId, x] as[number, ProductBatchResponse])))
- .flatMap(dayBatchesMap => this.getMonthlyBatches(fromDate, toDate)
- .map(monthBatches => new Map(monthBatches.map(x => [x.productTypeId, x] as[number, ProductBatchResponse])))
- .flatMap(monthBatchesMap => this.getProductsLeftovers(toDate)
- .map(currentOvers => new Map(currentOvers.map(x => [x.productTypeId, x] as[number, ProductLeftoverResponse])))
- .flatMap(currentOversMap => this.getProductsChecks()
- .map(checks => new Map(checks.map(x => [x.productTypeId, x] as[number, ProductCheckResponse])))
- .flatMap(checksMap => this.getProductTypes()
- .flatMap(types => from(types)
- .map(type => {
- const info: ProductInfo = {
- type,
- restLeftover: restOversMap.get(type.id) || <ProductLeftoverResponse>{},
- dayBatch: dayBatchesMap.get(type.id) || <ProductBatchResponse>{},
- monthBatch: monthBatchesMap.get(type.id) || <ProductBatchResponse>{},
- currentLeftover: currentOversMap.get(type.id) || <ProductLeftoverResponse>{},
- productCheck: checksMap.get(type.id) || <ProductCheckResponse>{}
- }
- return info;
- }))))))).toArray();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement