{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:sbv:iso20022:pacs.008.001.09",
  "title": "FIToFICustomerCreditTransfer — pacs.008.001.09 (SBV profile)",
  "description": "ISO 20022 pacs.008.001.09: liên ngân hàng chuyển khoản KH (NAPAS / mBridge)",
  "type": "object",
  "required": ["Document"],
  "properties": {
    "Document": {
      "type": "object",
      "required": ["FIToFICstmrCdtTrf"],
      "properties": {
        "FIToFICstmrCdtTrf": {
          "type": "object",
          "required": ["GrpHdr", "CdtTrfTxInf"],
          "properties": {

            "GrpHdr": {
              "type": "object",
              "required": ["MsgId", "CreDtTm", "NbOfTxs", "SttlmInf", "InstgAgt", "InstdAgt"],
              "properties": {
                "MsgId":   { "type": "string", "maxLength": 35 },
                "CreDtTm": { "type": "string", "format": "date-time" },
                "NbOfTxs": { "type": "string", "pattern": "^[0-9]{1,15}$" },
                "SttlmInf": {
                  "type": "object",
                  "required": ["SttlmMtd"],
                  "properties": {
                    "SttlmMtd": { "type": "string", "enum": ["INDA","INGA","COVE","CLRG"] },
                    "ClrSys":   { "type": "object", "properties": { "Cd": { "type": "string", "enum": ["VNIBPS","MBRIDGE","SWIFT"] } } }
                  }
                },
                "InstgAgt": { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" }, "LEI": { "type": "string" } } } } },
                "InstdAgt": { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" }, "LEI": { "type": "string" } } } } }
              }
            },

            "CdtTrfTxInf": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "object",
                "required": ["PmtId", "IntrBkSttlmAmt", "IntrBkSttlmDt", "Dbtr", "DbtrAcct", "DbtrAgt", "Cdtr", "CdtrAcct", "CdtrAgt"],
                "properties": {
                  "PmtId": {
                    "type": "object",
                    "required": ["EndToEndId", "UETR"],
                    "properties": {
                      "InstrId":    { "type": "string", "maxLength": 35 },
                      "EndToEndId": { "type": "string", "maxLength": 35 },
                      "TxId":       { "type": "string", "maxLength": 35 },
                      "UETR":       { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" }
                    }
                  },
                  "IntrBkSttlmAmt": {
                    "type": "object",
                    "required": ["_", "$"],
                    "properties": {
                      "_": { "type": "string", "pattern": "^[0-9]+(\\.[0-9]{1,2})?$" },
                      "$": { "type": "object", "required": ["Ccy"], "properties": { "Ccy": { "type": "string", "pattern": "^[A-Z]{3}$" } } }
                    }
                  },
                  "IntrBkSttlmDt": { "type": "string", "format": "date" },
                  "Purp":     { "type": "object", "properties": { "Cd": { "type": "string", "maxLength": 4 } } },
                  "RmtInf":   { "type": "object", "properties": { "Ustrd": { "type": "string", "maxLength": 140 } } },
                  "Dbtr":     { "type": "object", "required": ["Nm"], "properties": { "Nm": { "type": "string", "maxLength": 140 } } },
                  "DbtrAcct": { "type": "object", "required": ["Id"], "properties": { "Id": { "type": "object", "properties": { "Othr": { "type": "object", "properties": { "Id": { "type": "string" } } } } } } },
                  "DbtrAgt":  { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } },
                  "Cdtr":     { "type": "object", "required": ["Nm"], "properties": { "Nm": { "type": "string", "maxLength": 140 } } },
                  "CdtrAcct": { "type": "object", "required": ["Id"], "properties": { "Id": { "type": "object", "properties": { "Othr": { "type": "object", "properties": { "Id": { "type": "string" } } } } } } },
                  "CdtrAgt":  { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } }
                }
              }
            }

          }
        }
      }
    }
  }
}
