src/OpenCart/Invoice/Creator.php
protected function getTotalLine(array $line, $exVat)
    {
        $result = array(
            Tag::Product => $line['title'],
            Tag::Quantity => 1,
        );
        if ($exVat) {
            $result[Tag::UnitPrice] = $line['value'];
        } else {
            $result[Meta::UnitPriceInc] = $line['value'];
        }

        if ($line['code'] === 'voucher') {
            // A voucher is to be seen as a partial payment, thus no tax.
            $result += array(
                Tag::VatRate => -1,
                Meta::VatRateSource => Creator::VatRateSource_Exact0,
            );
        } elseif ($line['code'] === 'coupon') {
            // Coupons may have to be split over various taxes.
            $result += array(
                Tag::VatRate => null,
                Meta::VatRateSource => Creator::VatRateSource_Strategy,
                Meta::StrategySplit => $line['code'] === 'coupon',
            );
        } else {
            // Try to get a vat rate.
            $vatRateLookupMetaData = $this->getVatRateLookupByTotalLineType($line['code']);
            // The completor will add the looked up vat rate based on looked up
            // or just the highest appearing vat rate, or wil pass it to the
            // strategy phase.
            $result += array(
                Tag::VatRate => null,
                Meta::VatRateSource => Creator::VatRateSource_Completor,
                Meta::StrategySplit => false,
            ) + $vatRateLookupMetaData;
        }

        return $result;
    }
protected function getTotalLine(array $line, $exVat)
    {
        $result = array(
            Tag::Product => $line['title'],
            Tag::Quantity => 1,
        );
        if ($exVat) {
            $result[Tag::UnitPrice] = $line['value'];
        } else {
            $result[Meta::UnitPriceInc] = $line['value'];
        }

        if ($line['code'] === 'voucher') {
            // A voucher is to be seen as a partial payment, thus no tax.
            $result += array(
                Tag::VatRate => -1,
                Meta::VatRateSource => Creator::VatRateSource_Exact0,
            );
        } elseif ($line['code'] === 'coupon') {
            // Coupons may have to be split over various taxes.
            $result += array(
                Tag::VatRate => null,
                Meta::VatRateSource => Creator::VatRateSource_Strategy,
                Meta::StrategySplit => $line['code'] === 'coupon',
            );
        } else {
            // Try to get a vat rate.
            $vatRateLookupMetaData = $this->getVatRateLookupByTotalLineType($line['code']);
            // The completor will add the looked up vat rate based on looked up
            // or just the highest appearing vat rate, or wil pass it to the
            // strategy phase.
            $result += array(
                Tag::VatRate => null,
                Meta::VatRateSource => Creator::VatRateSource_Completor,
                Meta::StrategySplit => false,
            ) + $vatRateLookupMetaData;
        }

        return $result;
    }
protected function getTotalLine ( array $ line , $ exVat ) { $ result = array ( Tag :: Product => $ line [ 'title' ] , Tag :: Quantity => 1 , ) ; if ( $ exVat ) { $ result [ Tag :: UnitPrice ] = $ line [ 'value' ] ; } else { $ result [ Meta :: UnitPriceInc ] = $ line [ 'value' ] ; } if ( $ line [ 'code' ] === 'voucher' ) { // A voucher is to be seen as a partial payment, thus no tax. $ result += array ( Tag :: VatRate => - 1 , Meta :: VatRateSource => Creator :: VatRateSource_Exact0 , ) ; } elseif ( $ line [ 'code' ] === 'coupon' ) { // Coupons may have to be split over various taxes. $ result += array ( Tag :: VatRate => null , Meta :: VatRateSource => Creator :: VatRateSource_Strategy , Meta :: StrategySplit => $ line [ 'code' ] === 'coupon' , ) ; } else { // Try to get a vat rate. $ vatRateLookupMetaData = $ this -> getVatRateLookupByTotalLineType ( $ line [ 'code' ] ) ; // The completor will add the looked up vat rate based on looked up // or just the highest appearing vat rate, or wil pass it to the // strategy phase. $ result += array ( Tag :: VatRate => null , Meta :: VatRateSource => Creator :: VatRateSource_Completor , Meta :: StrategySplit => false , ) + $ vatRateLookupMetaData ; } return $ result ; }
Returns a line based on a "order total line".

@param array $line
The total line.
@param bool $exVat
Whether the value in this line is ex (true) or inc (false) vat.

@return array
An Acumulus invoice line.

@throws \Exception
Returns a line based on a order total line .