From 813485023b927f6069f0bbeadc6f42a6172b0a80 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Thu, 20 Dec 2018 14:04:00 +0000 Subject: [PATCH 01/21] Filter cancelled and draft payments --- .../sales_payment_summary.py | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py index 05c8fb78de..f4c72b4413 100644 --- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py @@ -108,33 +108,33 @@ def get_conditions(filters): def get_pos_invoice_data(filters): conditions = get_conditions(filters) result = frappe.db.sql('' - 'SELECT ' - 'posting_date, owner, sum(net_total) as "net_total", sum(total_taxes) as "total_taxes", ' - 'sum(paid_amount) as "paid_amount", sum(outstanding_amount) as "outstanding_amount", ' - 'mode_of_payment, warehouse, cost_center ' - 'FROM (' - 'SELECT ' - 'parent, item_code, sum(amount) as "base_total", warehouse, cost_center ' - 'from `tabSales Invoice Item` group by parent' - ') t1 ' - 'left join ' - '(select parent, mode_of_payment from `tabSales Invoice Payment` group by parent) t3 ' - 'on (t3.parent = t1.parent) ' - 'JOIN (' - 'SELECT ' - 'docstatus, company, is_pos, name, posting_date, owner, sum(base_total) as "base_total", ' - 'sum(net_total) as "net_total", sum(total_taxes_and_charges) as "total_taxes", ' - 'sum(base_paid_amount) as "paid_amount", sum(outstanding_amount) as "outstanding_amount" ' - 'FROM `tabSales Invoice` ' - 'GROUP BY name' - ') a ' - 'ON (' - 't1.parent = a.name and t1.base_total = a.base_total) ' - 'WHERE a.docstatus = 1' - ' AND {conditions} ' - 'GROUP BY ' - 'owner, posting_date, warehouse'.format(conditions=conditions), filters, as_dict=1 - ) + 'SELECT ' + 'posting_date, owner, sum(net_total) as "net_total", sum(total_taxes) as "total_taxes", ' + 'sum(paid_amount) as "paid_amount", sum(outstanding_amount) as "outstanding_amount", ' + 'mode_of_payment, warehouse, cost_center ' + 'FROM (' + 'SELECT ' + 'parent, item_code, sum(amount) as "base_total", warehouse, cost_center ' + 'from `tabSales Invoice Item` group by parent' + ') t1 ' + 'left join ' + '(select parent, mode_of_payment from `tabSales Invoice Payment` group by parent) t3 ' + 'on (t3.parent = t1.parent) ' + 'JOIN (' + 'SELECT ' + 'docstatus, company, is_pos, name, posting_date, owner, sum(base_total) as "base_total", ' + 'sum(net_total) as "net_total", sum(total_taxes_and_charges) as "total_taxes", ' + 'sum(base_paid_amount) as "paid_amount", sum(outstanding_amount) as "outstanding_amount" ' + 'FROM `tabSales Invoice` ' + 'GROUP BY name' + ') a ' + 'ON (' + 't1.parent = a.name and t1.base_total = a.base_total) ' + 'WHERE a.docstatus = 1' + ' AND {conditions} ' + 'GROUP BY ' + 'owner, posting_date, warehouse'.format(conditions=conditions), filters, as_dict=1 + ) return result @@ -170,6 +170,7 @@ def get_mode_of_payments(filters): from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c where a.name = c.reference_name and b.name = c.parent + and b.docstatus = 1 and a.name in ({invoice_list_names}) union select a.owner, a.posting_date, @@ -211,6 +212,7 @@ def get_mode_of_payment_details(filters): from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c where a.name = c.reference_name and b.name = c.parent + and b.docstatus = 1 and a.name in ({invoice_list_names}) group by a.owner, a.posting_date, mode_of_payment union From ed94317df99493c24c58a1e1aa553a8f822e793f Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Wed, 26 Dec 2018 08:36:32 +0000 Subject: [PATCH 02/21] Test cases --- .../test_sales_payment_summary.py | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py new file mode 100644 index 0000000000..58c77849b8 --- /dev/null +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -0,0 +1,117 @@ +# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import unittest +import frappe +import erpnext +from erpnext.accounts.report.sales_payment_summary.sales_payment_summary import get_mode_of_payments, get_mode_of_payment_details +from frappe.utils import nowdate +from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry + +test_dependencies = ["Sales Invoice"] + +class TestSalesPaymentSummary(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + + def test_get_mode_of_payments(self): + si = frappe.get_all("Sales Invoice", fields=["name", "docstatus"]) + filters = get_filters() + + for invoice in si[:2]: + doc = frappe.get_doc("Sales Invoice", invoice.name) + new_doc = frappe.copy_doc(doc) + new_doc.insert() + new_doc.submit() + try: + new_doc.submit() + except Exception as e: + pass + + if int(new_doc.name[-3:])%2 == 0: + bank_account = "_Test Cash - _TC" + mode_of_payment = "Cash" + else: + bank_account = "_Test Bank - _TC" + mode_of_payment = "Credit Card" + + pe = get_payment_entry("Sales Invoice", new_doc.name, bank_account=bank_account) + pe.reference_no = "_Test" + pe.reference_date = nowdate() + pe.mode_of_payment = mode_of_payment + pe.insert() + pe.submit() + + mop = get_mode_of_payments(filters) + self.assertTrue('Credit Card' in mop.values()[0]) + self.assertTrue('Cash' in mop.values()[0]) + + # Cancel all Cash payment entry and check if this mode of payment is still fetched. + payment_entries = frappe.get_all("Payment Entry", filters={"mode_of_payment": "Cash", "docstatus": 1}, fields=["name", "docstatus"]) + for payment_entry in payment_entries: + pe = frappe.get_doc("Payment Entry", payment_entry.name) + pe.cancel() + + mop = get_mode_of_payments(filters) + self.assertTrue('Credit Card' in mop.values()[0]) + self.assertTrue('Cash' not in mop.values()[0]) + + def test_get_mode_of_payments_details(self): + si = frappe.get_all("Sales Invoice", fields=["name", "docstatus"]) + filters = get_filters() + + for invoice in si[:2]: + doc = frappe.get_doc("Sales Invoice", invoice.name) + new_doc = frappe.copy_doc(doc) + new_doc.insert() + new_doc.submit() + try: + new_doc.submit() + except Exception as e: + pass + + if int(new_doc.name[-3:])%2 == 0: + bank_account = "_Test Cash - _TC" + mode_of_payment = "Cash" + else: + bank_account = "_Test Bank - _TC" + mode_of_payment = "Credit Card" + + pe = get_payment_entry("Sales Invoice", new_doc.name, bank_account=bank_account) + pe.reference_no = "_Test" + pe.reference_date = nowdate() + pe.mode_of_payment = mode_of_payment + pe.insert() + pe.submit() + + mopd = get_mode_of_payment_details(filters) + + mopd_values = mopd.values()[0] + for mopd_value in mopd_values: + if mopd_value[0] == "Credit Card": + cc_init_amount = mopd_value[1] + + # Cancel one Credit Card Payment Entry and check that it is not fetched in mode of payment details. + payment_entries = frappe.get_all("Payment Entry", filters={"mode_of_payment": "Credit Card", "docstatus": 1}, fields=["name", "docstatus"]) + for payment_entry in payment_entries[:1]: + pe = frappe.get_doc("Payment Entry", payment_entry.name) + pe.cancel() + + mopd = get_mode_of_payment_details(filters) + mopd_values = mopd.values()[0] + for mopd_value in mopd_values: + if mopd_value[0] == "Credit Card": + cc_final_amount = mopd_value[1] + + self.assertTrue(cc_init_amount > cc_final_amount) + +def get_filters(): + return { + "from_date": "1900-01-01", + "to_date": nowdate(), + "company": "_Test Company" + } \ No newline at end of file From 9d31452c25a43a4fd21ff97490a536ba0e5031f6 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Wed, 26 Dec 2018 08:38:42 +0000 Subject: [PATCH 03/21] Remove ununsed variable --- .../sales_payment_summary/test_sales_payment_summary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index 58c77849b8..d9d05135a6 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -29,7 +29,7 @@ class TestSalesPaymentSummary(unittest.TestCase): new_doc.submit() try: new_doc.submit() - except Exception as e: + except Exception: pass if int(new_doc.name[-3:])%2 == 0: @@ -71,7 +71,7 @@ class TestSalesPaymentSummary(unittest.TestCase): new_doc.submit() try: new_doc.submit() - except Exception as e: + except Exception: pass if int(new_doc.name[-3:])%2 == 0: From 899b9b1ea769045323bbe9ae61f2bc32a1bb17e7 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Wed, 26 Dec 2018 08:56:11 +0000 Subject: [PATCH 04/21] Codacy correction --- .../sales_payment_summary/test_sales_payment_summary.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index d9d05135a6..9b9711f5df 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import unittest import frappe -import erpnext from erpnext.accounts.report.sales_payment_summary.sales_payment_summary import get_mode_of_payments, get_mode_of_payment_details from frappe.utils import nowdate from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry @@ -29,8 +28,8 @@ class TestSalesPaymentSummary(unittest.TestCase): new_doc.submit() try: new_doc.submit() - except Exception: - pass + except Exception as e: + print(e) if int(new_doc.name[-3:])%2 == 0: bank_account = "_Test Cash - _TC" @@ -71,8 +70,8 @@ class TestSalesPaymentSummary(unittest.TestCase): new_doc.submit() try: new_doc.submit() - except Exception: - pass + except Exception as e: + print(e) if int(new_doc.name[-3:])%2 == 0: bank_account = "_Test Cash - _TC" From 9c1db688d1d8a2cb9f3c8232c3ca25981aa574dc Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Wed, 26 Dec 2018 10:33:42 +0000 Subject: [PATCH 05/21] Ignore pricing rule for Travis --- .../report/sales_payment_summary/test_sales_payment_summary.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index 9b9711f5df..8cabf6e6cb 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -24,6 +24,7 @@ class TestSalesPaymentSummary(unittest.TestCase): for invoice in si[:2]: doc = frappe.get_doc("Sales Invoice", invoice.name) new_doc = frappe.copy_doc(doc) + new_doc.ignore_pricing_rule = 1 new_doc.insert() new_doc.submit() try: From d7777696d78a92f20e4fdf7b0071adec212ffd22 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Wed, 26 Dec 2018 14:08:00 +0000 Subject: [PATCH 06/21] Corrections for Travis --- .../sales_payment_summary/test_sales_payment_summary.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index 8cabf6e6cb..096935f518 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -18,10 +18,10 @@ class TestSalesPaymentSummary(unittest.TestCase): pass def test_get_mode_of_payments(self): - si = frappe.get_all("Sales Invoice", fields=["name", "docstatus"]) + si = frappe.get_all("Sales Invoice", filters={"company": "_Test Company", "customer": "_Test Customer"}, fields=["name", "docstatus"]) filters = get_filters() - for invoice in si[:2]: + for invoice in si[:-2]: doc = frappe.get_doc("Sales Invoice", invoice.name) new_doc = frappe.copy_doc(doc) new_doc.ignore_pricing_rule = 1 @@ -61,10 +61,10 @@ class TestSalesPaymentSummary(unittest.TestCase): self.assertTrue('Cash' not in mop.values()[0]) def test_get_mode_of_payments_details(self): - si = frappe.get_all("Sales Invoice", fields=["name", "docstatus"]) + si = frappe.get_all("Sales Invoice", filters={"company": "_Test Company", "customer": "_Test Customer"}, fields=["name", "docstatus"]) filters = get_filters() - for invoice in si[:2]: + for invoice in si[:-2]: doc = frappe.get_doc("Sales Invoice", invoice.name) new_doc = frappe.copy_doc(doc) new_doc.insert() From 02aa9fb240f0944ddc2c705bf11bfd5da84ea176 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Thu, 27 Dec 2018 08:46:29 +0000 Subject: [PATCH 07/21] Understand Travis --- .../report/sales_payment_summary/test_sales_payment_summary.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index 096935f518..a9ecaaf546 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -19,10 +19,12 @@ class TestSalesPaymentSummary(unittest.TestCase): def test_get_mode_of_payments(self): si = frappe.get_all("Sales Invoice", filters={"company": "_Test Company", "customer": "_Test Customer"}, fields=["name", "docstatus"]) + print(si) filters = get_filters() for invoice in si[:-2]: doc = frappe.get_doc("Sales Invoice", invoice.name) + print(doc.__dict__) new_doc = frappe.copy_doc(doc) new_doc.ignore_pricing_rule = 1 new_doc.insert() From 0f9c47c242a494e0dd6d1915a190ef9d029fb598 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Thu, 27 Dec 2018 10:10:18 +0000 Subject: [PATCH 08/21] Remove pricing rule from items --- .../sales_payment_summary/test_sales_payment_summary.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index a9ecaaf546..70ba5a362a 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -19,14 +19,14 @@ class TestSalesPaymentSummary(unittest.TestCase): def test_get_mode_of_payments(self): si = frappe.get_all("Sales Invoice", filters={"company": "_Test Company", "customer": "_Test Customer"}, fields=["name", "docstatus"]) - print(si) filters = get_filters() for invoice in si[:-2]: doc = frappe.get_doc("Sales Invoice", invoice.name) - print(doc.__dict__) new_doc = frappe.copy_doc(doc) new_doc.ignore_pricing_rule = 1 + for item in new_doc.items: + item.pricing_rule = "" new_doc.insert() new_doc.submit() try: @@ -69,6 +69,9 @@ class TestSalesPaymentSummary(unittest.TestCase): for invoice in si[:-2]: doc = frappe.get_doc("Sales Invoice", invoice.name) new_doc = frappe.copy_doc(doc) + new_doc.ignore_pricing_rule = 1 + for item in new_doc.items: + item.pricing_rule = "" new_doc.insert() new_doc.submit() try: From 641d3e0073c7974309c48cc199cd35a023f5f131 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Thu, 27 Dec 2018 13:43:56 +0000 Subject: [PATCH 09/21] Add own records --- .../test_sales_payment_summary.py | 114 ++++++++++++------ 1 file changed, 74 insertions(+), 40 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index 70ba5a362a..aeb618f122 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -5,45 +5,34 @@ from __future__ import unicode_literals import unittest import frappe from erpnext.accounts.report.sales_payment_summary.sales_payment_summary import get_mode_of_payments, get_mode_of_payment_details -from frappe.utils import nowdate +from frappe.utils import today from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry test_dependencies = ["Sales Invoice"] class TestSalesPaymentSummary(unittest.TestCase): - def setUp(self): - pass - - def tearDown(self): - pass + @classmethod + def setUpClass(self): + create_records() def test_get_mode_of_payments(self): - si = frappe.get_all("Sales Invoice", filters={"company": "_Test Company", "customer": "_Test Customer"}, fields=["name", "docstatus"]) filters = get_filters() - for invoice in si[:-2]: - doc = frappe.get_doc("Sales Invoice", invoice.name) - new_doc = frappe.copy_doc(doc) - new_doc.ignore_pricing_rule = 1 - for item in new_doc.items: - item.pricing_rule = "" - new_doc.insert() - new_doc.submit() - try: - new_doc.submit() - except Exception as e: - print(e) + for dummy in range(2): + si = create_sales_invoice_record() + si.insert() + si.submit() - if int(new_doc.name[-3:])%2 == 0: + if int(si.name[-3:])%2 == 0: bank_account = "_Test Cash - _TC" mode_of_payment = "Cash" else: bank_account = "_Test Bank - _TC" mode_of_payment = "Credit Card" - pe = get_payment_entry("Sales Invoice", new_doc.name, bank_account=bank_account) + pe = get_payment_entry("Sales Invoice", si.name, bank_account=bank_account) pe.reference_no = "_Test" - pe.reference_date = nowdate() + pe.reference_date = today() pe.mode_of_payment = mode_of_payment pe.insert() pe.submit() @@ -63,32 +52,23 @@ class TestSalesPaymentSummary(unittest.TestCase): self.assertTrue('Cash' not in mop.values()[0]) def test_get_mode_of_payments_details(self): - si = frappe.get_all("Sales Invoice", filters={"company": "_Test Company", "customer": "_Test Customer"}, fields=["name", "docstatus"]) filters = get_filters() - for invoice in si[:-2]: - doc = frappe.get_doc("Sales Invoice", invoice.name) - new_doc = frappe.copy_doc(doc) - new_doc.ignore_pricing_rule = 1 - for item in new_doc.items: - item.pricing_rule = "" - new_doc.insert() - new_doc.submit() - try: - new_doc.submit() - except Exception as e: - print(e) + for dummy in range(2): + si = create_sales_invoice_record() + si.insert() + si.submit() - if int(new_doc.name[-3:])%2 == 0: + if int(si.name[-3:])%2 == 0: bank_account = "_Test Cash - _TC" mode_of_payment = "Cash" else: bank_account = "_Test Bank - _TC" mode_of_payment = "Credit Card" - pe = get_payment_entry("Sales Invoice", new_doc.name, bank_account=bank_account) + pe = get_payment_entry("Sales Invoice", si.name, bank_account=bank_account) pe.reference_no = "_Test" - pe.reference_date = nowdate() + pe.reference_date = today() pe.mode_of_payment = mode_of_payment pe.insert() pe.submit() @@ -117,6 +97,60 @@ class TestSalesPaymentSummary(unittest.TestCase): def get_filters(): return { "from_date": "1900-01-01", - "to_date": nowdate(), + "to_date": today(), "company": "_Test Company" - } \ No newline at end of file + } + +def create_sales_invoice_record(qty=1): + # return sales invoice doc object + return frappe.get_doc({ + "doctype": "Sales Invoice", + "customer": frappe.get_doc('Customer', {"customer_name": "Prestiga-Biz"}).name, + "company": '_Test Company', + "due_date": today(), + "posting_date": today(), + "currency": "INR", + "taxes_and_charges": "", + "debit_to": "Debtors - _TC", + "taxes": [], + "items": [{ + 'doctype': 'Sales Invoice Item', + 'item_code': frappe.get_doc('Item', {'item_name': 'Consulting'}).name, + 'qty': qty, + "rate": 10000, + 'income_account': 'Sales - _TC', + 'cost_center': 'Main - _TC', + 'expense_account': 'Cost of Goods Sold - _TC' + }] + }) + +def create_records(): + if frappe.db.exists("Customer", "Prestiga-Biz"): + return + + #customer + frappe.get_doc({ + "customer_group": "_Test Customer Group", + "customer_name": "Prestiga-Biz", + "customer_type": "Company", + "doctype": "Customer", + "territory": "_Test Territory" + }).insert() + + # item + item = frappe.get_doc({ + "doctype": "Item", + "item_code": "Consulting", + "item_name": "Consulting", + "item_group": "All Item Groups", + "company": "_Test Company", + "is_stock_item": 0 + }).insert() + + # item price + frappe.get_doc({ + "doctype": "Item Price", + "price_list": "Standard Selling", + "item_code": item.item_code, + "price_list_rate": 10000 + }).insert() \ No newline at end of file From 43c7bd57e4c4d47a398300150433b0384a830ebb Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Thu, 27 Dec 2018 14:43:30 +0000 Subject: [PATCH 10/21] Cancel existing payment entries for data integrity in test --- .../report/sales_payment_summary/test_sales_payment_summary.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index aeb618f122..bf9bc5ef68 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -14,6 +14,9 @@ class TestSalesPaymentSummary(unittest.TestCase): @classmethod def setUpClass(self): create_records() + pes = frappe.get_all("Payment Entry") + for pe in pes: + frappe.db.set_value("Payment Entry", pe.name, "docstatus", 2) def test_get_mode_of_payments(self): filters = get_filters() From b7339d7dcb4c39d938fcf99a36c0106cdb9be4f8 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Thu, 27 Dec 2018 15:30:56 +0000 Subject: [PATCH 11/21] Test travis --- .../report/sales_payment_summary/test_sales_payment_summary.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index bf9bc5ef68..8de3abca3c 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -51,6 +51,8 @@ class TestSalesPaymentSummary(unittest.TestCase): pe.cancel() mop = get_mode_of_payments(filters) + print(frappe.get_all("Payment Entry", filters={"docstatus": 1})) + print(mop) self.assertTrue('Credit Card' in mop.values()[0]) self.assertTrue('Cash' not in mop.values()[0]) From 8d71015bf8d517a156e6228494017d34eaee7bc6 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Thu, 27 Dec 2018 16:43:26 +0000 Subject: [PATCH 12/21] Cleanup journal entries --- .../sales_payment_summary/test_sales_payment_summary.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index 8de3abca3c..d3b3492153 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -15,8 +15,11 @@ class TestSalesPaymentSummary(unittest.TestCase): def setUpClass(self): create_records() pes = frappe.get_all("Payment Entry") + jes = frappe.get_all("Journal Entry") for pe in pes: frappe.db.set_value("Payment Entry", pe.name, "docstatus", 2) + for je in jes: + frappe.db.set_value("Journal Entry", je.name, "docstatus", 2) def test_get_mode_of_payments(self): filters = get_filters() @@ -51,8 +54,6 @@ class TestSalesPaymentSummary(unittest.TestCase): pe.cancel() mop = get_mode_of_payments(filters) - print(frappe.get_all("Payment Entry", filters={"docstatus": 1})) - print(mop) self.assertTrue('Credit Card' in mop.values()[0]) self.assertTrue('Cash' not in mop.values()[0]) From e87eb07e161fcd8bb417b6aab8645f0a415cfae3 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Thu, 27 Dec 2018 17:38:57 +0000 Subject: [PATCH 13/21] Correction for Travis --- .../report/sales_payment_summary/sales_payment_summary.py | 4 ++-- .../sales_payment_summary/test_sales_payment_summary.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py index f4c72b4413..c234da0fe3 100644 --- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py @@ -156,7 +156,6 @@ def get_sales_invoice_data(filters): def get_mode_of_payments(filters): - frappe.log_error(filters, 'filters') mode_of_payments = {} invoice_list = get_invoices(filters) invoice_list_names = ",".join(['"' + invoice['name'] + '"' for invoice in invoice_list]) @@ -164,6 +163,7 @@ def get_mode_of_payments(filters): inv_mop = frappe.db.sql("""select a.owner,a.posting_date, ifnull(b.mode_of_payment, '') as mode_of_payment from `tabSales Invoice` a, `tabSales Invoice Payment` b where a.name = b.parent + and a.docstatus = 1 and a.name in ({invoice_list_names}) union select a.owner,a.posting_date, ifnull(b.mode_of_payment, '') as mode_of_payment @@ -197,13 +197,13 @@ def get_invoices(filters): def get_mode_of_payment_details(filters): mode_of_payment_details = {} invoice_list = get_invoices(filters) - frappe.log_error(invoice_list, 'invoice_list') invoice_list_names = ",".join(['"' + invoice['name'] + '"' for invoice in invoice_list]) if invoice_list: inv_mop_detail = frappe.db.sql("""select a.owner, a.posting_date, ifnull(b.mode_of_payment, '') as mode_of_payment, sum(b.base_amount) as paid_amount from `tabSales Invoice` a, `tabSales Invoice Payment` b where a.name = b.parent + and a.docstatus = 1 and a.name in ({invoice_list_names}) group by a.owner, a.posting_date, mode_of_payment union diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index d3b3492153..62843e74ef 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -16,10 +16,13 @@ class TestSalesPaymentSummary(unittest.TestCase): create_records() pes = frappe.get_all("Payment Entry") jes = frappe.get_all("Journal Entry") + sis = frappe.get_all("Sales Invoice") for pe in pes: frappe.db.set_value("Payment Entry", pe.name, "docstatus", 2) for je in jes: frappe.db.set_value("Journal Entry", je.name, "docstatus", 2) + for si in sis: + frappe.db.set_value("Sales Invoice", si.name, "docstatus", 2) def test_get_mode_of_payments(self): filters = get_filters() From df4fe922c09aaeab09c6db67a9cd221ded3a4c86 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 28 Dec 2018 16:46:36 +0530 Subject: [PATCH 14/21] [Fix] Duplicate fieldnames operation and allow_alternative_item in BOM Item --- .../doctype/bom_item/bom_item.json | 210 ++++++------------ 1 file changed, 62 insertions(+), 148 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.json b/erpnext/manufacturing/doctype/bom_item/bom_item.json index 8a380f755b..8d4d69b09a 100644 --- a/erpnext/manufacturing/doctype/bom_item/bom_item.json +++ b/erpnext/manufacturing/doctype/bom_item/bom_item.json @@ -79,67 +79,67 @@ "unique": 0 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "operation", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Item operation", - "length": 0, - "no_copy": 0, - "options": "Operation", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "operation", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Item operation", + "length": 0, + "no_copy": 0, + "options": "Operation", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 - }, + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break_3", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -966,6 +966,7 @@ "collapsible": 0, "columns": 0, "fetch_from": "item_code.include_item_in_manufacturing", + "fieldname": "include_item_in_manufacturing", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -974,6 +975,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, + "label": "Include Item In Manufacturing", "length": 0, "no_copy": 0, "permlevel": 0, @@ -987,29 +989,6 @@ "search_index": 0, "set_only_once": 0, "translatable": 0, - "fieldname": "include_item_in_manufacturing", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Include Item In Manufacturing", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, "unique": 0 }, { @@ -1044,71 +1023,6 @@ "set_only_once": 0, "translatable": 0, "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "operation", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Item operation", - "length": 0, - "no_copy": 0, - "options": "Operation", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "allow_alternative_item", - "fieldtype": "Check", - "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Allow Alternative Item", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 } ], "has_web_view": 0, @@ -1121,7 +1035,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-12-26 15:04:56.187136", + "modified": "2018-12-28 16:38:56.529079", "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM Item", From 50f0a99330ae7cbf4354874baa06132f9bdcdc97 Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Fri, 28 Dec 2018 17:15:56 +0530 Subject: [PATCH 15/21] fix: Checks for status in employee and for date range in upload attendance. (#16279) * fix: checks for status in employee and for date range in upload attendance. 1. Earlier the status of an amployee can be set to 'Left' even though other employees are reporting to this employee, added checks to prevent this behaviour. 2. Earlier the range of dates added to the template were not checked for date of joining and relieving date. Now the range of dates added in the template are between the date of joining and relieving date. * remove "import erpnext" * fix: replace frappe.db.sql with frappe.db.get_all * fix: refactored using list comprehension * fix: query refactoring * fix: combining list comprehensions * travis debugging * fix: doc.save --- erpnext/hr/doctype/employee/employee.py | 16 ++++++--- erpnext/hr/doctype/employee/test_employee.py | 13 +++++++ .../test_upload_attendance.py | 34 +++++++++++++++++++ .../upload_attendance/upload_attendance.py | 33 ++++++++++++++---- 4 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 erpnext/hr/doctype/upload_attendance/test_upload_attendance.py diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index 66d9badd2a..d518cd8995 100755 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -13,8 +13,8 @@ from frappe.model.document import Document from erpnext.utilities.transaction_base import delete_events from frappe.utils.nestedset import NestedSet -class EmployeeUserDisabledError(frappe.ValidationError): - pass +class EmployeeUserDisabledError(frappe.ValidationError): pass +class EmployeeLeftValidationError(frappe.ValidationError): pass class Employee(NestedSet): nsm_parent_field = 'reports_to' @@ -147,8 +147,16 @@ class Employee(NestedSet): validate_email_add(self.personal_email, True) def validate_status(self): - if self.status == 'Left' and not self.relieving_date: - throw(_("Please enter relieving date.")) + if self.status == 'Left': + reports_to = frappe.db.get_all('Employee', + filters={'reports_to': self.name} + ) + if reports_to: + link_to_employees = [frappe.utils.get_link_to_form('Employee', employee.name) for employee in reports_to] + throw(_("Employee status cannot be set to 'Left' as following employees are currently reporting to this employee: ") + + ', '.join(link_to_employees), EmployeeLeftValidationError) + if not self.relieving_date: + throw(_("Please enter relieving date.")) def validate_for_enabled_user_id(self, enabled): if not self.status == 'Active': diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py index 1afb8f40b4..5a63beb283 100644 --- a/erpnext/hr/doctype/employee/test_employee.py +++ b/erpnext/hr/doctype/employee/test_employee.py @@ -7,6 +7,7 @@ import frappe import erpnext import unittest import frappe.utils +from erpnext.hr.doctype.employee.employee import EmployeeLeftValidationError test_records = frappe.get_test_records('Employee') @@ -32,6 +33,18 @@ class TestEmployee(unittest.TestCase): email_queue = frappe.db.sql("""select * from `tabEmail Queue`""", as_dict=True) self.assertTrue("Subject: Birthday Reminder" in email_queue[0].message) + def test_employee_status_left(self): + employee1 = make_employee("test_employee_1@company.com") + employee2 = make_employee("test_employee_2@company.com") + employee1_doc = frappe.get_doc("Employee", employee1) + employee2_doc = frappe.get_doc("Employee", employee2) + employee2_doc.reload() + employee2_doc.reports_to = employee1_doc.name + employee2_doc.save() + employee1_doc.reload() + employee1_doc.status = 'Left' + self.assertRaises(EmployeeLeftValidationError, employee1_doc.save) + def make_employee(user): if not frappe.db.get_value("User", user): frappe.get_doc({ diff --git a/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py b/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py new file mode 100644 index 0000000000..5ab2847dde --- /dev/null +++ b/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest +from frappe.utils import getdate +from erpnext.hr.doctype.upload_attendance.upload_attendance import get_data +from erpnext.hr.doctype.employee.test_employee import make_employee + +class TestUploadAttendance(unittest.TestCase): + def test_date_range(self): + employee = make_employee("test_employee@company.com") + employee_doc = frappe.get_doc("Employee", employee) + date_of_joining = "2018-01-02" + relieving_date = "2018-01-03" + from_date = "2018-01-01" + to_date = "2018-01-04" + employee_doc.date_of_joining = date_of_joining + employee_doc.relieving_date = relieving_date + employee_doc.save() + args = { + "from_date": from_date, + "to_date": to_date + } + data = get_data(args) + filtered_data = [] + for row in data: + if row[1] == employee: + filtered_data.append(row) + print(filtered_data) + for row in filtered_data: + self.assertTrue(getdate(row[3]) >= getdate(date_of_joining) and getdate(row[3]) <= getdate(relieving_date)) diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py index 3d080a725e..db74b102a7 100644 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py @@ -41,16 +41,28 @@ def add_header(w): return w def add_data(w, args): + data = get_data(args) + writedata(w, data) + return w + +def get_data(args): dates = get_dates(args) employees = get_active_employees() existing_attendance_records = get_existing_attendance_records(args) + data = [] for date in dates: for employee in employees: + if getdate(date) < getdate(employee.date_of_joining): + continue + if employee.relieving_date: + if getdate(date) > getdate(employee.relieving_date): + continue existing_attendance = {} if existing_attendance_records \ - and tuple([getdate(date), employee.name]) in existing_attendance_records: + and tuple([getdate(date), employee.name]) in existing_attendance_records \ + and getdate(employee.date_of_joining) >= getdate(date) \ + and getdate(employee.relieving_date) <= getdate(date): existing_attendance = existing_attendance_records[tuple([getdate(date), employee.name])] - row = [ existing_attendance and existing_attendance.name or "", employee.name, employee.employee_name, date, @@ -58,8 +70,12 @@ def add_data(w, args): existing_attendance and existing_attendance.leave_type or "", employee.company, existing_attendance and existing_attendance.naming_series or get_naming_series(), ] - w.writerow(row) - return w + data.append(row) + return data + +def writedata(w, data): + for row in data: + w.writerow(row) def get_dates(args): """get list of dates in between from date and to date""" @@ -68,8 +84,13 @@ def get_dates(args): return dates def get_active_employees(): - employees = frappe.db.sql("""select name, employee_name, company - from tabEmployee where docstatus < 2 and status = 'Active'""", as_dict=1) + employees = frappe.db.get_all('Employee', + fields=['name', 'employee_name', 'date_of_joining', 'company', 'relieving_date'], + filters={ + 'docstatus': ['<', 2], + 'status': 'Active' + } + ) return employees def get_existing_attendance_records(args): From 8f62aec2e35ed93548d7cf7f6639781b1ee6e634 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 1 Jan 2019 13:54:54 +0530 Subject: [PATCH 16/21] [Fix] Not able to delete department --- erpnext/utilities/transaction_base.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 4845e0b960..f845cef9b1 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -146,8 +146,18 @@ class TransactionBase(StatusUpdater): return ret def delete_events(ref_type, ref_name): - frappe.delete_doc("Event", frappe.db.sql_list("""select name from `tabEvent` - where ref_type=%s and ref_name=%s""", (ref_type, ref_name)), for_reload=True) + events = frappe.db.sql_list(""" SELECT + distinct `tabEvent`.name + from + `tabEvent`, `tabEvent Participants` + where + `tabEvent`.name = `tabEvent Participants`.parent + and `tabEvent Participants`.reference_doctype = %s + and `tabEvent Participants`.reference_docname = %s + """, (ref_type, ref_name)) or [] + + if events: + frappe.delete_doc("Event", events, for_reload=True) def validate_uom_is_integer(doc, uom_field, qty_fields, child_dt=None): if isinstance(qty_fields, string_types): From c186f153ff796989683c12b60ccd4a76c4a069ee Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 1 Jan 2019 14:18:14 +0530 Subject: [PATCH 17/21] Added test cases --- .../hr/doctype/department/test_department.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/department/test_department.py b/erpnext/hr/doctype/department/test_department.py index da696613f9..2eeca26e30 100644 --- a/erpnext/hr/doctype/department/test_department.py +++ b/erpnext/hr/doctype/department/test_department.py @@ -1,9 +1,24 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals +import frappe +import unittest test_ignore = ["Leave Block List"] +class TestDepartment(unittest.TestCase): + def test_remove_department_data(self): + doc = create_department("Test Department") + frappe.delete_doc('Department', doc.name) +def create_department(department_name, parent_department=None): + doc = frappe.get_doc({ + 'doctype': 'Department', + 'is_group': 0, + 'parent_department': parent_department, + 'department_name': department_name, + 'company': frappe.defaults.get_defaults().company + }).insert() + + return doc -import frappe test_records = frappe.get_test_records('Department') \ No newline at end of file From 94e35e7a7e233858a1f0670ec64ef2cabfa271eb Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Tue, 1 Jan 2019 17:55:13 +0100 Subject: [PATCH 18/21] Fix #15917 (#16311) --- erpnext/accounts/report/financial_statements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index db733dd1e1..09cf5b1d2f 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -213,7 +213,7 @@ def prepare_data(accounts, balance_must_be, period_list, company_currency): total = 0 row = frappe._dict({ "account": _(d.name), - "parent_account": _(d.parent_account), + "parent_account": _(d.parent_account) if d.parent_account else '', "indent": flt(d.indent), "year_start_date": year_start_date, "year_end_date": year_end_date, From c14c7c84e3d299341fb945c0a7294997012b450b Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 2 Jan 2019 21:28:11 +0530 Subject: [PATCH 19/21] fix: leave application and timesheet tests --- erpnext/hr/doctype/leave_application/test_leave_application.py | 2 +- erpnext/projects/doctype/timesheet/test_timesheet.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 4748011b62..a682e8b76f 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -457,7 +457,7 @@ def get_leave_period(): return frappe.get_doc(dict( name = 'Test Leave Period', doctype = 'Leave Period', - from_date = "{0}-01-01".format(now_datetime().year), + from_date = "{0}-12-01".format(now_datetime().year - 1), to_date = "{0}-12-31".format(now_datetime().year), company = "_Test Company", is_active = 1 diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index 8c84c11ae9..f1179033be 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -186,6 +186,8 @@ def make_salary_structure_for_timesheet(employee): if not frappe.db.get_value("Salary Structure Assignment", {'employee':employee, 'docstatus': 1}): + frappe.db.set_value('Employee', employee, 'date_of_joining', + add_months(nowdate(), -5)) create_salary_structure_assignment(employee, salary_structure.name) return salary_structure From 3ac57c756ba958a6c1490d55d43afa8d3b8ca1de Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Fri, 4 Jan 2019 12:57:34 +0530 Subject: [PATCH 20/21] fix: remove print statement from test case --- erpnext/hr/doctype/upload_attendance/test_upload_attendance.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py b/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py index 5ab2847dde..6e151d0e3c 100644 --- a/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py +++ b/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py @@ -29,6 +29,5 @@ class TestUploadAttendance(unittest.TestCase): for row in data: if row[1] == employee: filtered_data.append(row) - print(filtered_data) for row in filtered_data: self.assertTrue(getdate(row[3]) >= getdate(date_of_joining) and getdate(row[3]) <= getdate(relieving_date)) From 0d54271d150070bce25d801af9586d2ef7279cc6 Mon Sep 17 00:00:00 2001 From: Frappe Bot Date: Sat, 5 Jan 2019 09:11:14 +0000 Subject: [PATCH 21/21] bumped to version 11.0.3-beta.33 --- erpnext/hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 14e4f68864..3ab6752d8c 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -12,7 +12,7 @@ app_license = "GNU General Public License (v3)" source_link = "https://github.com/frappe/erpnext" develop_version = '12.x.x-develop' -staging_version = '11.0.3-beta.32' +staging_version = '11.0.3-beta.33' error_report_email = "support@erpnext.com"