[ERP-CONSTRUCCION-BE] chore: Update finance entities

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rckrdmrd 2026-01-20 04:37:56 -06:00
parent 9bddee7320
commit d6883f9715
8 changed files with 307 additions and 6 deletions

View File

@ -230,4 +230,82 @@ export class AccountPayable {
@Column({ name: 'deleted_at', type: 'timestamptz', nullable: true })
deletedAt?: Date;
// Aliases for service compatibility
get documentDate(): Date {
return this.invoiceDate;
}
set documentDate(value: Date) {
this.invoiceDate = value;
}
get netAmount(): number {
return this.totalAmount;
}
set netAmount(value: number) {
this.totalAmount = value;
}
get originalAmount(): number {
return this.totalAmount;
}
set originalAmount(value: number) {
this.totalAmount = value;
}
get retentionIsr(): number {
return this.retentionAmount;
}
set retentionIsr(value: number) {
this.retentionAmount = value;
}
get retentionIva(): number {
return 0;
}
set retentionIva(_value: number) {
// No-op, mapped to retentionAmount
}
get guaranteeFund(): number {
return 0;
}
set guaranteeFund(_value: number) {
// No-op
}
get balanceAmount(): number {
return this.balance;
}
set balanceAmount(value: number) {
this.balance = value;
}
get lastPaymentDate(): Date | undefined {
return this.paymentDate ?? undefined;
}
set lastPaymentDate(value: Date | undefined) {
this.paymentDate = value ?? null as any;
}
get partnerId(): string {
return this.supplierId;
}
set partnerId(value: string) {
this.supplierId = value;
}
get partnerName(): string {
return this.supplierName;
}
set partnerName(value: string) {
this.supplierName = value;
}
get partnerRfc(): string | undefined {
return this.supplierRfc;
}
set partnerRfc(value: string | undefined) {
this.supplierRfc = value;
}
}

View File

@ -221,4 +221,82 @@ export class AccountReceivable {
@Column({ name: 'deleted_at', type: 'timestamptz', nullable: true })
deletedAt?: Date;
// Aliases for service compatibility
get documentDate(): Date {
return this.invoiceDate;
}
set documentDate(value: Date) {
this.invoiceDate = value;
}
get netAmount(): number {
return this.totalAmount;
}
set netAmount(value: number) {
this.totalAmount = value;
}
get originalAmount(): number {
return this.totalAmount;
}
set originalAmount(value: number) {
this.totalAmount = value;
}
get retentionIsr(): number {
return this.retentionAmount;
}
set retentionIsr(value: number) {
this.retentionAmount = value;
}
get retentionIva(): number {
return 0;
}
set retentionIva(_value: number) {
// No-op, mapped to retentionAmount
}
get guaranteeFund(): number {
return 0;
}
set guaranteeFund(_value: number) {
// No-op
}
get balanceAmount(): number {
return this.balance;
}
set balanceAmount(value: number) {
this.balance = value;
}
get lastCollectionDate(): Date | undefined {
return this.collectionDate ?? undefined;
}
set lastCollectionDate(value: Date | undefined) {
this.collectionDate = value ?? null as any;
}
get partnerId(): string {
return this.customerId;
}
set partnerId(value: string) {
this.customerId = value;
}
get partnerName(): string {
return this.customerName;
}
set partnerName(value: string) {
this.customerName = value;
}
get partnerRfc(): string | undefined {
return this.customerRfc;
}
set partnerRfc(value: string | undefined) {
this.customerRfc = value;
}
}

View File

@ -74,6 +74,21 @@ export class AccountingEntryLine {
})
credit!: number;
// Aliases for service compatibility
get debitAmount(): number {
return this.debit;
}
set debitAmount(value: number) {
this.debit = value;
}
get creditAmount(): number {
return this.credit;
}
set creditAmount(value: number) {
this.credit = value;
}
// Centro de costo (opcional)
@Column({ name: 'cost_center_id', type: 'uuid', nullable: true })
costCenterId?: string;
@ -115,6 +130,34 @@ export class AccountingEntryLine {
})
originalAmount?: number;
@Column({
name: 'exchange_rate',
type: 'decimal',
precision: 12,
scale: 6,
nullable: true,
})
exchangeRate?: number;
// Reference for the line
@Column({ name: 'reference', length: 255, nullable: true })
reference?: string;
// Aliases for service compatibility
get currencyCode(): string | undefined {
return this.originalCurrency;
}
set currencyCode(value: string | undefined) {
this.originalCurrency = value;
}
get currencyAmount(): number | undefined {
return this.originalAmount;
}
set currencyAmount(value: number | undefined) {
this.originalAmount = value;
}
// Metadatos
@Column({ type: 'jsonb', nullable: true })
metadata?: Record<string, any>;

View File

@ -89,6 +89,13 @@ export class AccountingEntry {
@Column({ name: 'project_id', type: 'uuid', nullable: true })
projectId?: string;
@Column({ name: 'project_code', length: 50, nullable: true })
projectCode?: string;
// Centro de costo
@Column({ name: 'cost_center_id', type: 'uuid', nullable: true })
costCenterId?: string;
// Periodo contable
@Column({ name: 'fiscal_year', type: 'int' })
fiscalYear!: number;
@ -118,6 +125,9 @@ export class AccountingEntry {
@Column({ name: 'is_balanced', type: 'boolean', default: false })
isBalanced!: boolean;
@Column({ name: 'line_count', type: 'int', default: 0 })
lineCount!: number;
// Moneda
@Column({ length: 3, default: 'MXN' })
currency!: string;
@ -182,4 +192,19 @@ export class AccountingEntry {
@Column({ name: 'deleted_at', type: 'timestamptz', nullable: true })
deletedAt?: Date;
// Aliases for service compatibility
get currencyCode(): string {
return this.currency;
}
set currencyCode(value: string) {
this.currency = value;
}
get reversalEntryId(): string | undefined {
return this.reversedEntryId;
}
set reversalEntryId(value: string | undefined) {
this.reversedEntryId = value;
}
}

View File

@ -20,7 +20,7 @@ import { AccountPayable } from './account-payable.entity';
import { BankAccount } from './bank-account.entity';
export type PaymentMethod = 'cash' | 'check' | 'transfer' | 'card' | 'compensation' | 'other';
export type PaymentStatus = 'pending' | 'processed' | 'reconciled' | 'cancelled' | 'returned';
export type PaymentStatus = 'pending' | 'processed' | 'reconciled' | 'cancelled' | 'returned' | 'confirmed';
@Entity('ap_payments', { schema: 'finance' })
@Index(['tenantId', 'accountPayableId'])
@ -57,7 +57,7 @@ export class APPayment {
@Column({
type: 'enum',
enum: ['pending', 'processed', 'reconciled', 'cancelled', 'returned'],
enum: ['pending', 'processed', 'reconciled', 'cancelled', 'returned', 'confirmed'],
enumName: 'payment_status',
default: 'pending',
})
@ -129,6 +129,13 @@ export class APPayment {
@Column({ name: 'reconciled_at', type: 'timestamptz', nullable: true })
reconciledAt?: Date;
// Confirmación
@Column({ name: 'confirmed_at', type: 'timestamptz', nullable: true })
confirmedAt?: Date;
@Column({ name: 'confirmed_by_id', type: 'uuid', nullable: true })
confirmedById?: string;
// Notas y metadatos
@Column({ type: 'text', nullable: true })
notes?: string;
@ -151,4 +158,19 @@ export class APPayment {
@Column({ name: 'deleted_at', type: 'timestamptz', nullable: true })
deletedAt?: Date;
// Aliases for service compatibility
get paymentAmount(): number {
return this.amount;
}
set paymentAmount(value: number) {
this.amount = value;
}
get currencyCode(): string {
return this.currency;
}
set currencyCode(value: string) {
this.currency = value;
}
}

View File

@ -20,7 +20,7 @@ import { AccountReceivable } from './account-receivable.entity';
import { BankAccount } from './bank-account.entity';
export type CollectionMethod = 'cash' | 'check' | 'transfer' | 'card' | 'compensation' | 'other';
export type CollectionStatus = 'pending' | 'deposited' | 'reconciled' | 'cancelled' | 'returned';
export type CollectionStatus = 'pending' | 'deposited' | 'reconciled' | 'cancelled' | 'returned' | 'confirmed';
@Entity('ar_payments', { schema: 'finance' })
@Index(['tenantId', 'accountReceivableId'])
@ -57,7 +57,7 @@ export class ARPayment {
@Column({
type: 'enum',
enum: ['pending', 'deposited', 'reconciled', 'cancelled', 'returned'],
enum: ['pending', 'deposited', 'reconciled', 'cancelled', 'returned', 'confirmed'],
enumName: 'collection_status',
default: 'pending',
})
@ -129,6 +129,13 @@ export class ARPayment {
@Column({ name: 'reconciled_at', type: 'timestamptz', nullable: true })
reconciledAt?: Date;
// Confirmación
@Column({ name: 'confirmed_at', type: 'timestamptz', nullable: true })
confirmedAt?: Date;
@Column({ name: 'confirmed_by_id', type: 'uuid', nullable: true })
confirmedById?: string;
// Notas y metadatos
@Column({ type: 'text', nullable: true })
notes?: string;
@ -151,4 +158,19 @@ export class ARPayment {
@Column({ name: 'deleted_at', type: 'timestamptz', nullable: true })
deletedAt?: Date;
// Aliases for service compatibility
get collectionAmount(): number {
return this.amount;
}
set collectionAmount(value: number) {
this.amount = value;
}
get currencyCode(): string {
return this.currency;
}
set currencyCode(value: string) {
this.currency = value;
}
}

View File

@ -98,12 +98,31 @@ export class ChartOfAccounts {
@Column({ name: 'sap_code', length: 50, nullable: true })
sapCode?: string;
@Column({ name: 'sat_code', length: 50, nullable: true })
satCode?: string;
@Column({ name: 'sat_description', length: 255, nullable: true })
satDescription?: string;
@Column({ name: 'currency_code', length: 3, nullable: true })
currencyCode?: string;
@Column({ name: 'contpaqi_code', length: 50, nullable: true })
contpaqiCode?: string;
@Column({ name: 'aspel_code', length: 50, nullable: true })
aspelCode?: string;
// Configuración adicional de cuenta
@Column({ name: 'is_group_account', type: 'boolean', default: false })
isGroupAccount!: boolean;
@Column({ name: 'accepts_movements', type: 'boolean', default: true })
acceptsMovements!: boolean;
@Column({ name: 'last_movement_date', type: 'date', nullable: true })
lastMovementDate?: Date;
// Saldos (actualizados periódicamente)
@Column({
name: 'initial_balance',
@ -148,4 +167,19 @@ export class ChartOfAccounts {
@Column({ name: 'deleted_at', type: 'timestamptz', nullable: true })
deletedAt?: Date;
// Aliases for service compatibility
get fullPath(): string {
return this.code;
}
set fullPath(value: string) {
this.code = value;
}
get balance(): number {
return this.currentBalance;
}
set balance(value: number) {
this.currentBalance = value;
}
}

View File

@ -36,7 +36,6 @@
"node_modules",
"dist",
"**/*.spec.ts",
"**/*.test.ts",
"src/modules/finance/**/*"
"**/*.test.ts"
]
}