fix: sider issues
This commit is contained in:
parent
6099af5d00
commit
5b0ec6437b
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import cint
|
|
||||||
from frappe.utils.nestedset import NestedSet
|
from frappe.utils.nestedset import NestedSet
|
||||||
|
|
||||||
from erpnext.accounts.utils import validate_field_number
|
from erpnext.accounts.utils import validate_field_number
|
||||||
|
@ -9,7 +9,7 @@ frappe.ui.form.on('Cost Center Allocation', {
|
|||||||
"company": frm.doc.company
|
"company": frm.doc.company
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.set_query('main_cost_center', function() {
|
frm.set_query('main_cost_center', function() {
|
||||||
return {
|
return {
|
||||||
filters: filters
|
filters: filters
|
||||||
|
@ -58,11 +58,9 @@ class CostCenterAllocation(Document):
|
|||||||
|
|
||||||
if future_allocation:
|
if future_allocation:
|
||||||
frappe.msgprint(_("Another Cost Center Allocation record {0} applicable from {1}, hence this allocation will be applicable upto {2}")
|
frappe.msgprint(_("Another Cost Center Allocation record {0} applicable from {1}, hence this allocation will be applicable upto {2}")
|
||||||
.format(
|
.format(frappe.bold(future_allocation.name), frappe.bold(format_date(future_allocation.valid_from)),
|
||||||
frappe.bold(future_allocation.name),
|
frappe.bold(format_date(add_days(future_allocation.valid_from, -1)))),
|
||||||
frappe.bold(format_date(future_allocation.valid_from)),
|
title=_("Warning!"), indicator="orange", alert=1
|
||||||
frappe.bold(format_date(add_days(future_allocation.valid_from, -1)))
|
|
||||||
), title=_("Warning!"), indicator="orange", alert=1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_main_cost_center(self):
|
def validate_main_cost_center(self):
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import frappe
|
|
||||||
import unittest
|
import unittest
|
||||||
from frappe.utils import today, add_days
|
|
||||||
|
import frappe
|
||||||
|
from frappe.utils import add_days, today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
||||||
|
from erpnext.accounts.doctype.cost_center_allocation.cost_center_allocation import (
|
||||||
|
InvalidChildCostCenter,
|
||||||
|
InvalidDateError,
|
||||||
|
InvalidMainCostCenter,
|
||||||
|
MainCostCenterCantBeChild,
|
||||||
|
WrongPercentageAllocation,
|
||||||
|
)
|
||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
from erpnext.accounts.doctype.cost_center_allocation.cost_center_allocation import (MainCostCenterCantBeChild,
|
|
||||||
InvalidMainCostCenter, InvalidChildCostCenter, WrongPercentageAllocation, InvalidDateError)
|
|
||||||
|
|
||||||
class TestCostCenterAllocation(unittest.TestCase):
|
class TestCostCenterAllocation(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -22,7 +30,7 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
"Sub Cost Center 2 - _TC": 40
|
"Sub Cost Center 2 - _TC": 40
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
jv = make_journal_entry("_Test Cash - _TC", "Sales - _TC", 100,
|
jv = make_journal_entry("_Test Cash - _TC", "Sales - _TC", 100,
|
||||||
cost_center = "Main Cost Center 1 - _TC", submit=True)
|
cost_center = "Main Cost Center 1 - _TC", submit=True)
|
||||||
|
|
||||||
@ -77,14 +85,13 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
"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)
|
||||||
|
|
||||||
cca1.cancel()
|
cca1.cancel()
|
||||||
|
|
||||||
|
|
||||||
def test_if_child_cost_center_has_any_allocation_record(self):
|
def test_if_child_cost_center_has_any_allocation_record(self):
|
||||||
# Check if any child cost center is used as main cost center in any other existing allocation
|
# Check if any child cost center is used as main cost center in any other existing allocation
|
||||||
cca1 = create_cost_center_allocation("_Test Company", "Main Cost Center 1 - _TC",
|
cca1 = create_cost_center_allocation("_Test Company", "Main Cost Center 1 - _TC",
|
||||||
{
|
{
|
||||||
"Sub Cost Center 1 - _TC": 60,
|
"Sub Cost Center 1 - _TC": 60,
|
||||||
@ -98,7 +105,7 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
"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)
|
||||||
|
|
||||||
cca1.cancel()
|
cca1.cancel()
|
||||||
@ -128,7 +135,6 @@ class TestCostCenterAllocation(unittest.TestCase):
|
|||||||
self.assertRaises(InvalidDateError, cca.save)
|
self.assertRaises(InvalidDateError, cca.save)
|
||||||
|
|
||||||
jv.cancel()
|
jv.cancel()
|
||||||
|
|
||||||
|
|
||||||
def create_cost_center_allocation(company, main_cost_center, allocation_percentages,
|
def create_cost_center_allocation(company, main_cost_center, allocation_percentages,
|
||||||
valid_from=None, valid_upto=None, save=True, submit=True):
|
valid_from=None, valid_upto=None, save=True, submit=True):
|
||||||
|
@ -4,5 +4,6 @@
|
|||||||
# import frappe
|
# import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class CostCenterAllocationPercentage(Document):
|
class CostCenterAllocationPercentage(Document):
|
||||||
pass
|
pass
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
import frappe
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.meta import get_field_precision
|
from frappe.model.meta import get_field_precision
|
||||||
from frappe.utils import cint, cstr, flt, formatdate, getdate, now
|
from frappe.utils import cint, cstr, flt, formatdate, getdate, now
|
||||||
@ -101,7 +102,7 @@ def get_cost_center_allocation_data(company, posting_date):
|
|||||||
for d in records:
|
for d in records:
|
||||||
cc_allocation.setdefault(d.main_cost_center, frappe._dict())\
|
cc_allocation.setdefault(d.main_cost_center, frappe._dict())\
|
||||||
.setdefault(d.cost_center, d.percentage)
|
.setdefault(d.cost_center, d.percentage)
|
||||||
|
|
||||||
return cc_allocation
|
return cc_allocation
|
||||||
|
|
||||||
def merge_similar_entries(gl_map, precision=None):
|
def merge_similar_entries(gl_map, precision=None):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import today
|
from frappe.utils import today
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
for dt in ("cost_center_allocation", "cost_center_allocation_percentage"):
|
for dt in ("cost_center_allocation", "cost_center_allocation_percentage"):
|
||||||
frappe.reload_doc('accounts', 'doctype', dt)
|
frappe.reload_doc('accounts', 'doctype', dt)
|
||||||
@ -22,7 +23,6 @@ def create_new_cost_center_allocation_records(cc_allocations):
|
|||||||
"cost_center": child_cc,
|
"cost_center": child_cc,
|
||||||
"percentage": percentage
|
"percentage": percentage
|
||||||
}))
|
}))
|
||||||
|
|
||||||
cca.save()
|
cca.save()
|
||||||
cca.submit()
|
cca.submit()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user