[TASK-2026-02-03-INTEGRACION] fix: Backend corrections for integration
- Mark invoices module as @deprecated (consolidate with financial) - Relocate PaymentTransaction entity from mobile to payment-terminals - Update imports in transaction.dto.ts and transactions.service.ts - Update app.integration.ts to use new entity location Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3bc1cbf7a3
commit
651450225e
@ -52,7 +52,6 @@ import {
|
||||
MobileSession,
|
||||
OfflineSyncQueue,
|
||||
PushToken,
|
||||
PaymentTransaction,
|
||||
} from './modules/mobile/entities';
|
||||
|
||||
import {
|
||||
@ -146,7 +145,6 @@ export function getAllEntities() {
|
||||
MobileSession,
|
||||
OfflineSyncQueue,
|
||||
PushToken,
|
||||
PaymentTransaction,
|
||||
// Billing
|
||||
SubscriptionPlan,
|
||||
TenantSubscription,
|
||||
|
||||
@ -1,3 +1,10 @@
|
||||
/**
|
||||
* @deprecated This module is deprecated. Use 'financial' module instead.
|
||||
* The invoices functionality has been consolidated into the financial module
|
||||
* for better integration with accounting and GL posting.
|
||||
* See: docs/90-adr/ADR-019-CONSOLIDATE-INVOICES-FINANCIAL.md
|
||||
* Migration: Import from './modules/financial' instead of './modules/invoices'
|
||||
*/
|
||||
export { InvoicesModule, invoicesModule } from './invoices.module.js';
|
||||
export * from './entities/index.js';
|
||||
export { InvoicesService, invoicesService } from './services/index.js';
|
||||
|
||||
@ -3,4 +3,4 @@ export { OfflineSyncQueue, SyncOperation, SyncStatus, ConflictResolution } from
|
||||
export { SyncConflict, ConflictType, ConflictResolutionType } from './sync-conflict.entity';
|
||||
export { PushToken, PushProvider } from './push-token.entity';
|
||||
export { PushNotificationLog, NotificationStatus, NotificationCategory } from './push-notification-log.entity';
|
||||
export { PaymentTransaction, PaymentSourceType, PaymentMethod, PaymentStatus, CardType } from './payment-transaction.entity';
|
||||
// PaymentTransaction removed - use payment-terminals module instead
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Transaction DTOs
|
||||
*/
|
||||
|
||||
import { PaymentSourceType, PaymentMethod, PaymentStatus } from '../../mobile/entities/payment-transaction.entity';
|
||||
import { PaymentSourceType, PaymentMethod, PaymentStatus } from '../entities/payment-transaction.entity';
|
||||
|
||||
export class ProcessPaymentDto {
|
||||
terminalId: string;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
export * from './tenant-terminal-config.entity';
|
||||
export * from './terminal-payment.entity';
|
||||
export * from './terminal-webhook-event.entity';
|
||||
export * from './payment-transaction.entity';
|
||||
|
||||
@ -0,0 +1,115 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Index,
|
||||
} from 'typeorm';
|
||||
|
||||
export type PaymentSourceType = 'sale' | 'invoice' | 'subscription';
|
||||
export type PaymentMethod = 'card' | 'contactless' | 'qr' | 'link';
|
||||
export type PaymentStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'refunded' | 'cancelled';
|
||||
export type CardType = 'credit' | 'debit';
|
||||
|
||||
@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', nullable: true })
|
||||
branchId: string;
|
||||
|
||||
@Index()
|
||||
@Column({ name: 'user_id', type: 'uuid' })
|
||||
userId: string;
|
||||
|
||||
@Column({ name: 'device_id', type: 'uuid', nullable: true })
|
||||
deviceId: string;
|
||||
|
||||
// Referencia al documento origen
|
||||
@Index()
|
||||
@Column({ name: 'source_type', type: 'varchar', length: 30 })
|
||||
sourceType: PaymentSourceType;
|
||||
|
||||
@Column({ name: 'source_id', type: 'uuid' })
|
||||
sourceId: string;
|
||||
|
||||
// Terminal de pago
|
||||
@Column({ name: 'terminal_provider', type: 'varchar', length: 30 })
|
||||
terminalProvider: string; // clip, mercadopago, stripe
|
||||
|
||||
@Column({ name: 'terminal_id', type: 'varchar', length: 100, nullable: true })
|
||||
terminalId: string;
|
||||
|
||||
// Transaccion
|
||||
@Index()
|
||||
@Column({ name: 'external_transaction_id', type: 'varchar', length: 255, nullable: true })
|
||||
externalTransactionId: 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: 12, scale: 2, default: 0 })
|
||||
tipAmount: number;
|
||||
|
||||
@Column({ name: 'total_amount', type: 'decimal', precision: 12, scale: 2 })
|
||||
totalAmount: number;
|
||||
|
||||
// Metodo de pago
|
||||
@Column({ name: 'payment_method', type: 'varchar', length: 30 })
|
||||
paymentMethod: PaymentMethod;
|
||||
|
||||
@Column({ name: 'card_brand', type: 'varchar', length: 20, nullable: true })
|
||||
cardBrand: string; // visa, mastercard, amex
|
||||
|
||||
@Column({ name: 'card_last_four', type: 'varchar', length: 4, nullable: true })
|
||||
cardLastFour: string;
|
||||
|
||||
@Column({ name: 'card_type', type: 'varchar', length: 20, nullable: true })
|
||||
cardType: CardType;
|
||||
|
||||
// Estado
|
||||
@Index()
|
||||
@Column({ type: 'varchar', length: 20, default: 'pending' })
|
||||
status: PaymentStatus;
|
||||
|
||||
@Column({ name: 'failure_reason', type: 'text', nullable: true })
|
||||
failureReason: string;
|
||||
|
||||
// Tiempos
|
||||
@Column({ name: 'initiated_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
||||
initiatedAt: Date;
|
||||
|
||||
@Column({ name: 'completed_at', type: 'timestamptz', nullable: true })
|
||||
completedAt: Date;
|
||||
|
||||
// Metadata del proveedor
|
||||
@Column({ name: 'provider_response', type: 'jsonb', default: {} })
|
||||
providerResponse: Record<string, any>;
|
||||
|
||||
// Recibo
|
||||
@Column({ name: 'receipt_url', type: 'text', nullable: true })
|
||||
receiptUrl: string;
|
||||
|
||||
@Column({ name: 'receipt_sent', type: 'boolean', default: false })
|
||||
receiptSent: boolean;
|
||||
|
||||
@Column({ name: 'receipt_sent_to', type: 'varchar', length: 255, nullable: true })
|
||||
receiptSentTo: string;
|
||||
|
||||
@Index()
|
||||
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
||||
updatedAt: Date;
|
||||
}
|
||||
@ -9,7 +9,7 @@ import {
|
||||
PaymentTransaction,
|
||||
PaymentStatus,
|
||||
PaymentMethod,
|
||||
} from '../../mobile/entities/payment-transaction.entity';
|
||||
} from '../entities/payment-transaction.entity';
|
||||
import { BranchPaymentTerminal } from '../../branches/entities/branch-payment-terminal.entity';
|
||||
import {
|
||||
ProcessPaymentDto,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user