본문으로 건너뛰기
cccskills
무료GitHub에 공개

inntekt-skatt

Expert knowledge of income and tax integrations in melosys-api. Use when: (1) Understanding Inntektskomponenten/A-inntekt lookups, (2) Debugging skattehendelser Kafka processing, (3) Understanding årsavregning triggered by skatteoppgjør, (4) Investigating income data for trygdeavgift calculations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Confluence
설치 방법 보기

포함된 파일(2)

  • SKILL.md8.5 KB
  • references/debugging.md7.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Inntekt og Skatt Skill

Expert knowledge of income data (Inntektskomponenten) and tax event (skattehendelser) integrations.

Quick Reference

Key Components

ComponentLocationPurpose
InntektServiceintegrasjon/src/main/kotlin/.../inntekt/Fetches income data from Inntektskomponenten
InntektClientintegrasjon/src/main/kotlin/.../inntekt/WebClient REST client for Inntektskomponenten API (POST /hentinntektliste)
InntektClientConfigintegrasjon/src/main/kotlin/.../inntekt/Configures the inntektClient bean (base URL, Azure auth filter)
InntektKonverterintegrasjon/src/main/kotlin/.../inntekt/Converts API response to domain model
SkattehendelserConsumerservice/src/main/kotlin/.../aarsavregning/Kafka consumer for tax events
ÅrsavregningServiceservice/src/main/kotlin/.../aarsavregning/Annual reconciliation processing

Data Sources

SourceServiceDataUse Case
InntektskomponentenA-inntekt REST APIMonthly income by employerSaksopplysninger, trygdeavgift
Skattehendelsermelosys-skattehendelser KafkaTax settlement notificationsTrigger årsavregning

Inntektskomponenten Integration

API Request

InntektRequest(
    ainntektsfilter = "MedlemskapA-inntekt",
    formaal = "Medlemskap",
    ident = Aktoer(aktørId, AktoerType.AKTOER_ID),
    maanedFom = YearMonth.of(2024, 1),
    maanedTom = YearMonth.of(2024, 12)
)

Configuration

# application-nais.yml binds the base URL from an env var
inntekt:
  rest:
    url: ${INNTEKT_REST_V1_ENDPOINTURL}
# e.g. q2: https://team-inntekt-proxy.dev-fss-pub.nais.io/proxy/inntektskomponenten-q2/rs/api/v1

Data Limitations

  • Data available from January 2015 onwards
  • Queries before 2015 return empty response automatically
  • Uses filter MedlemskapA-inntekt for membership-relevant income

Income Types

TypeDescription
LOENNSINNTEKTSalary/wages
NAERINGSINNTEKTSelf-employment income
PENSJON_ELLER_TRYGDPension or social security
YTELSE_FRA_OFFENTLIGEPublic benefits

Key Fields in Response

data class Inntekt(
    val inntektType: InntektType,
    val beloep: BigDecimal,           // Amount
    val utbetaltIMaaned: YearMonth,   // Payment month
    val opptjeningsland: String?,     // Earning country (ISO-2)
    val opptjeningsperiodeFom: LocalDate?,
    val opptjeningsperiodeTom: LocalDate?,
    val skattemessigBosattLand: String?,  // Tax residence
    val virksomhet: Aktoer?,          // Employer org number
    val beskrivelse: String?          // Income description
)

Skattehendelser Integration

Kafka Configuration

@KafkaListener(
    topics = ["\${kafka.aiven.skattehendelser.topic}"],
    containerFactory = "aivenSkattehendelserListenerContainerFactory"
)

Skattehendelse Message

data class Skattehendelse(
    val gjelderPeriode: String,  // Year (e.g., "2024"), parsed with .toInt()
    val identifikator: String,   // Person identifier (used as aktørId in fagsak lookup)
    val hendelsetype: String,
)

Processing Flow

1. melosys-skattehendelser receives tax settlement from Skatteetaten
   ↓
2. Publishes event to Kafka topic
   ↓
3. SkattehendelserConsumer receives event
   ↓
4. Finds all fagsaker with trygdeavgift for this person/year
   ↓
5. For each sak: creates årsavregning behandling if needed
   ↓
6. Prosessinstans with prosess_type OPPRETT_NY_BEHANDLING_AARSAVREGNING starts
   (later IVERKSETT_VEDTAK_AARSAVREGNING iverksetter vedtaket)

Feature Toggle

if (unleash.isEnabled(ToggleName.MELOSYS_SKATTEHENDELSE_CONSUMER)) {
    // Process skattehendelse
}

Domain Model

Saksopplysning for Income

Saksopplysning().apply {
    type = SaksopplysningType.INNTK
    kildesystem = SaksopplysningKildesystem.INNTK
    versjon = "REST 1.0"
    dokument = InntektDokument().apply {
        arbeidsInntektMaanedListe = [...]
    }
}

InntektDokument Structure

InntektDokument
├── arbeidsInntektMaanedListe: List<ArbeidsInntektMaaned>
    ├── aarMaaned: YearMonth
    ├── avvikListe: List<Avvik>
    └── arbeidsInntektInformasjon
        ├── inntektListe: List<Inntekt>
        └── arbeidsforholdListe: List<ArbeidsforholdFrilanser>

Common Debugging

See references/debugging.md for symptom-based debug steps, log messages to search for, and the full set of diagnostic SQL queries.

Check Stored Income Data

-- Find income saksopplysning for behandling.
-- Physical columns are opplysning_type and registrert_dato (the JPA field is `type`).
SELECT s.id, s.opplysning_type, s.versjon, s.registrert_dato, s.dokument
FROM saksopplysning s
WHERE s.behandling_id = :behandlingId
AND s.opplysning_type = 'INNTK';

-- Parse income from JSON
SELECT id,
       JSON_VALUE(dokument, '$.arbeidsInntektMaanedListe[0].aarMaaned') as first_month
FROM saksopplysning
WHERE opplysning_type = 'INNTK' AND behandling_id = :behandlingId;

Trace Skattehendelse Processing

-- Find årsavregning created from skattehendelse.
-- behandling joins fagsak via saksnummer; behandling type is beh_type ('ÅRSAVREGNING').
-- The reconciliation year (aar) lives in the aarsavregning table,
-- keyed by behandlingsresultat_id (= behandlingsresultat.behandling_id).
SELECT b.id, b.status, b.beh_type, aa.aar
FROM behandling b
JOIN behandlingsresultat br ON br.behandling_id = b.id
JOIN aarsavregning aa ON aa.behandlingsresultat_id = br.behandling_id
WHERE b.saksnummer = :saksnummer
AND b.beh_type = 'ÅRSAVREGNING'
ORDER BY b.registrert_dato DESC;

Check Prosessinstans for Årsavregning

-- prosessinstans stores prosess_type and the last completed step inline (PK is uuid).
-- prosess_steg is just a (kode, navn) lookup table.
SELECT pi.uuid, pi.prosess_type, pi.sist_fullfort_steg, pi.endret_dato
FROM prosessinstans pi
WHERE pi.behandling_id = :behandlingId
AND pi.prosess_type IN ('OPPRETT_NY_BEHANDLING_AARSAVREGNING', 'IVERKSETT_VEDTAK_AARSAVREGNING')
ORDER BY pi.endret_dato DESC;

Integration with Trygdeavgift

Income data feeds the avgift calculation in two contexts:

  1. Foreløpig/forskudd beregning - Estimate avgift based on expected income
  2. Årsavregning - Final calculation based on actual income from skatteoppgjør

Within both contexts, two calculation rules can cap or replace the ordinary rate-based amount (folketrygdloven § 23-3 fjerde ledd):

  • 25%-regelen - The avgift cannot exceed 25% of the part of income that exceeds a minstebeløp; if that is lower than ordinary sats × inntekt, the 25% result is used. (Avgiftsberegningstype.TJUEFEM_PROSENT_REGEL.)
  • Minstebeløp - Income below the minstebeløp gives no avgift (Avgiftsberegningstype.MINSTEBELOEP).

Note: this trygdeavgift 25%-regel is unrelated to the lovvalg 25%-rule (forordning 987/2009 art. 14 nr. 8, "vesentlig del" of work) despite the shared name.

Income from a behandling is read via Behandling.hentInntektDokument(); InntektService.hentInntektListe(personID, fom, tom) fetches fresh data from Inntektskomponenten and returns a Saksopplysning.

Kafka Topics

TopicProducerConsumerPurpose
teammelosys.skattehendelser.v1melosys-skattehendelserSkattehendelserConsumer (group teammelosys.skattehendelser-consumer)Tax settlement notifications

External Systems

Inntektskomponenten

  • REST API for A-inntekt (income reported by employers)
  • Part of NAV's income registry
  • Documentation: Internal NAV confluence

melosys-skattehendelser

  • Separate service that polls Skatteetaten for tax events
  • Uses Sigrun/Skatteetaten APIs internally
  • Publishes simplified events to Kafka for melosys-api

Related Skills

  • trygdeavgift: Uses income for avgift calculation
  • behandlingsresultat: Stores årsavregning results
  • saksflyt: Årsavregning saga processing

External Documentation

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Expert knowledge of Altinn A1 application processing for posted workers in melosys-api. Use when: (1) Understanding Altinn søknad/skjema processing, (2) Debugging MedlemskapArbeidEOS form mapping, (3) Understanding SoeknadMapper transformations, (4) Investigating posted worker application issues, (5) Understanding the MOTTAK_SOKNAD_ALTINN saga flow.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

navikt/melosys-api22026년 10월 22일 업데이트

Expert knowledge of Employer/Employment integration (EREG/AAREG) in melosys-api. Use when: (1) Working with organization data from EREG (Enhetsregisteret), (2) Working with employment data from AAREG (Arbeidsforhold), (3) Understanding employer/organization lookup, (4) Debugging employer or employment issues, (5) Understanding the mapping between register data and domain models. Triggers: orgnummer, arbeidsforhold, EREG, AAREG, Enhetsregisteret, registeropplysninger, ansettelsesperiode, saksopplysning.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

navikt/melosys-api22026년 10월 22일 업데이트

Modular monolith architecture overview for melosys-api. Use when needing to understand module structure, dependencies between modules, where to place new code, or when changes in one module might affect others. Triggers: "architecture", "module dependencies", "where should I put", "which modules", "dependency graph".

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

navikt/melosys-api22026년 10월 22일 업데이트

Expert knowledge of Behandling (case treatment) domain in melosys-api. Use when: (1) Understanding the behandling lifecycle and status transitions, (2) Debugging issues with behandling creation, status changes, or closure, (3) Understanding relationships between Fagsak, Behandling, and Behandlingsresultat, (4) Investigating why a behandling is stuck or has wrong status, (5) Understanding Behandlingstyper, Behandlingstema, Behandlingsstatus enums, (6) Debugging journalføring or SED-triggered behandling creation, (7) Understanding behandling creation via saksflyt sagas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

navikt/melosys-api22026년 10월 22일 업데이트

Expert knowledge of Behandlingsresultat (treatment result) domain in melosys-api. Use when: (1) Understanding result types and their meaning (FASTSATT_LOVVALGSLAND, MEDLEM_I_FOLKETRYGDEN, etc.), (2) Working with periods - Lovvalgsperiode, Medlemskapsperiode, Anmodningsperiode, Utpekingsperiode, (3) Debugging vedtak/decision metadata, criteria evaluation, or social insurance charges, (4) Understanding EU/EEA coordination logic and Article 16 exception handling, (5) Working with trygdeavgift (social insurance charge) calculations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

navikt/melosys-api22026년 10월 22일 업데이트

brev

무료

Expert knowledge of Brev (letter generation) in melosys-api. Use when: (1) Producing letters and decision documents (vedtaksbrev), (2) Understanding Dokgen templates and mapping, (3) Configuring letter recipients and distribution, (4) Debugging letter generation issues, (5) Adding new letter types or templates.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

navikt/melosys-api22026년 10월 22일 업데이트

navikt의 스킬 모두 보기

이 스킬의 문제 신고