shipping and holder updates
This commit is contained in:
parent
127011b416
commit
912788b6c2
@ -57,8 +57,8 @@
|
||||
}
|
||||
|
||||
.table-container {
|
||||
// position: relative;
|
||||
// overflow-x: auto;
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
|
||||
.loading-shade {
|
||||
position: absolute;
|
||||
|
||||
@ -4,12 +4,24 @@
|
||||
<div class="section">
|
||||
<h3>Insurance & Bond</h3>
|
||||
<div class="checkbox-group">
|
||||
<mat-checkbox formControlName="needsBond">Do you need Bond from
|
||||
us?</mat-checkbox>
|
||||
<!-- <mat-checkbox formControlName="needsBond">Do you need Bond from
|
||||
us?</mat-checkbox> -->
|
||||
<mat-checkbox formControlName="needsInsurance">Do you need insurance for your
|
||||
goods?</mat-checkbox>
|
||||
<mat-checkbox formControlName="needsLostDocProtection">Do you need Lost document
|
||||
protection?</mat-checkbox>
|
||||
|
||||
<mat-form-field appearance="outline" class="formofsecurity">
|
||||
<mat-label>Form Of Security</mat-label>
|
||||
<mat-select formControlName="formOfSecurity" required>
|
||||
<mat-option *ngFor="let formOfSecurity of formOfSecurities" [value]="formOfSecurity.value">
|
||||
{{ formOfSecurity.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="shippingForm.get('formOfSecurity')?.errors?.['required']">
|
||||
Form Of Security is required
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -28,6 +28,11 @@
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
|
||||
.formofsecurity {
|
||||
margin-left: 1rem;
|
||||
min-width: 300px;
|
||||
}
|
||||
}
|
||||
|
||||
.radio-group {
|
||||
|
||||
@ -14,7 +14,7 @@ import { finalize, forkJoin, map, of, Subject, switchMap, takeUntil, throwError
|
||||
import { DeliveryType } from '../../core/models/delivery-type';
|
||||
import { DeliveryMethod } from '../../core/models/delivery-method';
|
||||
import { PaymentType } from '../../core/models/payment-type';
|
||||
import { format, addDays, isAfter, isWeekend, addBusinessDays } from 'date-fns';
|
||||
import { format, isAfter, isWeekend, addBusinessDays } from 'date-fns';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ShippingContact } from '../../core/models/carnet/shipping-contact';
|
||||
import { ShippingAddress } from '../../core/models/carnet/shipping-address';
|
||||
@ -23,6 +23,7 @@ import { HolderService } from '../../core/services/carnet/holder.service';
|
||||
import { Holder } from '../../core/models/carnet/holder';
|
||||
import { NavigationService } from '../../core/services/common/navigation.service';
|
||||
import { StorageService } from '../../core/services/common/storage.service';
|
||||
import { FormOfSecurity } from '../../core/models/formofsecurity';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shipping',
|
||||
@ -56,6 +57,7 @@ export class ShippingComponent {
|
||||
showContactForm = false;
|
||||
deliveryEstimate: string = '';
|
||||
holderid: number = 0;
|
||||
holder: Holder | undefined | null = null;
|
||||
|
||||
countriesHasStates = ['US', 'CA', 'MX'];
|
||||
countries: Country[] = [];
|
||||
@ -63,6 +65,9 @@ export class ShippingComponent {
|
||||
deliveryTypes: DeliveryType[] = [];
|
||||
deliveryMethods: DeliveryMethod[] = [];
|
||||
paymentTypes: PaymentType[] = [];
|
||||
formOfSecurities: FormOfSecurity[] = [];
|
||||
govFormOfSecurities: FormOfSecurity[] = [];
|
||||
nonGovFormOfSecurities: FormOfSecurity[] = [];
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
@ -75,9 +80,10 @@ export class ShippingComponent {
|
||||
|
||||
constructor() {
|
||||
this.shippingForm = this.fb.group({
|
||||
needsBond: [false],
|
||||
// needsBond: [false],
|
||||
needsInsurance: [false],
|
||||
needsLostDocProtection: [false],
|
||||
formOfSecurity: ['', Validators.required],
|
||||
shipTo: ['PREPARER', Validators.required],
|
||||
address: this.fb.group({
|
||||
companyName: [''],
|
||||
@ -118,6 +124,7 @@ export class ShippingComponent {
|
||||
this.loadDeliveryTypes();
|
||||
this.loadDeliveryMethods();
|
||||
this.loadPaymentTypes();
|
||||
this.loadFormOfSecurities();
|
||||
|
||||
if (this.headerid) {
|
||||
this.loadShippingData();
|
||||
@ -300,6 +307,20 @@ export class ShippingComponent {
|
||||
});
|
||||
}
|
||||
|
||||
loadFormOfSecurities(): void {
|
||||
this.commonService.getFormOfSecurities(0)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe({
|
||||
next: (fos) => {
|
||||
this.govFormOfSecurities = fos.filter(f => f.isGov);
|
||||
this.nonGovFormOfSecurities = fos.filter(f => !f.isGov);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to load form of securities', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadShippingData(): void {
|
||||
this.isLoading = true;
|
||||
|
||||
@ -309,6 +330,9 @@ export class ShippingComponent {
|
||||
return of(undefined);
|
||||
}
|
||||
|
||||
this.holder = holder;
|
||||
this.formOfSecurities = holder.holderType?.trim() === 'GOV' ? this.govFormOfSecurities : this.nonGovFormOfSecurities;
|
||||
|
||||
return forkJoin({
|
||||
holderContacts: this.shippingService.getHolderContactsById(holder.holderid),
|
||||
holderAddress: this.shippingService.getHolderAddressById(holder.holderid),
|
||||
@ -360,9 +384,10 @@ export class ShippingComponent {
|
||||
|
||||
patchShippingData(shipping: Shipping): void {
|
||||
this.shippingForm.patchValue({
|
||||
needsBond: shipping.needsBond,
|
||||
// needsBond: shipping.needsBond,
|
||||
needsInsurance: shipping.needsInsurance,
|
||||
needsLostDocProtection: shipping.needsLostDocProtection,
|
||||
formOfSecurity: shipping.formOfSecurity,
|
||||
shipTo: shipping.shipTo,
|
||||
deliveryType: shipping.deliveryType,
|
||||
deliveryMethod: shipping.deliveryMethod,
|
||||
@ -378,6 +403,14 @@ export class ShippingComponent {
|
||||
this.onDeliveryMethodChange(shipping.deliveryMethod);
|
||||
}
|
||||
|
||||
let formOfSecurityControl = this.shippingForm.get('formOfSecurity');
|
||||
if (this.holder?.holderType.trim() === 'GOV') {
|
||||
formOfSecurityControl?.setValue(this.govFormOfSecurities?.[0].value);
|
||||
formOfSecurityControl?.disable();
|
||||
} else {
|
||||
formOfSecurityControl?.enable();
|
||||
}
|
||||
|
||||
this.calculateDeliveryEstimate();
|
||||
this.updateShippingValidation(shipping.shipTo);
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background-color: var(--mat-sys-primary);
|
||||
background: var(--mat-sys-primary);
|
||||
}
|
||||
|
||||
.footer-links {
|
||||
@ -48,6 +48,16 @@
|
||||
color: #000000;
|
||||
background: #ffffff;
|
||||
|
||||
.footer-content {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.footer-links {
|
||||
a {
|
||||
color: #000000;
|
||||
|
||||
@ -5,7 +5,7 @@ export interface Holder {
|
||||
holderNumber: string;
|
||||
holderType: string;
|
||||
uscibMember: boolean;
|
||||
govAgency: boolean;
|
||||
govAgency?: boolean;
|
||||
address1: string;
|
||||
address2: string;
|
||||
city: string;
|
||||
|
||||
@ -3,9 +3,10 @@ import { ShippingContact } from "./shipping-contact";
|
||||
|
||||
export interface Shipping {
|
||||
// Insurance details
|
||||
needsBond: boolean;
|
||||
// needsBond: boolean;
|
||||
needsInsurance: boolean;
|
||||
needsLostDocProtection: boolean;
|
||||
formOfSecurity: string;
|
||||
|
||||
// Shipping details
|
||||
shipTo: string;
|
||||
|
||||
6
src/app/core/models/formofsecurity.ts
Normal file
6
src/app/core/models/formofsecurity.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface FormOfSecurity {
|
||||
name: string;
|
||||
id: string;
|
||||
value: string;
|
||||
isGov: boolean;
|
||||
}
|
||||
@ -7,7 +7,7 @@ export interface BasicDetail {
|
||||
holderNumber: string;
|
||||
holderType: string;
|
||||
uscibMember: boolean;
|
||||
govAgency: boolean;
|
||||
govAgency?: boolean;
|
||||
address1: string;
|
||||
address2: string;
|
||||
city: string;
|
||||
|
||||
@ -26,7 +26,7 @@ export class HolderService {
|
||||
holderNumber: holder.HOLDERNO,
|
||||
holderType: holder.HOLDERTYPE,
|
||||
uscibMember: holder.USCIBMEMBERFLAG === 'Y',
|
||||
govAgency: holder.GOVAGENCYFLAG === 'Y',
|
||||
// govAgency: holder.GOVAGENCYFLAG === 'Y',
|
||||
holderName: holder.HOLDERNAME,
|
||||
//NAMEQUALIFIER: holder.NAMEQUALIFIER || null,
|
||||
dbaName: holder.ADDLNAME || null,
|
||||
|
||||
@ -31,9 +31,10 @@ export class ShippingService {
|
||||
courierAccount: shippingDetails.CUSTCOURIERNO,
|
||||
paymentMethod: shippingDetails.PAYMENTMETHOD,
|
||||
|
||||
needsBond: shippingDetails.INSPROTECTION === 'Y',
|
||||
needsInsurance: shippingDetails.LDIPROTECTION === 'Y',
|
||||
needsLostDocProtection: shippingDetails.LDIPROTECTION === 'Y'
|
||||
//needsBond: shippingDetails.BONDPROTECTION === 'Y',
|
||||
needsInsurance: shippingDetails.INSPROTECTION === 'Y',
|
||||
needsLostDocProtection: shippingDetails.LDIPROTECTION === 'Y',
|
||||
formOfSecurity: shippingDetails.FORMOFSECURITY
|
||||
};
|
||||
|
||||
shippingData.address = {
|
||||
@ -74,9 +75,10 @@ export class ShippingService {
|
||||
P_CUSTCOURIERNO: shippingData.courierAccount,
|
||||
P_PAYMENTMETHOD: shippingData.paymentMethod,
|
||||
|
||||
P_FORMOFSECURITY: shippingData.needsBond ? 'Y' : 'N',
|
||||
// P_BONDPROTECTION: shippingData.needsBond ? 'Y' : 'N',
|
||||
P_INSPROTECTION: shippingData.needsInsurance ? 'Y' : 'N',
|
||||
P_LDIPROTECTION: shippingData.needsLostDocProtection ? 'Y' : 'N',
|
||||
P_FORMOFSECURITY: shippingData.formOfSecurity,
|
||||
|
||||
P_SHIPNAME: shippingData.address?.companyName,
|
||||
P_ADDRESS1: shippingData.address?.address1 || null,
|
||||
|
||||
@ -15,6 +15,7 @@ import { Country } from '../../models/country';
|
||||
import { UnitOfMeasure } from '../../models/unitofmeasure';
|
||||
import { DeliveryMethod } from '../../models/delivery-method';
|
||||
import { PaymentType } from '../../models/payment-type';
|
||||
import { FormOfSecurity } from '../../models/formofsecurity';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -189,6 +190,19 @@ export class CommonService {
|
||||
);
|
||||
}
|
||||
|
||||
getFormOfSecurities(spid: number = 0): Observable<FormOfSecurity[]> {
|
||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=016&P_SPID=0`).pipe(
|
||||
map((response) =>
|
||||
response.map((item) => ({
|
||||
name: item.PARAMDESC,
|
||||
id: item.PARAMID,
|
||||
value: item.PARAMVALUE,
|
||||
isGov: item.ADDLPARAMVALUE1 === 'GOV',
|
||||
}))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
formatUSDate(datetime: Date): string {
|
||||
const date = new Date(datetime);
|
||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
||||
|
||||
@ -28,7 +28,7 @@ export class BasicDetailService {
|
||||
holderNumber: basicDetails.HOLDERNO,
|
||||
holderType: basicDetails.HOLDERTYPE,
|
||||
uscibMember: basicDetails.USCIBMEMBERFLAG === 'Y',
|
||||
govAgency: basicDetails.GOVAGENCYFLAG === 'Y',
|
||||
// govAgency: basicDetails.GOVAGENCYFLAG === 'Y',
|
||||
holderName: basicDetails.HOLDERNAME,
|
||||
//NAMEQUALIFIER: basicDetails.NAMEQUALIFIER || null,
|
||||
dbaName: basicDetails.ADDLNAME || null,
|
||||
@ -48,7 +48,7 @@ export class BasicDetailService {
|
||||
P_HOLDERNO: data.holderNumber,
|
||||
P_HOLDERTYPE: data.holderType,
|
||||
P_USCIBMEMBERFLAG: data.uscibMember ? 'Y' : 'N',
|
||||
P_GOVAGENCYFLAG: data.govAgency ? 'Y' : 'N',
|
||||
P_GOVAGENCYFLAG: 'N',
|
||||
P_HOLDERNAME: data.holderName,
|
||||
P_NAMEQUALIFIER: null,
|
||||
P_ADDLNAME: data.dbaName,
|
||||
@ -72,7 +72,7 @@ export class BasicDetailService {
|
||||
P_HOLDERNO: data.holderNumber,
|
||||
P_HOLDERTYPE: data.holderType,
|
||||
P_USCIBMEMBERFLAG: data.uscibMember ? 'Y' : 'N',
|
||||
P_GOVAGENCYFLAG: data.govAgency ? 'Y' : 'N',
|
||||
P_GOVAGENCYFLAG: 'N',
|
||||
P_HOLDERNAME: data.holderName,
|
||||
P_NAMEQUALIFIER: null,
|
||||
P_ADDLNAME: data.dbaName,
|
||||
|
||||
@ -38,7 +38,7 @@ export class HolderService {
|
||||
holderNumber: holderDetail.HOLDERNO,
|
||||
holderType: holderDetail.HOLDERTYPE,
|
||||
uscibMember: holderDetail.USCIBMEMBERFLAG === 'Y',
|
||||
govAgency: holderDetail.GOVAGENCYFLAG === 'Y',
|
||||
// govAgency: holderDetail.GOVAGENCYFLAG === 'Y',
|
||||
holderName: holderDetail.HOLDERNAME,
|
||||
//: holderDetail.NAMEQUALIFIER,
|
||||
dbaName: holderDetail.ADDLNAME,
|
||||
|
||||
@ -57,11 +57,11 @@
|
||||
<mat-radio-button [value]="true">Yes</mat-radio-button>
|
||||
<mat-radio-button [value]="false">No</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
<mat-radio-group formControlName="govAgency" class="radio-group">
|
||||
<!-- <mat-radio-group formControlName="govAgency" class="radio-group">
|
||||
<mat-label>Are you belong to Government Agency ?</mat-label>
|
||||
<mat-radio-button [value]="true">Yes</mat-radio-button>
|
||||
<mat-radio-button [value]="false">No</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
</mat-radio-group> -->
|
||||
</div>
|
||||
|
||||
<!-- Address Information -->
|
||||
|
||||
@ -60,7 +60,7 @@ export class BasicDetailComponent implements OnInit, OnDestroy {
|
||||
holderNumber: ['', [Validators.required, Validators.maxLength(20)]],
|
||||
holderType: ['', [Validators.required, Validators.maxLength(20)]],
|
||||
uscibMember: [false, [Validators.required]],
|
||||
govAgency: [false, [Validators.required]],
|
||||
// govAgency: [false, [Validators.required]],
|
||||
address1: ['', [Validators.required, Validators.maxLength(100)]],
|
||||
address2: ['', Validators.maxLength(100)],
|
||||
city: ['', [Validators.required, Validators.maxLength(50)]],
|
||||
@ -156,7 +156,7 @@ export class BasicDetailComponent implements OnInit, OnDestroy {
|
||||
holderNumber: data.holderNumber,
|
||||
holderType: data.holderType,
|
||||
uscibMember: data.uscibMember,
|
||||
govAgency: data.govAgency,
|
||||
// govAgency: data.govAgency,
|
||||
address1: data.address1,
|
||||
address2: data.address2,
|
||||
city: data.city,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user