src/Invoice/FlattenerInvoiceLines.php
protected function copyVatInfoToChildren(array $parent, array $children)
    {
        static $vatMetaInfoTags = array(
            Meta::VatRateMin,
            Meta::VatRateMax,
            Meta::VatRateLookup,
            Meta::VatRateLookupLabel,
            Meta::VatRateLookupSource,
            Meta::VatRateLookupMatches,
            Meta::VatClassId,
            Meta::VatClassName,
        );

        foreach ($children as &$child) {
            if (isset($parent[Tag::VatRate])) {
                $child[Tag::VatRate] = $parent[Tag::VatRate];
            }
            $child[Meta::VatAmount] = 0;
            foreach ($vatMetaInfoTags as $tag) {
                unset($child[$tag]);
            }

            if (Completor::isCorrectVatRate($parent[Meta::VatRateSource])) {
                $child[Meta::VatRateSource] = Completor::VatRateSource_Copied_From_Parent;
            } else {
                // The parent does not yet have correct vat rate info, so also
                // copy the meta data to the child, so later phases can also
                // correct the children.
                $child[Meta::VatRateSource] = $parent[Meta::VatRateSource];
                foreach ($vatMetaInfoTags as $tag) {
                    if (isset($parent[$tag])) {
                        $child[$tag] = $parent[$tag];
                    }
                }
            }

            $child[Meta::LineVatAmount] = 0;
            unset($child[Meta::LineDiscountVatAmount]);
        }
        return $children;
    }
protected function copyVatInfoToChildren(array $parent, array $children)
    {
        static $vatMetaInfoTags = array(
            Meta::VatRateMin,
            Meta::VatRateMax,
            Meta::VatRateLookup,
            Meta::VatRateLookupLabel,
            Meta::VatRateLookupSource,
            Meta::VatRateLookupMatches,
            Meta::VatClassId,
            Meta::VatClassName,
        );

        foreach ($children as &$child) {
            if (isset($parent[Tag::VatRate])) {
                $child[Tag::VatRate] = $parent[Tag::VatRate];
            }
            $child[Meta::VatAmount] = 0;
            foreach ($vatMetaInfoTags as $tag) {
                unset($child[$tag]);
            }

            if (Completor::isCorrectVatRate($parent[Meta::VatRateSource])) {
                $child[Meta::VatRateSource] = Completor::VatRateSource_Copied_From_Parent;
            } else {
                // The parent does not yet have correct vat rate info, so also
                // copy the meta data to the child, so later phases can also
                // correct the children.
                $child[Meta::VatRateSource] = $parent[Meta::VatRateSource];
                foreach ($vatMetaInfoTags as $tag) {
                    if (isset($parent[$tag])) {
                        $child[$tag] = $parent[$tag];
                    }
                }
            }

            $child[Meta::LineVatAmount] = 0;
            unset($child[Meta::LineDiscountVatAmount]);
        }
        return $children;
    }
protected function copyVatInfoToChildren ( array $ parent , array $ children ) { static $ vatMetaInfoTags = array ( Meta :: VatRateMin , Meta :: VatRateMax , Meta :: VatRateLookup , Meta :: VatRateLookupLabel , Meta :: VatRateLookupSource , Meta :: VatRateLookupMatches , Meta :: VatClassId , Meta :: VatClassName , ) ; foreach ( $ children as & $ child ) { if ( isset ( $ parent [ Tag :: VatRate ] ) ) { $ child [ Tag :: VatRate ] = $ parent [ Tag :: VatRate ] ; } $ child [ Meta :: VatAmount ] = 0 ; foreach ( $ vatMetaInfoTags as $ tag ) { unset ( $ child [ $ tag ] ) ; } if ( Completor :: isCorrectVatRate ( $ parent [ Meta :: VatRateSource ] ) ) { $ child [ Meta :: VatRateSource ] = Completor :: VatRateSource_Copied_From_Parent ; } else { // The parent does not yet have correct vat rate info, so also // copy the meta data to the child, so later phases can also // correct the children. $ child [ Meta :: VatRateSource ] = $ parent [ Meta :: VatRateSource ] ; foreach ( $ vatMetaInfoTags as $ tag ) { if ( isset ( $ parent [ $ tag ] ) ) { $ child [ $ tag ] = $ parent [ $ tag ] ; } } } $ child [ Meta :: LineVatAmount ] = 0 ; unset ( $ child [ Meta :: LineDiscountVatAmount ] ) ; } return $ children ; }
Copies vat info from the parent to all children.

In Magento, VAT info on the children may contain a 0 vat rate. To correct
this, we copy the vat information (rate, source, correction info).

@param array $parent
The parent invoice line.
@param array[] $children
The child invoice lines.

@return array[]
The child invoice lines with vat info copied form the parent.
Copies vat info from the parent to all children .