Merged PR 363: #1087 Catch Error Creating Lieferschein & Reset Loading State | #1085 Reset Loader on Empty List of Receipts to Print

#1087 Catch Error Creating Lieferschein & Reset Loading State
#1085 Reset Loader on Empty List of Receipts to Print

Related work items: #1087
This commit is contained in:
Sebastian Neumair
2020-10-15 12:08:13 +00:00
2 changed files with 17 additions and 5 deletions

View File

@@ -6,12 +6,10 @@ import {
ResponseArgsOfValueTupleOfOrderItemSubsetDTOAndOrderItemSubsetDTO,
StatusValues,
} from '@swagger/oms';
import { BehaviorSubject, Observable } from 'rxjs';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { PrinterSelectionComponent } from '../../../components/printer-selection/printer-selection.component';
import { OrderDetailsCardInput } from '../components/order-details-card';
import { ShelfActionHandlerService } from './shelf-action-handler.service';
import { ShelfShippingNoteService } from './shelf-shipping-note.service';
@Injectable({ providedIn: 'root' })
export class ShelfOrderDetailsService {
@@ -67,7 +65,10 @@ export class ShelfOrderDetailsService {
receipts?: ReceiptDTO[];
})[]
): ReceiptDTO[] {
return items.reduce((acc, curr) => [...(acc || []), ...curr.receipts], []);
return items.reduce(
(acc, curr) => [...(acc || []), ...(curr.receipts ? curr.receipts : [])],
[]
);
}
public showPickUpAndPrintOption$(

View File

@@ -33,13 +33,23 @@ export class ShelfShippingNoteService {
statusObs$?: BehaviorSubject<boolean>;
}
): Promise<ReceiptDTO[]> {
if (data.statusObs$ && data.statusObs$.next) {
data.statusObs$.next(true);
}
let receipts: ReceiptDTO[];
try {
receipts = await this.createNote(orderItemSubsetIds, {
printerComponent: data.printerComponent,
statusObs$: data.statusObs$,
});
} catch (error) {}
} catch (error) {
console.error('Error creating Lieferschein');
} finally {
if (data.statusObs$ && data.statusObs$.next) {
data.statusObs$.next(false);
}
}
return receipts;
}
@@ -74,6 +84,7 @@ export class ShelfShippingNoteService {
}
}
data.statusObs$.next(false);
return true;
}