shipping preparer holder updates
This commit is contained in:
parent
dbc4bc523f
commit
e4e4679bd5
@ -15,7 +15,8 @@
|
|||||||
<mat-step *ngIf="applicationType === 'new'" [completed]="stepsCompleted.holderSelection"
|
<mat-step *ngIf="applicationType === 'new'" [completed]="stepsCompleted.holderSelection"
|
||||||
[editable]="stepsCompleted.applicationDetail">
|
[editable]="stepsCompleted.applicationDetail">
|
||||||
<ng-template matStepLabel>Holder Selection</ng-template>
|
<ng-template matStepLabel>Holder Selection</ng-template>
|
||||||
<app-holder (completed)="onHolderSelectionSaved($event)" [headerid]="headerid">
|
<app-holder (completed)="onHolderSelectionSaved($event)" [headerid]="headerid"
|
||||||
|
(updated)="onHolderSelectionUpdated($event)">
|
||||||
</app-holder>
|
</app-holder>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
@ -39,7 +40,8 @@
|
|||||||
<!-- Shipping & Payment Step -->
|
<!-- Shipping & Payment Step -->
|
||||||
<mat-step [completed]="stepsCompleted.shipping" [editable]="stepsCompleted.applicationDetail">
|
<mat-step [completed]="stepsCompleted.shipping" [editable]="stepsCompleted.applicationDetail">
|
||||||
<ng-template matStepLabel>Shipping & Payment</ng-template>
|
<ng-template matStepLabel>Shipping & Payment</ng-template>
|
||||||
<app-shipping (completed)="onShippingSaved($event)" [headerid]="headerid">
|
<app-shipping (completed)="onShippingSaved($event)" [headerid]="headerid"
|
||||||
|
[refreshShippingData]="refreshShippingData">
|
||||||
</app-shipping>
|
</app-shipping>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
</mat-stepper>
|
</mat-stepper>
|
||||||
|
|||||||
@ -26,6 +26,7 @@ export class AddCarnetComponent {
|
|||||||
isEditMode = false;
|
isEditMode = false;
|
||||||
headerid: number = 0;
|
headerid: number = 0;
|
||||||
userPreferences: UserPreferences;
|
userPreferences: UserPreferences;
|
||||||
|
refreshShippingData: boolean = false;
|
||||||
|
|
||||||
// Track completion of each step
|
// Track completion of each step
|
||||||
stepsCompleted = {
|
stepsCompleted = {
|
||||||
@ -54,6 +55,10 @@ export class AddCarnetComponent {
|
|||||||
this.stepsCompleted.holderSelection = completed;
|
this.stepsCompleted.holderSelection = completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onHolderSelectionUpdated(updated: boolean): void {
|
||||||
|
this.refreshShippingData = updated;
|
||||||
|
}
|
||||||
|
|
||||||
onGoodsSectionSaved(completed: boolean): void {
|
onGoodsSectionSaved(completed: boolean): void {
|
||||||
this.stepsCompleted.goodsSection = completed;
|
this.stepsCompleted.goodsSection = completed;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
[editable]="stepsCompleted.applicationDetail">
|
[editable]="stepsCompleted.applicationDetail">
|
||||||
<ng-template matStepLabel>Holder Selection</ng-template>
|
<ng-template matStepLabel>Holder Selection</ng-template>
|
||||||
<app-holder (completed)="onHolderSelectionSaved($event)" [headerid]="headerid"
|
<app-holder (completed)="onHolderSelectionSaved($event)" [headerid]="headerid"
|
||||||
[applicationName]="applicationName">
|
[applicationName]="applicationName" (updated)="onHolderSelectionUpdated($event)">
|
||||||
</app-holder>
|
</app-holder>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
@ -40,7 +40,8 @@
|
|||||||
<!-- Shipping & Payment Step -->
|
<!-- Shipping & Payment Step -->
|
||||||
<mat-step [completed]="stepsCompleted.shipping" [editable]="stepsCompleted.applicationDetail">
|
<mat-step [completed]="stepsCompleted.shipping" [editable]="stepsCompleted.applicationDetail">
|
||||||
<ng-template matStepLabel>Shipping & Payment</ng-template>
|
<ng-template matStepLabel>Shipping & Payment</ng-template>
|
||||||
<app-shipping (completed)="onShippingSaved($event)" [headerid]="headerid" [isEditMode]="isEditMode">
|
<app-shipping (completed)="onShippingSaved($event)" [headerid]="headerid" [isEditMode]="isEditMode"
|
||||||
|
[refreshShippingData]="refreshShippingData">
|
||||||
</app-shipping>
|
</app-shipping>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
</mat-stepper>
|
</mat-stepper>
|
||||||
|
|||||||
@ -27,6 +27,7 @@ export class EditCarnetComponent {
|
|||||||
headerid: number = 0;
|
headerid: number = 0;
|
||||||
userPreferences: UserPreferences;
|
userPreferences: UserPreferences;
|
||||||
applicationName: string = '';
|
applicationName: string = '';
|
||||||
|
refreshShippingData: boolean = false;
|
||||||
|
|
||||||
// Track completion of each step
|
// Track completion of each step
|
||||||
stepsCompleted = {
|
stepsCompleted = {
|
||||||
@ -68,6 +69,10 @@ export class EditCarnetComponent {
|
|||||||
this.stepsCompleted.goodsSection = completed;
|
this.stepsCompleted.goodsSection = completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onHolderSelectionUpdated(updated: boolean): void {
|
||||||
|
this.refreshShippingData = updated;
|
||||||
|
}
|
||||||
|
|
||||||
onTravelPlanSaved(completed: boolean): void {
|
onTravelPlanSaved(completed: boolean): void {
|
||||||
this.stepsCompleted.travelPlan = completed;
|
this.stepsCompleted.travelPlan = completed;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ export class HolderComponent {
|
|||||||
@Input() userPreferences: UserPreferences = {};
|
@Input() userPreferences: UserPreferences = {};
|
||||||
@Input() isEditMode: boolean = false;
|
@Input() isEditMode: boolean = false;
|
||||||
@Output() completed = new EventEmitter<boolean>();
|
@Output() completed = new EventEmitter<boolean>();
|
||||||
|
@Output() updated = new EventEmitter<boolean>();
|
||||||
|
|
||||||
selectedHolderId: number = 0;
|
selectedHolderId: number = 0;
|
||||||
|
|
||||||
@ -45,5 +46,6 @@ export class HolderComponent {
|
|||||||
|
|
||||||
onHolderSelectionSaved(completed: boolean): void {
|
onHolderSelectionSaved(completed: boolean): void {
|
||||||
this.completed.emit(completed);
|
this.completed.emit(completed);
|
||||||
|
this.updated.emit(true); // to update dependent data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,18 @@
|
|||||||
<div *ngIf="showAddressForm" class="address-form" formGroupName="address">
|
<div *ngIf="showAddressForm" class="address-form" formGroupName="address">
|
||||||
<h4>Shipping Address</h4>
|
<h4>Shipping Address</h4>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<mat-form-field appearance="outline" class="companyName">
|
||||||
|
<mat-label>Company Name</mat-label>
|
||||||
|
<input matInput formControlName="companyName" required>
|
||||||
|
<mat-error *ngIf="shippingForm.get('address.companyName')?.errors?.['required']">
|
||||||
|
Address is required
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="shippingForm.get('address.companyName')?.errors?.['maxlength']">
|
||||||
|
Maximum 100 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
<!-- Address Information -->
|
<!-- Address Information -->
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<mat-form-field appearance="outline" class="address1">
|
<mat-form-field appearance="outline" class="address1">
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component, EventEmitter, inject, Input, Output } from '@angular/core';
|
import { Component, EventEmitter, inject, Input, Output, SimpleChanges } from '@angular/core';
|
||||||
import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { NotificationService } from '../../core/services/common/notification.service';
|
import { NotificationService } from '../../core/services/common/notification.service';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
@ -31,6 +31,7 @@ import { Holder } from '../../core/models/carnet/holder';
|
|||||||
export class ShippingComponent {
|
export class ShippingComponent {
|
||||||
@Input() headerid: number = 0;
|
@Input() headerid: number = 0;
|
||||||
@Input() isEditMode = false;
|
@Input() isEditMode = false;
|
||||||
|
@Input() refreshShippingData = false;
|
||||||
@Output() completed = new EventEmitter<boolean>();
|
@Output() completed = new EventEmitter<boolean>();
|
||||||
|
|
||||||
private fb = inject(FormBuilder);
|
private fb = inject(FormBuilder);
|
||||||
@ -72,6 +73,7 @@ export class ShippingComponent {
|
|||||||
needsLostDocProtection: [false],
|
needsLostDocProtection: [false],
|
||||||
shipTo: ['PREPARER', Validators.required],
|
shipTo: ['PREPARER', Validators.required],
|
||||||
address: this.fb.group({
|
address: this.fb.group({
|
||||||
|
companyName: [''],
|
||||||
address1: [''],
|
address1: [''],
|
||||||
address2: [''],
|
address2: [''],
|
||||||
city: [''],
|
city: [''],
|
||||||
@ -110,7 +112,7 @@ export class ShippingComponent {
|
|||||||
this.loadDeliveryMethods();
|
this.loadDeliveryMethods();
|
||||||
this.loadPaymentTypes();
|
this.loadPaymentTypes();
|
||||||
|
|
||||||
if (this.headerid && this.isEditMode) {
|
if (this.headerid) {
|
||||||
this.loadShippingData();
|
this.loadShippingData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,6 +174,12 @@ export class ShippingComponent {
|
|||||||
this.shippingForm.get('address.zip')?.updateValueAndValidity();
|
this.shippingForm.get('address.zip')?.updateValueAndValidity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if (changes['refreshShippingData'] && this.headerid > 0) {
|
||||||
|
this.loadShippingData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editAddressForm(): void {
|
editAddressForm(): void {
|
||||||
this.showAddressForm = true;
|
this.showAddressForm = true;
|
||||||
let shipTo = this.shippingForm.get('shipTo')?.value;
|
let shipTo = this.shippingForm.get('shipTo')?.value;
|
||||||
@ -369,6 +377,7 @@ export class ShippingComponent {
|
|||||||
|
|
||||||
addressGroup.patchValue({
|
addressGroup.patchValue({
|
||||||
addressid: shipping.address?.addressid,
|
addressid: shipping.address?.addressid,
|
||||||
|
companyName: shipping.address?.companyName,
|
||||||
address1: shipping.address?.address1,
|
address1: shipping.address?.address1,
|
||||||
address2: shipping.address?.address2,
|
address2: shipping.address?.address2,
|
||||||
city: shipping.address?.city,
|
city: shipping.address?.city,
|
||||||
@ -399,7 +408,9 @@ export class ShippingComponent {
|
|||||||
|
|
||||||
if (shipTo === '3RDPARTY') {
|
if (shipTo === '3RDPARTY') {
|
||||||
Object.keys(addressGroup.controls).forEach(key => {
|
Object.keys(addressGroup.controls).forEach(key => {
|
||||||
if (key === 'address1') {
|
if (key === 'companyName') {
|
||||||
|
addressGroup.get(key)?.setValidators([Validators.required, Validators.maxLength(100)]);
|
||||||
|
} else if (key === 'address1') {
|
||||||
addressGroup.get(key)?.setValidators([Validators.required, Validators.maxLength(100)]);
|
addressGroup.get(key)?.setValidators([Validators.required, Validators.maxLength(100)]);
|
||||||
} else if (key === 'address2') {
|
} else if (key === 'address2') {
|
||||||
addressGroup.get(key)?.setValidators([Validators.maxLength(100)]);
|
addressGroup.get(key)?.setValidators([Validators.maxLength(100)]);
|
||||||
@ -450,13 +461,13 @@ export class ShippingComponent {
|
|||||||
let shipTo = this.shippingForm.get('shipTo')?.value;
|
let shipTo = this.shippingForm.get('shipTo')?.value;
|
||||||
|
|
||||||
if (shipTo === 'PREPARER' && this.preparerAddress) {
|
if (shipTo === 'PREPARER' && this.preparerAddress) {
|
||||||
return `${this.preparerAddress.address1},
|
return `${this.preparerAddress.companyName}, ${this.preparerAddress.address1},
|
||||||
${this.preparerAddress.city}, ${this.preparerAddress.state}, ${this.preparerAddress.zip},
|
${this.preparerAddress.city}, ${this.preparerAddress.state}, ${this.preparerAddress.zip},
|
||||||
${this.preparerAddress.country}`;
|
${this.preparerAddress.country}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shipTo === 'HOLDER' && this.holderAddress) {
|
if (shipTo === 'HOLDER' && this.holderAddress) {
|
||||||
return `${this.holderAddress.address1},
|
return `${this.holderAddress.companyName}, ${this.holderAddress.address1},
|
||||||
${this.holderAddress.city}, ${this.holderAddress.state}, ${this.holderAddress.zip},
|
${this.holderAddress.city}, ${this.holderAddress.state}, ${this.holderAddress.zip},
|
||||||
${this.holderAddress.country}`;
|
${this.holderAddress.country}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
export interface ShippingAddress {
|
export interface ShippingAddress {
|
||||||
|
companyName: string;
|
||||||
addressid: number;
|
addressid: number;
|
||||||
address1: string;
|
address1: string;
|
||||||
address2?: string | null;
|
address2?: string | null;
|
||||||
|
|||||||
@ -38,6 +38,7 @@ export class ShippingService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
shippingData.address = {
|
shippingData.address = {
|
||||||
|
companyName: shippingDetails.P_SHIPNAME,
|
||||||
addressid: shippingDetails.SHIPADDRESSID,
|
addressid: shippingDetails.SHIPADDRESSID,
|
||||||
address1: shippingDetails.ADDRESS1,
|
address1: shippingDetails.ADDRESS1,
|
||||||
address2: shippingDetails.ADDRESS2,
|
address2: shippingDetails.ADDRESS2,
|
||||||
@ -74,11 +75,11 @@ export class ShippingService {
|
|||||||
P_CUSTCOURIERNO: shippingData.courierAccount,
|
P_CUSTCOURIERNO: shippingData.courierAccount,
|
||||||
P_PAYMENTMETHOD: shippingData.paymentMethod,
|
P_PAYMENTMETHOD: shippingData.paymentMethod,
|
||||||
|
|
||||||
|
|
||||||
P_FORMOFSECURITY: shippingData.needsBond ? 'Y' : 'N',
|
P_FORMOFSECURITY: shippingData.needsBond ? 'Y' : 'N',
|
||||||
P_INSPROTECTION: shippingData.needsInsurance ? 'Y' : 'N',
|
P_INSPROTECTION: shippingData.needsInsurance ? 'Y' : 'N',
|
||||||
P_LDIPROTECTION: shippingData.needsLostDocProtection ? 'Y' : 'N',
|
P_LDIPROTECTION: shippingData.needsLostDocProtection ? 'Y' : 'N',
|
||||||
|
|
||||||
|
P_SHIPNAME: shippingData.address?.companyName,
|
||||||
P_ADDRESS1: shippingData.address?.address1 || null,
|
P_ADDRESS1: shippingData.address?.address1 || null,
|
||||||
P_ADDRESS2: shippingData.address?.address2 || null,
|
P_ADDRESS2: shippingData.address?.address2 || null,
|
||||||
P_CITY: shippingData.address?.city || null,
|
P_CITY: shippingData.address?.city || null,
|
||||||
@ -142,7 +143,8 @@ export class ShippingService {
|
|||||||
|
|
||||||
private mapToAddress(address: any): ShippingAddress {
|
private mapToAddress(address: any): ShippingAddress {
|
||||||
return {
|
return {
|
||||||
addressid: address.SHIPADDRESSID,
|
companyName: address.NAMEOF ?? address.HOLDERNAME,
|
||||||
|
addressid: address.LOCATIONID ?? address.LOCATIONID,
|
||||||
address1: address.ADDRESS1,
|
address1: address.ADDRESS1,
|
||||||
address2: address.ADDRESS2,
|
address2: address.ADDRESS2,
|
||||||
city: address.CITY,
|
city: address.CITY,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user