diff --git a/src/app/carnet/goods/goods.component.html b/src/app/carnet/goods/goods.component.html index ac395f4..edd35f2 100644 --- a/src/app/carnet/goods/goods.component.html +++ b/src/app/carnet/goods/goods.component.html @@ -86,7 +86,7 @@ Weight - {{ formatDecimalDisplay(item.weight, 4) }} + {{ item.weight | number:'1.2-2' }} @@ -240,6 +240,14 @@
+ +
+
+ Total Goods Value: + {{totalGoodsValue | currency}} +
+
+
+ + Did you misplace your carnet? + Yes + No + +
+ +
- Did you loose your carnet? Are you looking for + Are you looking for duplicates? Yes No @@ -102,6 +110,16 @@ {{ item.carnetNumber }} + + Delivery Type + {{ item.deliveryType }} + + + + Security Type + {{ item.securityType }} + + US Sets {{ item.usSets }} @@ -147,11 +165,6 @@ Actions
- @@ -175,23 +188,11 @@ print Print GL - -
diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index c1bd6fb..d95b819 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -23,6 +23,7 @@ import { BorDialogComponent } from './bor-dialog.component'; import { FormsModule } from '@angular/forms'; import { CarnetService } from '../core/services/carnet/carnet.service'; import { CopyCarnetDialogComponent } from './copy-carnet-dialog.component'; +import { UserService } from '../core/services/common/user.service'; @Component({ selector: 'app-home', @@ -35,8 +36,10 @@ export class HomeComponent { carnetData: any[] = []; isLoading = false; showTable = false; + duplicateQuestion: boolean = false; userPreferences: UserPreferences; carnetStatuses: CarnetStatus[] = []; + currentCarnetStatus: any = {}; // table filter variables selectedColumn: string = ''; @@ -45,6 +48,8 @@ export class HomeComponent { { value: 'applicationName', displayName: 'Application Name' }, { value: 'holderName', displayName: 'Holder Name' }, { value: 'carnetNumber', displayName: 'Carnet Number' }, + { value: 'deliveryType', displayName: 'Delivery Type' }, + { value: 'securityType', displayName: 'Security Type' }, { value: 'usSets', displayName: 'US Sets' }, { value: 'foreignSets', displayName: 'Foreign Sets' }, { value: 'transitSets', displayName: 'Transit Sets' }, @@ -67,7 +72,7 @@ export class HomeComponent { this.dataSource.sort = value; } - displayedColumns: string[] = ['applicationName', 'holderName', 'carnetNumber', 'usSets', 'foreignSets', 'transitSets', 'carnetValue', 'issueDate', 'expiryDate', 'orderType', 'carnetStatus', 'actions']; + displayedColumns: string[] = ['applicationName', 'holderName', 'carnetNumber', 'deliveryType', 'securityType', 'usSets', 'foreignSets', 'transitSets', 'carnetValue', 'issueDate', 'expiryDate', 'orderType', 'carnetStatus', 'actions']; private homeService = inject(HomeService); private carnetService = inject(CarnetService); @@ -75,6 +80,7 @@ export class HomeComponent { private notificationService = inject(NotificationService); private commonService = inject(CommonService); private navigationService = inject(NavigationService); + private userService = inject(UserService); private dialog = inject(MatDialog); constructor(userPrefenceService: UserPreferencesService) { @@ -103,6 +109,12 @@ export class HomeComponent { next: (data) => { this.carnetData = data; this.isLoading = false; + + if (!this.currentCarnetStatus?.spid) { + this.defaultCarnetStatusData(); + } else { + this.onCarnetStatusClick(this.currentCarnetStatus); + } }, error: (error) => { console.error('Error loading carnet data:', error); @@ -115,13 +127,15 @@ export class HomeComponent { this.isLoading = true; this.showTable = false; + this.currentCarnetStatus = event; + // Clear any existing filters when loading new data this.clearFilter(); this.homeService.getCarnetDataByStatus(event.spid, event.carnetStatus).subscribe({ next: (carnetDetails) => { this.isLoading = false; - this.showTable = true; + this.showTable = carnetDetails.length > 0; this.dataSource.data = carnetDetails; this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; @@ -138,6 +152,20 @@ export class HomeComponent { }); } + defaultCarnetStatusData(): void { + // if the carnet data has record with the status 'P' (not submitted), then load that data + const inProgressData = this.carnetData?.[0]?.CARNETSTATUS?.includes('P'); + if (inProgressData) { + let spid = this.carnetData[0].SPID ?? this.userService.getUserSpid(); + var carentData = { + spid: spid, + carnetStatus: 'P' + } + + this.onCarnetStatusClick(carentData); + } + } + exportData() { try { // Prepare worksheet data @@ -164,6 +192,8 @@ export class HomeComponent { 'Application Name': item.applicationName, 'Holder Name': item.holderName, 'Carnet Number': item.carnetNumber, + 'Delivery Type': item.deliveryType, + 'Security Type': item.securityType, 'US Sets': item.usSets, 'Foreign Sets': item.foreignSets, 'Transit Sets': item.transitSets, @@ -216,6 +246,10 @@ export class HomeComponent { } } + toggleDuplicateQuestion(event: MatRadioChange): void { + this.duplicateQuestion = event.value; + } + duplicateCarnet(event: MatRadioChange): void { if (event.value) { const dialogRef = this.dialog.open(CarnetDialogComponent, { @@ -313,16 +347,7 @@ export class HomeComponent { editCarnet(item: any): void { if (item && item.headerid) { - let route: string = 'edit-carnet'; - if (item.orderType === 'DUPLICATE') { - route = 'duplicate-carnet'; - } - else if (item.orderType === 'REPLACE') { - route = 'extend-carnet'; - } else if (item.orderType === 'REORDER') { - route = 'additional-sets'; - } - + let route: string = this.editActionRoute(item); this.navigateTo([route, item.headerid], { queryParams: { applicationname: item.applicationName } }); @@ -400,11 +425,11 @@ export class HomeComponent { } } - copyCarnet(headerid: number): void { - if (headerid) { + copyCarnet(item: any): void { + if (item && item.headerid) { const dialogRef = this.dialog.open(CopyCarnetDialogComponent, { width: '500px', - data: { headerid: headerid }, + data: { headerid: item.headerid }, }); dialogRef.afterClosed().subscribe(data => { @@ -412,8 +437,9 @@ export class HomeComponent { this.carnetService.copyCarnet(data.headerid, data.applicationName).subscribe({ next: (applicationData: any) => { this.notificationService.showSuccess('Carnet copied successfully'); - this.navigateTo(['edit-carnet', applicationData.HEADERID], { - queryParams: { applicationname: applicationData.APPLICATIONNAME } + let route: string = this.editActionRoute(item); + this.navigateTo([route, data.headerid], { + queryParams: { applicationname: data.applicationName } }); }, error: (error) => { @@ -523,4 +549,21 @@ export class HomeComponent { document.body.removeChild(a); // Clean up window.URL.revokeObjectURL(url); } + + private editActionRoute(item: any): string { + let route: string = 'edit-carnet'; + + if (item && item.orderType) { + if (item.orderType === 'DUPLICATE') { + route = 'duplicate-carnet'; + } + else if (item.orderType === 'REPLACE') { + route = 'extend-carnet'; + } else if (item.orderType === 'REORDER') { + route = 'additional-sets'; + } + } + + return route; + } } \ No newline at end of file