Skip to main content

sunat_cpe_dart 1.0.0 copy "sunat_cpe_dart: ^1.0.0" to clipboard
sunat_cpe_dart: ^1.0.0 copied to clipboard

Umbrella package and intelligent CPE router for Peruvian Electronic Invoicing (SUNAT Direct SOL + 9 OSE/PSE adapters) in pure Dart.

sunat_cpe_dart #

Umbrella package and intelligent CPE router (SunatCpeRouter) for Peruvian Electronic Invoicing (SUNAT CPE) in pure Dart.

Allows applications and multi-tenant ERPs to dynamically route electronic documents between direct SUNAT emission (sunat_cpe_direct) and any of the 9 OSE/PSE providers (Nubefact, EFACT, Mifact, Bizlinks, Digiflow, Sovos, FacturaloPeru, TCI, Cavali).

Features #

  • Single Umbrella Import: Re-exports sunat_cpe_core, sunat_cpe_direct, and all 9 OSE/PSE adapters.
  • Content-Based Routing (routesByDocumentType): Route specific CpeDocumentType values to dedicated providers (e.g., send Invoices 01 and Boletas 03 via an OSE/PSE while sending Despatch Advices 09/31 directly to SUNAT's REST OAuth2 API via sunat_cpe_direct).
  • Circuit-Safe Fallback (fallbackProvider): Automatically fails over to a backup provider only when the document has not been registered (OseTransportException or SunatExceptionError codes 0100–1999), never on local validation errors or formal SUNAT business rejections (2000–3999).
  • Automatic Ticket Origin Tracking: Remembers which provider issued each asynchronous ticket (RC, RA, RR, 09, 31) so checkTicket and pollTicketUntilDone query the exact originating provider.
  • Declarative Factory (SunatProviderDescriptor & SunatProviderFactory): Instantiate single providers or full SunatCpeRouter topologies from typed descriptors.

Usage #

import 'package:sunat_cpe_dart/sunat_cpe_dart.dart';

void main() async {
  final router = SunatCpeRouter.fromDescriptors(
    primaryDescriptor: NubefactDescriptor(
      NubefactConfig(
        routeUri: Uri.parse('https://api.nubefact.com/api/v1/...'),
        apiToken: 'NUBEFACT_TOKEN',
      ),
    ),
    routeDescriptorsByDocumentType: {
      CpeDocumentType.guiaRemisionRemitente: DirectSunatDescriptor(
        SunatDirectConfig.beta(),
      ),
    },
  );

  // Invoices route to Nubefact; Despatch Advices route to SunatDirectProvider!
}
0
likes
0
points
675
downloads

Publisher

unverified uploader

Weekly Downloads

Umbrella package and intelligent CPE router for Peruvian Electronic Invoicing (SUNAT Direct SOL + 9 OSE/PSE adapters) in pure Dart.

Repository (GitHub)
View/report issues

Topics

#sunat #cpe #facturacion-electronica #ose #peru

License

unknown (license)

Dependencies

sunat_cpe_bizlinks, sunat_cpe_cavali, sunat_cpe_core, sunat_cpe_digiflow, sunat_cpe_direct, sunat_cpe_efact, sunat_cpe_facturaloperu, sunat_cpe_mifact, sunat_cpe_nubefact, sunat_cpe_sovos, sunat_cpe_tci

More

Packages that depend on sunat_cpe_dart