# BR-KSA-61

Source: https://xmlvalid.com/rules/BR-KSA-61

> Previous invoice hash (KSA-13) must exist in an invoice.

- Level: warning
- Rule sets: ZATCA e-invoicing rules (Saudi Arabia) SDK 3.4.6
- Context: `/ubl:Invoice | /cn:CreditNote`
- Test: `(cac:AdditionalDocumentReference[normalize-space(cbc:ID) = 'PIH'] and exists(cac:AdditionalDocumentReference/cac:Attachment/cbc:EmbeddedDocumentBinaryObject) and (cac:AdditionalDocumentReference/cac:Attachment/cbc:EmbeddedDocumentBinaryObject) != '' and (cac:AdditionalDocumentReference/cac:Attachment/cbc:EmbeddedDocumentBinaryObject[normalize-space(@mimeCode) = 'text/plain']))`

Validate a document against these rules: https://xmlvalid.com/validate
