src/Invoice/CompletorStrategyBase.php
protected function initAmounts()
    {
        $invoicePart = &$this->invoice[Tag::Customer][Tag::Invoice];
        $this->vatAmount = isset($invoicePart[Meta::InvoiceVatAmount]) ? $invoicePart[Meta::InvoiceVatAmount] : $invoicePart[Meta::InvoiceAmountInc] - $invoicePart[Meta::InvoiceAmount];
        $this->invoiceAmount = isset($invoicePart[Meta::InvoiceAmount]) ? $invoicePart[Meta::InvoiceAmount] : $invoicePart[Meta::InvoiceAmountInc] - $invoicePart[Meta::InvoiceVatAmount];

        // The vat amount to divide over the non completed lines is the total vat
        // amount of the invoice minus all known vat amounts per line.
        $this->vat2Divide = (float) $this->vatAmount;
        foreach ($invoicePart[Tag::Line] as $line) {
            if ($line[Meta::VatRateSource] !== Creator::VatRateSource_Strategy) {
                // Deduct the vat amount from this line: if set, deduct it directly,
                // otherwise calculate the vat amount using the vat rate and unit price.
                if (isset($line[Meta::VatAmount])) {
                    $this->vat2Divide -= $line[Meta::VatAmount] * $line[Tag::Quantity];
                } else {
                    $this->vat2Divide -= ($line[Tag::VatRate] / 100.0) * $line[Tag::UnitPrice] * $line[Tag::Quantity];
                }
            }
        }
    }
protected function initAmounts()
    {
        $invoicePart = &$this->invoice[Tag::Customer][Tag::Invoice];
        $this->vatAmount = isset($invoicePart[Meta::InvoiceVatAmount]) ? $invoicePart[Meta::InvoiceVatAmount] : $invoicePart[Meta::InvoiceAmountInc] - $invoicePart[Meta::InvoiceAmount];
        $this->invoiceAmount = isset($invoicePart[Meta::InvoiceAmount]) ? $invoicePart[Meta::InvoiceAmount] : $invoicePart[Meta::InvoiceAmountInc] - $invoicePart[Meta::InvoiceVatAmount];

        // The vat amount to divide over the non completed lines is the total vat
        // amount of the invoice minus all known vat amounts per line.
        $this->vat2Divide = (float) $this->vatAmount;
        foreach ($invoicePart[Tag::Line] as $line) {
            if ($line[Meta::VatRateSource] !== Creator::VatRateSource_Strategy) {
                // Deduct the vat amount from this line: if set, deduct it directly,
                // otherwise calculate the vat amount using the vat rate and unit price.
                if (isset($line[Meta::VatAmount])) {
                    $this->vat2Divide -= $line[Meta::VatAmount] * $line[Tag::Quantity];
                } else {
                    $this->vat2Divide -= ($line[Tag::VatRate] / 100.0) * $line[Tag::UnitPrice] * $line[Tag::Quantity];
                }
            }
        }
    }
protected function initAmounts ( ) { $ invoicePart = & $ this -> invoice [ Tag :: Customer ] [ Tag :: Invoice ] ; $ this -> vatAmount = isset ( $ invoicePart [ Meta :: InvoiceVatAmount ] ) ? $ invoicePart [ Meta :: InvoiceVatAmount ] : $ invoicePart [ Meta :: InvoiceAmountInc ] - $ invoicePart [ Meta :: InvoiceAmount ] ; $ this -> invoiceAmount = isset ( $ invoicePart [ Meta :: InvoiceAmount ] ) ? $ invoicePart [ Meta :: InvoiceAmount ] : $ invoicePart [ Meta :: InvoiceAmountInc ] - $ invoicePart [ Meta :: InvoiceVatAmount ] ; // The vat amount to divide over the non completed lines is the total vat // amount of the invoice minus all known vat amounts per line. $ this -> vat2Divide = ( float ) $ this -> vatAmount ; foreach ( $ invoicePart [ Tag :: Line ] as $ line ) { if ( $ line [ Meta :: VatRateSource ] !== Creator :: VatRateSource_Strategy ) { // Deduct the vat amount from this line: if set, deduct it directly, // otherwise calculate the vat amount using the vat rate and unit price. if ( isset ( $ line [ Meta :: VatAmount ] ) ) { $ this -> vat2Divide -= $ line [ Meta :: VatAmount ] * $ line [ Tag :: Quantity ] ; } else { $ this -> vat2Divide -= ( $ line [ Tag :: VatRate ] / 100.0 ) * $ line [ Tag :: UnitPrice ] * $ line [ Tag :: Quantity ] ; } } } }
Initializes the amount properties.

to be able to calculate the amounts, at least 2 of the 3 meta amounts
meta-invoice-vatamount, meta-invoice-amountinc, or meta-invoice-amount must
be known.
Initializes the amount properties .