95 lines
1.8 KiB
TypeScript

/**
* Billing Domain - Contract
*
* Defines the normalized billing types used throughout the application.
* Provider-agnostic interface that all billing providers must map to.
*/
// Invoice Status
export const INVOICE_STATUS = {
DRAFT: "Draft",
PENDING: "Pending",
PAID: "Paid",
UNPAID: "Unpaid",
OVERDUE: "Overdue",
CANCELLED: "Cancelled",
REFUNDED: "Refunded",
COLLECTIONS: "Collections",
} as const;
export type InvoiceStatus = (typeof INVOICE_STATUS)[keyof typeof INVOICE_STATUS];
// Invoice Item
export interface InvoiceItem {
id: number;
description: string;
amount: number;
quantity?: number;
type: string;
serviceId?: number;
}
// Invoice
export interface Invoice {
id: number;
number: string;
status: InvoiceStatus;
currency: string;
currencySymbol?: string;
total: number;
subtotal: number;
tax: number;
issuedAt?: string;
dueDate?: string;
paidDate?: string;
pdfUrl?: string;
paymentUrl?: string;
description?: string;
items?: InvoiceItem[];
daysOverdue?: number;
}
// Invoice Pagination
export interface InvoicePagination {
page: number;
totalPages: number;
totalItems: number;
nextCursor?: string;
}
// Invoice List
export interface InvoiceList {
invoices: Invoice[];
pagination: InvoicePagination;
}
// SSO Link for invoice payment
export interface InvoiceSsoLink {
url: string;
expiresAt: string;
}
// Payment request for invoice
export interface PaymentInvoiceRequest {
invoiceId: number;
paymentMethodId?: number;
gatewayName?: string;
amount?: number;
}
// Billing Summary (calculated from invoices)
export interface BillingSummary {
totalOutstanding: number;
totalOverdue: number;
totalPaid: number;
currency: string;
currencySymbol?: string;
invoiceCount: {
total: number;
unpaid: number;
overdue: number;
paid: number;
};
}