mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
#913 Hide Deleted Shipping Documents
+ Update Logic On Which Shipping Document to Display for a Given Remission
This commit is contained in:
@@ -203,7 +203,7 @@ export class RestRemissionProductsService {
|
||||
)
|
||||
);
|
||||
|
||||
allProducts$ = combineLatest(regularProducts$, priorityItems$).pipe(
|
||||
allProducts$ = combineLatest([regularProducts$, priorityItems$]).pipe(
|
||||
map(([regular, priority]) => ({
|
||||
skip: regular.skip,
|
||||
take: regular.take,
|
||||
|
||||
@@ -1382,7 +1382,19 @@ export class RestRemissionService extends RemissionService {
|
||||
stockId: stock.id,
|
||||
queryToken: queryTokenOpen,
|
||||
})
|
||||
.pipe(map((response) => response.result));
|
||||
.pipe(
|
||||
map((response) => response.result),
|
||||
map((returns) =>
|
||||
returns.filter(
|
||||
(r) =>
|
||||
!r.receipts.every(
|
||||
(receipt) =>
|
||||
(receipt.data && receipt.data.status === 4) ||
|
||||
receipt.data.completed
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
const completedReturns$: Observable<ReturnDTO[]> = this.returnApi
|
||||
.queryReturns({
|
||||
stockId: stock.id,
|
||||
@@ -1399,21 +1411,17 @@ export class RestRemissionService extends RemissionService {
|
||||
}
|
||||
|
||||
return forkJoin([openReturns$, completedReturns$]).pipe(
|
||||
map(([openReturns, completedReturns]: [ReturnDTO[], ReturnDTO[]]) => [
|
||||
...openReturns,
|
||||
...completedReturns,
|
||||
])
|
||||
map(([openReturns, completedReturns]: [ReturnDTO[], ReturnDTO[]]) => {
|
||||
const openReturnIds = openReturns.map((r) => r.id);
|
||||
return [
|
||||
...openReturns,
|
||||
...completedReturns.filter(
|
||||
(completedReturn) => !openReturnIds.includes(completedReturn.id)
|
||||
),
|
||||
];
|
||||
})
|
||||
);
|
||||
}),
|
||||
map((returns) =>
|
||||
returns.reduce(
|
||||
(acc: ReturnDTO[], curr: ReturnDTO) =>
|
||||
acc.find((r) => r.returnNumber === curr.returnNumber)
|
||||
? [...acc]
|
||||
: [...acc, curr],
|
||||
[]
|
||||
)
|
||||
),
|
||||
withLatestFrom(this.stock$, this.targets$),
|
||||
mergeMap(([result, stock, targets]) => {
|
||||
if (!result.length) {
|
||||
@@ -1488,8 +1496,8 @@ export class RestRemissionService extends RemissionService {
|
||||
remissions.filter(
|
||||
(remission) =>
|
||||
!!remission.id &&
|
||||
!!remission.shippingDocuments[0] &&
|
||||
!remission.shippingDocuments[0].isDeleted
|
||||
!!remission.shippingDocuments &&
|
||||
!remission.shippingDocuments.every((document) => document.isDeleted)
|
||||
)
|
||||
),
|
||||
tap((remissions: RemissionProcess[]) =>
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
<div class="card-container" [ngClass]="{ last: last }" (click)="onClickOpenDetails()">
|
||||
<div
|
||||
class="card-container"
|
||||
[ngClass]="{ last: last }"
|
||||
(click)="onClickOpenDetails()"
|
||||
>
|
||||
<div class="card-wrapper">
|
||||
<div class="card-header">
|
||||
<span *ngIf="!shippingDocumentIsCompleted" class="red-circle"></span>
|
||||
<div class="card-title">#{{ shippingDocumentNumber | shippingDocumentNumberFormatter | packageNumberParser }}</div>
|
||||
<span
|
||||
*ngIf="!shippingDocumentIsCompleted && shippingDocumentNumber"
|
||||
class="red-circle"
|
||||
></span>
|
||||
<div class="card-title">
|
||||
#{{
|
||||
shippingDocumentNumber
|
||||
| shippingDocumentNumberFormatter
|
||||
| packageNumberParser
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-remissions-overview-card-content
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { Component, OnInit, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { RemissionProcess } from '@isa/remission';
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
ChangeDetectionStrategy,
|
||||
Input,
|
||||
Output,
|
||||
EventEmitter,
|
||||
} from '@angular/core';
|
||||
import { RemissionProcess, ShippingDocument } from '@isa/remission';
|
||||
|
||||
@Component({
|
||||
selector: 'app-remissions-overview-card',
|
||||
@@ -17,6 +24,16 @@ export class RemissionsOverviewCardComponent implements OnInit {
|
||||
@Output()
|
||||
openDetailsPage = new EventEmitter<number>();
|
||||
|
||||
get shippingDocument(): ShippingDocument {
|
||||
return (
|
||||
(this.remissionProcess.shippingDocuments &&
|
||||
this.remissionProcess.shippingDocuments.find(
|
||||
(sd) => !sd.isCompleted
|
||||
)) ||
|
||||
this.remissionProcess.shippingDocuments[0]
|
||||
);
|
||||
}
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {}
|
||||
@@ -26,7 +43,7 @@ export class RemissionsOverviewCardComponent implements OnInit {
|
||||
}
|
||||
|
||||
private shippingDocumentExists(remissionProcess: RemissionProcess): boolean {
|
||||
return !!remissionProcess.shippingDocuments && !!remissionProcess.shippingDocuments[0];
|
||||
return !!remissionProcess.shippingDocuments && !!this.shippingDocument;
|
||||
}
|
||||
|
||||
get shippingDocumentId() {
|
||||
@@ -34,7 +51,7 @@ export class RemissionsOverviewCardComponent implements OnInit {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.remissionProcess.shippingDocuments[0].id;
|
||||
return this.shippingDocument.id;
|
||||
}
|
||||
|
||||
get shippingDocumentIsCompleted() {
|
||||
@@ -42,7 +59,7 @@ export class RemissionsOverviewCardComponent implements OnInit {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.remissionProcess.shippingDocuments[0].isCompleted;
|
||||
return this.shippingDocument.isCompleted;
|
||||
}
|
||||
|
||||
get numberOfShippingDocumentProducts() {
|
||||
@@ -50,7 +67,9 @@ export class RemissionsOverviewCardComponent implements OnInit {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.remissionProcess.shippingDocuments[0].products.length;
|
||||
return this.shippingDocument.products
|
||||
? this.shippingDocument.products.length
|
||||
: 0;
|
||||
}
|
||||
|
||||
get shippingDocumentNumber() {
|
||||
@@ -58,7 +77,7 @@ export class RemissionsOverviewCardComponent implements OnInit {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.remissionProcess.shippingDocuments[0].shippingDocumentNumber;
|
||||
return this.shippingDocument.shippingDocumentNumber;
|
||||
}
|
||||
|
||||
get packageNumber() {
|
||||
@@ -66,6 +85,6 @@ export class RemissionsOverviewCardComponent implements OnInit {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.remissionProcess.shippingDocuments[0].packageNumber;
|
||||
return this.shippingDocument.packageNumber;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,85 @@
|
||||
<ng-container *ngIf="!(isLoading | async); else loading">
|
||||
<div class="scroll-container" *ngIf="remissionProcess$ | async as remissionProcess">
|
||||
<div class="container">
|
||||
<div class="card-wrapper">
|
||||
<ng-container [ngSwitch]="(remissionProcess?.shippingDocuments)[0].isCompleted">
|
||||
<div class="button-wrapper" *ngSwitchCase="false">
|
||||
<app-button (action)="deleteShippingDocument()" [alignRight]="true">Löschen</app-button>
|
||||
<div
|
||||
class="scroll-container"
|
||||
*ngIf="remissionProcess$ | async as remissionProcess"
|
||||
>
|
||||
<ng-container *ngIf="shippingDocument$ | async as shippingDocument">
|
||||
<div class="container">
|
||||
<div class="card-wrapper">
|
||||
<ng-container [ngSwitch]="shippingDocumentCompleted$ | async">
|
||||
<div class="button-wrapper" *ngSwitchCase="false">
|
||||
<app-button
|
||||
(action)="deleteShippingDocument()"
|
||||
[alignRight]="true"
|
||||
>Löschen</app-button
|
||||
>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="button-wrapper"
|
||||
*ngSwitchDefault
|
||||
[class.hide]="
|
||||
!isSupplierActivatedForPrinting(
|
||||
remissionProcess?.filter?.target
|
||||
)
|
||||
"
|
||||
>
|
||||
<app-button
|
||||
[alignRight]="true"
|
||||
[disabled]="!!(isPrinting | async)"
|
||||
(action)="openPrintSelection()"
|
||||
>Drucken</app-button
|
||||
>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<div class="header">
|
||||
<div class="title">Warenbegleitschein</div>
|
||||
<div class="title">
|
||||
#{{
|
||||
remissionProcess.shippingDocuments[0].shippingDocumentNumber
|
||||
| shippingDocumentNumberFormatter
|
||||
| packageNumberParser
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="button-wrapper" *ngSwitchDefault [class.hide]="!isSupplierActivatedForPrinting(remissionProcess?.filter?.target)">
|
||||
<app-button [alignRight]="true" [disabled]="!!(isPrinting | async)" (action)="openPrintSelection()">Drucken</app-button>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<div class="header">
|
||||
<div class="title">Warenbegleitschein</div>
|
||||
<div class="title">
|
||||
#{{ remissionProcess.shippingDocuments[0].shippingDocumentNumber | shippingDocumentNumberFormatter | packageNumberParser }}
|
||||
</div>
|
||||
<app-remissions-overview-card-content
|
||||
[isCompleted]="shippingDocument?.isCompleted"
|
||||
[supplier]="remissionProcess?.filter?.target?.name"
|
||||
[numberOfItems]="shippingDocument?.products?.length"
|
||||
[packageNumber]="shippingDocument?.packageNumber"
|
||||
alignRight="true"
|
||||
[date]="remissionProcess?.startDate"
|
||||
></app-remissions-overview-card-content>
|
||||
</div>
|
||||
|
||||
<app-remissions-overview-card-content
|
||||
[isCompleted]="(remissionProcess?.shippingDocuments)[0].isCompleted"
|
||||
[supplier]="remissionProcess?.filter?.target?.name"
|
||||
[numberOfItems]="(remissionProcess?.shippingDocuments)[0]?.products?.length"
|
||||
[packageNumber]="(remissionProcess?.shippingDocuments)[0]?.packageNumber"
|
||||
alignRight="true"
|
||||
[date]="remissionProcess?.startDate"
|
||||
></app-remissions-overview-card-content>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="container product-container"
|
||||
[ngClass]="{ last: last }"
|
||||
*ngFor="let product of (remissionProcess?.shippingDocuments)[0]?.products; let last = last"
|
||||
>
|
||||
<div class="card-wrapper products">
|
||||
<app-remission-details-product removePaddingLeftRight="true" [product]="product"></app-remission-details-product>
|
||||
<div
|
||||
class="container product-container"
|
||||
[ngClass]="{ last: last }"
|
||||
*ngFor="let product of shippingDocument?.products; let last = last"
|
||||
>
|
||||
<div class="card-wrapper products">
|
||||
<app-remission-details-product
|
||||
removePaddingLeftRight="true"
|
||||
[product]="product"
|
||||
></app-remission-details-product>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-remission-details-primary-cta
|
||||
[shippingDocument]="(remissionProcess?.shippingDocuments)[0]"
|
||||
[continueWithScan]="shouldScanToContinue((remissionProcess?.shippingDocuments)[0])"
|
||||
(action)="openRemission(remissionProcess)"
|
||||
></app-remission-details-primary-cta>
|
||||
<app-remission-details-primary-cta
|
||||
[shippingDocument]="shippingDocument"
|
||||
[continueWithScan]="shouldScanToContinue(shippingDocument)"
|
||||
(action)="openRemission(remissionProcess)"
|
||||
></app-remission-details-primary-cta>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
<app-remission-printer-selection #printModal (print)="print($event)"></app-remission-printer-selection>
|
||||
<app-remission-printer-selection
|
||||
#printModal
|
||||
(print)="print($event)"
|
||||
></app-remission-printer-selection>
|
||||
|
||||
<app-remission-confirm-delete-shipping-document
|
||||
#remissionConfirmDeleteDialog
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
catchError,
|
||||
take,
|
||||
withLatestFrom,
|
||||
switchMap,
|
||||
} from 'rxjs/operators';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { RemissionSelectors } from 'apps/sales/src/app/core/store/selectors/remission.selectors';
|
||||
@@ -69,6 +70,26 @@ export class RemissionDetailsComponent
|
||||
@ViewChild('scanner', { static: false })
|
||||
scannerComponent: RemissionContainerScannerScanditComponent;
|
||||
|
||||
get shippingDocument$(): Observable<ShippingDocument> {
|
||||
return this.getShippingDocumentId().pipe(
|
||||
switchMap((id) =>
|
||||
this.getRemissionProcess().pipe(
|
||||
map((remission) => {
|
||||
return remission.shippingDocuments.find(
|
||||
(document) => document.id === id
|
||||
);
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
get shippingDocumentCompleted$(): Observable<boolean> {
|
||||
return this.shippingDocument$.pipe(
|
||||
map((document) => document.isCompleted || document.isDeleted)
|
||||
);
|
||||
}
|
||||
|
||||
constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private store: Store,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<lib-icon class="icon" width="30px" name="Icon_Warenbegleitschein"></lib-icon>
|
||||
<lib-icon
|
||||
class="icon"
|
||||
width="30px"
|
||||
name="Icon_Warenbegleitschein"
|
||||
></lib-icon>
|
||||
<div class="header-item">
|
||||
<span class="title">Warenbegleitscheine</span>
|
||||
</div>
|
||||
|
||||
@@ -61,6 +61,14 @@ export class RemissionsOverviewComponent implements OnInit, OnDestroy {
|
||||
.subscribe(this.openDetailsPage);
|
||||
}
|
||||
|
||||
private getShippingDocument(remission: RemissionProcess) {
|
||||
return (
|
||||
(remission.shippingDocuments &&
|
||||
remission.shippingDocuments.find((sd) => !sd.isCompleted)) ||
|
||||
remission.shippingDocuments[0]
|
||||
);
|
||||
}
|
||||
|
||||
private openDetailsPage = (remissionProcess: RemissionProcess) => {
|
||||
const shippingDocumentId = this.getShippingDocumentId(remissionProcess);
|
||||
const shippingDocumentNumber = this.getShippingDocumentNumber(
|
||||
@@ -121,19 +129,19 @@ export class RemissionsOverviewComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
|
||||
private getShippingDocumentId = (remissionProcess: RemissionProcess) => {
|
||||
if (!remissionProcess.shippingDocuments[0]) {
|
||||
if (!this.getShippingDocument(remissionProcess)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return remissionProcess.shippingDocuments[0].id;
|
||||
return this.getShippingDocument(remissionProcess).id;
|
||||
};
|
||||
|
||||
private getShippingDocumentNumber = (remissionProcess: RemissionProcess) => {
|
||||
if (!remissionProcess.shippingDocuments[0]) {
|
||||
if (this.getShippingDocument(remissionProcess)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return remissionProcess.shippingDocuments[0].shippingDocumentNumber;
|
||||
return this.getShippingDocument(remissionProcess).shippingDocumentNumber;
|
||||
};
|
||||
|
||||
private getFormattedShippingDocumentNumber(
|
||||
|
||||
@@ -5,6 +5,9 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
})
|
||||
export class PackageNumberParserPipe implements PipeTransform {
|
||||
transform(packageNumber: string): string {
|
||||
if (!packageNumber) {
|
||||
return '';
|
||||
}
|
||||
if (packageNumber.length !== 18) {
|
||||
return packageNumber;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
})
|
||||
export class ShippingDocumentNumberFormatterPipe implements PipeTransform {
|
||||
transform(shippingDocumentNumber: string): string {
|
||||
if (!shippingDocumentNumber) {
|
||||
return '';
|
||||
}
|
||||
if (shippingDocumentNumber.length <= 18) {
|
||||
return shippingDocumentNumber;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user