Business-cXML

 view release on metacpan or  search on metacpan

lib/Business/cXML/Amount/TaxDetail.pm  view on Meta::CPAN


use 5.014;
use strict;

package Business::cXML::Amount::TaxDetail;
use base qw(Business::cXML::Object);

use constant NODENAME => 'TaxDetail';
use constant PROPERTIES => (
	category    => '',
	percent     => undef,
	basis       => undef,
	tax         => (Business::cXML::Amount->new()),
	description => undef,
	purpose     => undef,
);
use constant OBJ_PROPERTIES => (
	basis       => [ 'Business::cXML::Amount', 'TaxableAmount' ],
	tax         => [ 'Business::cXML::Amount', 'TaxAmount' ],
	description => 'Business::cXML::Description',
);

use Business::cXML::Amount;
use XML::LibXML::Ferry;

sub from_node {
	my ($self, $el) = @_;

	$el->ferry($self, {
		percentageRate     => 'percent',
		isVatRecoverable   => '__UNIMPLEMENTED',
		taxPointDate       => '__UNIMPLEMENTED',
		paymentDate        => '__UNIMPLEMENTED',
		isTriangularTransaction => '__UNIMPLEMENTED',
		exemptDetail       => '__UNIMPLEMENTED',
		isWithholdingTax   => '__UNIMPLEMENTED',
		taxRateType        => '__UNIMPLEMENTED',
		basePercentageRate => '__UNIMPLEMENTED',
		isIncludedInPrice  => '__UNIMPLEMENTED',
		TaxableAmount      => [ 'basis', 'Business::cXML::Amount' ],

lib/Business/cXML/Amount/TaxDetail.pm  view on Meta::CPAN

		TaxExemption => '__UNIMPLEMENTED',
		Description  => [ 'description', 'Business::cXML::Description' ],
	});
}

sub to_node {
	my ($self, $doc) = @_;
	my $node = $doc->create($self->{_nodeName}, undef,
		purpose        => $self->{purpose},
		category       => $self->{category},
		percentageRate => $self->{percent},
	);

	$node->add($self->{basis}->to_node($node)) if defined $self->{basis};
	$node->add($self->{tax}->to_node($node));
	# TaxLocation
	$node->add($self->{description}->to_node($node)) if defined $self->{description};
	# TriangularTransactionLawReference
	# TaxRegime
	# TaxExemption

	return $node;
}

=item C<B<category>>

Mandatory, i.e. C<gst>

=item C<B<percent>>

Optional, i.e. C<8>

=item C<B<basis>>

Optional, L<Business::cXML::Amount> of type C<TaxableAmount>

=item C<B<tax>>

Mandatory, L<Business::cXML::Amount> of type C<TaxAmount>

t/cxml-amount.t  view on Meta::CPAN

			full      => 'The price for this item',
		},
		type            => undef,
		fees            => [],
		tracking_domain => undef,
		tracking_id     => undef,
		tax_details     => [{
			_nodeName   => 'TaxDetail',
			basis       => undef,
			category    => 'gst',
			percent     => undef,
			purpose     => undef,
			description => undef,
			tax       => {
				_nodeName       => 'TaxAmount',
				currency        => 'USD',
				amount          => 4.99,
				description     => undef,
				type            => undef,
				fees            => [],
				tracking_domain => undef,

t/cxml-amount.t  view on Meta::CPAN

$h = $d->toHash;
$h->{__attributes}{type} = 'other';
cmp_deeply(Business::cXML::Amount->new($d)->to_node($d)->toHash, $h, 'XML AvailablePrice is valid despite incomplete input');

$d = XML::LibXML->load_xml(string => '<Shipping><Money currency="CAD">17.99</Money><Description xml:lang="fr-CA">Long periple</Description></Shipping>')->documentElement;
cmp_deeply(Business::cXML::Amount->new($d)->to_node($d)->toHash, $d->toHash, 'XML round-trip for minimal Shipping');

$d = XML::LibXML->load_xml(string => '<Shipping trackingDomain="td" trackingId="ti"><Money currency="CAD">17.99</Money><Description xml:lang="fr-CA">Long periple</Description></Shipping>')->documentElement;
cmp_deeply(Business::cXML::Amount->new($d)->to_node($d)->toHash, $d->toHash, 'XML round-trip for full Shipping');

$d = XML::LibXML->load_xml(string => '<Tax><Money currency="CAD">21.95</Money><Description xml:lang="fr-CA">General Sales Tax</Description><TaxDetail category="gst" percentageRate="8"><TaxAmount><Money currency="CAD">12.97</Money></TaxAmount></TaxDet...
cmp_deeply(Business::cXML::Amount->new($d)->to_node($d)->toHash, $d->toHash, 'XML round-trip for Tax with minimal TaxDetail');

$d = XML::LibXML->load_xml(string => '<Tax><Money currency="CAD">21.95</Money><Description xml:lang="fr-CA">General Sales Tax</Description><TaxDetail category="gst" percentageRate="8"><TaxableAmount><Money currency="CAD">9.95</Money></TaxableAmount><...
cmp_deeply(Business::cXML::Amount->new($d)->to_node($d)->toHash, $d->toHash, 'XML round-trip for Tax with full TaxDetail');

$d = XML::LibXML->load_xml(string => '<TaxAdjustment><Money currency="CAD">21.95</Money><TaxAdjustmentDetail category="additional" region="C"><Money currency="CAD">12.97</Money></TaxAdjustmentDetail></TaxAdjustment>')->documentElement;
cmp_deeply(Business::cXML::Amount->new($d)->to_node($d)->toHash, $d->toHash, 'XML round-trip for TaxAdjustment');

$d = XML::LibXML->load_xml(string => '<TaxAdjustment><Money currency="CAD">21.95</Money><TaxAdjustmentDetail category="additional"><Money currency="CAD">12.97</Money></TaxAdjustmentDetail></TaxAdjustment>')->documentElement;
cmp_deeply(Business::cXML::Amount->new($d)->to_node($d)->toHash, $d->toHash, 'XML round-trip for TaxAdjustment without detail region');

## Safe ignores
#

t/xml-catalog/cXML-1.2.036/cXML.dtd  view on Meta::CPAN

       The law reference for transactions where isTriangularTransaction is True

    purpose
       The purpose of the tax, e.g., tax (tax), custom duty, shippingTax,
       specialHandlingTax, etc.

    category
       The tax category, Sales tax (sales), Use tax (usage), VAT (vat),
       GST (gst) are defined categories. Other values are permitted.

    percentageRate
       The tax rate in number of percentage.

    isVatRecoverable
       True if the VAT is recoverable.  Default is false.

    taxPointDate
       refers to the date on which VAT becomes due.

    paymentDate
       indicate the date when payment must be made.

t/xml-catalog/cXML-1.2.036/cXML.dtd  view on Meta::CPAN

       a reason why.  zeroRated means the tax rate is zero.  exempt
       means the item or items are exempt from taxation.
	   
	taxRateType
	   Specify the tax rate type code(a string) that corresponds to a specific tax type. 
 	   For example, in Germany the tax rate of 19% for value-added tax (VAT) corresponds to the “Standard” tax rate type. 
 	   In different EU member states, different VAT rates are allowed. 
 	   The tax rate type makes it easy for the back-end system to handle different rates that result from changes in tax law.

    basePercentageRate
       The base tax rate in number of percentage.
       For some Tax categories (eg, ICMS for Brazil) TaxAmount will be calculated
       considering the basePercentageRate along with percentageRate.
       TaxAmount = TaxableAmount * percentageRate * basePercentageRate
       Used only in the Quote Messages.

    isIncludedInPrice
       True if the TaxAmount is included in price. Default is false.
       Used only in the Quote Messages.

-->
<!ELEMENT TaxDetail (TaxableAmount?, TaxAmount, TaxLocation?, Description?,
                     TriangularTransactionLawReference?, TaxRegime?, TaxExemption?,
					 Extrinsic*)>
<!ATTLIST TaxDetail
    taxedElement            IDREF          #IMPLIED
	purpose                 %string;       #IMPLIED
    category                %string;       #REQUIRED
    percentageRate          %r8;           #IMPLIED
    isVatRecoverable        (yes)          #IMPLIED
    taxPointDate            %datetime.tz;  #IMPLIED
    paymentDate             %datetime.tz;  #IMPLIED
    isTriangularTransaction (yes)          #IMPLIED
    exemptDetail            (zeroRated | exempt)  #IMPLIED
	isWithholdingTax        (yes)          #IMPLIED
	taxRateType				%string;	   #IMPLIED
    basePercentageRate      %r8;           #IMPLIED
    isIncludedInPrice       (yes)          #IMPLIED
>

t/xml-catalog/cXML-1.2.036/cXML.dtd  view on Meta::CPAN

    endDate          %datetime.tz;  #IMPLIED
 >

 <!ELEMENT Value EMPTY>
 <!ATTLIST Value
	value            %number;       #REQUIRED
 >

 <!ELEMENT Percentage EMPTY>
 <!ATTLIST Percentage
 	percent          %r8;           #REQUIRED
 >

 <!--
	The Money element is the final cost amount for this Additional Cost or Charge
 	DO NOT USE THIS ELEMENT FOR SHIPPING, SPECIAL HANDLING, FREIGHT, etc
 -->
 <!ELEMENT AdditionalCost (Money|Percentage)>

<!--
    Defines discount applied.

    DiscountAmount
        	The discount expressed as a flat amount with currency.

    DiscountPercent
        	The discount rate expressed as a percentage.
-->
<!ELEMENT Discount (DiscountPercent | DiscountAmount)>


<!-- Defines the Basis for the Discount. -->

<!ELEMENT DiscountBasis (Money)>

<!-- Defines the details of adjustments given over category and region -->

t/xml-catalog/cXML-1.2.036/cXML.dtd  view on Meta::CPAN


    TaxAdjustmentDetail
        Describes the list of all the Adjustments given on the payable on
        the basis of tax category and region.
-->
<!ELEMENT TaxAdjustment (Money, TaxAdjustmentDetail*)>

<!--
    Defines the discount rate

    percent
        The discount rate expressed as a percentage.  A negative discount percent
        represents a penalty.
-->
<!ELEMENT DiscountPercent EMPTY>
<!ATTLIST DiscountPercent
	percent          %r8;           #REQUIRED
>

<!--
    Defines the deduction rate

    percent
        The deduction rate expressed as a percentage.
-->
<!ELEMENT DeductionPercent EMPTY>
<!ATTLIST DeductionPercent
	percent          %r8;           #REQUIRED
>

<!--
    The ProductMovementItemIDInfo element provides a clear reference to the line item
    in a Consignment Movement.

    movementLineNumber
        The line number of current line item, copied from movement document.

    movementID

t/xml-catalog/cXML-1.2.036/cXML.dtd  view on Meta::CPAN


<!--
    Defines a payment term in an invoice or order.  This deprecates the
		InvoiceDetailPaymentTerm previously defined.  Payment term can be the 
		net term (without discount) or discount term (with discount).

    payInNumberOfDays
        The number of days after invoice effective date for the invoice to be paid.

    Discount
	 	The percentage or amount of the discount term.  This element should be omitted
	 	if the payment term is a net term.
    Extrinsic
	Additional information related to this payment term.
-->
<!ELEMENT PaymentTerm (Discount?, Extrinsic*)>
<!ATTLIST PaymentTerm
    payInNumberOfDays        %uint;         #REQUIRED
>

<!--

t/xml-catalog/cXML-1.2.036/cXML.dtd  view on Meta::CPAN

        it could be set to one.

    Note:
        The UnitsOfMeasure of Min/MaxQuantity and Min/MaxReleaseQuantity is same as the one in ItemDetail.

    Note:
        The MaxReleaseAmount/Quantity and MinReleaseAmount/Quantity at an item level
        indicate the item level amounts and quantities per release (purchase order).

    Note:
        <Modifications> in <UnitPrice> will be used to send Discount amount/percent, Surcharges, Tax, and etc.
        For example,
        <UnitPrice>
            <Money currency="USD">1000.00</Money>
            <Modifications>
                 <Modification>
                     <AdditionalDeduction type="DISCOUNT">
                         <DeductionAmount>
                             <Money currency="USD">10.00</Money>
                         </DeductionAmount>
                     </AdditionalDeduction>



( run in 0.360 second using v1.01-cache-2.11-cpan-709fd43a63f )