import { ENVIRONMENT } from '../networking'; import { P12ReaderData } from '../P12Reader'; import { AuthToken, CheckDocumentStatusParams, CommercialApprovalResponse, DocumentStatusResult, InvoiceResponse, ServiceDirectoryResponse, SummaryTrackingStatusResponse, VoidNCFResponse } from '../networking/types'; declare class ECF { private _api; private _p12ReaderData; constructor(p12ReaderData: P12ReaderData, environment?: ENVIRONMENT, accessToken?: string); /** * Authentication againt DGII or Buyers * @param buyerHost optional - If buyerHost is defined the authentication will be againt the buyer HOST to stablish the communication Sender<->Receiver * @returns string Bearer Token */ authenticate: (buyerHost?: string) => Promise; /** * Send the signed invoice to DGII * @param signedXml XML signed invoice * @param fileName the composition of the file name should be RNC+e-NCF.xml example: “101672919E3100000001.xml” * @param buyerHost optional - If buyerHost is defined the authentication will be againt the buyer HOST to stablish the communication Sender<->Receiver * @returns */ sendElectronicDocument: (signedXml: string, fileName: string, buyerHost?: string) => Promise; /** * Send summary for invoice < 250K pesos * @param signedXml * @param fileName * @returns */ sendSummary: (signedXml: string, fileName: string) => Promise; /** * Get the status using the track id generated after send a new invoice or other document * @param trackId string * @returns promise with the tracking status */ statusTrackId: (trackId: string) => Promise; /** * Servicio web responsable de responder la validez o estado de un e‐CF a un receptor o * incluso a un emisor, a través de la presentación del RNC emisor, e‐NCF y dos campos * condicionales a la vigencia del comprobante, RNC Comprador y el código de seguridad. * * NOTE: Only works for me for intake invoice with security code * @param rncEmisor * @param ncfElectronico * @param rncComprador * @param codigoSeguridad * @returns */ inquiryStatus: (rncEmisor: string, ncfElectronico: string, rncComprador?: string, codigoSeguridad?: string) => Promise; /** * Get all tracking * @param rncEmisor * @param encf * @returns */ trackStatuses: (rncEmisor: string, encf: string) => Promise; /** * Checks whether DGII already received an e-NCF, choosing the right service * for the way the document was sent. Use it before retrying a submission * whose response was lost: resending a document DGII already received * returns `Rechazado`. * * 1. `ConsultaTrackIds` (RNC emisor + e-NCF): every document sent with * `sendElectronicDocument`, including e-CF 32 >= RD$250,000. When the * e-NCF was sent more than once, an accepted submission wins over later * rejected resends, and `En Proceso` wins over `Rechazado`. * 2. `ConsultaEstado` (`inquiryStatus`): RFCE summaries (e-CF 32 < * RD$250,000), which never get a trackId. * * Pass `montoTotal` when you know it: the method then asks only the service * that can answer (see `isSummaryInvoice`), one request instead of two for * a summary. Without it, ConsultaTrackIds is asked first and ConsultaEstado * is only used for an `E32` e-NCF it does not know, when `codigoSeguridad` * is given. A blank or non-numeric `montoTotal` counts as not given. * * A document DGII has no record of resolves to `No encontrado` instead of * throwing; other errors (authentication, network, missing RNC comprador) * are thrown as `DgiiApiError`. * * @throws Error when `montoTotal` marks an RFCE summary and * `codigoSeguridad` is missing: the summary cannot be found without it. * @returns The overall status, the deciding trackId, and the raw responses */ checkDocumentStatus: (params: CheckDocumentStatusParams) => Promise; /** `checkDocumentStatus` through ConsultaTrackIds (RNC emisor + e-NCF). */ private checkTrackIdsStatus; /** `checkDocumentStatus` through ConsultaEstado, for RFCE summaries. */ private checkSummaryStatus; /** * Gets the service directory entries for an RNC. * * The DGII directory service is inconsistent about the response shape: some * environments/records return an array of directory entries while others return a * single entry object (see PR #24). This method always resolves to an array so * consumers never have to branch on the response shape, preserving the existing * `ServiceDirectoryResponse[]` contract. * * @param rnc Customer RNC to look up * @returns The service directory entries, or `undefined` when the service returns no body */ getCustomerDirectory: (rnc: string) => Promise; /** * Consulta de Resumen de Factura (RFCE) * Servicio web responsable de responder la validez o estado de un ENCF a un receptor o * incluso a un emisor, a través de la presentación del RNC emisor, e‐NCF y el código de seguridad. * >>>>>>>>>>>>>> ONLY AVAILABLE ON PRODUCTION ENVIRONEMNT <<<<<<<<<<<<<<< * @param rnc_emisor * @param encf * @param cod_seguridad_eCF * @returns */ getSummaryInvoiceInquiry: (rnc_emisor: string, encf: string, cod_seguridad_eCF: string) => Promise; /** * Servicio web responsable de recibir aprobaciones comerciales emitidas por * contribuyentes receptores, la cual consiste en la conformidad con una transacción * llevada a cabo entre dos contribuyentes y de la cual se recibió un comprobante * electrónico de un emisor. * @param signedXml * @param fileName * @returns */ sendCommercialApproval: (signedXml: string, fileName: string) => Promise; /** * Servicio web responsable de recibir y anular los rangos de secuencias no utilizados * (e‐NCF) a través de un XML de solicitud que contiene el código de comprobante * electrónico, una serie de rangos, desde y hasta, así como un token asociado a una * sesión válida. * @param signedXml * @param fileName * @returns */ voidENCF: (signedXml: string, fileName: string) => Promise; } export default ECF;