Update: read update below.
I had the exact same problem and fixed it just now for at least one invoice (it’s late and I don’t have another multi-item invoice that I can test it with, and I want to post my “fix”) by changing line 100 of
bamboo_system_files/application/models/invoices_model.php
in the function getSingleInvoice($invoice_id)
which was reading:
$this->db->select(’(SELECT SUM(’.$this->db->dbprefix(‘invoice_items’).’.amount * ‘.$this->db->dbprefix(‘invoice_items’).’.quantity + ROUND((’.$this->db->dbprefix(‘invoice_items’).’.amount * ‘.$this->db->dbprefix(‘invoice_items’).’.quantity * (’.$this->db->dbprefix(‘invoices’).’.tax1_rate/100 + ‘.$this->db->dbprefix(‘invoices’).’.tax2_rate/100) * ‘.$this->db->dbprefix(‘invoice_items’).’.taxable), 2)) FROM ‘.$this->db->dbprefix(‘invoice_items’).’ WHERE ‘.$this->db->dbprefix(‘invoice_items’).’.invoice_id=’ . $invoice_id . ‘) AS total_with_tax’, FALSE);
to
$this->db->select(’(SELECT SUM(’.$this->db->dbprefix(‘invoice_items’).’.amount * ‘.$this->db->dbprefix(‘invoice_items’).’.quantity + ROUND((’.$this->db->dbprefix(‘invoice_items’).’.amount * ‘.$this->db->dbprefix(‘invoice_items’).’.quantity * (’.$this->db->dbprefix(‘invoices’).’.tax1_rate/100 + ‘.$this->db->dbprefix(‘invoices’).’.tax2_rate/100) * ‘.$this->db->dbprefix(‘invoice_items’).’.taxable), 5)) FROM ‘.$this->db->dbprefix(‘invoice_items’).’ WHERE ‘.$this->db->dbprefix(‘invoice_items’).’.invoice_id=’ . $invoice_id . ‘) AS total_with_tax’, FALSE);
Notice the change of the ROUND digits from 2 to 5, just before the FROM statement.
I tested the rounding by setting the numberformat also to 5 in (around) line 311 of
bamboo_system_files/application/controllers/invoices.php
$data[‘total_with_tax’] = $this->lang->line(‘invoice_total’).’: ‘.$this->settings_model->get_setting(‘currency_symbol’).’ ‘.number_format($data[‘row’]->total_with_tax, 2, $this->config->item(‘currency_decimal’), ‘’).”
\n”;;
You can change that but change it back to 2 for your official invoices.
Update: Reading Zoltarc’s post of Oct 28, 2008 03:57am in which he said “I have removed the ROUND() functions from _getInvoices() and getSingleInvoice() and the problem seems to have disappeared.”, I have removed them too (this is in bambooinvoice 0.8.9 so apparently it was not updated) and my rounding problem is gone too.
Hopefully this works for you too and hopefully it’s not just for this particular invoice of mine.
Gerben