fix(Asset Repair): Only create GL entries if repair cost is capitalised

This commit is contained in:
GangaManoj 2021-05-14 03:20:15 +05:30
parent 8a41f6354a
commit 6bb920f25e

View File

@ -104,42 +104,17 @@ class AssetRepair(Document):
gl_entry = []
company = frappe.db.get_value('Asset', self.asset, 'company')
repair_and_maintenance_account = frappe.db.get_value('Company', company, 'repair_and_maintenance_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": self.doctype,
"voucher_no": self.name,
"cost_center": self.cost_center,
"posting_date": getdate()
})
gl_entry.insert()
gl_entry = frappe.get_doc({
"doctype": "GL Entry",
"account": repair_and_maintenance_account,
"debit": self.total_repair_cost,
"debit_in_account_currency": self.total_repair_cost,
"against": self.payable_account,
"voucher_type": self.doctype,
"voucher_no": self.name,
"cost_center": self.cost_center,
"posting_date": getdate()
})
gl_entry.insert()
if self.capitalize_repair_cost:
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({
"doctype": "GL Entry",
"account": self.payable_account,
"account": expense_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,
"voucher_type": self.doctype,
"voucher_no": self.name,
"cost_center": self.cost_center,
"posting_date": getdate()
})
@ -149,11 +124,13 @@ class AssetRepair(Document):
"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,
"against": expense_account,
"voucher_type": self.doctype,
"voucher_no": self.name,
"cost_center": self.cost_center,
"posting_date": getdate()
"posting_date": getdate(),
"against_voucher_type": "Purchase Invoice",
"against_voucher": self.purchase_invoice
})
gl_entry.insert()