|
|
|
|
@@ -235,7 +235,9 @@ def restore_asset(asset_name):
|
|
|
|
|
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,
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
gl_entries = [
|
|
|
|
|
{
|
|
|
|
|
"account": fixed_asset_account,
|
|
|
|
|
"debit_in_account_currency": asset.gross_purchase_amount,
|
|
|
|
|
"debit": asset.gross_purchase_amount,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"account": accumulated_depr_account,
|
|
|
|
|
"credit_in_account_currency": accumulated_depr_amount,
|
|
|
|
|
"credit": accumulated_depr_amount,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
},
|
|
|
|
|
asset.get_gl_dict(
|
|
|
|
|
{
|
|
|
|
|
"account": fixed_asset_account,
|
|
|
|
|
"debit_in_account_currency": asset.gross_purchase_amount,
|
|
|
|
|
"debit": asset.gross_purchase_amount,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
"posting_date": getdate(),
|
|
|
|
|
},
|
|
|
|
|
item=asset,
|
|
|
|
|
),
|
|
|
|
|
asset.get_gl_dict(
|
|
|
|
|
{
|
|
|
|
|
"account": accumulated_depr_account,
|
|
|
|
|
"credit_in_account_currency": accumulated_depr_amount,
|
|
|
|
|
"credit": accumulated_depr_amount,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
"posting_date": getdate(),
|
|
|
|
|
},
|
|
|
|
|
item=asset,
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
profit_amount = abs(flt(value_after_depreciation)) - abs(flt(selling_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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
gl_entries = [
|
|
|
|
|
{
|
|
|
|
|
"account": fixed_asset_account,
|
|
|
|
|
"credit_in_account_currency": asset.gross_purchase_amount,
|
|
|
|
|
"credit": asset.gross_purchase_amount,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"account": accumulated_depr_account,
|
|
|
|
|
"debit_in_account_currency": accumulated_depr_amount,
|
|
|
|
|
"debit": accumulated_depr_amount,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
},
|
|
|
|
|
asset.get_gl_dict(
|
|
|
|
|
{
|
|
|
|
|
"account": fixed_asset_account,
|
|
|
|
|
"credit_in_account_currency": asset.gross_purchase_amount,
|
|
|
|
|
"credit": asset.gross_purchase_amount,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
"posting_date": getdate(),
|
|
|
|
|
},
|
|
|
|
|
item=asset,
|
|
|
|
|
),
|
|
|
|
|
asset.get_gl_dict(
|
|
|
|
|
{
|
|
|
|
|
"account": accumulated_depr_account,
|
|
|
|
|
"debit_in_account_currency": accumulated_depr_amount,
|
|
|
|
|
"debit": accumulated_depr_amount,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
"posting_date": getdate(),
|
|
|
|
|
},
|
|
|
|
|
item=asset,
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
profit_amount = flt(selling_amount) - flt(value_after_depreciation)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
@@ -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"
|
|
|
|
|
gl_entries.append(
|
|
|
|
|
{
|
|
|
|
|
"account": disposal_account,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
debit_or_credit: abs(profit_amount),
|
|
|
|
|
debit_or_credit + "_in_account_currency": abs(profit_amount),
|
|
|
|
|
}
|
|
|
|
|
asset.get_gl_dict(
|
|
|
|
|
{
|
|
|
|
|
"account": disposal_account,
|
|
|
|
|
"cost_center": depreciation_cost_center,
|
|
|
|
|
debit_or_credit: abs(profit_amount),
|
|
|
|
|
debit_or_credit + "_in_account_currency": abs(profit_amount),
|
|
|
|
|
"posting_date": getdate(),
|
|
|
|
|
},
|
|
|
|
|
item=asset,
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|