2026-05-01 19:45:30 +03:30
|
|
|
import { IPaginatedResponse } from '@/core/models/service.model';
|
2026-05-17 12:04:11 +03:30
|
|
|
import { ISaleInvoiceFullResponse } from '@/domains/consumer/models';
|
|
|
|
|
import { ISaleInvoiceFullRawResponse } from '@/shared/components/invoices/sale-invoice-full-response.model';
|
2026-05-01 19:45:30 +03:30
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
import { POS_SALE_INVOICES_API_ROUTES } from '../constants';
|
|
|
|
|
import {
|
|
|
|
|
IPosSaleInvoiceFiscalActionResponse,
|
|
|
|
|
IPosSaleInvoiceFiscalAttemptsResponse,
|
|
|
|
|
IPosSaleInvoiceFiscalStatusResponse,
|
2026-05-03 16:08:26 +03:30
|
|
|
IPosSaleInvoicesFilterDto,
|
2026-05-01 19:45:30 +03:30
|
|
|
IPosSaleInvoicesSummaryRawResponse,
|
|
|
|
|
IPosSaleInvoicesSummaryResponse,
|
|
|
|
|
} from '../models';
|
|
|
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
|
|
|
export class PosSaleInvoicesService {
|
|
|
|
|
constructor(private http: HttpClient) {}
|
|
|
|
|
|
|
|
|
|
private apiRoutes = POS_SALE_INVOICES_API_ROUTES;
|
|
|
|
|
|
2026-05-03 16:08:26 +03:30
|
|
|
getAll(
|
|
|
|
|
query: IPosSaleInvoicesFilterDto = {},
|
|
|
|
|
): Observable<IPaginatedResponse<IPosSaleInvoicesSummaryResponse>> {
|
2026-05-01 19:45:30 +03:30
|
|
|
return this.http.get<IPaginatedResponse<IPosSaleInvoicesSummaryRawResponse>>(
|
|
|
|
|
this.apiRoutes.list(),
|
|
|
|
|
{ params: query as Record<string, string | number | boolean> },
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getSingle(invoiceId: string): Observable<ISaleInvoiceFullResponse> {
|
|
|
|
|
return this.http.get<ISaleInvoiceFullRawResponse>(this.apiRoutes.single(invoiceId));
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 18:08:57 +03:30
|
|
|
sendToTsp(invoiceId: string): Observable<IPosSaleInvoiceFiscalActionResponse> {
|
2026-05-03 16:08:26 +03:30
|
|
|
return this.http.post<IPosSaleInvoiceFiscalActionResponse>(
|
2026-05-08 18:08:57 +03:30
|
|
|
this.apiRoutes.tsp.send(invoiceId),
|
2026-05-03 16:08:26 +03:30
|
|
|
{},
|
|
|
|
|
);
|
2026-05-01 19:45:30 +03:30
|
|
|
}
|
|
|
|
|
|
2026-05-08 18:08:57 +03:30
|
|
|
retrySendToTsp(invoiceId: string): Observable<IPosSaleInvoiceFiscalActionResponse> {
|
2026-05-03 16:08:26 +03:30
|
|
|
return this.http.post<IPosSaleInvoiceFiscalActionResponse>(
|
2026-05-08 18:08:57 +03:30
|
|
|
this.apiRoutes.tsp.retry(invoiceId),
|
2026-05-03 16:08:26 +03:30
|
|
|
{},
|
|
|
|
|
);
|
2026-05-01 19:45:30 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getFiscalStatus(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
2026-05-08 18:08:57 +03:30
|
|
|
return this.http.get<IPosSaleInvoiceFiscalStatusResponse>(this.apiRoutes.tsp.status(invoiceId));
|
2026-05-01 19:45:30 +03:30
|
|
|
}
|
|
|
|
|
|
2026-05-03 16:08:26 +03:30
|
|
|
getInquiry(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
|
|
|
|
return this.http.get<IPosSaleInvoiceFiscalStatusResponse>(
|
2026-05-08 18:08:57 +03:30
|
|
|
this.apiRoutes.tsp.getInquiry(invoiceId),
|
2026-05-01 19:45:30 +03:30
|
|
|
{},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-04 20:02:10 +03:30
|
|
|
revoke(invoiceId: string): Observable<IPosSaleInvoiceFiscalStatusResponse> {
|
|
|
|
|
return this.http.post<IPosSaleInvoiceFiscalStatusResponse>(
|
2026-05-08 18:08:57 +03:30
|
|
|
this.apiRoutes.tsp.revoke(invoiceId),
|
2026-05-04 20:02:10 +03:30
|
|
|
{},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-01 19:45:30 +03:30
|
|
|
getFiscalAttempts(invoiceId: string): Observable<IPosSaleInvoiceFiscalAttemptsResponse> {
|
2026-05-03 16:08:26 +03:30
|
|
|
return this.http.get<IPosSaleInvoiceFiscalAttemptsResponse>(
|
2026-05-08 18:08:57 +03:30
|
|
|
this.apiRoutes.tsp.attempts(invoiceId),
|
2026-05-03 16:08:26 +03:30
|
|
|
);
|
2026-05-01 19:45:30 +03:30
|
|
|
}
|
|
|
|
|
}
|