diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index b31a304afb..a17668033e 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -40,9 +40,9 @@ class JournalEntry(AccountsController): self.clear_zero_debit_credit_row() if not self.title: self.title = self.get_title() - + def clear_zero_debit_credit_row(self): - self.accounts = [account for account in self.accounts + self.accounts = [account for account in self.accounts if not (account.debit_in_account_currency==0.0 and account.credit_in_account_currency==0.0)] def on_submit(self): @@ -436,7 +436,7 @@ class JournalEntry(AccountsController): if not self.get('accounts'): msgprint(_("'Entries' cannot be empty"), raise_exception=True) else: - flag, self.total_debit, self.total_credit = 0, 0, 0 + self.total_debit, self.total_credit = 0, 0 diff = flt(self.difference, self.precision("difference")) # If any row without amount, set the diff on that row @@ -566,7 +566,7 @@ def get_default_bank_cash_account(company, account_type=None, mode_of_payment=No if account: account_details = frappe.db.get_value("Account", account, ["account_currency", "account_type"], as_dict=1) - + return frappe._dict({ "account": account, "balance": get_balance_on(account), @@ -651,7 +651,7 @@ def get_payment_entry(ref_doc, args): cost_center = frappe.db.get_value("Company", ref_doc.company, "cost_center") exchange_rate = 1 if args.get("party_account"): - # Modified to include the posting date for which the exchange rate is required. + # Modified to include the posting date for which the exchange rate is required. # Assumed to be the posting date in the reference document exchange_rate = get_exchange_rate(ref_doc.get("posting_date") or ref_doc.get("transaction_date"), args.get("party_account"), args.get("party_account_currency"), @@ -687,7 +687,7 @@ def get_payment_entry(ref_doc, args): bank_account = get_default_bank_cash_account(ref_doc.company, "Bank", account=args.get("bank_account")) if bank_account: bank_row.update(bank_account) - # Modified to include the posting date for which the exchange rate is required. + # Modified to include the posting date for which the exchange rate is required. # Assumed to be the posting date of the reference date bank_row.exchange_rate = get_exchange_rate(ref_doc.get("posting_date") or ref_doc.get("transaction_date"), bank_account["account"], @@ -715,8 +715,14 @@ def get_payment_entry(ref_doc, args): @frappe.whitelist() def get_opening_accounts(company): """get all balance sheet accounts for opening entry""" - accounts = frappe.db.sql_list("""select name from tabAccount - where is_group=0 and report_type='Balance Sheet' and company=%s""", company) + accounts = frappe.db.sql_list("""select + name from tabAccount + where + is_group=0 and + report_type='Balance Sheet' and + ifnull(warehouse, '') = '' and + company=%s + order by name asc""", company) return [{"account": a, "balance": get_balance_on(a)} for a in accounts] @@ -814,8 +820,8 @@ def get_account_balance_and_party_type(account, date, company, debit=None, credi "party_type": party_type, "account_type": account_details.account_type, "account_currency": account_details.account_currency or company_currency, - - # The date used to retreive the exchange rate here is the date passed in + + # The date used to retreive the exchange rate here is the date passed in # as an argument to this function. It is assumed to be the date on which the balance is sought "exchange_rate": get_exchange_rate(date, account, account_details.account_currency, company, debit=debit, credit=credit, exchange_rate=exchange_rate) @@ -855,7 +861,7 @@ def get_exchange_rate(posting_date, account, account_currency=None, company=None (account_details.root_type == "Liability" and debit)): exchange_rate = get_average_exchange_rate(account) - # The date used to retreive the exchange rate here is the date passed + # The date used to retreive the exchange rate here is the date passed # in as an argument to this function. if not exchange_rate and account_currency and posting_date: exchange_rate = get_exchange_rate(account_currency, company_currency, posting_date) diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.py b/erpnext/buying/doctype/buying_settings/buying_settings.py index 344972168c..1f0184b82c 100644 --- a/erpnext/buying/doctype/buying_settings/buying_settings.py +++ b/erpnext/buying/doctype/buying_settings/buying_settings.py @@ -9,11 +9,10 @@ import frappe from frappe.model.document import Document class BuyingSettings(Document): - def validate(self): for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]: frappe.db.set_default(key, self.get(key, "")) from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series - set_by_naming_series("Supplier", "supplier_name", + set_by_naming_series("Supplier", "supplier_name", self.get("supp_master_name")=="Naming Series", hide_name_field=False) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 0ed6952c74..e4987390ca 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -43,7 +43,7 @@ def get_item_details(args): get_party_item_code(args, item_doc, out) if out.get("warehouse"): - out.update(get_bin_details(args.item_code, out.warehouse)) + out.update(get_bin_details(args.item_code, out.warehouse)) if frappe.db.exists("Product Bundle", args.item_code): valuation_rate = 0.0 @@ -239,7 +239,7 @@ def insert_item_price(args): if frappe.has_permission("Item Price", "write"): price_list_rate = args.rate / args.conversion_factor \ if args.get("conversion_factor") else args.rate - + item_price = frappe.get_doc({ "doctype": "Item Price", "price_list": args.price_list, @@ -247,16 +247,16 @@ def insert_item_price(args): "currency": args.currency, "price_list_rate": price_list_rate }) - + name = frappe.db.get_value('Item Price', {'item_code': args.item_code, 'price_list': args.price_list, 'currency': args.currency}, 'name') - + if name: item_price = frappe.get_doc('Item Price', name) item_price.price_list_rate = price_list_rate - item_price.save() + item_price.save() frappe.msgprint(_("Item Price updated for {0} in Price List {1}").format(args.item_code, args.price_list)) - else: + else: item_price.insert() frappe.msgprint(_("Item Price added for {0} in Price List {1}").format(args.item_code, args.price_list)) @@ -269,7 +269,7 @@ def validate_price_list(args): if args.get("price_list"): if not frappe.db.get_value("Price List", {"name": args.price_list, args.transaction_type: 1, "enabled": 1}): - throw(_("Price List {0} is disabled").format(args.price_list)) + throw(_("Price List {0} is disabled or does not exist").format(args.price_list)) else: throw(_("Price List not selected")) @@ -382,7 +382,7 @@ def get_serial_no_details(item_code, warehouse, qty, serial_no): args = frappe._dict({"item_code":item_code, "warehouse":warehouse, "qty":qty, "serial_no":serial_no}) serial_no = get_serial_no(args) return {'serial_no': serial_no} - + @frappe.whitelist() def get_bin_details_and_serial_nos(item_code, warehouse, qty=None, serial_no=None): bin_details_and_serial_nos = {} @@ -468,7 +468,7 @@ def get_price_list_currency(price_list): "enabled": 1}, ["name", "currency"], as_dict=True) if not result: - throw(_("Price List {0} is disabled").format(price_list)) + throw(_("Price List {0} is disabled or does not exist").format(price_list)) return result.currency @@ -482,7 +482,7 @@ def get_price_list_currency_and_exchange_rate(args): if (not plc_conversion_rate) or (price_list_currency and args.price_list_currency \ and price_list_currency != args.price_list_currency): # cksgb 19/09/2016: added args.transaction_date as posting_date argument for get_exchange_rate - plc_conversion_rate = get_exchange_rate(price_list_currency, args.currency, + plc_conversion_rate = get_exchange_rate(price_list_currency, args.currency, args.transaction_date) or plc_conversion_rate return frappe._dict({ @@ -533,7 +533,7 @@ def get_serial_no(args): args = frappe._dict(args) if args.get('warehouse') and args.get('qty') and args.get('item_code'): - + if frappe.get_value('Item', {'item_code': args.item_code}, "has_serial_no") == 1: args = json.dumps({"item_code": args.get('item_code'),"warehouse": args.get('warehouse'),"qty": args.get('qty')}) args = process_args(args)