{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "WiseWage supported B2B invoice request mapped to NRS v1.1",
  "description": "Documents the payload emitted by WiseWage. This is not the complete NRS schema; optional NRS features outside this release are intentionally excluded. Passing this schema does not prove NRS acceptance.",
  "type": "object",
  "properties": {
    "business_id": {
      "type": "string",
      "format": "uuid"
    },
    "irn": {
      "type": "string",
      "pattern": "^[A-Z0-9]+-[A-Z0-9]{8}-[0-9]{8}$",
      "maxLength": 80
    },
    "issue_date": {
      "type": "string",
      "format": "date"
    },
    "due_date": {
      "type": "string",
      "format": "date"
    },
    "invoice_type_code": {
      "enum": [
        "381",
        "380",
        "384"
      ]
    },
    "invoice_kind": {
      "const": "B2B"
    },
    "payment_status": {
      "const": "PENDING"
    },
    "note": {
      "type": "string"
    },
    "tax_point_date": {
      "type": "string",
      "format": "date"
    },
    "document_currency_code": {
      "type": "string",
      "maxLength": 3
    },
    "tax_currency_code": {
      "type": "string",
      "maxLength": 3
    },
    "buyer_reference": {
      "type": "string",
      "maxLength": 225
    },
    "order_reference": {
      "type": "string",
      "maxLength": 255
    },
    "accounting_supplier_party": {
      "type": "object",
      "properties": {
        "party_name": {
          "type": "string",
          "maxLength": 255
        },
        "tin": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "format": "email",
          "maxLength": 100
        },
        "telephone": {
          "type": "string",
          "maxLength": 100
        },
        "business_description": {
          "type": "string",
          "maxLength": 255
        },
        "postal_address": {
          "type": "object",
          "properties": {
            "street_name": {
              "type": "string",
              "maxLength": 255
            },
            "city_name": {
              "type": "string",
              "maxLength": 100
            },
            "postal_zone": {
              "type": "string",
              "maxLength": 20
            },
            "lga": {
              "type": "string",
              "maxLength": 100
            },
            "state": {
              "type": "string",
              "maxLength": 100
            },
            "country": {
              "type": "string",
              "maxLength": 2
            }
          },
          "required": [
            "street_name",
            "city_name",
            "postal_zone",
            "lga",
            "state",
            "country"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "party_name",
        "tin",
        "email",
        "postal_address"
      ],
      "additionalProperties": false
    },
    "accounting_customer_party": {
      "type": "object",
      "properties": {
        "party_name": {
          "type": "string",
          "maxLength": 255
        },
        "tin": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "format": "email",
          "maxLength": 100
        },
        "telephone": {
          "type": "string",
          "maxLength": 100
        },
        "business_description": {
          "type": "string",
          "maxLength": 255
        },
        "postal_address": {
          "type": "object",
          "properties": {
            "street_name": {
              "type": "string",
              "maxLength": 255
            },
            "city_name": {
              "type": "string",
              "maxLength": 100
            },
            "postal_zone": {
              "type": "string",
              "maxLength": 20
            },
            "lga": {
              "type": "string",
              "maxLength": 100
            },
            "state": {
              "type": "string",
              "maxLength": 100
            },
            "country": {
              "type": "string",
              "maxLength": 2
            }
          },
          "required": [
            "street_name",
            "city_name",
            "postal_zone",
            "lga",
            "state",
            "country"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "party_name",
        "tin",
        "email",
        "postal_address"
      ],
      "additionalProperties": false
    },
    "payment_means": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "payment_means_code": {
            "type": "string",
            "maxLength": 3
          },
          "payment_due_date": {
            "type": "string",
            "format": "date"
          }
        },
        "required": [
          "payment_means_code"
        ],
        "additionalProperties": false
      }
    },
    "tax_total": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "tax_amount": {
            "type": "number",
            "minimum": 0
          },
          "tax_subtotal": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "properties": {
                "taxable_amount": {
                  "type": "number",
                  "minimum": 0
                },
                "tax_amount": {
                  "type": "number",
                  "minimum": 0
                },
                "tax_category": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "enum": [
                        "STANDARD_VAT",
                        "ZERO_VAT",
                        "EXEMPTED"
                      ]
                    },
                    "percent": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "id",
                    "percent"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "taxable_amount",
                "tax_amount",
                "tax_category"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "tax_amount",
          "tax_subtotal"
        ],
        "additionalProperties": false
      }
    },
    "legal_monetary_total": {
      "type": "object",
      "properties": {
        "line_extension_amount": {
          "type": "number",
          "minimum": 0
        },
        "tax_exclusive_amount": {
          "type": "number",
          "minimum": 0
        },
        "tax_inclusive_amount": {
          "type": "number",
          "minimum": 0
        },
        "payable_amount": {
          "type": "number",
          "minimum": 0
        }
      },
      "required": [
        "line_extension_amount",
        "tax_exclusive_amount",
        "tax_inclusive_amount",
        "payable_amount"
      ],
      "additionalProperties": false
    },
    "invoice_line": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "hsn_code": {
            "type": "string",
            "maxLength": 7
          },
          "product_category": {
            "type": "string",
            "maxLength": 255
          },
          "isic_code": {
            "type": "string",
            "maxLength": 4
          },
          "service_category": {
            "type": "string",
            "maxLength": 255
          },
          "invoiced_quantity": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "line_extension_amount": {
            "type": "number",
            "minimum": 0
          },
          "item": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "sellers_item_identification": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "description"
            ],
            "additionalProperties": false
          },
          "price": {
            "type": "object",
            "properties": {
              "price_amount": {
                "type": "number",
                "minimum": 0
              },
              "base_quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "price_unit": {
                "type": "string",
                "maxLength": 3
              }
            },
            "required": [
              "price_amount",
              "base_quantity",
              "price_unit"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "invoiced_quantity",
          "line_extension_amount",
          "item",
          "price"
        ],
        "additionalProperties": false,
        "oneOf": [
          {
            "required": [
              "hsn_code",
              "product_category"
            ],
            "not": {
              "required": [
                "isic_code"
              ]
            }
          },
          {
            "required": [
              "isic_code",
              "service_category"
            ],
            "not": {
              "required": [
                "hsn_code"
              ]
            }
          }
        ]
      }
    },
    "billing_reference": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "irn": {
            "type": "string"
          },
          "issue_date": {
            "type": "string",
            "format": "date"
          }
        },
        "required": [
          "irn",
          "issue_date"
        ]
      }
    }
  },
  "required": [
    "business_id",
    "irn",
    "issue_date",
    "invoice_type_code",
    "invoice_kind",
    "document_currency_code",
    "tax_currency_code",
    "accounting_supplier_party",
    "accounting_customer_party",
    "tax_total",
    "legal_monetary_total",
    "invoice_line"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "invoice_type_code": {
            "enum": [
              "380",
              "384"
            ]
          }
        }
      },
      "then": {
        "required": [
          "billing_reference"
        ]
      }
    }
  ]
}
