Skip to content

Commit f582531

Browse files
committed
feat(src) add process to manager home loans
1 parent 1cec5c8 commit f582531

18 files changed

+508
-103
lines changed

src/common/services/crud/crud.service.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class CrudService<T> {
6868
where: data,
6969
order: data.sort as FindOptionsOrder<T>,
7070
select: this.mapSelectFields(fieldSelected as any) ?? undefined,
71-
relations
71+
relations,
7272
};
7373

7474
const cleanedOptions = this.cleanOptions(options);
@@ -176,11 +176,22 @@ export class CrudService<T> {
176176

177177
cleanOptions<T>(obj: T): T {
178178
const cleanedObject = Object.entries(obj).reduce((acc, [key, value]) => {
179-
if (value === undefined || value === '' || (typeof value === 'object' && value !== null && !Array.isArray(value) && Object.keys(value).length === 0)) {
179+
if (
180+
value === undefined ||
181+
value === '' ||
182+
(typeof value === 'object' &&
183+
value !== null &&
184+
!Array.isArray(value) &&
185+
Object.keys(value).length === 0)
186+
) {
180187
return acc;
181188
}
182189

183-
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
190+
if (
191+
typeof value === 'object' &&
192+
value !== null &&
193+
!Array.isArray(value)
194+
) {
184195
acc[key] = this.cleanOptions(value);
185196
} else {
186197
acc[key] = value;

src/modules/customer/entities/customer.entity.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from 'typeorm';
1313
import * as bcrypt from 'bcrypt';
1414
import { PersonalLoan } from 'src/modules/personal-loan/entities/personal-loan.entity';
15+
import { HomeLoan } from 'src/modules/home-loan/entities/home-loan.entity';
1516

1617
@Entity()
1718
export class Customer {
@@ -62,4 +63,7 @@ export class Customer {
6263

6364
@OneToMany(() => PersonalLoan, (personalLoan) => personalLoan.customer)
6465
personalLoans: PersonalLoan[];
66+
67+
@OneToMany(() => HomeLoan, (homeLoan) => homeLoan.customer)
68+
homeLoans: HomeLoan[];
6569
}
Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
11
import { ApiProperty } from '@nestjs/swagger';
2-
import {
3-
IsNotEmpty,
4-
IsBoolean,
5-
IsString,
6-
IsNumber,
7-
IsDate,
8-
ArrayNotEmpty,
9-
} from 'class-validator';
2+
import { IsBoolean, IsString, IsNumber, ArrayNotEmpty } from 'class-validator';
103

114
export class CreateHomeLoanDto {
125
@ApiProperty()
136
@IsString()
14-
partnerUuid: string;
7+
propertyUsage: string;
8+
9+
@ApiProperty()
10+
@IsString()
11+
typeHouse: string;
12+
13+
@ApiProperty()
14+
@IsString()
15+
address: string;
16+
17+
@ApiProperty()
18+
@IsString()
19+
state: string;
20+
21+
@ApiProperty()
22+
@IsString()
23+
city: string;
24+
25+
@ApiProperty()
26+
@IsString()
27+
town: string;
28+
29+
@ApiProperty()
30+
@IsNumber()
31+
priceHome: number;
32+
33+
@ApiProperty()
34+
@IsString()
35+
paymentInitial: string;
36+
37+
@ApiProperty()
38+
@IsNumber()
39+
monthlyIncome: number;
40+
41+
@ApiProperty()
42+
@IsNumber()
43+
monthlyDebt: number;
44+
45+
@ApiProperty()
46+
@ArrayNotEmpty()
47+
assets: string[];
48+
49+
@ApiProperty()
50+
@IsNumber()
51+
assetsAmount: number;
52+
53+
@ApiProperty()
54+
@IsBoolean()
55+
tc: boolean;
1556
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsString } from 'class-validator';
3+
4+
export class UpdateAddressHomeDto {
5+
@ApiProperty()
6+
@IsString()
7+
address: string;
8+
9+
@ApiProperty()
10+
@IsString()
11+
state: string;
12+
13+
@ApiProperty()
14+
@IsString()
15+
city: string;
16+
17+
@ApiProperty()
18+
@IsString()
19+
town: string;
20+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { PartialType } from '@nestjs/swagger';
2+
import { UpdateAssetsDto } from 'src/modules/personal-loan/dtos/update.assets.dto';
3+
4+
export class UpdateHomeAssetsDto extends PartialType(UpdateAssetsDto) {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { PartialType } from '@nestjs/swagger';
2+
import { LoanDetailsMounthlyDto } from 'src/modules/personal-loan/dtos/loan-details-mounthly.dto';
3+
4+
export class UpdateHomeLoanMounthlyDetailsDto extends PartialType(
5+
LoanDetailsMounthlyDto,
6+
) {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsNumber } from 'class-validator';
3+
4+
export class UpdatePaymentInitialDto {
5+
@ApiProperty()
6+
@IsNumber()
7+
paymentInitial: string;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsNumber } from 'class-validator';
3+
4+
export class UpdatePriceHomeDto {
5+
@ApiProperty()
6+
@IsNumber()
7+
priceHome: number;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsString } from 'class-validator';
3+
4+
export class PropertyUsageDto {
5+
@ApiProperty()
6+
@IsString()
7+
propertyUsage: string;
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsBoolean } from 'class-validator';
3+
4+
export class UpdateTermsAndConditionsDto {
5+
@ApiProperty({
6+
description: 'Indicates whether the terms and conditions are accepted',
7+
example: true,
8+
required: false,
9+
})
10+
@IsBoolean()
11+
tc: boolean;
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsString } from 'class-validator';
3+
4+
export class TypeHomeDto {
5+
@ApiProperty()
6+
@IsString()
7+
typeHome: string;
8+
}

src/modules/home-loan/entities/home-loan.entity.ts

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,68 @@
1+
import { Customer } from 'src/modules/customer/entities/customer.entity';
12
import {
23
Entity,
34
PrimaryGeneratedColumn,
45
Column,
56
CreateDateColumn,
67
UpdateDateColumn,
8+
ManyToOne,
79
} from 'typeorm';
10+
import { StatusHomeLoan } from '../enums/home-loan.enum';
811

912
@Entity()
1013
export class HomeLoan {
1114
@PrimaryGeneratedColumn('uuid')
1215
id: string;
1316

17+
@ManyToOne(() => Customer, (customer) => customer.homeLoans)
18+
customer: Customer;
19+
20+
@Column({ nullable: true })
21+
propertyUsage: string;
22+
23+
@Column({ nullable: true })
24+
typeHome: string;
25+
26+
@Column({ nullable: true })
27+
address: string;
28+
29+
@Column({ nullable: true })
30+
state: string;
31+
32+
@Column({ nullable: true })
33+
city: string;
34+
1435
@Column({ nullable: true })
15-
partnerUuid: string;
36+
town: string;
37+
38+
@Column({ type: 'numeric', nullable: true })
39+
priceHome: number;
40+
41+
@Column({ nullable: true })
42+
paymentInitial: string;
43+
44+
@Column({ type: 'numeric', nullable: true })
45+
monthlyIncome: number;
46+
47+
@Column({ type: 'numeric', nullable: true })
48+
monthlyDebt: number;
49+
50+
@Column('text', { array: true, nullable: true })
51+
assets: string[];
52+
53+
@Column({ type: 'numeric', nullable: true })
54+
assetsAmount: number;
55+
56+
@Column({ type: 'boolean', nullable: true })
57+
tc: boolean;
58+
59+
@Column({
60+
type: 'enum',
61+
enum: StatusHomeLoan,
62+
default: StatusHomeLoan.PROPERTY_USAGE,
63+
nullable: true,
64+
})
65+
status: StatusHomeLoan;
1666

1767
@Column({ type: 'boolean', default: true, nullable: true })
1868
isActive: boolean;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export enum StatusHomeLoan {
2+
PROPERTY_USAGE = 'PROPERTY_USAGE',
3+
TYPE_HOME = 'TYPE_HOME',
4+
ADDRESS = 'ADDRESS',
5+
PRICE = 'PRICE',
6+
PAYMENT_INITIAL = 'PAYMENT_INITIAL',
7+
MOUNTLY_FINANCE = 'MOUNTLY_FINANCE',
8+
ASSETS = 'ASSETS',
9+
TC = 'TC',
10+
CREATED = 'CREATED',
11+
PENDING = 'PENDING',
12+
IN_PROCESS = 'IN_PROCESS',
13+
FAILED = 'FAILED',
14+
COMPLETED = 'COMPLETED',
15+
}

0 commit comments

Comments
 (0)