fix: add get_office_employee_url() method for corepos handler

This commit is contained in:
Lance Edgar 2025-01-24 19:35:14 -06:00
parent e6921c8533
commit 1a9929c734
2 changed files with 32 additions and 0 deletions

View file

@ -180,6 +180,28 @@ class CoreposHandler(GenericHandler):
if office_url: if office_url:
return f'{office_url}/item/departments/DepartmentEditor.php?did={dept_id}' return f'{office_url}/item/departments/DepartmentEditor.php?did={dept_id}'
def get_office_employee_url(
self,
employee_id,
office_url=None,
require=False):
"""
Returns the CORE Office URL for an Employee.
:param employee_id: Employee ID for the URL.
:param office_url: Root URL from :meth:`get_office_url()`.
:param require: If true, an error is raised when URL cannot be
determined.
:returns: URL as string.
"""
if not office_url:
office_url = self.get_office_url(require=require)
if office_url:
return f'{office_url}/admin/Cashiers/CashierEditor.php?emp_no={employee_id}'
def get_office_likecode_url( def get_office_likecode_url(
self, self,
likecode_id, likecode_id,

View file

@ -115,6 +115,16 @@ class TestCoreposHandler(ConfigTestCase):
self.config.setdefault('corepos.office.url', 'http://localhost/fannie/') self.config.setdefault('corepos.office.url', 'http://localhost/fannie/')
self.assertEqual(handler.get_office_department_url(7), 'http://localhost/fannie/item/departments/DepartmentEditor.php?did=7') self.assertEqual(handler.get_office_department_url(7), 'http://localhost/fannie/item/departments/DepartmentEditor.php?did=7')
def test_get_office_employee_url(self):
handler = self.make_handler()
# null
self.assertIsNone(handler.get_office_employee_url(7))
# typical
self.config.setdefault('corepos.office.url', 'http://localhost/fannie/')
self.assertEqual(handler.get_office_employee_url(7), 'http://localhost/fannie/admin/Cashiers/CashierEditor.php?emp_no=7')
def test_get_office_likecode_url(self): def test_get_office_likecode_url(self):
handler = self.make_handler() handler = self.make_handler()