Search Posts

Visits: 783

スキーマトロン編集ソフト

Open Pepolで使用されているoXygenの試行版をダウンロードして評価したが、思ったように使えなかった。Schematornチェック方法判明。こちらも購入した。Macでも使えるので重宝している。
かってXML Spyのプラグインを提供していたXML ValidatorBudyの非商用(個人用)ライセンスが、税込JPY 2,673だったので、PayPal経由で購入した。

Open Peppol BIS Biling 3.0のスキーマトロン

Peppol BIS Billing 3.0のHomeから次の2つのスキーマトロンファイルをダウンロードした。
Schematron for PEPPOL rules (UBL)
Schematron file containing rules according to ISO Schematron.
Schematron for TC434 rules (UBL)
Schematron file containing rules according to ISO Schematron.
テスト用のサンプルは、PEPPOL BIS Billingページの一番下にあるサンプルを使用する。

日本向けにサンプルXML文書を修正し、検証用の日本向けスキーマトロンも上記ダウンロードから修正して作成

主な変更点

  • 企業コードに国税庁(0188)が発行する法人番号を使用する。
  • 金額表示で小数点以下を使用しない。
  • 1円単位に丸める計算は、切り捨て、四捨五入、切り上げのいずれでも良いので、丸めた値がその範囲内であるか検証する。

サンプル電子インボイス

peppol-bis-invoice-3-master/rules/examples/base-example.xml を基に修正を行い、peppol-bis-invoice-3-master/rules/national-examples/JP/JP-base-example.xmlを作成した。2つのファイルの違いは、次のとおり。

< 	<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
---
> 	<cbc:DocumentCurrencyCode>JPY</cbc:DocumentCurrencyCode>
15c17
< 			<cbc:EndpointID schemeID="0088">9482348239847239874</cbc:EndpointID>
---
> 			<cbc:EndpointID schemeID="0188">9482348239847</cbc:EndpointID>
26c28
< 				<cbc:PostalZone>GB 123 EW</cbc:PostalZone>
---
> 				<cbc:PostalZone>123 4567</cbc:PostalZone>
28c30
< 					<cbc:IdentificationCode>GB</cbc:IdentificationCode>
---
> 					<cbc:IdentificationCode>JP</cbc:IdentificationCode>
32c34
< 				<cbc:CompanyID>GB1232434</cbc:CompanyID>
---
> 				<cbc:CompanyID>T1234567890123</cbc:CompanyID>
39c41
< 				<cbc:CompanyID>GB983294</cbc:CompanyID>
---
> 				<cbc:CompanyID>1234567890123</cbc:CompanyID>
45c47
< 			<cbc:EndpointID schemeID="0002">FR23342</cbc:EndpointID>
---
> 			<cbc:EndpointID schemeID="0188">1234567890123</cbc:EndpointID>
47c49
< 				<cbc:ID schemeID="0002">FR23342</cbc:ID>
---
> 				<cbc:ID schemeID="0002">2334254768903</cbc:ID>
56c58
< 				<cbc:PostalZone>456 34</cbc:PostalZone>
---
> 				<cbc:PostalZone>456 3476</cbc:PostalZone>
58c60
< 					<cbc:IdentificationCode>SE</cbc:IdentificationCode>
---
> 					<cbc:IdentificationCode>JP</cbc:IdentificationCode>
62c64
< 				<cbc:CompanyID>SE4598375937</cbc:CompanyID>
---
> 				<cbc:CompanyID>T4598375937629</cbc:CompanyID>
69c71
< 				<cbc:CompanyID schemeID="0183">39937423947</cbc:CompanyID>
---
> 				<cbc:CompanyID schemeID="0188">3993742394743</cbc:CompanyID>
81c83
< 			<cbc:ID schemeID="0088">9483759475923478</cbc:ID>
---
> 			<cbc:ID schemeID="0188">9483759475923</cbc:ID>
88c90
< 					<cbc:IdentificationCode>SE</cbc:IdentificationCode>
---
> 					<cbc:IdentificationCode>JP</cbc:IdentificationCode>
115c117
< 		<cbc:Amount currencyID="EUR">25</cbc:Amount>
---
> 		<cbc:Amount currencyID="JPY">25</cbc:Amount>
118c120
< 			<cbc:Percent>25.0</cbc:Percent>
---
> 			<cbc:Percent>10</cbc:Percent>
125c127
< 		<cbc:TaxAmount currencyID="EUR">331.25</cbc:TaxAmount>
---
> 		<cbc:TaxAmount currencyID="JPY">132</cbc:TaxAmount>
127,128c129,130
< 			<cbc:TaxableAmount currencyID="EUR">1325</cbc:TaxableAmount>
< 			<cbc:TaxAmount currencyID="EUR">331.25</cbc:TaxAmount>
---
> 			<cbc:TaxableAmount currencyID="JPY">1325</cbc:TaxableAmount>
> 			<cbc:TaxAmount currencyID="JPY">132</cbc:TaxAmount>
131c133
< 				<cbc:Percent>25.0</cbc:Percent>
---
> 				<cbc:Percent>10.0</cbc:Percent>
139,143c141,145
< 		<cbc:LineExtensionAmount currencyID="EUR">1300</cbc:LineExtensionAmount>
< 		<cbc:TaxExclusiveAmount currencyID="EUR">1325</cbc:TaxExclusiveAmount>
< 		<cbc:TaxInclusiveAmount currencyID="EUR">1656.25</cbc:TaxInclusiveAmount>
< 		<cbc:ChargeTotalAmount currencyID="EUR">25</cbc:ChargeTotalAmount>
< 		<cbc:PayableAmount currencyID="EUR">1656.25</cbc:PayableAmount>
---
> 		<cbc:LineExtensionAmount currencyID="JPY">1300</cbc:LineExtensionAmount>
> 		<cbc:TaxExclusiveAmount currencyID="JPY">1325</cbc:TaxExclusiveAmount>
> 		<cbc:TaxInclusiveAmount currencyID="JPY">1458</cbc:TaxInclusiveAmount>
> 		<cbc:ChargeTotalAmount currencyID="JPY">25</cbc:ChargeTotalAmount>
> 		<cbc:PayableAmount currencyID="JPY">1458</cbc:PayableAmount>
148c150
< 		<cbc:LineExtensionAmount currencyID="EUR">2800</cbc:LineExtensionAmount>
---
> 		<cbc:LineExtensionAmount currencyID="JPY">2800</cbc:LineExtensionAmount>
167c169
< 				<cbc:Percent>25.0</cbc:Percent>
---
> 				<cbc:Percent>10.0</cbc:Percent>
174c176
< 			<cbc:PriceAmount currencyID="EUR">400</cbc:PriceAmount>
---
> 			<cbc:PriceAmount currencyID="JPY">400</cbc:PriceAmount>
180c182
< 		<cbc:LineExtensionAmount currencyID="EUR">-1500</cbc:LineExtensionAmount>
---
> 		<cbc:LineExtensionAmount currencyID="JPY">-1500</cbc:LineExtensionAmount>
198c200
< 				<cbc:Percent>25.0</cbc:Percent>
---
> 				<cbc:Percent>10.0</cbc:Percent>
205c207
< 			<cbc:PriceAmount currencyID="EUR">500</cbc:PriceAmount>
---
> 			<cbc:PriceAmount currencyID="JPY">500</cbc:PriceAmount>

JP-base-example.xml

注意: Open Peppolが提供しているサンプルを基に、日本対応として登録事業者番号と金額表示を修正しただけなので、現在EIPAで検討中の業務要件は反映されていない。

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:///D:/Users/pontsoleil/Documents/GitHub/EIPA/%E3%83%87%E3%83%BC%E3%82%BF%E6%A4%9C%E8%A8%BC/peppol-bis-invoice-3-master/stylesheet/stylesheet-ubl.xslt"?>
<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
  <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
  <cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
  <cbc:ID>Snippet1</cbc:ID>
  <cbc:IssueDate>2017-11-13</cbc:IssueDate>
  <cbc:DueDate>2017-12-01</cbc:DueDate>
  <cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
  <cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
  <cbc:AccountingCost>4025:123:4343</cbc:AccountingCost>
  <cbc:BuyerReference>0150abc</cbc:BuyerReference>
  <cac:AccountingSupplierParty>
    <cac:Party>
      <cbc:EndpointID schemeID="0088">9482348239847239874</cbc:EndpointID>
      <cac:PartyIdentification>
        <cbc:ID>99887766</cbc:ID>
      </cac:PartyIdentification>
      <cac:PartyName>
        <cbc:Name>SupplierTradingName Ltd.</cbc:Name>
      </cac:PartyName>
      <cac:PostalAddress>
        <cbc:StreetName>Main street 1</cbc:StreetName>
        <cbc:AdditionalStreetName>Postbox 123</cbc:AdditionalStreetName>
        <cbc:CityName>London</cbc:CityName>
        <cbc:PostalZone>GB 123 EW</cbc:PostalZone>
        <cac:Country>
          <cbc:IdentificationCode>GB</cbc:IdentificationCode>
        </cac:Country>
      </cac:PostalAddress>
      <cac:PartyTaxScheme>
        <cbc:CompanyID>GB1232434</cbc:CompanyID>
        <cac:TaxScheme>
          <cbc:ID>VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:PartyTaxScheme>
      <cac:PartyLegalEntity>
        <cbc:RegistrationName>SupplierOfficialName Ltd</cbc:RegistrationName>
        <cbc:CompanyID>GB983294</cbc:CompanyID>
      </cac:PartyLegalEntity>
    </cac:Party>
  </cac:AccountingSupplierParty>
  <cac:AccountingCustomerParty>
    <cac:Party>
      <cbc:EndpointID schemeID="0002">FR23342</cbc:EndpointID>
      <cac:PartyIdentification>
        <cbc:ID schemeID="0002">FR23342</cbc:ID>
      </cac:PartyIdentification>
      <cac:PartyName>
        <cbc:Name>BuyerTradingName AS</cbc:Name>
      </cac:PartyName>
      <cac:PostalAddress>
        <cbc:StreetName>Hovedgatan 32</cbc:StreetName>
        <cbc:AdditionalStreetName>Po box 878</cbc:AdditionalStreetName>
        <cbc:CityName>Stockholm</cbc:CityName>
        <cbc:PostalZone>456 34</cbc:PostalZone>
        <cac:Country>
          <cbc:IdentificationCode>SE</cbc:IdentificationCode>
        </cac:Country>
      </cac:PostalAddress>
      <cac:PartyTaxScheme>
        <cbc:CompanyID>SE4598375937</cbc:CompanyID>
        <cac:TaxScheme>
          <cbc:ID>VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:PartyTaxScheme>
      <cac:PartyLegalEntity>
        <cbc:RegistrationName>Buyer Official Name</cbc:RegistrationName>
        <cbc:CompanyID schemeID="0183">39937423947</cbc:CompanyID>
      </cac:PartyLegalEntity>
      <cac:Contact>
        <cbc:Name>Lisa Johnson</cbc:Name>
        <cbc:Telephone>23434234</cbc:Telephone>
        <cbc:ElectronicMail>lj@buyer.se</cbc:ElectronicMail>
      </cac:Contact>
    </cac:Party>
  </cac:AccountingCustomerParty>
  <cac:Delivery>
    <cbc:ActualDeliveryDate>2017-11-01</cbc:ActualDeliveryDate>
    <cac:DeliveryLocation>
      <cbc:ID schemeID="0088">9483759475923478</cbc:ID>
      <cac:Address>
        <cbc:StreetName>Delivery street 2</cbc:StreetName>
        <cbc:AdditionalStreetName>Building 56</cbc:AdditionalStreetName>
        <cbc:CityName>Stockholm</cbc:CityName>
        <cbc:PostalZone>21234</cbc:PostalZone>
        <cac:Country>
          <cbc:IdentificationCode>SE</cbc:IdentificationCode>
        </cac:Country>
      </cac:Address>
    </cac:DeliveryLocation>
    <cac:DeliveryParty>
      <cac:PartyName>
        <cbc:Name>Delivery party Name</cbc:Name>
      </cac:PartyName>
    </cac:DeliveryParty>
  </cac:Delivery>
  <cac:PaymentMeans>
    <cbc:PaymentMeansCode name="Credit transfer">30</cbc:PaymentMeansCode>
    <cbc:PaymentID>Snippet1</cbc:PaymentID>
    <cac:PayeeFinancialAccount>
      <cbc:ID>IBAN32423940</cbc:ID>
      <cbc:Name>AccountName</cbc:Name>
      <cac:FinancialInstitutionBranch>
        <cbc:ID>BIC324098</cbc:ID>
      </cac:FinancialInstitutionBranch>
    </cac:PayeeFinancialAccount>
  </cac:PaymentMeans>
  <cac:PaymentTerms>
    <cbc:Note>Payment within 10 days, 2% discount</cbc:Note>
  </cac:PaymentTerms>
  <cac:AllowanceCharge>
    <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
    <cbc:AllowanceChargeReason>Insurance</cbc:AllowanceChargeReason>
    <cbc:Amount currencyID="EUR">25</cbc:Amount>
    <cac:TaxCategory>
      <cbc:ID>S</cbc:ID>
      <cbc:Percent>25.0</cbc:Percent>
      <cac:TaxScheme>
        <cbc:ID>VAT</cbc:ID>
      </cac:TaxScheme>
    </cac:TaxCategory>
  </cac:AllowanceCharge>
  <cac:TaxTotal>
    <cbc:TaxAmount currencyID="EUR">331.25</cbc:TaxAmount>
    <cac:TaxSubtotal>
      <cbc:TaxableAmount currencyID="EUR">1325</cbc:TaxableAmount>
      <cbc:TaxAmount currencyID="EUR">331.25</cbc:TaxAmount>
      <cac:TaxCategory>
        <cbc:ID>S</cbc:ID>
        <cbc:Percent>25.0</cbc:Percent>
        <cac:TaxScheme>
          <cbc:ID>VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:TaxCategory>
    </cac:TaxSubtotal>
  </cac:TaxTotal>
  <cac:LegalMonetaryTotal>
    <cbc:LineExtensionAmount currencyID="EUR">1300</cbc:LineExtensionAmount>
    <cbc:TaxExclusiveAmount currencyID="EUR">1325</cbc:TaxExclusiveAmount>
    <cbc:TaxInclusiveAmount currencyID="EUR">1656.25</cbc:TaxInclusiveAmount>
    <cbc:ChargeTotalAmount currencyID="EUR">25</cbc:ChargeTotalAmount>
    <cbc:PayableAmount currencyID="EUR">1656.25</cbc:PayableAmount>
  </cac:LegalMonetaryTotal>
  <cac:InvoiceLine>
    <cbc:ID>1</cbc:ID>
    <cbc:InvoicedQuantity unitCode="DAY">7</cbc:InvoicedQuantity>
    <cbc:LineExtensionAmount currencyID="EUR">2800</cbc:LineExtensionAmount>
    <cbc:AccountingCost>Konteringsstreng</cbc:AccountingCost>
    <cac:OrderLineReference>
      <cbc:LineID>123</cbc:LineID>
    </cac:OrderLineReference>
    <cac:Item>
      <cbc:Description>Description of item</cbc:Description>
      <cbc:Name>item name</cbc:Name>
      <cac:StandardItemIdentification>
        <cbc:ID schemeID="0088">21382183120983</cbc:ID>
      </cac:StandardItemIdentification>
      <cac:OriginCountry>
        <cbc:IdentificationCode>NO</cbc:IdentificationCode>
      </cac:OriginCountry>
      <cac:CommodityClassification>
        <cbc:ItemClassificationCode listID="SRV">09348023</cbc:ItemClassificationCode>
      </cac:CommodityClassification>
      <cac:ClassifiedTaxCategory>
        <cbc:ID>S</cbc:ID>
        <cbc:Percent>25.0</cbc:Percent>
        <cac:TaxScheme>
          <cbc:ID>VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:ClassifiedTaxCategory>
    </cac:Item>
    <cac:Price>
      <cbc:PriceAmount currencyID="EUR">400</cbc:PriceAmount>
    </cac:Price>
  </cac:InvoiceLine>
  <cac:InvoiceLine>
    <cbc:ID>2</cbc:ID>
    <cbc:InvoicedQuantity unitCode="DAY">-3</cbc:InvoicedQuantity>
    <cbc:LineExtensionAmount currencyID="EUR">-1500</cbc:LineExtensionAmount>
    <cac:OrderLineReference>
      <cbc:LineID>123</cbc:LineID>
    </cac:OrderLineReference>
    <cac:Item>
      <cbc:Description>Description 2</cbc:Description>
      <cbc:Name>item name 2</cbc:Name>
      <cac:StandardItemIdentification>
        <cbc:ID schemeID="0088">21382183120983</cbc:ID>
      </cac:StandardItemIdentification>
      <cac:OriginCountry>
        <cbc:IdentificationCode>NO</cbc:IdentificationCode>
      </cac:OriginCountry>
      <cac:CommodityClassification>
        <cbc:ItemClassificationCode listID="SRV">09348023</cbc:ItemClassificationCode>
      </cac:CommodityClassification>
      <cac:ClassifiedTaxCategory>
        <cbc:ID>S</cbc:ID>
        <cbc:Percent>25.0</cbc:Percent>
        <cac:TaxScheme>
          <cbc:ID>VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:ClassifiedTaxCategory>
    </cac:Item>
    <cac:Price>
      <cbc:PriceAmount currencyID="EUR">500</cbc:PriceAmount>
    </cac:Price>
  </cac:InvoiceLine>
</Invoice>

CEN-EN-16931-UBL.schでの検証

このファイルをValidatorBudyでスキーマトロン検証したところ次のメッセージがあった。

result type=”error”

[BR-CL-25]-Endpoint identifier scheme identifier MUST belong to the CEF EAS code list
EndpointIDの発番機関に0188を指定したが、このコードがCEF EASコードリストにないことがその理由であり、正式登録が必要。今回の評価作業では、スキーマファイルにコード0188を追加した。

また、VAT登録番号の先頭にISO 3166-1で規定されている2文字の国コードがないというメッセージも発行された。

result type=”error”

[BR-CO-09] -The Seller VAT identifier (BT-31), the Seller tax representative VAT identifier (BT-63) and the Buyer VAT identifier (BT-48) shall have a prefix in accordance with ISO code ISO 3166-1 alpha-2 by which the country of issue may be identified. Nevertheless, Greece may use the prefix ‘EL’.
こちらについては、日本固有ルールとして先頭に”T”があることというルールを追加する必要があると考えるが、評価作業は、先頭に”JP”を付加して、”JPT1234567890123″等のコードを設定した。対応策を後述

日本向けルール

context

他の国別拡張の定義を参考に、次のようにcontextを定義した。
<rule context=”/ubl-invoice:Invoice[cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode = ‘JP’ ]”>

登録事業者番号ルール

[JP-R-001]

登録事業者番号がT+13桁の数字かどうかの検証ルールを次に示す。

<!-- VAT Registration Number Rules -->
<rule context="/ubl-invoice:Invoice[cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode = 'JP' ]/cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme[cac:TaxScheme/normalize-space(upper-case(cbc:ID))='VAT']">
      <assert id="JP-R-001" test="matches(normalize-space(cbc:CompanyID),'^T[0-9]{13}$')" flag="fatal">
[JP-R-001]- For the Japanese Suppliers, the VAT registration number must start with 'T' and be  followed by 13-digit number.</assert>
</rule>

金額表示ルール

[JP-R-002]

EN 16931-1およびBIS Billing 3.0では、個別の項目ごとに種数点以下の桁数が2以下であることを検証しているが、下記のように通貨コードでJPYを使用する項目(円通貨での金額)を対象としたルールを提案したい。金額表示では、小数点及び小数点以下を使わないので、正規表現で、^-?[1-9][0-9]*$ (数字のみの表記)の表現と一致するか検証している。
対象は、Amount型の要素のみとし、Unit price型は対象としないので、小数点以下の桁数を表現可能。

<!-- Amount, which is not Unit Price, Representation Rules -->
<rule context="/Invoice/*[local-name()!='InvoiceLine']/*[@currencyID='JPY'] |
        /Invoice/*[local-name()!='InvoiceLine']/*/*[@currencyID='JPY'] |
        //cac:InvoiceLine/cbc:LineExtensionAmount[@currencyID='JPY']">
    <assert id="JP-R-002" test="matches(normalize-space(.),'^-?[1-9][0-9]*$')" flag="fatal">[JP-R-002]- Amount shall be integer.</assert>
</rule>

このルールでは、XPathで//*[@currencyID=‘JPY’]と指定することで、通貨コードでJPYを使用する項目(円通貨での金額)を対象に指定し、正規表現^-?[1-9][0-9]*$と項目値がていマッチしているかチェックしている。
正規表現の意味は、下記の通り。
^正規表現$ ^は、次の文字が先頭文字であることを示し、$は、その前の文字が終端文字であることを示す。すなわち、正規表現との完全一致。

-? -:マイナス符号 ?:その前の文字が1文字存在、あるいは何もない。
[1-9] 1から9の数字1文字
[0-9]* 0から9の数字が複数(省略可)
^-?[1-9][0-9]*$ 先頭がゼロでない数字の組み合わせ、-(マイナス符号)がつくこともある。

[2021-07-01追加]
請求書明細行で記載する品目単価には、小数点以下の数字も必要との指摘があり、次の内容の定義に変更した。

<!-- Amount, which is not Unit Price, Representation Rules -->
<rule context="ubl-invoice:Invoice/*[local-name()!='InvoiceLine']/*[@currencyID='JPY'] |
        ubl-invoice:Invoice/*[local-name()!='InvoiceLine']/*/*[@currencyID='JPY'] |
        //cac:InvoiceLine/cbc:LineExtensionAmount[@currencyID='JPY']">
      <assert id="JP-R-003" test="matches(normalize-space(.),'^-?[1-9][0-9]*$')" flag="fatal">
        [JP-R-003]- Amount shall be integer.</assert>
</rule>

税率別の税額計算値丸めルール(日本)

[JP-BR-CO-17]

税率別の税額(BT-117)が 課税対象金額 (BT-116) x (税率 (BT-119) / 100)を整数に丸めた値の範囲か検証している。ここでは、1円単位で丸めた値が、切り捨てた値以上かつ切り上げた値以下かを検証している。

  <!-- JAPAN -->
  <pattern>
    <rule context="/ubl-invoice:Invoice[cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode = 'JP' ]">
       <assert id="JP-BR-DEC-05" test="not(exists(cac:AllowanceCharge[cbc:ChargeIndicator=true()])) or (matches(normalize-space(cac:AllowanceCharge[cbc:ChargeIndicator=true()]/cbc:Amount),'^[0-9]+$'))" flag="fatal">[JP-BR-DEC-05- the Document level charge amount (BT-99)  shall be integer.</assert>
    <assert id="JP-BR-CO-17" test="(
  round(cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/xs:decimal(cbc:Percent)) = 0
  and (round(xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount)) = 0)
)
or (
  round(cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/xs:decimal(cbc:Percent)) != 0 
  and (
    xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount) &gt;= floor(xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount) * (cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/xs:decimal(cbc:Percent) div 100)))
  and (
    xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount) &lt;= ceiling(xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount) * (cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/xs:decimal(cbc:Percent) div 100)))
)
or (
  not(exists(cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/xs:decimal(cbc:Percent)))
  and (round(xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount)) = 0)
)" flag="fatal">[JP-BR-CO-17]-VAT category tax amount (BT-117) = VAT category taxable amount (BT-116) x (VAT category rate (BT-119) / 100), rounded to integer. The rounded result amount SHALL be between the floor and the ceiling.</assert>
    </rule>
  </pattern>

税率別の税額計算値丸めルール(Open Peppol)

[BR-CO-17]

BR-CO-17 (fatal) VAT category tax amount (BT-117) = VAT category taxable amount (BT-116) x (VAT category rate (BT-119) / 100), rounded to two decimals.
このルールのスキーマトロンでは、* 10 * 10) div 100 で小数点以下2桁に丸めた値がround()で求めた値の±1の範囲内か検証しているが、例えば、34.5は、四捨五入した値が35となり、35±1だと36も許容される。切り上げた値が35なので、これを超えた値が許容されており、問題である。

<assert id="JP-BR-CO-17" test="(
  round(cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/xs:decimal(cbc:Percent)) != 0 
  and (
    xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount) &gt;= floor(xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount) * (cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/xs:decimal(cbc:Percent) div 100)))
  and (
    xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount) &lt;= ceiling(xs:decimal(cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount) * (cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/xs:decimal(cbc:Percent) div 100)))
)" flag="fatal">[JP-BR-CO-17]-VAT category tax amount (BT-117) = VAT category taxable amount (BT-116) x (VAT category rate (BT-119) / 100), rounded to integer. The rounded result amount SHALL be between the floor and the ceiling.</assert>

事業者のVAT登録事業者番号

税コードとしてVATを使用する場合、次のルールがあるため、国税庁のT+13桁をそのままでは使用できない。
BR-CO-09 (fatal)
The Seller VAT identifier (BT-31), the Seller tax representative VAT identifier (BT-63) and the Buyer VAT identifier (BT-48) shall have a prefix in accordance with ISO code ISO 3166-1 alpha-2 by which the country of issue may be identified. Nevertheless, Greece may use the prefix ‘EL’.
スキーマトロンで検証対象を日本とそれ以外の国で分けた、次のような定義が必要になる。最終形は、これから協議予定。

<!-- Not Japan -->
<rule context=“/ubl-invoice:Invoice[cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode != ‘JP’ ]/cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme[cac:TaxScheme/normalize-space(upper-case(cbc:ID))=‘VAT’]“>
      <assert id=“BR-CO-09” flag=“fatal” test=“( contains( 
' 1A AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH EL ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS XI YE YT ZA ZM ZW ’,
substring(cbc:CompanyID,1,2) ) )“>
[BR-CO-09]-The Seller VAT identifier (BT-31), the Seller tax representative VAT identifier (BT-63) and the Buyer VAT identifier (BT-48) shall have a prefix in accordance with ISO code ISO 3166-1 alpha-2 by which the country of issue may be identified. Nevertheless, Greece may use the prefix ‘EL’.
      </assert>
    </rule>
<!-- Japan -->
    <rule context=“/ubl-invoice:Invoice[cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode = ‘JP’ ]/cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme[cac:TaxScheme/normalize-space(upper-case(cbc:ID))=‘VAT’]“>
      <!-- VAT Number Rules -->
      <assert id=“JP-R-001” test=“matches(normalize-space(cbc:CompanyID),‘^T[0-9]{13}$’)” flag=“fatal”>
For the Japanese Suppliers, the VAT registered number must start with ‘T’ and be followed by 13-digit number.
      </assert>
    </rule>

スキーマトロン検証サービス

掲載したイメージは、Open PEPPOLの電子インボイスをスキーマトロンで検証するサービスに、日本対応テストサンプルをアップロードテストした結果。