Fixed Asset module cleanup and fixes
This commit is contained in:
@@ -470,18 +470,44 @@ class AccountsController(TransactionBase):
|
||||
# at quotation / sales order level and we shouldn't stop someone
|
||||
# from creating a sales invoice if sales order is already created
|
||||
|
||||
def validate_asset(self, asset, item_row):
|
||||
if asset.company != self.company:
|
||||
frappe.throw(_("Row #{0}: Asset {1} does not belong to company {2}")
|
||||
.format(item_row.idx, item_row.asset, self.company))
|
||||
def validate_fixed_asset(self):
|
||||
for d in self.get("items"):
|
||||
if d.is_fixed_asset:
|
||||
if d.qty > 1:
|
||||
frappe.throw(_("Row #{0}: Qty must be 1, as item is a fixed asset. Please use separate row for multiple qty.").format(d.idx))
|
||||
|
||||
elif asset.item_code != item_row.item_code:
|
||||
frappe.throw(_("Row #{0}: Asset {1} does not linked to Item {2}")
|
||||
.format(item_row.idx, item_row.asset, item_row.item_code))
|
||||
elif asset.docstatus != 1:
|
||||
frappe.throw(_("Row #{0}: Asset {1} must be submitted").format(item_row.idx, item_row.asset))
|
||||
elif item_row.qty > 1:
|
||||
frappe.throw(_("Row #{0}: Qty must be 1, as item is linked to an asset").format(item_row.idx))
|
||||
if d.meta.get_field("asset"):
|
||||
if not d.asset:
|
||||
frappe.throw(_("Row #{0}: Asset is mandatory for fixed asset purchase/sale")
|
||||
.format(d.idx))
|
||||
else:
|
||||
asset = frappe.get_doc("Asset", d.asset)
|
||||
|
||||
if asset.company != self.company:
|
||||
frappe.throw(_("Row #{0}: Asset {1} does not belong to company {2}")
|
||||
.format(d.idx, d.asset, self.company))
|
||||
|
||||
elif asset.item_code != d.item_code:
|
||||
frappe.throw(_("Row #{0}: Asset {1} does not linked to Item {2}")
|
||||
.format(d.idx, d.asset, d.item_code))
|
||||
|
||||
elif asset.docstatus != 1:
|
||||
frappe.throw(_("Row #{0}: Asset {1} must be submitted").format(d.idx, d.asset))
|
||||
|
||||
elif self.doctype == "Purchase Invoice":
|
||||
if asset.status != "Submitted":
|
||||
frappe.throw(_("Row #{0}: Asset {1} is already {2}")
|
||||
.format(d.idx, d.asset, asset.status))
|
||||
elif asset.is_existing_asset:
|
||||
frappe.throw(_("Row #{0}: Purchase Invoice cannot be made against an existing asset {1}").format(d.idx, d.asset))
|
||||
|
||||
elif self.docstatus=="Sales Invoice" and self.docstatus == 1:
|
||||
if self.update_stock:
|
||||
frappe.throw(_("'Update Stock' cannot be checked for fixed asset sale"))
|
||||
|
||||
elif asset.status in ("Scrapped", "Cancelled", "Sold"):
|
||||
frappe.throw(_("Row #{0}: Asset {1} cannot be submitted, it is already {2}")
|
||||
.format(d.idx, d.asset, asset.status))
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_tax_rate(account_head):
|
||||
|
||||
Reference in New Issue
Block a user