Skip to content

Commit

Permalink
frontend: Change apartment sale validation to compare only debtFreePu…
Browse files Browse the repository at this point in the history
…rchasePrice to its maximum
  • Loading branch information
indigane committed Apr 25, 2024
1 parent 7c9760c commit 482d6b3
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions frontend/src/features/apartment/ApartmentSalePage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const getRefinedApartmentSaleFormSchema = (apartment, maximumPrices, warn
// Normal apartment sale with confirmed maximum price calculation
else {
// Price can not be bigger than the maximum price calculations maximum price.
if (data.purchase_price && data.purchase_price > Math.round(maximumPrices.maximumPrice)) {
if (debtFreePurchasePrice > Math.round(maximumPrices.debtFreePurchasePrice)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["maximum_price_calculation"],
Expand All @@ -141,19 +141,6 @@ export const getRefinedApartmentSaleFormSchema = (apartment, maximumPrices, warn
}
}

// The apartment share of housing company loans must match the maximum price calculations value
if (
isCalculationValid &&
data.apartment_share_of_housing_company_loans !== null &&
data.apartment_share_of_housing_company_loans !== maximumPrices.apartmentShareOfHousingCompanyLoans
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["apartment_share_of_housing_company_loans"],
message: errorMessages.loanShareChanged,
});
}

// Warn that the price is over a million, as it is a rare case and might be a mistake.
if (!warningsGiven.purchase_price_over_million) {
if (data.purchase_price && data.purchase_price > 999999) {
Expand Down

0 comments on commit 482d6b3

Please sign in to comment.