|
| 1 | +package no.nav.dagpenger.inntekt.mapping |
| 2 | + |
| 3 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.Aktoer |
| 4 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.AktoerType |
| 5 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.ArbeidsInntektInformasjon |
| 6 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.ArbeidsInntektMaaned |
| 7 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.Inntekt |
| 8 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.InntektBeskrivelse |
| 9 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.InntektType |
| 10 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.InntektkomponentResponse |
| 11 | +import no.nav.dagpenger.inntekt.inntektskomponenten.v1.TilleggInformasjon |
| 12 | +import org.junit.jupiter.api.Test |
| 13 | +import java.math.BigDecimal |
| 14 | +import java.time.YearMonth |
| 15 | +import kotlin.test.assertEquals |
| 16 | +import kotlin.test.assertFalse |
| 17 | +import kotlin.test.assertTrue |
| 18 | + |
| 19 | +val inntektkomponentResponse = |
| 20 | + InntektkomponentResponse( |
| 21 | + ident = |
| 22 | + Aktoer( |
| 23 | + aktoerType = AktoerType.AKTOER_ID, |
| 24 | + identifikator = "2044350291600", |
| 25 | + ), |
| 26 | + arbeidsInntektMaaned = |
| 27 | + listOf( |
| 28 | + ArbeidsInntektMaaned( |
| 29 | + aarMaaned = YearMonth.of(2025, 1), |
| 30 | + arbeidsInntektInformasjon = |
| 31 | + ArbeidsInntektInformasjon( |
| 32 | + inntektListe = |
| 33 | + listOf( |
| 34 | + Inntekt( |
| 35 | + beloep = BigDecimal(50000), |
| 36 | + fordel = "kontantytelse", |
| 37 | + virksomhet = |
| 38 | + Aktoer( |
| 39 | + aktoerType = AktoerType.ORGANISASJON, |
| 40 | + identifikator = "896929119", |
| 41 | + ), |
| 42 | + beskrivelse = InntektBeskrivelse.FASTLOENN, |
| 43 | + inntektType = InntektType.LOENNSINNTEKT, |
| 44 | + inntektskilde = "A-ordningen", |
| 45 | + inntektsstatus = "LoependeInnrapportert", |
| 46 | + opptjeningsland = "NO", |
| 47 | + utbetaltIMaaned = YearMonth.of(2025, 1), |
| 48 | + inntektsmottaker = |
| 49 | + Aktoer( |
| 50 | + aktoerType = AktoerType.AKTOER_ID, |
| 51 | + identifikator = "2044350291600", |
| 52 | + ), |
| 53 | + informasjonsstatus = "InngaarAlltid", |
| 54 | + opplysningspliktig = |
| 55 | + Aktoer( |
| 56 | + aktoerType = AktoerType.ORGANISASJON, |
| 57 | + identifikator = "963743254", |
| 58 | + ), |
| 59 | + inntektsperiodetype = "Maaned", |
| 60 | + tilleggsinformasjon = |
| 61 | + TilleggInformasjon( |
| 62 | + kategori = "NorskKontinentalsokkel", |
| 63 | + tilleggsinformasjonDetaljer = null, |
| 64 | + ), |
| 65 | + skattemessigBosattLand = "NO", |
| 66 | + inngaarIGrunnlagForTrekk = true, |
| 67 | + utloeserArbeidsgiveravgift = true, |
| 68 | + ), |
| 69 | + ), |
| 70 | + ), |
| 71 | + avvikListe = emptyList(), |
| 72 | + ), |
| 73 | + ArbeidsInntektMaaned( |
| 74 | + aarMaaned = YearMonth.of(2025, 2), |
| 75 | + arbeidsInntektInformasjon = |
| 76 | + ArbeidsInntektInformasjon( |
| 77 | + inntektListe = |
| 78 | + listOf( |
| 79 | + Inntekt( |
| 80 | + beloep = BigDecimal(50000), |
| 81 | + fordel = "kontantytelse", |
| 82 | + virksomhet = |
| 83 | + Aktoer( |
| 84 | + aktoerType = AktoerType.ORGANISASJON, |
| 85 | + identifikator = "896929119", |
| 86 | + ), |
| 87 | + beskrivelse = InntektBeskrivelse.FASTLOENN, |
| 88 | + inntektType = InntektType.LOENNSINNTEKT, |
| 89 | + inntektskilde = "A-ordningen", |
| 90 | + inntektsstatus = "LoependeInnrapportert", |
| 91 | + opptjeningsland = "NO", |
| 92 | + utbetaltIMaaned = YearMonth.of(2025, 2), |
| 93 | + inntektsmottaker = |
| 94 | + Aktoer( |
| 95 | + aktoerType = AktoerType.AKTOER_ID, |
| 96 | + identifikator = "2044350291600", |
| 97 | + ), |
| 98 | + informasjonsstatus = "InngaarAlltid", |
| 99 | + opplysningspliktig = |
| 100 | + Aktoer( |
| 101 | + aktoerType = AktoerType.ORGANISASJON, |
| 102 | + identifikator = "963743254", |
| 103 | + ), |
| 104 | + inntektsperiodetype = "Maaned", |
| 105 | + tilleggsinformasjon = |
| 106 | + TilleggInformasjon( |
| 107 | + kategori = "NorskKontinentalsokkel", |
| 108 | + tilleggsinformasjonDetaljer = null, |
| 109 | + ), |
| 110 | + skattemessigBosattLand = "NO", |
| 111 | + inngaarIGrunnlagForTrekk = true, |
| 112 | + utloeserArbeidsgiveravgift = true, |
| 113 | + ), |
| 114 | + ), |
| 115 | + ), |
| 116 | + avvikListe = emptyList(), |
| 117 | + ), |
| 118 | + ArbeidsInntektMaaned( |
| 119 | + aarMaaned = YearMonth.of(2025, 3), |
| 120 | + arbeidsInntektInformasjon = |
| 121 | + ArbeidsInntektInformasjon( |
| 122 | + inntektListe = |
| 123 | + listOf( |
| 124 | + Inntekt( |
| 125 | + beloep = BigDecimal(50000), |
| 126 | + fordel = "kontantytelse", |
| 127 | + virksomhet = |
| 128 | + Aktoer( |
| 129 | + aktoerType = AktoerType.ORGANISASJON, |
| 130 | + identifikator = "896929120", |
| 131 | + ), |
| 132 | + beskrivelse = InntektBeskrivelse.FASTLOENN, |
| 133 | + inntektType = InntektType.LOENNSINNTEKT, |
| 134 | + inntektskilde = "A-ordningen", |
| 135 | + inntektsstatus = "LoependeInnrapportert", |
| 136 | + opptjeningsland = "NO", |
| 137 | + utbetaltIMaaned = YearMonth.of(2025, 3), |
| 138 | + inntektsmottaker = |
| 139 | + Aktoer( |
| 140 | + aktoerType = AktoerType.AKTOER_ID, |
| 141 | + identifikator = "2044350291600", |
| 142 | + ), |
| 143 | + informasjonsstatus = "InngaarAlltid", |
| 144 | + opplysningspliktig = |
| 145 | + Aktoer( |
| 146 | + aktoerType = AktoerType.ORGANISASJON, |
| 147 | + identifikator = "963743254", |
| 148 | + ), |
| 149 | + inntektsperiodetype = "Maaned", |
| 150 | + tilleggsinformasjon = |
| 151 | + TilleggInformasjon( |
| 152 | + kategori = "NorskKontinentalsokkel", |
| 153 | + tilleggsinformasjonDetaljer = null, |
| 154 | + ), |
| 155 | + skattemessigBosattLand = "NO", |
| 156 | + inngaarIGrunnlagForTrekk = true, |
| 157 | + utloeserArbeidsgiveravgift = true, |
| 158 | + ), |
| 159 | + ), |
| 160 | + ), |
| 161 | + avvikListe = emptyList(), |
| 162 | + ), |
| 163 | + ), |
| 164 | + ) |
| 165 | + |
| 166 | +val mottaker = |
| 167 | + Inntektsmottaker( |
| 168 | + pnr = "2044350291600", |
| 169 | + navn = "Ola Nordmann", |
| 170 | + ) |
| 171 | + |
| 172 | +class MapToInntektFrontendTest { |
| 173 | + @Test |
| 174 | + fun `Map inntekt til InntektForVirksomhetMedPersonInformasjon`() { |
| 175 | + val mappedToInntektFrontend = |
| 176 | + mapToInntektFrontend( |
| 177 | + inntektkomponentResponse, |
| 178 | + mottaker, |
| 179 | + ) |
| 180 | + |
| 181 | + assertEquals(2, mappedToInntektFrontend.inntektVirksomhetMaaned.size) |
| 182 | + assertEquals(mottaker, mappedToInntektFrontend.mottaker) |
| 183 | + |
| 184 | + assertTrue { mappedToInntektFrontend.inntektVirksomhetMaaned.any { it.virksomhet == "896929119" } } |
| 185 | + assertTrue { mappedToInntektFrontend.inntektVirksomhetMaaned.any { it.virksomhet == "896929120" } } |
| 186 | + assertFalse { mappedToInntektFrontend.inntektVirksomhetMaaned.any { it.virksomhet == "8969291001" } } |
| 187 | + |
| 188 | + assertEquals( |
| 189 | + 2, |
| 190 | + mappedToInntektFrontend.inntektVirksomhetMaaned |
| 191 | + .filter { it.virksomhet == "896929119" }[0] |
| 192 | + .inntekter |
| 193 | + ?.size, |
| 194 | + ) |
| 195 | + |
| 196 | + assertEquals( |
| 197 | + BigDecimal(100000), |
| 198 | + mappedToInntektFrontend.inntektVirksomhetMaaned |
| 199 | + .filter { it.virksomhet == "896929119" }[0] |
| 200 | + .totalBeløp, |
| 201 | + ) |
| 202 | + |
| 203 | + assertEquals( |
| 204 | + 1, |
| 205 | + mappedToInntektFrontend.inntektVirksomhetMaaned |
| 206 | + .filter { it.virksomhet == "896929120" }[0] |
| 207 | + .inntekter |
| 208 | + ?.size, |
| 209 | + ) |
| 210 | + |
| 211 | + assertEquals( |
| 212 | + BigDecimal(50000), |
| 213 | + mappedToInntektFrontend.inntektVirksomhetMaaned |
| 214 | + .filter { it.virksomhet == "896929120" }[0] |
| 215 | + .totalBeløp, |
| 216 | + ) |
| 217 | + } |
| 218 | +} |
0 commit comments