diff -uNr org/erp/erp_cash_sale/erp_cash_sale.info erp/erp_cash_sale/erp_cash_sale.info
--- org/erp/erp_cash_sale/erp_cash_sale.info	2011-02-25 09:33:21.000000000 +0200
+++ erp/erp_cash_sale/erp_cash_sale.info	2011-11-02 18:20:19.000000000 +0200
@@ -7,7 +7,7 @@
 core = 6.x
 
 ; Information added by drupal.org packaging script on 2011-02-25
-version = "6.x-1.x-dev"
+version = "6.x-1.2.x-dev"
 core = "6.x"
 project = "erp"
 datestamp = "1298619201"
diff -uNr org/erp/erp_cash_sale/erp_cash_sale.install erp/erp_cash_sale/erp_cash_sale.install
--- org/erp/erp_cash_sale/erp_cash_sale.install	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp_cash_sale/erp_cash_sale.install	2011-11-02 18:20:19.000000000 +0200
@@ -5,7 +5,7 @@
 
   // The 6001 updates only need to be done for v4/5 installs,
   // so if its a new install, mark it as done.
-  db_query("UPDATE {system} SET schema_version = 6002 WHERE name = 'erp_cash_sale'");
+  db_query("UPDATE {system} SET schema_version = 6003 WHERE name = 'erp_cash_sale'");
 }
 
 function erp_cash_sale_schema() {
@@ -17,6 +17,7 @@
       'customer_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
       'payment_type' => array('type' => 'varchar', 'length' => '30', 'not null' => FALSE),
       'payment_amount' => array('type' => 'float', 'not null' => FALSE, 'default' => 0, 'disp-width' => '20'),
+      'transaction_discount' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '20'),
       'total' => array('type' => 'float', 'not null' => FALSE, 'default' => 0, 'disp-width' => '20')),
     'primary key' => array('nid'),
     'indexes' => array(
@@ -31,6 +32,7 @@
       'completed_date' => array('type' => 'varchar', 'length' => '10', 'not null' => TRUE, 'default' => '0.00'),
       'extra' => array('type' => 'text', 'size' => 'medium'),
       'price' => array('type' => 'float', 'not null' => FALSE, 'default' => 0, 'disp-width' => '20'),
+      'line_discount' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '5'),
       'qty' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
       'serial' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE)),
     'primary key' => array('nid', 'line'),
@@ -77,3 +79,12 @@
 
   return $ret;
 }
+
+function erp_cash_sale_update_6003() {
+  $ret = array();
+
+  db_add_field($ret, 'erp_cash_sale', 'transaction_discount', array('type' => 'float', 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'erp_cash_sale_data', 'line_discount', array('type' => 'float', 'not null' => TRUE, 'default' => 0));
+
+  return $ret;
+}
diff -uNr org/erp/erp_cash_sale/erp_cash_sale.module erp/erp_cash_sale/erp_cash_sale.module
--- org/erp/erp_cash_sale/erp_cash_sale.module	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp_cash_sale/erp_cash_sale.module	2011-11-02 18:20:19.000000000 +0200
@@ -210,6 +210,20 @@
           '#title' => t('Record serial numbers with invoice & cash sale items? (common settting between both modules)'),
           '#default_value' => variable_get('erp_invoice_serial', FALSE));
 
+  $form['erp_invoice_line_discount'] =
+    array('#type' => 'checkbox',
+          '#title' => t('Enable line item discounts with quotes, invoices & cash sale items? (common settting between all three modules)'),
+          '#default_value' => variable_get('erp_invoice_line_discount', FALSE),
+          '#description' => t('ERP has the ability to give discounts per line item.')
+    );
+
+  $form['erp_invoice_transaction_discount'] =
+    array('#type' => 'checkbox',
+          '#title' => t('Enable discounts per transaction with quotes, invoices & cash sale items? (common settting between all three modules)'),
+          '#default_value' => variable_get('erp_invoice_transaction_discount', FALSE),
+          '#description' => t('ERP has the ability to give discounts per transaction.')
+    );
+
   $form['erp_cash_sale_default_count'] =
     array('#type' => 'textfield',
           '#title' => t('Default count for new cash sale lines'),
@@ -301,6 +315,16 @@
     array('#type' => 'hidden',
           '#default_value' => $node->customer_nid);
 
+  if (variable_get('erp_invoice_transaction_discount', FALSE)) {
+    $form['cash_sale_details']['transaction_discount'] =
+      array('#prefix' => '<div class="transaction_discount">',
+            '#type' => 'textfield',
+            '#title' => variable_get('erp_invoice_transaction_discount_label', 'Transaction Discount'),
+            '#default_value' => erp_currency($node->transaction_discount),
+            '#size' => 20,
+            '#suffix' => '</div>');
+  }
+
   $form['entries'] =
     array('#type' => 'fieldset',
           '#title' => t('Current Cash Sale Items'),
@@ -334,12 +358,13 @@
     $form['entries']['item_desc'][$i] =
       array('#type' => 'textfield',
             '#size' => 20,
-            '#maxlength' => 256,
+            '#maxlength' => 255,
             '#autocomplete_path' => 'erp/item/autocomplete/sell',
             '#default_value' => $node->entries['item_desc'][$i],
             '#prefix' => '<div class="item-desc">',
             '#suffix' => '</div>');
 
+/*
     $form['entries']['extra'][$i] =
       array('#type' => 'textfield',
             '#size' => 40,
@@ -347,6 +372,14 @@
             '#default_value' => $node->entries['extra'][$i],
             '#prefix' => '<div class="extra">',
             '#suffix' => '</div>');
+*/
+    $form['entries']['extra'][$i] =
+      array('#type' => 'textarea',
+            '#size' => 40,
+            '#rows' => 2,
+            '#default_value' => $node->entries['extra'][$i],
+            '#prefix' => '<div class="extra">',
+            '#suffix' => '</div>');
 
     if (variable_get('erp_invoice_serial', FALSE)) {
       if (!is_array($node->entries['serial'][$i])) {
@@ -362,6 +395,16 @@
               '#suffix' => '</div>');
     }
 
+    if (variable_get('erp_invoice_line_discount', FALSE)) {
+      $form['entries']['line_discount'][$i] =
+        array('#type' => 'textfield',
+              '#size' => 5,
+              '#maxlength' => 5,
+              '#default_value' => $node->entries['line_discount'][$i],
+              '#prefix' => '<div class="line_discount">',
+              '#suffix' => '</div>');
+    }
+
     $form['entries']['price'][$i] =
       array('#type' => 'textfield',
             '#size' => 12,
@@ -370,6 +413,17 @@
             '#prefix' => '<div class="price">',
             '#suffix' => '</div>');
 
+    $form['entries']['line_total'][$i] =
+      array('#type' => 'textfield',
+            '#size' => 12,
+            '#maxlength' => 12,
+            //'#default_value' => erp_currency($node->entries['price'][$i] * $node->entries['qty'][$i]),
+            //'#default_value' => erp_currency(($node->entries['price'][$i] * $node->entries['qty'][$i]) / (($node->entries['line_discount'][$i]/100)+1)),
+            '#default_value' => erp_currency((($node->entries['price'][$i] - (($node->entries['line_discount'][$i]/100) * $node->entries['price'][$i])) * $node->entries['qty'][$i])),
+            '#disabled' => 'TRUE',
+            '#prefix' => '<div class="line_total">',
+            '#suffix' => '</div>');
+
     // Remove button.
     $form['entries']['delete'][$i] = array(
       '#type' => 'submit',
@@ -385,9 +439,12 @@
       ),
     );
 
-    $total_price += $node->entries['price'][$i] * $node->entries['qty'][$i];
+    //$total_price += $node->entries['price'][$i] * $node->entries['qty'][$i];
+    $total_price += ((($node->entries['price'][$i] - (($node->entries['line_discount'][$i]/100) * $node->entries['price'][$i])) * $node->entries['qty'][$i]));
   }
 
+  $total_price += $node->transaction_discount;
+
   $form['entries']['total'] =
     array('#type' => 'textfield',
           '#prefix' => '<div class="total">',
@@ -395,6 +452,7 @@
           '#size' => 12,
           '#maxlength' => 12,
           '#value' => erp_currency($total_price),
+          '#disabled' => 'TRUE',
           '#suffix' => '</div>');
 
   $form['entries']['newline'] =
@@ -423,6 +481,7 @@
           '#default_value' => variable_get('erp_cash_sale_default_item', ''),
           '#suffix' => '</div>');
 
+/*
   $form['entries']['newline']['extra'] =
     array('#type' => 'textfield',
           '#prefix' => '<div class="extra">',
@@ -430,6 +489,14 @@
           '#maxlength' => 4096,
           '#default_value' => '',
           '#suffix' => '</div>');
+*/
+  $form['entries']['newline']['extra'] =
+    array('#type' => 'textarea',
+          '#prefix' => '<div class="extra">',
+          '#size' => 40,
+          '#rows' => 2,
+          '#default_value' => '',
+          '#suffix' => '</div>');
 
   if (variable_get('erp_invoice_serial', FALSE)) {
     $form['entries']['newline']['serial'] =
@@ -441,6 +508,16 @@
             '#suffix' => '</div>');
   }
 
+  if (variable_get('erp_invoice_line_discount', FALSE)) {
+    $form['entries']['newline']['line_discount'] =
+      array('#type' => 'textfield',
+            '#prefix' => '<div class="line_discount">',
+            '#size' => 5,
+            '#maxlength' => 5,
+            '#default_value' => '0',
+            '#suffix' => '</div>');
+  }
+
   $form['entries']['newline']['price'] =
     array('#type' => 'textfield',
           '#prefix' => '<div class="price">',
@@ -449,6 +526,29 @@
           '#default_value' => erp_item_price_from_string(variable_get('erp_cash_sale_default_item', '')),
           '#suffix' => '</div>');
 
+  $form['entries']['newline']['line_total'] =
+    array('#type' => 'textfield',
+          '#prefix' => '<div class="line_total">',
+          '#size' => 12,
+          '#maxlength' => 12,
+          '#default_value' => '',
+          '#disabled' => 'TRUE',
+          '#suffix' => '</div>');
+
+  $form['entries']['newline']['addlineP'] =
+    array('#type' => 'submit',
+          '#prefix' => '<div class="addlineP">',
+          '#name' => 'addlineP',
+          '#value' => t('+'),
+          '#submit' => array('erp_add_newline_submit'),
+          '#ahah' => array(
+            'path' => 'erp/linejs/0',
+            'wrapper' => 'entries',
+            'method' => 'replace',
+            'effect' => 'none'
+          ),
+          '#suffix' => '</div>');
+
   $form['entries']['newline']['item'] =
     array('#type' => 'hidden',
           '#default_value' => '');
@@ -457,7 +557,7 @@
     array('#type' => 'submit',
           '#prefix' => '<div class="addline">',
           '#name' => 'addline',
-          '#value' => t('Add line/Recalc'),
+          '#value' => t('Add line/Recalc [+]'),
           '#submit' => array('erp_add_newline_submit'),
           '#ahah' => array(
             'path' => 'erp/linejs/0',
@@ -467,6 +567,15 @@
           ),
           '#suffix' => '</div>');
 
+  $form['entries']['newline']['total'] =
+    array('#type' => 'textfield',
+          '#prefix' => '<div class="total">',
+          '#size' => 12,
+          '#maxlength' => 12,
+          '#disabled' => 'TRUE',
+          '#default_value' => erp_currency($total_price),
+          '#suffix' => '</div>');
+
   $form['payment_amount'] =
     array('#type' => 'textfield',
           '#title' => 'Payment Amount',
@@ -480,6 +589,20 @@
           '#options' => erp_payment_type_list(),
           '#default_value' => $node->payment_type);
 
+  $form['extra_notes'] =
+    array('#type' => 'fieldset',
+          '#collapsible' => TRUE,
+          '#collapsed' => $node->extra_notes ? FALSE : TRUE,
+          '#title' => 'Extra Notes');
+
+  $form['extra_notes']['extra_notes'] =
+    array('#type' => 'textarea',
+          '#rows' => 20,
+          '#title' => 'Write your extra notes here',
+          '#default_value' => $node->extra_notes);
+
+  $form['extra_notes']['format'] = filter_form(FILTER_FORMAT_DEFAULT, NULL, array('extra_notes_format'));
+
   $form['#validate'][] = 'erp_cash_sale_custom_validate';
 
   $form['#action'] = erp_fix_ahah_action($node);
@@ -534,6 +657,7 @@
           'completed_date' => date_convert($node->entries['completed_date'][$i], DATE_DATETIME, DATE_UNIX),
           'extra' => $node->entries['extra'][$i],
           'qty' => $node->entries['qty'][$i],
+          'line_discount' => $node->entries['line_discount'][$i],
           'price' => $node->entries['price'][$i],
           'serial' => $node->entries['serial'][$i],
           'sell_date' => time(),
@@ -644,6 +768,7 @@
     $cash_sale->entries['item_desc'][] = erp_item_desc_build($item);
     $cash_sale->entries['completed_date'][] = $cash_sale_data['completed_date'];
     $cash_sale->entries['extra'][] = $cash_sale_data['extra'];
+    $cash_sale->entries['line_discount'][] = $cash_sale_data['line_discount'];
     $cash_sale->entries['price'][] = $cash_sale_data['price'];
     $cash_sale->entries['qty'][] = $cash_sale_data['qty'];
     $cash_sale->entries['serial'][] = $cash_sale_data['serial'];
diff -uNr org/erp/erp.info erp/erp.info
--- org/erp/erp.info	2011-02-25 09:33:21.000000000 +0200
+++ erp/erp.info	2011-11-02 18:20:19.000000000 +0200
@@ -4,7 +4,7 @@
 core = 6.x
 
 ; Information added by drupal.org packaging script on 2011-02-25
-version = "6.x-1.x-dev"
+version = "6.x-1.2.x-dev"
 core = "6.x"
 project = "erp"
 datestamp = "1298619201"
diff -uNr org/erp/erp_invoice/erp_invoice.info erp/erp_invoice/erp_invoice.info
--- org/erp/erp_invoice/erp_invoice.info	2011-02-25 09:33:21.000000000 +0200
+++ erp/erp_invoice/erp_invoice.info	2011-11-02 18:20:19.000000000 +0200
@@ -13,7 +13,7 @@
 core = 6.x
 
 ; Information added by drupal.org packaging script on 2011-02-25
-version = "6.x-1.x-dev"
+version = "6.x-1.2.x-dev"
 core = "6.x"
 project = "erp"
 datestamp = "1298619201"
diff -uNr org/erp/erp_invoice/erp_invoice.install erp/erp_invoice/erp_invoice.install
--- org/erp/erp_invoice/erp_invoice.install	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp_invoice/erp_invoice.install	2011-11-02 18:20:19.000000000 +0200
@@ -9,7 +9,7 @@
 
   // The 6001 updates only need to be done for v4/5 installs,
   // so if its a new install, mark it as done.
-  db_query("UPDATE {system} SET schema_version = 6003 WHERE name = 'erp_invoice'");
+  db_query("UPDATE {system} SET schema_version = 6004 WHERE name = 'erp_invoice'");
 }
 
 function erp_invoice_schema() {
@@ -20,6 +20,7 @@
       'invoice_id' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '10'),
       'invoice_status' => array('type' => 'char', 'length' => '1', 'not null' => FALSE, 'default' => '0'),
       'customer_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
+      'transaction_discount' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '20'),
       'total' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '20'),
       'printed' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '1'),
       'po' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE),
@@ -38,6 +39,7 @@
       'completed_date' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '12'),
       'extra' => array('type' => 'text', 'size' => 'medium'),
       'price' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '20'),
+      'line_discount' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '5'),
       'qty' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
       'serial' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE)),
     'primary key' => array('nid', 'line'),
@@ -122,3 +124,12 @@
 
   return $ret;
 }
+
+function erp_invoice_update_6004() {
+  $ret = array();
+
+  db_add_field($ret, 'erp_invoice', 'transaction_discount', array('type' => 'float', 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'erp_invoice_data', 'line_discount', array('type' => 'float', 'not null' => TRUE, 'default' => 0));
+
+  return $ret;
+}
diff -uNr org/erp/erp_invoice/erp_invoice.module erp/erp_invoice/erp_invoice.module
--- org/erp/erp_invoice/erp_invoice.module	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp_invoice/erp_invoice.module	2011-11-02 18:20:19.000000000 +0200
@@ -264,11 +264,32 @@
 
   $form['erp_invoice_serial'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Record serial numbers with quotes, invoices & cash sale items? (common settting between both modules)'),
+    '#title' => t('Record serial numbers with invoices & cash sale items? (common settting between both modules)'),
     '#default_value' => variable_get('erp_invoice_serial', FALSE),
     '#description' => t('ERP has the ability to track goods by serial number, making warranty returns (in particular) easier to track.')
   );
 
+  $form['erp_invoice_line_discount'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable line item discounts with quotes, invoices & cash sale items? (common settting between all three modules)'),
+    '#default_value' => variable_get('erp_invoice_line_discount', FALSE),
+    '#description' => t('ERP has the ability to give discounts per line item.')
+  );
+
+  $form['erp_invoice_transaction_discount'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable discounts per transaction with quotes, invoices & cash sale items? (common settting between all three modules)'),
+    '#default_value' => variable_get('erp_invoice_transaction_discount', FALSE),
+    '#description' => t('ERP has the ability to give discounts per transaction.')
+  );
+
+  $form['erp_invoice_transaction_discount_label'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Label discounts per transaction with quotes, invoices & cash sale items? (common settting between all three modules)'),
+    '#default_value' => variable_get('erp_invoice_transaction_discount_label', 'Transaction Discount'),
+    '#description' => t('ERP has the ability to label discounts per transaction.')
+  );
+
   $form['erp_invoice_default_count'] = array(
     '#type' => 'textfield',
     '#title' => t('Default count for new invoice lines'),
@@ -415,11 +436,22 @@
           '#size' => 20,
           '#maxlength' => 40);
 
+  if (variable_get('erp_invoice_transaction_discount', FALSE)) {
+    $form['invoice_details']['transaction_discount'] =
+      array('#prefix' => '<div class="transaction_discount">',
+            '#type' => 'textfield',
+            '#title' => variable_get('erp_invoice_transaction_discount_label', 'Transaction Discount'),
+            '#default_value' => erp_currency($node->transaction_discount),
+            '#size' => 20,
+            '#suffix' => '</div>');
+  }
+
   $form['invoice_details']['printed'] =
     array('#type' => 'checkbox',
           '#title' => t('Printed'),
           '#default_value' => $node->printed);
 
+
   $form['invoice_details']['invoice_status'] =
     array('#type' => 'checkbox',
           '#title' => t('Closed'),
@@ -507,6 +539,16 @@
               '#suffix' => '</div>');
     }
 
+    if (variable_get('erp_invoice_line_discount', FALSE)) {
+      $form['entries']['line_discount'][$i] =
+        array('#type' => 'textfield',
+              '#size' => 5,
+              '#maxlength' => 5,
+              '#default_value' => $node->entries['line_discount'][$i],
+              '#prefix' => '<div class="line_discount">',
+              '#suffix' => '</div>');
+    }
+
     $form['entries']['price'][$i] =
       array('#type' => 'textfield',
             '#size' => 12,
@@ -530,9 +572,12 @@
       ),
     );
 
-    $total_price += $node->entries['price'][$i] * $node->entries['qty'][$i];
+    //$total_price += (($node->entries['price'][$i] * $node->entries['qty'][$i]) / (($node->entries['line_discount'][$i]/100)+1));
+    $total_price += ((($node->entries['price'][$i] - (($node->entries['line_discount'][$i]/100) * $node->entries['price'][$i])) * $node->entries['qty'][$i]));
   }
 
+  $total_price += $node->transaction_discount;
+
   $form['entries']['total'] =
     array('#type' => 'textfield',
           '#prefix' => '<div class="total">',
@@ -595,6 +640,16 @@
             '#suffix' => '</div>');
   }
 
+  if (variable_get('erp_invoice_line_discount', FALSE)) {
+    $form['entries']['newline']['line_discount'] =
+      array('#type' => 'textfield',
+            '#prefix' => '<div class="line_discount">',
+            '#size' => 5,
+            '#maxlength' => 5,
+            '#default_value' => '0',
+            '#suffix' => '</div>');
+  }
+
   $form['entries']['newline']['price'] =
     array('#type' => 'textfield',
           '#prefix' => '<div class="price">',
@@ -672,6 +727,7 @@
           'completed_date' => date_convert($node->entries['completed_date'][$i], DATE_DATETIME, DATE_UNIX),
           'extra' => $node->entries['extra'][$i],
           'qty' => $node->entries['qty'][$i],
+          'line_discount' => $node->entries['line_discount'][$i],
           'price' => $node->entries['price'][$i],
           'serial' => $node->entries['serial'][$i],
           'sell_date' => time(),
@@ -834,6 +890,7 @@
 
     $invoice->entries['item_desc'][] = erp_item_desc_build($item);
     $invoice->entries['completed_date'][] = $invoice_data['completed_date'];
+    $invoice->entries['line_discount'][] = $invoice_data['line_discount'];
     $invoice->entries['price'][] = $invoice_data['price'];
     $invoice->entries['qty'][] = $invoice_data['qty'];
     $invoice->entries['extra'][] = $invoice_data['extra'];
diff -uNr org/erp/erp_item/erp_item.info erp/erp_item/erp_item.info
--- org/erp/erp_item/erp_item.info	2011-02-25 09:33:21.000000000 +0200
+++ erp/erp_item/erp_item.info	2011-11-02 18:20:19.000000000 +0200
@@ -7,7 +7,7 @@
 core = 6.x
 
 ; Information added by drupal.org packaging script on 2011-02-25
-version = "6.x-1.x-dev"
+version = "6.x-1.2.x-dev"
 core = "6.x"
 project = "erp"
 datestamp = "1298619201"
diff -uNr org/erp/erp_item/erp_item.install erp/erp_item/erp_item.install
--- org/erp/erp_item/erp_item.install	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp_item/erp_item.install	2011-11-02 18:20:19.000000000 +0200
@@ -5,7 +5,7 @@
 
   // The 6001 updates only need to be done for v4/5 installs,
   // If its a new install, mark it as done.
-  db_query("UPDATE {system} set schema_version = 6001 WHERE name = 'erp_item'");
+  db_query("UPDATE {system} set schema_version = 6004 WHERE name = 'erp_item'");
 }
 
 function erp_item_schema() {
@@ -20,6 +20,7 @@
       'sell_price' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '20'),
       'barcode' => array('type' => 'varchar', 'length' => '40', 'not null' => TRUE, 'default' => ''),
       'active' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'disp-width' => '1'),
+      'discountable' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'disp-width' => '1'),
       'item_type' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE, 'default' => ''),
       'full_desc' => array('type' => 'text', 'not null' => FALSE),
       'item_locked' => array('type' => 'char', 'length' => '1', 'not null' => TRUE, 'default' => ''),
@@ -28,6 +29,7 @@
     'primary key' => array('nid'),
     'indexes' => array(
       'active' => array('active'),
+      'discountable' => array('discountable'),
       'buy_price' => array('buy_price'),
       'code' => array('code'),
       'our_price' => array('sell_price'),
@@ -88,4 +90,14 @@
   $ret[] = update_sql("ALTER TABLE {erp_item} ADD INDEX (supplier_nid) ");
 
   return $ret;
-}
\ No newline at end of file
+}
+
+function erp_item_update_6004() {
+  $ret = array();
+
+  db_add_field($ret, 'erp_item', 'discountable', array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE));
+  //$ret[] = update_sql("ALTER TABLE {erp_item} ADD INDEX (discountable) ");
+  db_add_index($ret, 'erp_item', 'discountable', array('discountable'));
+
+  return $ret;
+}
diff -uNr org/erp/erp_item/erp_item.module erp/erp_item/erp_item.module
--- org/erp/erp_item/erp_item.module	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp_item/erp_item.module	2011-11-02 18:34:22.742642470 +0200
@@ -315,6 +315,11 @@
           '#title' => t('Active'),
           '#default_value' => $node->active);
 
+  $form['sale_details']['discountable'] =
+    array('#type' => 'checkbox',
+          '#title' => t('Discountable'),
+          '#default_value' => $node->discountable);
+
   $form['sale_details']['item_locked'] =
     array('#type' => 'checkbox',
           '#title' => t('Locked from Updates'),
@@ -500,6 +505,14 @@
     $output .= t('Inactive');
   }
 
+  $output .= '<div class="discountable">';
+  if ($node->discountable) {
+    $output .= t('Discountable');
+  }
+  else {
+    $output .= t('Not Discountable');
+  }
+
   if (module_exists('erp_stock')) {
     $output .= '<div class="qty">';
     $output .= l(t('Qty on hand: !qty', array('!qty' => erp_stock_avail($node->nid))), 
@@ -948,6 +961,9 @@
   if (variable_get('erp_invoice_serial', FALSE) && ($node->type == 'erp_invoice' || $node->type == 'erp_cash_sale')) {
     $header[] = t('Serial no.');
   }
+  if (variable_get('erp_invoice_line_discount', FALSE) && ($node->type == 'erp_quote' || $node->type == 'erp_invoice' || $node->type == 'erp_cash_sale')) {
+    $header[] = t('Disc %');
+  }
   $header[] = t('Price');
   $header[] = t('Line total');
 
@@ -991,12 +1007,39 @@
       $row[] = array('data' => $node->entries['serial'][$i]);
     }
 
+    if ((variable_get('erp_invoice_line_discount', FALSE)) && ($node->type == 'erp_quote' || $node->type == 'erp_invoice' || $node->type == 'erp_cash_sale')) {
+      $row[] = array('data' => $node->entries['line_discount'][$i], 'class' => 'item-discount');
+    }
+
     $row[] = array('data' => erp_currency($node->entries['price'][$i]), 'class' => 'item-amount');
-    $row[] = array('data' => erp_currency($node->entries['price'][$i] * $node->entries['qty'][$i]), 'class' => 'item-subtotal');
+
+    //$row[] = array('data' => erp_currency($node->entries['price'][$i] * $node->entries['qty'][$i]), 'class' => 'item-subtotal');
+    //$row[] = array('data' => erp_currency(($node->entries['price'][$i] * $node->entries['qty'][$i]) / (($node->entries['line_discount'][$i]/100)+1)), 'class' => 'item-subtotal');
+    $row[] = array('data' => erp_currency((($node->entries['price'][$i] - (($node->entries['line_discount'][$i]/100) * $node->entries['price'][$i])) * $node->entries['qty'][$i])), 'class' => 'item-subtotal');
+
     $rows[] = $row;
 
     // Build a total price
-    $total_price += $node->entries['price'][$i] * $node->entries['qty'][$i];
+    if (variable_get('erp_invoice_line_discount', FALSE)) {
+      //$total_price += ($node->entries['price'][$i] * $node->entries['qty'][$i]) / (($node->entries['line_discount'][$i]/100)+1);
+      $total_price += (($node->entries['price'][$i] - (($node->entries['line_discount'][$i]/100) * $node->entries['price'][$i])) * $node->entries['qty'][$i]);
+    }
+    else {
+      $total_price += ($node->entries['price'][$i] * $node->entries['qty'][$i]);
+    }
+  }
+
+/*
+  if (variable_get('erp_invoice_line_discount', FALSE)) {
+    $total_price += $node->transaction_discount;
+  }
+*/
+
+  if (variable_get('erp_invoice_transaction_discount', FALSE)) {
+    $row = array_fill(0, count($header) - 2, array());
+    $row[] = array('data' => variable_get('erp_invoice_transaction_discount_label', 'Transaction Discount') . ': ', 'class' => 'transaction-discount-text');
+    $row[] = array('data' => erp_currency($node->transaction_discount), 'class' => 'transaction-discount-amount');
+    $rows[] = $row;
   }
 
   $row = array_fill(0, count($header) - 2, array());
@@ -1006,7 +1049,7 @@
 
   $row = array_fill(0, count($header) - 2, array());
   $row[] = array('data' => "Total: ", 'class' => 'total-text');
-  $row[] = array('data' => erp_currency($total_price), 'class' => 'total-amount');
+  $row[] = array('data' => erp_currency($total_price+$node->transaction_discount), 'class' => 'total-amount');
 
   $rows[] = $row;
   $output .= theme('table', $header, $rows, array('class' => 'item-list'));
diff -uNr org/erp/erp.module erp/erp.module
--- org/erp/erp.module	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp.module	2011-11-02 18:20:19.000000000 +0200
@@ -443,6 +443,11 @@
       $row_data[] = drupal_render($form['serial'][$key]);
     }
 
+    // Invoices etc.
+    if (isset($form['line_discount'][0])) {
+      $row_data[] = drupal_render($form['line_discount'][$key]);
+    }
+
     $row_data[] = drupal_render($form['price'][$key]);
 
     if (isset($form['delete'][0])) {
@@ -498,6 +503,9 @@
   if (isset($form['serial']['#id'])) {
     $row_data[] = drupal_render($form['serial']);
   }
+  if (isset($form['line_discount']['#id'])) {
+    $row_data[] = drupal_render($form['line_discount']);
+  }
   if (isset($form['price']['#id'])) {
     $row_data[] = drupal_render($form['price']);
   }
@@ -888,6 +896,7 @@
     $node->entries['serial'][] = $newline['serial'];
     $node->entries['completed_date'][] = $newline['completed_date'];
     $node->entries['price'][] = $newline['price'];
+    $node->entries['line_discount'][] = $newline['line_discount'];
   }
 
   $remove_delta = -1;
@@ -949,6 +958,9 @@
       }
       $new_entry['completed_date'] = $form_state['values']['entries']['newline']['completed_date'];
       $new_entry['price'] = $form_state['values']['entries']['newline']['price'];
+      if (variable_get('erp_invoice_line_discount', FALSE)) {
+        $new_entry['line_discount'] = $form_state['values']['entries']['newline']['line_discount'];
+      }
       $form_state['newline'] = $new_entry;
     }
   }
@@ -1073,6 +1085,9 @@
   if (isset($form['serial'][$item])) {
     $header[] = t('Serial');
   }
+  if (isset($form['line_discount'][$item])) {
+    $header[] = t('Disc %');
+  }
   if (isset($form['price'][$item])) {
     $header[] = t('Price');
   }
@@ -1091,9 +1106,13 @@
   $total = 0;
   if ($node->entries) {
     for ($i=0; $i < count($node->entries['qty']); $i++) {
-      $total += $node->entries['qty'][$i] * $node->entries['price'][$i];
+      //$total += ($node->entries['qty'][$i] * $node->entries['price'][$i]) / (($node->entries['line_discount'][$i]/100)+1);
+      $total += ((($node->entries['price'][$i] - (($node->entries['line_discount'][$i]/100) * $node->entries['price'][$i])) * $node->entries['qty'][$i]));
     }
   }
+
+  $total += $node->transaction_discount;
+
   return $total;
 }
 
diff -uNr org/erp/erp_quote/erp_quote.install erp/erp_quote/erp_quote.install
--- org/erp/erp_quote/erp_quote.install	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp_quote/erp_quote.install	2011-11-02 18:20:19.000000000 +0200
@@ -5,7 +5,7 @@
 
   // The 6001 updates only need to be done for v4/5 installs,
   // so if its a new install, mark it as done.
-  db_query("UPDATE {system} set schema_version = 6004 WHERE name = 'erp_quote'");
+  db_query("UPDATE {system} set schema_version = 6005 WHERE name = 'erp_quote'");
 }
 
 function erp_quote_schema() {
@@ -16,6 +16,7 @@
       'quote_id' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '10'),
       'customer_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
       'total' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '20'),
+      'transaction_discount' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '20'),
       'extra_notes' => array('type' => 'blob', 'not null' => TRUE),
       'quote_status' => array('type' => 'char', 'length' => '1', 'not null' => TRUE, 'default' => '')
     ),
@@ -34,6 +35,7 @@
       'extra' =>  array('type' => 'text', 'size' => 'medium'),
       'price' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '20'),
       'qty' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
+      'line_discount' => array('type' => 'float', 'not null' => TRUE, 'default' => 0, 'disp-width' => '5'),
       'serial' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE)
     ),
     'primary key' => array('nid', 'line'),
@@ -101,3 +103,12 @@
 
   return $ret;
 }
+
+function erp_quote_update_6005() {
+  $ret = array();
+
+  db_add_field($ret, 'erp_quote', 'transaction_discount', array('type' => 'float', 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'erp_quote_data', 'line_discount', array('type' => 'float', 'not null' => TRUE, 'default' => 0));
+
+  return $ret;
+}
diff -uNr org/erp/erp_quote/erp_quote.module erp/erp_quote/erp_quote.module
--- org/erp/erp_quote/erp_quote.module	2011-02-25 04:06:47.000000000 +0200
+++ erp/erp_quote/erp_quote.module	2011-11-02 18:20:19.000000000 +0200
@@ -196,6 +196,20 @@
           '#title' => t('How many days quotes are valid for before expiring'),
           '#default_value' => variable_get('erp_quote_valid_days', 14));
 
+  $form['erp_invoice_line_discount'] =
+    array('#type' => 'checkbox',
+          '#title' => t('Enable line item discounts with quotes, invoices & cash sale items? (common settting between all three modules)'),
+          '#default_value' => variable_get('erp_invoice_line_discount', FALSE),
+          '#description' => t('ERP has the ability to give discounts per line item.')
+    );
+
+  $form['erp_invoice_transaction_discount'] =
+    array('#type' => 'checkbox',
+          '#title' => t('Enable discounts per transaction with quotes, invoices & cash sale items? (common settting between all three modules)'),
+          '#default_value' => variable_get('erp_invoice_transaction_discount', FALSE),
+          '#description' => t('ERP has the ability to give discounts per transaction.')
+    );
+
   $form += erp_set_next_id_form('erp_quote', 'Quote');
 
   return system_settings_form($form);
@@ -219,12 +233,12 @@
   $total_price = 0;
 
   erp_set_customer($node);
-  
+
   // If this is being created from a quote, load the node data from that now.
   $extra_ops = arg(3);
   if ($extra_ops == 'erp-cart') {
     erp_cart_load($node);
-  }  
+  }
 
   // Default to the current user.
   if (!$node->owner) {
@@ -271,12 +285,23 @@
     array('#type' => 'hidden',
           '#default_value' => $node->customer_nid);
 
+  if (variable_get('erp_invoice_transaction_discount', FALSE)) {
+    $form['quote_details']['transaction_discount'] =
+      array('#prefix' => '<div class="transaction_discount">',
+            '#type' => 'textfield',
+            '#title' => variable_get('erp_invoice_transaction_discount_label', 'Transaction Discount'),
+            '#default_value' => erp_currency($node->transaction_discount),
+            '#size' => 20,
+            '#suffix' => '</div>');
+  }
+
   $form['quote_details']['quote_status'] =
     array('#prefix' => '<br />',
           '#type' => 'checkbox',
           '#title' => t('Closed'),
           '#default_value' => $node->quote_status);
 
+
   $form['entries'] =
     array('#type' => 'fieldset',
           '#title' => t('Current Quote Items'),
@@ -338,6 +363,16 @@
               '#suffix' => '</div>');
     }
 
+    if (variable_get('erp_invoice_line_discount', FALSE)) {
+      $form['entries']['line_discount'][$i] =
+        array('#type' => 'textfield',
+              '#size' => 5,
+              '#maxlength' => 5,
+              '#default_value' => $node->entries['line_discount'][$i],
+              '#prefix' => '<div class="line_discount">',
+              '#suffix' => '</div>');
+    }
+
     $form['entries']['price'][$i] =
       array('#type' => 'textfield',
             '#size' => 12,
@@ -361,9 +396,12 @@
       ),
     );
 
-    $total_price += $node->entries['price'][$i] * $node->entries['qty'][$i];
+    //$total_price += (($node->entries['price'][$i] * $node->entries['qty'][$i]) / (($node->entries['line_discount'][$i]/100)+1));
+    $total_price += ((($node->entries['price'][$i] - (($node->entries['line_discount'][$i]/100) * $node->entries['price'][$i])) * $node->entries['qty'][$i]));
   }
 
+  $total_price += $node->transaction_discount;
+
   $form['entries']['total'] =
     array('#type' => 'textfield',
           '#prefix' => '<div class="total">',
@@ -417,6 +455,16 @@
             '#suffix' => '</div>');
   }
 
+  if (variable_get('erp_invoice_line_discount', FALSE)) {
+    $form['entries']['newline']['line_discount'] =
+      array('#type' => 'textfield',
+            '#prefix' => '<div class="line_discount">',
+            '#size' => 5,
+            '#maxlength' => 5,
+            '#default_value' => '0',
+            '#suffix' => '</div>');
+  }
+
   $form['entries']['newline']['price'] =
     array('#type' => 'textfield',
           '#prefix' => '<div class="price">',
@@ -508,6 +556,7 @@
           'extra' => $node->entries['extra'][$i],
           'qty' => $node->entries['qty'][$i],
           'price' => $node->entries['price'][$i],
+          'line_discount' => $node->entries['line_discount'][$i],
           'serial' => $node->entries['serial'][$i],
         );
 
@@ -605,6 +654,7 @@
     $item = node_load($quote_data['item_nid']);
 
     $quote->entries['item_desc'][] = erp_item_desc_build($item);
+    $quote->entries['line_discount'][] = $quote_data['line_discount'];
     $quote->entries['price'][] = $quote_data['price'];
     $quote->entries['qty'][] = $quote_data['qty'];
     $quote->entries['extra'][] = $quote_data['extra'];
