{
  "resourceType": "StructureDefinition",
  "url": "https://api-erp.kamsoft.pl/ns/StructureDefinition/Invoice",
  "name": "Invoice",
  "version": "1.0.0",
  "title": "Faktura (model kanoniczny)",
  "description": "Zasób kanoniczny Invoice — nagłówek i pozycje; IG Invoice-Canonic-Model, zgodność z KSeF jako mapowanie na model.",
  "kind": "resource",
  "abstract": false,
  "type": "Invoice",
  "baseDefinition": "https://api-erp.kamsoft.pl/ns/StructureDefinition/DomainResource",
  "snapshot": {
    "element": [
      {
        "path": "Invoice.identifier",
        "min": 1,
        "max": "*",
        "short": "Identyfikatory faktury",
        "definition": "Numer faktury, KSeF (Identifier.system + value), inne identyfikatory.",
        "type": [
          {
            "code": "Identifier[]"
          }
        ]
      },
      {
        "path": "Invoice.issueDate",
        "min": 1,
        "max": "1",
        "short": "Data wystawienia",
        "definition": "Data wystawienia faktury (obligatoryjna wg art. 106e).",
        "type": [
          {
            "code": "String"
          }
        ]
      },
      {
        "path": "Invoice.saleDate",
        "min": 0,
        "max": "1",
        "short": "Data sprzedaży",
        "definition": "Gdy inna niż data wystawienia.",
        "type": [
          {
            "code": "String"
          }
        ]
      },
      {
        "path": "Invoice.dueDate",
        "min": 0,
        "max": "1",
        "short": "Termin płatności",
        "type": [
          {
            "code": "String"
          }
        ]
      },
      {
        "path": "Invoice.seller",
        "min": 1,
        "max": "1",
        "short": "Wystawca",
        "definition": "Reference do PartyRole (role=seller).",
        "type": [
          {
            "code": "Reference"
          }
        ]
      },
      {
        "path": "Invoice.buyer",
        "min": 1,
        "max": "1",
        "short": "Nabywca",
        "definition": "Reference do PartyRole (role=buyer).",
        "type": [
          {
            "code": "Reference"
          }
        ]
      },
      {
        "path": "Invoice.payer",
        "min": 0,
        "max": "1",
        "short": "Płatnik",
        "definition": "Gdy inny niż nabywca.",
        "type": [
          {
            "code": "Reference"
          }
        ]
      },
      {
        "path": "Invoice.totalNet",
        "min": 0,
        "max": "1",
        "short": "Suma netto dokumentu",
        "type": [
          {
            "code": "Money"
          }
        ]
      },
      {
        "path": "Invoice.totalVat",
        "min": 0,
        "max": "1",
        "short": "Suma VAT dokumentu",
        "type": [
          {
            "code": "Money"
          }
        ]
      },
      {
        "path": "Invoice.totalExcise",
        "min": 0,
        "max": "1",
        "short": "Suma akcyzy dokumentu",
        "type": [
          {
            "code": "Money"
          }
        ]
      },
      {
        "path": "Invoice.totalGross",
        "min": 1,
        "max": "1",
        "short": "Kwota należności ogółem",
        "definition": "Suma brutto / należność ogółem.",
        "type": [
          {
            "code": "Money"
          }
        ]
      },
      {
        "path": "Invoice.currency",
        "min": 1,
        "max": "1",
        "short": "Waluta",
        "definition": "Kod waluty ISO 4217 dla nagłówka i pozycji.",
        "type": [
          {
            "code": "String"
          }
        ]
      },
      {
        "path": "Invoice.paymentMethod",
        "min": 0,
        "max": "1",
        "short": "Sposób zapłaty",
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "binding": {
          "valueSet": "https://api-erp.kamsoft.pl/ns/payment-method"
        }
      },
      {
        "path": "Invoice.paymentAccount",
        "min": 0,
        "max": "1",
        "short": "Rachunek bankowy",
        "definition": "Reference do BankAccount.",
        "type": [
          {
            "code": "Reference"
          }
        ]
      },
      {
        "path": "Invoice.splitPayment",
        "min": 0,
        "max": "1",
        "short": "Split payment (MPP)",
        "type": [
          {
            "code": "Boolean"
          }
        ]
      },
      {
        "path": "Invoice.ksefAcquisitionDate",
        "min": 0,
        "max": "1",
        "short": "Data otrzymania w KSeF",
        "definition": "Data rejestracji / otrzymania w KSeF.",
        "type": [
          {
            "code": "String"
          }
        ]
      },
      {
        "path": "Invoice.lines",
        "min": 1,
        "max": "*",
        "short": "Wiersze faktury",
        "definition": "Pozycje InvoicePosition (nazwa JSON lines zgodnie z kontraktem OpenAPI/JSON Schema w IG).",
        "type": [
          {
            "code": "InvoicePosition[]"
          }
        ]
      },
      {
        "path": "Invoice.relatedDocument",
        "min": 0,
        "max": "*",
        "short": "Powiązane dokumenty",
        "definition": "Korekta, zamówienie, inne Reference.",
        "type": [
          {
            "code": "Reference[]"
          }
        ]
      },
      {
        "path": "Invoice.attachment",
        "min": 0,
        "max": "*",
        "short": "Załączniki",
        "type": [
          {
            "code": "Attachment[]"
          }
        ]
      }
    ]
  }
}