Skip to content

Commit

Permalink
Tulotiedot/alennukset vapautukset ja korotukset: kuka muokannut ja mi…
Browse files Browse the repository at this point in the history
…lloin (#5910)
  • Loading branch information
kechpaja-at-gofore authored Nov 7, 2024
1 parent b1e8027 commit b4d467f
Show file tree
Hide file tree
Showing 41 changed files with 338 additions and 201 deletions.
4 changes: 2 additions & 2 deletions frontend/src/e2e-test/dev-api/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ export class Fixture {
}

static income(
initial: SemiPartial<DevIncome, 'personId' | 'updatedBy'>
initial: SemiPartial<DevIncome, 'personId' | 'modifiedBy'>
): IncomeBuilder {
return new IncomeBuilder({
id: uuidv4(),
Expand All @@ -806,7 +806,7 @@ export class Fixture {
}
},
effect: 'INCOME',
updatedAt: HelsinkiDateTime.now(),
modifiedAt: HelsinkiDateTime.now(),
isEntrepreneur: false,
worksAtEcha: false,
...initial
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/e2e-test/generated/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,9 @@ export interface DevIncome {
effect: IncomeEffect
id: UUID
isEntrepreneur: boolean
modifiedAt: HelsinkiDateTime
modifiedBy: UUID
personId: UUID
updatedAt: HelsinkiDateTime
updatedBy: UUID
validFrom: LocalDate
validTo: LocalDate | null
worksAtEcha: boolean
Expand Down Expand Up @@ -1391,7 +1391,7 @@ export function deserializeJsonDevHoliday(json: JsonOf<DevHoliday>): DevHoliday
export function deserializeJsonDevIncome(json: JsonOf<DevIncome>): DevIncome {
return {
...json,
updatedAt: HelsinkiDateTime.parseIso(json.updatedAt),
modifiedAt: HelsinkiDateTime.parseIso(json.modifiedAt),
validFrom: LocalDate.parseIso(json.validFrom),
validTo: (json.validTo != null) ? LocalDate.parseIso(json.validTo) : null
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/e2e-test/specs/0_citizen/citizen-income.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ describe.each(e)('Citizen income (%s)', (env) => {
personId: guardian.id,
validFrom: placementStart,
validTo: incomeEndDate,
updatedBy: financeAdminId,
updatedAt: placementStart.toHelsinkiDateTime(LocalTime.of(0, 0))
modifiedBy: financeAdminId,
modifiedAt: placementStart.toHelsinkiDateTime(LocalTime.of(0, 0))
}).save()

await Fixture.fridgeChild({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('Employee - Head of family details', () => {
coefficient: 'MONTHLY_NO_HOLIDAY_BONUS'
}
},
updatedBy: employee.id
modifiedBy: employee.id
}).save()

const totalChildIncome = 1234
Expand All @@ -229,7 +229,7 @@ describe('Employee - Head of family details', () => {
coefficient: 'MONTHLY_NO_HOLIDAY_BONUS'
}
},
updatedBy: employee.id
modifiedBy: employee.id
}).save()

await guardianInformation.navigateToGuardian(regularPerson.id)
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/e2e-test/specs/5_employee/income.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ describe('Income', () => {
personId: personId,
validFrom: placementStart,
validTo: incomeEndDate,
updatedBy: financeAdminId,
updatedAt: placementStart.toHelsinkiDateTime(LocalTime.of(0, 0))
modifiedBy: financeAdminId,
modifiedAt: placementStart.toHelsinkiDateTime(LocalTime.of(0, 0))
}).save()

await Fixture.incomeNotification({
Expand Down Expand Up @@ -312,8 +312,8 @@ describe('Income', () => {
personId: personId,
validFrom: placementStart,
validTo: incomeEndDate,
updatedBy: financeAdminId,
updatedAt: placementStart.toHelsinkiDateTime(LocalTime.of(0, 0))
modifiedBy: financeAdminId,
modifiedAt: placementStart.toHelsinkiDateTime(LocalTime.of(0, 0))
}).save()

await page.reload()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default React.memo(function FeeAlteration({
cancel={() => clearUiMode()}
create={(data) =>
createFeeAlteration({
body: { ...data, updatedBy: null, updatedAt: null }
body: { ...data, modifiedBy: null, modifiedAt: null }
})
}
onSuccess={clearUiMode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
FeeAlterationWithPermittedActions
} from 'lib-common/generated/api-types/invoicing'
import { UUID } from 'lib-common/types'
import Tooltip from 'lib-components/atoms/Tooltip'
import { IconOnlyButton } from 'lib-components/atoms/buttons/IconOnlyButton'
import ListGrid from 'lib-components/layout/ListGrid'
import {
Expand Down Expand Up @@ -87,6 +88,22 @@ export default React.memo(function FeeAlterationList({
}`}</Dates>
<span>{feeAlteration.notes}</span>
</FixedSpaceRow>
{feeAlteration.modifiedAt && (
<FixedSpaceRow spacing="L">
<Tooltip
tooltip={
feeAlteration.modifiedBy &&
i18n.childInformation.feeAlteration.lastModifiedBy(
feeAlteration.modifiedBy.name
)
}
>
{i18n.childInformation.feeAlteration.lastModifiedAt(
feeAlteration.modifiedAt.format()
)}
</Tooltip>
</FixedSpaceRow>
)}
<FixedSpaceRow>
{permittedActions.includes('UPDATE') && (
<IconOnlyButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ const IncomeItemBody = React.memo(function IncomeItemBody({
<Label>{i18n.personProfile.income.details.notes}</Label>
<span>{income.notes}</span>
<Label>{i18n.personProfile.income.details.updated}</Label>
<span>{income.updatedAt?.toLocalDate().format()}</span>
<span>{income.modifiedAt?.toLocalDate().format()}</span>
<Label>{i18n.personProfile.income.details.handler}</Label>
<span>
{income.applicationId
? i18n.personProfile.income.details.originApplication
: income.updatedBy}
: income.modifiedBy.name}
</span>
{income.applicationId !== null && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ const IncomeItemEditor = React.memo(function IncomeItemEditor(props: Props) {
<Gap size="L" />
<ListGrid labelWidth="fit-content(40%)" rowGap="xs" columnGap="L">
<Label>{i18n.personProfile.income.details.updated}</Label>
<span>{props.baseIncome.updatedAt.toLocalDate().format()}</span>
<span>{props.baseIncome.modifiedAt.toLocalDate().format()}</span>

<Label>{i18n.personProfile.income.details.handler}</Label>
<span>{props.baseIncome.updatedBy}</span>
<span>{props.baseIncome.modifiedBy.name}</span>
</ListGrid>
</>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import styled from 'styled-components'

import { useTranslation } from 'employee-frontend/state/i18n'
import { Action } from 'lib-common/generated/action'
import { EvakaUser } from 'lib-common/generated/api-types/user'
import HelsinkiDateTime from 'lib-common/helsinki-date-time'
import { scrollRefIntoView } from 'lib-common/utils/scrolling'
import Title from 'lib-components/atoms/Title'
import Tooltip from 'lib-components/atoms/Tooltip'
import { IconOnlyButton } from 'lib-components/atoms/buttons/IconOnlyButton'
import { FixedSpaceRow } from 'lib-components/layout/flex-helpers'
import colors from 'lib-customizations/common'
Expand Down Expand Up @@ -47,11 +50,15 @@ interface Props {
startEditing: () => void
startDeleting: () => void
permittedActions: Action.Income[]
modifiedBy?: EvakaUser | null
modifiedAt?: HelsinkiDateTime | null
children?: React.JSX.Element[] | React.JSX.Element
}

const IncomeItemHeader = React.memo(function IncomeItemHeader({
title: period,
modifiedBy,
modifiedAt,
isOpen,
toggle,
editable,
Expand All @@ -76,6 +83,18 @@ const IncomeItemHeader = React.memo(function IncomeItemHeader({
<span>{period}</span>
</Title>
</ItemTitle>
{modifiedAt && (
<Row>
<Tooltip
tooltip={
modifiedBy &&
i18n.personProfile.income.lastModifiedBy(modifiedBy.name)
}
>
{i18n.personProfile.income.lastModifiedAt(modifiedAt.format())}
</Tooltip>
</Row>
)}
<Row>
{permittedActions.includes('UPDATE') && (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ const IncomeList = React.memo(function IncomeList({
startEditing={() => setEditing(item.id)}
startDeleting={() => setDeleting(item.id)}
permittedActions={permittedActions}
modifiedBy={item.modifiedBy}
modifiedAt={item.modifiedAt}
/>
{incomeNotificationsForIncome(item).length > 0 && (
<IncomeNotifications
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/employee-frontend/types/fee-alteration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import { FeeAlteration } from 'lib-common/generated/api-types/invoicing'

export type PartialFeeAlteration = Omit<
FeeAlteration,
'updatedAt' | 'updatedBy'
'modifiedAt' | 'modifiedBy'
>
13 changes: 7 additions & 6 deletions frontend/src/lib-common/generated/api-types/invoicing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import LocalDate from '../../local-date'
import YearMonth from '../../year-month'
import { Action } from '../action'
import { CareType } from './daycare'
import { EvakaUser } from './user'
import { IncomeAttachment } from './attachment'
import { JsonOf } from '../../json'
import { PlacementType } from './placement'
Expand Down Expand Up @@ -75,11 +76,11 @@ export interface FeeAlteration {
attachments: FeeAlterationAttachment[]
id: UUID | null
isAbsolute: boolean
modifiedAt: HelsinkiDateTime | null
modifiedBy: EvakaUser | null
notes: string
personId: UUID
type: FeeAlterationType
updatedAt: HelsinkiDateTime | null
updatedBy: UUID | null
validFrom: LocalDate
validTo: LocalDate | null
}
Expand Down Expand Up @@ -389,13 +390,13 @@ export interface Income {
effect: IncomeEffect
id: UUID
isEntrepreneur: boolean
modifiedAt: HelsinkiDateTime
modifiedBy: EvakaUser
notes: string
personId: UUID
total: number
totalExpenses: number
totalIncome: number
updatedAt: HelsinkiDateTime
updatedBy: string
validFrom: LocalDate
validTo: LocalDate | null
worksAtECHA: boolean
Expand Down Expand Up @@ -1125,7 +1126,7 @@ export function deserializeJsonCreateRetroactiveFeeDecisionsBody(json: JsonOf<Cr
export function deserializeJsonFeeAlteration(json: JsonOf<FeeAlteration>): FeeAlteration {
return {
...json,
updatedAt: (json.updatedAt != null) ? HelsinkiDateTime.parseIso(json.updatedAt) : null,
modifiedAt: (json.modifiedAt != null) ? HelsinkiDateTime.parseIso(json.modifiedAt) : null,
validFrom: LocalDate.parseIso(json.validFrom),
validTo: (json.validTo != null) ? LocalDate.parseIso(json.validTo) : null
}
Expand Down Expand Up @@ -1216,7 +1217,7 @@ export function deserializeJsonFeeThresholdsWithId(json: JsonOf<FeeThresholdsWit
export function deserializeJsonIncome(json: JsonOf<Income>): Income {
return {
...json,
updatedAt: HelsinkiDateTime.parseIso(json.updatedAt),
modifiedAt: HelsinkiDateTime.parseIso(json.modifiedAt),
validFrom: LocalDate.parseIso(json.validFrom),
validTo: (json.validTo != null) ? LocalDate.parseIso(json.validTo) : null
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/lib-customizations/defaults/employee/i18n/fi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,8 @@ export const fi = {
updateError: 'Maksumuutoksen tallennus epäonnistui',
deleteError: 'Maksumuutoksen poisto epäonnistui',
confirmDelete: 'Haluatko poistaa maksumuutoksen?',
lastModifiedAt: (date: string) => `Viimeksi muokattu ${date}`,
lastModifiedBy: (name: string) => `Muokkaaja: ${name}`,
editor: {
titleNew: 'Lisää uusi alennus tai korotus',
titleEdit: 'Muokkaa alennusta tai korotusta',
Expand Down Expand Up @@ -1869,6 +1871,8 @@ export const fi = {
title: 'Tulotiedot',
itemHeader: 'Tulotiedot ajalle',
itemHeaderNew: 'Uusi tulotieto',
lastModifiedAt: (date: string) => `Viimeksi muokattu ${date}`,
lastModifiedBy: (name: string) => `Muokkaaja: ${name}`,
details: {
attachments: 'Liitteet',
name: 'Nimi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,6 @@ fun DevEmployee.toEmployeeWithName() =
fun DevEmployee.toEvakaUser() =
EvakaUser(
id = EvakaUserId(this.id.raw),
name = this.firstName + " " + this.lastName,
name = this.lastName + " " + this.firstName,
type = EvakaUserType.EMPLOYEE,
)
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class AttachmentQueriesTest : PureJdbiTest(resetDbBeforeEach = true) {
)
income =
AttachmentParent.Income(
tx.insert(DevIncome(personId = guardian.id, updatedBy = admin.evakaUserId))
tx.insert(DevIncome(personId = guardian.id, modifiedBy = admin.evakaUserId))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class AttachmentServiceTest : PureJdbiTest(resetDbBeforeEach = true) {
insert(
DevIncome(
personId = insert(DevPerson(), DevPersonType.ADULT),
updatedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
modifiedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ class IncomeStatementControllerIntegrationTest : FullApplicationTest(resetDbBefo
tx.insert(
DevIncome(
personId = citizenId,
updatedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
modifiedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
validFrom = incomeDate1.minusYears(1),
validTo = incomeDate1.minusMonths(1).minusDays(1),
)
)
tx.insert(
DevIncome(
personId = citizenId,
updatedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
modifiedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
validFrom = incomeDate1.minusMonths(1),
validTo = incomeDate1,
)
Expand Down Expand Up @@ -366,15 +366,15 @@ class IncomeStatementControllerIntegrationTest : FullApplicationTest(resetDbBefo
tx.insert(
DevIncome(
personId = testAdult_2.id,
updatedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
modifiedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
validFrom = incomeDate2.minusMonths(1),
validTo = incomeDate2.minusDays(1),
)
)
tx.insert(
DevIncome(
personId = testAdult_2.id,
updatedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
modifiedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
effect = IncomeEffect.MAX_FEE_ACCEPTED,
validFrom = incomeDate2,
validTo = null,
Expand Down Expand Up @@ -1138,7 +1138,7 @@ class IncomeStatementControllerIntegrationTest : FullApplicationTest(resetDbBefo
tx.insert(
DevIncome(
personId = citizenId,
updatedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
modifiedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
validFrom = incomeRange1.start,
validTo = incomeRange1.end,
)
Expand All @@ -1164,7 +1164,7 @@ class IncomeStatementControllerIntegrationTest : FullApplicationTest(resetDbBefo
tx.insert(
DevIncome(
personId = testAdult_2.id,
updatedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
modifiedBy = AuthenticatedUser.SystemInternalUser.evakaUserId,
validFrom = incomeRange2.start,
validTo = incomeRange2.end,
)
Expand Down
Loading

0 comments on commit b4d467f

Please sign in to comment.