src/Invoice/Source.php
protected function completeTotals(array $totals)
    {
        if (!isset($totals[Meta::InvoiceAmount])) {
            $totals[Meta::InvoiceAmount] = $totals[Meta::InvoiceAmountInc] - $totals[Meta::InvoiceVatAmount];
            $totals[Meta::InvoiceCalculated ] = Meta::InvoiceAmount;
        }
        if (!isset($totals[Meta::InvoiceAmountInc])) {
            $totals[Meta::InvoiceAmountInc] = $totals[Meta::InvoiceAmount] + $totals[Meta::InvoiceVatAmount];
            $totals[Meta::InvoiceCalculated ] = Meta::InvoiceAmountInc;
        }
        if (!isset($totals[Meta::InvoiceVatAmount])) {
            $totals[Meta::InvoiceVatAmount] = $totals[Meta::InvoiceAmountInc] - $totals[Meta::InvoiceAmount];
            $totals[Meta::InvoiceCalculated ] = Meta::InvoiceVatAmount;
        }
        return $totals;
    }
protected function completeTotals(array $totals)
    {
        if (!isset($totals[Meta::InvoiceAmount])) {
            $totals[Meta::InvoiceAmount] = $totals[Meta::InvoiceAmountInc] - $totals[Meta::InvoiceVatAmount];
            $totals[Meta::InvoiceCalculated ] = Meta::InvoiceAmount;
        }
        if (!isset($totals[Meta::InvoiceAmountInc])) {
            $totals[Meta::InvoiceAmountInc] = $totals[Meta::InvoiceAmount] + $totals[Meta::InvoiceVatAmount];
            $totals[Meta::InvoiceCalculated ] = Meta::InvoiceAmountInc;
        }
        if (!isset($totals[Meta::InvoiceVatAmount])) {
            $totals[Meta::InvoiceVatAmount] = $totals[Meta::InvoiceAmountInc] - $totals[Meta::InvoiceAmount];
            $totals[Meta::InvoiceCalculated ] = Meta::InvoiceVatAmount;
        }
        return $totals;
    }
protected function completeTotals ( array $ totals ) { if ( ! isset ( $ totals [ Meta :: InvoiceAmount ] ) ) { $ totals [ Meta :: InvoiceAmount ] = $ totals [ Meta :: InvoiceAmountInc ] - $ totals [ Meta :: InvoiceVatAmount ] ; $ totals [ Meta :: InvoiceCalculated ] = Meta :: InvoiceAmount ; } if ( ! isset ( $ totals [ Meta :: InvoiceAmountInc ] ) ) { $ totals [ Meta :: InvoiceAmountInc ] = $ totals [ Meta :: InvoiceAmount ] + $ totals [ Meta :: InvoiceVatAmount ] ; $ totals [ Meta :: InvoiceCalculated ] = Meta :: InvoiceAmountInc ; } if ( ! isset ( $ totals [ Meta :: InvoiceVatAmount ] ) ) { $ totals [ Meta :: InvoiceVatAmount ] = $ totals [ Meta :: InvoiceAmountInc ] - $ totals [ Meta :: InvoiceAmount ] ; $ totals [ Meta :: InvoiceCalculated ] = Meta :: InvoiceVatAmount ; } return $ totals ; }
Completes the set of invoice totals as set by getInvoiceTotals.

Most shops only provide 2 out of these 3 in their data, so we calculate
the 3rd.

Do not override this method, just implement getAvailableTotals().

@param array $totals
The invoice totals to complete with missing total fields.

@return array
The invoice totals with all invoice total fields.
Completes the set of invoice totals as set by getInvoiceTotals .