Compare commits

...

7 Commits

Author SHA1 Message Date
Frappe PR Bot
9a755ca23d chore(release): Bumped to Version 14.23.4
## [14.23.4](https://github.com/frappe/erpnext/compare/v14.23.3...v14.23.4) (2023-05-06)

### Bug Fixes

* handle empty FBs properly in TB and GL [v14] (backport [#35189](https://github.com/frappe/erpnext/issues/35189)) ([#35191](https://github.com/frappe/erpnext/issues/35191)) ([a5a08c9](a5a08c9889))
2023-05-06 11:12:52 +00:00
mergify[bot]
a5a08c9889 fix: handle empty FBs properly in TB and GL [v14] (backport #35189) (#35191)
fix: handle empty FBs properly in TB and GL [v14] (#35189)

fix: handle empty FBs properly in TB and GL
(cherry picked from commit ed5f39c2c2)

Co-authored-by: Anand Baburajan <anandbaburajan@gmail.com>
2023-05-06 16:41:10 +05:30
Frappe PR Bot
a1842103b6 chore(release): Bumped to Version 14.23.3
## [14.23.3](https://github.com/frappe/erpnext/compare/v14.23.2...v14.23.3) (2023-05-04)

### Bug Fixes

* internal transfer condition ([736c34e](736c34e61a))
* not allow to transfer excess materials against the job card ([580641f](580641f55c))
2023-05-04 18:02:30 +00:00
rohitwaghchaure
4d54430010 Merge pull request #35174 from frappe/mergify/bp/version-14/pr-35163
fix: internal transfer condition (backport #35158) (backport #35163)
2023-05-04 23:30:29 +05:30
rohitwaghchaure
e855866820 Merge pull request #35175 from frappe/mergify/bp/version-14/pr-35169
fix: not allow to transfer excess materials against the job card (backport #35167) (backport #35169)
2023-05-04 23:30:07 +05:30
Rohit Waghchaure
580641f55c fix: not allow to transfer excess materials against the job card
(cherry picked from commit 8167b24219)
(cherry picked from commit b0c042de1b)
2023-05-04 17:11:54 +00:00
Rohit Waghchaure
736c34e61a fix: internal transfer condition
(cherry picked from commit b5a2ccf21d)
(cherry picked from commit f5f4902494)
2023-05-04 17:10:41 +00:00
8 changed files with 89 additions and 16 deletions

View File

@@ -3,7 +3,7 @@ import inspect
import frappe
__version__ = "14.23.2"
__version__ = "14.23.4"
def get_default_company(user=None):

View File

@@ -500,14 +500,18 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
else:
additional_conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
additional_conditions.append(
"(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
)
else:
additional_conditions.append("(finance_book in (%(company_fb)s) OR finance_book IS NULL)")
additional_conditions.append("(finance_book in (%(company_fb)s, '') OR finance_book IS NULL)")
else:
if filters.get("finance_book"):
additional_conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
additional_conditions.append(
"(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
)
else:
additional_conditions.append("(finance_book IS NULL)")
additional_conditions.append("(finance_book in ('') OR finance_book IS NULL)")
if accounting_dimensions:
for dimension in accounting_dimensions:

View File

@@ -253,14 +253,14 @@ def get_conditions(filters):
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
else:
conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
else:
conditions.append("(finance_book in (%(company_fb)s) OR finance_book IS NULL)")
conditions.append("(finance_book in (%(company_fb)s, '') OR finance_book IS NULL)")
else:
if filters.get("finance_book"):
conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
else:
conditions.append("(finance_book IS NULL)")
conditions.append("(finance_book in ('') OR finance_book IS NULL)")
if not filters.get("show_cancelled_entries"):
conditions.append("is_cancelled = 0")

View File

@@ -166,14 +166,16 @@ def get_rootwise_opening_balances(filters, report_type):
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
else:
additional_conditions += " AND (finance_book in (%(finance_book)s) OR finance_book IS NULL)"
additional_conditions += (
" AND (finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
)
else:
additional_conditions += " AND (finance_book in (%(company_fb)s) OR finance_book IS NULL)"
additional_conditions += " AND (finance_book in (%(company_fb)s, '') OR finance_book IS NULL)"
else:
if filters.get("finance_book"):
additional_conditions += " AND (finance_book in (%(finance_book)s) OR finance_book IS NULL)"
additional_conditions += " AND (finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
else:
additional_conditions += " AND (finance_book IS NULL)"
additional_conditions += " AND (finance_book in ('') OR finance_book IS NULL)"
accounting_dimensions = get_accounting_dimensions(as_list=False)

View File

@@ -272,6 +272,42 @@ class TestJobCard(FrappeTestCase):
transfer_entry_2.insert()
self.assertRaises(JobCardOverTransferError, transfer_entry_2.submit)
@change_settings("Manufacturing Settings", {"job_card_excess_transfer": 0})
def test_job_card_excess_material_transfer_with_no_reference(self):
self.transfer_material_against = "Job Card"
self.source_warehouse = "Stores - _TC"
self.generate_required_stock(self.work_order)
job_card_name = frappe.db.get_value("Job Card", {"work_order": self.work_order.name})
# fully transfer both RMs
transfer_entry_1 = make_stock_entry_from_jc(job_card_name)
row = transfer_entry_1.items[0]
# Add new row without reference of the job card item
transfer_entry_1.append(
"items",
{
"item_code": row.item_code,
"item_name": row.item_name,
"item_group": row.item_group,
"qty": row.qty,
"uom": row.uom,
"conversion_factor": row.conversion_factor,
"stock_uom": row.stock_uom,
"basic_rate": row.basic_rate,
"basic_amount": row.basic_amount,
"expense_account": row.expense_account,
"cost_center": row.cost_center,
"s_warehouse": row.s_warehouse,
"t_warehouse": row.t_warehouse,
},
)
self.assertRaises(frappe.ValidationError, transfer_entry_1.insert)
def test_job_card_partial_material_transfer(self):
"Test partial material transfer against Job Card"
self.transfer_material_against = "Job Card"

View File

@@ -379,7 +379,7 @@ class PurchaseReceipt(BuyingController):
)
outgoing_amount = d.base_net_amount
if self.is_internal_supplier and d.valuation_rate:
if self.is_internal_transfer() and d.valuation_rate:
outgoing_amount = abs(
frappe.db.get_value(
"Stock Ledger Entry",

View File

@@ -130,6 +130,7 @@ class StockEntry(StockController):
self.validate_fg_completed_qty()
self.validate_difference_account()
self.set_job_card_data()
self.validate_job_card_item()
self.set_purpose_for_stock_entry()
self.clean_serial_nos()
self.validate_duplicate_serial_no()
@@ -214,6 +215,24 @@ class StockEntry(StockController):
self.from_bom = 1
self.bom_no = data.bom_no
def validate_job_card_item(self):
if not self.job_card:
return
if cint(frappe.db.get_single_value("Manufacturing Settings", "job_card_excess_transfer")):
return
for row in self.items:
if row.job_card_item:
continue
msg = f"""Row #{0}: The job card item reference
is missing. Kindly create the stock entry
from the job card. If you have added the row manually
then you won't be able to add job card item reference."""
frappe.throw(_(msg))
def validate_work_order_status(self):
pro_doc = frappe.get_doc("Work Order", self.work_order)
if pro_doc.status == "Completed":

View File

@@ -556,7 +556,7 @@ class update_entries_after(object):
sle.voucher_type in ["Purchase Receipt", "Purchase Invoice"]
and sle.voucher_detail_no
and sle.actual_qty < 0
and frappe.get_cached_value(sle.voucher_type, sle.voucher_no, "is_internal_supplier")
and is_internal_transfer(sle)
):
sle.outgoing_rate = get_incoming_rate_for_inter_company_transfer(sle)
@@ -679,7 +679,7 @@ class update_entries_after(object):
elif (
sle.voucher_type in ["Purchase Receipt", "Purchase Invoice"]
and sle.voucher_detail_no
and frappe.get_cached_value(sle.voucher_type, sle.voucher_no, "is_internal_supplier")
and is_internal_transfer(sle)
):
rate = get_incoming_rate_for_inter_company_transfer(sle)
else:
@@ -1609,3 +1609,15 @@ def get_incoming_rate_for_inter_company_transfer(sle) -> float:
)
return rate
def is_internal_transfer(sle):
data = frappe.get_cached_value(
sle.voucher_type,
sle.voucher_no,
["is_internal_supplier", "represents_company", "company"],
as_dict=True,
)
if data.is_internal_supplier and data.represents_company == data.company:
return True