chore: whitespace cleanup from codebase

This commit is contained in:
Ankush Menat
2021-08-19 14:33:03 +05:30
parent e536f6d13f
commit 9bb69e711a
1218 changed files with 1391 additions and 1643 deletions

View File

@@ -176,4 +176,4 @@ def get_number_cards(fiscal_year, year_start_date, year_end_date):
"filters_json": "[]",
"doctype": "Number Card"
}
]
]

View File

@@ -103,11 +103,11 @@ frappe.ui.form.on('Asset', {
frm.trigger("create_asset_maintenance");
}, __("Manage"));
}
frm.add_custom_button(__("Repair Asset"), function() {
frm.trigger("create_asset_repair");
}, __("Manage"));
if (frm.doc.status != 'Fully Depreciated') {
frm.add_custom_button(__("Adjust Asset Value"), function() {
frm.trigger("create_asset_adjustment");

View File

@@ -176,16 +176,16 @@ class Asset(AccountsController):
for d in self.get('finance_books'):
self.validate_asset_finance_books(d)
start = self.clear_depreciation_schedule()
# value_after_depreciation - current Asset value
if d.value_after_depreciation:
value_after_depreciation = (flt(d.value_after_depreciation) -
flt(self.opening_accumulated_depreciation))
flt(self.opening_accumulated_depreciation))
else:
value_after_depreciation = (flt(self.gross_purchase_amount) -
flt(self.opening_accumulated_depreciation))
flt(self.opening_accumulated_depreciation))
d.value_after_depreciation = value_after_depreciation

View File

@@ -11,4 +11,4 @@ def get_data():
'items': ['Asset Movement']
}
]
}
}

View File

@@ -50,4 +50,4 @@ frappe.listview_settings['Asset'] = {
});
});
},
}
}

View File

@@ -763,4 +763,4 @@ def set_depreciation_settings_in_company():
company.save()
# 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)

View File

@@ -20,7 +20,7 @@ class AssetCategory(Document):
for field in ("Total Number of Depreciations", "Frequency of Depreciation"):
if cint(d.get(frappe.scrub(field)))<1:
frappe.throw(_("Row {0}: {1} must be greater than 0").format(d.idx, field), frappe.MandatoryError)
def validate_account_currency(self):
account_types = [
'fixed_asset_account', 'accumulated_depreciation_account', 'depreciation_expense_account', 'capital_work_in_progress_account'
@@ -33,13 +33,13 @@ class AssetCategory(Document):
account_currency = frappe.get_value("Account", d.get(type_of_account), "account_currency")
if account_currency != company_currency:
invalid_accounts.append(frappe._dict({ 'type': type_of_account, 'idx': d.idx, 'account': d.get(type_of_account) }))
for d in invalid_accounts:
frappe.throw(_("Row #{}: Currency of {} - {} doesn't matches company currency.")
.format(d.idx, frappe.bold(frappe.unscrub(d.type)), frappe.bold(d.account)),
title=_("Invalid Account"))
def validate_account_types(self):
account_type_map = {
'fixed_asset_account': { 'account_type': 'Fixed Asset' },
@@ -59,12 +59,12 @@ class AssetCategory(Document):
frappe.throw(_("Row #{}: {} of {} should be {}. Please modify the account or select a different account.")
.format(d.idx, frappe.unscrub(key_to_match), frappe.bold(selected_account), frappe.bold(expected_key_type)),
title=_("Invalid Account"))
def valide_cwip_account(self):
if self.enable_cwip_accounting:
missing_cwip_accounts_for_company = []
for d in self.accounts:
if (not d.capital_work_in_progress_account and
if (not d.capital_work_in_progress_account and
not frappe.db.get_value("Company", d.company_name, "capital_work_in_progress_account")):
missing_cwip_accounts_for_company.append(get_link_to_form("Company", d.company_name))
@@ -93,4 +93,4 @@ def get_asset_category_account(fieldname, item=None, asset=None, account=None, a
account = frappe.db.get_value("Asset Category Account",
filters={"parent": asset_category, "company_name": company}, fieldname=fieldname)
return account
return account

View File

@@ -10,9 +10,9 @@ class TestAssetCategory(unittest.TestCase):
def test_mandatory_fields(self):
asset_category = frappe.new_doc("Asset Category")
asset_category.asset_category_name = "Computers"
self.assertRaises(frappe.MandatoryError, asset_category.insert)
asset_category.total_number_of_depreciations = 3
asset_category.frequency_of_depreciation = 3
asset_category.append("accounts", {
@@ -21,7 +21,7 @@ class TestAssetCategory(unittest.TestCase):
"accumulated_depreciation_account": "_Test Accumulated Depreciations - _TC",
"depreciation_expense_account": "_Test Depreciations - _TC"
})
try:
asset_category.insert()
except frappe.DuplicateEntryError:
@@ -44,4 +44,4 @@ class TestAssetCategory(unittest.TestCase):
"depreciation_expense_account": "_Test Depreciations - _TC"
})
self.assertRaises(frappe.ValidationError, asset_category.insert)
self.assertRaises(frappe.ValidationError, asset_category.insert)

View File

@@ -97,4 +97,4 @@ var get_next_due_date = function (frm, cdt, cdn) {
}
});
}
};
};

View File

@@ -116,4 +116,4 @@ def get_maintenance_log(asset_name):
select maintenance_status, count(asset_name) as count, asset_name
from `tabAsset Maintenance Log`
where asset_name=%s group by maintenance_status""",
(asset_name), as_dict=1)
(asset_name), as_dict=1)

View File

@@ -73,7 +73,7 @@ def create_asset_data():
'doctype': 'Location',
'location_name': 'Test Location'
}).insert()
if not frappe.db.exists("Item", "Photocopier"):
meta = frappe.get_meta('Asset')
naming_series = meta.get_field("naming_series").options
@@ -157,6 +157,6 @@ def set_depreciation_settings_in_company():
company.disposal_account = "_Test Gain/Loss on Asset Disposal - _TC"
company.depreciation_cost_center = "_Test Cost Center - _TC"
company.save()
# 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)

View File

@@ -12,4 +12,4 @@ frappe.ui.form.on('Asset Maintenance Log', {
};
});
}
});
});

View File

@@ -99,4 +99,4 @@ frappe.ui.form.on('Asset Movement Item', {
});
}
}
});
});

View File

@@ -40,14 +40,14 @@ class AssetMovement(Document):
if current_location != d.source_location:
frappe.throw(_("Asset {0} does not belongs to the location {1}").
format(d.asset, d.source_location))
if self.purpose == 'Issue':
if d.target_location:
frappe.throw(_("Issuing cannot be done to a location. \
Please enter employee who has issued Asset {0}").format(d.asset), title="Incorrect Movement Purpose")
if not d.to_employee:
frappe.throw(_("Employee is required while issuing Asset {0}").format(d.asset))
if self.purpose == 'Transfer':
if d.to_employee:
frappe.throw(_("Transferring cannot be done to an Employee. \
@@ -57,7 +57,7 @@ class AssetMovement(Document):
frappe.throw(_("Target Location is required while transferring Asset {0}").format(d.asset))
if d.source_location == d.target_location:
frappe.throw(_("Source and Target Location cannot be same"))
if self.purpose == 'Receipt':
# only when asset is bought and first entry is made
if not d.source_location and not (d.target_location or d.to_employee):
@@ -80,14 +80,14 @@ class AssetMovement(Document):
if current_custodian != d.from_employee:
frappe.throw(_("Asset {0} does not belongs to the custodian {1}").
format(d.asset, d.from_employee))
if d.to_employee and frappe.db.get_value("Employee", d.to_employee, "company") != self.company:
frappe.throw(_("Employee {0} does not belongs to the company {1}").
format(d.to_employee, self.company))
def on_submit(self):
self.set_latest_location_in_asset()
def on_cancel(self):
self.set_latest_location_in_asset()
@@ -105,12 +105,12 @@ class AssetMovement(Document):
# In case of cancellation it corresponds to previous latest document's location, employee
latest_movement_entry = frappe.db.sql(
"""
SELECT asm_item.target_location, asm_item.to_employee
SELECT asm_item.target_location, asm_item.to_employee
FROM `tabAsset Movement Item` asm_item, `tabAsset Movement` asm
WHERE
WHERE
asm_item.parent=asm.name and
asm_item.asset=%(asset)s and
asm.company=%(company)s and
asm.company=%(company)s and
asm.docstatus=1 and {0}
ORDER BY
asm.transaction_date desc limit 1

View File

@@ -59,7 +59,7 @@ frappe.ui.form.on('Asset Repair', {
if (frm.doc.repair_status == "Completed") {
frm.set_value('completion_date', frappe.datetime.now_datetime());
}
}
}
});
@@ -68,4 +68,4 @@ frappe.ui.form.on('Asset Repair Consumed Item', {
var row = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, 'total_value', row.consumed_quantity * row.valuation_rate);
},
});
});

View File

@@ -18,7 +18,7 @@ class AssetRepair(AccountsController):
if self.get('stock_items'):
self.set_total_value()
self.calculate_total_repair_cost()
def update_status(self):
if self.repair_status == 'Pending':
frappe.db.set_value('Asset', self.asset, 'status', 'Out of Order')
@@ -98,7 +98,7 @@ class AssetRepair(AccountsController):
if self.capitalize_repair_cost:
row.value_after_depreciation -= self.repair_cost
def get_total_value_of_stock_consumed(self):
total_value_of_stock_consumed = 0
if self.get('stock_consumption'):
@@ -141,7 +141,7 @@ class AssetRepair(AccountsController):
gl_entries = []
repair_and_maintenance_account = frappe.db.get_value('Company', self.company, 'repair_and_maintenance_account')
fixed_asset_account = get_asset_account("fixed_asset_account", asset=self.asset, company=self.company)
expense_account = frappe.get_doc('Purchase Invoice', self.purchase_invoice).items[0].expense_account
expense_account = frappe.get_doc('Purchase Invoice', self.purchase_invoice).items[0].expense_account
gl_entries.append(
self.get_gl_dict({
@@ -149,7 +149,7 @@ class AssetRepair(AccountsController):
"credit": self.repair_cost,
"credit_in_account_currency": self.repair_cost,
"against": repair_and_maintenance_account,
"voucher_type": self.doctype,
"voucher_type": self.doctype,
"voucher_no": self.name,
"cost_center": self.cost_center,
"posting_date": getdate(),
@@ -167,7 +167,7 @@ class AssetRepair(AccountsController):
"credit": item.amount,
"credit_in_account_currency": item.amount,
"against": repair_and_maintenance_account,
"voucher_type": self.doctype,
"voucher_type": self.doctype,
"voucher_no": self.name,
"cost_center": self.cost_center,
"posting_date": getdate(),

View File

@@ -10,4 +10,3 @@ frappe.listview_settings['Asset Repair'] = {
}
}
};

View File

@@ -41,7 +41,7 @@ class TestAssetRepair(unittest.TestCase):
self.assertEqual(total_repair_cost, asset_repair.repair_cost)
for item in asset_repair.stock_items:
total_repair_cost += item.total_value
self.assertEqual(total_repair_cost, asset_repair.total_repair_cost)
def test_repair_status_after_submit(self):
@@ -99,7 +99,7 @@ class TestAssetRepair(unittest.TestCase):
initial_num_of_depreciations = num_of_depreciations(asset)
create_asset_repair(asset= asset, capitalize_repair_cost = 1, submit = 1)
asset.reload()
self.assertEqual((initial_num_of_depreciations + 1), num_of_depreciations(asset))
self.assertEqual(asset.schedules[-1].accumulated_depreciation_amount, asset.finance_books[0].value_after_depreciation)
@@ -139,7 +139,7 @@ def create_asset_repair(**args):
})
asset_repair.insert(ignore_if_duplicate=True)
if args.submit:
asset_repair.repair_status = "Completed"
asset_repair.cost_center = "_Test Cost Center - _TC"
@@ -165,4 +165,4 @@ def create_asset_repair(**args):
asset_repair.purchase_invoice = make_purchase_invoice().name
asset_repair.submit()
return asset_repair
return asset_repair

View File

@@ -91,4 +91,4 @@ def make_asset_value_adjustment(**args):
"cost_center": args.cost_center or "Main - _TC"
}).insert()
return doc
return doc

View File

@@ -30,4 +30,4 @@ frappe.treeview_settings["Location"] = {
onload: function (treeview) {
treeview.make_tree();
}
};
};

View File

@@ -76,7 +76,7 @@ frappe.query_reports["Fixed Asset Register"] = {
fieldtype: "Link",
options: "Asset Category"
},
{
{
fieldname:"finance_book",
label: __("Finance Book"),
fieldtype: "Link",

View File

@@ -99,7 +99,7 @@ def prepare_chart_data(data, filters):
labels_values_map = {}
date_field = frappe.scrub(filters.date_based_on)
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
filters.from_date, filters.to_date, filters.filter_based_on, "Monthly", company=filters.company)
for d in period_list:
@@ -293,4 +293,4 @@ def get_columns(filters):
"options": "Location",
"width": 100
},
]
]