Merge pull request #14701 from shreyashah115/testing-1
[minor] Blanket order
diff --git a/erpnext/accounts/doctype/finance_book/test_finance_book.py b/erpnext/accounts/doctype/finance_book/test_finance_book.py
index 771e813..8ea774f 100644
--- a/erpnext/accounts/doctype/finance_book/test_finance_book.py
+++ b/erpnext/accounts/doctype/finance_book/test_finance_book.py
@@ -2,9 +2,42 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
+from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
+
import frappe
import unittest
class TestFinanceBook(unittest.TestCase):
- pass
+ def create_finance_book(self):
+ if not frappe.db.exists("Finance Book", "_Test Finance Book"):
+ finance_book = frappe.get_doc({
+ "doctype": "Finance Book",
+ "finance_book_name": "_Test Finance Book"
+ }).insert()
+ else:
+ finance_book = frappe.get_doc("Finance Book", "_Test Finance Book")
+
+ return finance_book
+
+ def test_finance_book(self):
+ finance_book = self.create_finance_book()
+
+ # create jv entry
+ jv = make_journal_entry("_Test Bank - _TC",
+ "_Test Receivable - _TC", 100, save=False)
+
+ jv.accounts[1].update({
+ "party_type": "Customer",
+ "party": "_Test Customer USD"
+ })
+
+ jv.finance_book = finance_book.finance_book_name
+ jv.submit()
+
+ # check the Finance Book in the GL Entry
+ gl_entries = frappe.get_all("GL Entry", fields=["name", "finance_book"],
+ filters={"voucher_type": "Journal Entry", "voucher_no": jv.name})
+
+ for gl_entry in gl_entries:
+ self.assertEqual(gl_entry.finance_book, finance_book.name)
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
index 913eec8..97ab07c 100644
--- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
+++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
@@ -112,7 +112,7 @@
if max_benefits and max_benefits > 0:
have_depends_on_lwp = False
per_day_amount_total = 0
- payroll_period_days = get_payroll_period_days(on_date, on_date, employee)
+ payroll_period_days = get_payroll_period_days(on_date, on_date, employee)[0]
payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period)
# Get all salary slip flexi amount in the payroll period
diff --git a/erpnext/hr/doctype/payroll_period/payroll_period.py b/erpnext/hr/doctype/payroll_period/payroll_period.py
index e1c9e75..8990d75 100644
--- a/erpnext/hr/doctype/payroll_period/payroll_period.py
+++ b/erpnext/hr/doctype/payroll_period/payroll_period.py
@@ -67,4 +67,4 @@
holidays = get_holidays_for_employee(employee, getdate(payroll_period_dates[0][0]), getdate(payroll_period_dates[0][1]))
working_days -= len(holidays)
return working_days, actual_no_of_days
- return False
+ return False, False
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 944ba7c..63e9ab0 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -225,16 +225,16 @@
self.end_date = date_details.end_date
def check_sal_struct(self, joining_date, relieving_date):
- cond = ''
+ cond = """and sa.employee=%(employee)s and (sa.from_date <= %(start_date)s or
+ sa.from_date <= %(end_date)s or sa.from_date <= %(joining_date)s)"""
if self.payroll_frequency:
- cond = """and payroll_frequency = '%(payroll_frequency)s'""" % {"payroll_frequency": self.payroll_frequency}
+ cond += """and ss.payroll_frequency = '%(payroll_frequency)s'""" % {"payroll_frequency": self.payroll_frequency}
- st_name = frappe.db.sql("""select salary_structure from `tabSalary Structure Assignment`
- where employee=%s and (from_date <= %s or from_date <= %s or from_date <= %s)
- and docstatus = 1
- and salary_structure in (select name from `tabSalary Structure`
- where is_active = 'Yes' %s) order by from_date desc limit 1
- """, (self.employee, self.start_date, self.end_date, joining_date, cond))
+ st_name = frappe.db.sql("""select sa.salary_structure from `tabSalary Structure Assignment` sa
+ join `tabSalary Structure` ss where sa.salary_structure=ss.name
+ and sa.docstatus = 1 and ss.docstatus = 1 and ss.is_active ='Yes' %s
+ order by sa.from_date desc limit 1 """ %cond, {'employee': self.employee, 'start_date': self.start_date,
+ 'end_date': self.end_date, 'joining_date': joining_date})
if st_name:
if len(st_name) > 1: