blob: 8196701d75bd013d2f52fb65c06d6f49a37a8652 [file] [log] [blame]
Rushabh Mehtadc8067e2016-06-29 18:38:32 +05301from __future__ import unicode_literals
2import frappe
3from frappe.utils import random_string
4
5def work():
6 frappe.set_user(frappe.db.get_global('demo_hr_user'))
7
8 year, month = frappe.flags.current_date.strftime("%Y-%m").split("-")
9
10 # process payroll
11 if not frappe.db.get_value("Salary Slip", {"month": month, "fiscal_year": year}):
12 process_payroll = frappe.get_doc("Process Payroll", "Process Payroll")
13 process_payroll.company = frappe.flags.company
14 process_payroll.month = month
15 process_payroll.fiscal_year = year
16 process_payroll.create_sal_slip()
17 process_payroll.submit_salary_slip()
18 r = process_payroll.make_journal_entry(frappe.get_value('Account',
19 {'account_name': 'Salary'}))
20
21 journal_entry = frappe.get_doc(r)
22 journal_entry.cheque_no = random_string(10)
23 journal_entry.cheque_date = frappe.flags.current_date
24 journal_entry.posting_date = frappe.flags.current_date
25 journal_entry.insert()
26 journal_entry.submit()