[minor] dont get warehouse in opening entry #7353

This commit is contained in:
Rushabh Mehta 2016-12-30 15:06:54 +05:30
parent a8326de4d0
commit 985cb8226d
3 changed files with 29 additions and 24 deletions

View File

@ -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):
@ -434,7 +434,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
@ -564,7 +564,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),
@ -649,7 +649,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.posting_date, args.get("party_account"), args.get("party_account_currency"),
ref_doc.company, ref_doc.doctype, ref_doc.name)
@ -684,7 +684,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.posting_date, bank_account["account"],
bank_account["account_currency"], ref_doc.company)
@ -711,8 +711,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]
@ -810,8 +816,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)
@ -851,7 +857,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)

View File

@ -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)

View File

@ -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)