UNPKG

@vulog/aima-billing

Version:

Invoice management, credits, wallets, and refunds.

235 lines (225 loc) 6.29 kB
import { UUID } from 'crypto'; export type ChargeProductInfo = { productId: string; serviceId?: string; amount: number; userId: string; entityId: string; subscriptionId?: string; productNotes?: string; originId?: string; chargeProductRequestId?: string; additionalInfo?: { manualPayment?: boolean; }; }; export type ManualPayment = { requiresActionReturnUrl: string; online?: boolean; scope: 'RENTAL' | 'DEPOSIT'; }; export type Invoice = { id: string; sequence: number; refundSequence?: number; userId: string; pricingId?: string; tripId?: string; invoiceDate: string; updateDate: string; fleetId: string; invoiceYear: number; invoicesStatus: | 'PENDING' | 'PAID' | 'REFUSED' | 'ERROR' | 'REFUNDED' | 'CANCELLED' | 'PENDING_EXTERNAL_PAYMENT' | 'PENDING_MANUAL_PAYMENT' | 'PENDING_AUTHENTICATION' | 'MOP_MISSING'; amount: number; productId?: string; currency: string; serviceId?: string; tokenId?: string; entityId: string; amountPayWithSystemCredit?: number; attempts: number; pspName?: string; pspReference: string; withTaxRefundAmount: number; isRefunded?: boolean; paymentInProgress: boolean; subscriptionId?: string; paymentDate?: string; externalPaymentRequesterId?: string; externalPaymentNotes?: string; isPaidExternally?: boolean; refundInProgress?: boolean; originId?: string; originRole?: string; pspIdempotency: string; paidExternally?: boolean; refunded?: boolean; productTaxIncluded?: boolean; pspReferencePreAuth?: string; amountPreAuth?: number; preAuthEnabled?: boolean; [key: string]: any; }; export type Credit = { initialAmount: number; validityStartDate: string; validityEndDate: string; notes: string; discountCategory: 'CREDITS' | 'PERCENTAGE'; oneTimeUsage: boolean; id: UUID; availableAmount: number; usedAmount: number; originId: UUID; entityId: UUID; creditAlreadyUsed: boolean; updateDate: string; type: 'LOCAL' | 'GLOBAL' | 'PERIODIC'; usage: 'TRIP' | 'REGISTRATION' | 'PRODUCTS' | 'ALL'; [key: string]: any; }; export type Receipt = { id: string; pspName: string; pspReference: string; pspPublishableKey: string; amount: number; currency: string; date: string; status: string; paymentMethodType: string; paymentMethodPspReference: string; paymentIntentPspReference: string; number: number; code: string; declineCode: string; pspClientSecret: string; reason: string; note: string; nextAction: { nextActionRedirectUrl: { url: string; method: string; data: { [key: string]: unknown; }; }; type: string; }; metadatas: { [key: string]: unknown; }; }; export type RefundableAmount = { invoiceId: string; fleetId: string; refundableAmount: number; currency: string; refundablePaymentReceipts: Receipt[]; refundedPaymentReceipts: Receipt[]; }; /** Billing line item returned by the trip invoices endpoint (nested in Billing array). */ export type TripBillingItem = { trip?: unknown; product?: unknown; vehiculeModelName?: string; vehiculePlate?: string; modelId?: string; userId?: string; withoutTaxAmountForDriving?: number; withoutTaxAmountForStopover?: number; withoutTaxAmountForBooking?: number; withoutTaxForOvermileage?: number; withoutTaxAmountForStartZoneFee?: number; withoutTaxAmountForEndZoneFee?: number; withoutTaxAmountForCancellationFee?: number; withoutTaxAmountForScheduleTripFee?: number; withoutTaxAmountForTripSystemCredit?: number; withoutTaxAmountForBillingGroupDiscount?: number | null; withTaxAmountForDriving?: number; withTaxAmountForStopover?: number; withTaxAmountForBooking?: number; withTaxForOvermileage?: number; withTaxAmountForStartZoneFee?: number; withTaxAmountForEndZoneFee?: number; withTaxAmountForCancellationFee?: number; withTaxAmountForScheduleTripFee?: number; withTaxAmountForTripSystemCredit?: number; withTaxAmountForBillingGroupDiscount?: number; withoutTaxInitialTotalAmount?: number; withTaxInitialTotalAmount?: number; taxInitialTotalAmount?: number; paymentMethodType?: string; walletId?: string | null; totalTaxAmount?: number; totalWithTax?: number; totalWithoutTax?: number; taxRate?: number; taxName?: string; withoutTaxAmountRideCost?: number; withTaxAmountRideCost?: number; taxAmountRideCost?: number; products?: unknown[]; taxesPerRate?: unknown; serviceId?: string | null; profileId?: string | null; profileType?: string | null; profileName?: string | null; withoutTaxUnlockFee?: number; withTaxUnlockFee?: number; taxUnlockFee?: number; withTaxRefundAmount?: number | null; isRefunded?: boolean; cityName?: string | null; cityId?: string | null; tripBillingBreakdown?: unknown; pricingId?: string; netJourney?: number; taxJourney?: number; grossJourney?: number; durationJourney?: number; taxRemainingToBePaid?: number; grossRemainingToBePaid?: number; netRemainingToBePaid?: number; overriddenTripInfo?: unknown; interrupted?: boolean; interruptedReason?: string | null; invoice?: unknown; distanceUnit?: string; isTaxIncluded?: boolean; [key: string]: unknown; }; /** Response shape of GET .../trips/:tripId/invoices */ export type InvoicesByTripIdResponse = { balance: number; userId: string; entityId: string; Billing: TripBillingItem[]; }; export type Wallet = { initialAmount: number; validityStartDate: string; validityEndDate: string; notes: string; discountCategory: string; oneTimeUsage: boolean; id: string; availableAmount: number; usedAmount: number; originId: string; entityId: string; creditAlreadyUsed: boolean; updateDate: string; type: string; usage: string; };