feat: Disable CWIP Accounting checkbox added in Company and Asset Category (#19262)
* feat: Disable CWIP Accounting checkbox added in Company and Asset Category Asset Settings is removed completely Disable CWIP Accounting checkbox will give priority to Asset Category * fix: Changed checkbox name to 'Enable Capital Work in Progress Accounting' - checkbox will be disabled by default - Enabling it in Company will globally enable it - When globally disabled , it's value on the asset category will be considered * chore: Added patch to set pre-existing CWIP checkbox value into new checkbox * fix(test): Asset * fix: Asset Test and Patch * fix(test): Opening Invoice Creation Tool * Update asset.py * fix: Patch and other fixes
This commit is contained in:
parent
010714757c
commit
d00c59830e
@ -18,7 +18,7 @@ from erpnext.accounts.general_ledger import make_gl_entries, merge_similar_entri
|
|||||||
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
|
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
|
||||||
from erpnext.buying.utils import check_on_hold_or_closed_status
|
from erpnext.buying.utils import check_on_hold_or_closed_status
|
||||||
from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center
|
from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center
|
||||||
from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_disabled
|
from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_enabled
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
from erpnext.accounts.doctype.sales_invoice.sales_invoice import validate_inter_company_party, update_linked_doc,\
|
from erpnext.accounts.doctype.sales_invoice.sales_invoice import validate_inter_company_party, update_linked_doc,\
|
||||||
@ -226,6 +226,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
# in case of auto inventory accounting,
|
# in case of auto inventory accounting,
|
||||||
# expense account is always "Stock Received But Not Billed" for a stock item
|
# expense account is always "Stock Received But Not Billed" for a stock item
|
||||||
# except epening entry, drop-ship entry and fixed asset items
|
# except epening entry, drop-ship entry and fixed asset items
|
||||||
|
if item.item_code:
|
||||||
|
asset_category = frappe.get_cached_value("Item", item.item_code, "asset_category")
|
||||||
|
|
||||||
if auto_accounting_for_stock and item.item_code in stock_items \
|
if auto_accounting_for_stock and item.item_code in stock_items \
|
||||||
and self.is_opening == 'No' and not item.is_fixed_asset \
|
and self.is_opening == 'No' and not item.is_fixed_asset \
|
||||||
@ -236,7 +238,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
item.expense_account = warehouse_account[item.warehouse]["account"]
|
item.expense_account = warehouse_account[item.warehouse]["account"]
|
||||||
else:
|
else:
|
||||||
item.expense_account = stock_not_billed_account
|
item.expense_account = stock_not_billed_account
|
||||||
elif item.is_fixed_asset and is_cwip_accounting_disabled():
|
|
||||||
|
elif item.is_fixed_asset and not is_cwip_accounting_enabled(self.company, asset_category):
|
||||||
if not item.asset:
|
if not item.asset:
|
||||||
frappe.throw(_("Row {0}: asset is required for item {1}")
|
frappe.throw(_("Row {0}: asset is required for item {1}")
|
||||||
.format(item.idx, item.item_code))
|
.format(item.idx, item.item_code))
|
||||||
@ -392,7 +395,8 @@ 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)
|
||||||
if not is_cwip_accounting_disabled():
|
|
||||||
|
if self.check_asset_cwip_enabled():
|
||||||
self.get_asset_gl_entry(gl_entries)
|
self.get_asset_gl_entry(gl_entries)
|
||||||
|
|
||||||
self.make_tax_gl_entries(gl_entries)
|
self.make_tax_gl_entries(gl_entries)
|
||||||
@ -405,6 +409,15 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
return gl_entries
|
return gl_entries
|
||||||
|
|
||||||
|
def check_asset_cwip_enabled(self):
|
||||||
|
# Check if there exists any item with cwip accounting enabled in it's asset category
|
||||||
|
for item in self.get("items"):
|
||||||
|
if item.item_code and item.is_fixed_asset:
|
||||||
|
asset_category = frappe.get_cached_value("Item", item.item_code, "asset_category")
|
||||||
|
if is_cwip_accounting_enabled(self.company, asset_category):
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
def make_supplier_gl_entry(self, gl_entries):
|
def make_supplier_gl_entry(self, gl_entries):
|
||||||
# Checked both rounding_adjustment and rounded_total
|
# Checked both rounding_adjustment and rounded_total
|
||||||
# because rounded_total had value even before introcution of posting GLE based on rounded total
|
# because rounded_total had value even before introcution of posting GLE based on rounded total
|
||||||
@ -448,6 +461,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if flt(item.base_net_amount):
|
if flt(item.base_net_amount):
|
||||||
account_currency = get_account_currency(item.expense_account)
|
account_currency = get_account_currency(item.expense_account)
|
||||||
|
if item.item_code:
|
||||||
|
asset_category = frappe.get_cached_value("Item", item.item_code, "asset_category")
|
||||||
|
|
||||||
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 and item.item_code in stock_items:
|
||||||
# warehouse account
|
# warehouse account
|
||||||
@ -490,8 +505,9 @@ 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"], item=item))
|
}, warehouse_account[self.supplier_warehouse]["account_currency"], item=item))
|
||||||
elif not item.is_fixed_asset or (item.is_fixed_asset and is_cwip_accounting_disabled()):
|
|
||||||
|
|
||||||
|
elif not item.is_fixed_asset or (item.is_fixed_asset and not is_cwip_accounting_enabled(self.company,
|
||||||
|
asset_category)):
|
||||||
expense_account = (item.expense_account
|
expense_account = (item.expense_account
|
||||||
if (not item.enable_deferred_expense or self.is_return) else item.deferred_expense_account)
|
if (not item.enable_deferred_expense or self.is_return) else item.deferred_expense_account)
|
||||||
|
|
||||||
@ -532,7 +548,10 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
def get_asset_gl_entry(self, gl_entries):
|
def get_asset_gl_entry(self, gl_entries):
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if item.is_fixed_asset:
|
if item.item_code and item.is_fixed_asset :
|
||||||
|
asset_category = frappe.get_cached_value("Item", item.item_code, "asset_category")
|
||||||
|
|
||||||
|
if item.is_fixed_asset and is_cwip_accounting_enabled(self.company, asset_category) :
|
||||||
eiiav_account = self.get_company_default("expenses_included_in_asset_valuation")
|
eiiav_account = self.get_company_default("expenses_included_in_asset_valuation")
|
||||||
|
|
||||||
asset_amount = flt(item.net_amount) + flt(item.item_tax_amount/self.conversion_rate)
|
asset_amount = flt(item.net_amount) + flt(item.item_tax_amount/self.conversion_rate)
|
||||||
|
|||||||
@ -168,14 +168,20 @@ def validate_account_for_perpetual_inventory(gl_map):
|
|||||||
StockValueAndAccountBalanceOutOfSync)
|
StockValueAndAccountBalanceOutOfSync)
|
||||||
|
|
||||||
def validate_cwip_accounts(gl_map):
|
def validate_cwip_accounts(gl_map):
|
||||||
if not cint(frappe.db.get_value("Asset Settings", None, "disable_cwip_accounting")) \
|
cwip_enabled = cint(frappe.get_cached_value("Company",
|
||||||
and gl_map[0].voucher_type == "Journal Entry":
|
gl_map[0].company, "enable_cwip_accounting"))
|
||||||
|
|
||||||
|
if not cwip_enabled:
|
||||||
|
cwip_enabled = any([cint(ac.enable_cwip_accounting) for ac in frappe.db.get_all("Asset Category","enable_cwip_accounting")])
|
||||||
|
|
||||||
|
if cwip_enabled and gl_map[0].voucher_type == "Journal Entry":
|
||||||
cwip_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
|
cwip_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
|
||||||
where account_type = 'Capital Work in Progress' and is_group=0""")]
|
where account_type = 'Capital Work in Progress' and is_group=0""")]
|
||||||
|
|
||||||
for entry in gl_map:
|
for entry in gl_map:
|
||||||
if entry.account in cwip_accounts:
|
if entry.account in cwip_accounts:
|
||||||
frappe.throw(_("Account: <b>{0}</b> is capital Work in progress and can not be updated by Journal Entry").format(entry.account))
|
frappe.throw(
|
||||||
|
_("Account: <b>{0}</b> is capital Work in progress and can not be updated by Journal Entry").format(entry.account))
|
||||||
|
|
||||||
def round_off_debit_credit(gl_map):
|
def round_off_debit_credit(gl_map):
|
||||||
precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"),
|
precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"),
|
||||||
|
|||||||
@ -203,7 +203,7 @@ frappe.ui.form.on('Asset', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
opening_accumulated_depreciation: function(frm) {
|
opening_accumulated_depreciation: function(frm) {
|
||||||
erpnext.asset.set_accululated_depreciation(frm);
|
erpnext.asset.set_accumulated_depreciation(frm);
|
||||||
},
|
},
|
||||||
|
|
||||||
make_schedules_editable: function(frm) {
|
make_schedules_editable: function(frm) {
|
||||||
@ -282,17 +282,6 @@ frappe.ui.form.on('Asset', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
calculate_depreciation: function(frm) {
|
calculate_depreciation: function(frm) {
|
||||||
frappe.db.get_value("Asset Settings", {'name':"Asset Settings"}, 'schedule_based_on_fiscal_year', (data) => {
|
|
||||||
if (data.schedule_based_on_fiscal_year == 1) {
|
|
||||||
frm.set_df_property("depreciation_method", "options", "\nStraight Line\nManual");
|
|
||||||
frm.toggle_reqd("available_for_use_date", true);
|
|
||||||
frm.toggle_display("frequency_of_depreciation", false);
|
|
||||||
frappe.db.get_value("Fiscal Year", {'name': frappe.sys_defaults.fiscal_year}, "year_end_date", (data) => {
|
|
||||||
frm.set_value("next_depreciation_date", data.year_end_date);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
frm.toggle_reqd("finance_books", frm.doc.calculate_depreciation);
|
frm.toggle_reqd("finance_books", frm.doc.calculate_depreciation);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -371,12 +360,12 @@ frappe.ui.form.on('Depreciation Schedule', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
depreciation_amount: function(frm, cdt, cdn) {
|
depreciation_amount: function(frm, cdt, cdn) {
|
||||||
erpnext.asset.set_accululated_depreciation(frm);
|
erpnext.asset.set_accumulated_depreciation(frm);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
erpnext.asset.set_accululated_depreciation = function(frm) {
|
erpnext.asset.set_accumulated_depreciation = function(frm) {
|
||||||
if(frm.doc.depreciation_method != "Manual") return;
|
if(frm.doc.depreciation_method != "Manual") return;
|
||||||
|
|
||||||
var accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation);
|
var accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation);
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
"creation": "2016-03-01 17:01:27.920130",
|
"creation": "2016-03-01 17:01:27.920130",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Document",
|
"document_type": "Document",
|
||||||
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"naming_series",
|
"naming_series",
|
||||||
"asset_name",
|
"asset_name",
|
||||||
@ -215,7 +216,8 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "available_for_use_date",
|
"fieldname": "available_for_use_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Available-for-use Date"
|
"label": "Available-for-use Date",
|
||||||
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_18",
|
"fieldname": "column_break_18",
|
||||||
@ -453,7 +455,7 @@
|
|||||||
"idx": 72,
|
"idx": 72,
|
||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2019-05-25 22:26:19.786201",
|
"modified": "2019-10-07 15:34:30.976208",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
@ -494,4 +496,4 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"title_field": "asset_name"
|
"title_field": "asset_name"
|
||||||
}
|
}
|
||||||
@ -30,7 +30,8 @@ class Asset(AccountsController):
|
|||||||
self.validate_in_use_date()
|
self.validate_in_use_date()
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.update_stock_movement()
|
self.update_stock_movement()
|
||||||
if not self.booked_fixed_asset and not is_cwip_accounting_disabled():
|
if not self.booked_fixed_asset and is_cwip_accounting_enabled(self.company,
|
||||||
|
self.asset_category):
|
||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
@ -76,10 +77,13 @@ class Asset(AccountsController):
|
|||||||
self.set('finance_books', finance_books)
|
self.set('finance_books', finance_books)
|
||||||
|
|
||||||
def validate_asset_values(self):
|
def validate_asset_values(self):
|
||||||
|
if not self.asset_category:
|
||||||
|
self.asset_category = frappe.get_cached_value("Item", self.item_code, "asset_category")
|
||||||
|
|
||||||
if not flt(self.gross_purchase_amount):
|
if not flt(self.gross_purchase_amount):
|
||||||
frappe.throw(_("Gross Purchase Amount is mandatory"), frappe.MandatoryError)
|
frappe.throw(_("Gross Purchase Amount is mandatory"), frappe.MandatoryError)
|
||||||
|
|
||||||
if not is_cwip_accounting_disabled():
|
if is_cwip_accounting_enabled(self.company, self.asset_category):
|
||||||
if not self.is_existing_asset and not (self.purchase_receipt or self.purchase_invoice):
|
if not self.is_existing_asset and not (self.purchase_receipt or self.purchase_invoice):
|
||||||
frappe.throw(_("Please create purchase receipt or purchase invoice for the item {0}").
|
frappe.throw(_("Please create purchase receipt or purchase invoice for the item {0}").
|
||||||
format(self.item_code))
|
format(self.item_code))
|
||||||
@ -424,7 +428,7 @@ def update_maintenance_status():
|
|||||||
asset.set_status('Out of Order')
|
asset.set_status('Out of Order')
|
||||||
|
|
||||||
def make_post_gl_entry():
|
def make_post_gl_entry():
|
||||||
if is_cwip_accounting_disabled():
|
if not is_cwip_accounting_enabled(self.company, self.asset_category):
|
||||||
return
|
return
|
||||||
|
|
||||||
assets = frappe.db.sql_list(""" select name from `tabAsset`
|
assets = frappe.db.sql_list(""" select name from `tabAsset`
|
||||||
@ -574,8 +578,13 @@ def make_journal_entry(asset_name):
|
|||||||
|
|
||||||
return je
|
return je
|
||||||
|
|
||||||
def is_cwip_accounting_disabled():
|
def is_cwip_accounting_enabled(company, asset_category=None):
|
||||||
return cint(frappe.db.get_single_value("Asset Settings", "disable_cwip_accounting"))
|
enable_cwip_in_company = cint(frappe.db.get_value("Company", company, "enable_cwip_accounting"))
|
||||||
|
|
||||||
|
if enable_cwip_in_company or not asset_category:
|
||||||
|
return enable_cwip_in_company
|
||||||
|
|
||||||
|
return cint(frappe.db.get_value("Asset Category", asset_category, "enable_cwip_accounting"))
|
||||||
|
|
||||||
def get_pro_rata_amt(row, depreciation_amount, from_date, to_date):
|
def get_pro_rata_amt(row, depreciation_amount, from_date, to_date):
|
||||||
days = date_diff(to_date, from_date)
|
days = date_diff(to_date, from_date)
|
||||||
|
|||||||
@ -14,7 +14,6 @@ from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchas
|
|||||||
class TestAsset(unittest.TestCase):
|
class TestAsset(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
set_depreciation_settings_in_company()
|
set_depreciation_settings_in_company()
|
||||||
remove_prorated_depreciation_schedule()
|
|
||||||
create_asset_data()
|
create_asset_data()
|
||||||
frappe.db.sql("delete from `tabTax Rule`")
|
frappe.db.sql("delete from `tabTax Rule`")
|
||||||
|
|
||||||
@ -70,11 +69,13 @@ class TestAsset(unittest.TestCase):
|
|||||||
{"voucher_type": "Purchase Invoice", "voucher_no": pi.name}))
|
{"voucher_type": "Purchase Invoice", "voucher_no": pi.name}))
|
||||||
|
|
||||||
def test_is_fixed_asset_set(self):
|
def test_is_fixed_asset_set(self):
|
||||||
|
asset = create_asset(is_existing_asset = 1)
|
||||||
doc = frappe.new_doc('Purchase Invoice')
|
doc = frappe.new_doc('Purchase Invoice')
|
||||||
doc.supplier = '_Test Supplier'
|
doc.supplier = '_Test Supplier'
|
||||||
doc.append('items', {
|
doc.append('items', {
|
||||||
'item_code': 'Macbook Pro',
|
'item_code': 'Macbook Pro',
|
||||||
'qty': 1
|
'qty': 1,
|
||||||
|
'asset': asset.name
|
||||||
})
|
})
|
||||||
|
|
||||||
doc.set_missing_values()
|
doc.set_missing_values()
|
||||||
@ -200,7 +201,6 @@ class TestAsset(unittest.TestCase):
|
|||||||
self.assertEqual(schedules, expected_schedules)
|
self.assertEqual(schedules, expected_schedules)
|
||||||
|
|
||||||
def test_schedule_for_prorated_straight_line_method(self):
|
def test_schedule_for_prorated_straight_line_method(self):
|
||||||
set_prorated_depreciation_schedule()
|
|
||||||
pr = make_purchase_receipt(item_code="Macbook Pro",
|
pr = make_purchase_receipt(item_code="Macbook Pro",
|
||||||
qty=1, rate=100000.0, location="Test Location")
|
qty=1, rate=100000.0, location="Test Location")
|
||||||
|
|
||||||
@ -233,8 +233,6 @@ class TestAsset(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(schedules, expected_schedules)
|
self.assertEqual(schedules, expected_schedules)
|
||||||
|
|
||||||
remove_prorated_depreciation_schedule()
|
|
||||||
|
|
||||||
def test_depreciation(self):
|
def test_depreciation(self):
|
||||||
pr = make_purchase_receipt(item_code="Macbook Pro",
|
pr = make_purchase_receipt(item_code="Macbook Pro",
|
||||||
qty=1, rate=100000.0, location="Test Location")
|
qty=1, rate=100000.0, location="Test Location")
|
||||||
@ -487,6 +485,8 @@ class TestAsset(unittest.TestCase):
|
|||||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import (
|
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import (
|
||||||
make_purchase_invoice as make_purchase_invoice_from_pr)
|
make_purchase_invoice as make_purchase_invoice_from_pr)
|
||||||
|
|
||||||
|
#frappe.db.set_value("Asset Category","Computers","enable_cwip_accounting", 1)
|
||||||
|
|
||||||
pr = make_purchase_receipt(item_code="Macbook Pro",
|
pr = make_purchase_receipt(item_code="Macbook Pro",
|
||||||
qty=1, rate=5000, do_not_submit=True, location="Test Location")
|
qty=1, rate=5000, do_not_submit=True, location="Test Location")
|
||||||
|
|
||||||
@ -565,6 +565,7 @@ class TestAsset(unittest.TestCase):
|
|||||||
where voucher_type='Asset' and voucher_no = %s
|
where voucher_type='Asset' and voucher_no = %s
|
||||||
order by account""", asset_doc.name)
|
order by account""", asset_doc.name)
|
||||||
|
|
||||||
|
|
||||||
self.assertEqual(gle, expected_gle)
|
self.assertEqual(gle, expected_gle)
|
||||||
|
|
||||||
def test_expense_head(self):
|
def test_expense_head(self):
|
||||||
@ -575,7 +576,6 @@ class TestAsset(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEquals('Asset Received But Not Billed - _TC', doc.items[0].expense_account)
|
self.assertEquals('Asset Received But Not Billed - _TC', doc.items[0].expense_account)
|
||||||
|
|
||||||
|
|
||||||
def create_asset_data():
|
def create_asset_data():
|
||||||
if not frappe.db.exists("Asset Category", "Computers"):
|
if not frappe.db.exists("Asset Category", "Computers"):
|
||||||
create_asset_category()
|
create_asset_category()
|
||||||
@ -596,15 +596,15 @@ def create_asset(**args):
|
|||||||
|
|
||||||
asset = frappe.get_doc({
|
asset = frappe.get_doc({
|
||||||
"doctype": "Asset",
|
"doctype": "Asset",
|
||||||
"asset_name": "Macbook Pro 1",
|
"asset_name": args.asset_name or "Macbook Pro 1",
|
||||||
"asset_category": "Computers",
|
"asset_category": "Computers",
|
||||||
"item_code": "Macbook Pro",
|
"item_code": args.item_code or "Macbook Pro",
|
||||||
"company": "_Test Company",
|
"company": args.company or"_Test Company",
|
||||||
"purchase_date": "2015-01-01",
|
"purchase_date": "2015-01-01",
|
||||||
"calculate_depreciation": 0,
|
"calculate_depreciation": 0,
|
||||||
"gross_purchase_amount": 100000,
|
"gross_purchase_amount": 100000,
|
||||||
"expected_value_after_useful_life": 10000,
|
"expected_value_after_useful_life": 10000,
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
"warehouse": args.warehouse or "_Test Warehouse - _TC",
|
||||||
"available_for_use_date": "2020-06-06",
|
"available_for_use_date": "2020-06-06",
|
||||||
"location": "Test Location",
|
"location": "Test Location",
|
||||||
"asset_owner": "Company",
|
"asset_owner": "Company",
|
||||||
@ -616,6 +616,9 @@ def create_asset(**args):
|
|||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if args.submit:
|
||||||
|
asset.submit()
|
||||||
|
|
||||||
return asset
|
return asset
|
||||||
|
|
||||||
def create_asset_category():
|
def create_asset_category():
|
||||||
@ -623,6 +626,7 @@ def create_asset_category():
|
|||||||
asset_category.asset_category_name = "Computers"
|
asset_category.asset_category_name = "Computers"
|
||||||
asset_category.total_number_of_depreciations = 3
|
asset_category.total_number_of_depreciations = 3
|
||||||
asset_category.frequency_of_depreciation = 3
|
asset_category.frequency_of_depreciation = 3
|
||||||
|
asset_category.enable_cwip_accounting = 1
|
||||||
asset_category.append("accounts", {
|
asset_category.append("accounts", {
|
||||||
"company_name": "_Test Company",
|
"company_name": "_Test Company",
|
||||||
"fixed_asset_account": "_Test Fixed Asset - _TC",
|
"fixed_asset_account": "_Test Fixed Asset - _TC",
|
||||||
@ -657,18 +661,3 @@ def set_depreciation_settings_in_company():
|
|||||||
|
|
||||||
# Enable booking asset depreciation entry automatically
|
# Enable booking asset depreciation entry automatically
|
||||||
frappe.db.set_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically", 1)
|
frappe.db.set_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically", 1)
|
||||||
|
|
||||||
def remove_prorated_depreciation_schedule():
|
|
||||||
asset_settings = frappe.get_doc("Asset Settings", "Asset Settings")
|
|
||||||
asset_settings.schedule_based_on_fiscal_year = 0
|
|
||||||
asset_settings.save()
|
|
||||||
|
|
||||||
frappe.db.commit()
|
|
||||||
|
|
||||||
def set_prorated_depreciation_schedule():
|
|
||||||
asset_settings = frappe.get_doc("Asset Settings", "Asset Settings")
|
|
||||||
asset_settings.schedule_based_on_fiscal_year = 1
|
|
||||||
asset_settings.number_of_days_in_fiscal_year = 360
|
|
||||||
asset_settings.save()
|
|
||||||
|
|
||||||
frappe.db.commit()
|
|
||||||
|
|||||||
@ -1,284 +1,115 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
|
||||||
"allow_guest_to_view": 0,
|
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
"autoname": "field:asset_category_name",
|
"autoname": "field:asset_category_name",
|
||||||
"beta": 0,
|
|
||||||
"creation": "2016-03-01 17:41:39.778765",
|
"creation": "2016-03-01 17:41:39.778765",
|
||||||
"custom": 0,
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Document",
|
"document_type": "Document",
|
||||||
"editable_grid": 0,
|
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"asset_category_name",
|
||||||
|
"column_break_3",
|
||||||
|
"depreciation_options",
|
||||||
|
"enable_cwip_accounting",
|
||||||
|
"finance_book_detail",
|
||||||
|
"finance_books",
|
||||||
|
"section_break_2",
|
||||||
|
"accounts"
|
||||||
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "asset_category_name",
|
"fieldname": "asset_category_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Asset Category Name",
|
"label": "Asset Category Name",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 0,
|
"unique": 1
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break"
|
||||||
"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,
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"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,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "finance_book_detail",
|
"fieldname": "finance_book_detail",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"label": "Finance Book Detail"
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Finance Book Detail",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"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,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "finance_books",
|
"fieldname": "finance_books",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"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": "Finance Books",
|
"label": "Finance Books",
|
||||||
"length": 0,
|
"options": "Asset Finance Book"
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Asset Finance Book",
|
|
||||||
"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,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "section_break_2",
|
"fieldname": "section_break_2",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"label": "Accounts"
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Accounts",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"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,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "accounts",
|
"fieldname": "accounts",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"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": "Accounts",
|
"label": "Accounts",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Asset Category Account",
|
"options": "Asset Category Account",
|
||||||
"permlevel": 0,
|
"reqd": 1
|
||||||
"precision": "",
|
},
|
||||||
"print_hide": 0,
|
{
|
||||||
"print_hide_if_no_value": 0,
|
"fieldname": "depreciation_options",
|
||||||
"read_only": 0,
|
"fieldtype": "Section Break",
|
||||||
"remember_last_selected_value": 0,
|
"label": "Depreciation Options"
|
||||||
"report_hide": 0,
|
},
|
||||||
"reqd": 1,
|
{
|
||||||
"search_index": 0,
|
"default": "0",
|
||||||
"set_only_once": 0,
|
"fieldname": "enable_cwip_accounting",
|
||||||
"unique": 0
|
"fieldtype": "Check",
|
||||||
|
"label": "Enable Capital Work in Progress Accounting"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"modified": "2019-10-11 12:19:59.759136",
|
||||||
"hide_heading": 0,
|
|
||||||
"hide_toolbar": 0,
|
|
||||||
"idx": 0,
|
|
||||||
"image_view": 0,
|
|
||||||
"in_create": 0,
|
|
||||||
"is_submittable": 0,
|
|
||||||
"issingle": 0,
|
|
||||||
"istable": 0,
|
|
||||||
"max_attachments": 0,
|
|
||||||
"modified": "2018-05-12 14:56:04.116425",
|
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset Category",
|
"name": "Asset Category",
|
||||||
"name_case": "",
|
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"apply_user_permissions": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 1,
|
"import": 1,
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "Accounts User",
|
"role": "Accounts User",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"apply_user_permissions": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 1,
|
"import": 1,
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "Accounts Manager",
|
"role": "Accounts Manager",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"apply_user_permissions": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "Quality Manager",
|
"role": "Quality Manager",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"read_only_onload": 0,
|
|
||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC"
|
||||||
"track_changes": 0,
|
|
||||||
"track_seen": 0
|
|
||||||
}
|
}
|
||||||
@ -10,11 +10,24 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
class AssetCategory(Document):
|
class AssetCategory(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
self.validate_finance_books()
|
||||||
|
self.validate_enable_cwip_accounting()
|
||||||
|
|
||||||
|
def validate_finance_books(self):
|
||||||
for d in self.finance_books:
|
for d in self.finance_books:
|
||||||
for field in ("Total Number of Depreciations", "Frequency of Depreciation"):
|
for field in ("Total Number of Depreciations", "Frequency of Depreciation"):
|
||||||
if cint(d.get(frappe.scrub(field)))<1:
|
if cint(d.get(frappe.scrub(field)))<1:
|
||||||
frappe.throw(_("Row {0}: {1} must be greater than 0").format(d.idx, field), frappe.MandatoryError)
|
frappe.throw(_("Row {0}: {1} must be greater than 0").format(d.idx, field), frappe.MandatoryError)
|
||||||
|
|
||||||
|
def validate_enable_cwip_accounting(self):
|
||||||
|
if self.enable_cwip_accounting :
|
||||||
|
for d in self.accounts:
|
||||||
|
cwip = frappe.db.get_value("Company",d.company_name,"enable_cwip_accounting")
|
||||||
|
if cwip:
|
||||||
|
frappe.throw(_
|
||||||
|
("CWIP is enabled globally in Company {1}. To enable it in Asset Category, first disable it in {1} ").format(
|
||||||
|
frappe.bold(d.idx), frappe.bold(d.company_name)))
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_asset_category_account(asset, fieldname, account=None, asset_category = None, company = None):
|
def get_asset_category_account(asset, fieldname, account=None, asset_category = None, company = None):
|
||||||
if not asset_category and company:
|
if not asset_category and company:
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
|
||||||
// For license information, please see license.txt
|
|
||||||
|
|
||||||
frappe.ui.form.on('Asset Settings', {
|
|
||||||
});
|
|
||||||
@ -1,148 +0,0 @@
|
|||||||
{
|
|
||||||
"allow_copy": 0,
|
|
||||||
"allow_events_in_timeline": 0,
|
|
||||||
"allow_guest_to_view": 0,
|
|
||||||
"allow_import": 0,
|
|
||||||
"allow_rename": 0,
|
|
||||||
"beta": 0,
|
|
||||||
"creation": "2018-01-03 10:30:32.983381",
|
|
||||||
"custom": 0,
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "",
|
|
||||||
"editable_grid": 1,
|
|
||||||
"engine": "InnoDB",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fetch_if_empty": 0,
|
|
||||||
"fieldname": "depreciation_options",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"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": "Depreciation Options",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"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_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fetch_if_empty": 0,
|
|
||||||
"fieldname": "disable_cwip_accounting",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"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": "Disable CWIP Accounting",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"has_web_view": 0,
|
|
||||||
"hide_heading": 0,
|
|
||||||
"hide_toolbar": 0,
|
|
||||||
"idx": 0,
|
|
||||||
"image_view": 0,
|
|
||||||
"in_create": 0,
|
|
||||||
"is_submittable": 0,
|
|
||||||
"issingle": 1,
|
|
||||||
"istable": 0,
|
|
||||||
"max_attachments": 0,
|
|
||||||
"modified": "2019-05-26 18:31:19.930563",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"module": "Assets",
|
|
||||||
"name": "Asset Settings",
|
|
||||||
"name_case": "",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"permissions": [
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"email": 1,
|
|
||||||
"export": 0,
|
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 0,
|
|
||||||
"role": "System Manager",
|
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"email": 1,
|
|
||||||
"export": 0,
|
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 0,
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"quick_entry": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"read_only_onload": 0,
|
|
||||||
"show_name_in_global_search": 0,
|
|
||||||
"sort_field": "modified",
|
|
||||||
"sort_order": "DESC",
|
|
||||||
"track_changes": 1,
|
|
||||||
"track_seen": 0,
|
|
||||||
"track_views": 0
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
|
||||||
# For license information, please see license.txt
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
from frappe.model.document import Document
|
|
||||||
|
|
||||||
class AssetSettings(Document):
|
|
||||||
pass
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
// rename this file from _test_[name] to test_[name] to activate
|
|
||||||
// and remove above this line
|
|
||||||
|
|
||||||
QUnit.test("test: Asset Settings", function (assert) {
|
|
||||||
let done = assert.async();
|
|
||||||
|
|
||||||
// number of asserts
|
|
||||||
assert.expect(1);
|
|
||||||
|
|
||||||
frappe.run_serially([
|
|
||||||
// insert a new Asset Settings
|
|
||||||
() => frappe.tests.make('Asset Settings', [
|
|
||||||
// values to be set
|
|
||||||
{key: 'value'}
|
|
||||||
]),
|
|
||||||
() => {
|
|
||||||
assert.equal(cur_frm.doc.key, 'value');
|
|
||||||
},
|
|
||||||
() => done()
|
|
||||||
]);
|
|
||||||
|
|
||||||
});
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
|
||||||
# See license.txt
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
class TestAssetSettings(unittest.TestCase):
|
|
||||||
pass
|
|
||||||
@ -21,10 +21,6 @@ def get_data():
|
|||||||
"name": "Asset Category",
|
"name": "Asset Category",
|
||||||
"onboard": 1,
|
"onboard": 1,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Asset Settings",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Asset Movement",
|
"name": "Asset Movement",
|
||||||
|
|||||||
@ -640,6 +640,7 @@ erpnext.patches.v12_0.create_default_energy_point_rules
|
|||||||
erpnext.patches.v12_0.set_produced_qty_field_in_sales_order_for_work_order
|
erpnext.patches.v12_0.set_produced_qty_field_in_sales_order_for_work_order
|
||||||
erpnext.patches.v12_0.generate_leave_ledger_entries
|
erpnext.patches.v12_0.generate_leave_ledger_entries
|
||||||
erpnext.patches.v12_0.set_default_shopify_app_type
|
erpnext.patches.v12_0.set_default_shopify_app_type
|
||||||
|
erpnext.patches.v12_0.set_cwip_and_delete_asset_settings
|
||||||
erpnext.patches.v12_0.set_expense_account_in_landed_cost_voucher_taxes
|
erpnext.patches.v12_0.set_expense_account_in_landed_cost_voucher_taxes
|
||||||
erpnext.patches.v12_0.replace_accounting_with_accounts_in_home_settings
|
erpnext.patches.v12_0.replace_accounting_with_accounts_in_home_settings
|
||||||
erpnext.patches.v12_0.set_payment_entry_status
|
erpnext.patches.v12_0.set_payment_entry_status
|
||||||
|
|||||||
22
erpnext/patches/v12_0/set_cwip_and_delete_asset_settings.py
Normal file
22
erpnext/patches/v12_0/set_cwip_and_delete_asset_settings.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe.utils import cint
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
'''Get 'Disable CWIP Accounting value' from Asset Settings, set it in 'Enable Capital Work in Progress Accounting' field
|
||||||
|
in Company, delete Asset Settings '''
|
||||||
|
|
||||||
|
if frappe.db.exists("DocType","Asset Settings"):
|
||||||
|
frappe.reload_doctype("Company")
|
||||||
|
cwip_value = frappe.db.sql(""" SELECT value FROM `tabSingles` WHERE doctype='Asset Settings'
|
||||||
|
and field='disable_cwip_accounting' """, as_dict=1)
|
||||||
|
|
||||||
|
companies = [x['name'] for x in frappe.get_all("Company", "name")]
|
||||||
|
for company in companies:
|
||||||
|
enable_cwip_accounting = cint(not cint(cwip_value[0]['value']))
|
||||||
|
frappe.set_value("Company", company, "enable_cwip_accounting", enable_cwip_accounting)
|
||||||
|
|
||||||
|
frappe.db.sql(
|
||||||
|
""" DELETE FROM `tabSingles` where doctype = 'Asset Settings' """)
|
||||||
|
frappe.delete_doc_if_exists("DocType","Asset Settings")
|
||||||
@ -72,6 +72,7 @@
|
|||||||
"stock_received_but_not_billed",
|
"stock_received_but_not_billed",
|
||||||
"expenses_included_in_valuation",
|
"expenses_included_in_valuation",
|
||||||
"fixed_asset_depreciation_settings",
|
"fixed_asset_depreciation_settings",
|
||||||
|
"enable_cwip_accounting",
|
||||||
"accumulated_depreciation_account",
|
"accumulated_depreciation_account",
|
||||||
"depreciation_expense_account",
|
"depreciation_expense_account",
|
||||||
"series_for_depreciation_entry",
|
"series_for_depreciation_entry",
|
||||||
@ -720,12 +721,18 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Default Buying Terms",
|
"label": "Default Buying Terms",
|
||||||
"options": "Terms and Conditions"
|
"options": "Terms and Conditions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "enable_cwip_accounting",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Enable Capital Work in Progress Accounting"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-building",
|
"icon": "fa fa-building",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"image_field": "company_logo",
|
"image_field": "company_logo",
|
||||||
"modified": "2019-07-04 22:20:45.104307",
|
"modified": "2019-10-09 14:42:04.440974",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Company",
|
"name": "Company",
|
||||||
@ -767,6 +774,18 @@
|
|||||||
{
|
{
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"role": "Projects User"
|
"role": "Projects User"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
|
|||||||
@ -14,7 +14,7 @@ from erpnext.accounts.utils import get_account_currency
|
|||||||
from frappe.desk.notifications import clear_doctype_notifications
|
from frappe.desk.notifications import clear_doctype_notifications
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from erpnext.buying.utils import check_on_hold_or_closed_status
|
from erpnext.buying.utils import check_on_hold_or_closed_status
|
||||||
from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_disabled
|
from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_enabled
|
||||||
from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
|
from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
@ -338,12 +338,13 @@ class PurchaseReceipt(BuyingController):
|
|||||||
def get_asset_gl_entry(self, gl_entries, expenses_included_in_valuation=None):
|
def get_asset_gl_entry(self, gl_entries, expenses_included_in_valuation=None):
|
||||||
arbnb_account, cwip_account = None, None
|
arbnb_account, cwip_account = None, None
|
||||||
|
|
||||||
cwip_disabled = is_cwip_accounting_disabled()
|
|
||||||
|
|
||||||
if not expenses_included_in_valuation:
|
if not expenses_included_in_valuation:
|
||||||
expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
|
expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
|
||||||
|
|
||||||
for d in self.get("items"):
|
for d in self.get("items"):
|
||||||
|
asset_category = frappe.get_cached_value("Item", d.item_code, "asset_category")
|
||||||
|
cwip_enabled = is_cwip_accounting_enabled(self.company, asset_category)
|
||||||
|
|
||||||
if d.is_fixed_asset and not (arbnb_account and cwip_account):
|
if d.is_fixed_asset and not (arbnb_account and cwip_account):
|
||||||
arbnb_account = self.get_company_default("asset_received_but_not_billed")
|
arbnb_account = self.get_company_default("asset_received_but_not_billed")
|
||||||
|
|
||||||
@ -351,8 +352,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
cwip_account = get_asset_account("capital_work_in_progress_account", d.asset,
|
cwip_account = get_asset_account("capital_work_in_progress_account", d.asset,
|
||||||
company = self.company)
|
company = self.company)
|
||||||
|
|
||||||
if d.is_fixed_asset and not cwip_disabled:
|
if d.is_fixed_asset and cwip_enabled:
|
||||||
|
|
||||||
asset_amount = flt(d.net_amount) + flt(d.item_tax_amount/self.conversion_rate)
|
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)
|
base_asset_amount = flt(d.base_net_amount + d.item_tax_amount)
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
|
|
||||||
if d.is_fixed_asset and flt(d.landed_cost_voucher_amount):
|
if d.is_fixed_asset and flt(d.landed_cost_voucher_amount):
|
||||||
asset_account = (get_asset_category_account(d.asset, 'fixed_asset_account',
|
asset_account = (get_asset_category_account(d.asset, 'fixed_asset_account',
|
||||||
company = self.company) if cwip_disabled else cwip_account)
|
company = self.company) if not cwip_enabled else cwip_account)
|
||||||
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
gl_entries.append(self.get_gl_dict({
|
||||||
"account": expenses_included_in_valuation,
|
"account": expenses_included_in_valuation,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user