OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

ubl-dev message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [ubl-dev] Test Assertions for UBL Calculation Model?


Here is a more mature/complete calculation model
represented in unapproved draft (0.4) OASIS Test
Assertions Guidelines TC (TAG TC) test assertions
markup.

Hopefully the calculation 'rules' can be extracted in
a more human-readable format (hopefully on wiki for
HISC Calculation Model within a short while, time
permitting).

http://wiki.oasis-open.org/ubl/Example_Calculation_Models/Invoice_Tax_Total
http://lists.oasis-open.org/archives/ubl-dev/200906/msg00065.html

I do hope this can eventually mature to the point it
can be formally approved by the UBL TC.


I'll attach the XML file as an attachment too (but I'm
not sure whether the list server will allow it through)

Note: the 'permitted' value for 'PrescriptionLevel' reflects
same degree of ambiguity within the definitions and between
those and the examples/accepted practice; plus the
conformance definition being in terms of schema-validity
such that there may be several conformant calculation
models, though I am here seeking the best practise
one which I believe is implicit in the UBL Invoice model.


<?xml version="1.0" encoding="UTF-8"?>
<testAssertionSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:noNamespaceSchemaLocation="testAssertion-0-4.xsd"
    id="documentengineeringservices:sdg:ubl:2:ta:draft:0-3">
    <header>
        <var name="ubl-cac-2-0-schema"
lg="xpath20">doc("http://docs.oasis-open.org/ubl/os-UBL-2.0/xsd/common/UBL-CommonAggregateComponents-2.0.xsd";)</var>
        <tag name="invoice"/>
    </header>
    <testAssertion id="INV001">
        <normativeSource>
            <comment>is an OASIS UBL 2 invoice according to OASIS UBL
2.0 standard schema</comment>
            <derivedSourceItem>http://docs.oasis-open.org/ubl/os-UBL-2.0/UBL-2.0.html</derivedSourceItem>
            <derivedSourceItem>http://docs.oasis-open.org/ubl/os-UBL-2.0/xsdrt/maindoc/UBL-Invoice-2.0.xsd</derivedSourceItem>
            <interpretation>invoice is valid according to the UBL 2.0
standard invoice schema</interpretation>
        </normativeSource>
        <target lg="xpath20">/in:Invoice</target>
        <prerequisite lg="xpath20">count(/*[local-name()="Invoice"])
eq 1</prerequisite>
        <predicate lg="en-us">document validates against schema:
http://docs.oasis-open.org/ubl/os-UBL-2.0/xsdrt/maindoc/UBL-Invoice-2.0.xsd</predicate>
        <prescriptionLevel>mandatory</prescriptionLevel>
    </testAssertion>
    <testAssertionSet id="invoice-calculation-model-001">
        <header>
            <prerequisite lg="ta">INV001 = "pass"</prerequisite>
        </header>
        <testAssertion id="INVTAX001">
            <normativeSource>
                <comment>general practice but no known normative
source</comment>
            </normativeSource>
            <target
lg="xpath20">count(distinct-values(/*[local-name()="Invoice"]/cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount/@currencyID))</target>
            <prerequisite lg="ta">is-tax-invoice-001 = 'pass'</prerequisite>
            <predicate>count(distinct-values(/*[local-name()="Invoice"]/cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount/@currencyID))
                gt 0</predicate>
            <prescriptionLevel>preferred</prescriptionLevel>
            <tag name="invoice:tax"/>
        </testAssertion>
        <testAssertion id="INVTAX002">
            <normativeSource>
                <comment>general practice but no known normative
source</comment>
            </normativeSource>
            <target
lg="xpath20">count(distinct-values(/*[local-name()="Invoice"]/cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount/@currencyID))</target>
            <prerequisite lg="ta">is-tax-invoice-001 = 'pass' and
INVTAX001 = "pass"</prerequisite>
            <predicate
lg="xpath20">count(distinct-values(/*[local-name()="Invoice"]/cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount/@currencyID))
                lt 2</predicate>
            <prescriptionLevel>preferred</prescriptionLevel>
            <tag name="invoice:tax"/>
        </testAssertion>
        <testAssertion id="INVTAX003">
            <normativeSource>
                <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='TaxTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:TaxAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='TaxSubtotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:TaxAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
            </normativeSource>
            <target
lg="xpath20">sum(/in:Invoice/cac:TaxTotal/cbc:TaxAmount)</target>
            <prerequisite lg="ta">is-tax-invoice-001 = 'pass' and
INVTAX001 = 'pass'</prerequisite>
            <predicate
lg="xpath20">sum(/*[local-name()="Invoice"]/cac:TaxTotal/cbc:TaxAmount)
eq

sum(/*[local-name()="Invoice"]/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount)</predicate>
            <prescriptionLevel>preferred</prescriptionLevel>
            <tag name="invoice:tax"/>
        </testAssertion>
        <testAssertionSet id="is-tax-invoice-001"
definesNormativeProperty="true">
            <header>
                <normativePropertyTag>TaxInvoice</normativePropertyTag>
                <tag name="invoice:tax"/>
            </header>
            <testAssertion id="TAXINV001">
                <normativeSource>
                    <comment>general practice but no known normative
source</comment>
                </normativeSource>
                <predicate
lg="xpath20">exists(ubl-invoice-2-0-instance//cbc:TaxAmount)</predicate>
                <prescriptionLevel>mandatory</prescriptionLevel>
            </testAssertion>
            <testAssertion id="TAXINV002" lg="en-us">
                <normativeSource>
                    <comment>is a tax invoice according to most
relevant tax rules</comment>
                </normativeSource>
                <predicate lg="en-us">is a tax invoice</predicate>
                <prescriptionLevel>mandatory</prescriptionLevel>
            </testAssertion>
        </testAssertionSet>
        <testAssertionSet id="invoice-total-001">
            <testAssertion id="INVTOT001">
                <normativeSource>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:LineExtensionAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                </normativeSource>
                <target
lg="xpath20">/in:Invoice/cac:LegalMonetaryTotal/cbc:LineExtensionAmount</target>
                <prerequisite
lg="xpath20">count(distinct-values(//@currencyID)) eq 1 and

exists(/*[local-name()="Invoice"]/cac:InvoiceLine/cbc:LineExtensionAmount)</prerequisite>
                <predicate
lg="xpath20">number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:LineExtensionAmount)
eq

(sum(/*[local-name()="Invoice"]/cac:InvoiceLine/cbc:LineExtensionAmount))</predicate>
                <prescriptionLevel>preferred</prescriptionLevel>
                <tag name="invoice:total"/>
            </testAssertion>
            <testAssertion id="INVTOT002">
                <normativeSource>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:TaxExclusiveAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                </normativeSource>
                <target
lg="xpath20">/in:Invoice/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount</target>
                <prerequisite
lg="xpath20">count(distinct-values(/*[local-name()="Invoice"]//@currencyID))
eq 1 and

exists(/*[local-name()="Invoice"]/cac:InvoiceLine/cbc:LineExtensionAmount)</prerequisite>
                <predicate
lg="xpath20">number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount)
eq

(sum(/*[local-name()="Invoice"]/cac:InvoiceLine/cbc:LineExtensionAmount)
+

sum(/*[local-name()="Invoice"]/cac:AllowanceCharge[cbc:ChargeIndicator='true']/cbc:Amount)
-

sum(/*[local-name()="Invoice"]/cac:AllowanceCharge[cbc:ChargeIndicator='false']/cbc:Amount))</predicate>
                <prescriptionLevel>preferred</prescriptionLevel>
                <tag name="invoice:total"/>
            </testAssertion>
            <testAssertion id="INVTOT002">
                <normativeSource>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:TaxExclusiveAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                </normativeSource>
                <target
lg="xpath20">/in:Invoice/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount</target>
                <prerequisite
lg="xpath20">count(distinct-values(//@currencyID)) eq 1 and

exists(/*[local-name()="Invoice"]/cac:InvoiceLine/cbc:LineExtensionAmount)</prerequisite>
                <predicate
lg="xpath20">number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount)
eq

(sum(/*[local-name()="Invoice"]/cac:InvoiceLine/cbc:LineExtensionAmount)
+

sum(/*[local-name()="Invoice"]/cac:AllowanceCharge[cbc:ChargeIndicator='true']/cbc:Amount)
-

sum(/*[local-name()="Invoice"]/cac:AllowanceCharge[cbc:ChargeIndicator='false']/cbc:Amount))</predicate>
                <prescriptionLevel>preferred</prescriptionLevel>
                <tag name="invoice:total"/>
            </testAssertion>
            <testAssertion id="INVTOT003">
                <normativeSource>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:AllowanceTotalAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                </normativeSource>
                <target
lg="xpath20">/in:Invoice/cac:LegalMonetaryTotal/cbc:AllowanceTotalAmount</target>
                <prerequisite
lg="xpath20">count(distinct-values(//@currencyID)) eq 1 and

exists(/*[local-name()="Invoice"]/cac:InvoiceLine/cbc:LineExtensionAmount)</prerequisite>
                <predicate
lg="xpath20">number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:AllowanceTotalAmount)
eq

(sum(/*[local-name()="Invoice"]/cac:AllowanceCharge[cbc:ChargeIndicator='false']/cbc:Amount)
-

sum(/*[local-name()="Invoice"]/cac:AllowanceCharge[cbc:ChargeIndicator='true']/cbc:Amount))</predicate>
                <prescriptionLevel>preferred</prescriptionLevel>
                <tag name="invoice:total"/>
            </testAssertion>
            <testAssertion id="INVTOT004">
                <normativeSource>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:LineExtensionAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:TaxExclusiveAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:AllowanceTotalAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                </normativeSource>
                <target lg="xpath20">/in:Invoice/cac:LegalMonetaryTotal</target>
                <prerequisite
lg="xpath20">count(distinct-values(//@currencyID)) eq 1 and

exists(/*[local-name()="Invoice"]/cac:InvoiceLine/cbc:LineExtensionAmount)</prerequisite>
                <predicate
lg="xpath20">number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:LineExtensionAmount)
eq

number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount)
+ number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:AllowanceTotalAmount)</predicate>
                <prescriptionLevel>preferred</prescriptionLevel>
                <tag name="invoice:total"/>
            </testAssertion>
        </testAssertionSet>
        <testAssertionSet id="invoice-total-002">
            <testAssertion id="INVTOT005">
                <normativeSource>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:LineExtensionAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:TaxExclusiveAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:AllowanceTotalAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='MonetaryTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:PayableAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='TaxTotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:TaxAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                    <refSourceItem
lg="xpath20">$ubl-cac-2-0-schema/xsd:schema/xsd:complexType[@name='TaxSubtotalType']/xsd:sequence[1]/xsd:element[@ref='cbc:TaxAmount']/xsd:annotation[1]/xsd:documentation[1]/ccts:Component[1]/ccts:Definition[1]</refSourceItem>
                </normativeSource>
                <target
lg="xpath20">/in:Invoice/cac:LegalMonetaryTotal/cbc:PayableAmount</target>
                <prerequisite lg="xpath20">invoice-total-001 =
"pass"</prerequisite>
                <predicate
lg="xpath20">number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:PayableAmount)
eq

number(/*[local-name()="Invoice"]/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount)
+ sum(/*[local-name()="Invoice"]/cac:TaxTotal/cbc:TaxAmount)</predicate>
                <prescriptionLevel>preferred</prescriptionLevel>
                <tag name="invoice:total"/>
            </testAssertion>
        </testAssertionSet>
    </testAssertionSet>
</testAssertionSet>



Stephen D Green



2009/6/26 Stephen Green <stephen.green@documentengineeringservices.com>:
> To UBL-DEV and UBL-comment
>
> I've been looking at prototyping some test assertions (TAs) to represent
> the UBL Calculation Model (for possible conformance testing in future)
> - albeit what is implied by the semantic definitions in the UBL 2.0
> schema set. I'm using the OASIS Test Assertions TC TA model,
> guidelines and markup. I anticipate needing to feedback to UBL TC any
> ambiguities and/or corner cases in the definitions that this process turns
> up. One which has just turned up is the LineExtensionAmount which
> seems to be ambiguous in that it would appear (from the invoice example
> in the 2.0 package) to be at document level the total of all
> LineExtensionAmounts at line level. The ambiguity is that the definition
> doesn't very well support this apprently safe interpretation in that it could
> be read to mean that the document level total LineExtensionAmount
> also includes allowances and charges. These would normally be
> not in the LineExtensionAmount but in the TaxExclusiveAmount, as shown
> in the UBL invoice example.
>
> Here is a provisional prototype of my TA Set - no liability if it's wrong, etc
>
> <?xml version="1.0" encoding="UTF-8"?>
...

ubl-ta-draft-0-3.zip



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]