--- erp_item/erp_item.module-org	2011-03-03 12:33:11.000000000 +0200
+++ erp_item/erp_item.module	2011-04-04 15:51:23.000000000 +0200
@@ -277,12 +277,23 @@
             '#maxlength' => 128,
             '#default_value' => $node->supp_code);
 
-    $form['supplier_details']['buy_price'] =
-      array('#type' => 'textfield',
-            '#title' => t('Buy Price(ex)'),
-            '#size' => 10,
-            '#maxlength' => 10,
-            '#default_value' => erp_currency($node->buy_price));
+    if (module_exists('erp_tax')) {
+        $form['supplier_details']['buy_price'] =
+	  array('#type' => 'textfield',
+		'#title' => t('Buy Price(ex)'),
+		'#field_prefix' => erp_symbol(),
+		'#size' => 10,
+		'#maxlength' => 10,
+		'#default_value' => erp_currency($node->buy_price));
+    } else {
+	$form['supplier_details']['buy_price'] =
+          array('#type' => 'textfield',
+		'#title' => t('Buy Price'),
+		'#field_prefix' => erp_symbol(),
+		'#size' => 10,
+		'#maxlength' => 10,
+		'#default_value' => erp_currency($node->buy_price));
+    }
   }
 
   $form['sale_details'] =
@@ -293,22 +304,32 @@
           '#tree' => FALSE,
           '#suffix' => '</div>');
 
-  $rrp_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $node->rrp_price)));
+  if (module_exists('erp_tax')) {
+    $rrp_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $node->rrp_price)));
+  } else {
+    $rrp_price = erp_currency($node->rrp_price);
+  }
 
   $form['sale_details']['rrp_price'] =
     array('#type' => 'textfield',
           '#title' => t('RRP Price'),
           '#size' => 10,
           '#maxlength' => 10,
+          '#field_prefix' => erp_symbol(),
           '#default_value' => $rrp_price);
 
-  $sell_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $node->sell_price)));
+  if (module_exists('erp_tax')) {
+    $sell_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $node->sell_price)));
+  } else {
+    $sell_price = erp_currency($node->sell_price);
+  }
 
   $form['sale_details']['sell_price'] =
     array('#type' => 'textfield',
           '#title' => t('Sell Price'),
           '#size' => 10,
           '#maxlength' => 10,
+          '#field_prefix' => erp_symbol(),
           '#default_value' => $sell_price);
 
   $form['sale_details']['active'] =
@@ -377,12 +398,14 @@
     }
   }
 
-  if (!$node->tax_ex) {
-    // Convert prices back to ex tax
-    $node->buy_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->buy_price)), 2);
-    $node->rrp_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->rrp_price)), 2);
-    $node->sell_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->sell_price)), 2);
-  }
+    if (module_exists('erp_tax')) {
+      if (!$node->tax_ex) {
+	// Convert prices back to ex tax
+	$node->buy_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->buy_price)), 2);
+	$node->rrp_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->rrp_price)), 2);
+	$node->sell_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->sell_price)), 2);
+      }
+    }
 
   drupal_write_record('erp_item', $node);
 }
@@ -405,12 +428,14 @@
     }
   }
 
-  if (!$node->tax_ex) {
-    // Convert prices back to ex tax
-    $node->buy_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->buy_price)), 2);
-    $node->rrp_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->rrp_price)), 2);
-    $node->sell_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->sell_price)), 2);
-  }
+    if (module_exists('erp_tax')) {
+	if (!$node->tax_ex) {
+	    // Convert prices back to ex tax
+	    $node->buy_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->buy_price)), 2);
+	    $node->rrp_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->rrp_price)), 2);
+	    $node->sell_price = round(array_pop(module_invoke_all('erp_tax_ex_amount', $node->sell_price)), 2);
+	}
+    }
 
   drupal_write_record('erp_item', $node, array('nid'));
 }
@@ -481,13 +506,22 @@
     }
   }
 
-  $rrp_price = array_pop(module_invoke_all('erp_tax_inc_amount', $node->rrp_price));
+  if (module_exists('erp_tax')) {
+	$rrp_price = array_pop(module_invoke_all('erp_tax_inc_amount', $node->rrp_price));
+  } else {
+	//$rrp_price = erp_currency($node->rrp_price);
+	$rrp_price = $node->rrp_price;
+  }
 
   $output .= '<div class="rrp-price">';
   $output .= t('RRP Price: ') . erp_symbol() . erp_currency($rrp_price);
   $output .= '</div>';
 
-  $sell_price = array_pop(module_invoke_all('erp_tax_inc_amount', $node->sell_price));
+  if (module_exists('erp_tax')) {
+    $sell_price = array_pop(module_invoke_all('erp_tax_inc_amount', $node->sell_price));
+  } else {
+    $sell_price = $node->sell_price;
+  }
 
   $output .= '<div class="our-price">';
   $output .= t('Sell Price: ') . erp_symbol() . erp_currency($sell_price);
@@ -707,12 +747,18 @@
     		$amount = $row['sell_price'];
     	}
 
-      // apply tax
-      $amount = erp_tax_erp_tax_inc_amount($amount);
+      if (module_exists('erp_tax')) {
+        // apply tax
+        $amount = erp_tax_erp_tax_inc_amount($amount);
+      }
       return $amount;
     }
     else {
-      return erp_tax_erp_tax_inc_amount($row[$type .'_price']);
+      if (module_exists('erp_tax')) {
+        return erp_tax_erp_tax_inc_amount($row[$type .'_price']);
+      } else {
+        return $row[$type .'_price'];
+      }
     }
   }
   else {
@@ -877,9 +923,11 @@
     if ($item->serial || $item->store_nid) {
       $item->code .= ' - #'. $store->title .'@'. $item->serial .'#';
     }
-    $item->rrp_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $item->rrp_price)));
-    $item->sell_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $item->sell_price)));
-    $item->buy_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $item->buy_price)));
+    if (module_exists('erp_tax')) {
+	$item->rrp_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $item->rrp_price)));
+	$item->sell_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $item->sell_price)));
+	$item->buy_price = erp_currency(array_pop(module_invoke_all('erp_tax_inc_amount', $item->buy_price)));
+    }
     if ($type == 'buy') {
       $code = check_plain($item->code) .' - '. check_plain($item->title) .' - '. check_plain($item->buy_price);
     }
@@ -1001,8 +1049,14 @@
   }
 
   $row = array_fill(0, count($header) - 2, array());
-  $row[] = array('data' => 'GST total: ', 'class' => 'tax-total-text');
-  $row[] = array('data' => erp_currency(array_pop(module_invoke_all('erp_tax_amount', $total_price))));
+
+  if (module_exists('erp_tax')) {
+      $row[] = array('data' => 'GST total: ', 'class' => 'tax-total-text');
+      $row[] = array('data' => erp_currency(array_pop(module_invoke_all('erp_tax_amount', $total_price))));
+//  } else {
+//      $row[] = array('data' => erp_currency($total_price));
+  }
+
   $rows[] = $row;
 
   $row = array_fill(0, count($header) - 2, array());
