mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged in bugfix/HIMA-1186 (pull request #1240)
[HIMA-1186] now when finishing remission and printing is required we don show the finished remission page directly but after the printing is finished
This commit is contained in:
@@ -1,28 +1,13 @@
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
ChangeDetectorRef,
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, ChangeDetectorRef, ViewChild } from '@angular/core';
|
||||
import { RemissionFinishingProcessStatus } from '../../models/remission-finishing-process-status.enum';
|
||||
import { Store, Select } from '@ngxs/store';
|
||||
import { RemissionSelectors } from 'apps/sales/src/app/core/store/selectors/remission.selectors';
|
||||
import {
|
||||
RemissionSupplier,
|
||||
RemissionProcess,
|
||||
RemissionService,
|
||||
ShippingDocument,
|
||||
Printer
|
||||
} from '@isa/remission';
|
||||
import { RemissionSupplier, RemissionProcess, RemissionService, ShippingDocument, Printer } from '@isa/remission';
|
||||
import { filter, takeUntil, take, switchMap, map } from 'rxjs/operators';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { Subject, Observable, merge } from 'rxjs';
|
||||
import { SUPPLIER_PLACEHOLDER } from '../../constants/remission.constants';
|
||||
import {
|
||||
AddBreadcrumb,
|
||||
ResetBreadcrumbsTo
|
||||
} from 'apps/sales/src/app/core/store/actions/breadcrumb.actions';
|
||||
import { AddBreadcrumb, ResetBreadcrumbsTo } from 'apps/sales/src/app/core/store/actions/breadcrumb.actions';
|
||||
import { SetBranchProcessCurrentPath } from 'apps/sales/src/app/core/store/actions/branch-process.actions';
|
||||
import { Router } from '@angular/router';
|
||||
import {
|
||||
@@ -50,9 +35,7 @@ import { PrinterSelectionComponent } from 'apps/sales/src/app/components/printer
|
||||
styleUrls: ['./remission-finish.component.scss']
|
||||
})
|
||||
export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
@Select(RemissionSelectors.getRemissionProcess) remissionProcess$: Observable<
|
||||
RemissionProcess
|
||||
>;
|
||||
@Select(RemissionSelectors.getRemissionProcess) remissionProcess$: Observable<RemissionProcess>;
|
||||
@Select(RemissionSelectors.getRemissionShippingDocument)
|
||||
shippingDocument$: Observable<ShippingDocument>;
|
||||
@Select(RemissionSelectors.getRemissionShippingDocumentstatus)
|
||||
@@ -76,8 +59,7 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
destroy$ = new Subject();
|
||||
containerId: string;
|
||||
showError = false;
|
||||
errorMsg =
|
||||
'Leider haben Sie den falschen Barcode gescannt. Scannen Sie bitte den Barcode seitlich an der Wanne.';
|
||||
errorMsg = 'Leider haben Sie den falschen Barcode gescannt. Scannen Sie bitte den Barcode seitlich an der Wanne.';
|
||||
supplier: RemissionSupplier;
|
||||
startNewRemission = false;
|
||||
title = {
|
||||
@@ -138,12 +120,8 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
.subscribe(status => {
|
||||
this.pageStatus = status;
|
||||
this.cdrf.detectChanges();
|
||||
if (
|
||||
this.pageStatus === RemissionFinishingProcessStatus.containerScanned
|
||||
) {
|
||||
this.containerId = this.store.selectSnapshot(
|
||||
RemissionSelectors.getRemissionContainerId
|
||||
);
|
||||
if (this.pageStatus === RemissionFinishingProcessStatus.containerScanned) {
|
||||
this.containerId = this.store.selectSnapshot(RemissionSelectors.getRemissionContainerId);
|
||||
} else if (this.pageStatus === RemissionFinishingProcessStatus.notSet) {
|
||||
this.navigateToNewRemissionList();
|
||||
}
|
||||
@@ -180,8 +158,7 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
)
|
||||
.subscribe(({ isCompleted }) => {
|
||||
if (isCompleted) {
|
||||
this.pageStatus =
|
||||
RemissionFinishingProcessStatus.containerScanned;
|
||||
this.pageStatus = RemissionFinishingProcessStatus.containerScanned;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -199,9 +176,7 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
loadCurrentRemissionProcess() {
|
||||
return this.currentRemissionProcess$.pipe(
|
||||
filter(data => !isNullOrUndefined(data), take(1))
|
||||
);
|
||||
return this.currentRemissionProcess$.pipe(filter(data => !isNullOrUndefined(data), take(1)));
|
||||
}
|
||||
|
||||
continueProcess() {
|
||||
@@ -213,21 +188,13 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
}
|
||||
|
||||
shippingDocumentSubscriptionHandler = (
|
||||
shippingDocument: ShippingDocument
|
||||
) => {
|
||||
shippingDocumentSubscriptionHandler = (shippingDocument: ShippingDocument) => {
|
||||
this.shippingDocument = shippingDocument;
|
||||
};
|
||||
|
||||
remissionProcessSubscriptionHandler = (
|
||||
remissionProcess: RemissionProcess
|
||||
) => {
|
||||
remissionProcessSubscriptionHandler = (remissionProcess: RemissionProcess) => {
|
||||
this.remissionProcess = remissionProcess;
|
||||
if (
|
||||
remissionProcess &&
|
||||
remissionProcess.filter &&
|
||||
remissionProcess.filter.target
|
||||
) {
|
||||
if (remissionProcess && remissionProcess.filter && remissionProcess.filter.target) {
|
||||
this.loadSupplier(remissionProcess.filter.target);
|
||||
}
|
||||
};
|
||||
@@ -241,15 +208,11 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
if (this.supplier) {
|
||||
const selectedSupplierName = remissionSuplier.name;
|
||||
this.title[
|
||||
RemissionFinishingProcessStatus.finished
|
||||
] = this.finishPocessTitles[this.supplier.id].replace(
|
||||
this.title[RemissionFinishingProcessStatus.finished] = this.finishPocessTitles[this.supplier.id].replace(
|
||||
SUPPLIER_PLACEHOLDER,
|
||||
selectedSupplierName
|
||||
);
|
||||
this.subTitle[
|
||||
RemissionFinishingProcessStatus.finished
|
||||
] = this.finishPocessSubTitles[this.supplier.id].replace(
|
||||
this.subTitle[RemissionFinishingProcessStatus.finished] = this.finishPocessSubTitles[this.supplier.id].replace(
|
||||
SUPPLIER_PLACEHOLDER,
|
||||
selectedSupplierName
|
||||
);
|
||||
@@ -266,25 +229,14 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
finishRemission() {
|
||||
this.appService.clearIdleReminder();
|
||||
this.pageStatus = RemissionFinishingProcessStatus.finished;
|
||||
this.store.dispatch(new SetRemissionFinishedProcessStatus(this.pageStatus));
|
||||
const remissionProcessId = this.remissionProcess.id;
|
||||
this.remissionService
|
||||
.completeRemissions({ remissionProcessId })
|
||||
.subscribe(status => {
|
||||
if (status) {
|
||||
this.remissionService
|
||||
.isPrintingRequired({ remissionProcessId })
|
||||
.subscribe(isPrintingRequired => {
|
||||
if (isPrintingRequired) {
|
||||
this.printModal.openDialog();
|
||||
} else {
|
||||
this.store.dispatch(new ResetRemissionState());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.remissionService.isPrintingRequired({ remissionProcessId }).subscribe(isPrintingRequired => {
|
||||
if (isPrintingRequired) {
|
||||
this.printModal.openDialog();
|
||||
} else {
|
||||
this.postFinishRemission(remissionProcessId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
print(selectedPrinter) {
|
||||
@@ -297,19 +249,28 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
})
|
||||
.subscribe(
|
||||
() => {
|
||||
this.store.dispatch(new ResetRemissionState());
|
||||
this.postFinishRemission(this.remissionProcess.id);
|
||||
this.isPrinting = false;
|
||||
},
|
||||
() => {
|
||||
this.pageStatus = RemissionFinishingProcessStatus.containerScanned;
|
||||
this.store.dispatch(
|
||||
new SetRemissionFinishedProcessStatus(this.pageStatus)
|
||||
);
|
||||
this.store.dispatch(new SetRemissionFinishedProcessStatus(this.pageStatus));
|
||||
this.isPrinting = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
postFinishRemission(remissionProcessId: number) {
|
||||
this.remissionService.completeRemissions({ remissionProcessId }).subscribe(status => {
|
||||
if (status) {
|
||||
this.appService.clearIdleReminder();
|
||||
this.pageStatus = RemissionFinishingProcessStatus.finished;
|
||||
this.store.dispatch(new SetRemissionFinishedProcessStatus(this.pageStatus));
|
||||
this.store.dispatch(new ResetRemissionState());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
continueRemission() {
|
||||
this.startRemission();
|
||||
}
|
||||
@@ -373,9 +334,7 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
if (response.errorReasons.PackageCode) {
|
||||
this.emptyOrInvalidBarcode = false;
|
||||
this.pageStatus = RemissionFinishingProcessStatus.start;
|
||||
this.store.dispatch(
|
||||
new SetRemissionFinishedProcessStatus(this.pageStatus)
|
||||
);
|
||||
this.store.dispatch(new SetRemissionFinishedProcessStatus(this.pageStatus));
|
||||
const closeDialogRef = this.invalidBarcodeDialog.openDialog();
|
||||
closeDialogRef.subscribe(() => (this.emptyOrInvalidBarcode = true));
|
||||
} else {
|
||||
@@ -383,9 +342,7 @@ export class RemissionFinishComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
} else {
|
||||
this.pageStatus = RemissionFinishingProcessStatus.containerScanned;
|
||||
this.store.dispatch(
|
||||
new CompleteRemissionShippingDocument(this.shippingDocument)
|
||||
);
|
||||
this.store.dispatch(new CompleteRemissionShippingDocument(this.shippingDocument));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user