Skip to content

Commit 1202dc1

Browse files
committed
Merge branch 'hotfix'
2 parents 4de1083 + e2ddc82 commit 1202dc1

66 files changed

Lines changed: 466 additions & 184 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ dist: trusty
33

44
python:
55
- "2.7"
6+
- "3.6"
7+
8+
env:
9+
- TEST_TYPE="Server Side Test"
10+
- TEST_TYPE="Patch Test"
611

712
services:
813
- mysql
@@ -39,18 +44,8 @@ before_script:
3944
- bench start &
4045
- sleep 10
4146

42-
jobs:
43-
include:
44-
- stage: test
45-
script:
46-
- set -e
47-
- bench run-tests --app erpnext --coverage
48-
after_script:
49-
- coveralls -b apps/erpnext -d ../../sites/.coverage
50-
env: Server Side Test
51-
- # stage
52-
script:
53-
- wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
54-
- bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis
55-
- bench migrate
56-
env: Patch Testing
47+
script:
48+
- bash $TRAVIS_BUILD_DIR/travis/run-tests.sh
49+
50+
after_script:
51+
- coveralls -b apps/erpnext -d ../../sites/.coverage

erpnext/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from erpnext.hooks import regional_overrides
66
from frappe.utils import getdate
77

8-
__version__ = '11.1.39'
8+
__version__ = '11.1.40'
99

1010
def get_default_company(user=None):
1111
'''Get default company for user'''

erpnext/accounts/doctype/pricing_rule/pricing_rule.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def filter_pricing_rules(args, pricing_rules):
350350
if len(pricing_rules) > 1:
351351
rate_or_discount = list(set([d.rate_or_discount for d in pricing_rules]))
352352
if len(rate_or_discount) == 1 and rate_or_discount[0] == "Discount Percentage":
353-
pricing_rules = filter(lambda x: x.for_price_list==args.price_list, pricing_rules) \
353+
pricing_rules = list(filter(lambda x: x.for_price_list==args.price_list, pricing_rules)) \
354354
or pricing_rules
355355

356356
if len(pricing_rules) > 1 and not args.for_shopping_cart:
@@ -373,7 +373,7 @@ def apply_internal_priority(pricing_rules, field_set, args):
373373
filtered_rules = []
374374
for field in field_set:
375375
if args.get(field):
376-
filtered_rules = filter(lambda x: x[field]==args[field], pricing_rules)
376+
filtered_rules = list(filter(lambda x: x[field]==args[field], pricing_rules))
377377
if filtered_rules: break
378378

379379
return filtered_rules or pricing_rules

erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ def tearDown(self):
1818
frappe.db.sql("delete from `tabPricing Rule`")
1919

2020
def test_pricing_rule_for_discount(self):
21-
from erpnext.stock.get_item_details import get_item_details
22-
from frappe import MandatoryError
23-
2421
test_record = {
2522
"doctype": "Pricing Rule",
2623
"title": "_Test Pricing Rule",
@@ -94,9 +91,6 @@ def test_pricing_rule_for_discount(self):
9491
self.assertEquals(details.get("discount_percentage"), 15)
9592

9693
def test_pricing_rule_for_margin(self):
97-
from erpnext.stock.get_item_details import get_item_details
98-
from frappe import MandatoryError
99-
10094
test_record = {
10195
"doctype": "Pricing Rule",
10296
"title": "_Test Pricing Rule",
@@ -139,9 +133,6 @@ def test_pricing_rule_for_margin(self):
139133
self.assertEquals(details.get("margin_rate_or_amount"), 10)
140134

141135
def test_pricing_rule_for_variants(self):
142-
from erpnext.stock.get_item_details import get_item_details
143-
from frappe import MandatoryError
144-
145136
if not frappe.db.exists("Item", "Test Variant PRT"):
146137
frappe.get_doc({
147138
"doctype": "Item",

erpnext/accounts/doctype/sales_invoice/sales_invoice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def set_against_income_account(self):
487487
"""Set against account for debit to account"""
488488
against_acc = []
489489
for d in self.get('items'):
490-
if d.income_account not in against_acc:
490+
if d.income_account and d.income_account not in against_acc:
491491
against_acc.append(d.income_account)
492492
self.against_income_account = ','.join(against_acc)
493493

erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_cumulative_threshold_tds(self):
2222
invoices = []
2323

2424
# create invoices for lower than single threshold tax rate
25-
for _ in xrange(2):
25+
for _ in range(2):
2626
pi = create_purchase_invoice(supplier = "Test TDS Supplier")
2727
pi.submit()
2828
invoices.append(pi)

erpnext/accounts/report/balance_sheet/balance_sheet.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
1010
"fieldtype": "Check",
1111
"default": 1
1212
});
13+
14+
frappe.query_reports["Balance Sheet"]["filters"].push({
15+
"fieldname": "include_default_book_entries",
16+
"label": __("Include Default Book Entries"),
17+
"fieldtype": "Check"
18+
});
1319
});

erpnext/accounts/report/cash_flow/cash_flow.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
1515
"label": __("Accumulated Values"),
1616
"fieldtype": "Check"
1717
});
18+
19+
frappe.query_reports["Cash Flow"]["filters"].push({
20+
"fieldname": "include_default_book_entries",
21+
"label": __("Include Default Book Entries"),
22+
"fieldtype": "Check"
23+
});
1824
});

erpnext/accounts/report/cash_flow/cash_flow.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def execute(filters=None):
1414
if cint(frappe.db.get_single_value('Accounts Settings', 'use_custom_cash_flow')):
1515
from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom
1616
return execute_custom(filters=filters)
17-
18-
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
17+
18+
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
1919
filters.periodicity, filters.accumulated_values, filters.company)
2020

2121
cash_flow_accounts = get_cash_flow_accounts()
@@ -25,45 +25,45 @@ def execute(filters=None):
2525
accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)
2626
expense = get_data(filters.company, "Expense", "Debit", period_list, filters=filters,
2727
accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)
28-
28+
2929
net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company)
3030

3131
data = []
3232
company_currency = frappe.get_cached_value('Company', filters.company, "default_currency")
33-
33+
3434
for cash_flow_account in cash_flow_accounts:
3535
section_data = []
3636
data.append({
37-
"account_name": cash_flow_account['section_header'],
37+
"account_name": cash_flow_account['section_header'],
3838
"parent_account": None,
39-
"indent": 0.0,
39+
"indent": 0.0,
4040
"account": cash_flow_account['section_header']
4141
})
4242

4343
if len(data) == 1:
4444
# add first net income in operations section
4545
if net_profit_loss:
4646
net_profit_loss.update({
47-
"indent": 1,
47+
"indent": 1,
4848
"parent_account": cash_flow_accounts[0]['section_header']
4949
})
5050
data.append(net_profit_loss)
5151
section_data.append(net_profit_loss)
5252

5353
for account in cash_flow_account['account_types']:
54-
account_data = get_account_type_based_data(filters.company,
55-
account['account_type'], period_list, filters.accumulated_values)
54+
account_data = get_account_type_based_data(filters.company,
55+
account['account_type'], period_list, filters.accumulated_values, filters)
5656
account_data.update({
5757
"account_name": account['label'],
58-
"account": account['label'],
58+
"account": account['label'],
5959
"indent": 1,
6060
"parent_account": cash_flow_account['section_header'],
6161
"currency": company_currency
6262
})
6363
data.append(account_data)
6464
section_data.append(account_data)
6565

66-
add_total_row_account(data, section_data, cash_flow_account['section_footer'],
66+
add_total_row_account(data, section_data, cash_flow_account['section_footer'],
6767
period_list, company_currency)
6868

6969
add_total_row_account(data, data, _("Net Change in Cash"), period_list, company_currency)
@@ -105,13 +105,15 @@ def get_cash_flow_accounts():
105105
# combine all cash flow accounts for iteration
106106
return [operation_accounts, investing_accounts, financing_accounts]
107107

108-
def get_account_type_based_data(company, account_type, period_list, accumulated_values):
108+
def get_account_type_based_data(company, account_type, period_list, accumulated_values, filters):
109109
data = {}
110110
total = 0
111111
for period in period_list:
112112
start_date = get_start_date(period, accumulated_values, company)
113113

114-
amount = get_account_type_based_gl_data(company, start_date, period['to_date'], account_type)
114+
amount = get_account_type_based_gl_data(company, start_date,
115+
period['to_date'], account_type, filters)
116+
115117
if amount and account_type == "Depreciation":
116118
amount *= -1
117119

@@ -121,14 +123,24 @@ def get_account_type_based_data(company, account_type, period_list, accumulated_
121123
data["total"] = total
122124
return data
123125

124-
def get_account_type_based_gl_data(company, start_date, end_date, account_type):
126+
def get_account_type_based_gl_data(company, start_date, end_date, account_type, filters):
127+
cond = ""
128+
129+
if filters.finance_book:
130+
cond = " and finance_book = '%s'" %(frappe.db.escape(filters.finance_book))
131+
if filters.include_default_book_entries:
132+
company_fb = frappe.db.get_value("Company", company, 'default_finance_book')
133+
134+
cond = """ and finance_book in ('%s', '%s')
135+
""" %(frappe.db.escape(filters.finance_book), frappe.db.escape(company_fb))
136+
125137
gl_sum = frappe.db.sql_list("""
126138
select sum(credit) - sum(debit)
127139
from `tabGL Entry`
128140
where company=%s and posting_date >= %s and posting_date <= %s
129141
and voucher_type != 'Period Closing Voucher'
130-
and account in ( SELECT name FROM tabAccount WHERE account_type = %s)
131-
""", (company, start_date, end_date, account_type))
142+
and account in ( SELECT name FROM tabAccount WHERE account_type = %s) {cond}
143+
""".format(cond=cond), (company, start_date, end_date, account_type))
132144

133145
return gl_sum[0] if gl_sum and gl_sum[0] else 0
134146

@@ -154,7 +166,7 @@ def add_total_row_account(out, data, label, period_list, currency, consolidated
154166
key = period if consolidated else period['key']
155167
total_row.setdefault(key, 0.0)
156168
total_row[key] += row.get(key, 0.0)
157-
169+
158170
total_row.setdefault("total", 0.0)
159171
total_row["total"] += row["total"]
160172

erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,10 @@ frappe.query_reports["Consolidated Financial Statement"] = {
5555
"fieldtype": "Check",
5656
"default": 0
5757
},
58+
{
59+
"fieldname": "include_default_book_entries",
60+
"label": __("Include Default Book Entries"),
61+
"fieldtype": "Check"
62+
}
5863
]
5964
}

0 commit comments

Comments
 (0)