File

apps/recallassess/recallassess-api/src/api/admin/report/reports/invoice/invoice.dto.ts

Description

Invoice fluid report row — maps Invoice via bnestPlainToDto / bnestPlainToDtoArray. Serialized shape matches InvoiceRowVm (@recallassess/shared-ng).

Implements

InvoiceRowVm

Index

Properties

Properties

course_name
Type : string
Decorators :
@Expose()

LMS label(s) or billing package fallback on plain row — see InvoiceFiltersService.

created_at
Type : string
Decorators :
@Expose()
@Transform( => )
id
Type : number
Decorators :
@Expose()
invoice_number
Type : string
Decorators :
@Expose()
invoice_type
Type : string
Decorators :
@Expose()
@Transform( => )
invoice_type_label
Type : string
Decorators :
@Expose()
@Transform( => )
license_quantity
Type : number
Decorators :
@Expose()
package_type
Type : string
Decorators :
@Expose()
@Transform( => )
package_type_label
Type : string
Decorators :
@Expose()
@Transform( => )
paid_date
Type : string | null
Decorators :
@Expose()
@Transform( => )
period_end
Type : string | null
Decorators :
@Expose()
@Transform( => )
period_start
Type : string | null
Decorators :
@Expose()
@Transform( => )
status
Type : string
Decorators :
@Expose()
@Transform( => )
status_label
Type : string
Decorators :
@Expose()
@Transform( => )
total_amount
Type : number | null
Decorators :
@Expose()
@Transform( => )
unit_price_per_license
Type : number | null
Decorators :
@Expose()
@Transform( => )
import { dateToIsoString, decimalToNumber, humanizeEnumLabel } from "@bish-nest/core";
import type { Invoice } from "@prisma/client";
import type { InvoiceDetailVm, InvoiceRowVm } from "@recallassess/shared-ng";
import { Exclude, Expose, Transform } from "class-transformer";

function src(obj: unknown): Invoice {
  return obj as Invoice;
}

/**
 * Invoice fluid report row — maps **`Invoice`** via **`bnestPlainToDto`** / **`bnestPlainToDtoArray`**.
 * Serialized shape matches **`InvoiceRowVm`** (`@recallassess/shared-ng`).
 */
@Exclude()
export class InvoiceRowDto implements InvoiceRowVm {
  @Expose()
  id!: number;

  @Expose()
  invoice_number!: string;

  /** LMS label(s) or billing package fallback on plain row — see **`InvoiceFiltersService`**. */
  @Expose()
  course_name!: string;

  @Expose()
  @Transform(({ obj }) => String(src(obj).status))
  status!: string;

  @Expose()
  @Transform(({ obj }) => humanizeEnumLabel(String(src(obj).status)))
  status_label!: string;

  @Expose()
  @Transform(({ obj }) => String(src(obj).invoice_type))
  invoice_type!: string;

  @Expose()
  @Transform(({ obj }) => humanizeEnumLabel(String(src(obj).invoice_type)))
  invoice_type_label!: string;

  @Expose()
  @Transform(({ obj }) => String(src(obj).package_type))
  package_type!: string;

  @Expose()
  @Transform(({ obj }) => humanizeEnumLabel(String(src(obj).package_type)))
  package_type_label!: string;

  @Expose()
  license_quantity!: number;

  @Expose()
  @Transform(({ obj }) => decimalToNumber(src(obj).unit_price_per_license))
  unit_price_per_license!: number | null;

  @Expose()
  @Transform(({ obj }) => decimalToNumber(src(obj).total_amount))
  total_amount!: number | null;

  @Expose()
  @Transform(({ obj }) => dateToIsoString(src(obj).paid_date ?? undefined))
  paid_date!: string | null;

  @Expose()
  @Transform(({ obj }) => dateToIsoString(src(obj).period_start ?? undefined))
  period_start!: string | null;

  @Expose()
  @Transform(({ obj }) => dateToIsoString(src(obj).period_end ?? undefined))
  period_end!: string | null;

  @Expose()
  @Transform(({ obj }) => dateToIsoString(src(obj).created_at) ?? "")
  created_at!: string;
}

/**
 * Single-invoice document — plain fields match **`invoiceDetailPlain`** output before **`bnestPlainToDto`**.
 */
@Exclude()
export class InvoiceDetailDto implements InvoiceDetailVm {
  @Expose()
  id!: number;

  @Expose()
  invoice_number!: string;

  @Expose()
  course_name!: string;

  @Expose()
  status!: string;

  @Expose()
  status_label!: string;

  @Expose()
  invoice_type!: string;

  @Expose()
  invoice_type_label!: string;

  @Expose()
  package_type!: string;

  @Expose()
  package_type_label!: string;

  @Expose()
  license_quantity!: number;

  @Expose()
  unit_price_per_license!: number | null;

  @Expose()
  total_amount!: number | null;

  @Expose()
  paid_date!: string | null;

  @Expose()
  period_start!: string | null;

  @Expose()
  period_end!: string | null;

  @Expose()
  created_at!: string;

  @Expose()
  company_id!: number;

  @Expose()
  company_name!: string;

  @Expose()
  company_email!: string | null;

  @Expose()
  company_address!: string | null;

  @Expose()
  subtotal_amount!: number | null;

  @Expose()
  gross_license_amount!: number | null;

  @Expose()
  pre_vat_total_amount!: number | null;

  @Expose()
  discount_amount!: number | null;

  @Expose()
  coupon_code!: string | null;

  @Expose()
  vat_fee!: number | null;

  @Expose()
  processing_fee!: number | null;

  @Expose()
  proration_amount!: number | null;

  @Expose()
  billing_reference_notes!: string | null;

  @Expose()
  pdf_heading!: string;

  @Expose()
  pdf_subheading!: string | null;

  @Expose()
  pdf_invoice_type_label!: string;

  @Expose()
  pdf_is_credit_note!: boolean;

  @Expose()
  billing_cycle_label!: string | null;

  @Expose()
  billing_cycle_months!: number;

  @Expose()
  parent_invoice_number!: string | null;

  @Expose()
  subscription_plan_display!: string;

  @Expose()
  processing_fee_percentage!: number | null;

  @Expose()
  vat_fee_percentage!: number | null;

  @Expose()
  period_display_start!: string | null;

  @Expose()
  period_display_end!: string | null;
}

export type { InvoiceSummaryVm as InvoiceSummaryDto } from "@recallassess/shared-ng";

results matching ""

    No results matching ""