feat(Asset Repair): Create GL Entries
This commit is contained in:
parent
0739d4bb1b
commit
e5ab5d8963
@ -34,6 +34,7 @@ class AssetRepair(Document):
|
|||||||
frappe.throw(_("Please update Repair Status."))
|
frappe.throw(_("Please update Repair Status."))
|
||||||
|
|
||||||
self.increase_asset_value()
|
self.increase_asset_value()
|
||||||
|
self.make_gl_entries()
|
||||||
|
|
||||||
def increase_asset_value(self):
|
def increase_asset_value(self):
|
||||||
if self.capitalize_repair_cost:
|
if self.capitalize_repair_cost:
|
||||||
@ -45,64 +46,42 @@ class AssetRepair(Document):
|
|||||||
print(asset_value)
|
print(asset_value)
|
||||||
frappe.db.set_value('Asset', self.asset, 'asset_value', asset_value)
|
frappe.db.set_value('Asset', self.asset, 'asset_value', asset_value)
|
||||||
|
|
||||||
# self.make_gl_entries()
|
def on_cancel(self):
|
||||||
|
if self.payable_account:
|
||||||
|
self.make_gl_entries(cancel=True)
|
||||||
|
|
||||||
# def on_cancel(self):
|
def make_gl_entries(self, cancel=False):
|
||||||
# if self.payable_account:
|
if flt(self.repair_cost) > 0:
|
||||||
# self.make_gl_entries(cancel=True)
|
gl_entries = self.get_gl_entries()
|
||||||
|
make_gl_entries(gl_entries, cancel)
|
||||||
|
|
||||||
# def make_gl_entries(self, cancel=False):
|
def get_gl_entries(self):
|
||||||
# if flt(self.repair_cost) > 0:
|
gl_entry = []
|
||||||
# gl_entries = self.get_gl_entries()
|
company = frappe.db.get_value('Asset', self.asset, 'company')
|
||||||
# make_gl_entries(gl_entries, cancel)
|
repair_and_maintenance_account = frappe.db.get_value('Company', company, 'repair_and_maintenance_account')
|
||||||
|
|
||||||
# def get_gl_entries(self):
|
gl_entry = frappe.get_doc({
|
||||||
# gl_entry = []
|
"doctype": "GL Entry",
|
||||||
# company = frappe.db.get_value('Asset', self.asset, 'company')
|
"account": self.payable_account,
|
||||||
# repair_and_maintenance_account = frappe.db.get_value('Company', company, 'repair_and_maintenance_account')
|
"credit": self.repair_cost,
|
||||||
|
"credit_in_account_currency": self.repair_cost,
|
||||||
# gl_entry = frappe.get_doc({
|
"against": repair_and_maintenance_account,
|
||||||
# "doctype": "GL Entry",
|
"voucher_type": self.doctype,
|
||||||
# "account": self.payable_account,
|
"voucher_no": self.name,
|
||||||
# "credit": self.repair_cost,
|
"cost_center": "Main - F"
|
||||||
# "credit_in_account_currency": self.repair_cost,
|
})
|
||||||
# "against": repair_and_maintenance_account,
|
gl_entry.insert()
|
||||||
# "voucher_type": self.doctype,
|
gl_entry = frappe.get_doc({
|
||||||
# "voucher_no": self.name
|
"doctype": "GL Entry",
|
||||||
# })
|
"account": repair_and_maintenance_account,
|
||||||
# gl_entry.insert()
|
"debit": self.repair_cost,
|
||||||
# gl_entry = frappe.get_doc({
|
"debit_in_account_currency": self.repair_cost,
|
||||||
# "doctype": "GL Entry",
|
"against": self.payable_account,
|
||||||
# "account": repair_and_maintenance_account,
|
"voucher_type": self.doctype,
|
||||||
# "debit": self.repair_cost,
|
"voucher_no": self.name,
|
||||||
# "credit_in_account_currency": self.repair_cost,
|
"cost_center": "Main - F"
|
||||||
# "against": self.payable_account,
|
})
|
||||||
# "voucher_type": self.doctype,
|
gl_entry.insert()
|
||||||
# "voucher_no": self.name
|
|
||||||
# })
|
|
||||||
# gl_entry.insert()
|
|
||||||
|
|
||||||
# gl_entry.append(
|
|
||||||
# self.get_gl_dict({
|
|
||||||
# "account": self.payable_account,
|
|
||||||
# "credit": self.repair_cost,
|
|
||||||
# "credit_in_account_currency": self.repair_cost,
|
|
||||||
# "against": repair_and_maintenance_account,
|
|
||||||
# "against_voucher_type": self.doctype,
|
|
||||||
# "against_voucher": self.name
|
|
||||||
# })
|
|
||||||
# )
|
|
||||||
|
|
||||||
# gl_entry.append(
|
|
||||||
# self.get_gl_dict({
|
|
||||||
# "account": repair_and_maintenance_account,
|
|
||||||
# "debit": self.repair_cost,
|
|
||||||
# "credit_in_account_currency": self.repair_cost,
|
|
||||||
# "against": self.payable_account,
|
|
||||||
# "against_voucher_type": self.doctype,
|
|
||||||
# "against_voucher": self.name
|
|
||||||
# })
|
|
||||||
# )
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_downtime(failure_date, completion_date):
|
def get_downtime(failure_date, completion_date):
|
||||||
|
@ -744,8 +744,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "repair_and_maintenance_account",
|
"fieldname": "repair_and_maintenance_account",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Link",
|
||||||
"label": "Repair and Maintenance Account"
|
"label": "Repair and Maintenance Account",
|
||||||
|
"options": "Account"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-building",
|
"icon": "fa fa-building",
|
||||||
@ -753,7 +754,7 @@
|
|||||||
"image_field": "company_logo",
|
"image_field": "company_logo",
|
||||||
"is_tree": 1,
|
"is_tree": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-11 21:47:04.667950",
|
"modified": "2021-05-12 16:51:08.187233",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Company",
|
"name": "Company",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user