diff --git a/src/Handler/Utils/Company.hs b/src/Handler/Utils/Company.hs index 81b76d10f..5ee079280 100644 --- a/src/Handler/Utils/Company.hs +++ b/src/Handler/Utils/Company.hs @@ -169,6 +169,10 @@ switchAvsUserCompany usrPostEmailUpds keepOldCompanySupervs uid newCompanyId = d usrDisplayEmailUp = toMaybe (usrPostEmailUpds && avsEmail == Just usrDisplayEmail) (UserDisplayEmail =. "") -- delete DisplayEmail, if equal to AVS Firm Email usrUpdate = catMaybes [usrPostUp, usrPrefPostUp, usrDisplayEmailUp] -- [UserPostAddress =. Nothing, UserPrefersPostal =. companyPrefersPostal newCompany] -- unconditional + + newUserComp = UserCompany uid newCompanyId False False 1 True Nothing -- default value for new company insertion, if no update can be done + superReasonComDef = tshow SupervisorReasonCompanyDefault + -- update uid usrUpdate -- repsertSuperiorSupervisor is not called here, since the Superior is indepentent of the actual company association case mbUsrComp of @@ -180,7 +184,7 @@ switchAvsUserCompany usrPostEmailUpds keepOldCompanySupervs uid newCompanyId = d | newCompanyId == oldCompanyId -> return mempty -- nothing to do | otherwise -> do -- switch company when (isNothing oldAssocReason) $ deleteBy $ UniqueUserCompany uid oldCompanyId - void $ upsertBy (UniqueUserCompany uid newCompanyId) newUserComp + void $ upsertBy (UniqueUserCompany uid newCompanyId) newUserComp{userCompanyPriority = succ oldPrio} [UserCompanyPriority =. succ oldPrio, UserCompanySupervisor =. False, UserCompanySupervisorReroute =. False, UserCompanyUseCompanyAddress =. True, UserCompanyReason =. Nothing] -- supervised by uid supervisees :: [(Entity UserSupervisor, E.Value Bool)] <- E.select $ do @@ -213,9 +217,6 @@ switchAvsUserCompany usrPostEmailUpds keepOldCompanySupervs uid newCompanyId = d $ bcons isNoLongerSupervised (AdminProblemNewlyUnsupervised uid (Just oldCompanyId) newCompanyId) newlyUnsupervised return (usrUpdate ,problems) - where - newUserComp = UserCompany uid newCompanyId False False 1 True Nothing -- default value for new company insertion, if no update can be done - superReasonComDef = tshow SupervisorReasonCompanyDefault defaultSupervisorReasonFilter :: [Filter UserSupervisor] defaultSupervisorReasonFilter =