Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a755ca23d | ||
|
|
a5a08c9889 | ||
|
|
a1842103b6 | ||
|
|
4d54430010 | ||
|
|
e855866820 | ||
|
|
580641f55c | ||
|
|
736c34e61a |
@@ -3,7 +3,7 @@ import inspect
|
||||
|
||||
import frappe
|
||||
|
||||
__version__ = "14.23.2"
|
||||
__version__ = "14.23.4"
|
||||
|
||||
|
||||
def get_default_company(user=None):
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user