+
+ function split_line_values()
+ {
+ // split nominal line values
+ foreach($this->grn_items as $line)
+ $line->split_item_value($this);
+
+ // Exact tax values are currently entered as tax totals, so we need to move the differences back on line level.
+ // currently first item with given tax type will be fixed with the calculated difference
+ // FIXME: change UI moving tax edit to line level in line edit mode, then this workaround will be obsolete.
+ foreach($this->get_taxes() as $tax_id => $tax)
+ {
+ if ($tax['Value'] != 0 && isset($tax['Override']) && ($tax['Value'] != $tax['Override']))
+ {
+ foreach($this->grn_items as $id => $line)
+ if ($line->gl_amounts[0]['tax_type_id'] == $tax_id) // assumed single tax rate on item, so always gl_mount[0] is valid
+ {
+ $diff = $tax['Override'] - $tax['Value'];
+ $this->grn_items[$id]->gl_amounts[0]['Value'] += $diff;
+ if ($this->vat_category() != VC_NONDEDUCT)
+ $this->grn_items[$id]->gl_amounts[0]['Deductible'] += $diff;
+ else
+ $this->grn_items[$id]->gl_amounts['Cost'] += $diff;
+ // when supplier uses net prices the price is exact, so don't fix net, still record exact VAT.
+ if ($this->tax_included) {
+ $this->grn_items[$id]->gl_amounts['Net'] -= $diff;
+ $this->grn_items[$id]->gl_amounts['Cost'] -= $diff;
+ }
+ break;
+ }
+ }
+ }
+ }