<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.ftb.ca.gov/efile"
                      xmlns="http://www.ftb.ca.gov/efile"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:irs="http://www.irs.gov/efile"
         elementFormDefault="qualified"
       attributeFormDefault="unqualified"
                    version="2018v4.1">

	<xsd:import namespace="http://www.irs.gov/efile"
	       schemaLocation="../../../IRS/2018v5.3_1120x+4.1_1065x/Common/efileTypes.xsd"/>

	<xsd:annotation>
		<xsd:documentation>
			<Description>CA FTB e-file Schema - Content models for e-file response file definitions</Description>
			<TaxYear>2018</TaxYear>
			<MaturityLevel>Production Release</MaturityLevel>
			<ReleaseDate>January 23, 2020</ReleaseDate>
		</xsd:documentation>
	</xsd:annotation>

	<xsd:include schemaLocation="CA-InterfaceTypes.xsd"/>

<!-- ===================================  RESPONSES  =================================== -->

	<!-- Transmission Receipt -->
	<xsd:element name="CA-TransmissionReceipt" type="CA-TransmissionReceiptType">
		<xsd:annotation>
			<xsd:documentation>an instance of a transmission receipt</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:complexType name="CA-TransmissionReceiptType">
		<xsd:annotation>
			<xsd:documentation>record of receiving transmission</xsd:documentation>
		</xsd:annotation>

		<xsd:sequence>
			<!-- Transmission ID -->
			<xsd:element name="TransmissionId" type="CA-TransmissionIdType">
				<xsd:annotation>
					<xsd:documentation>A globally unique ID provided by the transmitter that must be unique for the transmitter for the tax year.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Receipt Timestamp -->
			<xsd:element name="ReceiptTimestamp" type="irs:TimestampType">
				<xsd:annotation>
					<xsd:documentation>The date and time the transmission was received by the CA FTB.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Transmission Serial Number -->
			<xsd:element name="TransmissionSerialNumber" type="CA-TransmissionSerialNumberType">
				<xsd:annotation>
					<xsd:documentation>A unique FTB-generated ID sent to the transmitter as a receipt.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>
		</xsd:sequence>

		<!-- Transmission Receipt Version -->
		<xsd:attribute name="transmissionReceiptVersion" type="xsd:string" use="optional"/>

		<!-- Imported IRS Schema Version -->
		<xsd:attribute name="importedIrsSchemaVersion" type="xsd:string" use="optional"/>
	</xsd:complexType>

	<!-- Transmission Acknowledgement -->
	<xsd:element name="CA-TransmissionAcknowledgement" type="CA-TransmissionAcknowledgementType">
		<xsd:annotation>
			<xsd:documentation>an instance of a transmission acknowledgement</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:complexType name="CA-TransmissionAcknowledgementType">
		<xsd:annotation>
			<xsd:documentation>results of transmission validation</xsd:documentation>
		</xsd:annotation>

		<xsd:sequence>
			<!-- Common Transmission Elements -->
			<xsd:group ref="CA-CommonTransmissionElements"/>

			<!-- Receipt Timestamp -->
			<xsd:element name="ReceiptTimestamp" type="irs:TimestampType">
				<xsd:annotation>
					<xsd:documentation>The date and time the transmission was received by the CA FTB.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Status Timestamp -->
			<xsd:element name="StatusTimestamp" type="irs:TimestampType">
				<xsd:annotation>
					<xsd:documentation>The date and time this acknowledgement was created.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Transmission Serial Number -->
			<xsd:element name="TransmissionSerialNumber" type="CA-TransmissionSerialNumberType">
				<xsd:annotation>
					<xsd:documentation>A unique FTB-generated ID sent to the transmitter as a receipt.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Transmission Status -->
			<xsd:element name="TransmissionStatus" type="CA-StatusType">
				<xsd:annotation>
					<xsd:documentation>Indicator whether the transmission is [A]ccepted or [R]ejected.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Error List -->
			<xsd:element name="ErrorList" type="CA-ValidationErrorListType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) List of errors for a rejected transmission.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>
		</xsd:sequence>

		<!-- Transmission Acknowledgement Version -->
		<xsd:attribute name="transmissionAcknowledgementVersion" type="xsd:string" use="optional"/>

		<!-- Imported IRS Schema Version -->
		<xsd:attribute name="importedIrsSchemaVersion" type="xsd:string" use="optional"/>
	</xsd:complexType>

	<!-- Submission Acknowledgement -->
	<xsd:element name="CA-SubmissionAcknowledgement" type="CA-SubmissionAcknowledgementType">
		<xsd:annotation>
			<xsd:documentation>an instance of a submission acknowledgement</xsd:documentation>
		</xsd:annotation>
	</xsd:element>
	<xsd:complexType name="CA-SubmissionAcknowledgementType">
		<xsd:annotation>
			<xsd:documentation>results of submission validation</xsd:documentation>
		</xsd:annotation>

		<xsd:sequence>
			<!-- Common Submission/Acknowledgement Elements -->
			<xsd:group ref="CA-CommonSubmissionAndAcknowledgementElements"/>

			<!-- Timestamp -->
			<xsd:element name="Timestamp" type="irs:TimestampType">
				<xsd:annotation>
					<xsd:documentation>The date and time when the return was created (from CA-ReturnHeader).</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Electronic Postmark -->
			<xsd:element name="ElectronicPostmark" type="irs:TimestampType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) The time stamp indicating when the transmitter received the originated return before sending it on to the CA FTB.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Status Timestamp -->
			<xsd:element name="StatusTimestamp" type="irs:TimestampType">
				<xsd:annotation>
					<xsd:documentation>The date and time the submission's filing status was acknowledged.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Submission Category -->
			<xsd:element name="SubmissionCategory" type="CA-SubmissionCategoryType">
				<xsd:annotation>
					<xsd:documentation>Identifies the submission category.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Acceptance Status -->
			<xsd:element name="AcceptanceStatus" type="CA-StatusType">
				<xsd:annotation>
					<xsd:documentation>[A]ccepted or [R]ejected filing status of the submission.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- IRS Submission ID -->
			<xsd:element name="IRSSubmissionId" type="CA-SubmissionIdType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) The submission ID of an IRS submission that the processing of this state submission depends on.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- CA Business Entity ID -->
			<xsd:element name="CA-BusinessEntityId" type="CA-BusinessEntityIdType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) The filers' unique California BE identifier (depending on form-type filed):  Corporation # [7 digits], FEIN (Federal Employment ID #) [9 digits], SOSG (Secretary of State General Partnership #) [12 digits], or TEMP(orary #) [7 digits].</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Tax Period End Date -->
			<xsd:element name="TaxPeriodEndDate" type="irs:DateType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) The tax period end date of the submission.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Completed Validation -->
			<xsd:element name="CompletedValidation" type="xsd:boolean">
				<xsd:annotation>
					<xsd:documentation>Indicates whether the submission went through all possible validation processing ('true') or not ('false').</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Embedded CRC32 Checksum -->
			<xsd:element name="EmbeddedCRC32" type="CA-Crc32ChecksumType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) Embedded ZIP CRC32 checksum ("0x" + 8-digit Hexadecimal value).</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Computed CRC32 Checksum -->
			<xsd:element name="ComputedCRC32" type="CA-Crc32ChecksumType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) CA FTB computed CRC32 checksum ("0x" + 8-digit Hexadecimal value).</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Taxable Income -->
			<xsd:element name="TaxableIncome" type="irs:USAmountType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) Taxable income.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Total Tax -->
			<xsd:element name="TotalTax" type="irs:USAmountNNType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) Total tax.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Error List -->
			<xsd:element name="ErrorList" type="CA-ValidationErrorListType" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) List of errors for a rejected submission.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>
		</xsd:sequence>

		<!-- Submission Acknowledgement Version -->
		<xsd:attribute name="submissionAcknowledgementVersion" type="xsd:string" use="optional"/>

		<!-- Imported IRS Schema Version -->
		<xsd:attribute name="importedIrsSchemaVersion" type="xsd:string" use="optional"/>
	</xsd:complexType>

<!-- ===================================  COMMON COMPLEX TYPES  =================================== -->

	<!-- Type for Validation Error List -->
	<xsd:complexType name="CA-ValidationErrorListType">
		<xsd:annotation>
			<xsd:documentation>list of validation errors' information</xsd:documentation>
		</xsd:annotation>

		<xsd:sequence>
			<!-- Error -->
			<xsd:element name="Error" type="CA-ValidationErrorType" minOccurs="1" maxOccurs="unbounded">
				<xsd:annotation>
					<xsd:documentation>Validation Error</xsd:documentation>
				</xsd:annotation>
			</xsd:element>
		</xsd:sequence>

		<!-- Error Count -->
		<xsd:attribute name="errorCount" type="xsd:positiveInteger" use="required"/>
	</xsd:complexType>

	<!-- Type for Validation Error -->
	<xsd:complexType name="CA-ValidationErrorType">
		<xsd:annotation>
			<xsd:documentation>The following elements are optional for all acknowledgements and will be included (as a repeating group) for each error found during the validation of a transmission or submission.</xsd:documentation>
		</xsd:annotation>

		<xsd:sequence>
			<!-- Document ID -->
			<xsd:element name="DocumentID" type="irs:IdType">
				<xsd:annotation>
					<xsd:documentation>The document ID of the form containing the error (Legal Characters: A-Z, a-z, 0-9, colon, period, and hyphen).</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- XPath -->
			<xsd:element name="XPath" type="xsd:string" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) The XPath expression of the location of an error in XML data with its full path from the root to the offending element or attribute.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Error Category -->
			<xsd:element name="ErrorCategory" type="xsd:string">
				<xsd:annotation>
					<xsd:documentation>The FTB-defined category for the reported error.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Error Message -->
			<xsd:element name="ErrorMessage" type="xsd:string">
				<xsd:annotation>
					<xsd:documentation>Text describing the error, usually the rule text.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Rule Number -->
			<xsd:element name="RuleNumber" type="xsd:string">
				<xsd:annotation>
					<xsd:documentation>The FTB-assigned number for the rule creating the error.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Severity -->
			<xsd:element name="Severity" type="CA-SeverityType">
				<xsd:annotation>
					<xsd:documentation>([R]eject/RejectAnd[S]top) "Reject and Stop" errors cause validation of the transmission or submission to stop before any remaining validation rules are executed.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>

			<!-- Data Value -->
			<xsd:element name="DataValue" type="xsd:string" minOccurs="0">
				<xsd:annotation>
					<xsd:documentation>(Optional) The value provided in the transmission or submission data for the element used in the validation rule.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>
		</xsd:sequence>

		<!-- Error ID -->
		<xsd:attribute name="errorId" type="CA-ErrorIdType" use="required"/>
	</xsd:complexType>

<!-- ===================================  COMMON SIMPLE TYPES  =================================== -->

	<!-- Type for CRC32 Checksum -->
	<xsd:simpleType name="CA-Crc32ChecksumType">
		<xsd:annotation>
			<xsd:documentation>10 digits ("0x" + 8-digit Hexadecimal value)</xsd:documentation>
		</xsd:annotation>

		<xsd:restriction base="xsd:string">
			<xsd:maxLength value="10"/>
			<xsd:pattern   value="0x[0-9A-Fa-f]{1,8}"/>
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Type for Error ID -->
	<xsd:simpleType name="CA-ErrorIdType">
		<xsd:annotation>
			<xsd:documentation>6 digits (positive integer)</xsd:documentation>
		</xsd:annotation>

		<xsd:restriction base="xsd:positiveInteger">
			<xsd:totalDigits value="6"/>
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Type for Severity -->
	<xsd:simpleType name="CA-SeverityType">
		<xsd:annotation>
			<xsd:documentation>two-item enumerator: [R]eject or RejectAnd[S]top</xsd:documentation>
		</xsd:annotation>

		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="R">
				<xsd:annotation>
					<xsd:documentation>Reject</xsd:documentation>
				</xsd:annotation>
			</xsd:enumeration>

			<xsd:enumeration value="S">
				<xsd:annotation>
					<xsd:documentation>Reject and Stop</xsd:documentation>
				</xsd:annotation>
			</xsd:enumeration>
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Type for Status -->
	<xsd:simpleType name="CA-StatusType">
		<xsd:annotation>
			<xsd:documentation>two-item enumerator: [A]ccepted or [R]ejected</xsd:documentation>
		</xsd:annotation>

		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="A">
				<xsd:annotation>
					<xsd:documentation>Accepted</xsd:documentation>
				</xsd:annotation>
			</xsd:enumeration>

			<xsd:enumeration value="R">
				<xsd:annotation>
					<xsd:documentation>Rejected</xsd:documentation>
				</xsd:annotation>
			</xsd:enumeration>
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Type for Transmission Serial Number -->
	<xsd:simpleType name="CA-TransmissionSerialNumberType">
		<xsd:annotation>
			<xsd:documentation>8 digits</xsd:documentation>
		</xsd:annotation>

		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[0-9]{8}"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>
