From a123638d37328ab70109cb41f8c4200ba4a3fd27 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 16 Jun 2015 15:20:52 +0530 Subject: [PATCH] [fix][report] Payment period based on invoice date --- .../doctype/sales_invoice/sales_invoice.py | 3 +-- .../payment_period_based_on_invoice_date.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index e5af1763b1..fe5954e0e0 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -65,8 +65,7 @@ class SalesInvoice(SellingController): 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 bf5c4e5799..3c8f550301 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 @@ from frappe.utils import flt 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 @@ def execute(filters=None): 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"