Merge pull request #5885 from nabinhait/payment_entry_fix12

[fix] Set amounts only if party and bank account exists
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 1850146..0a6655d 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.0.5'
+__version__ = '7.0.7'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 1d657dc..f83d144 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -64,8 +64,8 @@
 		if self.salary_slip_based_on_timesheet and not self.get('timesheets'):
 			self.set("timesheets", [])
 
-			timesheets = frappe.db.sql(""" select * from `tabTimesheet` where employee = %(employee)s and (status = 'Submitted' or
-				status = 'Billed')""", {'employee': self.employee}, as_dict=1)
+			timesheets = frappe.db.sql(""" select * from `tabTimesheet` where employee = %(employee)s and start_date BETWEEN %(start_date)s AND %(end_date)s and (status = 'Submitted' or
+				status = 'Billed')""", {'employee': self.employee, 'start_date': self.start_date, 'end_date': self.end_date}, as_dict=1)
 
 			for data in timesheets:
 				self.append('timesheets', {
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 6971e0d..e700bea 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -304,3 +304,4 @@
 erpnext.patches.v7_0.rename_fee_amount_to_fee_component
 erpnext.patches.v7_0.calculate_total_costing_amount
 erpnext.patches.v7_0.fix_nonwarehouse_ledger_gl_entries_for_transactions
+execute:frappe.db.sql("""update `tabOpportunity` set status='Quotation' where status='Converted'""")
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
index ff9d48a..ba1d067 100644
--- a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
+++ b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
@@ -20,7 +20,7 @@
 			from `tabStock Ledger Entry` sle
 			where sle.warehouse in (%s) and creation > '2016-05-01'
 			and not exists(select name from `tabGL Entry` 
-				where account=sle.warehosue and voucher_type=sle.voucher_type and voucher_no=sle.voucher_no)
+				where account=sle.warehouse and voucher_type=sle.voucher_type and voucher_no=sle.voucher_no)
 			order by sle.posting_date""" %
 			', '.join(['%s']*len(warehouses)), tuple(warehouses))
 
@@ -47,4 +47,4 @@
 		else:
 			warehouse_account.remove(account)
 
-	return warehouse_account
\ No newline at end of file
+	return warehouse_account
diff --git a/erpnext/schools/doctype/fees/fees.json b/erpnext/schools/doctype/fees/fees.json
index 75e3315..ce911ad 100644
--- a/erpnext/schools/doctype/fees/fees.json
+++ b/erpnext/schools/doctype/fees/fees.json
@@ -394,6 +394,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "default": "0", 
    "fieldname": "total_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -419,7 +420,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "default": "", 
+   "default": "0", 
    "fieldname": "paid_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -445,6 +446,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "default": "0", 
    "fieldname": "outstanding_amount", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -478,7 +480,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-07-25 08:44:33.595812", 
+ "modified": "2016-07-27 03:52:28.509757", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Fees", 
diff --git a/erpnext/schools/doctype/fees/fees.py b/erpnext/schools/doctype/fees/fees.py
index 0f2db50..d2540f7 100644
--- a/erpnext/schools/doctype/fees/fees.py
+++ b/erpnext/schools/doctype/fees/fees.py
@@ -14,8 +14,9 @@
 	def calculate_total(self):
 		"""Calculates total amount."""
 		self.total_amount = 0
-		for d in self.amount:
+		for d in self.components:
 			self.total_amount += d.amount
+		self.outstanding_amount = self.total_amount
 
 def get_fee_list(doctype, txt, filters, limit_start, limit_page_length=20):
 	user = frappe.session.user
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 03f2ee1..a980ed0 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -250,7 +250,7 @@
 
 					self.valuation_rate = new_stock_value / new_stock_qty
 				else:
-					self.valuation_rate = self.outgoing_rate
+					self.valuation_rate = sle.outgoing_rate
 
 		else:
 			if flt(self.qty_after_transaction) >= 0 and sle.outgoing_rate: