Skip to content

Commit

Permalink
Merge branch 'version-13-hotfix' of https://github.com/frappe/erpnext
Browse files Browse the repository at this point in the history
…into discount_accounting_v13
  • Loading branch information
deepeshgarg007 committed Aug 6, 2021
2 parents 71077f9 + ffd7642 commit 4573cb2
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 49 deletions.
4 changes: 2 additions & 2 deletions erpnext/accounts/doctype/budget/test_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def test_monthly_budget_against_parent_group_cost_center(self):

def set_total_expense_zero(posting_date, budget_against_field=None, budget_against_CC=None):
if budget_against_field == "project":
budget_against = "_Test Project"
budget_against = frappe.db.get_value("Project", {"project_name": "_Test Project"})
else:
budget_against = budget_against_CC or "_Test Cost Center - _TC"

Expand All @@ -275,7 +275,7 @@ def set_total_expense_zero(posting_date, budget_against_field=None, budget_again
"_Test Bank - _TC", -existing_expense, "_Test Cost Center - _TC", posting_date=nowdate(), submit=True)
elif budget_against_field == "project":
make_journal_entry("_Test Account Cost for Goods Sold - _TC",
"_Test Bank - _TC", -existing_expense, "_Test Cost Center - _TC", submit=True, project="_Test Project", posting_date=nowdate())
"_Test Bank - _TC", -existing_expense, "_Test Cost Center - _TC", submit=True, project=budget_against, posting_date=nowdate())

def make_budget(**args):
args = frappe._dict(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
},
get_query_filters: {
docstatus: 1,
status: ["not in", ["Closed", "Completed"]],
status: ["not in", ["Closed", "Completed", "Return Issued"]],
company: me.frm.doc.company,
is_return: 0
}
Expand Down
3 changes: 2 additions & 1 deletion erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@
'erpnext.hr.utils.calculate_annual_eligible_hra_exemption': 'erpnext.regional.india.utils.calculate_annual_eligible_hra_exemption',
'erpnext.hr.utils.calculate_hra_exemption_for_period': 'erpnext.regional.india.utils.calculate_hra_exemption_for_period',
'erpnext.controllers.accounts_controller.validate_einvoice_fields': 'erpnext.regional.india.e_invoice.utils.validate_einvoice_fields',
'erpnext.assets.doctype.asset.asset.get_depreciation_amount': 'erpnext.regional.india.utils.get_depreciation_amount'
'erpnext.assets.doctype.asset.asset.get_depreciation_amount': 'erpnext.regional.india.utils.get_depreciation_amount',
'erpnext.stock.doctype.item.item.set_item_tax_from_hsn_code': 'erpnext.regional.india.utils.set_item_tax_from_hsn_code'
},
'United Arab Emirates': {
'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.united_arab_emirates.utils.update_itemised_tax_data',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ def get_amount(self, sal_start_date, sal_end_date):
no_of_days = date_diff(getdate(end_date), getdate(start_date)) + 1
return amount_per_day * no_of_days

@frappe.whitelist()
def get_additional_salaries(employee, start_date, end_date, component_type):
additional_salary_list = frappe.db.sql("""
select name, salary_component as component, type, amount, overwrite_salary_structure_amount as overwrite,
deduct_full_tax_on_selected_payroll_date, is_recurring
select name, salary_component as component, type, amount,
overwrite_salary_structure_amount as overwrite,
deduct_full_tax_on_selected_payroll_date
from `tabAdditional Salary`
where employee=%(employee)s
and docstatus = 1
Expand Down
11 changes: 1 addition & 10 deletions erpnext/payroll/doctype/salary_detail/salary_detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"year_to_date",
"section_break_5",
"additional_salary",
"is_recurring_additional_salary",
"statistical_component",
"depends_on_payment_days",
"exempted_from_income_tax",
Expand Down Expand Up @@ -236,19 +235,11 @@
"label": "Year To Date",
"options": "currency",
"read_only": 1
},
{
"default": "0",
"depends_on": "eval:doc.parenttype=='Salary Slip' && doc.parentfield=='earnings' && doc.additional_salary",
"fieldname": "is_recurring_additional_salary",
"fieldtype": "Check",
"label": "Is Recurring Additional Salary",
"read_only": 1
}
],
"istable": 1,
"links": [],
"modified": "2021-03-14 13:39:15.847158",
"modified": "2021-01-14 13:39:15.847158",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Salary Detail",
Expand Down
21 changes: 5 additions & 16 deletions erpnext/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from frappe.utils import add_days, cint, cstr, flt, getdate, rounded, date_diff, money_in_words, formatdate, get_first_day
from frappe.model.naming import make_autoname
from frappe.utils.background_jobs import enqueue

from frappe import msgprint, _
from erpnext.payroll.doctype.payroll_entry.payroll_entry import get_start_end_dates
from erpnext.hr.doctype.employee.employee import get_holiday_list_for_employee
from erpnext.utilities.transaction_base import TransactionBase
from frappe.utils.background_jobs import enqueue
from erpnext.payroll.doctype.additional_salary.additional_salary import get_additional_salaries
from erpnext.payroll.doctype.payroll_period.payroll_period import get_period_factor, get_payroll_period
from erpnext.payroll.doctype.employee_benefit_application.employee_benefit_application import get_benefit_component_amount
Expand Down Expand Up @@ -618,8 +618,7 @@ def add_additional_salary_components(self, component_type):
get_salary_component_data(additional_salary.component),
additional_salary.amount,
component_type,
additional_salary,
is_recurring = additional_salary.is_recurring
additional_salary
)

def add_tax_components(self, payroll_period):
Expand All @@ -640,7 +639,7 @@ def add_tax_components(self, payroll_period):
tax_row = get_salary_component_data(d)
self.update_component_row(tax_row, tax_amount, "deductions")

def update_component_row(self, component_data, amount, component_type, additional_salary=None, is_recurring = 0):
def update_component_row(self, component_data, amount, component_type, additional_salary=None):
component_row = None
for d in self.get(component_type):
if d.salary_component != component_data.salary_component:
Expand Down Expand Up @@ -681,7 +680,6 @@ def update_component_row(self, component_data, amount, component_type, additiona
component_row.set('abbr', abbr)

if additional_salary:
component_row.is_recurring_additional_salary = is_recurring
component_row.default_amount = 0
component_row.additional_amount = amount
component_row.additional_salary = additional_salary.name
Expand Down Expand Up @@ -715,7 +713,6 @@ def calculate_variable_tax(self, payroll_period, tax_component):
# get remaining numbers of sub-period (period for which one salary is processed)
remaining_sub_periods = get_period_factor(self.employee,
self.start_date, self.end_date, self.payroll_frequency, payroll_period)[1]

# get taxable_earnings, paid_taxes for previous period
previous_taxable_earnings = self.get_taxable_earnings_for_prev_period(payroll_period.start_date,
self.start_date, tax_slab.allow_tax_exemption)
Expand Down Expand Up @@ -875,16 +872,8 @@ def get_taxable_earnings(self, allow_tax_exemption=False, based_on_payment_days=

if earning.is_tax_applicable:
if additional_amount:
if not earning.is_recurring_additional_salary:
taxable_earnings += (amount - additional_amount)
additional_income += additional_amount
else:
to_date = frappe.db.get_value("Additional Salary", earning.additional_salary, 'to_date')
period = (getdate(to_date).month - getdate(self.start_date).month) + 1
if period > 0:
taxable_earnings += (amount - additional_amount) * period
additional_income += additional_amount * period

taxable_earnings += (amount - additional_amount)
additional_income += additional_amount
if earning.deduct_full_tax_on_selected_payroll_date:
additional_income_with_full_tax += additional_amount
continue
Expand Down
13 changes: 12 additions & 1 deletion erpnext/regional/india/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,4 +851,15 @@ def get_depreciation_amount(asset, depreciable_value, row):

depreciation_amount = flt(depreciable_value * (flt(rate_of_depreciation) / 100))

return depreciation_amount
return depreciation_amount

def set_item_tax_from_hsn_code(item):
if not item.taxes and item.gst_hsn_code:
hsn_doc = frappe.get_doc("GST HSN Code", item.gst_hsn_code)

for tax in hsn_doc.taxes:
item.append('taxes', {
'item_tax_template': tax.item_tax_template,
'tax_category': tax.tax_category,
'valid_from': tax.valid_from
})
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2021-05-08 23:13:48.049879",
"modified": "2021-08-04 20:15:59.071493",
"modified_by": "Administrator",
"module": "Setup",
"name": "Transaction Deletion Record",
Expand All @@ -70,6 +70,7 @@
"report": 1,
"role": "System Manager",
"share": 1,
"submit": 1,
"write": 1
}
],
Expand Down
14 changes: 0 additions & 14 deletions erpnext/stock/doctype/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,6 @@ frappe.ui.form.on("Item", {
frm.toggle_reqd('customer', frm.doc.is_customer_provided_item ? 1:0);
},

gst_hsn_code: function(frm) {
if((!frm.doc.taxes || !frm.doc.taxes.length) && frm.doc.gst_hsn_code) {
frappe.db.get_doc("GST HSN Code", frm.doc.gst_hsn_code).then(hsn_doc => {
$.each(hsn_doc.taxes || [], function(i, tax) {
let a = frappe.model.add_child(cur_frm.doc, 'Item Tax', 'taxes');
a.item_tax_template = tax.item_tax_template;
a.tax_category = tax.tax_category;
a.valid_from = tax.valid_from;
frm.refresh_field('taxes');
});
});
}
},

is_fixed_asset: function(frm) {
// set serial no to false & toggles its visibility
frm.set_value('has_serial_no', 0);
Expand Down
5 changes: 5 additions & 0 deletions erpnext/stock/doctype/item/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def validate(self):
self.cant_change()
self.update_show_in_website()
self.validate_item_tax_net_rate_range()
set_item_tax_from_hsn_code(self)

if not self.is_new():
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
Expand Down Expand Up @@ -1305,3 +1306,7 @@ def update_variants(variants, template, publish_progress=True):
def on_doctype_update():
# since route is a Text column, it needs a length for indexing
frappe.db.add_index("Item", ["route(500)"])

@erpnext.allow_regional
def set_item_tax_from_hsn_code(item):
pass
15 changes: 15 additions & 0 deletions erpnext/stock/doctype/item/regional/india.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
frappe.ui.form.on('Item', {
gst_hsn_code: function(frm) {
if ((!frm.doc.taxes || !frm.doc.taxes.length) && frm.doc.gst_hsn_code) {
frappe.db.get_doc("GST HSN Code", frm.doc.gst_hsn_code).then(hsn_doc => {
$.each(hsn_doc.taxes || [], function(i, tax) {
let a = frappe.model.add_child(cur_frm.doc, 'Item Tax', 'taxes');
a.item_tax_template = tax.item_tax_template;
a.tax_category = tax.tax_category;
a.valid_from = tax.valid_from;
frm.refresh_field('taxes');
});
});
}
},
});

0 comments on commit 4573cb2

Please sign in to comment.