fix: Travis(develop)
This commit is contained in:
parent
7d3c3b9a8b
commit
9df4532d14
@ -5,7 +5,18 @@ import frappe
|
|||||||
import json
|
import json
|
||||||
from frappe.utils import nowdate, add_months, get_date_str
|
from frappe.utils import nowdate, add_months, get_date_str
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from erpnext.accounts.utils import get_fiscal_year, get_account_name
|
from erpnext.accounts.utils import get_fiscal_year, get_account_name, FiscalYearError
|
||||||
|
|
||||||
|
def _get_fiscal_year(date=None):
|
||||||
|
try:
|
||||||
|
fiscal_year = get_fiscal_year(date=nowdate())
|
||||||
|
except FiscalYearError:
|
||||||
|
#if no fiscal year for current date then get default fiscal year
|
||||||
|
try:
|
||||||
|
fiscal_year = get_fiscal_year()
|
||||||
|
except FiscalYearError:
|
||||||
|
#if still no fiscal year found then no accounting data created, return
|
||||||
|
return None
|
||||||
|
|
||||||
def get_company_for_dashboards():
|
def get_company_for_dashboards():
|
||||||
company = frappe.defaults.get_defaults().company
|
company = frappe.defaults.get_defaults().company
|
||||||
@ -18,10 +29,16 @@ def get_company_for_dashboards():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
|
|
||||||
|
fiscal_year = _get_fiscal_year(nowdate())
|
||||||
|
|
||||||
|
if not fiscal_year:
|
||||||
|
return frappe._dict()
|
||||||
|
|
||||||
return frappe._dict({
|
return frappe._dict({
|
||||||
"dashboards": get_dashboards(),
|
"dashboards": get_dashboards(),
|
||||||
"charts": get_charts(),
|
"charts": get_charts(fiscal_year),
|
||||||
"number_cards": get_number_cards()
|
"number_cards": get_number_cards(fiscal_year)
|
||||||
})
|
})
|
||||||
|
|
||||||
def get_dashboards():
|
def get_dashboards():
|
||||||
@ -46,10 +63,9 @@ def get_dashboards():
|
|||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def get_charts():
|
def get_charts(fiscal_year):
|
||||||
company = frappe.get_doc("Company", get_company_for_dashboards())
|
company = frappe.get_doc("Company", get_company_for_dashboards())
|
||||||
bank_account = company.default_bank_account or get_account_name("Bank", company=company.name)
|
bank_account = company.default_bank_account or get_account_name("Bank", company=company.name)
|
||||||
fiscal_year = get_fiscal_year(date=nowdate())
|
|
||||||
default_cost_center = company.cost_center
|
default_cost_center = company.cost_center
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -190,8 +206,8 @@ def get_charts():
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_number_cards():
|
def get_number_cards(fiscal_year):
|
||||||
fiscal_year = get_fiscal_year(date=nowdate())
|
|
||||||
year_start_date = get_date_str(fiscal_year[1])
|
year_start_date = get_date_str(fiscal_year[1])
|
||||||
year_end_date = get_date_str(fiscal_year[2])
|
year_end_date = get_date_str(fiscal_year[2])
|
||||||
return [
|
return [
|
||||||
|
@ -1745,53 +1745,6 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
check_gl_entries(self, si.name, expected_gle, "2019-01-30")
|
check_gl_entries(self, si.name, expected_gle, "2019-01-30")
|
||||||
|
|
||||||
def test_deferred_error_email(self):
|
|
||||||
deferred_account = create_account(account_name="Deferred Revenue",
|
|
||||||
parent_account="Current Liabilities - _TC", company="_Test Company")
|
|
||||||
|
|
||||||
item = create_item("_Test Item for Deferred Accounting")
|
|
||||||
item.enable_deferred_revenue = 1
|
|
||||||
item.deferred_revenue_account = deferred_account
|
|
||||||
item.no_of_months = 12
|
|
||||||
item.save()
|
|
||||||
|
|
||||||
si = create_sales_invoice(item=item.name, posting_date="2019-01-10", do_not_submit=True)
|
|
||||||
si.items[0].enable_deferred_revenue = 1
|
|
||||||
si.items[0].service_start_date = "2019-01-10"
|
|
||||||
si.items[0].service_end_date = "2019-03-15"
|
|
||||||
si.items[0].deferred_revenue_account = deferred_account
|
|
||||||
si.save()
|
|
||||||
si.submit()
|
|
||||||
|
|
||||||
from erpnext.accounts.deferred_revenue import convert_deferred_revenue_to_income
|
|
||||||
|
|
||||||
acc_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
|
|
||||||
acc_settings.acc_frozen_upto = '2019-01-31'
|
|
||||||
acc_settings.save()
|
|
||||||
|
|
||||||
pda = frappe.get_doc(dict(
|
|
||||||
doctype='Process Deferred Accounting',
|
|
||||||
posting_date=nowdate(),
|
|
||||||
start_date="2019-01-01",
|
|
||||||
end_date="2019-03-31",
|
|
||||||
type="Income",
|
|
||||||
company="_Test Company"
|
|
||||||
))
|
|
||||||
|
|
||||||
pda.insert()
|
|
||||||
pda.submit()
|
|
||||||
|
|
||||||
email = frappe.db.sql(""" select name from `tabEmail Queue`
|
|
||||||
where message like %(txt)s """, {
|
|
||||||
'txt': "%%%s%%" % "Error while processing deferred accounting for {0}".format(pda.name)
|
|
||||||
})
|
|
||||||
|
|
||||||
self.assertTrue(email)
|
|
||||||
|
|
||||||
acc_settings.load_from_db()
|
|
||||||
acc_settings.acc_frozen_upto = None
|
|
||||||
acc_settings.save()
|
|
||||||
|
|
||||||
def test_inter_company_transaction(self):
|
def test_inter_company_transaction(self):
|
||||||
|
|
||||||
if not frappe.db.exists("Customer", "_Test Internal Customer"):
|
if not frappe.db.exists("Customer", "_Test Internal Customer"):
|
||||||
|
@ -5,14 +5,23 @@ import frappe
|
|||||||
import json
|
import json
|
||||||
from frappe.utils import nowdate, add_months, get_date_str
|
from frappe.utils import nowdate, add_months, get_date_str
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.dashboard_fixtures import _get_fiscal_year
|
||||||
|
from erpnext.buying.dashboard_fixtures import get_company_for_dashboards
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
|
|
||||||
|
fiscal_year = _get_fiscal_year(nowdate())
|
||||||
|
|
||||||
|
if not fiscal_year:
|
||||||
|
return frappe._dict()
|
||||||
|
|
||||||
|
year_start_date = get_date_str(fiscal_year[1])
|
||||||
|
year_end_date = get_date_str(fiscal_year[2])
|
||||||
|
|
||||||
return frappe._dict({
|
return frappe._dict({
|
||||||
"dashboards": get_dashboards(),
|
"dashboards": get_dashboards(),
|
||||||
"charts": get_charts(),
|
"charts": get_charts(fiscal_year, year_start_date, year_end_date),
|
||||||
"number_cards": get_number_cards(),
|
"number_cards": get_number_cards(fiscal_year, year_start_date, year_end_date),
|
||||||
})
|
})
|
||||||
|
|
||||||
def get_dashboards():
|
def get_dashboards():
|
||||||
@ -31,12 +40,7 @@ def get_dashboards():
|
|||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
fiscal_year = get_fiscal_year(date=nowdate())
|
def get_charts(fiscal_year, year_start_date, year_end_date):
|
||||||
year_start_date = get_date_str(fiscal_year[1])
|
|
||||||
year_end_date = get_date_str(fiscal_year[2])
|
|
||||||
|
|
||||||
|
|
||||||
def get_charts():
|
|
||||||
company = get_company_for_dashboards()
|
company = get_company_for_dashboards()
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -134,7 +138,7 @@ def get_charts():
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_number_cards():
|
def get_number_cards(fiscal_year, year_start_date, year_end_date):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"name": "Total Assets",
|
"name": "Total Assets",
|
||||||
@ -172,14 +176,4 @@ def get_number_cards():
|
|||||||
"filters_json": "[]",
|
"filters_json": "[]",
|
||||||
"doctype": "Number Card"
|
"doctype": "Number Card"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_company_for_dashboards():
|
|
||||||
company = frappe.defaults.get_defaults().company
|
|
||||||
if company:
|
|
||||||
return company
|
|
||||||
else:
|
|
||||||
company_list = frappe.get_list("Company")
|
|
||||||
if company_list:
|
|
||||||
return company_list[0].name
|
|
||||||
return None
|
|
@ -5,13 +5,24 @@ import frappe
|
|||||||
import json
|
import json
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import nowdate
|
from frappe.utils import nowdate
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.dashboard_fixtures import _get_fiscal_year
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
|
|
||||||
|
fiscal_year = _get_fiscal_year(nowdate())
|
||||||
|
|
||||||
|
if not fiscal_year:
|
||||||
|
return frappe._dict()
|
||||||
|
|
||||||
|
company = frappe.get_doc("Company", get_company_for_dashboards())
|
||||||
|
fiscal_year_name = fiscal_year.get("name")
|
||||||
|
start_date = str(fiscal_year.get("year_start_date"))
|
||||||
|
end_date = str(fiscal_year.get("year_end_date"))
|
||||||
|
|
||||||
return frappe._dict({
|
return frappe._dict({
|
||||||
"dashboards": get_dashboards(),
|
"dashboards": get_dashboards(),
|
||||||
"charts": get_charts(),
|
"charts": get_charts(company, fiscal_year_name, start_date, end_date),
|
||||||
"number_cards": get_number_cards(),
|
"number_cards": get_number_cards(company, fiscal_year_name, start_date, end_date),
|
||||||
})
|
})
|
||||||
|
|
||||||
def get_company_for_dashboards():
|
def get_company_for_dashboards():
|
||||||
@ -24,12 +35,6 @@ def get_company_for_dashboards():
|
|||||||
return company_list[0].name
|
return company_list[0].name
|
||||||
return None
|
return None
|
||||||
|
|
||||||
company = frappe.get_doc("Company", get_company_for_dashboards())
|
|
||||||
fiscal_year = get_fiscal_year(nowdate(), as_dict=1)
|
|
||||||
fiscal_year_name = fiscal_year.get("name")
|
|
||||||
start_date = str(fiscal_year.get("year_start_date"))
|
|
||||||
end_date = str(fiscal_year.get("year_end_date"))
|
|
||||||
|
|
||||||
def get_dashboards():
|
def get_dashboards():
|
||||||
return [{
|
return [{
|
||||||
"name": "Buying",
|
"name": "Buying",
|
||||||
@ -48,7 +53,7 @@ def get_dashboards():
|
|||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def get_charts():
|
def get_charts(company, fiscal_year_name, start_date, end_date):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"name": "Purchase Order Analysis",
|
"name": "Purchase Order Analysis",
|
||||||
@ -139,7 +144,7 @@ def get_charts():
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_number_cards():
|
def get_number_cards(company, fiscal_year_name, start_date, end_date):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"name": "Annual Purchase",
|
"name": "Annual Purchase",
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
import frappe, erpnext, json
|
import frappe, erpnext, json
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import nowdate, get_first_day, get_last_day, add_months
|
from frappe.utils import nowdate, get_first_day, get_last_day, add_months
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
return frappe._dict({
|
return frappe._dict({
|
||||||
|
@ -9,14 +9,14 @@ def setup(company=None, patch=True):
|
|||||||
make_custom_fields()
|
make_custom_fields()
|
||||||
add_print_formats()
|
add_print_formats()
|
||||||
|
|
||||||
def make_custom_fields():
|
def make_custom_fields(update=True):
|
||||||
custom_fields = {
|
custom_fields = {
|
||||||
'Supplier': [
|
'Supplier': [
|
||||||
dict(fieldname='irs_1099', fieldtype='Check', insert_after='tax_id',
|
dict(fieldname='irs_1099', fieldtype='Check', insert_after='tax_id',
|
||||||
label='Is IRS 1099 reporting required for supplier?')
|
label='Is IRS 1099 reporting required for supplier?')
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
create_custom_fields(custom_fields)
|
create_custom_fields(custom_fields, update=update)
|
||||||
|
|
||||||
def add_print_formats():
|
def add_print_formats():
|
||||||
frappe.reload_doc("regional", "print_format", "irs_1099_form")
|
frappe.reload_doc("regional", "print_format", "irs_1099_form")
|
||||||
|
@ -5,31 +5,26 @@ import frappe
|
|||||||
import json
|
import json
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import nowdate
|
from frappe.utils import nowdate
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.dashboard_fixtures import _get_fiscal_year
|
||||||
|
from erpnext.buying.dashboard_fixtures import get_company_for_dashboards
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
|
fiscal_year = _get_fiscal_year(nowdate())
|
||||||
|
|
||||||
|
if not fiscal_year:
|
||||||
|
return frappe._dict()
|
||||||
|
|
||||||
|
company = frappe.get_doc("Company", get_company_for_dashboards())
|
||||||
|
fiscal_year_name = fiscal_year.get("name")
|
||||||
|
start_date = str(fiscal_year.get("year_start_date"))
|
||||||
|
end_date = str(fiscal_year.get("year_end_date"))
|
||||||
|
|
||||||
return frappe._dict({
|
return frappe._dict({
|
||||||
"dashboards": get_dashboards(),
|
"dashboards": get_dashboards(),
|
||||||
"charts": get_charts(),
|
"charts": get_charts(company, fiscal_year_name, start_date, end_date),
|
||||||
"number_cards": get_number_cards(),
|
"number_cards": get_number_cards(company, fiscal_year_name, start_date, end_date),
|
||||||
})
|
})
|
||||||
|
|
||||||
def get_company_for_dashboards():
|
|
||||||
company = frappe.defaults.get_defaults().company
|
|
||||||
if company:
|
|
||||||
return company
|
|
||||||
else:
|
|
||||||
company_list = frappe.get_list("Company")
|
|
||||||
if company_list:
|
|
||||||
return company_list[0].name
|
|
||||||
return None
|
|
||||||
|
|
||||||
company = frappe.get_doc("Company", get_company_for_dashboards())
|
|
||||||
fiscal_year = get_fiscal_year(nowdate(), as_dict=1)
|
|
||||||
fiscal_year_name = fiscal_year.get("name")
|
|
||||||
start_date = str(fiscal_year.get("year_start_date"))
|
|
||||||
end_date = str(fiscal_year.get("year_end_date"))
|
|
||||||
|
|
||||||
def get_dashboards():
|
def get_dashboards():
|
||||||
return [{
|
return [{
|
||||||
"name": "Stock",
|
"name": "Stock",
|
||||||
@ -48,7 +43,7 @@ def get_dashboards():
|
|||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def get_charts():
|
def get_charts(company, fiscal_year_name, start_date, end_date):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"doctype": "Dashboard Chart",
|
"doctype": "Dashboard Chart",
|
||||||
@ -133,7 +128,7 @@ def get_charts():
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_number_cards():
|
def get_number_cards(company, fiscal_year_name, start_date, end_date):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"name": "Total Active Items",
|
"name": "Total Active Items",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user