fix: Scrap Asset Accounting Dimensions (#31949)
* fix: Scrap Asset Accounting Dimensions
This commit is contained in:
parent
c917d716f7
commit
c760ca2323
@ -1081,7 +1081,7 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
if self.is_return:
|
if self.is_return:
|
||||||
fixed_asset_gl_entries = get_gl_entries_on_asset_regain(
|
fixed_asset_gl_entries = get_gl_entries_on_asset_regain(
|
||||||
asset, item.base_net_amount, item.finance_book
|
asset, item.base_net_amount, item.finance_book, self.get("doctype"), self.get("name")
|
||||||
)
|
)
|
||||||
asset.db_set("disposal_date", None)
|
asset.db_set("disposal_date", None)
|
||||||
|
|
||||||
@ -1091,7 +1091,7 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
||||||
asset, item.base_net_amount, item.finance_book
|
asset, item.base_net_amount, item.finance_book, self.get("doctype"), self.get("name")
|
||||||
)
|
)
|
||||||
asset.db_set("disposal_date", self.posting_date)
|
asset.db_set("disposal_date", self.posting_date)
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ frappe.ui.form.on('Asset', {
|
|||||||
datasets: [{
|
datasets: [{
|
||||||
color: 'green',
|
color: 'green',
|
||||||
values: asset_values,
|
values: asset_values,
|
||||||
formatted: asset_values.map(d => d.toFixed(2))
|
formatted: asset_values.map(d => d?.toFixed(2))
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
type: 'line'
|
type: 'line'
|
||||||
|
@ -235,7 +235,9 @@ def restore_asset(asset_name):
|
|||||||
asset.set_status()
|
asset.set_status()
|
||||||
|
|
||||||
|
|
||||||
def get_gl_entries_on_asset_regain(asset, selling_amount=0, finance_book=None):
|
def get_gl_entries_on_asset_regain(
|
||||||
|
asset, selling_amount=0, finance_book=None, voucher_type=None, voucher_no=None
|
||||||
|
):
|
||||||
(
|
(
|
||||||
fixed_asset_account,
|
fixed_asset_account,
|
||||||
asset,
|
asset,
|
||||||
@ -247,28 +249,45 @@ def get_gl_entries_on_asset_regain(asset, selling_amount=0, finance_book=None):
|
|||||||
) = get_asset_details(asset, finance_book)
|
) = get_asset_details(asset, finance_book)
|
||||||
|
|
||||||
gl_entries = [
|
gl_entries = [
|
||||||
|
asset.get_gl_dict(
|
||||||
{
|
{
|
||||||
"account": fixed_asset_account,
|
"account": fixed_asset_account,
|
||||||
"debit_in_account_currency": asset.gross_purchase_amount,
|
"debit_in_account_currency": asset.gross_purchase_amount,
|
||||||
"debit": asset.gross_purchase_amount,
|
"debit": asset.gross_purchase_amount,
|
||||||
"cost_center": depreciation_cost_center,
|
"cost_center": depreciation_cost_center,
|
||||||
|
"posting_date": getdate(),
|
||||||
},
|
},
|
||||||
|
item=asset,
|
||||||
|
),
|
||||||
|
asset.get_gl_dict(
|
||||||
{
|
{
|
||||||
"account": accumulated_depr_account,
|
"account": accumulated_depr_account,
|
||||||
"credit_in_account_currency": accumulated_depr_amount,
|
"credit_in_account_currency": accumulated_depr_amount,
|
||||||
"credit": accumulated_depr_amount,
|
"credit": accumulated_depr_amount,
|
||||||
"cost_center": depreciation_cost_center,
|
"cost_center": depreciation_cost_center,
|
||||||
|
"posting_date": getdate(),
|
||||||
},
|
},
|
||||||
|
item=asset,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
profit_amount = abs(flt(value_after_depreciation)) - abs(flt(selling_amount))
|
profit_amount = abs(flt(value_after_depreciation)) - abs(flt(selling_amount))
|
||||||
if profit_amount:
|
if profit_amount:
|
||||||
get_profit_gl_entries(profit_amount, gl_entries, disposal_account, depreciation_cost_center)
|
get_profit_gl_entries(
|
||||||
|
asset, profit_amount, gl_entries, disposal_account, depreciation_cost_center
|
||||||
|
)
|
||||||
|
|
||||||
|
if voucher_type and voucher_no:
|
||||||
|
for entry in gl_entries:
|
||||||
|
entry["voucher_type"] = voucher_type
|
||||||
|
entry["voucher_no"] = voucher_no
|
||||||
|
|
||||||
return gl_entries
|
return gl_entries
|
||||||
|
|
||||||
|
|
||||||
def get_gl_entries_on_asset_disposal(asset, selling_amount=0, finance_book=None):
|
def get_gl_entries_on_asset_disposal(
|
||||||
|
asset, selling_amount=0, finance_book=None, voucher_type=None, voucher_no=None
|
||||||
|
):
|
||||||
(
|
(
|
||||||
fixed_asset_account,
|
fixed_asset_account,
|
||||||
asset,
|
asset,
|
||||||
@ -280,23 +299,38 @@ def get_gl_entries_on_asset_disposal(asset, selling_amount=0, finance_book=None)
|
|||||||
) = get_asset_details(asset, finance_book)
|
) = get_asset_details(asset, finance_book)
|
||||||
|
|
||||||
gl_entries = [
|
gl_entries = [
|
||||||
|
asset.get_gl_dict(
|
||||||
{
|
{
|
||||||
"account": fixed_asset_account,
|
"account": fixed_asset_account,
|
||||||
"credit_in_account_currency": asset.gross_purchase_amount,
|
"credit_in_account_currency": asset.gross_purchase_amount,
|
||||||
"credit": asset.gross_purchase_amount,
|
"credit": asset.gross_purchase_amount,
|
||||||
"cost_center": depreciation_cost_center,
|
"cost_center": depreciation_cost_center,
|
||||||
|
"posting_date": getdate(),
|
||||||
},
|
},
|
||||||
|
item=asset,
|
||||||
|
),
|
||||||
|
asset.get_gl_dict(
|
||||||
{
|
{
|
||||||
"account": accumulated_depr_account,
|
"account": accumulated_depr_account,
|
||||||
"debit_in_account_currency": accumulated_depr_amount,
|
"debit_in_account_currency": accumulated_depr_amount,
|
||||||
"debit": accumulated_depr_amount,
|
"debit": accumulated_depr_amount,
|
||||||
"cost_center": depreciation_cost_center,
|
"cost_center": depreciation_cost_center,
|
||||||
|
"posting_date": getdate(),
|
||||||
},
|
},
|
||||||
|
item=asset,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
profit_amount = flt(selling_amount) - flt(value_after_depreciation)
|
profit_amount = flt(selling_amount) - flt(value_after_depreciation)
|
||||||
if profit_amount:
|
if profit_amount:
|
||||||
get_profit_gl_entries(profit_amount, gl_entries, disposal_account, depreciation_cost_center)
|
get_profit_gl_entries(
|
||||||
|
asset, profit_amount, gl_entries, disposal_account, depreciation_cost_center
|
||||||
|
)
|
||||||
|
|
||||||
|
if voucher_type and voucher_no:
|
||||||
|
for entry in gl_entries:
|
||||||
|
entry["voucher_type"] = voucher_type
|
||||||
|
entry["voucher_no"] = voucher_no
|
||||||
|
|
||||||
return gl_entries
|
return gl_entries
|
||||||
|
|
||||||
@ -333,15 +367,21 @@ def get_asset_details(asset, finance_book=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_profit_gl_entries(profit_amount, gl_entries, disposal_account, depreciation_cost_center):
|
def get_profit_gl_entries(
|
||||||
|
asset, profit_amount, gl_entries, disposal_account, depreciation_cost_center
|
||||||
|
):
|
||||||
debit_or_credit = "debit" if profit_amount < 0 else "credit"
|
debit_or_credit = "debit" if profit_amount < 0 else "credit"
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
|
asset.get_gl_dict(
|
||||||
{
|
{
|
||||||
"account": disposal_account,
|
"account": disposal_account,
|
||||||
"cost_center": depreciation_cost_center,
|
"cost_center": depreciation_cost_center,
|
||||||
debit_or_credit: abs(profit_amount),
|
debit_or_credit: abs(profit_amount),
|
||||||
debit_or_credit + "_in_account_currency": abs(profit_amount),
|
debit_or_credit + "_in_account_currency": abs(profit_amount),
|
||||||
}
|
"posting_date": getdate(),
|
||||||
|
},
|
||||||
|
item=asset,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -428,7 +428,11 @@ class AssetCapitalization(StockController):
|
|||||||
asset.reload()
|
asset.reload()
|
||||||
|
|
||||||
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
||||||
asset, item.asset_value, item.get("finance_book") or self.get("finance_book")
|
asset,
|
||||||
|
item.asset_value,
|
||||||
|
item.get("finance_book") or self.get("finance_book"),
|
||||||
|
self.get("doctype"),
|
||||||
|
self.get("name"),
|
||||||
)
|
)
|
||||||
|
|
||||||
asset.db_set("disposal_date", self.posting_date)
|
asset.db_set("disposal_date", self.posting_date)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user