mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-20 07:22:13 +00:00
fix: set expense account as Assets RBNB only if it is booked in linked PR (backport #41368) (#41673)
fix: set expense account as Assets RBNB only if it is booked in linked PR (#41368)
* fix: set expense account as Assets RBNB only if it is booked in linked PR
* fix: broken translations
(cherry picked from commit 014486de39)
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
@@ -70,7 +70,7 @@ class POSClosingEntry(StatusUpdater):
|
|||||||
for key, value in pos_occurences.items():
|
for key, value in pos_occurences.items():
|
||||||
if len(value) > 1:
|
if len(value) > 1:
|
||||||
error_list.append(
|
error_list.append(
|
||||||
_(f"{frappe.bold(key)} is added multiple times on rows: {frappe.bold(value)}")
|
_("{0} is added multiple times on rows: {1}").format(frappe.bold(key), frappe.bold(value))
|
||||||
)
|
)
|
||||||
|
|
||||||
if error_list:
|
if error_list:
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class POSInvoiceMergeLog(Document):
|
|||||||
for key, value in pos_occurences.items():
|
for key, value in pos_occurences.items():
|
||||||
if len(value) > 1:
|
if len(value) > 1:
|
||||||
error_list.append(
|
error_list.append(
|
||||||
_(f"{frappe.bold(key)} is added multiple times on rows: {frappe.bold(value)}")
|
_("{0} is added multiple times on rows: {1}").format(frappe.bold(key), frappe.bold(value))
|
||||||
)
|
)
|
||||||
|
|
||||||
if error_list:
|
if error_list:
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
|
stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
|
||||||
stock_items = self.get_stock_items()
|
stock_items = self.get_stock_items()
|
||||||
|
|
||||||
asset_received_but_not_billed = None
|
asset_received_but_not_billed = self.get_company_default("asset_received_but_not_billed")
|
||||||
|
|
||||||
if self.update_stock:
|
if self.update_stock:
|
||||||
self.validate_item_code()
|
self.validate_item_code()
|
||||||
@@ -531,26 +531,40 @@ class PurchaseInvoice(BuyingController):
|
|||||||
frappe.msgprint(msg, title=_("Expense Head Changed"))
|
frappe.msgprint(msg, title=_("Expense Head Changed"))
|
||||||
|
|
||||||
item.expense_account = stock_not_billed_account
|
item.expense_account = stock_not_billed_account
|
||||||
elif item.is_fixed_asset and item.pr_detail:
|
|
||||||
if not asset_received_but_not_billed:
|
|
||||||
asset_received_but_not_billed = self.get_company_default("asset_received_but_not_billed")
|
|
||||||
item.expense_account = asset_received_but_not_billed
|
|
||||||
elif item.is_fixed_asset:
|
elif item.is_fixed_asset:
|
||||||
account_type = (
|
account = None
|
||||||
"capital_work_in_progress_account"
|
if item.pr_detail:
|
||||||
if is_cwip_accounting_enabled(item.asset_category)
|
# check if 'Asset Received But Not Billed' account is credited in Purchase receipt or not
|
||||||
else "fixed_asset_account"
|
arbnb_booked_in_pr = frappe.db.get_value(
|
||||||
)
|
"GL Entry",
|
||||||
asset_category_account = get_asset_category_account(
|
{
|
||||||
account_type, item=item.item_code, company=self.company
|
"voucher_type": "Purchase Receipt",
|
||||||
)
|
"voucher_no": item.purchase_receipt,
|
||||||
if not asset_category_account:
|
"account": asset_received_but_not_billed,
|
||||||
form_link = get_link_to_form("Asset Category", item.asset_category)
|
},
|
||||||
throw(
|
"name",
|
||||||
_("Please set Fixed Asset Account in {} against {}.").format(form_link, self.company),
|
|
||||||
title=_("Missing Account"),
|
|
||||||
)
|
)
|
||||||
item.expense_account = asset_category_account
|
if arbnb_booked_in_pr:
|
||||||
|
account = asset_received_but_not_billed
|
||||||
|
|
||||||
|
if not account:
|
||||||
|
account_type = (
|
||||||
|
"capital_work_in_progress_account"
|
||||||
|
if is_cwip_accounting_enabled(item.asset_category)
|
||||||
|
else "fixed_asset_account"
|
||||||
|
)
|
||||||
|
account = get_asset_category_account(
|
||||||
|
account_type, item=item.item_code, company=self.company
|
||||||
|
)
|
||||||
|
if not account:
|
||||||
|
form_link = get_link_to_form("Asset Category", item.asset_category)
|
||||||
|
throw(
|
||||||
|
_("Please set Fixed Asset Account in {} against {}.").format(
|
||||||
|
form_link, self.company
|
||||||
|
),
|
||||||
|
title=_("Missing Account"),
|
||||||
|
)
|
||||||
|
item.expense_account = account
|
||||||
elif not item.expense_account and for_validate:
|
elif not item.expense_account and for_validate:
|
||||||
throw(_("Expense account is mandatory for item {0}").format(item.item_code or item.item_name))
|
throw(_("Expense account is mandatory for item {0}").format(item.item_code or item.item_name))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user