Merge branch 'hotfix' into validate_iban

This commit is contained in:
Nabin Hait
2019-04-23 18:39:12 +05:30
committed by GitHub
30 changed files with 3910 additions and 197 deletions

View File

@@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides from erpnext.hooks import regional_overrides
from frappe.utils import getdate from frappe.utils import getdate
__version__ = '11.1.21' __version__ = '11.1.22'
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,6 +1,6 @@
{ {
"country_code": "de", "country_code": "de",
"name": "Germany - Kontenplan SKR04", "name": "SKR04 ohne Kontonummern",
"tree": { "tree": {
"Bilanz - Aktiva": { "Bilanz - Aktiva": {
"Anlageverm\u00f6gen": { "Anlageverm\u00f6gen": {
@@ -1383,8 +1383,7 @@
"Sonstige Zinsen und \u00e4hnliche Ertr\u00e4ge 1": { "Sonstige Zinsen und \u00e4hnliche Ertr\u00e4ge 1": {
"Diskontertr\u00e4ge": {}, "Diskontertr\u00e4ge": {},
"Diskontertr\u00e4ge aus verbundenen Unternehmen": {}, "Diskontertr\u00e4ge aus verbundenen Unternehmen": {},
"Laufende Ertr\u00e4ge aus Anteilen an Kapitalgesellschaften 100% / 50% steuerfrei": {}, "Laufende Ertr\u00e4ge aus Anteilen an Kapitalgesellschaften 100% / 50% steuerfrei": {},
"Laufende Ertr\u00e4ge aus Anteilen an Kapitalgesellschaften 100% / 50% steuerfrei": {},
"Sonstige Zinsen und \u00e4hnliche Ertr\u00e4ge 2": {}, "Sonstige Zinsen und \u00e4hnliche Ertr\u00e4ge 2": {},
"Sonstige Zinsen und \u00e4hnliche Ertr\u00e4ge aus verbundenen Unternehmen": {}, "Sonstige Zinsen und \u00e4hnliche Ertr\u00e4ge aus verbundenen Unternehmen": {},
"Sonstige Zinsertr\u00e4ge": {}, "Sonstige Zinsertr\u00e4ge": {},
@@ -1703,4 +1702,4 @@
"root_type": "Asset" "root_type": "Asset"
} }
} }
} }

View File

@@ -38,24 +38,24 @@
"Kas": { "Kas": {
"Kas Mata Uang Lain": { "Kas Mata Uang Lain": {
"Kas USD": { "Kas USD": {
"account_number": "1112.0010", "account_number": "1112.001",
"account_type": "Cash" "account_type": "Cash"
}, },
"account_number": "1112.000" "account_number": "1112.000"
}, },
"Kas Rupiah": { "Kas Rupiah": {
"Kas Besar": { "Kas Besar": {
"account_number": "1111.0020", "account_number": "1111.002",
"account_type": "Cash" "account_type": "Cash"
}, },
"Kas Kecil": { "Kas Kecil": {
"account_number": "1111.0010", "account_number": "1111.001",
"account_type": "Cash" "account_type": "Cash"
}, },
"account_number": "1111.000", "account_number": "1111.000",
"account_type": "Cash" "account_type": "Cash"
}, },
"account_number": "1110.0000" "account_number": "1110.000"
}, },
"Pendapatan Yang Akan di Terima": { "Pendapatan Yang Akan di Terima": {
"Pendapatan Yang di Terima": { "Pendapatan Yang di Terima": {
@@ -98,7 +98,7 @@
}, },
"account_number": "1130.000" "account_number": "1130.000"
}, },
"account_number": "1100.0000" "account_number": "1100.000"
}, },
"Aktiva Tetap": { "Aktiva Tetap": {
"Aktiva": { "Aktiva": {
@@ -121,20 +121,20 @@
"Investasi": { "Investasi": {
"Investasi": { "Investasi": {
"Deposito": { "Deposito": {
"account_number": "1231.003", "account_number": "1231.300",
"is_group": 1 "is_group": 1
}, },
"Investai Saham": { "Investasi Saham": {
"Investasi Saham": { "Investasi Saham": {
"account_number": "1231.0011" "account_number": "1231.101"
}, },
"account_number": "1231.001" "account_number": "1231.100"
}, },
"Investasi Perumahan": { "Investasi Perumahan": {
"Investasi Perumahan": { "Investasi Perumahan": {
"account_number": "1231.0021" "account_number": "1231.201"
}, },
"account_number": "1231.002" "account_number": "1231.200"
}, },
"account_number": "1231.000" "account_number": "1231.000"
}, },
@@ -142,7 +142,7 @@
}, },
"account_number": "1200.000" "account_number": "1200.000"
}, },
"account_number": "1000.0000", "account_number": "1000.000",
"root_type": "Asset" "root_type": "Asset"
}, },
"Beban": { "Beban": {
@@ -684,4 +684,4 @@
"root_type": "Income" "root_type": "Income"
} }
} }
} }

View File

@@ -3511,6 +3511,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "clearance_date", "fieldname": "clearance_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 1, "hidden": 1,
@@ -3543,6 +3544,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "col_br_payments", "fieldname": "col_br_payments",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -3880,7 +3882,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "1", "default": "",
"fetch_if_empty": 0, "fetch_if_empty": 0,
"fieldname": "allocate_advances_automatically", "fieldname": "allocate_advances_automatically",
"fieldtype": "Check", "fieldtype": "Check",
@@ -4901,7 +4903,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2019-04-11 16:08:22.288425", "modified": "2019-04-22 12:45:49.728359",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Purchase Invoice", "name": "Purchase Invoice",
@@ -5016,4 +5018,4 @@
"track_changes": 1, "track_changes": 1,
"track_seen": 0, "track_seen": 0,
"track_views": 0 "track_views": 0
} }

View File

@@ -3630,7 +3630,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "1", "default": "",
"fetch_if_empty": 0, "fetch_if_empty": 0,
"fieldname": "allocate_advances_automatically", "fieldname": "allocate_advances_automatically",
"fieldtype": "Check", "fieldtype": "Check",
@@ -5816,7 +5816,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2019-04-10 16:10:34.266458", "modified": "2019-04-22 12:45:41.109345",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice", "name": "Sales Invoice",

View File

@@ -107,8 +107,8 @@
<thead> <thead>
<tr> <tr>
{% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %} {% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %}
<th style="width: 9%">{%= __("Date") %}</th> <th style="width: 10%">{%= __("Date") %}</th>
<th style="width: 5%">{%= __("Age (Days)") %}</th> <th style="width: 4%">{%= __("Age (Days)") %}</th>
{% if(report.report_name === "Accounts Receivable" && filters.show_sales_person_in_print) { %} {% if(report.report_name === "Accounts Receivable" && filters.show_sales_person_in_print) { %}
<th style="width: 16%">{%= __("Reference") %}</th> <th style="width: 16%">{%= __("Reference") %}</th>
@@ -206,7 +206,7 @@
{% if(!filters.show_pdc_in_print) { %} {% if(!filters.show_pdc_in_print) { %}
<td></td> <td></td>
{% } %} {% } %}
{% if(report.report_name === "Accounts Receivable") { %} {% if(report.report_name === "Accounts Receivable" && filters.show_sales_person_in_print) { %}
<td></td> <td></td>
{% } %} {% } %}
<td></td> <td></td>

View File

@@ -1,23 +1,27 @@
{ {
"add_total_row": 0, "add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2017-12-27 16:15:52.615453", "creation": "2017-12-27 16:15:52.615453",
"disable_prepared_report": 0,
"disabled": 0, "disabled": 0,
"docstatus": 0, "docstatus": 0,
"doctype": "Report", "doctype": "Report",
"idx": 0, "idx": 0,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2017-12-27 16:46:54.422356", "modified": "2019-04-19 10:50:36.061588",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Share Ledger", "name": "Share Ledger",
"owner": "Administrator", "owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Share Transfer", "ref_doctype": "Share Transfer",
"report_name": "Share Ledger", "report_name": "Share Ledger",
"report_type": "Script Report", "report_type": "Script Report",
"roles": [ "roles": [
{ {
"role": "Administrator" "role": "Administrator"
},
{
"role": "System Manager"
} }
] ]
} }

View File

@@ -27,6 +27,11 @@ def get_data():
"type": "doctype", "type": "doctype",
"name": "Payment Entry", "name": "Payment Entry",
"description": _("Bank/Cash transactions against party or for internal transfer") "description": _("Bank/Cash transactions against party or for internal transfer")
},
{
"type": "doctype",
"name": "Payment Term",
"description": _("Payment Terms based on conditions")
} }
] ]
@@ -284,6 +289,11 @@ def get_data():
"name": "Currency Exchange", "name": "Currency Exchange",
"description": _("Currency exchange rate master.") "description": _("Currency exchange rate master.")
}, },
{
"type": "doctype",
"name": "Exchange Rate Revaluation",
"description": _("Exchange Rate Revaluation master.")
},
{ {
"type": "doctype", "type": "doctype",
"name": "Payment Gateway Account", "name": "Payment Gateway Account",

View File

@@ -34,8 +34,8 @@ status_map = {
], ],
"Sales Order": [ "Sales Order": [
["Draft", None], ["Draft", None],
["To Deliver and Bill", "eval:self.per_delivered < 100 and self.per_billed < 100 and self.docstatus == 1"], ["To Deliver and Bill", "eval:self.per_delivered < 100 and self.per_billed < 100 and self.docstatus == 1 and self.order_type in ['Sales', 'Shopping Cart']"],
["To Bill", "eval:self.per_delivered == 100 and self.per_billed < 100 and self.docstatus == 1"], ["To Bill", "eval:self.per_delivered == 100 or self.order_type == 'Maintenance' and self.per_billed < 100 and self.docstatus == 1"],
["To Deliver", "eval:self.per_delivered < 100 and self.per_billed == 100 and self.docstatus == 1"], ["To Deliver", "eval:self.per_delivered < 100 and self.per_billed == 100 and self.docstatus == 1"],
["Completed", "eval:self.per_delivered == 100 and self.per_billed == 100 and self.docstatus == 1"], ["Completed", "eval:self.per_delivered == 100 and self.per_billed == 100 and self.docstatus == 1"],
["Completed", "eval:self.order_type == 'Maintenance' and self.per_billed == 100 and self.docstatus == 1"], ["Completed", "eval:self.order_type == 'Maintenance' and self.per_billed == 100 and self.docstatus == 1"],

View File

@@ -51,7 +51,7 @@ def get_additional_salary_component(employee, start_date, end_date):
for d in additional_components: for d in additional_components:
component = frappe.get_doc("Salary Component", d.salary_component) component = frappe.get_doc("Salary Component", d.salary_component)
struct_row = {'salary_component': d.salary_component} struct_row = {'salary_component': d.salary_component}
for field in ["depends_on_lwp", "abbr", "is_tax_applicable", "variable_based_on_taxable_salary", "is_additional_component"]: for field in ["depends_on_payment_days", "abbr", "is_tax_applicable", "variable_based_on_taxable_salary", "is_additional_component"]:
struct_row[field] = component.get(field) struct_row[field] = component.get(field)
additional_components_list.append({ additional_components_list.append({

View File

@@ -113,7 +113,7 @@ def get_max_benefits(employee, on_date):
def get_max_benefits_remaining(employee, on_date, payroll_period): def get_max_benefits_remaining(employee, on_date, payroll_period):
max_benefits = get_max_benefits(employee, on_date) max_benefits = get_max_benefits(employee, on_date)
if max_benefits and max_benefits > 0: if max_benefits and max_benefits > 0:
have_depends_on_lwp = False have_depends_on_payment_days = False
per_day_amount_total = 0 per_day_amount_total = 0
payroll_period_days = get_payroll_period_days(on_date, on_date, employee)[0] payroll_period_days = get_payroll_period_days(on_date, on_date, employee)[0]
payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period) payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period)
@@ -122,22 +122,22 @@ def get_max_benefits_remaining(employee, on_date, payroll_period):
prev_sal_slip_flexi_total = get_sal_slip_total_benefit_given(employee, payroll_period_obj) prev_sal_slip_flexi_total = get_sal_slip_total_benefit_given(employee, payroll_period_obj)
if prev_sal_slip_flexi_total > 0: if prev_sal_slip_flexi_total > 0:
# Check salary structure hold depends_on_lwp component # Check salary structure hold depends_on_payment_days component
# If yes then find the amount per day of each component and find the sum # If yes then find the amount per day of each component and find the sum
sal_struct_name = get_assigned_salary_structure(employee, on_date) sal_struct_name = get_assigned_salary_structure(employee, on_date)
if sal_struct_name: if sal_struct_name:
sal_struct = frappe.get_doc("Salary Structure", sal_struct_name) sal_struct = frappe.get_doc("Salary Structure", sal_struct_name)
for sal_struct_row in sal_struct.get("earnings"): for sal_struct_row in sal_struct.get("earnings"):
salary_component = frappe.get_doc("Salary Component", sal_struct_row.salary_component) salary_component = frappe.get_doc("Salary Component", sal_struct_row.salary_component)
if salary_component.depends_on_lwp == 1 and salary_component.pay_against_benefit_claim != 1: if salary_component.depends_on_payment_days == 1 and salary_component.pay_against_benefit_claim != 1:
have_depends_on_lwp = True have_depends_on_payment_days = True
benefit_amount = get_benefit_pro_rata_ratio_amount(sal_struct, salary_component.max_benefit_amount) benefit_amount = get_benefit_pro_rata_ratio_amount(sal_struct, salary_component.max_benefit_amount)
amount_per_day = benefit_amount / payroll_period_days amount_per_day = benefit_amount / payroll_period_days
per_day_amount_total += amount_per_day per_day_amount_total += amount_per_day
# Then the sum multiply with the no of lwp in that period # Then the sum multiply with the no of lwp in that period
# Include that amount to the prev_sal_slip_flexi_total to get the actual # Include that amount to the prev_sal_slip_flexi_total to get the actual
if have_depends_on_lwp and per_day_amount_total > 0: if have_depends_on_payment_days and per_day_amount_total > 0:
holidays = get_holidays_for_employee(employee, payroll_period_obj.start_date, on_date) holidays = get_holidays_for_employee(employee, payroll_period_obj.start_date, on_date)
working_days = date_diff(on_date, payroll_period_obj.start_date) + 1 working_days = date_diff(on_date, payroll_period_obj.start_date) + 1
leave_days = calculate_lwp(employee, payroll_period_obj.start_date, holidays, working_days) leave_days = calculate_lwp(employee, payroll_period_obj.start_date, holidays, working_days)
@@ -185,7 +185,7 @@ def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal
'payroll_period': payroll_period 'payroll_period': payroll_period
}) })
if frappe.db.get_value("Salary Component", struct_row.salary_component, "depends_on_lwp") != 1: if frappe.db.get_value("Salary Component", struct_row.salary_component, "depends_on_payment_days") != 1:
if frequency == "Monthly" and actual_payroll_days in range(360, 370): if frequency == "Monthly" and actual_payroll_days in range(360, 370):
period_length = 1 period_length = 1
period_factor = 12 period_factor = 12

View File

@@ -170,7 +170,7 @@ def get_last_payroll_period_benefits(employee, sal_slip_start_date, sal_slip_end
amount += current_claimed_amount amount += current_claimed_amount
struct_row = {} struct_row = {}
salary_components_dict = {} salary_components_dict = {}
struct_row['depends_on_lwp'] = salary_component.depends_on_lwp struct_row['depends_on_payment_days'] = salary_component.depends_on_payment_days
struct_row['salary_component'] = salary_component.name struct_row['salary_component'] = salary_component.name
struct_row['abbr'] = salary_component.salary_component_abbr struct_row['abbr'] = salary_component.salary_component_abbr
struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total

View File

@@ -135,6 +135,7 @@ class LeaveApplication(Document):
date = dt.strftime("%Y-%m-%d") date = dt.strftime("%Y-%m-%d")
doc = frappe.new_doc("Attendance") doc = frappe.new_doc("Attendance")
doc.employee = self.employee doc.employee = self.employee
doc.employee_name = self.employee_name
doc.attendance_date = date doc.attendance_date = date
doc.company = self.company doc.company = self.company
doc.leave_type = self.leave_type doc.leave_type = self.leave_type

View File

@@ -75,5 +75,5 @@ var set_value_for_condition_and_formula = function(frm) {
frm.set_value("amount_based_on_formula", 0); frm.set_value("amount_based_on_formula", 0);
frm.set_value("statistical_component", 0); frm.set_value("statistical_component", 0);
frm.set_value("do_not_include_in_total", 0); frm.set_value("do_not_include_in_total", 0);
frm.set_value("depends_on_lwp", 0); frm.set_value("depends_on_payment_days", 0);
}; };

View File

@@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0, "allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
@@ -19,6 +20,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "salary_component", "fieldname": "salary_component",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@@ -51,6 +53,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "salary_component_abbr", "fieldname": "salary_component_abbr",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@@ -85,6 +88,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "type", "fieldname": "type",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
@@ -119,6 +123,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.is_flexible_benefit != 1", "depends_on": "eval:doc.is_flexible_benefit != 1",
"fetch_if_empty": 0,
"fieldname": "is_additional_component", "fieldname": "is_additional_component",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -153,6 +158,7 @@
"columns": 0, "columns": 0,
"default": "1", "default": "1",
"depends_on": "eval:doc.type == \"Earning\"", "depends_on": "eval:doc.type == \"Earning\"",
"fetch_if_empty": 0,
"fieldname": "is_tax_applicable", "fieldname": "is_tax_applicable",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -186,6 +192,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "1", "default": "1",
"fetch_if_empty": 0,
"fieldname": "is_payable", "fieldname": "is_payable",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -218,7 +225,9 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "depends_on_lwp", "default": "1",
"fetch_if_empty": 0,
"fieldname": "depends_on_payment_days",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
@@ -227,7 +236,7 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Depends on Leave Without Pay", "label": "Depends on Payment Days",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@@ -250,6 +259,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "do_not_include_in_total", "fieldname": "do_not_include_in_total",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -282,6 +292,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_4", "fieldname": "column_break_4",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -313,6 +324,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "disabled", "fieldname": "disabled",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -345,6 +357,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "description", "fieldname": "description",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -378,6 +391,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "If selected, the value specified or calculated in this component will not contribute to the earnings or deductions. However, it's value can be referenced by other components that can be added or deducted. ", "description": "If selected, the value specified or calculated in this component will not contribute to the earnings or deductions. However, it's value can be referenced by other components that can be added or deducted. ",
"fetch_if_empty": 0,
"fieldname": "statistical_component", "fieldname": "statistical_component",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -411,6 +425,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.type==\"Earning\" && doc.is_additional_component != 1 && doc.statistical_component!=1", "depends_on": "eval:doc.type==\"Earning\" && doc.is_additional_component != 1 && doc.statistical_component!=1",
"fetch_if_empty": 0,
"fieldname": "flexible_benefits", "fieldname": "flexible_benefits",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -444,6 +459,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.is_additional_component != 1", "depends_on": "eval:doc.is_additional_component != 1",
"fetch_if_empty": 0,
"fieldname": "is_flexible_benefit", "fieldname": "is_flexible_benefit",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -477,6 +493,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "is_flexible_benefit", "depends_on": "is_flexible_benefit",
"fetch_if_empty": 0,
"fieldname": "max_benefit_amount", "fieldname": "max_benefit_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -509,6 +526,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_9", "fieldname": "column_break_9",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -541,6 +559,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "is_flexible_benefit", "depends_on": "is_flexible_benefit",
"fetch_if_empty": 0,
"fieldname": "pay_against_benefit_claim", "fieldname": "pay_against_benefit_claim",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -574,6 +593,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.is_flexible_benefit == 1 & doc.create_separate_payment_entry_against_benefit_claim !=1", "depends_on": "eval:doc.is_flexible_benefit == 1 & doc.create_separate_payment_entry_against_benefit_claim !=1",
"fetch_if_empty": 0,
"fieldname": "only_tax_impact", "fieldname": "only_tax_impact",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -607,6 +627,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.is_flexible_benefit == 1 & doc.only_tax_impact !=1", "depends_on": "eval:doc.is_flexible_benefit == 1 & doc.only_tax_impact !=1",
"fetch_if_empty": 0,
"fieldname": "create_separate_payment_entry_against_benefit_claim", "fieldname": "create_separate_payment_entry_against_benefit_claim",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -640,6 +661,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.type=='Deduction'", "depends_on": "eval:doc.type=='Deduction'",
"fetch_if_empty": 0,
"fieldname": "section_break_11", "fieldname": "section_break_11",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -671,6 +693,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "variable_based_on_taxable_salary", "fieldname": "variable_based_on_taxable_salary",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -704,6 +727,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.statistical_component != 1", "depends_on": "eval:doc.statistical_component != 1",
"fetch_if_empty": 0,
"fieldname": "section_break_5", "fieldname": "section_break_5",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -736,6 +760,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "accounts", "fieldname": "accounts",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@@ -771,6 +796,7 @@
"collapsible_depends_on": "", "collapsible_depends_on": "",
"columns": 0, "columns": 0,
"depends_on": "eval:doc.is_flexible_benefit != 1 && doc.variable_based_on_taxable_salary != 1", "depends_on": "eval:doc.is_flexible_benefit != 1 && doc.variable_based_on_taxable_salary != 1",
"fetch_if_empty": 0,
"fieldname": "condition_and_formula", "fieldname": "condition_and_formula",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -803,6 +829,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "condition", "fieldname": "condition",
"fieldtype": "Code", "fieldtype": "Code",
"hidden": 0, "hidden": 0,
@@ -836,6 +863,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "", "default": "",
"fetch_if_empty": 0,
"fieldname": "amount_based_on_formula", "fieldname": "amount_based_on_formula",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -869,6 +897,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.amount_based_on_formula!==0", "depends_on": "eval:doc.amount_based_on_formula!==0",
"fetch_if_empty": 0,
"fieldname": "formula", "fieldname": "formula",
"fieldtype": "Code", "fieldtype": "Code",
"hidden": 0, "hidden": 0,
@@ -902,6 +931,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.amount_based_on_formula!==1", "depends_on": "eval:doc.amount_based_on_formula!==1",
"fetch_if_empty": 0,
"fieldname": "amount", "fieldname": "amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -934,6 +964,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_28", "fieldname": "column_break_28",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -965,6 +996,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "help", "fieldname": "help",
"fieldtype": "HTML", "fieldtype": "HTML",
"hidden": 0, "hidden": 0,
@@ -1003,7 +1035,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-09-20 16:44:58.876044", "modified": "2019-04-16 19:08:55.323567",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Salary Component", "name": "Salary Component",

View File

@@ -19,6 +19,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "salary_component", "fieldname": "salary_component",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -55,6 +56,7 @@
"default": "", "default": "",
"depends_on": "eval:doc.parenttype=='Salary Structure'", "depends_on": "eval:doc.parenttype=='Salary Structure'",
"fetch_from": "salary_component.salary_component_abbr", "fetch_from": "salary_component.salary_component_abbr",
"fetch_if_empty": 0,
"fieldname": "abbr", "fieldname": "abbr",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@@ -88,6 +90,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_3", "fieldname": "column_break_3",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -121,6 +124,7 @@
"columns": 0, "columns": 0,
"description": "If selected, the value specified or calculated in this component will not contribute to the earnings or deductions. However, it's value can be referenced by other components that can be added or deducted. ", "description": "If selected, the value specified or calculated in this component will not contribute to the earnings or deductions. However, it's value can be referenced by other components that can be added or deducted. ",
"fetch_from": "salary_component.statistical_component", "fetch_from": "salary_component.statistical_component",
"fetch_if_empty": 0,
"fieldname": "statistical_component", "fieldname": "statistical_component",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -154,6 +158,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_from": "salary_component.is_tax_applicable", "fetch_from": "salary_component.is_tax_applicable",
"fetch_if_empty": 0,
"fieldname": "is_tax_applicable", "fieldname": "is_tax_applicable",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -187,6 +192,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_from": "salary_component.is_flexible_benefit", "fetch_from": "salary_component.is_flexible_benefit",
"fetch_if_empty": 0,
"fieldname": "is_flexible_benefit", "fieldname": "is_flexible_benefit",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -221,6 +227,7 @@
"columns": 0, "columns": 0,
"default": "", "default": "",
"fetch_from": "salary_component.is_additional_component", "fetch_from": "salary_component.is_additional_component",
"fetch_if_empty": 0,
"fieldname": "is_additional_component", "fieldname": "is_additional_component",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 1, "hidden": 1,
@@ -255,6 +262,7 @@
"columns": 0, "columns": 0,
"default": "", "default": "",
"fetch_from": "salary_component.variable_based_on_taxable_salary", "fetch_from": "salary_component.variable_based_on_taxable_salary",
"fetch_if_empty": 0,
"fieldname": "variable_based_on_taxable_salary", "fieldname": "variable_based_on_taxable_salary",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -288,8 +296,9 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "", "depends_on": "",
"fetch_from": "salary_component.depends_on_lwp", "fetch_from": "salary_component.depends_on_payment_days",
"fieldname": "depends_on_lwp", "fetch_if_empty": 0,
"fieldname": "depends_on_payment_days",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
@@ -298,7 +307,7 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Depends on Leave Without Pay", "label": "Depends on Payment Days",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@@ -322,6 +331,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.is_flexible_benefit != 1", "depends_on": "eval:doc.is_flexible_benefit != 1",
"fetch_if_empty": 0,
"fieldname": "section_break_2", "fieldname": "section_break_2",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -354,6 +364,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.parenttype=='Salary Structure'", "depends_on": "eval:doc.parenttype=='Salary Structure'",
"fetch_if_empty": 0,
"fieldname": "condition", "fieldname": "condition",
"fieldtype": "Code", "fieldtype": "Code",
"hidden": 0, "hidden": 0,
@@ -389,6 +400,7 @@
"default": "0", "default": "0",
"depends_on": "eval:doc.parenttype=='Salary Structure'", "depends_on": "eval:doc.parenttype=='Salary Structure'",
"fetch_from": "", "fetch_from": "",
"fetch_if_empty": 0,
"fieldname": "amount_based_on_formula", "fieldname": "amount_based_on_formula",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -425,6 +437,7 @@
"default": "", "default": "",
"depends_on": "eval:doc.amount_based_on_formula!==0 && doc.parenttype==='Salary Structure'", "depends_on": "eval:doc.amount_based_on_formula!==0 && doc.parenttype==='Salary Structure'",
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "formula", "fieldname": "formula",
"fieldtype": "Code", "fieldtype": "Code",
"hidden": 0, "hidden": 0,
@@ -458,6 +471,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.amount_based_on_formula!==1 || doc.parenttype==='Salary Slip'", "depends_on": "eval:doc.amount_based_on_formula!==1 || doc.parenttype==='Salary Slip'",
"fetch_if_empty": 0,
"fieldname": "amount", "fieldname": "amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -491,6 +505,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "do_not_include_in_total", "fieldname": "do_not_include_in_total",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -524,6 +539,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.parenttype=='Salary Structure'", "depends_on": "eval:doc.parenttype=='Salary Structure'",
"fetch_if_empty": 0,
"fieldname": "default_amount", "fieldname": "default_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -558,6 +574,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.parenttype=='Salary Slip' && doc.parentfield=='deductions' && doc.variable_based_on_taxable_salary == 1", "depends_on": "eval:doc.parenttype=='Salary Slip' && doc.parentfield=='deductions' && doc.variable_based_on_taxable_salary == 1",
"fetch_if_empty": 0,
"fieldname": "tax_on_flexible_benefit", "fieldname": "tax_on_flexible_benefit",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -591,6 +608,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.parenttype=='Salary Slip' && doc.parentfield=='deductions' && doc.variable_based_on_taxable_salary == 1", "depends_on": "eval:doc.parenttype=='Salary Slip' && doc.parentfield=='deductions' && doc.variable_based_on_taxable_salary == 1",
"fetch_if_empty": 0,
"fieldname": "tax_on_additional_salary", "fieldname": "tax_on_additional_salary",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -624,6 +642,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.parenttype=='Salary Structure'", "depends_on": "eval:doc.parenttype=='Salary Structure'",
"fetch_if_empty": 0,
"fieldname": "section_break_11", "fieldname": "section_break_11",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -656,6 +675,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.parenttype=='Salary Structure'", "depends_on": "eval:doc.parenttype=='Salary Structure'",
"fetch_if_empty": 0,
"fieldname": "condition_and_formula_help", "fieldname": "condition_and_formula_help",
"fieldtype": "HTML", "fieldtype": "HTML",
"hidden": 0, "hidden": 0,
@@ -693,7 +713,7 @@
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2019-02-04 14:41:56.030991", "modified": "2019-04-16 19:09:31.726597",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Salary Detail", "name": "Salary Detail",

View File

@@ -132,9 +132,6 @@ var get_emp_and_leave_details = function(doc, dt, dn) {
}); });
} }
cur_frm.cscript.employee = function(doc,dt,dn){
get_emp_and_leave_details(doc, dt, dn);
}
cur_frm.cscript.leave_without_pay = function(doc,dt,dn){ cur_frm.cscript.leave_without_pay = function(doc,dt,dn){
if (doc.employee && doc.start_date && doc.end_date) { if (doc.employee && doc.start_date && doc.end_date) {
@@ -160,7 +157,7 @@ cur_frm.cscript.amount = function(doc,dt,dn){
calculate_all(doc, dt, dn); calculate_all(doc, dt, dn);
} }
cur_frm.cscript.depends_on_lwp = function(doc,dt,dn){ cur_frm.cscript.depends_on_payment_days = function(doc,dt,dn){
calculate_earning_total(doc, dt, dn, true); calculate_earning_total(doc, dt, dn, true);
calculate_ded_total(doc, dt, dn, true); calculate_ded_total(doc, dt, dn, true);
calculate_net_pay(doc, dt, dn); calculate_net_pay(doc, dt, dn);
@@ -174,7 +171,7 @@ var calculate_earning_total = function(doc, dt, dn, reset_amount) {
var tbl = doc.earnings || []; var tbl = doc.earnings || [];
var total_earn = 0; var total_earn = 0;
for(var i = 0; i < tbl.length; i++){ for(var i = 0; i < tbl.length; i++){
if(cint(tbl[i].depends_on_lwp) == 1) { if(cint(tbl[i].depends_on_payment_days) == 1) {
tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days) / tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days) /
cint(doc.total_working_days)*100)/100; cint(doc.total_working_days)*100)/100;
} else if(reset_amount && tbl[i].default_amount) { } else if(reset_amount && tbl[i].default_amount) {
@@ -196,7 +193,7 @@ var calculate_ded_total = function(doc, dt, dn, reset_amount) {
var tbl = doc.deductions || []; var tbl = doc.deductions || [];
var total_ded = 0; var total_ded = 0;
for(var i = 0; i < tbl.length; i++){ for(var i = 0; i < tbl.length; i++){
if(cint(tbl[i].depends_on_lwp) == 1) { if(cint(tbl[i].depends_on_payment_days) == 1) {
tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days)/cint(doc.total_working_days)*100)/100; tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days)/cint(doc.total_working_days)*100)/100;
} else if(reset_amount && tbl[i].default_amount) { } else if(reset_amount && tbl[i].default_amount) {
tbl[i].amount = tbl[i].default_amount; tbl[i].amount = tbl[i].default_amount;
@@ -209,16 +206,12 @@ var calculate_ded_total = function(doc, dt, dn, reset_amount) {
refresh_many(['deductions', 'total_deduction']); refresh_many(['deductions', 'total_deduction']);
} }
// Calculate net payable amount
// ------------------------------------------------------------------------
var calculate_net_pay = function(doc, dt, dn) { var calculate_net_pay = function(doc, dt, dn) {
doc.net_pay = flt(doc.gross_pay) - flt(doc.total_deduction); doc.net_pay = flt(doc.gross_pay) - flt(doc.total_deduction);
doc.rounded_total = Math.round(doc.net_pay); doc.rounded_total = Math.round(doc.net_pay);
refresh_many(['net_pay', 'rounded_total']); refresh_many(['net_pay', 'rounded_total']);
} }
// validate
// ------------------------------------------------------------------------
cur_frm.cscript.validate = function(doc, dt, dn) { cur_frm.cscript.validate = function(doc, dt, dn) {
calculate_all(doc, dt, dn); calculate_all(doc, dt, dn);
} }

View File

@@ -131,11 +131,12 @@ class SalarySlip(TransactionBase):
for d in self.get(key): for d in self.get(key):
if d.salary_component == struct_row.salary_component: if d.salary_component == struct_row.salary_component:
component_row = d component_row = d
if not component_row: if not component_row:
self.append(key, { self.append(key, {
'amount': amount, 'amount': amount,
'default_amount': amount, 'default_amount': amount,
'depends_on_lwp' : struct_row.depends_on_lwp, 'depends_on_payment_days' : struct_row.depends_on_payment_days,
'salary_component' : struct_row.salary_component, 'salary_component' : struct_row.salary_component,
'abbr' : struct_row.abbr, 'abbr' : struct_row.abbr,
'do_not_include_in_total' : struct_row.do_not_include_in_total, 'do_not_include_in_total' : struct_row.do_not_include_in_total,
@@ -147,12 +148,11 @@ class SalarySlip(TransactionBase):
'tax_on_additional_salary': additional_tax 'tax_on_additional_salary': additional_tax
}) })
else: else:
if overwrite: if not overwrite:
component_row.default_amount = amount amount += struct_row.get("default_amount", 0)
component_row.amount = amount
else: component_row.default_amount = amount
component_row.default_amount += amount component_row.amount = amount
component_row.amount = component_row.default_amount
component_row.tax_on_flexible_benefit = benefit_tax component_row.tax_on_flexible_benefit = benefit_tax
component_row.tax_on_additional_salary = additional_tax component_row.tax_on_additional_salary = additional_tax
@@ -418,7 +418,7 @@ class SalarySlip(TransactionBase):
for d in self.get(component_type): for d in self.get(component_type):
if (self.salary_structure and if (self.salary_structure and
cint(d.depends_on_lwp) and cint(d.depends_on_payment_days) and
(not (not
self.salary_slip_based_on_timesheet or self.salary_slip_based_on_timesheet or
getdate(self.start_date) < joining_date or getdate(self.start_date) < joining_date or
@@ -431,7 +431,7 @@ class SalarySlip(TransactionBase):
) )
elif not self.payment_days and not self.salary_slip_based_on_timesheet and \ elif not self.payment_days and not self.salary_slip_based_on_timesheet and \
cint(d.depends_on_lwp): cint(d.depends_on_payment_days):
d.amount = 0 d.amount = 0
elif not d.amount: elif not d.amount:
d.amount = d.default_amount d.amount = d.default_amount
@@ -441,7 +441,7 @@ class SalarySlip(TransactionBase):
def calculate_net_pay(self): def calculate_net_pay(self):
if self.salary_structure: if self.salary_structure:
self.calculate_component_amounts() self.calculate_component_amounts()
disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total")) disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total"))
precision = frappe.defaults.get_global_default("currency_precision") precision = frappe.defaults.get_global_default("currency_precision")
self.total_deduction = 0 self.total_deduction = 0
@@ -455,7 +455,7 @@ class SalarySlip(TransactionBase):
self.net_pay = flt(self.gross_pay) - (flt(self.total_deduction) + flt(self.total_loan_repayment)) self.net_pay = flt(self.gross_pay) - (flt(self.total_deduction) + flt(self.total_loan_repayment))
self.rounded_total = rounded(self.net_pay, self.rounded_total = rounded(self.net_pay,
self.precision("net_pay") if disable_rounded_total else 0) self.precision("net_pay") if disable_rounded_total else 0)
if self.net_pay < 0: if self.net_pay < 0:
frappe.throw(_("Net Pay cannnot be negative")) frappe.throw(_("Net Pay cannnot be negative"))
@@ -599,12 +599,11 @@ class SalarySlip(TransactionBase):
annual_earning = taxable_earning["taxable_earning"] * period_factor annual_earning = taxable_earning["taxable_earning"] * period_factor
exemption_amount = 0 exemption_amount = 0
if frappe.db.exists("Employee Tax Exemption Declaration", {"employee": self.employee, if frappe.db.exists("Employee Tax Exemption Declaration", {"employee": self.employee,
"payroll_period": payroll_period.name, "docstatus": 1}): "payroll_period": payroll_period.name, "docstatus": 1}):
exemption_amount = frappe.db.get_value("Employee Tax Exemption Declaration", exemption_amount = frappe.db.get_value("Employee Tax Exemption Declaration",
{"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1}, {"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1},
"total_exemption_amount") "total_exemption_amount")
annual_taxable_earning = annual_earning - exemption_amount annual_taxable_earning = annual_earning - exemption_amount
if self.deduct_tax_for_unclaimed_employee_benefits or self.deduct_tax_for_unsubmitted_tax_exemption_proof: if self.deduct_tax_for_unclaimed_employee_benefits or self.deduct_tax_for_unsubmitted_tax_exemption_proof:
tax_detail = self.get_tax_paid_in_period(payroll_period, tax_component) tax_detail = self.get_tax_paid_in_period(payroll_period, tax_component)
if tax_detail: if tax_detail:
@@ -770,13 +769,21 @@ class SalarySlip(TransactionBase):
def get_period_factor(self, period_start, period_end, start_date=None, end_date=None): def get_period_factor(self, period_start, period_end, start_date=None, end_date=None):
# TODO if both deduct checked update the factor to make tax consistent # TODO if both deduct checked update the factor to make tax consistent
joining_date, relieving_date = frappe.db.get_value("Employee", self.employee, ["date_of_joining", "relieving_date"])
if getdate(joining_date) > getdate(period_start):
period_start = joining_date
if relieving_date and getdate(relieving_date) < getdate(period_end):
period_end = relieving_date
payroll_days = date_diff(period_end, period_start) + 1 payroll_days = date_diff(period_end, period_start) + 1
if start_date and end_date: if start_date and end_date:
salary_days = date_diff(end_date, start_date) + 1 salary_days = date_diff(end_date, start_date) + 1
return flt(payroll_days)/flt(salary_days) return flt(payroll_days)/flt(salary_days)
# if period configured for a year and monthly frequency return 12 to make tax calc consistent # if period configured for a year and monthly frequency return 12 to make tax calc consistent
if 360 <= payroll_days <= 370 and self.payroll_frequency == "Monthly": if 360 <= payroll_days <= 370 and self.payroll_frequency == "Monthly":
return 12 return 12
salary_days = date_diff(self.end_date, self.start_date) + 1 salary_days = date_diff(self.end_date, self.start_date) + 1
return flt(payroll_days)/flt(salary_days) return flt(payroll_days)/flt(salary_days)
@@ -784,7 +791,7 @@ class SalarySlip(TransactionBase):
component = frappe.get_doc("Salary Component", salary_component) component = frappe.get_doc("Salary Component", salary_component)
# Data for update_component_row # Data for update_component_row
struct_row = {} struct_row = {}
struct_row['depends_on_lwp'] = component.depends_on_lwp struct_row['depends_on_payment_days'] = component.depends_on_payment_days
struct_row['salary_component'] = component.name struct_row['salary_component'] = component.name
struct_row['abbr'] = component.salary_component_abbr struct_row['abbr'] = component.salary_component_abbr
struct_row['do_not_include_in_total'] = component.do_not_include_in_total struct_row['do_not_include_in_total'] = component.do_not_include_in_total

View File

@@ -246,7 +246,7 @@ frappe.ui.form.on('Salary Detail', {
frappe.model.set_value(cdt, cdn, 'amount', result.amount); frappe.model.set_value(cdt, cdn, 'amount', result.amount);
} }
frappe.model.set_value(cdt, cdn, 'statistical_component', result.statistical_component); frappe.model.set_value(cdt, cdn, 'statistical_component', result.statistical_component);
frappe.model.set_value(cdt, cdn, 'depends_on_lwp', result.depends_on_lwp); frappe.model.set_value(cdt, cdn, 'depends_on_payment_days', result.depends_on_payment_days);
frappe.model.set_value(cdt, cdn, 'do_not_include_in_total', result.do_not_include_in_total); frappe.model.set_value(cdt, cdn, 'do_not_include_in_total', result.do_not_include_in_total);
frappe.model.set_value(cdt, cdn, 'variable_based_on_taxable_salary', result.variable_based_on_taxable_salary); frappe.model.set_value(cdt, cdn, 'variable_based_on_taxable_salary', result.variable_based_on_taxable_salary);
frappe.model.set_value(cdt, cdn, 'is_tax_applicable', result.is_tax_applicable); frappe.model.set_value(cdt, cdn, 'is_tax_applicable', result.is_tax_applicable);

View File

@@ -18,7 +18,7 @@ class SalaryStructure(Document):
self.validate_max_benefits_with_flexi() self.validate_max_benefits_with_flexi()
def set_missing_values(self): def set_missing_values(self):
overwritten_fields = ["depends_on_lwp", "variable_based_on_taxable_salary", "is_tax_applicable", "is_flexible_benefit"] overwritten_fields = ["depends_on_payment_days", "variable_based_on_taxable_salary", "is_tax_applicable", "is_flexible_benefit"]
overwritten_fields_if_missing = ["amount_based_on_formula", "formula", "amount"] overwritten_fields_if_missing = ["amount_based_on_formula", "formula", "amount"]
for table in ["earnings", "deductions"]: for table in ["earnings", "deductions"]:
for d in self.get(table): for d in self.get(table):
@@ -126,7 +126,7 @@ def create_salary_structures_assignment(employee, salary_structure, from_date, b
def get_existing_assignments(employees, salary_structure,from_date): def get_existing_assignments(employees, salary_structure,from_date):
salary_structures_assignments = frappe.db.sql_list(""" salary_structures_assignments = frappe.db.sql_list("""
select distinct employee from `tabSalary Structure Assignment` select distinct employee from `tabSalary Structure Assignment`
where salary_structure=%s and employee in (%s) where salary_structure=%s and employee in (%s)
and from_date=%s and docstatus=1 and from_date=%s and docstatus=1
""" % ('%s', ', '.join(['%s']*len(employees)),'%s'), [salary_structure] + employees+[from_date]) """ % ('%s', ', '.join(['%s']*len(employees)),'%s'), [salary_structure] + employees+[from_date])

View File

@@ -1,18 +1,18 @@
{ {
"creation": "2016-07-07 12:38:32.447281", "creation": "2016-07-07 12:38:32.447281",
"custom_format": 0, "custom_format": 0,
"disabled": 0, "disabled": 0,
"doc_type": "Salary Slip", "doc_type": "Salary Slip",
"docstatus": 0, "docstatus": 0,
"doctype": "Print Format", "doctype": "Print Format",
"font": "Default", "font": "Default",
"format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"HTML\", \"options\": \" <h3 style=\\\"text-align: right;\\\">{{doc.name}}</h3><div><hr></div> \"}, {\"fieldtype\": \"Section Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"employee\"}, {\"print_hide\": 0, \"fieldname\": \"employee_name\"}, {\"print_hide\": 0, \"fieldname\": \"department\"}, {\"print_hide\": 0, \"fieldname\": \"designation\"}, {\"print_hide\": 0, \"fieldname\": \"branch\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"start_date\"}, {\"print_hide\": 0, \"fieldname\": \"end_date\"}, {\"print_hide\": 0, \"fieldname\": \"total_working_hours\"}, {\"print_hide\": 0, \"fieldname\": \"hour_rate\"}, {\"fieldtype\": \"Section Break\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"time_sheet\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"working_hours\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"timesheets\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Section Break\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"salary_component\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"depends_on_lwp\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"earnings\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"salary_component\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"depends_on_lwp\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"deductions\"}, {\"fieldtype\": \"Section Break\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"gross_pay\"}, {\"print_hide\": 0, \"fieldname\": \"total_deduction\"}, {\"print_hide\": 0, \"fieldname\": \"net_pay\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\"}, {\"print_hide\": 0, \"fieldname\": \"total_in_words\"}]", "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"HTML\", \"options\": \" <h3 style=\\\"text-align: right;\\\">{{doc.name}}</h3><div><hr></div> \"}, {\"fieldtype\": \"Section Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"employee\"}, {\"print_hide\": 0, \"fieldname\": \"employee_name\"}, {\"print_hide\": 0, \"fieldname\": \"department\"}, {\"print_hide\": 0, \"fieldname\": \"designation\"}, {\"print_hide\": 0, \"fieldname\": \"branch\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"start_date\"}, {\"print_hide\": 0, \"fieldname\": \"end_date\"}, {\"print_hide\": 0, \"fieldname\": \"total_working_hours\"}, {\"print_hide\": 0, \"fieldname\": \"hour_rate\"}, {\"fieldtype\": \"Section Break\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"time_sheet\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"working_hours\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"timesheets\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Section Break\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"salary_component\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"depends_on_payment_days\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"earnings\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"salary_component\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"depends_on_payment_days\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"deductions\"}, {\"fieldtype\": \"Section Break\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"gross_pay\"}, {\"print_hide\": 0, \"fieldname\": \"total_deduction\"}, {\"print_hide\": 0, \"fieldname\": \"net_pay\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\"}, {\"print_hide\": 0, \"fieldname\": \"total_in_words\"}]",
"idx": 0, "idx": 0,
"modified": "2016-08-21 21:02:59.896033", "modified": "2016-08-21 21:02:59.896033",
"modified_by": "Administrator", "modified_by": "Administrator",
"name": "Salary Slip based on Timesheet", "name": "Salary Slip based on Timesheet",
"owner": "Administrator", "owner": "Administrator",
"print_format_builder": 1, "print_format_builder": 1,
"print_format_type": "Server", "print_format_type": "Server",
"standard": "Yes" "standard": "Yes"
} }

View File

@@ -1,22 +1,22 @@
{ {
"align_labels_right": 0, "align_labels_right": 0,
"creation": "2016-07-07 11:45:14.872204", "creation": "2016-07-07 11:45:14.872204",
"custom_format": 0, "custom_format": 0,
"disabled": 0, "disabled": 0,
"doc_type": "Salary Slip", "doc_type": "Salary Slip",
"docstatus": 0, "docstatus": 0,
"doctype": "Print Format", "doctype": "Print Format",
"font": "Default", "font": "Default",
"format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \" <h3 style=\\\"text-align: right;\\\"><span style=\\\"line-height: 1.42857;\\\">{{doc.name}}</span></h3>\\n<div>\\n <hr style=\\\"text-align: center;\\\">\\n</div> \"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"employee\", \"label\": \"Employee\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"employee_name\", \"label\": \"Employee Name\"}, {\"print_hide\": 0, \"fieldname\": \"department\", \"label\": \"Department\"}, {\"print_hide\": 0, \"fieldname\": \"designation\", \"label\": \"Designation\"}, {\"print_hide\": 0, \"fieldname\": \"branch\", \"label\": \"Branch\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"start_date\", \"label\": \"Start Date\"}, {\"print_hide\": 0, \"fieldname\": \"end_date\", \"label\": \"End Date\"}, {\"print_hide\": 0, \"fieldname\": \"total_working_days\", \"label\": \"Working Days\"}, {\"print_hide\": 0, \"fieldname\": \"leave_without_pay\", \"label\": \"Leave Without Pay\"}, {\"print_hide\": 0, \"fieldname\": \"payment_days\", \"label\": \"Payment Days\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"salary_component\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"earnings\", \"label\": \"Earnings\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"salary_component\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"depends_on_lwp\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"deductions\", \"label\": \"Deductions\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"gross_pay\", \"label\": \"Gross Pay\"}, {\"print_hide\": 0, \"fieldname\": \"total_deduction\", \"label\": \"Total Deduction\"}, {\"print_hide\": 0, \"fieldname\": \"net_pay\", \"label\": \"Net Pay\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"total_in_words\", \"label\": \"Total in words\"}]", "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \" <h3 style=\\\"text-align: right;\\\"><span style=\\\"line-height: 1.42857;\\\">{{doc.name}}</span></h3>\\n<div>\\n <hr style=\\\"text-align: center;\\\">\\n</div> \"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"employee\", \"label\": \"Employee\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"employee_name\", \"label\": \"Employee Name\"}, {\"print_hide\": 0, \"fieldname\": \"department\", \"label\": \"Department\"}, {\"print_hide\": 0, \"fieldname\": \"designation\", \"label\": \"Designation\"}, {\"print_hide\": 0, \"fieldname\": \"branch\", \"label\": \"Branch\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"start_date\", \"label\": \"Start Date\"}, {\"print_hide\": 0, \"fieldname\": \"end_date\", \"label\": \"End Date\"}, {\"print_hide\": 0, \"fieldname\": \"total_working_days\", \"label\": \"Working Days\"}, {\"print_hide\": 0, \"fieldname\": \"leave_without_pay\", \"label\": \"Leave Without Pay\"}, {\"print_hide\": 0, \"fieldname\": \"payment_days\", \"label\": \"Payment Days\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"salary_component\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"earnings\", \"label\": \"Earnings\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"salary_component\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"depends_on_payment_days\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"deductions\", \"label\": \"Deductions\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"gross_pay\", \"label\": \"Gross Pay\"}, {\"print_hide\": 0, \"fieldname\": \"total_deduction\", \"label\": \"Total Deduction\"}, {\"print_hide\": 0, \"fieldname\": \"net_pay\", \"label\": \"Net Pay\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"total_in_words\", \"label\": \"Total in words\"}]",
"idx": 0, "idx": 0,
"line_breaks": 0, "line_breaks": 0,
"modified": "2018-07-24 19:31:39.040701", "modified": "2018-07-24 19:31:39.040701",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Salary Slip Standard", "name": "Salary Slip Standard",
"owner": "Administrator", "owner": "Administrator",
"print_format_builder": 1, "print_format_builder": 1,
"print_format_type": "Server", "print_format_type": "Server",
"show_section_headings": 0, "show_section_headings": 0,
"standard": "Yes" "standard": "Yes"
} }

View File

@@ -590,4 +590,7 @@ erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019
erpnext.patches.v11_0.make_italian_localization_fields # 26-03-2019 erpnext.patches.v11_0.make_italian_localization_fields # 26-03-2019
erpnext.patches.v11_1.make_job_card_time_logs erpnext.patches.v11_1.make_job_card_time_logs
erpnext.patches.v11_1.set_variant_based_on erpnext.patches.v11_1.set_variant_based_on
erpnext.patches.v11_1.woocommerce_set_creation_user erpnext.patches.v11_1.woocommerce_set_creation_user
erpnext.patches.v11_1.delete_bom_browser
erpnext.patches.v11_1.set_salary_details_submittable
erpnext.patches.v11_1.rename_depends_on_lwp

View File

@@ -0,0 +1,8 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.delete_doc_if_exists('Page', 'bom-browser')

View File

@@ -0,0 +1,13 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import scrub
from frappe.model.utils.rename_field import rename_field
def execute():
for doctype in ("Salary Component", "Salary Detail"):
if "depends_on_lwp" in frappe.db.get_table_columns(doctype):
frappe.reload_doc("hr", "doctype", scrub(doctype))
rename_field(doctype, "depends_on_lwp", "depends_on_payment_days")

View File

@@ -0,0 +1,9 @@
from __future__ import unicode_literals
import frappe
def execute():
frappe.db.sql("""
update `tabSalary Structure` ss, `tabSalary Detail` sd
set sd.docstatus=1
where ss.name=sd.parent and ss.docstatus=1 and sd.parenttype='Salary Structure'
""")

View File

@@ -5,79 +5,79 @@ from frappe.model.utils.rename_field import update_property_setters
def execute(): def execute():
if not frappe.db.exists("DocType", "Salary Structure Earning"): if not frappe.db.exists("DocType", "Salary Structure Earning"):
return return
frappe.reload_doc("hr", "doctype", "salary_detail") frappe.reload_doc("hr", "doctype", "salary_detail")
frappe.reload_doc("hr", "doctype", "salary_component") frappe.reload_doc("hr", "doctype", "salary_component")
standard_cols = ["name", "creation", "modified", "owner", "modified_by", "parent", "parenttype", "parentfield", "idx"] standard_cols = ["name", "creation", "modified", "owner", "modified_by", "parent", "parenttype", "parentfield", "idx"]
dt_cols = { dt_cols = {
"Salary Structure Deduction": ["d_type", "d_modified_amt", "depend_on_lwp"], "Salary Structure Deduction": ["d_type", "d_modified_amt", "depend_on_lwp"],
"Salary Structure Earning": ["e_type", "modified_value", "depend_on_lwp"], "Salary Structure Earning": ["e_type", "modified_value", "depend_on_lwp"],
"Salary Slip Earning": ["e_type", "e_modified_amount", "e_depends_on_lwp", "e_amount"], "Salary Slip Earning": ["e_type", "e_modified_amount", "e_depends_on_lwp", "e_amount"],
"Salary Slip Deduction": ["d_type", "d_modified_amount", "d_depends_on_lwp", "d_amount"], "Salary Slip Deduction": ["d_type", "d_modified_amount", "d_depends_on_lwp", "d_amount"],
} }
earning_type_exists = True if "earning_type" in frappe.db.get_table_columns("Salary Slip Earning") else False earning_type_exists = True if "earning_type" in frappe.db.get_table_columns("Salary Slip Earning") else False
e_type_exists = True if "e_type" in frappe.db.get_table_columns("Salary Slip Earning") else False e_type_exists = True if "e_type" in frappe.db.get_table_columns("Salary Slip Earning") else False
if e_type_exists and earning_type_exists: if e_type_exists and earning_type_exists:
frappe.db.sql("""update `tabSalary Slip Earning` frappe.db.sql("""update `tabSalary Slip Earning`
set e_type = earning_type, e_modified_amount = earning_amount set e_type = earning_type, e_modified_amount = earning_amount
where e_type is null and earning_type is not null""") where e_type is null and earning_type is not null""")
frappe.db.sql("""update `tabSalary Structure Earning` set e_type = earning_type frappe.db.sql("""update `tabSalary Structure Earning` set e_type = earning_type
where e_type is null and earning_type is not null""") where e_type is null and earning_type is not null""")
frappe.db.sql("""update `tabSalary Slip Deduction` set frappe.db.sql("""update `tabSalary Slip Deduction` set
d_type = deduction_type, d_modified_amount = deduction_amount d_type = deduction_type, d_modified_amount = deduction_amount
where d_type is null and deduction_type is not null""") where d_type is null and deduction_type is not null""")
frappe.db.sql("""update `tabSalary Structure Deduction` set d_type = deduction_type frappe.db.sql("""update `tabSalary Structure Deduction` set d_type = deduction_type
where d_type is null and deduction_type is not null""") where d_type is null and deduction_type is not null""")
if earning_type_exists and not e_type_exists: if earning_type_exists and not e_type_exists:
for val in dt_cols.values(): for val in dt_cols.values():
if val[0] == "e_type": if val[0] == "e_type":
val[0] = "earning_type" val[0] = "earning_type"
if val[0] == "d_type": if val[0] == "d_type":
val[0] = "deduction_type" val[0] = "deduction_type"
if val[1] == "e_modified_amount": if val[1] == "e_modified_amount":
val[1] ="earning_amount" val[1] ="earning_amount"
if val[1] == "d_modified_amount": if val[1] == "d_modified_amount":
val[1] ="deduction_amount" val[1] ="deduction_amount"
target_cols = standard_cols + ["salary_component", "amount", "depends_on_lwp", "default_amount"]
target_cols = "`" + "`, `".join(target_cols) + "`" target_cols = standard_cols + ["salary_component", "amount", "depends_on_payment_days", "default_amount"]
target_cols = "`" + "`, `".join(target_cols) + "`"
for doctype, cols in dt_cols.items():
for doctype, cols in dt_cols.items():
source_cols = "`" + "`, `".join(standard_cols + cols) + "`" source_cols = "`" + "`, `".join(standard_cols + cols) + "`"
if len(cols) == 3: if len(cols) == 3:
source_cols += ", 0" source_cols += ", 0"
frappe.db.sql("""INSERT INTO `tabSalary Detail` ({0}) SELECT {1} FROM `tab{2}`""" frappe.db.sql("""INSERT INTO `tabSalary Detail` ({0}) SELECT {1} FROM `tab{2}`"""
.format(target_cols, source_cols, doctype)) .format(target_cols, source_cols, doctype))
dt_cols_de = { dt_cols_de = {
"Deduction Type": ["deduction_name", "description"], "Deduction Type": ["deduction_name", "description"],
"Earning Type": ["earning_name", "description"], "Earning Type": ["earning_name", "description"],
} }
standard_cols_de = standard_cols standard_cols_de = standard_cols
target_cols = standard_cols_de + ["salary_component", "description"] target_cols = standard_cols_de + ["salary_component", "description"]
target_cols = "`" + "`, `".join(target_cols) + "`" target_cols = "`" + "`, `".join(target_cols) + "`"
for doctype, cols in dt_cols_de.items(): for doctype, cols in dt_cols_de.items():
source_cols = "`" + "`, `".join(standard_cols_de + cols) + "`" source_cols = "`" + "`, `".join(standard_cols_de + cols) + "`"
try: try:
frappe.db.sql("""INSERT INTO `tabSalary Component` ({0}) SELECT {1} FROM `tab{2}`""" frappe.db.sql("""INSERT INTO `tabSalary Component` ({0}) SELECT {1} FROM `tab{2}`"""
@@ -85,10 +85,10 @@ def execute():
except Exception as e: except Exception as e:
if e.args[0]==1062: if e.args[0]==1062:
pass pass
update_customizations() update_customizations()
for doctype in ["Salary Structure Deduction", "Salary Structure Earning", "Salary Slip Earning", for doctype in ["Salary Structure Deduction", "Salary Structure Earning", "Salary Slip Earning",
"Salary Slip Deduction", "Deduction Type", "Earning Type"] : "Salary Slip Deduction", "Deduction Type", "Earning Type"] :
frappe.delete_doc("DocType", doctype) frappe.delete_doc("DocType", doctype)
@@ -96,35 +96,35 @@ def execute():
def update_customizations(): def update_customizations():
dt_cols = { dt_cols = {
"Salary Structure Deduction": { "Salary Structure Deduction": {
"d_type": "salary_component", "d_type": "salary_component",
"deduction_type": "salary_component", "deduction_type": "salary_component",
"d_modified_amt": "amount", "d_modified_amt": "amount",
"depend_on_lwp": "depends_on_lwp" "depend_on_lwp": "depends_on_payment_days"
}, },
"Salary Structure Earning": { "Salary Structure Earning": {
"e_type": "salary_component", "e_type": "salary_component",
"earning_type": "salary_component", "earning_type": "salary_component",
"modified_value": "amount", "modified_value": "amount",
"depend_on_lwp": "depends_on_lwp" "depend_on_lwp": "depends_on_payment_days"
}, },
"Salary Slip Earning": { "Salary Slip Earning": {
"e_type": "salary_component", "e_type": "salary_component",
"earning_type": "salary_component", "earning_type": "salary_component",
"e_modified_amount": "amount", "e_modified_amount": "amount",
"e_amount" : "default_amount", "e_amount" : "default_amount",
"e_depends_on_lwp": "depends_on_lwp" "e_depends_on_lwp": "depends_on_payment_days"
}, },
"Salary Slip Deduction": { "Salary Slip Deduction": {
"d_type": "salary_component", "d_type": "salary_component",
"deduction_type": "salary_component", "deduction_type": "salary_component",
"d_modified_amount": "amount", "d_modified_amount": "amount",
"d_amount" : "default_amount", "d_amount" : "default_amount",
"d_depends_on_lwp": "depends_on_lwp" "d_depends_on_lwp": "depends_on_payment_days"
} }
} }
update_property_setters_and_custom_fields("Salary Detail", dt_cols) update_property_setters_and_custom_fields("Salary Detail", dt_cols)
dt_cols = { dt_cols = {
"Earning Type": { "Earning Type": {
"earning_name": "salary_component" "earning_name": "salary_component"
@@ -133,17 +133,17 @@ def update_customizations():
"deduction_name": "salary_component" "deduction_name": "salary_component"
} }
} }
update_property_setters_and_custom_fields("Salary Component", dt_cols) update_property_setters_and_custom_fields("Salary Component", dt_cols)
def update_property_setters_and_custom_fields(new_dt, dt_cols): def update_property_setters_and_custom_fields(new_dt, dt_cols):
for doctype, cols in dt_cols.items(): for doctype, cols in dt_cols.items():
frappe.db.sql("update `tabProperty Setter` set doc_type = %s where doc_type=%s", (new_dt, doctype)) frappe.db.sql("update `tabProperty Setter` set doc_type = %s where doc_type=%s", (new_dt, doctype))
frappe.db.sql("update `tabCustom Field` set dt = %s where dt=%s", (new_dt, doctype)) frappe.db.sql("update `tabCustom Field` set dt = %s where dt=%s", (new_dt, doctype))
for old_fieldname, new_fieldname in cols.items(): for old_fieldname, new_fieldname in cols.items():
update_property_setters(new_dt, old_fieldname, new_fieldname) update_property_setters(new_dt, old_fieldname, new_fieldname)

View File

@@ -151,10 +151,10 @@ def get_opening_balance(filters, columns):
"posting_date": filters.from_date, "posting_date": filters.from_date,
"posting_time": "00:00:00" "posting_time": "00:00:00"
}) })
row = [""]*len(columns) row = {}
row[1] = _("'Opening'") row["item_code"] = _("'Opening'")
for i, v in ((9, 'qty_after_transaction'), (11, 'valuation_rate'), (12, 'stock_value')): for dummy, v in ((9, 'qty_after_transaction'), (11, 'valuation_rate'), (12, 'stock_value')):
row[i] = last_entry.get(v, 0) row[v] = last_entry.get(v, 0)
return row return row

View File

@@ -5,50 +5,36 @@ from __future__ import unicode_literals
import frappe, erpnext import frappe, erpnext
from frappe import _ from frappe import _
from six import iteritems
def get_level(): def get_level():
activation_level = 0 activation_level = 0
sales_data = []
min_count = 0
doctypes = {"Item": 5, "Customer": 5, "Sales Order": 2, "Sales Invoice": 2, "Purchase Order": 2, "Employee": 3, "Lead": 3, "Quotation": 3,
"Payment Entry": 2, "User": 5, "Student": 5, "Instructor": 5, "BOM": 3, "Journal Entry": 3, "Stock Entry": 3}
for doctype, min_count in iteritems(doctypes):
count = frappe.db.count(doctype)
if count > min_count:
activation_level += 1
sales_data.append({doctype: count})
if frappe.db.get_single_value('System Settings', 'setup_complete'): if frappe.db.get_single_value('System Settings', 'setup_complete'):
activation_level = 1
if frappe.db.count('Item') > 5:
activation_level += 1 activation_level += 1
if frappe.db.count('Customer') > 5: communication_number = frappe.db.count('Communication', dict(communication_medium='Email'))
activation_level += 1 if communication_number > 10:
if frappe.db.count('Sales Order') > 2:
activation_level += 1
if frappe.db.count('Purchase Order') > 2:
activation_level += 1
if frappe.db.count('Employee') > 3:
activation_level += 1
if frappe.db.count('Lead') > 3:
activation_level += 1
if frappe.db.count('Payment Entry') > 2:
activation_level += 1
if frappe.db.count('Communication', dict(communication_medium='Email')) > 10:
activation_level += 1
if frappe.db.count('User') > 5:
activation_level += 1
if frappe.db.count('Student') > 5:
activation_level += 1
if frappe.db.count('Instructor') > 5:
activation_level += 1 activation_level += 1
sales_data.append({"Communication": communication_number})
# recent login # recent login
if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'): if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'):
activation_level += 1 activation_level += 1
return activation_level level = {"activation_level": activation_level, "sales_data": sales_data}
return level
def get_help_messages(): def get_help_messages():
'''Returns help messages to be shown on Desktop''' '''Returns help messages to be shown on Desktop'''