mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
#907 Upgrade von Kundenkonto nur auf Onlinekonto
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { StringDictionary } from '@cmf/core';
|
||||
import { InputDTO, OptionDTO, StringDictionary } from '@cmf/core';
|
||||
import { BuyerResult, CheckoutDTO, OLAAvailabilityDTO, PayerDTO, ShippingAddressDTO, ShoppingCartDTO } from '@swagger/checkout';
|
||||
import { CustomerDTO, PayerDTO as CrmPayerDTO, ShippingAddressDTO as CrmShippingAddressDTO } from '@swagger/crm';
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -61,7 +61,7 @@ export class CheckoutService {
|
||||
canSetCustomer(
|
||||
processId: number,
|
||||
customer: CustomerDTO
|
||||
): Observable<{ ok?: boolean; filter?: StringDictionary<string>; message?: string }> {
|
||||
): Observable<{ ok?: boolean; filter?: StringDictionary<string>; message?: string; create?: InputDTO[] }> {
|
||||
throw new Error('Not Implemented');
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { CheckoutService } from '@domain/checkout';
|
||||
import { AddressHelper, AssignedPayerHelper, CrmCustomerService } from '@domain/crm';
|
||||
import { CustomerDTO, KeyValueDTOOfStringAndString } from '@swagger/crm';
|
||||
import { UiDebugModalComponent, UiModalService } from '@ui/modal';
|
||||
import { isArray } from '@utils/common';
|
||||
import { ShippingAddressHelper } from 'apps/domain/crm/src/lib/helpers/shipping-address.helper';
|
||||
import { Observable } from 'rxjs';
|
||||
import { first, map, shareReplay, switchMap, tap } from 'rxjs/operators';
|
||||
@@ -147,11 +148,22 @@ export class CustomerDetailsComponent implements OnInit {
|
||||
// Check if customer can be added to the checkout
|
||||
const canSetCustomer = await this.checkoutService.canSetCustomer(this.application.activatedProcessId, customer).toPromise();
|
||||
if (!canSetCustomer.ok) {
|
||||
let canBeExtendedTo = await this.customerDetailsService.canUpgrade(customer.id).toPromise();
|
||||
|
||||
if (isArray(canBeExtendedTo)) {
|
||||
canBeExtendedTo = canBeExtendedTo.filter((f) => !f.startsWith('!'));
|
||||
} else {
|
||||
canBeExtendedTo = [];
|
||||
}
|
||||
|
||||
this.modal.open({
|
||||
content: CantAddCustomerToCartModalComponent,
|
||||
data: {
|
||||
filter: canSetCustomer.filter,
|
||||
message: canSetCustomer.message,
|
||||
canBeExtendedTo,
|
||||
customerId: customer.id,
|
||||
create: canSetCustomer.create,
|
||||
} as CantAddCustomerToCartData,
|
||||
});
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
|
||||
<div class="cta-wrapper">
|
||||
<a class="search-btn" [routerLink]="['/customer/search']" [queryParams]="ref.data.filter" (click)="ref.close()">Zur Kundensuche</a>
|
||||
<a class="create-btn" [routerLink]="['/customer/create', createCustomerType]" (click)="ref.close()">Kundendaten erfassen</a>
|
||||
<a
|
||||
class="create-btn"
|
||||
[routerLink]="['/customer/create', createCustomerType]"
|
||||
(click)="ref.close()"
|
||||
[queryParams]="{ upgradeCustomerId: upgradable ? ref.data.customerId : '' }"
|
||||
>Kundendaten erfassen</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { UiModalRef } from '@ui/modal';
|
||||
import { isArray } from '@utils/common';
|
||||
import { CantAddCustomerToCartData } from './cant-add-customer-to-cart.data';
|
||||
|
||||
@Component({
|
||||
@@ -16,5 +17,21 @@ export class CantAddCustomerToCartModalComponent {
|
||||
return '';
|
||||
}
|
||||
|
||||
constructor(public ref: UiModalRef<CantAddCustomerToCartData>) {}
|
||||
get upgradable(): boolean {
|
||||
return (
|
||||
isArray(this.ref?.data?.canBeExtendedTo) &&
|
||||
!!this.ref?.data?.canBeExtendedTo?.length &&
|
||||
this.extendableTo.some((s) => this.customerTypes.includes(s))
|
||||
);
|
||||
}
|
||||
|
||||
get extendableTo() {
|
||||
return this.ref.data.canBeExtendedTo.reduce((agg, v) => [...agg, ...v.split(';')], []);
|
||||
}
|
||||
|
||||
get customerTypes() {
|
||||
return this.ref.data.create.options.values.map((v) => v.value);
|
||||
}
|
||||
|
||||
constructor(public ref: UiModalRef<any, CantAddCustomerToCartData>) {}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { StringDictionary } from '@cmf/core';
|
||||
import { InputDTO, StringDictionary } from '@cmf/core';
|
||||
|
||||
export interface CantAddCustomerToCartData {
|
||||
message: string;
|
||||
filter: StringDictionary<string>;
|
||||
create: InputDTO;
|
||||
canBeExtendedTo: string[];
|
||||
customerId: number;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const routes: Routes = [
|
||||
{ path: 'debug', loadChildren: () => import('./modules/debug/debug.module').then((m) => m.DebugModule) },
|
||||
{ path: 'goodsin', loadChildren: () => import('./modules/goods-in/goods-in.module').then((m) => m.GoodsInModule) },
|
||||
{ path: 'remission', loadChildren: () => import('./modules/remission/remission-client.module').then((m) => m.RemissionClientModule) },
|
||||
// { path: 'task-calendar', loadChildren: './modules/task-calendar/task-calendar.module#TaskCalendarModule'}
|
||||
{ path: 'task-calendar', loadChildren: () => import('./modules/task-calendar/task-calendar.module').then((m) => m.TaskCalendarModule) },
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -9,6 +9,7 @@ import { EffectsModule } from '@ngrx/effects';
|
||||
import { SearchEffects } from './store/customer';
|
||||
import { HistoryEffects } from '@shelf-store/history';
|
||||
import { DetailsEffects } from '@shelf-store/details';
|
||||
import { TaskCalendarEffects } from './store/branch';
|
||||
|
||||
// TODO: In Service Speichern
|
||||
export function storeInLocalStorage(reducer: ActionReducer<any>): ActionReducer<any> {
|
||||
@@ -32,7 +33,7 @@ export const metaReducers: MetaReducer<RootState>[] = !environment.production ?
|
||||
@NgModule({
|
||||
imports: [
|
||||
StoreModule.forRoot(rootReducer, { metaReducers }),
|
||||
EffectsModule.forRoot([SearchEffects, HistoryEffects, DetailsEffects]),
|
||||
EffectsModule.forRoot([SearchEffects, HistoryEffects, DetailsEffects, TaskCalendarEffects]),
|
||||
StoreDevtoolsModule.instrument({ name: 'ISA Ngrx Store' }),
|
||||
],
|
||||
})
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
<span class="branch-menu-item branch-disabled">Abholfach</span>
|
||||
</ng-template>
|
||||
</div>
|
||||
<div class="menu-item-grid align-center active">
|
||||
<div class="menu-item-grid align-center active" (click)="routeToMenu('/task-calendar/calendar', 'calendar')">
|
||||
<div>
|
||||
<lib-icon
|
||||
class="menu-icon"
|
||||
|
||||
@@ -227,7 +227,7 @@ export class GoodsInArticleDetailsComponent implements OnInit, OnDestroy {
|
||||
.then((receiptList: ReceiptListItemDTO[]) => {
|
||||
if (receiptList && receiptList.length > 0) {
|
||||
this.showPayment = true;
|
||||
const receipt = receiptList[0];
|
||||
const receipt = receiptList[0] as any;
|
||||
this._article.receiptNumber = receipt.receiptNumber;
|
||||
this._article.receiptType = receiptType[receipt.receiptType];
|
||||
if (receipt.printedDate) {
|
||||
|
||||
@@ -220,7 +220,7 @@ export class ShelfArticleDetailsComponent implements OnInit, OnDestroy {
|
||||
.toPromise()
|
||||
.then((receiptList: ReceiptListItemDTO[]) => {
|
||||
if (receiptList && receiptList.length > 0) {
|
||||
const receipt = receiptList[0];
|
||||
const receipt = receiptList[0] as any;
|
||||
this._article.receiptNumber = receipt.receiptNumber;
|
||||
this._article.receiptType = receiptType[receipt.receiptType];
|
||||
if (receipt.printedDate) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { StringDictionary } from '@cmf/core';
|
||||
import { InputDTO, OptionDTO, StringDictionary } from '@cmf/core';
|
||||
import { CartService } from '@domain/cart';
|
||||
import { CheckoutService } from '@domain/checkout';
|
||||
import { Store } from '@ngxs/store';
|
||||
@@ -117,7 +117,7 @@ export class CheckoutRefactImp implements CheckoutService {
|
||||
canSetCustomer(
|
||||
processId: number,
|
||||
customer: CustomerDTO
|
||||
): Observable<{ ok?: boolean; filter?: StringDictionary<string>; message?: string }> {
|
||||
): Observable<{ ok?: boolean; filter?: StringDictionary<string>; message?: string; create?: InputDTO[] }> {
|
||||
const cartId$ = this.cartService.getCartId(processId).pipe(first());
|
||||
|
||||
const customerFeatures: StringDictionary<string> = {};
|
||||
@@ -135,7 +135,8 @@ export class CheckoutRefactImp implements CheckoutService {
|
||||
ok: response.result.ok,
|
||||
filter: response.result.queryToken?.filter || {},
|
||||
message: response.message,
|
||||
} as { ok?: boolean; filter?: StringDictionary<string>; message?: string })
|
||||
create: response.result.create,
|
||||
} as { ok?: boolean; filter?: StringDictionary<string>; message?: string; create?: InputDTO[] })
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user