Project

General

Profile

1
import { environment } from 'src/environments/environment';
2
import { Injectable } from '@angular/core';
3
import { GenericRestService } from './generic-rest.service';
4
import { LookupData } from '../models/lookup-data.interface';
5
import { HttpClient } from '@angular/common/http';
6
import { Observable, of, } from 'rxjs';
7
import { FullInvoiceProcess } from '../models/full-invoice-process.interface';
8
import { InvoiceProcess } from '../models/invoice-process.interface';
9
import { AlteryxUnhandledData } from '../models/alteryx-unhandled-data.interface';
10
import { InvoiceMasterData } from '../models/invoice-master-data.interface';
11
import { SentStringInterface } from '../models/sentString.interface';
12
import {JournalEntry} from "../models/journal-entry.interface";
13
import {AlteryxException} from "../models/alteryx-exception.interface";
14
import {ProcessFailedRecord} from "../models/process-failed-record.interface";
15
import {ProcessHistory} from "../models/process-history.interface";
16

    
17
@Injectable({
18
  providedIn: 'root'
19
})
20
export class InvoiceProcessesService extends GenericRestService<InvoiceProcess> {
21

    
22
  constructor(private http: HttpClient) {
23
    super(`${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}/processes`, http);
24
  }
25

    
26
  getAllStatuses(): Observable<LookupData> {
27
    return this.http.get<LookupData>(this.baseUrl + '/process-status/all');
28
  }
29

    
30
  getAllFileTypes(): Observable<string[]> {
31
    return of(['XL', 'PDF', 'DOCX']);
32
  }
33

    
34
  getFullInvoiceProcessById(invoiceProcessId: number): Observable<FullInvoiceProcess> {
35
    return this.http.get<FullInvoiceProcess>(this.baseUrl + '/full/' + invoiceProcessId.toString());
36
  }
37

    
38
  getIframe(invoiceProcessId: string): Observable<string> {
39
    return this.http.get<string>(
40
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}/abbyy` + '/verify/' + invoiceProcessId.toString());
41
  }
42

    
43
  getAssignToUsersDistinct(username: string): Observable<string[]> {
44
    return this.http.get<string[]>(
45
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}/processes/search-username/` + username.toString());
46
  }
47

    
48
  reclassifyRecords(id: string, selectedClassification: any, selectedSubClassification: any): Observable<InvoiceMasterData> {
49
    return this.http.post<any>(
50
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
51
      '/alteryx/reclassify/' + id, '', {
52
      params: {
53
        docClassificationId: selectedClassification,
54
        docSubClassificationId: selectedSubClassification
55
      }
56
    });
57
  }
58

    
59
  recalculateException(id: number): Observable<any> {
60
    return this.http.post<any>(
61
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
62
      '/alteryx/recalculate-exception/' + id, ''
63
    );
64
  }
65

    
66
  updateVerificationCompletedForProcess(id: number): Observable<any> {
67
    return this.http.get(
68
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
69
      '/abbyy/verification-completed/' + id
70
    );
71
  }
72

    
73
  downloadFile(id: number): Observable<string> {
74
    return this.http.get(
75
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
76
      '/processes/download-file/' + id, { responseType: 'text' }
77
    );
78
  }
79

    
80
  assignProcess(id: number, name: string): any {
81
    return this.http.put(
82
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
83
      '/processes/assign-process?processId=' + id + '&username=' + name, '', {responseType: 'text'}
84
    );
85
  }
86

    
87
  unassignProcess(id: number): any {
88
    return this.http.put(
89
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
90
      '/processes/assign-process?processId=' + id, '', {responseType: 'text'}
91
    );
92
  }
93

    
94
  refreshJournalEntries(processId: number): Observable<JournalEntry[]> {
95
    return this.http.get<JournalEntry[]>(
96
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
97
      '/processes/refresh-journal/' + processId
98
    );
99
  }
100

    
101
  refreshAlteryxExceptions(processId: number): Observable<AlteryxException[]> {
102
    return this.http.get<AlteryxException[]>(
103
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
104
      '/processes/refresh-alteryx-exceptions/' + processId
105
    );
106
  }
107

    
108
  refreshAlteryxUnhandled(processId: number): Observable<AlteryxUnhandledData[]> {
109
    return this.http.get<AlteryxUnhandledData[]>(
110
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
111
      '/processes/refresh-alteryx-unhandled/' + processId
112
    );
113
  }
114

    
115
  sendProcessToAlteryxRecalculation(id: number): any {
116
    return this.http.put(
117
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
118
      '/processes/send-to-alteryx-recalculation/' + id , '', {responseType: 'text'}
119
    );
120
  }
121

    
122
  sendProcessToAbbyyVerification(id: number): any {
123
    return this.http.put(
124
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
125
      '/processes/send-to-abbyy-verification/' + id , '' , {responseType: 'text'}
126
    );
127
  }
128

    
129
  setProcessCanceled(id: number): any {
130
    return this.http.put(
131
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
132
      '/processes/set-canceled/' + id , '' , {responseType: 'text'}
133
    );
134
  }
135

    
136
  setProcessCompleted(id: number): any {
137
    return this.http.put(
138
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
139
      '/processes/set-completed/' + id , '' , {responseType: 'text'}
140
    );
141
  }
142

    
143
  getProcessHistory(processId: number): Observable<ProcessHistory[]> {
144
    return this.http.get<ProcessHistory[]>(
145
      `${environment.baseApiUrl}${environment.apiUrl.documentsProcessesWs}` +
146
      '/processes/process-history/' + processId
147
    );
148
  }
149
}
(15-15/21)