Skip to content

Commit c2acbfd

Browse files
authored
MIM-532: add rental information type (#64)
* base: add rental information * base: wip relations * base: add rental information * tree: render residence info type
1 parent 196fded commit c2acbfd

File tree

11 files changed

+170
-5
lines changed

11 files changed

+170
-5
lines changed

packages/property-base/prisma/schema/PropertyObject_cmobj.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ model PropertyObject {
2323
administrativeUnit AdministrativeUnit? //@relation("PropertyObjectToAdministrativeUnit")
2424
propertyArea PropertyArea[] //@relation("PropertyObjectToPropertyArea")
2525
property Property? //@relation("PropertyObjectToProperty") //todo: fix this relation
26+
rentalInformation RentalInformation? @relation("PropertyObjectToRentalInformation")
2627
2728
rentalObject RentalObject? //@relation("PropertyObjectToRentalObject")
2829
//company Company? @relation("PropertyObjectToCompany")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
model RentalInformationType {
2+
@@map("hyint")
3+
4+
id String @id(map: "pkhyint") @map("keyhyint") @db.Char(15)
5+
code String @map("code") @db.Char(10)
6+
name String? @map("caption") @db.Char(30)
7+
// Exclude unused fields
8+
9+
// waitingListTypeId String? @map("keybkkty") @db.Char(15)
10+
// minimumAge Int? @map("minage") @db.TinyInt
11+
// maximumAge Int? @map("maxage") @db.TinyInt
12+
// housingType Int @default(0, map: "DF__hyint__lmcat__66796CD3") @map("lmcat") @db.TinyInt
13+
// publishStatus Int @default(0, map: "DF__hyint__publicera__676D910C") @map("publiceras") @db.TinyInt
14+
// apartmentInspectionStatus Int @default(1, map: "DF__hyint__lbcreate__6861B545") @map("lbcreate") @db.TinyInt
15+
// turnoverVisibility Int @default(0, map: "DF__hyint__tuovisibl__6955D97E") @map("tuovisible") @db.TinyInt
16+
// familySituationStatus Int @default(0, map: "DF__hyint__familysit__6A49FDB7") @map("familysit") @db.TinyInt
17+
// timestamp String @map("timestamp") @db.Char(10)
18+
19+
rentalInformations RentalInformation[] // Previously hyinf; converted to use the new model name
20+
// waitingListType WaitingListType? @relation(fields: [waitingListTypeId], references: [waitingListTypeId], onDelete: NoAction, onUpdate: NoAction, map: "fkhyintkeybkkty")
21+
22+
// @@index([waitingListTypeId], map: "fkhyintbkkty")
23+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
model RentalInformation {
2+
@@map("hyinf")
3+
id String @id(map: "pkhyinf") @map("keyhyinf") @db.Char(15)
4+
propertyObjectId String @unique(map: "akhyinf1") @map("keycmobj") @db.Char(15)
5+
rentalInformationTypeId String @map("keyhyint") @db.Char(15)
6+
// Exclude unused fields
7+
8+
// shownByUserId String? @map("keybkvis") @db.Char(15) // TODO: Confirm relation name if changed
9+
// indexSeriesId String? @map("keycmind") @db.Char(15)
10+
// indexValueId String? @map("keycminv") @db.Char(15)
11+
// quantityTypeId String? @map("keycmvat") @db.Char(15)
12+
// quantityTypeId2 String? @map("keycmvat2") @db.Char(15)
13+
// quantityTypeId3 String? @map("keycmvat3") @db.Char(15)
14+
// quantityTypeId4 String? @map("keycmvat4") @db.Char(15)
15+
// taxAreaId String? @map("keyhyvaa") @db.Char(15)
16+
// heatingId String? @map("keybahea") @db.Char(15)
17+
// renovationExemptionId String? @map("keybarex") @db.Char(15)
18+
// creditTemplateId String? @map("keycmcte") @db.Char(15)
19+
// rentId String? @map("hyresid") @db.VarChar(30)
20+
// generation Int? @map("generation") @db.SmallInt
21+
// startGeneration Int? @map("startgen") @db.TinyInt
22+
// apartmentNumber String? @map("lmnr") @db.Char(5)
23+
// housingNumber String? @map("prynumber") @db.VarChar(30)
24+
// shareNumber String? @map("shareno") @db.VarChar(60)
25+
// tenureForm Int? @map("upplform") @db.TinyInt
26+
// currentTenureForm Int? @map("upplformnu") @db.TinyInt
27+
// isShortTermRental Int @map("shortstay") @db.TinyInt
28+
// sharePercentage Decimal? @map("andelstal") @db.Decimal(22, 7)
29+
// rentDistributionFactor Decimal? @map("aixrent") @db.Decimal(8, 7)
30+
// shareValue Float? @map("sharevalue") @db.Money
31+
// voteCount Int? @map("votecount") @db.TinyInt
32+
// depositAdvance Float? @map("insatspre") @db.Money
33+
// depositForfeit Float? @map("insatsfors") @db.Money // deposit Float? @map("insats") @db.Money // depositDate DateTime? @map("inputdate") @db.DateTime
34+
// tenureFee Float? @map("upplavg") @db.Money
35+
// tenureFeeDate DateTime? @map("letfeedate") @db.DateTime
36+
// irrevocableCapitalContribution Float? @map("oaterkap") @db.Money
37+
// originalAnnualFee Float? @map("planarsavg") @db.Money
38+
// firstOccupancyDate DateTime? @map("inflyttdat") @db.DateTime
39+
// queueManagement Int? @map("direktuth") @db.TinyInt
40+
// baseRentAmount Float? @map("akthyratot") @db.Money
41+
// contractBaseRent Float? @map("konthyra") @db.Money
42+
// isDraft Int @default(0, map: "DF__hyinf__draft__535320DE") @map("draft") @db.TinyInt
43+
// doNotInvoiceDeposit Int @map("ejbrinsats") @db.TinyInt
44+
// doNotAllocateToInternalFund Int @map("ejbrfnd") @db.TinyInt
45+
// statisticsFrom DateTime @map("statfrom") @db.DateTime
46+
// statisticsTo DateTime @map("stattom") @db.DateTime
47+
// rentLossFrom DateTime? @map("lossfrom") @db.DateTime
48+
// rentLossTo DateTime? @map("lossto") @db.DateTime
49+
// salesStop Int @map("saljstopp") @db.TinyInt
50+
// housingEvaluationType Int @default(0, map: "DF__hyinf__pointtype__54474517") @map("pointtype") @db.TinyInt
51+
// housingAllowance Int @default(0, map: "DF__hyinf__allowance__553B6950") @map("allowance") @db.TinyInt
52+
// housingEnergyClass Int @default(0, map: "DF__hyinf__fohenergy__562F8D89") @map("fohenergyc") @db.TinyInt
53+
// targetRentPercentage Decimal? @map("targetperc") @db.Decimal(4, 1)
54+
// targetRentAmount Float? @map("targetrent") @db.Money
55+
// evaluationPoints Int? @map("points") @db.SmallInt
56+
// minOccupants Int? @map("persmin") @db.TinyInt
57+
// maxOccupants Int? @map("persmax") @db.TinyInt
58+
// minAge Int? @map("persagemin") @db.TinyInt
59+
// maxAge Int? @map("persagemax") @db.TinyInt
60+
// minTenureMonths Int? @map("tentimemin") @db.TinyInt
61+
// minIncomeRentFactor Decimal? @map("increntmin") @db.Decimal(4, 2)
62+
// additionalInfo String? @map("otherinfo") @db.VarChar(200)
63+
// renovationExemptionComment String? @map("rexcomment") @db.VarChar(200)
64+
// firstClassId Int @default(0, map: "DF__hyinf__fcobject__5723B1C2") @map("fcobject") @db.TinyInt
65+
// upgradeStandard Int @default(0, map: "DF__hyinf__fcstatus__5817D5FB") @map("fcstatus") @db.TinyInt
66+
// upgradeNeed Int @default(0, map: "DF__hyinf__fcupgneed__590BFA34") @map("fcupgneed") @db.TinyInt
67+
// lastUpgradeDate DateTime? @map("fcdate") @db.DateTime
68+
// upgradeComment String? @map("fccomment") @db.VarChar(250)
69+
// isBGUCovered Int @default(0, map: "DF__hyinf__bguused__5A001E6D") @map("bguused") @db.TinyInt
70+
// hasLakeView Int @default(0, map: "DF__hyinf__lakeview__5AF442A6") @map("lakeview") @db.TinyInt
71+
// vatRate Decimal @default(0, map: "DF__hyinf__vatstat__5BE866DF") @map("vatstat") @db.Decimal(4, 2)
72+
// purposeLabel Int @default(1, map: "DF__hyinf__label__5CDC8B18") @map("label") @db.TinyInt
73+
// isRenovated Int @default(0, map: "DF__hyinf__renovatio__5DD0AF51") @map("renovation") @db.TinyInt
74+
// daebStatus Int @default(1, map: "DF__hyinf__daeb__5EC4D38A") @map("daeb") @db.TinyInt
75+
// standardYearRent Float? @map("stdyrrent") @db.Money
76+
// discountFee Float @default(0, map: "DF__hyinf__discfee__5FB8F7C3") @map("discfee") @db.Money
77+
// rentCalculationMethod Int @default(0, map: "DF__hyinf__rentcalcm__60AD1BFC") @map("rentcalcm") @db.TinyInt
78+
// deleteMark Int @default(0, map: "DF__hyinf__deletemar__61A14035") @map("deletemark") @db.TinyInt
79+
// timestamp String @map("timestamp") @db.Char(10)
80+
81+
// heating Heating? @relation(fields: [heatingId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fkhyinfbahea")
82+
// creditTemplate CreditTemplate? @relation(fields: [creditTemplateId], references: [id], onUpdate: NoAction, map: "fkhyinfcmcte")
83+
84+
// TODO: change relations when knowing the new model names
85+
// indexSeries cmind? @relation(fields: [indexSeriesId], references: [keycmind], onDelete: NoAction, onUpdate: NoAction, map: "fkhyinfkeycmind")
86+
// indexValue IndexValue? @relation(fields: [indexValueId], references: [indexValueId], onDelete: NoAction, onUpdate: NoAction, map: "fkhyinfkeycminv")
87+
// propertyObject cmobj @relation(fields: [propertyObjectId], references: [keycmobj], onDelete: Cascade, onUpdate: NoAction, map: "fkhyinfkeycmobj")
88+
// quantityType cmvat_hyinf_keycmvatTocmvat cmvat? @relation("hyinf_keycmvatTocmvat", fields: [quantityTypeId], references: [keycmvat], onDelete: NoAction, onUpdate: NoAction, map: "fkhyinfkeycmvat")
89+
// quantityType2 cmvat_hyinf_keycmvat2Tocmvat cmvat? @relation("hyinf_keycmvat2Tocmvat", fields: [quantityTypeId2], references: [keycmvat], onDelete: NoAction, onUpdate: NoAction, map: "fkhyinfkeycmvat2")
90+
// quantityType3 cmvat_hyinf_keycmvat3Tocmvat cmvat? @relation("hyinf_keycmvat3Tocmvat", fields: [quantityTypeId3], references: [keycmvat], onDelete: NoAction, onUpdate: NoAction, map: "fkhyinfkeycmvat3")
91+
// quantityType4 cmvat_hyinf_keycmvat4Tocmvat cmvat? @relation("hyinf_keycmvat4Tocmvat", fields: [quantityTypeId4], references: [keycmvat], onDelete: NoAction, onUpdate: NoAction, map: "fkhyinfkeycmvat4")
92+
rentalInformationType RentalInformationType @relation(fields: [rentalInformationTypeId], references: [id], onUpdate: NoAction, map: "fkhyinfkeyhyint")
93+
propertyObject PropertyObject @relation("PropertyObjectToRentalInformation", fields: [propertyObjectId], references: [id], map: "fkhyinfkeycmobj")
94+
// @@index([heatingId], map: "fkhyinfbahea")
95+
// @@index([shownByUserId], map: "fkhyinfbkvis")
96+
// @@index([creditTemplateId], map: "fkhyinfcmcte")
97+
// @@index([indexSeriesId], map: "fkhyinfcmind")
98+
// @@index([indexValueId], map: "fkhyinfcminv")
99+
// @@index([quantityTypeId], map: "fkhyinfcmvat")
100+
// @@index([quantityTypeId2], map: "fkhyinfcmvat2")
101+
// @@index([quantityTypeId3], map: "fkhyinfcmvat3")
102+
// @@index([quantityTypeId4], map: "fkhyinfcmvat4")
103+
// @@index([rentalInformationTypeId], map: "fkhyinfhyint")
104+
// @@index([rentId], map: "inhyinf_2J70GWSR9")
105+
}

packages/property-base/src/adapters/residence-adapter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type ResidenceWithRelations = Prisma.ResidenceGetPayload<{
2424
residenceType: true
2525
propertyObject: {
2626
include: {
27+
rentalInformation: { include: { rentalInformationType: true } }
2728
propertyStructures: {
2829
select: {
2930
rentalId: true
@@ -59,6 +60,7 @@ export const getResidenceById = async (
5960
residenceType: true,
6061
propertyObject: {
6162
include: {
63+
rentalInformation: { include: { rentalInformationType: true } },
6264
propertyStructures: {
6365
select: {
6466
rentalId: true,

packages/property-base/src/routes/residences-route.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,16 @@ export const routes = (router: KoaRouter) => {
311311
energyIndex: residence.propertyObject?.energyIndex?.toNumber(),
312312
},
313313
rentalId,
314+
rentalInformation: !residence.propertyObject?.rentalInformation
315+
? null
316+
: {
317+
type: {
318+
code: residence.propertyObject.rentalInformation
319+
.rentalInformationType.code,
320+
name: residence.propertyObject.rentalInformation
321+
.rentalInformationType.name,
322+
},
323+
},
314324
},
315325
property: {
316326
code: residence.propertyObject.propertyStructures[0].propertyCode,

packages/property-base/src/types/residence.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ export const ResidenceDetailedSchema = z.object({
107107
energyIndex: z.number().optional(),
108108
}),
109109
rentalId: z.string().nullable(),
110+
rentalInformation: z
111+
.object({
112+
type: z.object({
113+
code: z.string(),
114+
name: z.string().nullable(),
115+
}),
116+
})
117+
.nullable(),
110118
}),
111119
property: z.object({
112120
name: z.string().nullable(),

packages/property-tree/src/components/residence/ResidenceBasicInfo.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import {
44
CardHeader,
55
CardTitle,
66
} from '@/components/ui/v2/Card'
7-
import { ResidenceDetails } from '@/services/types'
87
import { useIsMobile } from '../hooks/useMobile'
8+
import { components } from '@/services/api/core/generated/api-types'
9+
10+
type ResidenceDetails = components['schemas']['ResidenceDetails']
911

1012
interface ResidenceBasicInfoProps {
1113
residence: ResidenceDetails
@@ -35,9 +37,9 @@ export const ResidenceBasicInfo = ({ residence }: ResidenceBasicInfoProps) => {
3537
className={`grid ${isMobile ? 'grid-cols-1 gap-y-4' : 'grid-cols-2 md:grid-cols-3 gap-4'}`}
3638
>
3739
<div>
38-
<p className="text-sm text-muted-foreground">Namn</p>
40+
<p className="text-sm text-muted-foreground">Hyresobjektstyp</p>
3941
<p className="font-medium">
40-
{residence.residenceType.name}, {residence.name}
42+
{residence.propertyObject?.rentalInformation?.type.name}
4143
</p>
4244
</div>
4345
<div>

packages/property-tree/src/services/api/core/generated/api-types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,12 @@ export interface components {
23272327
energyIndex?: number;
23282328
};
23292329
rentalId: string | null;
2330+
rentalInformation: ({
2331+
type: {
2332+
code: string;
2333+
name: string | null;
2334+
};
2335+
}) | null;
23302336
};
23312337
property: {
23322338
name: string | null;

packages/property-tree/src/services/api/generated/api-types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,12 @@ export interface components {
621621
energyIndex?: number;
622622
};
623623
rentalId: string | null;
624+
rentalInformation: ({
625+
type: {
626+
code: string;
627+
name: string | null;
628+
};
629+
}) | null;
624630
};
625631
property: {
626632
name: string | null;

packages/property-tree/src/services/api/residenceService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { Residence, ResidenceDetails } from '../types'
1+
import { Residence } from '../types'
22
import { GET } from './core/base-api'
3+
import { components } from './core/generated/api-types'
4+
5+
type ResidenceDetails = components['schemas']['ResidenceDetails']
36

47
export const residenceService = {
58
async getByBuildingCode(buildingCode: string): Promise<Residence[]> {

0 commit comments

Comments
 (0)