Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed May 4, 2017
2 parents d71a1c5 + 8470b39 commit c9bfb64
Show file tree
Hide file tree
Showing 22 changed files with 270 additions and 63 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe

__version__ = '8.0.21'
__version__ = '8.0.22'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
4 changes: 2 additions & 2 deletions erpnext/accounts/doctype/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def validate_warehouse_account(self):

if account_balance != stock_balance:
frappe.throw(_('Account balance ({0}) and stock value ({1}) must be same')\
.format(fmt_money(account_balance, self.account_currency),
fmt_money(stock_balance, self.account_currency)))
.format(fmt_money(account_balance, currency=self.account_currency),
fmt_money(stock_balance, currency=self.account_currency)))

elif self.warehouse:
self.warehouse = None
Expand Down
25 changes: 25 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,10 @@ def make_customer_and_address(customers):
if not frappe.db.exists('Customer', name):
name = add_customer(name)
data = json.loads(data)
make_contact(data, name)
make_address(data, name)
customer_list.append(name)
frappe.db.commit()
return customer_list

def add_customer(name):
Expand All @@ -340,6 +342,29 @@ def add_customer(name):
frappe.db.commit()
return customer_doc.name

def make_contact(args,customer):
if args.get('email_id') or args.get('phone'):
name = frappe.db.get_value('Dynamic Link',
{'link_doctype': 'Customer', 'link_name': customer, 'parenttype': 'Contact'}, 'parent')

args = {
'email_id': args.get('email_id'),
'phone': args.get('phone')
}

doc = frappe.new_doc('Contact')
if name:
doc = frappe.get_doc('Contact', name)

doc.update(args)
if not name:
doc.first_name = customer
doc.append('links',{
'link_doctype': 'Customer',
'link_name': customer
})
doc.save(ignore_permissions=True)

def make_address(args, customer):
if not args.get('address_line1'): return

Expand Down
17 changes: 12 additions & 5 deletions erpnext/accounts/page/pos/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.name = null;
this.load_data(true);
this.setup();
this.set_default_customer()
},

load_data: function (load_doc) {
Expand Down Expand Up @@ -360,6 +361,16 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
}
},

set_default_customer: function() {
if (this.default_customer && !this.frm.doc.customer) {
this.party_field.$input.val(this.default_customer);
this.frm.doc.customer = this.default_customer;
this.numeric_keypad.show();
this.toggle_list_customer(false)
this.toggle_item_cart(true)
}
},

set_transaction_defaults: function (party) {
var me = this;
this.party = party;
Expand Down Expand Up @@ -675,11 +686,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
me.toggle_delete_button();
}

if (this.default_customer && !this.frm.doc.customer) {
this.party_field.$input.val(this.default_customer);
this.frm.doc.customer = this.default_customer;
}

this.party_field.awesomeplete =
new Awesomplete(this.party_field.$input.get(0), {
minChars: 0,
Expand Down Expand Up @@ -860,6 +866,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.customer_doc.set_primary_action(__("Save"), function () {
me.make_offline_customer(new_customer);
me.pos_bill.show();
me.list_customers.hide();
});
},

Expand Down
3 changes: 2 additions & 1 deletion erpnext/accounts/report/balance_sheet/balance_sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Balance Sheet"]["filters"].push({
"fieldname": "accumulated_values",
"label": __("Accumulated Values"),
"fieldtype": "Check"
"fieldtype": "Check",
"default": 1
});
});

Expand Down
14 changes: 6 additions & 8 deletions erpnext/accounts/report/balance_sheet/balance_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@

def execute(filters=None):
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
filters.periodicity, filters.accumulated_values, filters.company)
filters.periodicity, company=filters.company)

asset = get_data(filters.company, "Asset", "Debit", period_list,
only_current_fiscal_year=False, filters=filters,
accumulated_values=filters.accumulated_values,
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
accumulated_values=filters.accumulated_values)

liability = get_data(filters.company, "Liability", "Credit", period_list,
only_current_fiscal_year=False, filters=filters,
accumulated_values=filters.accumulated_values,
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
accumulated_values=filters.accumulated_values)

equity = get_data(filters.company, "Equity", "Credit", period_list,
only_current_fiscal_year=False, filters=filters,
accumulated_values=filters.accumulated_values,
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
accumulated_values=filters.accumulated_values)

provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
period_list, filters.company)
Expand Down Expand Up @@ -114,7 +111,8 @@ def check_opening_balance(asset, liability, equity):
opening_balance -= flt(liability[0].get("opening_balance", 0), float_precision)
if equity:
opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision)


opening_balance = flt(opening_balance, float_precision)
if opening_balance:
return _("Previous Financial Year is not closed"),opening_balance
return None,None
Expand Down
17 changes: 10 additions & 7 deletions erpnext/accounts/report/financial_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
from frappe import _
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
add_months, add_days, formatdate, cint)
from erpnext.accounts.utils import get_fiscal_year

def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False, company=None):

def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False,
company=None, reset_period_on_fy_change=True):
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
Periodicity can be (Yearly, Quarterly, Monthly)"""

Expand Down Expand Up @@ -49,7 +52,8 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_v
# if a fiscal year ends before a 12 month period
period.to_date = year_end_date

period.to_date_fiscal_year = get_date_fiscal_year(period.to_date, company)
period.to_date_fiscal_year = get_fiscal_year(period.to_date, company=company)[0]
period.from_date_fiscal_year_start_date = get_fiscal_year(period.from_date, company=company)[1]

period_list.append(period)

Expand All @@ -65,7 +69,10 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_v
if not accumulated_values:
label = get_label(periodicity, opts["from_date"], opts["to_date"])
else:
label = get_label(periodicity, period_list[0]["from_date"], opts["to_date"])
if reset_period_on_fy_change:
label = get_label(periodicity, opts.from_date_fiscal_year_start_date, opts["to_date"])
else:
label = get_label(periodicity, period_list[0].from_date, opts["to_date"])

opts.update({
"key": key.replace(" ", "_").replace("-", "_"),
Expand Down Expand Up @@ -150,10 +157,6 @@ def calculate_values(accounts_by_name, gl_entries_by_account, period_list, accum
if entry.posting_date < period_list[0].year_start_date:
d["opening_balance"] = d.get("opening_balance", 0.0) + flt(entry.debit) - flt(entry.credit)

def get_date_fiscal_year(date, company):
from erpnext.accounts.utils import get_fiscal_year
return get_fiscal_year(date, company=company)[0]

def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values):
"""accumulate children's values in parent accounts"""
for d in reversed(accounts):
Expand Down
3 changes: 2 additions & 1 deletion erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

# imported to enable erpnext.accounts.utils.get_account_currency
from erpnext.accounts.doctype.account.account import get_account_currency
from erpnext.accounts.report.financial_statements import sort_root_accounts

class FiscalYearError(frappe.ValidationError): pass

Expand Down Expand Up @@ -652,6 +651,8 @@ def get_companies():

@frappe.whitelist()
def get_children():
from erpnext.accounts.report.financial_statements import sort_root_accounts

args = frappe.local.form_dict
doctype, company = args['doctype'], args['company']
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
Expand Down
23 changes: 23 additions & 0 deletions erpnext/buying/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import frappe
from frappe.utils import flt, cstr, cint
from frappe import _
import json

from erpnext.stock.doctype.item.item import get_last_purchase_details
from erpnext.stock.doctype.item.item import validate_end_of_life
Expand Down Expand Up @@ -78,3 +79,25 @@ def check_for_closed_status(doctype, docname):
if status == "Closed":
frappe.throw(_("{0} {1} status is {2}").format(doctype, docname, status), frappe.InvalidStatusError)

@frappe.whitelist()
def get_linked_material_requests(items):
items = json.loads(items)
mr_list = []
for item in items:
material_request = frappe.db.sql("""SELECT distinct mr.name AS mr_name,
(mr_item.qty - mr_item.ordered_qty) AS qty,
mr_item.item_code AS item_code,
mr_item.name AS mr_item
FROM `tabMaterial Request` mr, `tabMaterial Request Item` mr_item
WHERE mr.name = mr_item.parent
AND mr_item.item_code = %(item)s
AND mr.material_request_type = 'Purchase'
AND mr.per_ordered < 99.99
AND mr.docstatus = 1
AND mr.status != 'Stopped'
ORDER BY mr_item.item_code ASC""",{"item": item}, as_dict=1)
if material_request:
mr_list.append(material_request)

return mr_list

2 changes: 1 addition & 1 deletion erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
app_license = "GNU General Public License (v3)"
source_link = "https://github.com/frappe/erpnext"

develop_version = '8.0.0-beta'
develop_version = '8.x.x-beta'

error_report_email = "support@erpnext.com"

Expand Down
2 changes: 1 addition & 1 deletion erpnext/hr/doctype/employee_loan/employee_loan.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ frappe.ui.form.on('Employee Loan', {
},

employee_loan_application: function(frm) {
return frm.call({
return frappe.call({
method: "erpnext.hr.doctype.employee_loan.employee_loan.get_employee_loan_application",
args: {
"employee_loan_application": frm.doc.employee_loan_application
Expand Down
Loading

0 comments on commit c9bfb64

Please sign in to comment.