fix: resolving commits
diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json
index 5baf693..51a38e2 100644
--- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json
+++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json
@@ -27,17 +27,11 @@
   "stock_qty",
   "sec_break1",
   "price_list_rate",
-  "last_purchase_rate",
-  "col_break3",
-  "base_price_list_rate",
-  "discount_and_margin_section",
-  "margin_type",
-  "margin_rate_or_amount",
-  "rate_with_margin",
-  "column_break_28",
   "discount_percentage",
   "discount_amount",
-  "base_rate_with_margin",
+  "col_break3",
+  "last_purchase_rate",
+  "base_price_list_rate",
   "sec_break2",
   "rate",
   "amount",
@@ -56,6 +50,8 @@
   "base_net_amount",
   "warehouse_and_reference",
   "warehouse",
+  "actual_qty",
+  "company_total_stock",
   "material_request",
   "material_request_item",
   "sales_order",
@@ -739,51 +735,21 @@
    "fieldname": "stock_uom_rate",
    "fieldtype": "Currency",
    "label": "Rate of Stock UOM",
-   "no_copy": 1,
    "options": "currency",
    "read_only": 1
   },
   {
-   "collapsible": 1,
-   "fieldname": "discount_and_margin_section",
-   "fieldtype": "Section Break",
-   "label": "Discount and Margin"
-  },
-  {
-   "depends_on": "price_list_rate",
-   "fieldname": "margin_type",
-   "fieldtype": "Select",
-   "label": "Margin Type",
-   "options": "\nPercentage\nAmount",
-   "print_hide": 1
-  },
-  {
-   "depends_on": "eval:doc.margin_type && doc.price_list_rate",
-   "fieldname": "margin_rate_or_amount",
+   "allow_on_submit": 1,
+   "fieldname": "actual_qty",
    "fieldtype": "Float",
-   "label": "Margin Rate or Amount",
-   "print_hide": 1
-  },
-  {
-   "depends_on": "eval:doc.margin_type && doc.price_list_rate && doc.margin_rate_or_amount",
-   "fieldname": "rate_with_margin",
-   "fieldtype": "Currency",
-   "label": "Rate With Margin",
-   "options": "currency",
+   "label": "Available Qty at Warehouse",
    "print_hide": 1,
    "read_only": 1
   },
   {
-   "fieldname": "column_break_28",
-   "fieldtype": "Column Break"
-  },
-  {
-   "depends_on": "eval:doc.margin_type && doc.price_list_rate && doc.margin_rate_or_amount",
-   "fieldname": "base_rate_with_margin",
-   "fieldtype": "Currency",
-   "label": "Rate With Margin (Company Currency)",
-   "options": "Company:company:default_currency",
-   "print_hide": 1,
+   "fieldname": "company_total_stock",
+   "fieldtype": "Float",
+   "label": "Available Qty at Company",
    "read_only": 1
   }
  ],
@@ -791,7 +757,7 @@
  "index_web_pages_for_search": 1,
  "istable": 1,
  "links": [],
- "modified": "2021-02-23 01:00:27.132705",
+ "modified": "2021-03-22 11:20:00.121296",
  "modified_by": "Administrator",
  "module": "Buying",
  "name": "Purchase Order Item",
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index 67b12fb..cdfd909 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -216,7 +216,8 @@
 				child: item,
 				args: {
 					item_code: item.item_code,
-					warehouse: item.warehouse
+					warehouse: item.warehouse,
+					company: doc.company
 				}
 			});
 		}
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 873cfec..01b6e71 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -917,11 +917,26 @@
 		{"item_code": item_code, "warehouse": warehouse}, "projected_qty")}
 
 @frappe.whitelist()
-def get_bin_details(item_code, warehouse):
-	return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
+def get_bin_details(item_code, warehouse, company=None):
+	bin_details = frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
 		["projected_qty", "actual_qty", "reserved_qty"], as_dict=True, cache=True) \
 			or {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0}
+	if company:
+		bin_details['company_total_stock'] = get_company_total_stock(item_code, company)
+	return bin_details
 
+def get_company_total_stock(item_code, company):
+	return frappe.db.sql("""SELECT sum(actual_qty) from 
+		(`tabBin` INNER JOIN `tabWarehouse` ON `tabBin`.warehouse = `tabWarehouse`.name) 
+		WHERE `tabWarehouse`.company = '{0}' and `tabBin`.item_code = '{1}'"""
+		.format(company, item_code))[0][0]
+
+@frappe.whitelist()
+def get_total_stock_value(item_code):
+	query = """select sum(actual_qty) from `tabBin`, `tabItem` where
+		 `tabItem`.name = `tabBin`.item_code and ifnull(`tabItem`.disabled, 0) = 0  and `tabBin`.item_code = %(item_code)s"""
+	return frappe.db.sql(query, debug=True)
+	
 @frappe.whitelist()
 def get_serial_no_details(item_code, warehouse, stock_qty, serial_no):
 	args = frappe._dict({"item_code":item_code, "warehouse":warehouse, "stock_qty":stock_qty, "serial_no":serial_no})