Merge pull request #3479 from nabinhait/develop

[fix][report] Payment period based on invoice date
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index e5af176..fe5954e 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -65,8 +65,7 @@
 		self.set_against_income_account()
 		self.validate_c_form()
 		self.validate_time_logs_are_submitted()
-		self.validate_multiple_billing("Delivery Note", "dn_detail", "amount",
-			"items")
+		self.validate_multiple_billing("Delivery Note", "dn_detail", "amount", "items")
 
 	def on_submit(self):
 		super(SalesInvoice, self).on_submit()
diff --git a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py
index bf5c4e5..3c8f550 100644
--- a/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py
+++ b/erpnext/accounts/report/payment_period_based_on_invoice_date/payment_period_based_on_invoice_date.py
@@ -9,8 +9,9 @@
 
 def execute(filters=None):
 	if not filters: filters = {}
-
-	columns = get_columns()
+	validate_filters(filters)
+			
+	columns = get_columns(filters)
 	entries = get_entries(filters)
 	invoice_posting_date_map = get_invoice_posting_date_map(filters)
 	against_date = ""
@@ -36,11 +37,18 @@
 		data.append(row)
 
 	return columns, data
+	
+def validate_filters(filters):
+	if (filters.get("payment_type") == "Incoming" and filters.get("party_type") == "Supplier") or \
+		(filters.get("payment_type") == "Outgoing" and filters.get("party_type") == "Customer"):
+			frappe.throw(_("{0} payment entries can not be filtered by {1}")\
+				.format(filters.payment_type, filters.party_type))
 
-def get_columns():
+def get_columns(filters):
 	return [_("Journal Entry") + ":Link/Journal Entry:140", 
-		_("Party Type") + ":Link/DocType:100", _("Party") + ":Dynamic Link/party_type:140",
-		_("Posting Date") + ":Date:100", _("Against Invoice") + ":Link/Purchase Invoice:130",
+		_("Party Type") + ":Link/DocType:100", _("Party") + ":Dynamic Link/Party Type:140",
+		_("Posting Date") + ":Date:100", 
+		_("Against Invoice") + (":Link/Purchase Invoice:130" if filters.get("payment_type") == "Outgoing" else ":Link/Sales Invoice:130"),
 		_("Against Invoice Posting Date") + ":Date:130", _("Debit") + ":Currency:120", _("Credit") + ":Currency:120",
 		_("Reference No") + "::100", _("Reference Date") + ":Date:100", _("Remarks") + "::150", _("Age") +":Int:40",
 		"0-30:Currency:100", "30-60:Currency:100", "60-90:Currency:100", _("90-Above") + ":Currency:100"