From fb03b9699262dde2293b1d015fed444332e07052 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 29 Mar 2016 11:41:46 +0530 Subject: [PATCH] fixed asset fixes --- erpnext/accounts/doctype/asset/asset.py | 2 +- .../accounts/doctype/purchase_invoice/purchase_invoice.py | 7 +++++-- .../docs/user/manual/en/accounts/managing-fixed-assets.md | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/asset/asset.py b/erpnext/accounts/doctype/asset/asset.py index def9ae961d..d6547a6347 100644 --- a/erpnext/accounts/doctype/asset/asset.py +++ b/erpnext/accounts/doctype/asset/asset.py @@ -101,7 +101,7 @@ class Asset(Document): d.db_set("journal_entry", None) total_depreciation_amount += flt(d.depreciation_amount) - self.db_set("current_value", (self.current_value - total_depreciation_amount)) + self.db_set("current_value", (self.current_value + total_depreciation_amount)) def validate_depreciation_settings_in_company(self): company = frappe.get_doc("Company", self.company) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 7d9745bee3..2699f44f9d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -266,15 +266,18 @@ class PurchaseInvoice(BuyingController): frappe.throw(_("Purchase Date of asset {0} does not match with Purchase Invoice date") .format(d.asset)) - if asset.supplier != self.supplier: + if asset.supplier and asset.supplier != self.supplier: frappe.throw(_("Supplier of asset {0} does not match with the supplier in the Purchase Invoice").format(d.asset)) - if asset.status != "Available": + if asset.status != "Submitted": frappe.throw(_("Row #{0}: Asset {1} is already {2}") .format(d.idx, d.asset, asset.status)) frappe.db.set_value("Asset", asset.name, "purchase_invoice", (self.name if self.docstatus==1 else None)) + + if self.docstatus==1 and not asset.supplier: + frappe.db.set_value("Asset", asset.name, "supplier", self.supplier) def make_gl_entries(self): auto_accounting_for_stock = \ diff --git a/erpnext/docs/user/manual/en/accounts/managing-fixed-assets.md b/erpnext/docs/user/manual/en/accounts/managing-fixed-assets.md index fff8982054..35b83aa819 100644 --- a/erpnext/docs/user/manual/en/accounts/managing-fixed-assets.md +++ b/erpnext/docs/user/manual/en/accounts/managing-fixed-assets.md @@ -28,7 +28,7 @@ Explanation of the fields: - Double Declining Method: An accelerated method of depreciation, it results in higher depreciation expense in the earlier years of ownership. 8. Number of Depreciations: The number of depreciations during the useful life. In case of existing assets which are partially depreciated, mention the number of pending depreciations. 9. Number of Months in a Period: The number of months between two depreciations. -10. Next Depreciation Date: Mention the next depreciation date, even if it is the first one. +10. Next Depreciation Date: Mention the next depreciation date, even if it is the first one. If depreciation already completed, leave it blank. ### Depreciations