mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 21:19:19 +00:00
fix(Asset Repair): Only create GL entries if repair cost is capitalised
This commit is contained in:
@@ -47,7 +47,7 @@ class AssetRepair(Document):
|
|||||||
self.decrease_stock_quantity()
|
self.decrease_stock_quantity()
|
||||||
if self.capitalize_repair_cost:
|
if self.capitalize_repair_cost:
|
||||||
self.check_for_purchase_invoice()
|
self.check_for_purchase_invoice()
|
||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
|
|
||||||
def check_repair_status(self):
|
def check_repair_status(self):
|
||||||
if self.repair_status == "Pending":
|
if self.repair_status == "Pending":
|
||||||
@@ -104,10 +104,12 @@ class AssetRepair(Document):
|
|||||||
gl_entry = []
|
gl_entry = []
|
||||||
company = frappe.db.get_value('Asset', self.asset, 'company')
|
company = frappe.db.get_value('Asset', self.asset, 'company')
|
||||||
repair_and_maintenance_account = frappe.db.get_value('Company', company, 'repair_and_maintenance_account')
|
repair_and_maintenance_account = frappe.db.get_value('Company', company, 'repair_and_maintenance_account')
|
||||||
|
fixed_asset_account = self.get_fixed_asset_account()
|
||||||
|
expense_account = frappe.get_doc('Purchase Invoice', self.purchase_invoice).items[0].expense_account
|
||||||
|
|
||||||
gl_entry = frappe.get_doc({
|
gl_entry = frappe.get_doc({
|
||||||
"doctype": "GL Entry",
|
"doctype": "GL Entry",
|
||||||
"account": self.payable_account,
|
"account": expense_account,
|
||||||
"credit": self.total_repair_cost,
|
"credit": self.total_repair_cost,
|
||||||
"credit_in_account_currency": self.total_repair_cost,
|
"credit_in_account_currency": self.total_repair_cost,
|
||||||
"against": repair_and_maintenance_account,
|
"against": repair_and_maintenance_account,
|
||||||
@@ -119,44 +121,19 @@ class AssetRepair(Document):
|
|||||||
gl_entry.insert()
|
gl_entry.insert()
|
||||||
gl_entry = frappe.get_doc({
|
gl_entry = frappe.get_doc({
|
||||||
"doctype": "GL Entry",
|
"doctype": "GL Entry",
|
||||||
"account": repair_and_maintenance_account,
|
"account": fixed_asset_account,
|
||||||
"debit": self.total_repair_cost,
|
"debit": self.total_repair_cost,
|
||||||
"debit_in_account_currency": self.total_repair_cost,
|
"debit_in_account_currency": self.total_repair_cost,
|
||||||
"against": self.payable_account,
|
"against": expense_account,
|
||||||
"voucher_type": self.doctype,
|
"voucher_type": self.doctype,
|
||||||
"voucher_no": self.name,
|
"voucher_no": self.name,
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
"posting_date": getdate()
|
"posting_date": getdate(),
|
||||||
|
"against_voucher_type": "Purchase Invoice",
|
||||||
|
"against_voucher": self.purchase_invoice
|
||||||
})
|
})
|
||||||
gl_entry.insert()
|
gl_entry.insert()
|
||||||
|
|
||||||
if self.capitalize_repair_cost:
|
|
||||||
fixed_asset_account = self.get_fixed_asset_account()
|
|
||||||
gl_entry = frappe.get_doc({
|
|
||||||
"doctype": "GL Entry",
|
|
||||||
"account": self.payable_account,
|
|
||||||
"credit": self.total_repair_cost,
|
|
||||||
"credit_in_account_currency": self.total_repair_cost,
|
|
||||||
"against": repair_and_maintenance_account,
|
|
||||||
"voucher_type": "Asset",
|
|
||||||
"voucher_no": self.asset,
|
|
||||||
"cost_center": self.cost_center,
|
|
||||||
"posting_date": getdate()
|
|
||||||
})
|
|
||||||
gl_entry.insert()
|
|
||||||
gl_entry = frappe.get_doc({
|
|
||||||
"doctype": "GL Entry",
|
|
||||||
"account": fixed_asset_account,
|
|
||||||
"debit": self.total_repair_cost,
|
|
||||||
"debit_in_account_currency": self.total_repair_cost,
|
|
||||||
"against": self.payable_account,
|
|
||||||
"voucher_type": "Asset",
|
|
||||||
"voucher_no": self.asset,
|
|
||||||
"cost_center": self.cost_center,
|
|
||||||
"posting_date": getdate()
|
|
||||||
})
|
|
||||||
gl_entry.insert()
|
|
||||||
|
|
||||||
def get_fixed_asset_account(self):
|
def get_fixed_asset_account(self):
|
||||||
asset_category = frappe.get_doc('Asset Category', frappe.db.get_value('Asset', self.asset, 'asset_category'))
|
asset_category = frappe.get_doc('Asset Category', frappe.db.get_value('Asset', self.asset, 'asset_category'))
|
||||||
company = frappe.db.get_value('Asset', self.asset, 'company')
|
company = frappe.db.get_value('Asset', self.asset, 'company')
|
||||||
|
|||||||
Reference in New Issue
Block a user