mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Ten EIMS_SELLER_* env vars were the only source of EDR's own seller identity, duplicating data the platform already has via the same e-Trade lookup used for every customer company at onboarding. EimsSellerCacheService now enriches it — but static config remains the source of truth: MoR validates SellerDetails against its own taxpayer registry (rule 7017, already cleared against the current static values), so e-Trade fills a field only when the static value is blank, never overrides one already confirmed. The static config is therefore the durable fallback, not the cache; an in-memory snapshot lost on restart is harmless. ETradeService has no request timeout of its own and no AbortController, so the cache enforces one locally (stops waiting, doesn't cancel the request) and de-duplicates concurrent refresh() calls into the same in-flight promise. getSellerDetails() is fully synchronous — zero I/O — so live registration never depends on e-Trade being reachable, at boot or per invoice. VatNumber and Email stay on static config permanently — confirmed by reading e-Trade's actual response shapes, neither field exists anywhere in what it returns. Region/Wereda/City reuse the existing EIMS_BUYER_*_CODES maps rather than adding seller-specific ones — the geography is objective, not buyer-specific. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
64 lines
2.8 KiB
TypeScript
64 lines
2.8 KiB
TypeScript
import { HttpModule } from "@nestjs/axios";
|
|
import { Module } from "@nestjs/common";
|
|
import { TypeOrmModule } from "@nestjs/typeorm";
|
|
|
|
import { Invoice } from "../billing/entities/invoice.entity";
|
|
import { DocumentsModule } from "../billing/documents/documents.module";
|
|
import { CompaniesModule } from "../companies/companies.module";
|
|
import { NotificationInboxModule } from "../notification-inbox/notification-inbox.module";
|
|
import { NotificationsModule } from "../notifications/notifications.module";
|
|
import { EimsAuthService } from "./eims-auth.service";
|
|
import { EimsAutoSubmitService } from "./eims-auto-submit.service";
|
|
import { EimsCancellationService } from "./eims-cancellation.service";
|
|
import { EimsClientService } from "./eims-client.service";
|
|
import { EimsCredentialsProvider } from "./eims-credentials.provider";
|
|
import { EimsInvoiceController } from "./eims-invoice.controller";
|
|
import { EimsInvoiceRegistrationService } from "./eims-invoice-registration.service";
|
|
import { EimsReceiptService } from "./eims-receipt.service";
|
|
import { EimsSellerCacheService } from "./eims-seller-cache.service";
|
|
import { EimsSignerService } from "./eims-signer.service";
|
|
import { EimsReceipt } from "./entities/eims-receipt.entity";
|
|
import { EimsSystemState } from "./entities/eims-system-state.entity";
|
|
|
|
/**
|
|
* MoR EIMS e-invoicing: signed transport, authentication, and manual single-invoice registration.
|
|
*
|
|
* Exports only what other modules will consume; the credential loader and signer stay internal so
|
|
* the private key has exactly one user. Nothing here is called from invoice creation.
|
|
*/
|
|
@Module({
|
|
imports: [
|
|
HttpModule.register({ timeout: Number(process.env.EIMS_HTTP_TIMEOUT_MS) || 30_000 }),
|
|
TypeOrmModule.forFeature([EimsSystemState, Invoice, EimsReceipt]),
|
|
NotificationInboxModule,
|
|
NotificationsModule,
|
|
// For EimsReceiptService.document() — the shared sealed invoice/receipt PDF layout. No domain
|
|
// deps of its own (StampSettingsService/LogoSettingsService are both @Global), so no cycle.
|
|
DocumentsModule,
|
|
// For EimsSellerCacheService's ETradeService — CompaniesModule has a forwardRef cycle with
|
|
// ShippingLineCompaniesModule -> BillingModule, but nothing in that chain imports EimsModule,
|
|
// so this stays a plain one-directional import, not a new cycle.
|
|
CompaniesModule,
|
|
],
|
|
controllers: [EimsInvoiceController],
|
|
providers: [
|
|
EimsCredentialsProvider,
|
|
EimsSignerService,
|
|
EimsAuthService,
|
|
EimsClientService,
|
|
EimsInvoiceRegistrationService,
|
|
EimsAutoSubmitService,
|
|
EimsCancellationService,
|
|
EimsReceiptService,
|
|
EimsSellerCacheService,
|
|
],
|
|
exports: [
|
|
EimsAuthService,
|
|
EimsClientService,
|
|
EimsInvoiceRegistrationService,
|
|
EimsCancellationService,
|
|
EimsReceiptService,
|
|
],
|
|
})
|
|
export class EimsModule {}
|