+
+ //
+ // Returns taxes for PO/GRN.
+ // $receival=true in purchase receive context.
+ //
+ function get_taxes($shipping_cost=null, $receival=false)
+ {
+ $items = array();
+ $prices = array();
+ if($shipping_cost==null)
+ $shipping_cost = 0;//$this->freight_cost;
+
+ foreach ($this->line_items as $ln_itm) {
+ $items[] = $ln_itm->stock_id;
+ $prices[] = round($ln_itm->price * ($receival ? $ln_itm->receive_qty : $ln_itm->quantity), user_price_dec());
+ }
+ $taxes = get_tax_for_items($items, $prices, $shipping_cost,
+ $this->tax_group_id, $this->tax_included, $this->tax_group_array);
+
+ // Adjustment for swiss franken, we always have 5 rappen = 1/20 franken
+ if ($this->curr_code == 'CHF') {
+ $val = $taxes['1']['Value'];
+ $val1 = (floatval((intval(round(($val*20),0)))/20));
+ $taxes['1']['Value'] = $val1;
+ }
+ return $taxes;
+ }
+
+ /*
+ Returns order value including all taxes
+ */
+ function get_trans_total() {
+
+ $total = 0;
+ $dec = user_price_dec();
+
+ foreach ($this->line_items as $ln_itm) {
+ $items[] = $ln_itm->stock_id;
+ $value = round($ln_itm->quantity * $ln_itm->price, $dec);
+ $prices[] =$value;
+ $total += $value;
+ }
+
+ if (!$this->tax_included ) {
+ $taxes = get_tax_for_items($items, $prices, 0, $this->tax_group_id,
+ $this->tax_included, $this->tax_group_array);
+
+ foreach($taxes as $tax)
+ $total += round($tax['Value'], $dec);
+ }
+ return $total;
+ }
+