Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruleset 1.3.3 - UBL - BR-CO-15 is broken if more than one TaxAmount is present #257

Closed
phax opened this issue Dec 18, 2020 · 9 comments
Closed
Milestone

Comments

@phax
Copy link
Collaborator

phax commented Dec 18, 2020

A UBL CreditNote having 2 TaxTotal sections

  <cac:TaxTotal>
      <cbc:TaxAmount currencyID="EUR">2048.44</cbc:TaxAmount>
      <cac:TaxSubtotal>
         <cbc:TaxableAmount currencyID="EUR">10781.25</cbc:TaxableAmount>
         <cbc:TaxAmount currencyID="EUR">2048.44</cbc:TaxAmount>
         <cac:TaxCategory>
            <cbc:ID>S</cbc:ID>
            <cbc:Percent>19</cbc:Percent>
            <cac:TaxScheme>
               <cbc:ID>VAT</cbc:ID>
            </cac:TaxScheme>
         </cac:TaxCategory>
      </cac:TaxSubtotal>    
  </cac:TaxTotal>
  
  
  <cac:TaxTotal>
      <cbc:TaxAmount currencyID="EUR">2048.44</cbc:TaxAmount>
  </cac:TaxTotal>

(taken from an XRechnung 2.0.1 example UBL creditnote -
ubl-cn-br-de-10-test-219-identity.log (it's an XML))

Creates the following error with Saxon 10.3:

net.sf.saxon.trans.XPathException: A sequence of more than one item is not allowed as the second operand of '+' (2048.44, 2048.44)

The source of the rule is this:

  <param name="BR-CO-15" value="every $Currency in cbc:DocumentCurrencyCode satisfies (cac:LegalMonetaryTotal/xs:decimal(cbc:TaxInclusiveAmount) = round( (cac:LegalMonetaryTotal/xs:decimal(cbc:TaxExclusiveAmount) + cac:TaxTotal/xs:decimal(cbc:TaxAmount[@currencyID=$Currency])) * 10 * 10) div 100)"/>

To avoid the error, may using the sum function here should resolve the issue.

@oriol
Copy link
Collaborator

oriol commented Mar 16, 2021

@phax,the second repetition of the TaxTotal is supposed to be in another currency.

From the EN: The BT-111 Invoice total VAT amount in accounting currency

In the example, the second repetition of the TaxTotal has the same currency as the first one, and I think the solution is not summing up both values.

@oriol oriol added the wontfix label Mar 16, 2021
@phax
Copy link
Collaborator Author

phax commented Mar 16, 2021

Okay, so maybe you could add a rule that states, that no 2 top-level TaxTotal elements have the same TaxAmount/@currencyID ??

@oriol
Copy link
Collaborator

oriol commented Mar 16, 2021

Added condition to check there is only one TaxTotal for each currency.

@oriol oriol closed this as completed Mar 16, 2021
@BewanBC
Copy link

BewanBC commented May 19, 2021

The consequence of this modification is that we can not specify the TaxTotal in the InvoiceLine level anymore, should we modify our software to avoid the use of TaxTotal in the invoiceLine ?

@oriol
Copy link
Collaborator

oriol commented May 19, 2021

As far as I know, the EN does not allow TaxTotal in the InvoiceLine. You can specify the class ClassifiedTaxCategory within the Item of each InvoiceLine, but not TaxTotal per InvoiceLine.

@BewanBC
Copy link

BewanBC commented May 20, 2021

ok thank you for your answer, we will remove the TaxTotal per InvoiceLine for BIS3. On the other hand we must keep it for UBLBE (until now UBLBE need the TaxTotal per InvoiceLine but maybe this could change in the next few days...)

@PatrickVHL
Copy link

@oriol this change has broken the SeeF (energy e-invoice) extension that is used in the Netherlands.
The extension contains a TaxTotalPerSupplierParty which references the TaxTotal.
Is it possible to make the xpath more specific to overcome this issue?

@PatrickVHL
Copy link

<param name="BR-CO-15" value="every $Currency in cbc:DocumentCurrencyCode satisfies (count(cac:TaxTotal/xs:decimal(cbc:TaxAmount[@currencyID=$Currency])) eq 1) and (cac:LegalMonetaryTotal/xs:decimal(cbc:TaxInclusiveAmount) = round( (cac:LegalMonetaryTotal/xs:decimal(cbc:TaxExclusiveAmount) + cac:TaxTotal/xs:decimal(cbc:TaxAmount[@currencyID=$Currency])) * 10 * 10) div 100)"/>

or

<param name="BR-CO-15" value="every $Currency in cbc:DocumentCurrencyCode satisfies (count(/*/cac:TaxTotal/xs:decimal(cbc:TaxAmount[@currencyID=$Currency])) eq 1) and (cac:LegalMonetaryTotal/xs:decimal(cbc:TaxInclusiveAmount) = round( (cac:LegalMonetaryTotal/xs:decimal(cbc:TaxExclusiveAmount) + cac:TaxTotal/xs:decimal(cbc:TaxAmount[@currencyID=$Currency])) * 10 * 10) div 100)"/>

@oriol oriol reopened this Jun 25, 2021
@rkottmann
Copy link
Contributor

That could be the CII solution:

every $Currency  in rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode satisfies       
            (  count (
                   rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:TaxTotalAmount[@currencyID=$Currency]    ) eq 1 
              and  
              (//ram:SpecifiedTradeSettlementHeaderMonetarySummation/xs:decimal(ram:GrandTotalAmount) 
                = round( 
                    (//ram:SpecifiedTradeSettlementHeaderMonetarySummation/xs:decimal(ram:TaxBasisTotalAmount) + (//ram:SpecifiedTradeSettlementHeaderMonetarySummation/xs:decimal(ram:TaxTotalAmount[@currencyID=$Currency]))) * 10 * 10) div 100)) or (//ram:SpecifiedTradeSettlementHeaderMonetarySummation/xs:decimal(ram:GrandTotalAmount)     = (//ram:SpecifiedTradeSettlementHeaderMonetarySummation/xs:decimal(ram:TaxBasisTotalAmount)
                    
       )
    )

But only did some first tests. More to follow.

@oriol oriol closed this as completed in 9abc852 Sep 22, 2021
oriol added a commit that referenced this issue Sep 22, 2021
Proposed fix for #257 and #284 - BR-CO-15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants