Skip to content

Commit c9bfb64

Browse files
committed
Merge branch 'develop'
2 parents d71a1c5 + 8470b39 commit c9bfb64

File tree

22 files changed

+270
-63
lines changed

22 files changed

+270
-63
lines changed

erpnext/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import unicode_literals
33
import frappe
44

5-
__version__ = '8.0.21'
5+
__version__ = '8.0.22'
66

77
def get_default_company(user=None):
88
'''Get default company for user'''

erpnext/accounts/doctype/account/account.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ def validate_warehouse_account(self):
189189

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

195195
elif self.warehouse:
196196
self.warehouse = None

erpnext/accounts/doctype/sales_invoice/pos.py

+25
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,10 @@ def make_customer_and_address(customers):
325325
if not frappe.db.exists('Customer', name):
326326
name = add_customer(name)
327327
data = json.loads(data)
328+
make_contact(data, name)
328329
make_address(data, name)
329330
customer_list.append(name)
331+
frappe.db.commit()
330332
return customer_list
331333

332334
def add_customer(name):
@@ -340,6 +342,29 @@ def add_customer(name):
340342
frappe.db.commit()
341343
return customer_doc.name
342344

345+
def make_contact(args,customer):
346+
if args.get('email_id') or args.get('phone'):
347+
name = frappe.db.get_value('Dynamic Link',
348+
{'link_doctype': 'Customer', 'link_name': customer, 'parenttype': 'Contact'}, 'parent')
349+
350+
args = {
351+
'email_id': args.get('email_id'),
352+
'phone': args.get('phone')
353+
}
354+
355+
doc = frappe.new_doc('Contact')
356+
if name:
357+
doc = frappe.get_doc('Contact', name)
358+
359+
doc.update(args)
360+
if not name:
361+
doc.first_name = customer
362+
doc.append('links',{
363+
'link_doctype': 'Customer',
364+
'link_name': customer
365+
})
366+
doc.save(ignore_permissions=True)
367+
343368
def make_address(args, customer):
344369
if not args.get('address_line1'): return
345370

erpnext/accounts/page/pos/pos.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
327327
this.name = null;
328328
this.load_data(true);
329329
this.setup();
330+
this.set_default_customer()
330331
},
331332

332333
load_data: function (load_doc) {
@@ -360,6 +361,16 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
360361
}
361362
},
362363

364+
set_default_customer: function() {
365+
if (this.default_customer && !this.frm.doc.customer) {
366+
this.party_field.$input.val(this.default_customer);
367+
this.frm.doc.customer = this.default_customer;
368+
this.numeric_keypad.show();
369+
this.toggle_list_customer(false)
370+
this.toggle_item_cart(true)
371+
}
372+
},
373+
363374
set_transaction_defaults: function (party) {
364375
var me = this;
365376
this.party = party;
@@ -675,11 +686,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
675686
me.toggle_delete_button();
676687
}
677688

678-
if (this.default_customer && !this.frm.doc.customer) {
679-
this.party_field.$input.val(this.default_customer);
680-
this.frm.doc.customer = this.default_customer;
681-
}
682-
683689
this.party_field.awesomeplete =
684690
new Awesomplete(this.party_field.$input.get(0), {
685691
minChars: 0,
@@ -860,6 +866,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
860866
this.customer_doc.set_primary_action(__("Save"), function () {
861867
me.make_offline_customer(new_customer);
862868
me.pos_bill.show();
869+
me.list_customers.hide();
863870
});
864871
},
865872

erpnext/accounts/report/balance_sheet/balance_sheet.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
77
frappe.query_reports["Balance Sheet"]["filters"].push({
88
"fieldname": "accumulated_values",
99
"label": __("Accumulated Values"),
10-
"fieldtype": "Check"
10+
"fieldtype": "Check",
11+
"default": 1
1112
});
1213
});
1314

erpnext/accounts/report/balance_sheet/balance_sheet.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@
99

1010
def execute(filters=None):
1111
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
12-
filters.periodicity, filters.accumulated_values, filters.company)
12+
filters.periodicity, company=filters.company)
1313

1414
asset = get_data(filters.company, "Asset", "Debit", period_list,
1515
only_current_fiscal_year=False, filters=filters,
16-
accumulated_values=filters.accumulated_values,
17-
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
16+
accumulated_values=filters.accumulated_values)
1817

1918
liability = get_data(filters.company, "Liability", "Credit", period_list,
2019
only_current_fiscal_year=False, filters=filters,
21-
accumulated_values=filters.accumulated_values,
22-
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
20+
accumulated_values=filters.accumulated_values)
2321

2422
equity = get_data(filters.company, "Equity", "Credit", period_list,
2523
only_current_fiscal_year=False, filters=filters,
26-
accumulated_values=filters.accumulated_values,
27-
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
24+
accumulated_values=filters.accumulated_values)
2825

2926
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
3027
period_list, filters.company)
@@ -114,7 +111,8 @@ def check_opening_balance(asset, liability, equity):
114111
opening_balance -= flt(liability[0].get("opening_balance", 0), float_precision)
115112
if equity:
116113
opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision)
117-
114+
115+
opening_balance = flt(opening_balance, float_precision)
118116
if opening_balance:
119117
return _("Previous Financial Year is not closed"),opening_balance
120118
return None,None

erpnext/accounts/report/financial_statements.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
from frappe import _
77
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
88
add_months, add_days, formatdate, cint)
9+
from erpnext.accounts.utils import get_fiscal_year
910

10-
def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False, company=None):
11+
12+
def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False,
13+
company=None, reset_period_on_fy_change=True):
1114
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
1215
Periodicity can be (Yearly, Quarterly, Monthly)"""
1316

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

52-
period.to_date_fiscal_year = get_date_fiscal_year(period.to_date, company)
55+
period.to_date_fiscal_year = get_fiscal_year(period.to_date, company=company)[0]
56+
period.from_date_fiscal_year_start_date = get_fiscal_year(period.from_date, company=company)[1]
5357

5458
period_list.append(period)
5559

@@ -65,7 +69,10 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_v
6569
if not accumulated_values:
6670
label = get_label(periodicity, opts["from_date"], opts["to_date"])
6771
else:
68-
label = get_label(periodicity, period_list[0]["from_date"], opts["to_date"])
72+
if reset_period_on_fy_change:
73+
label = get_label(periodicity, opts.from_date_fiscal_year_start_date, opts["to_date"])
74+
else:
75+
label = get_label(periodicity, period_list[0].from_date, opts["to_date"])
6976

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

153-
def get_date_fiscal_year(date, company):
154-
from erpnext.accounts.utils import get_fiscal_year
155-
return get_fiscal_year(date, company=company)[0]
156-
157160
def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values):
158161
"""accumulate children's values in parent accounts"""
159162
for d in reversed(accounts):

erpnext/accounts/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
# imported to enable erpnext.accounts.utils.get_account_currency
1313
from erpnext.accounts.doctype.account.account import get_account_currency
14-
from erpnext.accounts.report.financial_statements import sort_root_accounts
1514

1615
class FiscalYearError(frappe.ValidationError): pass
1716

@@ -652,6 +651,8 @@ def get_companies():
652651

653652
@frappe.whitelist()
654653
def get_children():
654+
from erpnext.accounts.report.financial_statements import sort_root_accounts
655+
655656
args = frappe.local.form_dict
656657
doctype, company = args['doctype'], args['company']
657658
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))

erpnext/buying/utils.py

+23
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import frappe
66
from frappe.utils import flt, cstr, cint
77
from frappe import _
8+
import json
89

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

82+
@frappe.whitelist()
83+
def get_linked_material_requests(items):
84+
items = json.loads(items)
85+
mr_list = []
86+
for item in items:
87+
material_request = frappe.db.sql("""SELECT distinct mr.name AS mr_name,
88+
(mr_item.qty - mr_item.ordered_qty) AS qty,
89+
mr_item.item_code AS item_code,
90+
mr_item.name AS mr_item
91+
FROM `tabMaterial Request` mr, `tabMaterial Request Item` mr_item
92+
WHERE mr.name = mr_item.parent
93+
AND mr_item.item_code = %(item)s
94+
AND mr.material_request_type = 'Purchase'
95+
AND mr.per_ordered < 99.99
96+
AND mr.docstatus = 1
97+
AND mr.status != 'Stopped'
98+
ORDER BY mr_item.item_code ASC""",{"item": item}, as_dict=1)
99+
if material_request:
100+
mr_list.append(material_request)
101+
102+
return mr_list
103+

erpnext/hooks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
app_license = "GNU General Public License (v3)"
1313
source_link = "https://github.com/frappe/erpnext"
1414

15-
develop_version = '8.0.0-beta'
15+
develop_version = '8.x.x-beta'
1616

1717
error_report_email = "[email protected]"
1818

erpnext/hr/doctype/employee_loan/employee_loan.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ frappe.ui.form.on('Employee Loan', {
7979
},
8080

8181
employee_loan_application: function(frm) {
82-
return frm.call({
82+
return frappe.call({
8383
method: "erpnext.hr.doctype.employee_loan.employee_loan.get_employee_loan_application",
8484
args: {
8585
"employee_loan_application": frm.doc.employee_loan_application

0 commit comments

Comments
 (0)