mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
fix: validate expense account for items linked to sales invoice
This commit is contained in:
committed by
kavin-114
parent
78993c1ebe
commit
9ff3e28f5d
@@ -480,22 +480,26 @@ class DeliveryNote(SellingController):
|
|||||||
|
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
if item.get("against_sales_invoice"):
|
if item.get("against_sales_invoice"):
|
||||||
continue
|
if sdbnb_account and item.expense_account == sdbnb_account:
|
||||||
is_stock_item = frappe.get_cached_value("Item", item.item_code, "is_stock_item")
|
frappe.throw(
|
||||||
# Only stock items
|
_(
|
||||||
if not is_stock_item or item.get("is_fixed_asset") or item.get("is_subcontracted"):
|
"Row #{0}: Stock Delivered But Not Billed account cannot be used for items linked to a Sales Invoice"
|
||||||
continue
|
).format(item.idx)
|
||||||
# Sales Return handling
|
)
|
||||||
if self.is_return and disable_sdbnb_in_sr:
|
else:
|
||||||
if default_expense_account and (
|
is_stock_item = frappe.get_cached_value("Item", item.item_code, "is_stock_item")
|
||||||
not item.expense_account or item.expense_account == sdbnb_account
|
# Only stock items
|
||||||
):
|
if is_stock_item and not item.get("is_fixed_asset") and not item.get("is_subcontracted"):
|
||||||
item.expense_account = default_expense_account
|
# Sales Return handling
|
||||||
continue
|
if self.is_return and disable_sdbnb_in_sr:
|
||||||
|
if default_expense_account and (
|
||||||
|
not item.expense_account or item.expense_account == sdbnb_account
|
||||||
|
):
|
||||||
|
item.expense_account = default_expense_account
|
||||||
|
|
||||||
if sdbnb_account:
|
elif sdbnb_account:
|
||||||
item.expense_account = sdbnb_account
|
item.expense_account = sdbnb_account
|
||||||
elif not item.expense_account and default_expense_account:
|
if not item.expense_account and default_expense_account:
|
||||||
item.expense_account = default_expense_account
|
item.expense_account = default_expense_account
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user