src/Invoice/CompletorInvoiceLines.php
protected function correctCalculatedVatRates(array $lines)
    {
        foreach ($lines as &$line) {
            if (!empty($line[Meta::VatRateSource]) && $line[Meta::VatRateSource] === Creator::VatRateSource_Calculated) {
                $line = $this->correctVatRateByRange($line);
            }
            if (!empty($line[Meta::ChildrenLines])) {
                $line[Meta::ChildrenLines] = $this->correctCalculatedVatRates($line[Meta::ChildrenLines]);
            }
        }
        return $lines;
    }
protected function correctCalculatedVatRates(array $lines)
    {
        foreach ($lines as &$line) {
            if (!empty($line[Meta::VatRateSource]) && $line[Meta::VatRateSource] === Creator::VatRateSource_Calculated) {
                $line = $this->correctVatRateByRange($line);
            }
            if (!empty($line[Meta::ChildrenLines])) {
                $line[Meta::ChildrenLines] = $this->correctCalculatedVatRates($line[Meta::ChildrenLines]);
            }
        }
        return $lines;
    }
protected function correctCalculatedVatRates ( array $ lines ) { foreach ( $ lines as & $ line ) { if ( ! empty ( $ line [ Meta :: VatRateSource ] ) && $ line [ Meta :: VatRateSource ] === Creator :: VatRateSource_Calculated ) { $ line = $ this -> correctVatRateByRange ( $ line ) ; } if ( ! empty ( $ line [ Meta :: ChildrenLines ] ) ) { $ line [ Meta :: ChildrenLines ] = $ this -> correctCalculatedVatRates ( $ line [ Meta :: ChildrenLines ] ) ; } } return $ lines ; }
Corrects 'calculated' vat rates.

Tries to correct 'calculated' vat rates for rounding errors by matching
them with possible vatRates obtained from the vat lookup service.

@param array[] $lines
The invoice lines to correct.

@return array[]
The corrected invoice lines.
Corrects calculated vat rates .