Rushabh Mehta | dc8067e | 2016-06-29 18:38:32 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
| 2 | import frappe |
| 3 | from frappe.utils import random_string |
| 4 | |
| 5 | def 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() |