fix: Fixed test case and sider issues
This commit is contained in:
parent
3dadfc9048
commit
6099af5d00
@ -4,7 +4,8 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import getdate, format_date, add_days
|
from frappe.utils import add_days, format_date, getdate
|
||||||
|
|
||||||
|
|
||||||
class MainCostCenterCantBeChild(frappe.ValidationError):
|
class MainCostCenterCantBeChild(frappe.ValidationError):
|
||||||
pass
|
pass
|
||||||
|
@ -57,8 +57,8 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
{
|
{
|
||||||
"Sub Cost Center 1 - _TC": 60,
|
"Sub Cost Center 1 - _TC": 60,
|
||||||
"Main Cost Center 1 - _TC": 40
|
"Main Cost Center 1 - _TC": 40
|
||||||
}
|
}, save=False
|
||||||
, save=False)
|
)
|
||||||
|
|
||||||
self.assertRaises(MainCostCenterCantBeChild, cca.save)
|
self.assertRaises(MainCostCenterCantBeChild, cca.save)
|
||||||
|
|
||||||
@ -75,8 +75,8 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
cca2 = create_cost_center_allocation("_Test Company", "Sub Cost Center 1 - _TC",
|
cca2 = create_cost_center_allocation("_Test Company", "Sub Cost Center 1 - _TC",
|
||||||
{
|
{
|
||||||
"Sub Cost Center 2 - _TC": 100
|
"Sub Cost Center 2 - _TC": 100
|
||||||
}
|
}, save=False
|
||||||
, save=False)
|
)
|
||||||
|
|
||||||
self.assertRaises(InvalidMainCostCenter, cca2.save)
|
self.assertRaises(InvalidMainCostCenter, cca2.save)
|
||||||
|
|
||||||
@ -96,8 +96,8 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
{
|
{
|
||||||
"Main Cost Center 1 - _TC": 60,
|
"Main Cost Center 1 - _TC": 60,
|
||||||
"Sub Cost Center 1 - _TC": 40
|
"Sub Cost Center 1 - _TC": 40
|
||||||
}
|
}, save=False
|
||||||
, save=False)
|
)
|
||||||
|
|
||||||
self.assertRaises(InvalidChildCostCenter, cca2.save)
|
self.assertRaises(InvalidChildCostCenter, cca2.save)
|
||||||
|
|
||||||
@ -108,8 +108,8 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
{
|
{
|
||||||
"Sub Cost Center 1 - _TC": 40,
|
"Sub Cost Center 1 - _TC": 40,
|
||||||
"Sub Cost Center 2 - _TC": 40
|
"Sub Cost Center 2 - _TC": 40
|
||||||
}
|
}, save=False
|
||||||
, save=False)
|
)
|
||||||
self.assertRaises(WrongPercentageAllocation, cca.save)
|
self.assertRaises(WrongPercentageAllocation, cca.save)
|
||||||
|
|
||||||
def test_valid_from_based_on_existing_gle(self):
|
def test_valid_from_based_on_existing_gle(self):
|
||||||
@ -122,8 +122,8 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
{
|
{
|
||||||
"Sub Cost Center 1 - _TC": 60,
|
"Sub Cost Center 1 - _TC": 60,
|
||||||
"Sub Cost Center 2 - _TC": 40
|
"Sub Cost Center 2 - _TC": 40
|
||||||
}
|
}, valid_from=add_days(today(), -1), save=False
|
||||||
, valid_from=add_days(today(), -1), save=False)
|
)
|
||||||
|
|
||||||
self.assertRaises(InvalidDateError, cca.save)
|
self.assertRaises(InvalidDateError, cca.save)
|
||||||
|
|
||||||
|
@ -52,6 +52,9 @@ def validate_accounting_period(gl_map):
|
|||||||
.format(frappe.bold(accounting_periods[0].name)), ClosedAccountingPeriod)
|
.format(frappe.bold(accounting_periods[0].name)), ClosedAccountingPeriod)
|
||||||
|
|
||||||
def process_gl_map(gl_map, merge_entries=True, precision=None):
|
def process_gl_map(gl_map, merge_entries=True, precision=None):
|
||||||
|
if not gl_map:
|
||||||
|
return []
|
||||||
|
|
||||||
gl_map = distribute_gl_based_on_cost_center_allocation(gl_map, precision)
|
gl_map = distribute_gl_based_on_cost_center_allocation(gl_map, precision)
|
||||||
|
|
||||||
if merge_entries:
|
if merge_entries:
|
||||||
@ -86,8 +89,7 @@ def get_cost_center_allocation_data(company, posting_date):
|
|||||||
child = frappe.qb.DocType("Cost Center Allocation Percentage")
|
child = frappe.qb.DocType("Cost Center Allocation Percentage")
|
||||||
|
|
||||||
records = (
|
records = (
|
||||||
frappe.qb.from_(par)
|
frappe.qb.from_(par).inner_join(child).on(par.name == child.parent)
|
||||||
.inner_join(child).on(par.name == child.parent)
|
|
||||||
.select(par.main_cost_center, child.cost_center, child.percentage)
|
.select(par.main_cost_center, child.cost_center, child.percentage)
|
||||||
.where(par.docstatus == 1)
|
.where(par.docstatus == 1)
|
||||||
.where(par.company == company)
|
.where(par.company == company)
|
||||||
|
@ -393,8 +393,9 @@ def set_gl_entries_by_account(
|
|||||||
where company=%(company)s
|
where company=%(company)s
|
||||||
{additional_conditions}
|
{additional_conditions}
|
||||||
and posting_date <= %(to_date)s
|
and posting_date <= %(to_date)s
|
||||||
and is_cancelled = 0
|
and is_cancelled = 0""".format(
|
||||||
""".format(additional_conditions=additional_conditions), gl_filters, as_dict=True) #nosec
|
additional_conditions=additional_conditions), gl_filters, as_dict=True
|
||||||
|
)
|
||||||
|
|
||||||
if filters and filters.get('presentation_currency'):
|
if filters and filters.get('presentation_currency'):
|
||||||
convert_to_presentation_currency(gl_entries, get_currency(filters), filters.get('company'))
|
convert_to_presentation_currency(gl_entries, get_currency(filters), filters.get('company'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user