openapi: 3.0.3
info:
  title: API ERP Canonical – EOD (FK / finance & accounting)
  description: Komponenty schemas wygenerowane z repozytoryjnych definitions JSON Schema (schemas/). Pełne ścieżki HTTP mogą być
    rozszerzone osobno.
  version: 1.0.0
paths: {}
components:
  schemas:
    AccountingVariant:
      title: AccountingVariant
      description: AccountingVariant — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      allOf:
        - $ref: "#/components/schemas/DomainResource"
        - type: object
          properties:
            name:
              description: nazwa
              type: string
              minLength: 1
              maxLength: 50
    Address:
      title: Address
      description: Address — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        type:
          $ref: "#/components/schemas/CodeableConcept"
        use:
          $ref: "#/components/schemas/CodeableConcept"
        component:
          type: array
          items:
            $ref: "#/components/schemas/CodeableConcept"
    AllocationItem:
      title: AllocationItem
      description: Pozycja alokacji dla PostingInstruction: typ alokacji KR/KO oraz jedna ze sciezek mapowania (formulaComponent, costCarrier lub valueString).
      version: 2.0.0-draft
      type: object
      required:
        - type
      properties:
        type:
          $ref: "#/components/schemas/CodeableConcept"
          description: Typ alokacji z ValueSet posting-instruction-allocation-type (np. KR, KO).
        formulaComponent:
          $ref: "#/components/schemas/Reference"
          description: Skladnik formuly - sciezka KO/KR przez przepis.
        costCarrier:
          $ref: "#/components/schemas/Reference"
          description: Nosnik kosztow - alternatywna sciezka KO.
        weight:
          type: number
          minimum: 0
          maximum: 100
          description: Udzial procentowy 0-100 przy rozbiciu; brak oznacza rowny podzial wsrod wpisow tego samego type na pozycji.
        valueString:
          type: string
          description: Wariant 3 (migracja): kody alokacji lub @symbol nosnika kosztow (opcjonalnie z wagami).
    AllocationWeight:
      title: AllocationWeight
      description: Waga w pozycji alokacji.
      version: 1.0.0
      type: object
      properties:
        code:
          $ref: "#/components/schemas/CodeableConcept"
          description: Kod elementu schematu podziału
        weight:
          type: number
          description: Waga liczbowa
    Attachment:
      title: Attachment
      description: Attachment — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        contentType:
          type: string
        url:
          type: string
          format: uri
        data:
          type: string
          format: byte
        title:
          type: string
        size:
          type: integer
        basedOn:
          $ref: "#/components/schemas/Reference"
          description: Referencja do innego Attachment (zasób źródłowy)
    Attribute:
      title: Attribute
      description: >-
        Cecha – identyfikator (code: CodeableConcept) i wartość (value: ValueItem).
        ValueItem niesie opcjonalny typ oraz jeden wariant: quantity, money,
        string, integer, boolean, codeableConcept lub reference.
      version: 1.1.0
      type: object
      properties:
        code:
          $ref: "#/components/schemas/CodeableConcept"
        value:
          $ref: "#/components/schemas/ValueItem"
          description: Wartość cechy
    BankAccount:
      title: BankAccount
      description: BankAccount — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        id:
          type: string
        meta:
          $ref: "#/components/schemas/Meta"
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        accountNumber:
          type: string
        bankName:
          type: string
        swiftCode:
          type: string
        owner:
          $ref: "#/components/schemas/Reference"
        ledgerAccount:
          $ref: "#/components/schemas/Reference"
        currency:
          $ref: "#/components/schemas/CodeableConcept"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        isDefault:
          type: boolean
    CodeableConcept:
      title: CodeableConcept
      description: CodeableConcept — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        coding:
          type: array
          items:
            type: object
            properties:
              system:
                type: string
              code:
                type: string
              display:
                type: string
    ContactPoint:
      title: ContactPoint
      description: ContactPoint — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        system:
          $ref: "#/components/schemas/CodeableConcept"
        value:
          type: string
    DeliveryScheduleLine:
      title: DeliveryScheduleLine
      description: Linia harmonogramu dostawy — termin i ilość w ramach harmonogramu pozycji zamówienia zakupu.
      version: 1.0.0
      type: object
      properties:
        date:
          type: string
          format: date
        quantity:
          $ref: "#/components/schemas/Quantity"
    Document:
      title: Document
      description: Dokument kanoniczny; rozszerza DomainResource. Pola profilu FK (płatność, daty księgowe itd.) wyraża się przez
        attribute[] lub Profile — poza rdzeniem tego zasobu.
      version: 1.1.0
      type: object
      properties:
        id:
          type: string
        meta:
          $ref: "#/components/schemas/Meta"
        owner:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
          description: "Identyfikatory owner (pole JSON: owner)."
        comment:
          type: string
        category:
          type: array
          items:
            $ref: "#/components/schemas/CodeableConcept"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        type:
          $ref: "#/components/schemas/CodeableConcept"
        contained:
          type: array
          items:
            type: object
          description: "Zasoby zagnieżdżone (pole JSON: contained)."
        attribute:
          type: array
          items:
            $ref: "#/components/schemas/Attribute"
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        space:
          $ref: "#/components/schemas/CodeableConcept"
          description: Przestrzeń dokumentu (np. fk-inbox, eod, whs)
        issueDate:
          type: string
          format: date
        participant:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
        relatedDocument:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
        position:
          type: array
          items:
            $ref: "#/components/schemas/DocumentPosition"
        attachment:
          type: array
          items:
            $ref: "#/components/schemas/Attachment"
        statusDate:
          type: string
          format: date-time
        expectedDate:
          type: string
          format: date
        realizationDate:
          type: string
          format: date
    DocumentPosition:
      title: DocumentPosition
      description: Pozycja dokumentu.
      version: 1.1.0
      type: object
      properties:
        code:
          $ref: "#/components/schemas/CodeableConcept"
        positionNo:
          type: integer
          minimum: 1
          description: Numer pozycji w dokumencie (od 1)
        value:
          type: array
          items:
            $ref: "#/components/schemas/ValueItem"
          description: >-
            Lista wartości pozycji (0..*); każdy element ValueItem niesie opcjonalny type
            oraz dokładnie jeden wariant: quantity, money, string, integer, boolean,
            codeableConcept lub reference.
        status:
          $ref: "#/components/schemas/CodeableConcept"
        attachment:
          type: array
          items:
            $ref: "#/components/schemas/Attachment"
    FormulaComponent:
      title: FormulaComponent
      description: FormulaComponent — składnik formuły (amortyzacji)
      version: 1.1.0
      type: object
      properties:
        id:
          type: string
        meta:
          $ref: "#/components/schemas/Meta"
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        type:
          $ref: "#/components/schemas/CodeableConcept"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        attribute:
          type: array
          items:
            $ref: "#/components/schemas/Attribute"
        partOf:
          $ref: "#/components/schemas/Reference"
          description: Składnik nadrzędny w hierarchii formuły
        level:
          type: integer
          minimum: 0
          description: Poziom zagłębienia w strukturze
        isLast:
          type: boolean
          description: Czy ostatni w gałęzi
        startingYear:
          type: integer
          minimum: 1900
          maximum: 9999
          description: Rok początkowy obowiązywania
        endingYear:
          type: integer
          minimum: 1900
          maximum: 9999
          description: Rok końcowy obowiązywania
    Group:
      title: Group
      description: Group — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        id:
          type: string
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        name:
          type: string
        type:
          $ref: "#/components/schemas/CodeableConcept"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        member:
          type: array
          items:
            type: object
            properties:
              entity:
                $ref: "#/components/schemas/Reference"
              period:
                type: object
                properties:
                  start:
                    type: string
                    format: date
                  end:
                    type: string
                    format: date
        partOf:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
    Identifier:
      title: Identifier
      description: Identifier — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        type:
          $ref: "#/components/schemas/CodeableConcept"
        system:
          type: string
        value:
          type: string
    Invoice:
      title: Invoice
      description: Faktura (model kanoniczny); rozszerza DomainResource. Pozycje w JSON w tablicy lines.
      version: 1.1.0
      type: object
      properties:
        id:
          type: string
        meta:
          $ref: "#/components/schemas/Meta"
        owner:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
          description: "Identyfikatory owner (pole JSON: owner)."
        comment:
          type: string
        category:
          type: array
          items:
            $ref: "#/components/schemas/CodeableConcept"
        contained:
          type: array
          items:
            type: object
          description: "Zasoby zagnieżdżone (pole JSON: contained)."
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
          description: Identyfikatory faktury (numer, numer KSeF, itp.)
        type:
          $ref: "#/components/schemas/CodeableConcept"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        attribute:
          type: array
          items:
            $ref: "#/components/schemas/Attribute"
          description: Atrybuty DomainResource (np. uzupełnienia profilu)
        issueDate:
          type: string
          format: date
          description: Data wystawienia
        saleDate:
          type: string
          format: date
          description: Data sprzedaży
        dueDate:
          type: string
          format: date
          description: Termin płatności
        seller:
          $ref: "#/components/schemas/Reference"
        buyer:
          $ref: "#/components/schemas/Reference"
        payer:
          $ref: "#/components/schemas/Reference"
        totalNet:
          $ref: "#/components/schemas/Money"
        totalVat:
          $ref: "#/components/schemas/Money"
        totalExcise:
          $ref: "#/components/schemas/Money"
          description: Suma akcyzy dokumentu
        totalGross:
          $ref: "#/components/schemas/Money"
        currency:
          type: string
          description: Kod waluty ISO 4217
        paymentMethod:
          $ref: "#/components/schemas/CodeableConcept"
        paymentAccount:
          $ref: "#/components/schemas/Reference"
        splitPayment:
          type: boolean
          description: Mechanizm podzielonej płatności (MPP)
        lines:
          type: array
          items:
            $ref: "#/components/schemas/InvoicePosition"
          description: Wiersze faktury (InvoicePosition)
        taxLine:
          type: array
          items:
            title: InvoiceTaxLine
            description: >
              Podsumowanie wartości faktury dla jednej stawki VAT.
              Typ wartości osadzany jako Invoice.taxLine[]; nie jest samodzielnym zasobem.
              Wymagane przez art. 106e ust. 1 pkt 8–10 ustawy o VAT.
            type: object
            properties:
              vatRate:
                $ref: "#/components/schemas/CodeableConcept"
                description: >
                  Stawka VAT (system: vat-rate).
                  Kody liczbowe: 23, 8, 5, 0. Kody specjalne: ZW (zwolniony), NP (nie podlega).
              netAmount:
                $ref: "#/components/schemas/Money"
                description: Wartość netto dla stawki VAT w cenach zakupu.
              vatAmount:
                $ref: "#/components/schemas/Money"
                description: Kwota VAT dla stawki w cenach zakupu.
              grossAmount:
                $ref: "#/components/schemas/Money"
                description: Wartość brutto dla stawki. Powinna być równa netAmount + vatAmount.
            required:
              - vatRate
              - netAmount
              - vatAmount
              - grossAmount
          description: Podsumowanie wartości faktury w rozbiciu na stawki VAT. Suma netAmount powinna być równa totalNet, suma vatAmount — totalVat, suma grossAmount — totalGross.
        attachment:
          type: array
          items:
            $ref: "#/components/schemas/Attachment"
          description: Załączniki
        relatedDocument:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
          description: Powiązane dokumenty
        ksefAcquisitionDate:
          type: string
          format: date-time
          description: Data otrzymania w KSeF
    InvoicePosition:
      title: InvoicePosition
      description: Wiersz faktury (Invoice.lines).
      version: 1.1.0
      type: object
      properties:
        positionNo:
          type: integer
          minimum: 1
          description: Numer wiersza
        description:
          type: string
          description: Opis towaru/usługi
        quantity:
          $ref: "#/components/schemas/Quantity"
          description: Ilość i jednostka miary
        unitPriceNet:
          $ref: "#/components/schemas/Money"
          description: Cena jednostkowa netto
        netAmount:
          $ref: "#/components/schemas/Money"
          description: Wartość netto pozycji
        vatRate:
          $ref: "#/components/schemas/CodeableConcept"
          description: Stawka VAT (system vat-rate)
        vatAmount:
          $ref: "#/components/schemas/Money"
          description: Kwota VAT pozycji
        exciseAmount:
          $ref: "#/components/schemas/Money"
          description: Kwota akcyzy pozycji
        exciseType:
          $ref: "#/components/schemas/CodeableConcept"
          description: Rodzaj / kategoria akcyzy
        productReference:
          $ref: "#/components/schemas/Reference"
          description: Referencja do ProductDefinition lub Product
        discount:
          $ref: "#/components/schemas/Money"
          description: Rabat (kwota)
        discountCodeableConcept:
          $ref: "#/components/schemas/CodeableConcept"
          description: Rabat (kodowanie)
        costLink:
          type: array
          items:
            title: InvoiceCostLink
            description: >
              Powiązanie kosztowe między pozycją faktury a dokumentem przyjęcia magazynowego (PZ) dla danego magazynu.
              Typ wartości osadzany jako InvoicePosition.costLink[]; nie jest samodzielnym zasobem.
            type: object
            properties:
              sourceDocument:
                $ref: "#/components/schemas/Reference"
                description: >
                  Referencja do dokumentu PZ (InventoryDocument).
                  reference = identyfikator PZ, display = nazwa definicji dokumentu.
              location:
                $ref: "#/components/schemas/Reference"
                description: Referencja do Location lub Party (np. magazyn lub podmiot prowadzący magazyn), na którym zaewidencjonowano przyjęcie.
              costAmount:
                $ref: "#/components/schemas/Money"
                description: Suma wartości pozycji PZ powiązanych z pozycją faktury.
              comment:
                type: string
                description: Uwagi z nagłówka dokumentu PZ.
              category:
                $ref: "#/components/schemas/CodeableConcept"
                description: Rodzaj kosztu; aktualnie zawsze null — zarezerwowane dla przyszłych wersji.
              relatedDocument:
                type: array
                items:
                  $ref: "#/components/schemas/Reference"
                description: Powiązane dokumenty (umowa, zamówienie); aktualnie zawsze null — zarezerwowane.
            required:
              - sourceDocument
              - location
              - costAmount
          description: Powiązania kosztowe pozycji faktury z dokumentami PZ; jeden element na każde powiązanie pozycja–PZ–magazyn.
    JournalEntry:
      title: JournalEntry
      description: Zaksiegowany dekret utworzony na podstawie PostingInstruction. Rozszerza DomainResource.
      version: 1.0.0
      allOf:
        - $ref: "#/components/schemas/DomainResource"
        - type: object
          required:
            - postingInstruction
            - accountingDate
          properties:
            identifier:
              type: array
              items:
                $ref: "#/components/schemas/Identifier"
              description: Identyfikatory biznesowe i techniczne dekretu.
            postingInstruction:
              $ref: "#/components/schemas/Reference"
              description: Referencja do PostingInstruction, z ktorej utworzono dekret.
            accountingDate:
              oneOf:
                - type: string
                  format: date
                - type: string
                  format: date-time
              description: Data księgowania.
            description:
              type: string
              description: Opis nagłówka dekretu.
            position:
              type: array
              items:
                $ref: "#/components/schemas/JournalEntryPosition"
              description: Pozycje dekretu.
    JournalEntryPosition:
      title: JournalEntryPosition
      description: Pozycja dekretu w JournalEntry.
      version: 1.0.0
      type: object
      required:
        - positionNo
        - entrySide
        - amount
        - decreePosition
      properties:
        positionNo:
          type: integer
          minimum: 1
          description: Numer pozycji dekretu w ramach JournalEntry.
        entrySide:
          $ref: "#/components/schemas/CodeableConcept"
          description: Strona zapisu: Wn / Ma.
        description:
          type: string
          description: Opis pozycji dekretu.
        symbol:
          $ref: "#/components/schemas/CodeableConcept"
          description: Symbol pozycji dekretu.
        debitAccount:
          $ref: "#/components/schemas/Reference"
          description: Konto księgowe strony Wn (LedgerAccount).
        creditAccount:
          $ref: "#/components/schemas/Reference"
          description: Konto księgowe strony Ma (LedgerAccount).
        amount:
          $ref: "#/components/schemas/Money"
          description: Kwota pozycji dekretu.
        foreignAmount:
          $ref: "#/components/schemas/Money"
          description: Kwota w walucie obcej, jeśli zapis źródłowo dotyczy innej waluty.
        exchangeRate:
          type: number
          description: Kurs użyty do przeliczenia waluty obcej na PLN.
        decreePosition:
          type: integer
          minimum: 1
          description: Pozycja dekretu w obrębie dokumentu.
    Ledger:
      title: Ledger
      description: Ledger — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        id:
          type: string
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        name:
          type: string
        currency:
          $ref: "#/components/schemas/CodeableConcept"
        chartOfAccounts:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
        status:
          $ref: "#/components/schemas/CodeableConcept"
    LedgerAccount:
      title: LedgerAccount
      description: LedgerAccount — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        id:
          type: string
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        name:
          type: string
        type:
          $ref: "#/components/schemas/CodeableConcept"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        currency:
          $ref: "#/components/schemas/CodeableConcept"
        partOf:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
    LedgerEntry:
      title: LedgerEntry
      description: LedgerEntry – pojedynczy zapis księgowy (linia w ogólnika). Rozszerza DomainResource.
      version: 1.0.0
      type: object
      properties:
        id:
          type: string
        meta:
          $ref: "#/components/schemas/Meta"
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        ledger:
          $ref: "#/components/schemas/Reference"
        account:
          $ref: "#/components/schemas/Reference"
        postingDate:
          type: string
          format: date
          description: Data zaksięgowania
        documentDate:
          type: string
          format: date
          description: Data dokumentu źródłowego
        documentNumber:
          type: string
          description: Numer dokumentu źródłowego
        description:
          type: string
          description: Opis zapisu
        debitAmount:
          $ref: "#/components/schemas/Money"
        creditAmount:
          $ref: "#/components/schemas/Money"
        currency:
          $ref: "#/components/schemas/CodeableConcept"
        journal:
          $ref: "#/components/schemas/CodeableConcept"
        relatedDocument:
          $ref: "#/components/schemas/Reference"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        reversingEntry:
          $ref: "#/components/schemas/Reference"
        attachment:
          type: array
          items:
            $ref: "#/components/schemas/Attachment"
        extension:
          type: array
          items:
            type: object
          description: Rozszerzenia (DomainResource pattern)
    Meta:
      title: Meta
      description: Meta — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        lastModified:
          type: string
          format: date-time
    Money:
      title: Money
      description: Money — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        value:
          type: number
        currency:
          type: string
    Party:
      title: Party
      description: Party — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        id:
          type: string
        meta:
          $ref: "#/components/schemas/Meta"
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        name:
          $ref: "#/components/schemas/CodeableConcept"
        type:
          $ref: "#/components/schemas/CodeableConcept"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        address:
          type: array
          items:
            $ref: "#/components/schemas/Address"
        contactPoint:
          type: array
          items:
            $ref: "#/components/schemas/ContactPoint"
    PostingInstruction:
      title: PostingInstruction
      description: >
        Kanoniczny bufor dokumentu do procedowania w FK (dekretacja,
        ewidencja VAT, JPK). Jeden zasob dla wielu typow dokumentow,
        roznicowany przez pole type i profile walidacji.
      version: 2.0.0-draft
      type: object
      required:
        - issueDate
        - symbol
      properties:
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
          description: Identyfikatory biznesowe i techniczne dokumentu z systemu zewnetrznego.
        participant:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
          description: Uczestnicy dokumentu jako referencje do PartyRole.
        attachment:
          type: array
          items:
            $ref: "#/components/schemas/Attachment"
          description: Zalaczniki powiazane z dokumentem.
        issueDate:
          type: string
          format: date
          description: Data wystawienia.
        realizationDate:
          type: string
          format: date
          description: Data otrzymania / realizacji.
        symbol:
          $ref: "#/components/schemas/CodeableConcept"
          description: Symbol typu dokumentu w systemie zewnetrznym (dawne symbolType).
        paymentMethod:
          $ref: "#/components/schemas/CodeableConcept"
        accountingVariant:
          $ref: "#/components/schemas/Reference"
        grossAmount:
          $ref: "#/components/schemas/Money"
        netAmount:
          $ref: "#/components/schemas/Money"
        vatAmount:
          $ref: "#/components/schemas/Money"
        register:
          $ref: "#/components/schemas/Reference"
        saleDate:
          type: string
          format: date-time
          description: Data sprzedazy (dopuszczalne date/date-time).
        dueDate:
          type: string
          format: date-time
          description: Termin platnosci (dopuszczalne date/date-time).
        accountingDate:
          type: string
          format: date-time
          description: Data ksiegowania (dopuszczalne date/date-time).
        paymentAccount:
          $ref: "#/components/schemas/Reference"
        position:
          type: array
          items:
            $ref: "#/components/schemas/PostingInstructionLine"
          description: Pozycje instrukcji (accounting-item, vat-summary).
    PostingInstructionLine:
      title: PostingInstructionLine
      description: >
        Pozycja instrukcji ksiegowania zgodna semantycznie z DocumentPosition
        (accounting-item, vat-summary).
      version: 2.0.0-draft
      type: object
      properties:
        positionNo:
          type: integer
          minimum: 1
          description: Numer pozycji (od 1).
        code:
          $ref: "#/components/schemas/CodeableConcept"
        value:
          type: array
          items:
            $ref: "#/components/schemas/ValueItem"
          description: >
            Lista warto\u015bci pozycji. Ka\u017cdy element (ValueItem) niesie opcjonalny type
            oraz dok\u0142adnie jeden wariant: quantity, money, string, integer, boolean,
            codeableConcept lub reference.
        allocation:
          $ref: "#/components/schemas/AllocationItem"
          description: Alokacja pozycji.
        purchaseVatDeduction:
          $ref: "#/components/schemas/CodeableConcept"
          description: Tylko vat-summary: typ odliczenia VAT zakupu - §7.3.
        vatRate:
          $ref: "#/components/schemas/CodeableConcept"
          description: Tylko vat-summary: stawka VAT (https://api-erp.kamsoft.pl/ns/vat-rate).
        valueString:
          type: string
          description: Wariant 3 (migracja): kody alokacji lub @symbol nosnika kosztow (opcjonalnie z wagami).
        accountingVariant:
          $ref: "#/components/schemas/Reference"
    ProblemDetails:
      title: ProblemDetails
      description: RFC 7807 Problem Details for HTTP APIs
      version: 1.0.0
      type: object
      properties:
        type:
          type: string
          format: uri
          description: URI reference identifying the problem type
        title:
          type: string
          description: Short, human-readable summary
        status:
          type: integer
          description: HTTP status code
        detail:
          type: string
          description: Human-readable explanation specific to this occurrence
        instance:
          type: string
          format: uri
          description: URI reference identifying the specific occurrence
    PurchaseOrder:
      title: PurchaseOrder
      description: "Zamówienie zakupu — request do dostawcy: strony, pozycje, kwoty, terminy. Źródłem może być PurchaseRequisition (PR)."
      version: 1.0.0
      type: object
      properties:
        id:
          type: string
        meta:
          $ref: "#/components/schemas/Meta"
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
        issueDate:
          type: string
          format: date
        party:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
          description: "Strony (PartyRole): buyer, supplier."
        position:
          type: array
          items:
            $ref: "#/components/schemas/PurchaseOrderPosition"
        amount:
          $ref: "#/components/schemas/Money"
        status:
          $ref: "#/components/schemas/CodeableConcept"
          description: Status workflow zamówienia (ValueSet purchase-order-status).
        realizationStep:
          $ref: "#/components/schemas/CodeableConcept"
          description: Stopień realizacji nagłówka (niezależnie od statusu workflow); ValueSet purchase-order-realization-step.
        expectedDeliveryDate:
          type: string
          format: date
        dueDate:
          type: string
          format: date
        paymentTerms:
          $ref: "#/components/schemas/CodeableConcept"
        sourceDocument:
          $ref: "#/components/schemas/Reference"
          description: Dokument źródłowy — PurchaseRequisition (PR).
        relatedDocument:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
        attribute:
          type: array
          items:
            $ref: "#/components/schemas/Attribute"
        type:
          $ref: "#/components/schemas/CodeableConcept"
        category:
          type: array
          items:
            $ref: "#/components/schemas/CodeableConcept"
    PurchaseOrderPosition:
      title: PurchaseOrderPosition
      description: Pozycja zamówienia zakupu — produkt, ilość, ceny, harmonogram dostaw.
      version: 1.0.0
      type: object
      properties:
        positionNo:
          type: integer
          minimum: 1
        product:
          $ref: "#/components/schemas/Reference"
          description: Referencja do ProductDefinition.
        description:
          type: string
          description: Opis pozycji (jeśli różny od ProductDefinition.name).
        quantity:
          $ref: "#/components/schemas/Quantity"
        unitPrice:
          $ref: "#/components/schemas/Money"
        amount:
          $ref: "#/components/schemas/Money"
        status:
          $ref: "#/components/schemas/CodeableConcept"
          description: Etap realizacji pozycji; ValueSet purchase-order-position-status.
        supplierProductId:
          type: string
        deliverySchedule:
          type: array
          items:
            $ref: "#/components/schemas/DeliveryScheduleLine"
    Quantity:
      title: Quantity
      description: Quantity — wartość numeryczna z jednostką niepieniężną (FHIR‑podobnie); kanoniczny EOD/FK.
      version: 1.0.0
      type: object
      properties:
        value:
          type: number
          description: Wartość mierzalna
        comparator:
          type: string
          description: Opcjonalny komparator (FHIR Quantity.comparator)
        unit:
          type: string
          description: Jednostka tekstowa (np. szt., kg)
        system:
          type: string
          description: URI systemu kodów jednostki (np. UCUM)
        code:
          type: string
          description: Kod jednostki w systemie
    Reference:
      title: Reference
      description: Reference — model API (API ERP Canonical – FK (Finance/Accounting))
      version: 1.0.0
      type: object
      properties:
        reference:
          type: string
        display:
          type: string
    Register:
      title: Register
      description: Register — rejestr księgowy.
      version: 1.1.0
      type: object
      properties:
        id:
          type: string
        meta:
          $ref: "#/components/schemas/Meta"
        identifier:
          type: array
          items:
            $ref: "#/components/schemas/Identifier"
          description: Identyfikatory rejestru
        type:
          $ref: "#/components/schemas/CodeableConcept"
        status:
          $ref: "#/components/schemas/CodeableConcept"
        attribute:
          type: array
          items:
            $ref: "#/components/schemas/Attribute"
        symbol:
          type: string
          minLength: 1
          description: Symbol rejestru (unikalny w obrębie kontekstu)
        documentHeaderAccountingVariant:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
          description: Wariant księgowy — nagłówek dokumentu
        documentItemAccountingVariant:
          type: array
          items:
            $ref: "#/components/schemas/Reference"
          description: Wariant księgowy — pozycja dokumentu
      required:
        - symbol
    ValueItem:
      title: ValueItem
      description: Jedna wartość z typem.
      version: 1.1.0
      type: object
      properties:
        type:
          $ref: "#/components/schemas/CodeableConcept"
        valueQuantity:
          $ref: "#/components/schemas/Quantity"
        valueMoney:
          $ref: "#/components/schemas/Money"
        valueString:
          type: string
        valueInteger:
          type: integer
        valueBoolean:
          type: boolean
        valueCodeableConcept:
          $ref: "#/components/schemas/CodeableConcept"
        valueReference:
          $ref: "#/components/schemas/Reference"
