diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 0399cf95839..1ac69b3a180 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -356,6 +356,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte set_pos_data: function() { if(this.frm.doc.is_pos) { + this.frm.set_value("allocate_advances_automatically", this.frm.doc.is_pos ? 0 : 1); if(!this.frm.doc.company) { this.frm.set_value("is_pos", 0); frappe.msgprint(__("Please specify Company to proceed")); diff --git a/erpnext/accounts/report/gross_profit/gross_profit.js b/erpnext/accounts/report/gross_profit/gross_profit.js index 1f7d24db1e4..ba17a94e8d3 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.js +++ b/erpnext/accounts/report/gross_profit/gross_profit.js @@ -23,6 +23,12 @@ frappe.query_reports["Gross Profit"] = { "fieldtype": "Date", "default": frappe.defaults.get_user_default("year_end_date") }, + { + "fieldname":"sales_invoice", + "label": __("Sales Invoice"), + "fieldtype": "Link", + "options": "Sales Invoice" + }, { "fieldname":"group_by", "label": __("Group By"), diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index e5aaafaff49..ee5a4d28e37 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -302,6 +302,12 @@ class GrossProfitGenerator(object): sales_person_cols = "" sales_team_table = "" + if self.filters.get("sales_invoice"): + conditions += " and `tabSales Invoice`.name = %(sales_invoice)s" + + if self.filters.get("item_code"): + conditions += " and `tabSales Invoice Item`.item_code = %(item_code)s" + self.si_list = frappe.db.sql(""" select `tabSales Invoice Item`.parenttype, `tabSales Invoice Item`.parent, diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index 8500aea4159..0b17c8f964a 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -135,3 +135,22 @@ def get_appropriate_company(filters): company = get_default_company() return company + +@frappe.whitelist() +def get_invoiced_item_gross_margin(sales_invoice=None, item_code=None, company=None): + from erpnext.accounts.report.gross_profit.gross_profit import GrossProfitGenerator + + sales_invoice = sales_invoice or frappe.form_dict.get('sales_invoice') + item_code = item_code or frappe.form_dict.get('item_code') + company = company or frappe.get_cached_value("Sales Invoice", sales_invoice, 'company') + + filters = { + 'sales_invoice': sales_invoice, + 'item_code': item_code, + 'company': company, + 'group_by': 'Invoice' + } + + gross_profit_data = GrossProfitGenerator(filters) + + return gross_profit_data.grouped_data diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ca24cd670bd..6d2c30abb50 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -88,7 +88,7 @@ class AccountsController(TransactionBase): self.validate_paid_amount() if self.doctype in ['Purchase Invoice', 'Sales Invoice']: - if cint(self.allocate_advances_automatically): + if cint(self.allocate_advances_automatically) and not cint(self.is_pos): self.set_advances() if self.is_return: diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json index 865e8219b31..899b869b90a 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_events_in_timeline": 0, "allow_guest_to_view": 0, "allow_import": 1, "allow_rename": 1, @@ -20,6 +21,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "employee", "fieldtype": "Link", "hidden": 0, @@ -54,6 +56,7 @@ "collapsible": 0, "columns": 0, "fetch_from": "employee.company", + "fetch_if_empty": 0, "fieldname": "company", "fieldtype": "Link", "hidden": 0, @@ -87,6 +90,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_2", "fieldtype": "Column Break", "hidden": 0, @@ -118,6 +122,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "payroll_period", "fieldtype": "Link", "hidden": 0, @@ -151,6 +156,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "total_exemption_amount", "fieldtype": "Currency", "hidden": 0, @@ -184,6 +190,7 @@ "collapsible": 0, "columns": 0, "fetch_from": "employee.department", + "fetch_if_empty": 0, "fieldname": "department", "fieldtype": "Link", "hidden": 0, @@ -217,6 +224,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "amended_from", "fieldtype": "Link", "hidden": 0, @@ -249,6 +257,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "section_break_8", "fieldtype": "Section Break", "hidden": 0, @@ -280,6 +289,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "declarations", "fieldtype": "Table", "hidden": 0, @@ -300,7 +310,7 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 1, + "reqd": 0, "search_index": 0, "set_only_once": 0, "translatable": 0, @@ -317,7 +327,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-08-21 16:15:49.363307", + "modified": "2019-04-23 15:50:48.693555", "modified_by": "Administrator", "module": "HR", "name": "Employee Tax Exemption Declaration", diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index ac4e40bd6de..032ae8f2e6f 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -167,7 +167,7 @@ class SalarySlip(TransactionBase): if d.amount_based_on_formula: formula = d.formula.strip() if d.formula else None if formula: - amount = frappe.safe_eval(formula, self.whitelisted_globals, data) + amount = rounded(frappe.safe_eval(formula, self.whitelisted_globals, data)) if amount: data[d.abbr] = amount @@ -735,22 +735,24 @@ class SalarySlip(TransactionBase): # less paid taxes if args.get("pro_rata_tax_paid"): tax_amount -= args.get("pro_rata_tax_paid") + tax_amount = rounded(tax_amount) struct_row = self.get_salary_slip_row(args.get("tax_component")) return [struct_row, tax_amount, benefit_tax, additional_tax] - def calculate_tax_by_tax_slab(self, payroll_period, annual_earning): + def calculate_tax_by_tax_slab(self, payroll_period, annual_taxable_earning): payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period) data = self.get_data_for_eval() + data.update({"annual_taxable_earning": annual_taxable_earning}) taxable_amount = 0 for slab in payroll_period_obj.taxable_salary_slabs: if slab.condition and not self.eval_tax_slab_condition(slab.condition, data): continue - if not slab.to_amount and annual_earning > slab.from_amount: - taxable_amount += (annual_earning - slab.from_amount) * slab.percent_deduction *.01 + if not slab.to_amount and annual_taxable_earning > slab.from_amount: + taxable_amount += (annual_taxable_earning - slab.from_amount) * slab.percent_deduction *.01 continue - if annual_earning > slab.from_amount and annual_earning < slab.to_amount: - taxable_amount += (annual_earning - slab.from_amount) * slab.percent_deduction *.01 - elif annual_earning > slab.from_amount and annual_earning > slab.to_amount: + if annual_taxable_earning > slab.from_amount and annual_taxable_earning < slab.to_amount: + taxable_amount += (annual_taxable_earning - slab.from_amount) * slab.percent_deduction *.01 + elif annual_taxable_earning > slab.from_amount and annual_taxable_earning > slab.to_amount: taxable_amount += (slab.to_amount - slab.from_amount) * slab.percent_deduction * .01 return taxable_amount