src/Invoice/CompletorStrategyLines.php
protected function completeStrategyLines()
    {
        if ($this->invoiceHasStrategyLine()) {
            $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-rates'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($this->possibleVatRates, true));

            $isFirst = true;
            $strategies = $this->getStrategyClasses();
            foreach ($strategies as $strategyClass) {
                /** @var CompletorStrategyBase $strategy */
                $strategy = new $strategyClass($this->config, $this->translator, $this->invoice, $this->possibleVatTypes, $this->possibleVatRates, $this->source);
                if ($isFirst) {
                    $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-2-divide'] = $strategy->getVat2Divide();
                    $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-breakdown'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($strategy->getVatBreakdown(), true));
                    $isFirst = false;
                }
                if ($strategy->apply()) {
                    $this->replaceLinesCompleted($strategy->getLinesCompleted(), $strategy->getReplacingLines(), $strategy->getName());
                    if (empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed])) {
                        $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] = $strategy->getDescription();
                    } else {
                        $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] .= '; ' . $strategy->getDescription();
                    }
                    // Allow for partial solutions: a strategy may correct only some of
                    // the strategy lines and leave the rest up to other strategies.
                    if (!$this->invoiceHasStrategyLine()) {
                        break;
                    }
                }
            }
        }
    }
protected function completeStrategyLines()
    {
        if ($this->invoiceHasStrategyLine()) {
            $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-rates'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($this->possibleVatRates, true));

            $isFirst = true;
            $strategies = $this->getStrategyClasses();
            foreach ($strategies as $strategyClass) {
                /** @var CompletorStrategyBase $strategy */
                $strategy = new $strategyClass($this->config, $this->translator, $this->invoice, $this->possibleVatTypes, $this->possibleVatRates, $this->source);
                if ($isFirst) {
                    $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-2-divide'] = $strategy->getVat2Divide();
                    $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-breakdown'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($strategy->getVatBreakdown(), true));
                    $isFirst = false;
                }
                if ($strategy->apply()) {
                    $this->replaceLinesCompleted($strategy->getLinesCompleted(), $strategy->getReplacingLines(), $strategy->getName());
                    if (empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed])) {
                        $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] = $strategy->getDescription();
                    } else {
                        $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] .= '; ' . $strategy->getDescription();
                    }
                    // Allow for partial solutions: a strategy may correct only some of
                    // the strategy lines and leave the rest up to other strategies.
                    if (!$this->invoiceHasStrategyLine()) {
                        break;
                    }
                }
            }
        }
    }
protected function completeStrategyLines ( ) { if ( $ this -> invoiceHasStrategyLine ( ) ) { $ this -> invoice [ Tag :: Customer ] [ Tag :: Invoice ] [ Meta :: CompletorStrategyInput ] [ 'vat-rates' ] = str_replace ( array ( '=>' , ' ' , "\r" , "\n" , "\t" ) , array ( '=' ) , var_export ( $ this -> possibleVatRates , true ) ) ; $ isFirst = true ; $ strategies = $ this -> getStrategyClasses ( ) ; foreach ( $ strategies as $ strategyClass ) { /** @var CompletorStrategyBase $strategy */ $ strategy = new $ strategyClass ( $ this -> config , $ this -> translator , $ this -> invoice , $ this -> possibleVatTypes , $ this -> possibleVatRates , $ this -> source ) ; if ( $ isFirst ) { $ this -> invoice [ Tag :: Customer ] [ Tag :: Invoice ] [ Meta :: CompletorStrategyInput ] [ 'vat-2-divide' ] = $ strategy -> getVat2Divide ( ) ; $ this -> invoice [ Tag :: Customer ] [ Tag :: Invoice ] [ Meta :: CompletorStrategyInput ] [ 'vat-breakdown' ] = str_replace ( array ( '=>' , ' ' , "\r" , "\n" , "\t" ) , array ( '=' ) , var_export ( $ strategy -> getVatBreakdown ( ) , true ) ) ; $ isFirst = false ; } if ( $ strategy -> apply ( ) ) { $ this -> replaceLinesCompleted ( $ strategy -> getLinesCompleted ( ) , $ strategy -> getReplacingLines ( ) , $ strategy -> getName ( ) ) ; if ( empty ( $ this -> invoice [ Tag :: Customer ] [ Tag :: Invoice ] [ Meta :: CompletorStrategyUsed ] ) ) { $ this -> invoice [ Tag :: Customer ] [ Tag :: Invoice ] [ Meta :: CompletorStrategyUsed ] = $ strategy -> getDescription ( ) ; } else { $ this -> invoice [ Tag :: Customer ] [ Tag :: Invoice ] [ Meta :: CompletorStrategyUsed ] .= '; ' . $ strategy -> getDescription ( ) ; } // Allow for partial solutions: a strategy may correct only some of // the strategy lines and leave the rest up to other strategies. if ( ! $ this -> invoiceHasStrategyLine ( ) ) { break ; } } } } }
Complete all lines that need a vat divide strategy to compute correct
values.
Complete all lines that need a vat divide strategy to compute correct values .