import { ApiError, ApiErrorResponse, ApiResponse } from './Api'; import { Payment, PaymentResponse } from './Payment'; import { AddPaymentMethodRequest, BillingAddress } from './PaymentMethod'; export enum InvoicePaymentStatus { OVERDUE = 'Overdue', PAID = 'Paid', PARTIALLY_PAID = 'Partially Paid', UNPAID = 'Unpaid', } export enum InvoiceStatus { DRAFT = 'Draft', CANCELLED = 'Cancelled', ERROR = 'Error', INITIATED = 'Initiated', POSTED = 'Posted', POST_IN_PROGRESS = 'Post In Progress', REBILLED = 'Rebilled', CREDITED = 'Credited', } export type Invoice = { amount: number; billToInfo: BillingAddress; payments: Payment[]; contentDocumentId: string; currencyISOCode: string; dueDate: string; id: string; issueDate: string; invoiceStatus: InvoiceStatus; name: string; paymentStatus: InvoicePaymentStatus; taxAmount: number; subTotal: number; }; export type InvoiceResponse = { amount: number; bill_to_info: Pick< AddPaymentMethodRequest, | 'billing_street' | 'billing_city' | 'billing_state' | 'billing_country' | 'billing_postal_code' >; payments: PaymentResponse[]; content_document_id: string; currency_iso_code: string; due_date: string; id: string; issue_date: string; invoice_status: InvoiceStatus; name: string; payment_status: InvoicePaymentStatus; tax_amount: number; sub_total: number; }; export type GetInvoicesRequest = undefined; export type GetInvoices = ApiResponse<{ firstName: string; invoices: Invoice[]; lastName: string; paymentStatus: string; }>; export type GetInvoicesResponse = ApiResponse<{ first_name: string; invoices: InvoiceResponse[]; last_name: string; payment_status: string; }>; export type GetInvoicesErrorResponse = ApiErrorResponse; export type DownloadInvoiceRequest = { content_document_id: InvoiceResponse['content_document_id']; }; export type DownloadInvoiceResponse = undefined; export type InvoicesError = ApiError; export type DownloadInvoiceErrorResponse = ApiErrorResponse; export type ToggleInvoicesRequest = { toggle: boolean; }; export type ToggleInvoicesResponse = ApiResponse<{ is_email_delivery_on: boolean; }>; export type ToggleInvoices = ApiResponse<{ isEmailDeliveryOn: boolean }>; export type GetInvoicesQueryParams = { has_outstanding_balance?: string; max_issue_date?: string; min_issue_date?: string; }; export type GetOutstandingBalanceRequest = undefined; export type GetOutstandingBalance = ApiResponse<{ hasOutstandingInvoices: boolean; billToContactEmail: string; }>; export type GetOutstandingBalanceResponse = ApiResponse<{ has_outstanding_invoices: boolean; bill_to_contact_email: string; }>; export type ChargeInvoiceRequest = { invoice_id: InvoiceResponse['id']; invoice_amount: InvoiceResponse['amount']; payment_method_id: PaymentResponse['payment_method_id']; currency_iso_code: InvoiceResponse['currency_iso_code']; }; export type ChargeInvoiceResponse = ApiResponse<{ status: 'Success'; transaction_id: string; message: string; }>; export type ChargeInvoiceError = ApiError; export type ChargeInvoiceErrorResponse = ApiErrorResponse;