118 lines
3.6 KiB
TypeScript
118 lines
3.6 KiB
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { inject, Injectable } from '@angular/core';
|
|
import { Observable, map } from 'rxjs';
|
|
import { environment } from '../../../../environments/environment';
|
|
import { UserService } from '../common/user.service';
|
|
import { Fees } from '../../models/carnet/fee';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class CarnetService {
|
|
private apiUrl = environment.apiUrl;
|
|
private apiDb = environment.apiDb;
|
|
|
|
private http = inject(HttpClient);
|
|
private userService = inject(UserService);
|
|
|
|
getEstimatedFees(headerid: number): Observable<Fees> {
|
|
return this.http.get<any>(`${this.apiUrl}/${this.apiDb}/EstimatedFees/${this.userService.getUserSpid()}/${this.userService.getUser()}/${headerid}`).pipe(
|
|
map(response => this.mapToFeesData(response)));
|
|
}
|
|
|
|
private mapToFeesData(estimatedFeesDetails: any): Fees {
|
|
let estimatedFeesData: Fees = {
|
|
basicFee: estimatedFeesDetails.BASICFEE,
|
|
counterFoilFee: estimatedFeesDetails.CFFEE,
|
|
continuationSheetFee: estimatedFeesDetails.CSFEE,
|
|
expeditedFee: estimatedFeesDetails.EFFEE,
|
|
shippingFee: estimatedFeesDetails.SHIPFEE,
|
|
bondPremium: estimatedFeesDetails.BONDPREMIUM,
|
|
cargoPremium: estimatedFeesDetails.CARGOPREMIUM,
|
|
ldiPremium: estimatedFeesDetails.LDIPREMIUM,
|
|
};
|
|
|
|
return estimatedFeesData;
|
|
}
|
|
|
|
submitApplication(headerid: number): Observable<any> {
|
|
|
|
let appData = {
|
|
P_SPID: this.userService.getUserSpid(),
|
|
P_USERID: this.userService.getUser(),
|
|
P_HEADERID: headerid
|
|
}
|
|
|
|
return this.http.post<any>(`${this.apiUrl}/${this.apiDb}/TransmitApplicationtoProcess`, appData);
|
|
}
|
|
|
|
processApplication(headerid: number): Observable<any> {
|
|
|
|
let appData = {
|
|
// P_SPID: this.userService.getUserSpid(),
|
|
P_USERID: this.userService.getUser(),
|
|
P_HEADERID: headerid
|
|
}
|
|
|
|
return this.http.patch<any>(`${this.apiUrl}/${this.apiDb}//ProcessCarnet`, appData);
|
|
}
|
|
|
|
deleteCarnet(headerid: number): Observable<any> {
|
|
const data = {
|
|
P_USERID: this.userService.getUser(),
|
|
P_HEADERID: headerid
|
|
}
|
|
return this.http.delete(`${this.apiUrl}/${this.apiDb}/DeleteCarnet`, { body: data });
|
|
}
|
|
|
|
printCarnet(headerid: number): Observable<any> {
|
|
const data = {
|
|
P_SPID: this.userService.getUserSpid(),
|
|
P_HEADERID: headerid,
|
|
P_PRINTGL: 'N'
|
|
}
|
|
return this.http.post(`${this.apiUrl}/${this.apiDb}/PrintCarnet`, data);
|
|
}
|
|
|
|
printGeneralList(headerid: number): Observable<any> {
|
|
const data = {
|
|
P_SPID: this.userService.getUserSpid(),
|
|
P_HEADERID: headerid
|
|
}
|
|
return this.http.post(`${this.apiUrl}/${this.apiDb}/PrintGL`, data);
|
|
}
|
|
|
|
duplicateCarnet(carnetNumber: string): Observable<any> {
|
|
const data = {
|
|
P_USERID: this.userService.getUser(),
|
|
P_CARNETNO: carnetNumber
|
|
}
|
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/DuplicateCarnet`, data);
|
|
}
|
|
|
|
extendCarnet(carnetNumber: string): Observable<any> {
|
|
const data = {
|
|
P_USERID: this.userService.getUser(),
|
|
P_CARNETNO: carnetNumber
|
|
}
|
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/ExtendCarnet`, data);
|
|
}
|
|
|
|
additionalSets(carnetNumber: string): Observable<any> {
|
|
const data = {
|
|
P_USERID: this.userService.getUser(),
|
|
P_CARNETNO: carnetNumber
|
|
}
|
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/AddlSets`, data);
|
|
}
|
|
|
|
copyCarnet(headerid: number, applicationName: string): Observable<any> {
|
|
const data = {
|
|
P_USERID: this.userService.getUser(),
|
|
P_HEADERID: headerid,
|
|
P_APPLICATIONNAME: applicationName
|
|
}
|
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/CopyCarnet`, data);
|
|
}
|
|
}
|