[enhance] close purchase order
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 6ae83d0..9a70159 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -19,11 +19,13 @@
 		this._super();
 		// this.frm.dashboard.reset();
 
-		if(doc.docstatus == 1 && doc.status != 'Stopped') {
+		if(doc.docstatus == 1 && doc.status != 'Stopped' && doc.status != 'Closed') {
 
 			if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100)
 				cur_frm.add_custom_button(__('Stop'), cur_frm.cscript['Stop Purchase Order']);
 
+			cur_frm.add_custom_button(__('Close'), cur_frm.cscript['Close Purchase Order']);
+
 			if(flt(doc.per_billed)==0) {
 				cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry);
 			}
@@ -223,6 +225,18 @@
 	}
 }
 
+cur_frm.cscript['Close Purchase Order'] = function() {
+	var doc = cur_frm.doc;
+	var check = confirm(__("Do you really want to Close ") + doc.name);
+
+	if (check) {
+		return $c('runserverobj', args={'method':'update_status', 'arg': 'Closed', 'docs':doc}, function(r,rt) {
+			cur_frm.refresh();
+		});
+	}
+}
+
+
 cur_frm.pformat.indent_no = function(doc, cdt, cdn){
 	//function to make row of table
 
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index 98dbfbe..5f15675 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -1684,7 +1684,7 @@
    "no_copy": 1, 
    "oldfieldname": "status", 
    "oldfieldtype": "Select", 
-   "options": "\nDraft\nTo Receive and Bill\nTo Bill\nTo Receive\nCompleted\nStopped\nCancelled", 
+   "options": "\nDraft\nTo Receive and Bill\nTo Bill\nTo Receive\nCompleted\nStopped\nCancelled\nClosed", 
    "permlevel": 0, 
    "print_hide": 1, 
    "read_only": 1, 
@@ -2238,7 +2238,7 @@
  "is_submittable": 1, 
  "issingle": 0, 
  "istable": 0, 
- "modified": "2015-10-16 06:13:50.058318", 
+ "modified": "2015-10-19 14:23:14.190768", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Purchase Order", 
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order_list.js b/erpnext/buying/doctype/purchase_order/purchase_order_list.js
index 7f0ab65..ad83fb2 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order_list.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order_list.js
@@ -4,6 +4,8 @@
 	get_indicator: function(doc) {
         if(doc.status==="Stopped") {
 			return [__("Stopped"), "darkgrey", "status,=,Stopped"];
+		} else if(doc.status==="Closed"){
+			return [__("Closed"), "green", "status,=,Closed"];
 		} else if(flt(doc.per_received, 2) < 100 && doc.status!=="Stopped") {
 			if(flt(doc.per_billed, 2) < 100) {
 				return [__("To Receive and Bill"), "orange",
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index f666eed..69e2d3e 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -47,6 +47,7 @@
 		["Completed", "eval:self.per_received == 100 and self.per_billed == 100 and self.docstatus == 1"],
 		["Stopped", "eval:self.status=='Stopped'"],
 		["Cancelled", "eval:self.docstatus==2"],
+		["Closed", "eval:self.status=='Closed'"],
 	],
 	"Delivery Note": [
 		["Draft", None],
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 57162a1..7a2bdb0 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -236,6 +236,21 @@
 	}
 }
 
+cur_frm.cscript['Unstop Sales Order'] = function() {
+	var doc = cur_frm.doc;
+
+	var check = confirm(__("Are you sure you want to UNSTOP ") + doc.name);
+
+	if (check) {
+		return $c('runserverobj', {
+			'method':'unstop_sales_order',
+			'docs': doc
+		}, function(r,rt) {
+			cur_frm.refresh();
+		});
+	}
+}
+
 cur_frm.cscript['Close Sales Order'] = function(){
 	var doc = cur_frm.doc;
 
@@ -252,21 +267,6 @@
 	}
 }
 
-cur_frm.cscript['Unstop Sales Order'] = function() {
-	var doc = cur_frm.doc;
-
-	var check = confirm(__("Are you sure you want to UNSTOP ") + doc.name);
-
-	if (check) {
-		return $c('runserverobj', {
-			'method':'unstop_sales_order',
-			'docs': doc
-		}, function(r,rt) {
-			cur_frm.refresh();
-		});
-	}
-}
-
 cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
 	if(cint(frappe.boot.notification_settings.sales_order)) {
 		cur_frm.email_doc(frappe.boot.notification_settings.sales_order_message);
diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py
index b0654e2..b1e8b22 100644
--- a/erpnext/stock/stock_balance.py
+++ b/erpnext/stock/stock_balance.py
@@ -122,7 +122,7 @@
 		from `tabPurchase Order Item` po_item, `tabPurchase Order` po
 		where po_item.item_code=%s and po_item.warehouse=%s
 		and po_item.qty > ifnull(po_item.received_qty, 0) and po_item.parent=po.name
-		and po.status!='Stopped' and po.docstatus=1""", (item_code, warehouse))
+		and po.status not in ('Stopped', 'Closed') and po.docstatus=1""", (item_code, warehouse))
 
 	return flt(ordered_qty[0][0]) if ordered_qty else 0