From 5f5457085ee288a8fcc699ea06ce30adaab8c3af Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Mon, 6 Feb 2017 10:48:43 +0530 Subject: [PATCH 1/7] Joining date validation removed from Salary Structure --- erpnext/hr/doctype/salary_slip/salary_slip.py | 7 +- .../doctype/salary_slip/test_salary_slip.py | 9 +- .../salary_structure/salary_structure.json | 122 +++++------------- .../salary_structure/salary_structure.py | 10 +- .../salary_structure/test_salary_structure.py | 5 +- .../salary_structure_employee.json | 77 ++++++++++- erpnext/patches.txt | 3 +- ...dates_from_salary_structure_to_employee.py | 9 ++ .../doctype/timesheet/test_timesheet.py | 5 +- 9 files changed, 131 insertions(+), 116 deletions(-) create mode 100644 erpnext/patches/v7_2/move_dates_from_salary_structure_to_employee.py diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index eeec6e8e769..daa86a85979 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -156,11 +156,10 @@ class SalarySlip(TransactionBase): cond = """and payroll_frequency = '%(payroll_frequency)s'""" % {"payroll_frequency": self.payroll_frequency} st_name = frappe.db.sql("""select parent from `tabSalary Structure Employee` - where employee=%s + where employee=%s and (from_date <= %s or from_date <= %s) + and (to_date is null or to_date >= %s or to_date >= %s) and parent in (select name from `tabSalary Structure` - where is_active = 'Yes' - and (from_date <= %s or from_date <= %s) - and (to_date is null or to_date >= %s or to_date >= %s) %s) + where is_active = 'Yes'%s) """% ('%s', '%s', '%s','%s','%s', cond),(self.employee, self.start_date, joining_date, self.end_date, relieving_date)) if st_name: diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index 54faa640536..1a4734772ab 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -7,7 +7,7 @@ import frappe import erpnext import calendar from erpnext.accounts.utils import get_fiscal_year -from frappe.utils import getdate, nowdate, add_days +from frappe.utils import getdate, nowdate, add_days, add_months from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip from erpnext.hr.doctype.process_payroll.test_process_payroll import get_salary_component_account from erpnext.hr.doctype.process_payroll.process_payroll import get_month_details @@ -257,7 +257,6 @@ def make_salary_structure(sal_struct, payroll_frequency, employee): "doctype": "Salary Structure", "name": sal_struct, "company": erpnext.get_default_company(), - "from_date": nowdate(), "employees": get_employee_details(employee), "earnings": get_earnings_component(), "deductions": get_deductions_component(), @@ -270,7 +269,8 @@ def make_salary_structure(sal_struct, payroll_frequency, employee): sal_struct.append("employees", {"employee": employee, "employee_name": employee, "base": 32000, - "variable": 3200 + "variable": 3200, + "from_date": add_months(nowdate(),-1) }) sal_struct.save() sal_struct = sal_struct.name @@ -279,7 +279,8 @@ def make_salary_structure(sal_struct, payroll_frequency, employee): def get_employee_details(employee): return [{"employee": employee, "base": 25000, - "variable": 5000 + "variable": 5000, + "from_date": add_months(nowdate(),-1) } ] diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.json b/erpnext/hr/doctype/salary_structure/salary_structure.json index 8db8e93ef77..526d8373359 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.json +++ b/erpnext/hr/doctype/salary_structure/salary_structure.json @@ -95,37 +95,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "Monthly", - "depends_on": "eval:(!doc.salary_slip_based_on_timesheet)", - "fieldname": "payroll_frequency", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Payroll Frequency", - "length": 0, - "no_copy": 0, - "options": "\nMonthly\nFortnightly\nBimonthly\nWeekly\nDaily", - "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, - "unique": 0 - }, { "allow_on_submit": 0, "bold": 0, @@ -184,6 +153,37 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "Monthly", + "depends_on": "eval:(!doc.salary_slip_based_on_timesheet)", + "fieldname": "payroll_frequency", + "fieldtype": "Select", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Payroll Frequency", + "length": 0, + "no_copy": 0, + "options": "\nMonthly\nFortnightly\nBimonthly\nWeekly\nDaily", + "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, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -214,64 +214,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "from_date", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "From Date", - "length": 0, - "no_copy": 0, - "oldfieldname": "from_date", - "oldfieldtype": "Date", - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "to_date", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "To Date", - "length": 0, - "no_copy": 0, - "oldfieldname": "to_date", - "oldfieldtype": "Date", - "permlevel": 0, - "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, - "unique": 0 - }, { "allow_on_submit": 0, "bold": 0, @@ -894,7 +836,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-12-14 02:02:10.848614", + "modified": "2017-02-06 01:32:16.815429", "modified_by": "Administrator", "module": "HR", "name": "Salary Structure", diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index 13622c35b3e..cfecd63221f 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -4,8 +4,7 @@ from __future__ import unicode_literals import frappe -from frappe.utils import cstr, flt, getdate, cint -from frappe.model.naming import make_autoname +from frappe.utils import flt, cint from frappe import _ from frappe.model.mapper import get_mapped_doc from frappe.model.document import Document @@ -15,7 +14,6 @@ class SalaryStructure(Document): def validate(self): self.validate_amount() - self.validate_joining_date() for e in self.get('employees'): set_employee_name(e) @@ -29,12 +27,6 @@ class SalaryStructure(Document): def validate_amount(self): if flt(self.net_pay) < 0 and self.salary_slip_based_on_timesheet: frappe.throw(_("Net pay cannot be negative")) - - def validate_joining_date(self): - for e in self.get('employees'): - joining_date = getdate(frappe.db.get_value("Employee", e.employee, "date_of_joining")) - if getdate(self.from_date) < joining_date: - frappe.throw(_("From Date in Salary Structure cannot be lesser than Employee Joining Date.")) @frappe.whitelist() diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py index fe88d9afcfc..7d761fd6986 100644 --- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py @@ -6,7 +6,7 @@ import frappe import unittest import erpnext from frappe.utils.make_random import get_random -from frappe.utils import nowdate, add_days, add_years, getdate +from frappe.utils import nowdate, add_days, add_years, getdate, add_months from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip from erpnext.hr.doctype.salary_slip.test_salary_slip \ import make_earning_salary_component, make_deduction_salary_component @@ -94,7 +94,6 @@ def make_salary_structure(sal_struct): "doctype": "Salary Structure", "name": sal_struct, "company": erpnext.get_default_company(), - "from_date": nowdate(), "employees": get_employee_details(), "earnings": get_earnings_component(), "deductions": get_deductions_component(), @@ -108,11 +107,13 @@ def get_employee_details(): return [{"employee": frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "base": 25000, "variable": 5000, + "from_date": add_months(nowdate(),-1), "idx": 1 }, {"employee": frappe.get_value("Employee", {"employee_name":"test_employee_2@salary.com"}, "name"), "base": 15000, "variable": 100, + "from_date": add_months(nowdate(),-1), "idx": 2 } ] diff --git a/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json b/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json index aae33e3cac5..afbbf8f56b9 100644 --- a/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json +++ b/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json @@ -10,11 +10,13 @@ "doctype": "DocType", "document_type": "", "editable_grid": 1, + "engine": "InnoDB", "fields": [ { "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "employee", "fieldtype": "Link", "hidden": 0, @@ -22,6 +24,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Employee", "length": 0, "no_copy": 0, @@ -31,6 +34,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 1, "search_index": 0, @@ -41,6 +45,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "employee_name", "fieldtype": "Data", "hidden": 0, @@ -48,6 +53,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Employee Name", "length": 0, "no_copy": 0, @@ -56,6 +62,7 @@ "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, @@ -66,14 +73,16 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "base", - "fieldtype": "Currency", + "columns": 0, + "fieldname": "from_date", + "fieldtype": "Date", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, - "label": "Base", + "in_standard_filter": 0, + "label": "From Date", "length": 0, "no_copy": 0, "permlevel": 0, @@ -81,6 +90,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 1, "search_index": 0, @@ -91,6 +101,63 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, + "fieldname": "to_date", + "fieldtype": "Date", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "To Date", + "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, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "base", + "fieldtype": "Currency", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Base", + "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": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, "fieldname": "variable", "fieldtype": "Currency", "hidden": 0, @@ -98,6 +165,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Variable", "length": 0, "no_copy": 0, @@ -106,6 +174,7 @@ "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, @@ -123,7 +192,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-08-11 12:18:14.526977", + "modified": "2017-02-06 01:32:38.183131", "modified_by": "Administrator", "module": "HR", "name": "Salary Structure Employee", diff --git a/erpnext/patches.txt b/erpnext/patches.txt index b997dfc13b2..4c5cb7fb93c 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -363,4 +363,5 @@ erpnext.patches.v7_2.update_website_for_variant erpnext.patches.v7_2.update_doctype_status erpnext.patches.v7_2.update_salary_slips erpnext.patches.v7_2.set_null_value_to_fields -erpnext.patches.v7_2.update_abbr_in_salary_slips \ No newline at end of file +erpnext.patches.v7_2.update_abbr_in_salary_slips +erpnext.patches.v7_2.move_dates_from_salary_structure_to_employee \ No newline at end of file diff --git a/erpnext/patches/v7_2/move_dates_from_salary_structure_to_employee.py b/erpnext/patches/v7_2/move_dates_from_salary_structure_to_employee.py new file mode 100644 index 00000000000..98e076e060e --- /dev/null +++ b/erpnext/patches/v7_2/move_dates_from_salary_structure_to_employee.py @@ -0,0 +1,9 @@ +import frappe + +def execute(): + frappe.reload_doc('hr', 'doctype', 'salary_structure_employee') + salary_structures = frappe.db.sql("""select name, to_date, from_date from `tabSalary Structure`""", as_dict=True) + + for salary_structure in salary_structures: + frappe.db.sql(""" update `tabSalary Structure Employee` set from_date = %s, to_date = %s + where parent = %s """, (salary_structure.from_date, salary_structure.to_date or 'null', salary_structure.name)) \ No newline at end of file diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index 11d0b1ce6ee..1db0610e89c 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -7,7 +7,7 @@ import frappe import unittest import datetime from frappe.utils.make_random import get_random -from frappe.utils import now_datetime, nowdate, add_days +from frappe.utils import now_datetime, nowdate, add_days, add_months from erpnext.projects.doctype.timesheet.timesheet import OverlapError from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice @@ -88,7 +88,8 @@ def make_salary_structure(employee): es = salary_structure.append('employees', { "employee": employee, - "base": 1200 + "base": 1200, + "from_date": add_months(nowdate(),-1) }) From e17519accbecdc2dbca04681ad30328d27d70aeb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 20 Feb 2017 19:30:44 +0530 Subject: [PATCH 2/7] Update salary_structure.py --- erpnext/hr/doctype/salary_structure/salary_structure.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index cfecd63221f..828962ef0e4 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -14,6 +14,7 @@ class SalaryStructure(Document): def validate(self): self.validate_amount() + self.validate_joining_date() for e in self.get('employees'): set_employee_name(e) @@ -27,7 +28,13 @@ class SalaryStructure(Document): def validate_amount(self): if flt(self.net_pay) < 0 and self.salary_slip_based_on_timesheet: frappe.throw(_("Net pay cannot be negative")) - + + def validate_joining_date(self): + for e in self.get('employees'): + joining_date = getdate(frappe.db.get_value("Employee", e.employee, "date_of_joining")) + if e.from_date and getdate(e.from_date) < joining_date: + frappe.throw(_("From Date {0} for Employee {1} cannot be before employee's joining Date {2}") + .format(e.from_date, e.employee, joining_date)) @frappe.whitelist() def make_salary_slip(source_name, target_doc = None, employee = None, as_print = False, print_format = None): From 7056ce54d71d376ec4a059795a592cd578d564ef Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 20 Feb 2017 23:28:47 +0530 Subject: [PATCH 3/7] Update salary_structure.py --- erpnext/hr/doctype/salary_structure/salary_structure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index 828962ef0e4..b9f246a47ce 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -from frappe.utils import flt, cint +from frappe.utils import flt, cint, getdate from frappe import _ from frappe.model.mapper import get_mapped_doc from frappe.model.document import Document From 6e1a2b16a534ad342950f4ca2ea4e109e5f7b28f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 21 Feb 2017 13:11:02 +0530 Subject: [PATCH 4/7] Company, Currency, Conversion Rate fields are mandatory in BOM --- erpnext/manufacturing/doctype/bom/bom.json | 10 +++++----- erpnext/manufacturing/doctype/bom/bom.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json index c2c9b642a53..7e4b7ea7f6c 100644 --- a/erpnext/manufacturing/doctype/bom/bom.json +++ b/erpnext/manufacturing/doctype/bom/bom.json @@ -323,7 +323,7 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 0, + "reqd": 1, "search_index": 0, "set_only_once": 0, "unique": 0 @@ -378,7 +378,7 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 0, + "reqd": 1, "search_index": 0, "set_only_once": 0, "unique": 0 @@ -976,7 +976,7 @@ "read_only": 0, "remember_last_selected_value": 1, "report_hide": 0, - "reqd": 0, + "reqd": 1, "search_index": 0, "set_only_once": 0, "unique": 0 @@ -1271,8 +1271,8 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-11-21 17:06:49.349654", - "modified_by": "rohit@erpnext.com", + "modified": "2017-02-21 13:10:27.394012", + "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM", "owner": "Administrator", diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index f4fed6e097f..53398ea0abb 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -321,9 +321,9 @@ class BOM(Document): if d.bom_no: d.rate = self.get_bom_unitcost(d.bom_no) - d.base_rate = d.rate * self.conversion_rate + d.base_rate = flt(d.rate) * flt(self.conversion_rate) d.amount = flt(d.rate, self.precision("rate", d)) * flt(d.qty, self.precision("qty", d)) - d.base_amount = d.amount * self.conversion_rate + d.base_amount = d.amount * flt(self.conversion_rate) d.qty_consumed_per_unit = flt(d.qty, self.precision("qty", d)) / flt(self.quantity, self.precision("quantity")) total_rm_cost += d.amount base_total_rm_cost += d.base_amount From 49523d7f80de26d92bd83c03e31c53cb04c382e5 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 21 Feb 2017 14:20:26 +0530 Subject: [PATCH 5/7] [Fix] Company fiscal year issue in financial statement --- erpnext/accounts/report/balance_sheet/balance_sheet.py | 2 +- erpnext/accounts/report/cash_flow/cash_flow.py | 2 +- erpnext/accounts/report/financial_statements.py | 9 +++++---- .../profit_and_loss_statement.py | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py index 5ff8e3e2283..7e57dce67a7 100644 --- a/erpnext/accounts/report/balance_sheet/balance_sheet.py +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py @@ -8,7 +8,7 @@ from frappe.utils import flt, cint from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data) def execute(filters=None): - period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity) + period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.company) asset = get_data(filters.company, "Asset", "Debit", period_list, only_current_fiscal_year=False) liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False) diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py index 182878af37a..d4d22525cb1 100644 --- a/erpnext/accounts/report/cash_flow/cash_flow.py +++ b/erpnext/accounts/report/cash_flow/cash_flow.py @@ -10,7 +10,7 @@ from erpnext.accounts.utils import get_fiscal_year def execute(filters=None): - period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity) + period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.company) operation_accounts = { "section_name": "Operations", diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index bc4a220faa1..695503749a1 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -8,7 +8,7 @@ from frappe import _ from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff, add_months, add_days, formatdate, cint) -def get_period_list(from_fiscal_year, to_fiscal_year, periodicity): +def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, company): """Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label} Periodicity can be (Yearly, Quarterly, Monthly)""" @@ -50,7 +50,7 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity): # if a fiscal year ends before a 12 month period period.to_date = year_end_date - period.to_date_fiscal_year = get_date_fiscal_year(period.to_date) + period.to_date_fiscal_year = get_date_fiscal_year(period.to_date, company) period_list.append(period) @@ -142,15 +142,16 @@ def calculate_values(accounts_by_name, gl_entries_by_account, period_list, accum if entry.posting_date <= period.to_date: if (accumulated_values or entry.posting_date >= period.from_date) and \ (entry.fiscal_year == period.to_date_fiscal_year or not ignore_accumulated_values_for_fy): + frappe.errprint([entry.fiscal_year, period.to_date_fiscal_year]) d[period.key] = d.get(period.key, 0.0) + flt(entry.debit) - flt(entry.credit) if entry.posting_date < period_list[0].year_start_date: d["opening_balance"] = d.get("opening_balance", 0.0) + flt(entry.debit) - flt(entry.credit) -def get_date_fiscal_year(date): +def get_date_fiscal_year(date, company): from erpnext.accounts.utils import get_fiscal_year - return get_fiscal_year(date)[0] + return get_fiscal_year(date, company=company)[0] def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values): """accumulate children's values in parent accounts""" diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py index 747eb43006d..e12fa063fb3 100644 --- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py @@ -8,7 +8,7 @@ from frappe.utils import flt from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data) def execute(filters=None): - period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity) + period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.company) income = get_data(filters.company, "Income", "Credit", period_list, filters = filters, accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True) From a8fa10d2a98780bb33c36fa678e5e192c909e598 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Wed, 22 Feb 2017 14:50:48 +0530 Subject: [PATCH 6/7] [minor] minor fixes for journal entry get_exchange_rate trigger --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 2 +- erpnext/accounts/doctype/journal_entry/journal_entry.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index c98e77fdd24..add3e54d79d 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -38,7 +38,7 @@ frappe.ui.form.on("Journal Entry", { }, posting_date: function(frm) { - if(!frm.doc.multi_currency) return; + if(!frm.doc.multi_currency || !frm.doc.posting_date) return; $.each(frm.doc.accounts || [], function(i, row) { erpnext.journal_entry.set_exchange_rate(frm, row.doctype, row.name); diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 5cf2d9277cb..0f9b5d34bbc 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -832,7 +832,7 @@ def get_account_balance_and_party_type(account, date, company, debit=None, credi # Added posting_date as one of the parameters of get_exchange_rate @frappe.whitelist() -def get_exchange_rate(posting_date, account, account_currency=None, company=None, +def get_exchange_rate(posting_date, account=None, account_currency=None, company=None, reference_type=None, reference_name=None, debit=None, credit=None, exchange_rate=None): from erpnext.setup.utils import get_exchange_rate account_details = frappe.db.get_value("Account", account, From 633698affc0b5b9ada51049dc1f711755b83a630 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 22 Feb 2017 15:35:27 +0600 Subject: [PATCH 7/7] bumped to version 7.2.23 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index e9be38a791b..cd1d288345d 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import frappe -__version__ = '7.2.22' +__version__ = '7.2.23' def get_default_company(user=None): '''Get default company for user'''