Merge branch 'version-13-hotfix' into fix-salary-calc-pd

This commit is contained in:
Rucha Mahabal
2022-07-12 11:42:07 +05:30
committed by GitHub
7 changed files with 166 additions and 16 deletions

View File

@@ -181,12 +181,20 @@ class RequestforQuotation(BuyingController):
doc_args = self.as_dict() doc_args = self.as_dict()
doc_args.update({"supplier": data.get("supplier"), "supplier_name": data.get("supplier_name")}) doc_args.update({"supplier": data.get("supplier"), "supplier_name": data.get("supplier_name")})
# Get Contact Full Name
supplier_name = None
if data.get("contact"):
contact_name = frappe.db.get_value(
"Contact", data.get("contact"), ["first_name", "middle_name", "last_name"]
)
supplier_name = (" ").join(x for x in contact_name if x) # remove any blank values
args = { args = {
"update_password_link": update_password_link, "update_password_link": update_password_link,
"message": frappe.render_template(self.message_for_supplier, doc_args), "message": frappe.render_template(self.message_for_supplier, doc_args),
"rfq_link": rfq_link, "rfq_link": rfq_link,
"user_fullname": full_name, "user_fullname": full_name,
"supplier_name": data.get("supplier_name"), "supplier_name": supplier_name or data.get("supplier_name"),
"supplier_salutation": self.salutation or "Dear Mx.", "supplier_salutation": self.salutation or "Dear Mx.",
} }

View File

@@ -299,7 +299,7 @@ class BuyingController(StockController, Subcontracting):
raise_error_if_no_rate=False, raise_error_if_no_rate=False,
) )
rate = flt(outgoing_rate * d.conversion_factor, d.precision("rate")) rate = flt(outgoing_rate * (d.conversion_factor or 1), d.precision("rate"))
else: else:
rate = frappe.db.get_value(ref_doctype, d.get(frappe.scrub(ref_doctype)), "rate") rate = frappe.db.get_value(ref_doctype, d.get(frappe.scrub(ref_doctype)), "rate")

View File

@@ -368,3 +368,4 @@ erpnext.patches.v13_0.set_per_billed_in_return_delivery_note
erpnext.patches.v13_0.update_employee_advance_status erpnext.patches.v13_0.update_employee_advance_status
erpnext.patches.v13_0.job_card_status_on_hold erpnext.patches.v13_0.job_card_status_on_hold
erpnext.patches.v13_0.add_cost_center_in_loans erpnext.patches.v13_0.add_cost_center_in_loans
erpnext.patches.v13_0.show_india_localisation_deprecation_warning

View File

@@ -0,0 +1,15 @@
import click
import frappe
def execute():
if not frappe.db.exists("Company", {"country": "India"}):
return
click.secho(
"India-specific regional features have been moved to a separate app"
" and will be removed from ERPNext in Version 14."
" Please install India Compliance after upgrading to Version 14:\n"
"https://github.com/resilient-tech/india-compliance",
fg="yellow",
)

View File

@@ -468,6 +468,7 @@ class PurchaseReceipt(BuyingController):
and not d.is_fixed_asset and not d.is_fixed_asset
and flt(d.qty) and flt(d.qty)
and provisional_accounting_for_non_stock_items and provisional_accounting_for_non_stock_items
and d.get("provisional_expense_account")
): ):
self.add_provisional_gl_entry( self.add_provisional_gl_entry(
d, gl_entries, self.posting_date, d.get("provisional_expense_account") d, gl_entries, self.posting_date, d.get("provisional_expense_account")

View File

@@ -5,7 +5,7 @@
import frappe import frappe
from frappe.permissions import add_user_permission, remove_user_permission from frappe.permissions import add_user_permission, remove_user_permission
from frappe.tests.utils import FrappeTestCase, change_settings from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.utils import flt, nowdate, nowtime from frappe.utils import add_days, flt, nowdate, nowtime
from six import iteritems from six import iteritems
from erpnext.accounts.doctype.account.test_account import get_inventory_account from erpnext.accounts.doctype.account.test_account import get_inventory_account
@@ -1414,6 +1414,138 @@ class TestStockEntry(FrappeTestCase):
self.assertEqual(se.items[0].item_name, item.item_name) self.assertEqual(se.items[0].item_name, item.item_name)
self.assertEqual(se.items[0].stock_uom, item.stock_uom) self.assertEqual(se.items[0].stock_uom, item.stock_uom)
def test_reposting_for_depedent_warehouse(self):
from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation import repost_sl_entries
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
# Inward at WH1 warehouse (Component)
# 1st Repack (Component (WH1) - Subcomponent (WH2))
# 2nd Repack (Subcomponent (WH2) - FG Item (WH3))
# Material Transfer of FG Item -> WH 3 -> WH2 -> Wh1 (Two transfer entries)
# Backdated transction which should update valuation rate in repack as well trasfer entries
for item_code in ["FG Item 1", "Sub Component 1", "Component 1"]:
create_item(item_code)
for warehouse in ["WH 1", "WH 2", "WH 3"]:
create_warehouse(warehouse)
make_stock_entry(
item_code="Component 1",
rate=100,
purpose="Material Receipt",
qty=10,
to_warehouse="WH 1 - _TC",
posting_date=add_days(nowdate(), -10),
)
repack1 = make_stock_entry(
item_code="Component 1",
purpose="Repack",
do_not_save=True,
qty=10,
from_warehouse="WH 1 - _TC",
posting_date=add_days(nowdate(), -9),
)
repack1.append(
"items",
{
"item_code": "Sub Component 1",
"qty": 10,
"t_warehouse": "WH 2 - _TC",
"transfer_qty": 10,
"uom": "Nos",
"stock_uom": "Nos",
"conversion_factor": 1.0,
},
)
repack1.save()
repack1.submit()
self.assertEqual(repack1.items[1].basic_rate, 100)
self.assertEqual(repack1.items[1].amount, 1000)
repack2 = make_stock_entry(
item_code="Sub Component 1",
purpose="Repack",
do_not_save=True,
qty=10,
from_warehouse="WH 2 - _TC",
posting_date=add_days(nowdate(), -8),
)
repack2.append(
"items",
{
"item_code": "FG Item 1",
"qty": 10,
"t_warehouse": "WH 3 - _TC",
"transfer_qty": 10,
"uom": "Nos",
"stock_uom": "Nos",
"conversion_factor": 1.0,
},
)
repack2.save()
repack2.submit()
self.assertEqual(repack2.items[1].basic_rate, 100)
self.assertEqual(repack2.items[1].amount, 1000)
transfer1 = make_stock_entry(
item_code="FG Item 1",
purpose="Material Transfer",
qty=10,
from_warehouse="WH 3 - _TC",
to_warehouse="WH 2 - _TC",
posting_date=add_days(nowdate(), -7),
)
self.assertEqual(transfer1.items[0].basic_rate, 100)
self.assertEqual(transfer1.items[0].amount, 1000)
transfer2 = make_stock_entry(
item_code="FG Item 1",
purpose="Material Transfer",
qty=10,
from_warehouse="WH 2 - _TC",
to_warehouse="WH 1 - _TC",
posting_date=add_days(nowdate(), -6),
)
self.assertEqual(transfer2.items[0].basic_rate, 100)
self.assertEqual(transfer2.items[0].amount, 1000)
# Backdated transaction
receipt2 = make_stock_entry(
item_code="Component 1",
rate=200,
purpose="Material Receipt",
qty=10,
to_warehouse="WH 1 - _TC",
posting_date=add_days(nowdate(), -15),
)
self.assertEqual(receipt2.items[0].basic_rate, 200)
self.assertEqual(receipt2.items[0].amount, 2000)
repost_name = frappe.db.get_value(
"Repost Item Valuation", {"voucher_no": receipt2.name, "docstatus": 1}, "name"
)
doc = frappe.get_doc("Repost Item Valuation", repost_name)
repost_sl_entries(doc)
for obj in [repack1, repack2, transfer1, transfer2]:
obj.load_from_db()
index = 1 if obj.purpose == "Repack" else 0
self.assertEqual(obj.items[index].basic_rate, 200)
self.assertEqual(obj.items[index].basic_amount, 2000)
def make_serialized_item(**args): def make_serialized_item(**args):
args = frappe._dict(args) args = frappe._dict(args)

View File

@@ -247,16 +247,11 @@ def repost_future_sle(
data.sle_changed = False data.sle_changed = False
i += 1 i += 1
if doc and i % 2 == 0: if doc:
update_args_in_repost_item_valuation( update_args_in_repost_item_valuation(
doc, i, args, distinct_item_warehouses, affected_transactions doc, i, args, distinct_item_warehouses, affected_transactions
) )
if doc and args:
update_args_in_repost_item_valuation(
doc, i, args, distinct_item_warehouses, affected_transactions
)
def update_args_in_repost_item_valuation( def update_args_in_repost_item_valuation(
doc, index, args, distinct_item_warehouses, affected_transactions doc, index, args, distinct_item_warehouses, affected_transactions
@@ -491,7 +486,8 @@ class update_entries_after(object):
elif dependant_sle.item_code == self.item_code and dependant_sle.warehouse in self.data: elif dependant_sle.item_code == self.item_code and dependant_sle.warehouse in self.data:
return entries_to_fix return entries_to_fix
else: else:
return self.append_future_sle_for_dependant(dependant_sle, entries_to_fix) self.append_future_sle_for_dependant(dependant_sle, entries_to_fix)
return entries_to_fix
def update_distinct_item_warehouses(self, dependant_sle): def update_distinct_item_warehouses(self, dependant_sle):
key = (dependant_sle.item_code, dependant_sle.warehouse) key = (dependant_sle.item_code, dependant_sle.warehouse)
@@ -510,14 +506,11 @@ class update_entries_after(object):
def append_future_sle_for_dependant(self, dependant_sle, entries_to_fix): def append_future_sle_for_dependant(self, dependant_sle, entries_to_fix):
self.initialize_previous_data(dependant_sle) self.initialize_previous_data(dependant_sle)
self.distinct_item_warehouses[(self.item_code, dependant_sle.warehouse)] = frappe._dict(
args = self.data[dependant_sle.warehouse].previous_sle or frappe._dict( {"sle": dependant_sle}
{"item_code": self.item_code, "warehouse": dependant_sle.warehouse}
) )
future_sle_for_dependant = list(self.get_sle_after_datetime(args))
entries_to_fix.extend(future_sle_for_dependant) self.new_items_found = True
return sorted(entries_to_fix, key=lambda k: k["timestamp"])
def process_sle(self, sle): def process_sle(self, sle):
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos