Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed Feb 22, 2017
2 parents f8cff12 + 633698a commit 10ec553
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 115 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'''
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/journal_entry/journal_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/report/balance_sheet/balance_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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)
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/report/cash_flow/cash_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


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",
Expand Down
9 changes: 5 additions & 4 deletions erpnext/accounts/report/financial_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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)"""

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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)
Expand Down
7 changes: 3 additions & 4 deletions erpnext/hr/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,10 @@ def check_sal_struct(self, joining_date, relieving_date):
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:
Expand Down
9 changes: 5 additions & 4 deletions erpnext/hr/doctype/salary_slip/test_salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down Expand Up @@ -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(),
Expand All @@ -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
Expand All @@ -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)
}
]

Expand Down
98 changes: 20 additions & 78 deletions erpnext/hr/doctype/salary_structure/salary_structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -189,56 +158,28 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "No",
"fieldname": "is_default",
"default": "Monthly",
"depends_on": "eval:(!doc.salary_slip_based_on_timesheet)",
"fieldname": "payroll_frequency",
"fieldtype": "Select",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Is Default",
"length": 0,
"no_copy": 1,
"options": "Yes\nNo",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"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,
"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_list_view": 0,
"in_standard_filter": 0,
"label": "From Date",
"label": "Payroll Frequency",
"length": 0,
"no_copy": 0,
"oldfieldname": "from_date",
"oldfieldtype": "Date",
"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": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
Expand All @@ -248,23 +189,24 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "to_date",
"fieldtype": "Date",
"hidden": 0,
"default": "No",
"fieldname": "is_default",
"fieldtype": "Select",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "To Date",
"label": "Is Default",
"length": 0,
"no_copy": 0,
"oldfieldname": "to_date",
"oldfieldtype": "Date",
"no_copy": 1,
"options": "Yes\nNo",
"permlevel": 0,
"print_hide": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 5 additions & 6 deletions erpnext/hr/doctype/salary_structure/salary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, getdate
from frappe import _
from frappe.model.mapper import get_mapped_doc
from frappe.model.document import Document
Expand All @@ -29,13 +28,13 @@ def get_ss_values(self,employee):
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."))

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):
Expand Down
5 changes: 3 additions & 2 deletions erpnext/hr/doctype/salary_structure/test_salary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -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(),
Expand All @@ -108,11 +107,13 @@ def get_employee_details():
return [{"employee": frappe.get_value("Employee", {"employee_name":"[email protected]"}, "name"),
"base": 25000,
"variable": 5000,
"from_date": add_months(nowdate(),-1),
"idx": 1
},
{"employee": frappe.get_value("Employee", {"employee_name":"[email protected]"}, "name"),
"base": 15000,
"variable": 100,
"from_date": add_months(nowdate(),-1),
"idx": 2
}
]
Expand Down
Loading

0 comments on commit 10ec553

Please sign in to comment.