Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change overMaxPrice error message to be more correct #451

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/common/schemas/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const errorMessages = {
urlInvalid: "Virheellinen www-osoite",
APIIdMin: "Rajapinnan palauttamassa ID-arvossa liian vähän merkkejä",
APIIdMax: "Rajapinnan palauttamassa ID-arvossa on liian monta merkkiä",
overMaxPrice: "Kauppahinta ylittää enimmäishinnan",
overMaxPrice: "Velaton kauppahinta ylittää velattoman enimmäishinnan",
priceHigherThanUnconfirmedMaxPrice: "Velaton kauppahinta ylittää rajaneliöhinnan.",
loanShareChanged: "Lainaosuus muuttunut laskelmasta",
loanShareChangedCatalog: "Lainaosuus muuttunut myyntihintaluettelon tiedoista",
Expand Down
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
Loading