Merge pull request #14092 from rohitwaghchaure/enterprise_develop_asset_fixes_for_perpetual
[Fix] Asset gl entry not creating for non perpetual
This commit is contained in:
commit
4ea97c84ac
@ -352,6 +352,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
self.make_supplier_gl_entry(gl_entries)
|
self.make_supplier_gl_entry(gl_entries)
|
||||||
self.make_item_gl_entries(gl_entries)
|
self.make_item_gl_entries(gl_entries)
|
||||||
|
self.get_asset_gl_entry(gl_entries)
|
||||||
self.make_tax_gl_entries(gl_entries)
|
self.make_tax_gl_entries(gl_entries)
|
||||||
|
|
||||||
gl_entries = merge_similar_entries(gl_entries)
|
gl_entries = merge_similar_entries(gl_entries)
|
||||||
@ -389,10 +390,10 @@ class PurchaseInvoice(BuyingController):
|
|||||||
warehouse_account = get_warehouse_account_map()
|
warehouse_account = get_warehouse_account_map()
|
||||||
|
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if flt(item.base_net_amount):
|
if flt(item.base_net_amount) and item.item_code in stock_items:
|
||||||
account_currency = get_account_currency(item.expense_account)
|
account_currency = get_account_currency(item.expense_account)
|
||||||
|
|
||||||
if self.update_stock and self.auto_accounting_for_stock and item.item_code in stock_items:
|
if self.update_stock and self.auto_accounting_for_stock:
|
||||||
val_rate_db_precision = 6 if cint(item.precision("valuation_rate")) <= 6 else 9
|
val_rate_db_precision = 6 if cint(item.precision("valuation_rate")) <= 6 else 9
|
||||||
|
|
||||||
# warehouse account
|
# warehouse account
|
||||||
@ -434,50 +435,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"credit": flt(item.rm_supp_cost)
|
"credit": flt(item.rm_supp_cost)
|
||||||
}, warehouse_account[self.supplier_warehouse]["account_currency"]))
|
}, warehouse_account[self.supplier_warehouse]["account_currency"]))
|
||||||
|
|
||||||
elif item.is_fixed_asset:
|
|
||||||
asset_accounts = self.get_company_default(["asset_received_but_not_billed",
|
|
||||||
"expenses_included_in_asset_valuation", "capital_work_in_progress_account"])
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
if not self.update_stock:
|
|
||||||
asset_rbnb_currency = get_account_currency(asset_accounts[0])
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
|
||||||
"account": asset_accounts[0],
|
|
||||||
"against": self.supplier,
|
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
|
||||||
"debit": base_asset_amount,
|
|
||||||
"debit_in_account_currency": (base_asset_amount
|
|
||||||
if asset_rbnb_currency == self.company_currency else asset_amount)
|
|
||||||
}))
|
|
||||||
else:
|
|
||||||
cwip_account = get_asset_category_account(item.asset,
|
|
||||||
'capital_work_in_progress_account') or asset_accounts[2]
|
|
||||||
|
|
||||||
cwip_account_currency = get_account_currency(cwip_account)
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
|
||||||
"account": cwip_account,
|
|
||||||
"against": self.supplier,
|
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
|
||||||
"debit": base_asset_amount,
|
|
||||||
"debit_in_account_currency": (base_asset_amount
|
|
||||||
if cwip_account_currency == self.company_currency else asset_amount)
|
|
||||||
}))
|
|
||||||
|
|
||||||
if item.item_tax_amount:
|
|
||||||
asset_eiiav_currency = get_account_currency(asset_accounts[0])
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
|
||||||
"account": asset_accounts[1],
|
|
||||||
"against": self.supplier,
|
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
|
||||||
"cost_center": item.cost_center,
|
|
||||||
"credit": item.item_tax_amount,
|
|
||||||
"credit_in_account_currency": (item.item_tax_amount
|
|
||||||
if asset_eiiav_currency == self.company_currency else
|
|
||||||
item.item_tax_amount / self.conversion_rate)
|
|
||||||
}))
|
|
||||||
else:
|
else:
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
@ -513,6 +470,67 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.negative_expense_to_be_booked += flt(item.item_tax_amount, \
|
self.negative_expense_to_be_booked += flt(item.item_tax_amount, \
|
||||||
item.precision("item_tax_amount"))
|
item.precision("item_tax_amount"))
|
||||||
|
|
||||||
|
def get_asset_gl_entry(self, gl_entries):
|
||||||
|
for item in self.get("items"):
|
||||||
|
if item.is_fixed_asset:
|
||||||
|
asset_accounts = self.get_company_default(["asset_received_but_not_billed",
|
||||||
|
"expenses_included_in_asset_valuation", "capital_work_in_progress_account"])
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
if not self.update_stock:
|
||||||
|
asset_rbnb_currency = get_account_currency(asset_accounts[0])
|
||||||
|
gl_entries.append(self.get_gl_dict({
|
||||||
|
"account": asset_accounts[0],
|
||||||
|
"against": self.supplier,
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
||||||
|
"debit": base_asset_amount,
|
||||||
|
"debit_in_account_currency": (base_asset_amount
|
||||||
|
if asset_rbnb_currency == self.company_currency else asset_amount)
|
||||||
|
}))
|
||||||
|
|
||||||
|
if item.item_tax_amount:
|
||||||
|
asset_eiiav_currency = get_account_currency(asset_accounts[0])
|
||||||
|
gl_entries.append(self.get_gl_dict({
|
||||||
|
"account": asset_accounts[1],
|
||||||
|
"against": self.supplier,
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
||||||
|
"cost_center": item.cost_center,
|
||||||
|
"credit": item.item_tax_amount,
|
||||||
|
"credit_in_account_currency": (item.item_tax_amount
|
||||||
|
if asset_eiiav_currency == self.company_currency else
|
||||||
|
item.item_tax_amount / self.conversion_rate)
|
||||||
|
}))
|
||||||
|
else:
|
||||||
|
cwip_account = get_asset_category_account(item.asset,
|
||||||
|
'capital_work_in_progress_account') or asset_accounts[2]
|
||||||
|
|
||||||
|
cwip_account_currency = get_account_currency(cwip_account)
|
||||||
|
gl_entries.append(self.get_gl_dict({
|
||||||
|
"account": cwip_account,
|
||||||
|
"against": self.supplier,
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
||||||
|
"debit": base_asset_amount,
|
||||||
|
"debit_in_account_currency": (base_asset_amount
|
||||||
|
if cwip_account_currency == self.company_currency else asset_amount)
|
||||||
|
}))
|
||||||
|
|
||||||
|
if item.item_tax_amount and not cint(erpnext.is_perpetual_inventory_enabled(self.company)):
|
||||||
|
asset_eiiav_currency = get_account_currency(asset_accounts[0])
|
||||||
|
gl_entries.append(self.get_gl_dict({
|
||||||
|
"account": asset_accounts[1],
|
||||||
|
"against": self.supplier,
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
||||||
|
"cost_center": item.cost_center,
|
||||||
|
"credit": item.item_tax_amount,
|
||||||
|
"credit_in_account_currency": (item.item_tax_amount
|
||||||
|
if asset_eiiav_currency == self.company_currency else
|
||||||
|
item.item_tax_amount / self.conversion_rate)
|
||||||
|
}))
|
||||||
|
|
||||||
|
return gl_entries
|
||||||
|
|
||||||
def make_tax_gl_entries(self, gl_entries):
|
def make_tax_gl_entries(self, gl_entries):
|
||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
valuation_tax = {}
|
valuation_tax = {}
|
||||||
|
@ -2027,6 +2027,39 @@
|
|||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"depends_on": "is_fixed_asset",
|
||||||
|
"fieldname": "asset_location",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Asset Location",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "Location",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -2258,7 +2291,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-04-23 14:07:33.576495",
|
"modified": "2018-05-16 17:50:21.957780",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice Item",
|
"name": "Purchase Invoice Item",
|
||||||
|
@ -28,6 +28,7 @@ class Asset(AccountsController):
|
|||||||
self.validate_expected_value_after_useful_life()
|
self.validate_expected_value_after_useful_life()
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
self.validate_in_use_date()
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.update_stock_movement()
|
self.update_stock_movement()
|
||||||
|
|
||||||
@ -48,6 +49,10 @@ class Asset(AccountsController):
|
|||||||
elif item.is_stock_item:
|
elif item.is_stock_item:
|
||||||
frappe.throw(_("Item {0} must be a non-stock item").format(self.item_code))
|
frappe.throw(_("Item {0} must be a non-stock item").format(self.item_code))
|
||||||
|
|
||||||
|
def validate_in_use_date(self):
|
||||||
|
if not self.available_for_use_date:
|
||||||
|
frappe.throw(_("Available for use data is required"))
|
||||||
|
|
||||||
def set_missing_values(self):
|
def set_missing_values(self):
|
||||||
if not self.asset_category:
|
if not self.asset_category:
|
||||||
self.asset_category = frappe.db.get_value("Item", self.item_code, "asset_category")
|
self.asset_category = frappe.db.get_value("Item", self.item_code, "asset_category")
|
||||||
|
@ -639,10 +639,10 @@ class AccountsController(TransactionBase):
|
|||||||
frappe.throw(_("Row #{0}: Asset {1} must be submitted").format(d.idx, d.asset))
|
frappe.throw(_("Row #{0}: Asset {1} must be submitted").format(d.idx, d.asset))
|
||||||
|
|
||||||
elif self.doctype == "Purchase Invoice":
|
elif self.doctype == "Purchase Invoice":
|
||||||
if asset.status != "Submitted":
|
# if asset.status != "Submitted":
|
||||||
frappe.throw(_("Row #{0}: Asset {1} is already {2}")
|
# frappe.throw(_("Row #{0}: Asset {1} is already {2}")
|
||||||
.format(d.idx, d.asset, asset.status))
|
# .format(d.idx, d.asset, asset.status))
|
||||||
elif getdate(asset.purchase_date) != getdate(self.posting_date):
|
if getdate(asset.purchase_date) != getdate(self.posting_date):
|
||||||
frappe.throw(_("Row #{0}: Posting Date must be same as purchase date {1} of asset {2}").format(d.idx, asset.purchase_date, d.asset))
|
frappe.throw(_("Row #{0}: Posting Date must be same as purchase date {1} of asset {2}").format(d.idx, asset.purchase_date, d.asset))
|
||||||
elif asset.is_existing_asset:
|
elif asset.is_existing_asset:
|
||||||
frappe.throw(_("Row #{0}: Purchase Invoice cannot be made against an existing asset {1}").format(d.idx, d.asset))
|
frappe.throw(_("Row #{0}: Purchase Invoice cannot be made against an existing asset {1}").format(d.idx, d.asset))
|
||||||
|
@ -33,6 +33,10 @@ class StockController(AccountsController):
|
|||||||
items, warehouses = self.get_items_and_warehouses()
|
items, warehouses = self.get_items_and_warehouses()
|
||||||
update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items,
|
update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items,
|
||||||
warehouse_account)
|
warehouse_account)
|
||||||
|
elif self.doctype in ['Purchase Receipt', 'Purchase Invoice']:
|
||||||
|
gl_entries = []
|
||||||
|
gl_entries = self.get_asset_gl_entry(gl_entries)
|
||||||
|
make_gl_entries(gl_entries, from_repost=from_repost)
|
||||||
|
|
||||||
def get_gl_entries(self, warehouse_account=None, default_expense_account=None,
|
def get_gl_entries(self, warehouse_account=None, default_expense_account=None,
|
||||||
default_cost_center=None):
|
default_cost_center=None):
|
||||||
|
@ -62,9 +62,8 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
|||||||
this._super();
|
this._super();
|
||||||
if(this.frm.doc.docstatus===1) {
|
if(this.frm.doc.docstatus===1) {
|
||||||
this.show_stock_ledger();
|
this.show_stock_ledger();
|
||||||
if (erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) {
|
//removed for temporary
|
||||||
this.show_general_ledger();
|
this.show_general_ledger();
|
||||||
}
|
|
||||||
|
|
||||||
this.frm.add_custom_button(__('Asset'), function() {
|
this.frm.add_custom_button(__('Asset'), function() {
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
|
@ -254,40 +254,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
d.rejected_warehouse not in warehouse_with_no_account:
|
d.rejected_warehouse not in warehouse_with_no_account:
|
||||||
warehouse_with_no_account.append(d.warehouse)
|
warehouse_with_no_account.append(d.warehouse)
|
||||||
|
|
||||||
elif d.is_fixed_asset:
|
self.get_asset_gl_entry(gl_entries)
|
||||||
asset_accounts = self.get_company_default(["capital_work_in_progress_account",
|
|
||||||
"asset_received_but_not_billed"])
|
|
||||||
|
|
||||||
# CWIP entry
|
|
||||||
cwip_account = get_asset_category_account(d.asset,
|
|
||||||
'capital_work_in_progress_account') or asset_accounts[0]
|
|
||||||
|
|
||||||
asset_amount = flt(d.net_amount) + flt(d.item_tax_amount/self.conversion_rate)
|
|
||||||
base_asset_amount = flt(d.base_net_amount + d.item_tax_amount)
|
|
||||||
|
|
||||||
cwip_account_currency = get_account_currency(cwip_account)
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
|
||||||
"account": cwip_account,
|
|
||||||
"against": asset_accounts[1],
|
|
||||||
"cost_center": d.cost_center,
|
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
|
||||||
"debit": base_asset_amount,
|
|
||||||
"debit_in_account_currency": (base_asset_amount
|
|
||||||
if cwip_account_currency == self.company_currency else asset_amount)
|
|
||||||
}))
|
|
||||||
|
|
||||||
# Asset received but not billed
|
|
||||||
asset_rbnb_currency = get_account_currency(asset_accounts[1])
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
|
||||||
"account": asset_accounts[1],
|
|
||||||
"against": asset_accounts[0],
|
|
||||||
"cost_center": d.cost_center,
|
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
|
||||||
"credit": base_asset_amount,
|
|
||||||
"credit_in_account_currency": (base_asset_amount
|
|
||||||
if asset_rbnb_currency == self.company_currency else asset_amount)
|
|
||||||
}))
|
|
||||||
|
|
||||||
# Cost center-wise amount breakup for other charges included for valuation
|
# Cost center-wise amount breakup for other charges included for valuation
|
||||||
valuation_tax = {}
|
valuation_tax = {}
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
@ -341,6 +308,44 @@ class PurchaseReceipt(BuyingController):
|
|||||||
|
|
||||||
return process_gl_map(gl_entries)
|
return process_gl_map(gl_entries)
|
||||||
|
|
||||||
|
def get_asset_gl_entry(self, gl_entries):
|
||||||
|
for d in self.get("items"):
|
||||||
|
if d.is_fixed_asset:
|
||||||
|
asset_accounts = self.get_company_default(["capital_work_in_progress_account",
|
||||||
|
"asset_received_but_not_billed"])
|
||||||
|
|
||||||
|
# CWIP entry
|
||||||
|
cwip_account = get_asset_category_account(d.asset,
|
||||||
|
'capital_work_in_progress_account') or asset_accounts[0]
|
||||||
|
|
||||||
|
asset_amount = flt(d.net_amount) + flt(d.item_tax_amount/self.conversion_rate)
|
||||||
|
base_asset_amount = flt(d.base_net_amount + d.item_tax_amount)
|
||||||
|
|
||||||
|
cwip_account_currency = get_account_currency(cwip_account)
|
||||||
|
gl_entries.append(self.get_gl_dict({
|
||||||
|
"account": cwip_account,
|
||||||
|
"against": asset_accounts[1],
|
||||||
|
"cost_center": d.cost_center,
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
||||||
|
"debit": base_asset_amount,
|
||||||
|
"debit_in_account_currency": (base_asset_amount
|
||||||
|
if cwip_account_currency == self.company_currency else asset_amount)
|
||||||
|
}))
|
||||||
|
|
||||||
|
# Asset received but not billed
|
||||||
|
asset_rbnb_currency = get_account_currency(asset_accounts[1])
|
||||||
|
gl_entries.append(self.get_gl_dict({
|
||||||
|
"account": asset_accounts[1],
|
||||||
|
"against": asset_accounts[0],
|
||||||
|
"cost_center": d.cost_center,
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
||||||
|
"credit": base_asset_amount,
|
||||||
|
"credit_in_account_currency": (base_asset_amount
|
||||||
|
if asset_rbnb_currency == self.company_currency else asset_amount)
|
||||||
|
}))
|
||||||
|
|
||||||
|
return gl_entries
|
||||||
|
|
||||||
def update_status(self, status):
|
def update_status(self, status):
|
||||||
self.set_status(update=True, status = status)
|
self.set_status(update=True, status = status)
|
||||||
self.notify_update()
|
self.notify_update()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user