- Replace class-validator with plain TypeScript interfaces in AI DTOs - Fix AIModel field names (inputCostPer1k instead of inputCostPer1m) - Fix AIUsageLog field mapping (promptTokens, completionTokens, cost) - Add 'branches', 'financial', 'sales' to MCP ToolCategory - Add branchId to McpContext interface - Create stub entities for BranchPaymentTerminal and PaymentTransaction - Create CircuitBreaker utility for payment transactions - Create database config and error classes for base.service.ts - Fix type assertions for fetch response.json() calls - Align PaymentStatus and PaymentMethod types between entities and DTOs - Add @types/pg dependency Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
113 lines
3.1 KiB
TypeScript
113 lines
3.1 KiB
TypeScript
/**
|
|
* Payment Transaction Entity (Stub)
|
|
* TODO: Full implementation
|
|
*/
|
|
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
Index,
|
|
} from 'typeorm';
|
|
|
|
export type PaymentSourceType = 'sale' | 'service_order' | 'fiado_payment' | 'manual';
|
|
export type PaymentMethod = 'card' | 'qr' | 'link' | 'cash' | 'bank_transfer';
|
|
export type PaymentStatus =
|
|
| 'pending'
|
|
| 'processing'
|
|
| 'approved'
|
|
| 'authorized'
|
|
| 'in_process'
|
|
| 'rejected'
|
|
| 'refunded'
|
|
| 'partially_refunded'
|
|
| 'cancelled'
|
|
| 'charged_back'
|
|
| 'completed'
|
|
| 'failed';
|
|
|
|
@Entity({ name: 'payment_transactions', schema: 'mobile' })
|
|
export class PaymentTransaction {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Index()
|
|
@Column({ name: 'tenant_id', type: 'uuid' })
|
|
tenantId: string;
|
|
|
|
@Index()
|
|
@Column({ name: 'branch_id', type: 'uuid' })
|
|
branchId: string;
|
|
|
|
@Column({ name: 'user_id', type: 'uuid', nullable: true })
|
|
userId: string | null;
|
|
|
|
@Column({ name: 'source_type', type: 'varchar', length: 30 })
|
|
sourceType: PaymentSourceType;
|
|
|
|
@Column({ name: 'source_id', type: 'uuid' })
|
|
sourceId: string;
|
|
|
|
@Column({ name: 'terminal_provider', type: 'varchar', length: 50 })
|
|
terminalProvider: string;
|
|
|
|
@Column({ name: 'terminal_id', type: 'varchar', length: 100 })
|
|
terminalId: string;
|
|
|
|
@Column({ type: 'decimal', precision: 12, scale: 2 })
|
|
amount: number;
|
|
|
|
@Column({ type: 'varchar', length: 3, default: 'MXN' })
|
|
currency: string;
|
|
|
|
@Column({ name: 'tip_amount', type: 'decimal', precision: 10, scale: 2, default: 0 })
|
|
tipAmount: number;
|
|
|
|
@Column({ name: 'total_amount', type: 'decimal', precision: 12, scale: 2 })
|
|
totalAmount: number;
|
|
|
|
@Column({ name: 'payment_method', type: 'varchar', length: 30, default: 'card' })
|
|
paymentMethod: PaymentMethod;
|
|
|
|
@Index()
|
|
@Column({ type: 'varchar', length: 20, default: 'pending' })
|
|
status: PaymentStatus;
|
|
|
|
@Column({ name: 'external_transaction_id', type: 'varchar', length: 255, nullable: true })
|
|
externalTransactionId: string | null;
|
|
|
|
@Column({ name: 'card_brand', type: 'varchar', length: 30, nullable: true })
|
|
cardBrand: string | null;
|
|
|
|
@Column({ name: 'card_last_four', type: 'varchar', length: 4, nullable: true })
|
|
cardLastFour: string | null;
|
|
|
|
@Column({ name: 'receipt_url', type: 'text', nullable: true })
|
|
receiptUrl: string | null;
|
|
|
|
@Column({ name: 'receipt_sent', type: 'boolean', default: false })
|
|
receiptSent: boolean;
|
|
|
|
@Column({ name: 'receipt_sent_to', type: 'varchar', length: 255, nullable: true })
|
|
receiptSentTo: string | null;
|
|
|
|
@Column({ name: 'failure_reason', type: 'text', nullable: true })
|
|
failureReason: string | null;
|
|
|
|
@Column({ name: 'provider_response', type: 'jsonb', nullable: true })
|
|
providerResponse: Record<string, any> | null;
|
|
|
|
@Column({ name: 'initiated_at', type: 'timestamptz', nullable: true })
|
|
initiatedAt: Date | null;
|
|
|
|
@Column({ name: 'completed_at', type: 'timestamptz', nullable: true })
|
|
completedAt: Date | null;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
}
|