I Think there is an error for invoice discounts. They are only calculated if an invoice tax is set. In Germany we don’t use invoice taxes.
Problem might be here:
public function calculate_invoice_taxes()
…
if ($invoice_tax_rates) {
…
$invoice_total = $this->calculate_discount($invoice_id, $invoice_total);
…