Search Posts

Views: 69

Nobuyuki SAMBUICHI

ISO/TC295 Audit data services/SG1 Semantic model Convener

ChatGPTは日本語が母国語でないので、要求事項を正しく理解せずに自己解釈して回答してくるので、再々質問まで行わないと正しい回答をしてくれませんでした。ChatGPTは物知りですが、その回答を鵜呑みにせず、検証しながら問いただすことで正しい解答が得られます。

問題個所は、

<rule context="cac:TaxTotal">
    <assert id="aligned-ibr-jp-07-ntr" flag="fatal" test="//cbc:TaxAmount = 0">
    [aligned-ibr-jp-07-ntr]-Invoice total TAX amount in tax accounting currency (ibt-111), TAX category tax amount (ibt-117) and TAX category tax amount in accounting currency (ibt-190) MUST be 0 (zero).</assert>
</rule>

このルールでは、税額ゼロの要素が一つでもあると他に税額ゼロ以外の要素があってもエラーが報告されません。

ChatGPTの提案は、

<rule context="//cbc:TaxAmount">
  <assert id="aligned-ibr-jp-07-ntr" flag="fatal" test=". = 0">
    [aligned-ibr-jp-07-ntr]-Invoice total TAX amount in tax accounting currency (ibt-111), TAX category tax amount (ibt-117) and TAX category tax amount in accounting currency (ibt-190) MUST be 0 (zero).
  </assert>
</rule>

cbc:TaxAmount要素が現れるすべての箇所でその値が 0 がチェックしています。

エラーメッセージも次の内容が妥当だと思います。

[aligned-ibr-jp-07-ntr]-**Invoice total TAX amount (ibt-110)**, Invoice total TAX amount in tax accounting currency (ibt-111), TAX category tax amount (ibt-117) and TAX category tax amount in accounting currency (ibt-190) MUST be 0 (zero)

OpenPeppolにもChatGPT程度のXML, XPath, Schematronの知識のあるエンジニアはおられるのですが、日本対応の作業についての確認が十分とはいえないようです。日本での公開前にしっかり検証して頂きたいなと思います。

ChatGPTにチェック方法を質問

User

次のXML文書について
XPathで cbc;TaxAmountの値がすべての箇所で 0 であることを確認するスキーマトロンのスクリプト<rule>と<assertion>を作成してください。
<assertion>エラーメッセージは次で fatalです。
[aligned-ibr-jp-07-ntr]-Invoice total TAX amount in tax accounting currency (ibt-111),
TAX category tax amount (ibt-117) and TAX category tax amount in accounting currency (ibt-190)
MUST be 0 (zero).

ChatGPTに示した[検証用デジタルインボイス]は、本ページの最下部に掲載しています。

ChatGPT

次のスキーマトロンのスクリプトは、与えられたXML文書内のcbc:TaxAmount要素の値がすべて0であることを確認するためのものです。

<rule context="cac:TaxTotal">
    <assert id="aligned-ibr-jp-07-ntr" flag="fatal" test="//cbc:TaxAmount != 0">
    [aligned-ibr-jp-07-ntr]-Invoice total TAX amount in tax accounting currency (ibt-111),
    TAX category tax amount (ibt-117) and TAX category tax amount in accounting currency (ibt-190)
    MUST be 0 (zero).</assert>
</rule>

このスキーマトロンのスクリプトは、cac:TaxTotal要素を対象としています。そして、cbc:TaxAmount要素の値が0でない(0ではない値を持つ)場合にエラーとなります。テストが失敗すると、指定されたエラーメッセージが表示されます。

スキーマトロンのスクリプトはXML文書のバリデーションに使用されます。XML文書をスキーマトロンに適用することで、指定された条件に適合しない箇所がある場合にエラーとなります。

ただし、与えられたXML文書ではcbc:TaxAmount要素の値が0である箇所が存在しており、スキーマトロンのテストは合格となります。もしエラーとなるべきである場合は、スキーマトロンのスクリプトを確認し、条件式が正しく指定されているか、XML文書とのマッピングが正確であるかなどを再確認してください。

再質問

User

全てのcbc:TaxAmount要素の値が0であることが要請されています。0でないものがあるときにエラーとしてください。

ChatGPT

申し訳ありません、先の回答で誤ってスキーマトロンのスクリプトを説明しました。正しいスクリプトを以下に示します。

<rule context="//cbc:TaxAmount">
  <assert id="aligned-ibr-jp-07-ntr" flag="fatal" test=". != 0">
    [aligned-ibr-jp-07-ntr]-Invoice total TAX amount in tax accounting currency (ibt-111),
    TAX category tax amount (ibt-117) and TAX category tax amount in accounting currency (ibt-190)
    MUST be 0 (zero).
  </assert>
</rule>

このスクリプトでは、cbc:TaxAmount要素の値が0でない場合にエラーが発生します。context属性にはXPath式 //cbc:TaxAmount を使用して、XML内のすべての cbc:TaxAmount 要素を選択しています。そして、test属性の値 . != 0 によって、要素の値が0でないかどうかをテストしています。

もし与えられたXML文書内で、cbc:TaxAmount要素のいずれかの値が0でない場合、スキーマトロンのテストは失敗し、指定されたエラーメッセージが表示されます。

再度、正しいスクリプトを提供できることをお詫び申し上げます。お手数をおかけしました。

再々質問

User

これでは、0でないものがあってもエラーにならないのでは?

ChatGPT

申し訳ありません、再度誤った情報を提供してしまいました。正しいスキーマトロンのスクリプトを以下に示します。

<rule context="//cbc:TaxAmount">
  <assert id="aligned-ibr-jp-07-ntr" flag="fatal" test=". = 0">
    [aligned-ibr-jp-07-ntr]-Invoice total TAX amount in tax accounting currency (ibt-111),
    TAX category tax amount (ibt-117) and TAX category tax amount in accounting currency (ibt-190)
    MUST be 0 (zero).
  </assert>
</rule>

このスクリプトでは、cbc:TaxAmount要素の値が0でない場合にエラーが発生します。test属性の値 . = 0 によって、要素の値が0であるかどうかをテストしています。

もし与えられたXML文書内で、cbc:TaxAmount要素のいずれかの値が0でない場合、スキーマトロンのテストは失敗し、指定されたエラーメッセージが表示されます。

再度、正しいスクリプトを提供できることをお詫び申し上げます。お手数をおかけしました。

ChatGPT may produce inaccurate information about people, places, or facts. ChatGPT May 12 Version

検証用デジタルインボイス

<?xml version="1.0" encoding="UTF-8"?>
<Invoice
	xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
	xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
	xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
	xmlns:ccts="urn:un:unece:uncefact:documentation:2"
	xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
	xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"
	xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 https://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd">

	<!--<cbc:UBLVersionID>2.1</cbc:UBLVersionID>-->
	<cbc:CustomizationID>urn:peppol:pint:nontaxinvoice-1@jp-1</cbc:CustomizationID> 	<!-- IBT-024 - Specification identifier -->
	<cbc:ProfileID>urn:peppol:bis:billing</cbc:ProfileID> <!-- IBT-023 - Business process type -->
	<cbc:ID>156</cbc:ID> <!-- IBT-001 - Invoice number -->
	<cbc:IssueDate>2023-10-24</cbc:IssueDate> <!-- IBT-002 - Invoice issue date -->
	<!-- cbc:IssueTime, IBT-168 - Invoice issue time -->
	<cbc:DueDate>2023-11-20</cbc:DueDate> <!-- IBT-009 - Payment due date -->
	<cbc:InvoiceTypeCode>480</cbc:InvoiceTypeCode> <!-- IBT-003 - Invoice type code -->
	<cbc:Note>Ordered at trade show</cbc:Note> <!-- IBT-022 - Invoice note -->
	<cbc:DocumentCurrencyCode>JPY</cbc:DocumentCurrencyCode> <!-- IBT-005 - Invoice currency code -->
	<cac:InvoicePeriod> <!-- IBG-14 - INVOICING PERIOD -->
		<cbc:StartDate>2023-10-18</cbc:StartDate> <!-- IBT-073 - Invoicing period start date -->
		<cbc:EndDate>2023-10-18</cbc:EndDate> <!-- IBT-074 - Invoicing period end date -->
		<!-- cbc:DescriptionCode, IBT-008 - TAX point date code -->
	</cac:InvoicePeriod>
	<cac:AccountingSupplierParty> <!-- IBG-04 - SELLER -->
		<cac:Party>
			<cbc:EndpointID schemeID="0188">1234567890123</cbc:EndpointID> <!-- IBT-034 - Seller electronic address, IBT-034-1 - Scheme identifier -->
			<cac:PartyIdentification>
				<cbc:ID schemeID="0147">123456:000123:0147:1</cbc:ID> <!-- IBT-029 Seller identifier, IBT-029-1 Scheme identifier -->
			</cac:PartyIdentification>
			<cac:PartyName>
				<cbc:Name>株式会社 〇〇商事</cbc:Name> <!-- IBT-028 - Seller trading name -->
			</cac:PartyName>
			<cac:PostalAddress> <!-- IBG-05 - SELLER POSTAL ADDRESS -->
				<cbc:StreetName>四谷4-29-X</cbc:StreetName> <!-- IBT-035 - Seller address line 1 -->
				<cbc:AdditionalStreetName>〇〇商事ビル</cbc:AdditionalStreetName> <!-- IBT-036 - Seller address line 2 -->
				<cbc:CityName>新宿区</cbc:CityName> <!-- IBT-037 - Seller city -->
				<cbc:PostalZone>1600044</cbc:PostalZone> <!-- IBT-038 - Seller post code -->
				<cbc:CountrySubentity>東京都</cbc:CountrySubentity> <!-- IBT-039 - Seller country subdivision -->
				<cac:AddressLine>
					<cbc:Line>Third address line</cbc:Line> <!-- IBT-162 - Seller address line 3 -->
				</cac:AddressLine>
				<cac:Country>
					<cbc:IdentificationCode>JP</cbc:IdentificationCode> <!-- IBT-040 - Seller country code -->
				</cac:Country>
			</cac:PostalAddress>
			<cac:PartyLegalEntity>
				<cbc:RegistrationName>株式会社 〇〇商事</cbc:RegistrationName> <!-- IBT-027 - Seller name -->
				<cbc:CompanyID schemeID="0188">1234567890123</cbc:CompanyID> <!-- IBT-030 - Seller legal registration identifier, IBT-030-1 - Scheme identifier -->
				<cbc:CompanyLegalForm>Private Limited Company</cbc:CompanyLegalForm> <!-- IBT-033 - Seller additional legal information -->
			</cac:PartyLegalEntity>
			<cac:Contact> <!-- IBG-06 - SELLER CONTACT -->
				<cbc:Name>青木 志郎</cbc:Name> <!-- IBT-041 - Seller contact point -->
				<cbc:Telephone>03-3xxx-0001</cbc:Telephone> <!-- IBT-042 - Seller contact telephone number -->
				<cbc:ElectronicMail>shirou_aoki@〇〇co.jp</cbc:ElectronicMail> <!-- IBT-043 - Seller contact email address -->
			</cac:Contact>
		</cac:Party>
	</cac:AccountingSupplierParty>
	<cac:AccountingCustomerParty> <!-- IBG-07 - BUYER -->
		<cac:Party>
			<cbc:EndpointID schemeID="0188">3210987654321</cbc:EndpointID> <!-- IBT-049 - Buyer electronic address, IBT-049-1 - Scheme identifier -->
			<cac:PartyIdentification>
				<cbc:ID schemeID="0147">654321:000321:0147:1</cbc:ID> <!-- IBT-046 - Buyer identifier, IBT-046-1 - Scheme identifier -->
			</cac:PartyIdentification>
			<cac:PartyName>
				<cbc:Name>株式会社 〇〇物産</cbc:Name> <!-- IBT-045 - Buyer trading name -->
			</cac:PartyName>
			<cac:PostalAddress> <!-- IBG-08 - BUYER POSTAL ADDRESS -->
				<cbc:StreetName>北区</cbc:StreetName> <!-- IBT-050 - Buyer address line 1 -->
				<cbc:AdditionalStreetName>北十二条西76-X</cbc:AdditionalStreetName> <!-- IBT-051 - Buyer address line 2 -->
				<cbc:CityName>札幌市</cbc:CityName> <!-- IBT-052 - Buyer city	 -->
				<cbc:PostalZone>0010012</cbc:PostalZone> <!-- IBT-053 - Buyer post code -->
				<cbc:CountrySubentity>北海道</cbc:CountrySubentity> <!-- IBT-054 - Buyer country subdivision -->
				<cac:AddressLine>
					<cbc:Line>Third line</cbc:Line> <!-- IBT-163 - Buyer address line 3 -->
				</cac:AddressLine>
				<cac:Country>
					<cbc:IdentificationCode>JP</cbc:IdentificationCode> <!-- IBT-055 - Buyer country code -->
				</cac:Country>
			</cac:PostalAddress>
			<cac:PartyTaxScheme>
            	<cbc:CompanyID>T3210987654321</cbc:CompanyID> <!-- IBT-048 - Buyer TAX identifier -->
            	<cac:TaxScheme>
                	<cbc:ID>VAT</cbc:ID> <!-- IBT-048, qualifier -->
            	</cac:TaxScheme>
        	</cac:PartyTaxScheme>
			<cac:PartyLegalEntity>
				<cbc:RegistrationName>株式会社 〇〇物産</cbc:RegistrationName> <!-- IBT-044 - Buyer name -->
				<cbc:CompanyID schemeID="0147">654321:000321:0147:1</cbc:CompanyID> <!-- IBT-047 - Buyer legal registration identifier, IBT-047-1 - Scheme identifier -->
			</cac:PartyLegalEntity>
			<cac:Contact> <!-- IBG-09 - BUYER CONTACT -->
				<cbc:Name>株式会社 〇〇物産</cbc:Name> <!-- IBT-056 - Buyer contact point -->
				<cbc:Telephone>011-757-1xxx</cbc:Telephone> <!-- IBT-057 - Buyer contact telephone number -->
				<cbc:ElectronicMail>purchaser@oobussan.co.jp</cbc:ElectronicMail> <!-- IBT-058 - Buyer contact email address -->
			</cac:Contact>
		</cac:Party>
	</cac:AccountingCustomerParty>
	<cac:TaxTotal>
		<cbc:TaxAmount currencyID="JPY">26000</cbc:TaxAmount> <!-- IBT-110 - Invoice total TAX amount -->
		<cac:TaxSubtotal> <!-- IBG-23 - TAX BREAKDOWN -->
			<cbc:TaxableAmount currencyID="JPY">260000</cbc:TaxableAmount> <!-- IBT-116 - TAX category taxable amount -->
			<cbc:TaxAmount currencyID="JPY">26000</cbc:TaxAmount> <!-- IBT-117 - TAX category tax amount -->
			<cac:TaxCategory>
				<cbc:ID>S</cbc:ID> <!-- IBT-118 - TAX category code -->
				<cbc:Percent>10</cbc:Percent> <!-- IBT-119 - TAX category rate -->
				<cac:TaxScheme>
					<cbc:ID>VAT</cbc:ID> <!-- IBT-118, qualifier -->
				</cac:TaxScheme>
			</cac:TaxCategory>
		</cac:TaxSubtotal>
		<cac:TaxSubtotal> <!-- IBG-23 - TAX BREAKDOWN -->
			<cbc:TaxableAmount currencyID="JPY">3490</cbc:TaxableAmount> <!-- IBT-116 - TAX category taxable amount -->
			<cbc:TaxAmount currencyID="JPY">0</cbc:TaxAmount> <!-- IBT-117 - TAX category tax amount -->
			<cac:TaxCategory>
				<cbc:ID>E</cbc:ID> <!-- IBT-118 - TAX category code -->
				<cbc:Percent>0</cbc:Percent> <!-- IBT-119 - TAX category rate -->
				<cac:TaxScheme>
					<cbc:ID>VAT</cbc:ID> <!-- IBT-118, qualifier -->
				</cac:TaxScheme>
			</cac:TaxCategory>
		</cac:TaxSubtotal>
	</cac:TaxTotal>
	<cac:LegalMonetaryTotal> <!-- IBG-22 - DOCUMENT TOTALS -->
		<cbc:LineExtensionAmount currencyID="JPY">255990</cbc:LineExtensionAmount> <!-- IBT-106 - Sum of Invoice line net amount -->
		<cbc:TaxExclusiveAmount currencyID="JPY">263490</cbc:TaxExclusiveAmount> <!-- IBT-109 - Invoice total amount without TAX -->
		<cbc:TaxInclusiveAmount currencyID="JPY">289490</cbc:TaxInclusiveAmount> <!-- IBT-112 - Invoice total amount with TAX -->
		<cbc:AllowanceTotalAmount currencyID="JPY">179</cbc:AllowanceTotalAmount> <!-- IBT-107 - Sum of allowances on document level -->
		<cbc:ChargeTotalAmount currencyID="JPY">7679</cbc:ChargeTotalAmount> <!-- IBT-108 - Sum of charges on document level -->
		<cbc:PrepaidAmount currencyID="JPY">0</cbc:PrepaidAmount> <!-- IBT-113 - Paid amount -->
		<cbc:PayableRoundingAmount currencyID="JPY">0</cbc:PayableRoundingAmount> <!-- IBT-114 - Rounding amount -->
		<cbc:PayableAmount currencyID="JPY">289490</cbc:PayableAmount> <!-- IBT-115 - Amount due for payment -->
	</cac:LegalMonetaryTotal>
	<cac:InvoiceLine> <!-- IBG-25 - INVOICE LINE -->
		<cbc:ID>1</cbc:ID> <!-- IBT-126 - Invoice line identifier -->
		<cbc:Note>The equipment has 3 year warranty.</cbc:Note> <!-- IBT-127 - Invoice line note -->
		<cbc:InvoicedQuantity unitCode="H87">5</cbc:InvoicedQuantity> <!-- IBT-129 - Invoiced quantity, IBT-130 - Invoiced quantity unit of measure code -->
		<cac:InvoicePeriod> <!-- IBG-26 - INVOICE LINE PERIOD -->
			<cbc:StartDate>2023-10-18</cbc:StartDate> <!-- IBT-134 - Invoice line period start date -->
			<cbc:EndDate>2023-10-18</cbc:EndDate> <!-- IBT-135 - Invoice line period end date -->
		</cac:InvoicePeriod>
		<cac:Item> <!-- IBG-31 - ITEM INFORMATION -->
			<!-- cbc:Description, IBT-154 - Item description -->
			<cbc:Name>デスクチェア</cbc:Name> <!-- IBT-153 - Item name -->
			<cac:ClassifiedTaxCategory> <!-- IBG-30 - LINE TAX INFORMATION -->
				<cbc:ID>S</cbc:ID> <!-- IBT-151 - Invoiced item TAX category code -->
				<cbc:Percent>10</cbc:Percent> <!-- IBT-152 - Invoiced item TAX rate -->
				<!-- cbc:PerUnitAmount, IBT-166 - Unit TAX -->
				<cac:TaxScheme>
					<cbc:ID>VAT</cbc:ID> <!-- IBT-167 - Tax Scheme -->
				</cac:TaxScheme>
			</cac:ClassifiedTaxCategory>
		</cac:Item>
		<cac:Price> <!-- IBG-29 - PRICE DETAILS -->
			<cbc:PriceAmount currencyID="JPY">50000</cbc:PriceAmount> <!-- IBT-146 - Item net price -->
			<cbc:BaseQuantity unitCode="H87">1</cbc:BaseQuantity> <!-- IBT-149 - Item price base quantity, IBT-150 - Item price base quantity unit of measure code -->
		</cac:Price>
	</cac:InvoiceLine>
</Invoice>

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です