diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 729c101a7c..545967eb97 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -81,7 +81,6 @@ class PurchaseInvoice(BuyingController): self.validate_write_off_account() self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount", "items") self.validate_fixed_asset() - self.validate_fixed_asset_account() self.create_remarks() self.set_status() validate_inter_company_party(self.doctype, self.supplier, self.company, self.inter_company_invoice_reference) @@ -436,7 +435,7 @@ class PurchaseInvoice(BuyingController): "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "credit": flt(item.rm_supp_cost) }, warehouse_account[self.supplier_warehouse]["account_currency"])) - else: + elif not item.is_fixed_asset: gl_entries.append( self.get_gl_dict({ "account": item.expense_account, @@ -479,11 +478,17 @@ class PurchaseInvoice(BuyingController): asset_amount = flt(item.net_amount) + flt(item.item_tax_amount/self.conversion_rate) base_asset_amount = flt(item.base_net_amount + item.item_tax_amount) + item.expense_account = item.expense_account or asset_accounts[0] + + if (not item.expense_account or frappe.db.get_value('Account', + item.expense_account, 'account_type') != 'Asset Received But Not Billed'): + frappe.throw(_("Row {0}: Expense account must be of type Asset Received But Not Billed"). + format(item.idx)) if not self.update_stock: - asset_rbnb_currency = get_account_currency(asset_accounts[0]) + asset_rbnb_currency = get_account_currency(item.expense_account) gl_entries.append(self.get_gl_dict({ - "account": asset_accounts[0], + "account": item.expense_account, "against": self.supplier, "remarks": self.get("remarks") or _("Accounting Entry for Asset"), "debit": base_asset_amount, @@ -518,7 +523,7 @@ class PurchaseInvoice(BuyingController): })) if item.item_tax_amount and not cint(erpnext.is_perpetual_inventory_enabled(self.company)): - asset_eiiav_currency = get_account_currency(asset_accounts[0]) + asset_eiiav_currency = get_account_currency(asset_accounts[1]) gl_entries.append(self.get_gl_dict({ "account": asset_accounts[1], "against": self.supplier, @@ -751,13 +756,6 @@ class PurchaseInvoice(BuyingController): for pr in set(updated_pr): frappe.get_doc("Purchase Receipt", pr).update_billing_percentage(update_modified=update_modified) - def validate_fixed_asset_account(self): - for d in self.get('items'): - if d.is_fixed_asset: - account_type = frappe.db.get_value("Account", d.expense_account, "account_type") - if account_type != 'Fixed Asset': - frappe.throw(_("Row {0}# Account must be of type 'Fixed Asset'").format(d.idx)) - def on_recurring(self, reference_doc, auto_repeat_doc): self.due_date = None diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 2d0bd52fd0..7134b91cd0 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -11,6 +11,9 @@ from erpnext.accounts.utils import get_account_currency def execute(filters=None): + if not filters: + return [], [] + account_details = {} if filters and filters.get('print_in_account_currency') and \ diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index a16047c34e..b68f24ae3d 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -621,8 +621,8 @@ class AccountsController(TransactionBase): 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)) + # 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)) if d.meta.get_field("asset") and d.asset: asset = frappe.get_doc("Asset", d.asset) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 8b6dd176e1..a4e95a1bc1 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -366,7 +366,7 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select tabAccount.name from `tabAccount` where (tabAccount.report_type = "Profit and Loss" - or tabAccount.account_type in ("Expense Account", "Fixed Asset", "Temporary")) + or tabAccount.account_type in ("Expense Account", "Fixed Asset", "Temporary", "Asset Received But Not Billed")) and tabAccount.is_group=0 and tabAccount.docstatus!=2 and tabAccount.{key} LIKE %(txt)s