Merge remote-tracking branch 'frappe/develop' into develop
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 729c101..545967e 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -81,7 +81,6 @@
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 @@
"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 @@
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 @@
}))
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 @@
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 2d0bd52..7134b91 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -11,6 +11,9 @@
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 a16047c..b68f24a 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -621,8 +621,8 @@
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 8b6dd17..a4e95a1 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -366,7 +366,7 @@
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