Files
edr-platform/apps/edr-freight-api/src/modules/shipping-lines/shipping-line-companies.module.ts
2026-08-13 18:56:52 +00:00

60 lines
2.8 KiB
TypeScript

import { Module, forwardRef } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { User } from "@tria-plc/iamapi-common/entities/iam/user/user.entity";
import { FreightAuthModule } from "../auth/freight-auth.module";
import { BillingModule } from "../billing/billing.module";
import { Booking } from "../bookings/entities/booking.entity";
import { OtpModule } from "../otp/otp.module";
import { ShippingLineCompany } from "./entities/shipping-line-company.entity";
import { ShippingLineCredit } from "./entities/shipping-line-credit.entity";
import { ShippingLineInvoiceApproval } from "./entities/shipping-line-invoice-approval.entity";
import { ShippingLineInvoiceApprovalsRepository } from "./shipping-line-invoice-approvals.repository";
import { ShippingLineBookingsController } from "./shipping-line-bookings.controller";
import { ShippingLineBookingsService } from "./shipping-line-bookings.service";
import { ShippingLineCompaniesController } from "./shipping-line-companies.controller";
import { ShippingLineCompaniesRepository } from "./shipping-line-companies.repository";
import { ShippingLineCompaniesService } from "./shipping-line-companies.service";
import { ShippingLineCreditsController } from "./shipping-line-credits.controller";
import { ShippingLineCreditsRepository } from "./shipping-line-credits.repository";
import { ShippingLineCreditsService } from "./shipping-line-credits.service";
@Module({
imports: [
// Booking is registered here only so this module can create shipping-line
// rows in `freight.bookings`; the customer BookingsModule is untouched.
TypeOrmModule.forFeature([
ShippingLineCompany,
ShippingLineCredit,
ShippingLineInvoiceApproval,
User,
Booking,
]),
// CustomerResetService — activation links reuse the staff-triggered reset path.
FreightAuthModule,
OtpModule,
// Credits are billed by generating an ordinary invoice. Billing still knows
// nothing about credits and hears about settlement only by emitting its own
// `shipping_line_credit.invoice.paid` event, but the module graph now cycles
// (billing -> companies -> here -> billing), so this edge needs forwardRef.
forwardRef(() => BillingModule),
],
controllers: [
ShippingLineCompaniesController,
ShippingLineBookingsController,
ShippingLineCreditsController,
],
providers: [
ShippingLineCompaniesService,
ShippingLineCompaniesRepository,
ShippingLineBookingsService,
ShippingLineCreditsService,
ShippingLineCreditsRepository,
ShippingLineInvoiceApprovalsRepository,
],
// Exported so whatever prices a shipping-line booking can record the charge.
exports: [ShippingLineCompaniesService, ShippingLineCreditsService],
})
export class ShippingLineCompaniesModule {}