fix: sider issues

This commit is contained in:
Nabin Hait 2022-01-31 18:07:04 +05:30
parent 6099af5d00
commit 5b0ec6437b
7 changed files with 26 additions and 21 deletions

View File

@ -4,7 +4,6 @@
import frappe
from frappe import _
from frappe.utils import cint
from frappe.utils.nestedset import NestedSet
from erpnext.accounts.utils import validate_field_number

View File

@ -9,7 +9,7 @@ frappe.ui.form.on('Cost Center Allocation', {
"company": frm.doc.company
});
}
frm.set_query('main_cost_center', function() {
return {
filters: filters

View File

@ -58,11 +58,9 @@ class CostCenterAllocation(Document):
if future_allocation:
frappe.msgprint(_("Another Cost Center Allocation record {0} applicable from {1}, hence this allocation will be applicable upto {2}")
.format(
frappe.bold(future_allocation.name),
frappe.bold(format_date(future_allocation.valid_from)),
frappe.bold(format_date(add_days(future_allocation.valid_from, -1)))
), title=_("Warning!"), indicator="orange", alert=1
.format(frappe.bold(future_allocation.name), frappe.bold(format_date(future_allocation.valid_from)),
frappe.bold(format_date(add_days(future_allocation.valid_from, -1)))),
title=_("Warning!"), indicator="orange", alert=1
)
def validate_main_cost_center(self):

View File

@ -1,13 +1,21 @@
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
import frappe
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_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.cost_center_allocation.cost_center_allocation import (MainCostCenterCantBeChild,
InvalidMainCostCenter, InvalidChildCostCenter, WrongPercentageAllocation, InvalidDateError)
class TestCostCenterAllocation(unittest.TestCase):
def setUp(self):
@ -22,7 +30,7 @@ class TestCostCenterAllocation(unittest.TestCase):
"Sub Cost Center 2 - _TC": 40
}
)
jv = make_journal_entry("_Test Cash - _TC", "Sales - _TC", 100,
cost_center = "Main Cost Center 1 - _TC", submit=True)
@ -77,14 +85,13 @@ class TestCostCenterAllocation(unittest.TestCase):
"Sub Cost Center 2 - _TC": 100
}, save=False
)
self.assertRaises(InvalidMainCostCenter, cca2.save)
cca1.cancel()
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",
{
"Sub Cost Center 1 - _TC": 60,
@ -98,7 +105,7 @@ class TestCostCenterAllocation(unittest.TestCase):
"Sub Cost Center 1 - _TC": 40
}, save=False
)
self.assertRaises(InvalidChildCostCenter, cca2.save)
cca1.cancel()
@ -128,7 +135,6 @@ class TestCostCenterAllocation(unittest.TestCase):
self.assertRaises(InvalidDateError, cca.save)
jv.cancel()
def create_cost_center_allocation(company, main_cost_center, allocation_percentages,
valid_from=None, valid_upto=None, save=True, submit=True):

View File

@ -4,5 +4,6 @@
# import frappe
from frappe.model.document import Document
class CostCenterAllocationPercentage(Document):
pass

View File

@ -2,8 +2,9 @@
# License: GNU General Public License v3. See license.txt
import frappe
import copy
import frappe
from frappe import _
from frappe.model.meta import get_field_precision
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:
cc_allocation.setdefault(d.main_cost_center, frappe._dict())\
.setdefault(d.cost_center, d.percentage)
return cc_allocation
def merge_similar_entries(gl_map, precision=None):

View File

@ -1,6 +1,7 @@
import frappe
from frappe.utils import today
def execute():
for dt in ("cost_center_allocation", "cost_center_allocation_percentage"):
frappe.reload_doc('accounts', 'doctype', dt)
@ -22,7 +23,6 @@ def create_new_cost_center_allocation_records(cc_allocations):
"cost_center": child_cc,
"percentage": percentage
}))
cca.save()
cca.submit()