fix: Billing % Logic and Map Pending Qty only in PR and DN

- Billing % should consider unreturned amount as total
- While mapping to return doc, map unreturned amount
- Added field Received Qty in Stock UOM, to tally against Returned Qty in PR
- PR billing percentage updation custom function
- In patch set received qty in stock uom first, then update returned qty and billing
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index f376836..af2474d 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -497,6 +497,10 @@
 					frappe.throw(_("Row {0}: Conversion Factor is mandatory").format(d.idx))
 				d.stock_qty = flt(d.qty) * flt(d.conversion_factor)
 
+				if self.doctype=="Purchase Receipt" and d.meta.get_field("received_stock_qty"):
+					# Set Received Qty in Stock UOM
+					d.received_stock_qty = flt(d.received_qty) * flt(d.conversion_factor, d.precision("conversion_factor"))
+
 	def validate_purchase_return(self):
 		for d in self.get("items"):
 			if self.is_return and flt(d.rejected_qty) != 0: