Merge branch 'develop'

This commit is contained in:
Rushabh Mehta 2016-07-29 18:55:48 +05:30
commit 3e001b5fac
13 changed files with 108 additions and 13 deletions

View File

@ -2,7 +2,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
__version__ = '7.0.10' __version__ = '7.0.11'
def get_default_company(user=None): def get_default_company(user=None):
'''Get default company for user''' '''Get default company for user'''

View File

@ -1 +1 @@
{% include "erpnext/accounts/report/accounts_receivable/accounts_receivable.html" %} {% include "accounts/report/accounts_receivable/accounts_receivable.html" %}

View File

@ -1 +1 @@
{% include "erpnext/accounts/report/accounts_receivable/accounts_receivable.html" %} {% include "accounts/report/accounts_receivable/accounts_receivable.html" %}

View File

@ -1 +1 @@
{% include "erpnext/accounts/report/accounts_receivable/accounts_receivable.html" %} {% include "accounts/report/accounts_receivable/accounts_receivable.html" %}

View File

@ -1 +1 @@
{% include "erpnext/accounts/report/financial_statements.html" %} {% include "accounts/report/financial_statements.html" %}

View File

@ -1 +1 @@
{% include "erpnext/accounts/report/financial_statements.html" %} {% include "accounts/report/financial_statements.html" %}

View File

@ -1 +1 @@
{% include "erpnext/accounts/report/financial_statements.html" %} {% include "accounts/report/financial_statements.html" %}

View File

@ -32,6 +32,7 @@ def setup_data():
setup_employee() setup_employee()
setup_salary_structure() setup_salary_structure()
setup_salary_structure_for_timesheet() setup_salary_structure_for_timesheet()
setup_leave_allocation()
setup_mode_of_payment() setup_mode_of_payment()
setup_account_to_expense_type() setup_account_to_expense_type()
setup_user_roles() setup_user_roles()
@ -430,3 +431,23 @@ def setup_pos_profile():
}) })
pos.insert() pos.insert()
def setup_leave_allocation():
year = now_datetime().year
for employee in frappe.get_all('Employee', fields=['name']):
leave_types = frappe.get_all("Leave Type", fields=['name', 'max_days_allowed'])
for leave_type in leave_types:
if not leave_type.max_days_allowed:
leave_type.max_days_allowed = 10
leave_allocation = frappe.get_doc({
"doctype": "Leave Allocation",
"employee": employee.name,
"from_date": "{0}-01-01".format(year),
"to_date": "{0}-12-31".format(year),
"leave_type": leave_type.name,
"new_leaves_allocated": random.randint(1, int(leave_type.max_days_allowed))
})
leave_allocation.insert()
leave_allocation.submit()
frappe.db.commit()

View File

@ -1,16 +1,20 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
import random import random
from frappe.utils import random_string from frappe.utils import random_string, add_days
from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet
from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice
from frappe.utils.make_random import how_many, get_random from frappe.utils.make_random import how_many, get_random
from erpnext.hr.doctype.expense_claim.expense_claim import get_expense_approver, make_bank_entry from erpnext.hr.doctype.expense_claim.expense_claim import get_expense_approver, make_bank_entry
from erpnext.hr.doctype.leave_application.leave_application import get_leave_balance_on, OverlapError
def work(): def work():
frappe.set_user(frappe.db.get_global('demo_hr_user')) frappe.set_user(frappe.db.get_global('demo_hr_user'))
year, month = frappe.flags.current_date.strftime("%Y-%m").split("-") year, month = frappe.flags.current_date.strftime("%Y-%m").split("-")
mark_attendance()
make_leave_application()
# process payroll # process payroll
if not frappe.db.get_value("Salary Slip", {"month": month, "fiscal_year": year}): if not frappe.db.get_value("Salary Slip", {"month": month, "fiscal_year": year}):
process_payroll = frappe.get_doc("Process Payroll", "Process Payroll") process_payroll = frappe.get_doc("Process Payroll", "Process Payroll")
@ -124,3 +128,52 @@ def make_sales_invoice_for_timesheet(name):
sales_invoice.insert() sales_invoice.insert()
sales_invoice.submit() sales_invoice.submit()
frappe.db.commit() frappe.db.commit()
def make_leave_application():
allocated_leaves = frappe.get_all("Leave Allocation", fields=['employee', 'leave_type'])
for allocated_leave in allocated_leaves:
leave_balance = get_leave_balance_on(allocated_leave.employee, allocated_leave.leave_type, frappe.flags.current_date,
consider_all_leaves_in_the_allocation_period=True)
if leave_balance != 0:
if leave_balance == 1:
to_date = frappe.flags.current_date
else:
to_date = add_days(frappe.flags.current_date, random.randint(0, leave_balance-1))
leave_application = frappe.get_doc({
"doctype": "Leave Application",
"employee": allocated_leave.employee,
"from_date": frappe.flags.current_date,
"to_date": to_date,
"leave_type": allocated_leave.leave_type,
"status": "Approved"
})
try:
leave_application.insert()
leave_application.submit()
frappe.db.commit()
except (OverlapError):
frappe.db.rollback()
def mark_attendance():
att_date = frappe.flags.current_date
for employee in frappe.get_all('Employee', fields=['name'], filters = {'status': 'Active'}):
if not frappe.db.get_value("Attendance", {"employee": employee.name, "att_date": att_date}):
attendance = frappe.get_doc({
"doctype": "Attendance",
"employee": employee.name,
"att_date": att_date
})
leave = frappe.db.sql("""select name from `tabLeave Application`
where employee = %s and %s between from_date and to_date and status = 'Approved'
and docstatus = 1""", (employee.name, att_date))
if leave:
attendance.status = "Absent"
else:
attendance.status = "Present"
attendance.save()
attendance.submit()
frappe.db.commit()

View File

@ -8,4 +8,6 @@ Checkout the following Video Tutorials to understand how to enable social logins
* for Google - https://www.youtube.com/watch?v=w_EAttrE9sw * for Google - https://www.youtube.com/watch?v=w_EAttrE9sw
* for GitHub - https://www.youtube.com/watch?v=bG71DxxkVjQ * for GitHub - https://www.youtube.com/watch?v=bG71DxxkVjQ
For Google the *Authorized redirect URI* is [yoursite]/api/method/frappe.www.login.login_via_google
{next} {next}

View File

@ -15,7 +15,7 @@ frappe.ui.form.on('Homepage Featured Product', {
method: 'frappe.client.get_value', method: 'frappe.client.get_value',
args: { args: {
'doctype': 'Item', 'doctype': 'Item',
'filters': featured_product.item_code, 'filters': {'name': featured_product.item_code},
'fieldname': [ 'fieldname': [
'item_name', 'item_name',
'web_long_description', 'web_long_description',

View File

@ -179,6 +179,22 @@ erpnext.utils.map_current_doc = function(opts) {
} }
} }
frappe.form.link_formatters['Item'] = function(value, doc) {
if(doc.item_name && doc.item_name !== value) {
return value + ': ' + doc.item_name;
} else {
return value;
}
}
frappe.form.link_formatters['Employee'] = function(value, doc) {
if(doc.employee_name && doc.employee_name !== value) {
return value + ': ' + doc.employee_name;
} else {
return value;
}
}
// add description on posting time // add description on posting time
$(document).on('app_ready', function() { $(document).on('app_ready', function() {
if(!frappe.datetime.is_timezone_same()) { if(!frappe.datetime.is_timezone_same()) {

View File

@ -121,6 +121,9 @@ class Item(WebsiteGenerator):
if not self.is_stock_item or self.has_serial_no or self.has_batch_no: if not self.is_stock_item or self.has_serial_no or self.has_batch_no:
return return
if not self.valuation_rate and self.standard_rate:
self.valuation_rate = self.standard_rate
if not self.valuation_rate: if not self.valuation_rate:
frappe.throw(_("Valuation Rate is mandatory if Opening Stock entered")) frappe.throw(_("Valuation Rate is mandatory if Opening Stock entered"))