'Creates salary slip for selected employees if already not created'

def create_salary_slips(self):

    self.check_permission(u'write')
    emp_list = self.get_emp_list()
    ss_list = []
    if emp_list:
        for emp in emp_list:
            if (not frappe.db.sql(u'select\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB name    from    `tabSalary    Slip`\n DCTB  DCTB  DCTB  DCTB  DCTB where\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB docstatus!=    2    and\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB employee    =    %s    and\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB start_date    >=    %s    and\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB end_date    <=    %s    and\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB company    =    %s\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB ', (emp[0], self.start_date, self.end_date, self.company))):
                ss = frappe.get_doc({u'doctype': u'Salary    Slip', u'salary_slip_based_on_timesheet': self.salary_slip_based_on_timesheet, u'payroll_frequency': self.payroll_frequency, u'start_date': self.start_date, u'end_date': self.end_date, u'employee': emp[0], u'employee_name': frappe.get_value(u'Employee', {u'name': emp[0]}, u'employee_name'), u'company': self.company, u'posting_date': self.posting_date})
                ss.insert()
                ss_dict = {}
                ss_dict[u'Employee    Name'] = ss.employee_name
                ss_dict[u'Total    Pay'] = fmt_money(ss.rounded_total, currency=frappe.defaults.get_global_default(u'currency'))
                ss_dict[u'Salary    Slip'] = self.format_as_links(ss.name)[0]
                ss_list.append(ss_dict)
    return self.create_log(ss_list)
