From 8e454389b749770f1aef5a8f89bac907344aceaa Mon Sep 17 00:00:00 2001 From: solomonfortune Date: Thu, 30 Apr 2026 15:08:08 +0300 Subject: [PATCH 1/4] O3-5638 : Remove cashier timesheet feature --- .../module/billing/ModuleSettings.java | 44 --- .../module/billing/api/ITimesheetService.java | 57 ---- .../api/impl/CashierOptionsServiceGpImpl.java | 21 +- .../api/impl/TimesheetServiceImpl.java | 134 --------- .../billing/api/model/CashierOptions.java | 10 - .../billing/api/model/CashierSettings.java | 40 --- .../module/billing/api/model/Timesheet.java | 75 ----- .../api/tasks/AutoCloseTimesheetsTask.java | 45 --- .../billing/api/util/PrivilegeConstants.java | 15 +- .../api/util/TimesheetRequiredException.java | 25 -- .../billing/api/util/TimesheetUtil.java | 68 ----- api/src/main/resources/Cashier.hbm.xml | 32 --- api/src/main/resources/messages.properties | 25 -- .../resources/moduleApplicationContext.xml | 15 +- .../billing/ICashierOptionsServiceTest.java | 2 - .../module/billing/ITimesheetServiceTest.java | 268 ------------------ .../impl/CashierOptionsServiceGpImplTest.java | 79 ------ .../billing/api/include/TimesheetTest.xml | 45 --- .../controller/BillAddEditController.java | 18 -- .../controller/CashierController.java | 146 ---------- .../CashierModuleSettingsController.java | 28 +- .../controller/TimesheetEntryValidator.java | 46 --- .../legacyweb/filter/CashierLogoutFilter.java | 99 ------- .../web/rest/resource/BillResource.java | 33 +-- .../web/rest/resource/TimesheetResource.java | 72 ----- .../rest/search/TimesheetSearchHandler.java | 65 ----- omod/src/main/resources/config.xml | 47 +-- omod/src/main/resources/liquibase.xml | 9 + 28 files changed, 20 insertions(+), 1543 deletions(-) delete mode 100644 api/src/main/java/org/openmrs/module/billing/api/ITimesheetService.java delete mode 100644 api/src/main/java/org/openmrs/module/billing/api/impl/TimesheetServiceImpl.java delete mode 100644 api/src/main/java/org/openmrs/module/billing/api/model/Timesheet.java delete mode 100644 api/src/main/java/org/openmrs/module/billing/api/tasks/AutoCloseTimesheetsTask.java delete mode 100644 api/src/main/java/org/openmrs/module/billing/api/util/TimesheetRequiredException.java delete mode 100644 api/src/main/java/org/openmrs/module/billing/api/util/TimesheetUtil.java delete mode 100644 api/src/test/java/org/openmrs/module/billing/ITimesheetServiceTest.java delete mode 100644 api/src/test/resources/org/openmrs/module/billing/api/include/TimesheetTest.xml delete mode 100644 omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/CashierController.java delete mode 100644 omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/TimesheetEntryValidator.java delete mode 100644 omod/src/main/java/org/openmrs/module/billing/web/legacyweb/filter/CashierLogoutFilter.java delete mode 100644 omod/src/main/java/org/openmrs/module/billing/web/rest/resource/TimesheetResource.java delete mode 100644 omod/src/main/java/org/openmrs/module/billing/web/rest/search/TimesheetSearchHandler.java diff --git a/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java b/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java index ec701796..5ed03d83 100644 --- a/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java +++ b/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java @@ -23,10 +23,6 @@ public class ModuleSettings { public static final String RECEIPT_REPORT_ID_PROPERTY = "billing.defaultReceiptReportId"; - public static final String CASHIER_SHIFT_REPORT_ID_PROPERTY = "billing.defaultShiftReportId"; - - public static final String TIMESHEET_REQUIRED_PROPERTY = "billing.timesheetRequired"; - public static final String ROUNDING_MODE_PROPERTY = "billing.roundingMode"; public static final String ROUND_TO_NEAREST_PROPERTY = "billing.roundToNearest"; @@ -51,10 +47,6 @@ public class ModuleSettings { public static final String DEPARTMENT_REVENUE_REPORT_ID_PROPERTY = "billing.reports.departmentRevenue"; - public static final String SHIFT_SUMMARY_REPORT_ID_PROPERTY = "billing.reports.shiftSummary"; - - public static final String DAILY_SHIFT_SUMMARY_REPORT_ID_PROPERTY = "billing.reports.dailyShiftSummary"; - public static final String PAYMENTS_BY_PAYMENT_MODE_REPORT_ID_PROPERTY = "billing.reports.paymentsByPaymentMode"; private static final AdministrationService administrationService; @@ -105,14 +97,6 @@ public void apply(Integer parameter) { } }); - getIntProperty(CASHIER_SHIFT_REPORT_ID_PROPERTY, new Action1() { - - @Override - public void apply(Integer parameter) { - cashierSettings.setDefaultShiftReportId(parameter); - } - }); - getIntProperty(RECEIPT_REPORT_ID_PROPERTY, new Action1() { @Override @@ -126,14 +110,6 @@ public void apply(Integer parameter) { cashierSettings.setCashierRoundingMode(property); } - getBoolProperty(TIMESHEET_REQUIRED_PROPERTY, new Action1() { - - @Override - public void apply(Boolean parameter) { - cashierSettings.setCashierTimesheetRequired(parameter); - } - }); - getIntProperty(PATIENT_DASHBOARD_2_BILL_COUNT, DEFAULT_PATIENT_DASHBOARD_2_BILL_COUNT, new Action1() { @Override @@ -158,22 +134,6 @@ public void apply(Integer parameter) { } }); - getIntProperty(SHIFT_SUMMARY_REPORT_ID_PROPERTY, new Action1() { - - @Override - public void apply(Integer parameter) { - cashierSettings.setShiftSummaryReportId(parameter); - } - }); - - getIntProperty(DAILY_SHIFT_SUMMARY_REPORT_ID_PROPERTY, new Action1() { - - @Override - public void apply(Integer parameter) { - cashierSettings.setDailyShiftSummaryReportId(parameter); - } - }); - getIntProperty(PAYMENTS_BY_PAYMENT_MODE_REPORT_ID_PROPERTY, new Action1() { @Override @@ -193,16 +153,12 @@ public static void saveSettings(CashierSettings cashierSettings) { setBoolProperty(ADJUSTMENT_REASON_FIELD, cashierSettings.getAdjustmentReasonField()); setBoolProperty(ALLOW_BILL_ADJUSTMENT, cashierSettings.getAllowBillAdjustment()); setBoolProperty(AUTOFILL_PAYMENT_AMOUNT, cashierSettings.getAutoFillPaymentAmount()); - setIntProperty(CASHIER_SHIFT_REPORT_ID_PROPERTY, cashierSettings.getDefaultShiftReportId()); setIntProperty(ROUND_TO_NEAREST_PROPERTY, cashierSettings.getCashierRoundingToNearest()); setIntProperty(RECEIPT_REPORT_ID_PROPERTY, cashierSettings.getDefaultReceiptReportId()); setStringProperty(ROUNDING_MODE_PROPERTY, cashierSettings.getCashierRoundingMode()); - setBoolProperty(TIMESHEET_REQUIRED_PROPERTY, cashierSettings.getCashierTimesheetRequired()); setIntProperty(PATIENT_DASHBOARD_2_BILL_COUNT, cashierSettings.getPatientDashboard2BillCount()); setIntProperty(DEPARTMENT_COLLECTIONS_REPORT_ID_PROPERTY, cashierSettings.getDepartmentCollectionsReportId()); setIntProperty(DEPARTMENT_REVENUE_REPORT_ID_PROPERTY, cashierSettings.getDepartmentRevenueReportId()); - setIntProperty(SHIFT_SUMMARY_REPORT_ID_PROPERTY, cashierSettings.getShiftSummaryReportId()); - setIntProperty(DAILY_SHIFT_SUMMARY_REPORT_ID_PROPERTY, cashierSettings.getDailyShiftSummaryReportId()); setIntProperty(PAYMENTS_BY_PAYMENT_MODE_REPORT_ID_PROPERTY, cashierSettings.getPaymentsByPaymentModeReportId()); } diff --git a/api/src/main/java/org/openmrs/module/billing/api/ITimesheetService.java b/api/src/main/java/org/openmrs/module/billing/api/ITimesheetService.java deleted file mode 100644 index 74c25035..00000000 --- a/api/src/main/java/org/openmrs/module/billing/api/ITimesheetService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.api; - -import java.util.Date; -import java.util.List; - -import org.openmrs.Provider; -import org.openmrs.module.billing.api.base.entity.IEntityDataService; -import org.openmrs.module.billing.api.model.Timesheet; - -/** - * Interface that represents classes which perform data operations for {@link Timesheet}s. - */ -public interface ITimesheetService extends IEntityDataService { - - /** - * Gets the current {@link Timesheet} that the specified {@link Provider}. - * - * @param cashier The cashier. - * @return The {@link Timesheet} or {@code null} is the cashier is not clocked in. - * @should return the current timesheet for the cashier - * @should return null if the cashier has no timesheets - * @should return the most recent timesheet if the cashier is clocked into multiple timesheets - * @should return null if the timesheet is clocked out - */ - Timesheet getCurrentTimesheet(Provider cashier); - - /** - * Gets all the {@link Timesheet}'s for the specified user on the specified day. - * - * @param cashier The cashier. - * @param date The date. - * @return All the timesheets for the cashier on the specified day. - * @should return empty list if there are no timesheets for date - * @should return timesheets that start and end on date - * @should return timesheets that start on date and end on different date - * @should return timesheet that start on different date and end on date - * @should return timesheets that start before date but end after date - * @should return timesheets that start before date and have not ended - */ - List getTimesheetsByDate(Provider cashier, Date date); - - /** - * Closes all open {@link Timesheet}'s. - * - * @should return close all open timesheets - */ - void closeOpenTimesheets(); -} diff --git a/api/src/main/java/org/openmrs/module/billing/api/impl/CashierOptionsServiceGpImpl.java b/api/src/main/java/org/openmrs/module/billing/api/impl/CashierOptionsServiceGpImpl.java index ce309922..0779b693 100644 --- a/api/src/main/java/org/openmrs/module/billing/api/impl/CashierOptionsServiceGpImpl.java +++ b/api/src/main/java/org/openmrs/module/billing/api/impl/CashierOptionsServiceGpImpl.java @@ -35,9 +35,8 @@ public CashierOptionsServiceGpImpl() { * @return The {@link CashierOptions} * @should throw APIException if rounding is set but rounding item is not * @should throw APIException if rounding is set but rounding item cannot be found - * @should not throw exception if numeric options are null - * @should default to false if timesheet required is not specified - * @should load cashier options from the database + * @should not throw exception if numeric options are null * @should load cashier options from the + * database */ public CashierOptions getOptions() { CashierOptions options = new CashierOptions(); @@ -47,7 +46,6 @@ public CashierOptions getOptions() { if (StringUtils.isEmpty(options.getRoundingItemUuid())) { setRoundingOptionsForEmptyUuid(options); } - setTimesheetOptions(options); return options; } @@ -113,19 +111,4 @@ private void setRoundingOptionsForEmptyUuid(CashierOptions options) { options.setRoundingMode(CashierOptions.RoundingMode.MID); options.setRoundToNearest(0); } - - private void setTimesheetOptions(CashierOptions options) { - String timesheetRequiredProperty = Context.getAdministrationService() - .getGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY); - if (StringUtils.isNotBlank(timesheetRequiredProperty)) { - try { - options.setTimesheetRequired(Boolean.parseBoolean(timesheetRequiredProperty)); - } - catch (Exception ex) { - options.setTimesheetRequired(false); - } - } else { - options.setTimesheetRequired(false); - } - } } diff --git a/api/src/main/java/org/openmrs/module/billing/api/impl/TimesheetServiceImpl.java b/api/src/main/java/org/openmrs/module/billing/api/impl/TimesheetServiceImpl.java deleted file mode 100644 index 936f3ef6..00000000 --- a/api/src/main/java/org/openmrs/module/billing/api/impl/TimesheetServiceImpl.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.api.impl; - -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; -import org.openmrs.Provider; -import org.openmrs.api.context.Context; -import org.openmrs.module.billing.api.ITimesheetService; -import org.openmrs.module.billing.api.base.entity.impl.BaseEntityDataServiceImpl; -import org.openmrs.module.billing.api.base.entity.security.IEntityAuthorizationPrivileges; -import org.openmrs.module.billing.api.model.Timesheet; -import org.openmrs.module.billing.api.util.PrivilegeConstants; -import org.springframework.transaction.annotation.Transactional; - -/** - * Data service implementation class for {@link Timesheet}s. - */ -@Transactional -public class TimesheetServiceImpl extends BaseEntityDataServiceImpl implements ITimesheetService, IEntityAuthorizationPrivileges { - - private static final String CLOCK_IN = "clockIn"; - - private static final String CLOCK_OUT = "clockOut"; - - private static final Integer BATCH_SIZE = 50; - - private static final Integer END_DATE_HOUR_OF_DAY = 23; - - private static final Integer END_DATE_MINUTE = 59; - - private static final Integer END_DATE_SECOND = 59; - - @Override - protected IEntityAuthorizationPrivileges getPrivileges() { - return this; - } - - @Override - protected void validate(Timesheet entity) { - } - - @Override - public String getVoidPrivilege() { - return PrivilegeConstants.MANAGE_TIMESHEETS; - } - - @Override - public String getSavePrivilege() { - return PrivilegeConstants.MANAGE_TIMESHEETS; - } - - @Override - public String getPurgePrivilege() { - return PrivilegeConstants.PURGE_TIMESHEETS; - } - - @Override - public String getGetPrivilege() { - return PrivilegeConstants.VIEW_TIMESHEETS; - } - - @Override - public Timesheet getCurrentTimesheet(Provider cashier) { - Criteria criteria = getRepository().createCriteria(Timesheet.class); - criteria.add(Restrictions.and(Restrictions.eq("cashier", cashier), Restrictions.isNull(CLOCK_OUT))); - criteria.addOrder(Order.desc(CLOCK_IN)); - - return getRepository().selectSingle(Timesheet.class, criteria); - } - - @Override - public void closeOpenTimesheets() { - Criteria criteria = getRepository().createCriteria(Timesheet.class); - criteria.add(Restrictions.isNull("clockOut")); - criteria.addOrder(Order.desc("clockIn")); - - List timesheets = getRepository().select(Timesheet.class, criteria); - - Date clockOutDate = new Date(); - int counter = 0; - for (Timesheet timesheet : timesheets) { - timesheet.setClockOut(clockOutDate); - - if (counter++ > BATCH_SIZE) { - //ensure changes are persisted to DB before reclaiming memory - Context.flushSession(); - Context.clearSession(); - counter = 0; - } - } - } - - @Override - public List getTimesheetsByDate(Provider cashier, Date date) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - Date startDate = calendar.getTime(); - - calendar.set(Calendar.HOUR_OF_DAY, END_DATE_HOUR_OF_DAY); - calendar.set(Calendar.MINUTE, END_DATE_MINUTE); - calendar.set(Calendar.SECOND, END_DATE_SECOND); - Date endDate = calendar.getTime(); - - Criteria criteria = getRepository().createCriteria(Timesheet.class); - criteria.add(Restrictions.and(Restrictions.eq("cashier", cashier), Restrictions.or( - // Start or end on date - Restrictions.or(Restrictions.between(CLOCK_IN, startDate, endDate), - Restrictions.between(CLOCK_OUT, startDate, endDate)), - Restrictions.or( - // Start on or before date and have not ended - Restrictions.and(Restrictions.le(CLOCK_IN, endDate), Restrictions.isNull(CLOCK_OUT)), - // Start before and end after date - Restrictions.and(Restrictions.le(CLOCK_IN, startDate), Restrictions.ge(CLOCK_OUT, endDate)))))); - criteria.addOrder(Order.desc(CLOCK_IN)); - - return getRepository().select(Timesheet.class, criteria); - } -} diff --git a/api/src/main/java/org/openmrs/module/billing/api/model/CashierOptions.java b/api/src/main/java/org/openmrs/module/billing/api/model/CashierOptions.java index ae67569c..3e746855 100644 --- a/api/src/main/java/org/openmrs/module/billing/api/model/CashierOptions.java +++ b/api/src/main/java/org/openmrs/module/billing/api/model/CashierOptions.java @@ -24,8 +24,6 @@ public class CashierOptions { private int defaultReceiptReportId; - private boolean timesheetRequired = false; - public String getRoundingItemUuid() { return roundingItemUuid; } @@ -59,14 +57,6 @@ public void setDefaultReceiptReportId(int defaultReceiptReportId) { this.defaultReceiptReportId = defaultReceiptReportId; } - public boolean isTimesheetRequired() { - return timesheetRequired; - } - - public void setTimesheetRequired(boolean timesheetRequired) { - this.timesheetRequired = timesheetRequired; - } - /** * Defines the collection of constants to be used for setting the rounding mode */ diff --git a/api/src/main/java/org/openmrs/module/billing/api/model/CashierSettings.java b/api/src/main/java/org/openmrs/module/billing/api/model/CashierSettings.java index 7cf65e21..9d503262 100644 --- a/api/src/main/java/org/openmrs/module/billing/api/model/CashierSettings.java +++ b/api/src/main/java/org/openmrs/module/billing/api/model/CashierSettings.java @@ -24,26 +24,18 @@ public class CashierSettings { private Integer defaultReceiptReportId; - private Integer defaultShiftReportId; - private Boolean cashierMandatory; private Integer cashierRoundingToNearest; private String cashierRoundingMode; - private Boolean cashierTimesheetRequired; - private Integer patientDashboard2BillCount; private Integer departmentCollectionsReportId; private Integer departmentRevenueReportId; - private Integer shiftSummaryReportId; - - private Integer dailyShiftSummaryReportId; - private Integer paymentsByPaymentModeReportId; public Boolean getAdjustmentReasonField() { @@ -78,14 +70,6 @@ public void setDefaultReceiptReportId(Integer defaultReceiptReportId) { this.defaultReceiptReportId = defaultReceiptReportId; } - public Integer getDefaultShiftReportId() { - return defaultShiftReportId; - } - - public void setDefaultShiftReportId(Integer defaultShiftReportId) { - this.defaultShiftReportId = defaultShiftReportId; - } - public Boolean getCashierMandatory() { return cashierMandatory; } @@ -110,14 +94,6 @@ public void setCashierRoundingMode(String cashierRoundingMode) { this.cashierRoundingMode = cashierRoundingMode; } - public Boolean getCashierTimesheetRequired() { - return cashierTimesheetRequired; - } - - public void setCashierTimesheetRequired(Boolean cashierTimesheetRequired) { - this.cashierTimesheetRequired = cashierTimesheetRequired; - } - public Integer getPatientDashboard2BillCount() { return patientDashboard2BillCount; } @@ -142,22 +118,6 @@ public void setDepartmentRevenueReportId(Integer departmentRevenueReportId) { this.departmentRevenueReportId = departmentRevenueReportId; } - public Integer getShiftSummaryReportId() { - return shiftSummaryReportId; - } - - public void setShiftSummaryReportId(Integer shiftSummaryReportId) { - this.shiftSummaryReportId = shiftSummaryReportId; - } - - public Integer getDailyShiftSummaryReportId() { - return dailyShiftSummaryReportId; - } - - public void setDailyShiftSummaryReportId(Integer dailyShiftSummaryReportId) { - this.dailyShiftSummaryReportId = dailyShiftSummaryReportId; - } - public Integer getPaymentsByPaymentModeReportId() { return paymentsByPaymentModeReportId; } diff --git a/api/src/main/java/org/openmrs/module/billing/api/model/Timesheet.java b/api/src/main/java/org/openmrs/module/billing/api/model/Timesheet.java deleted file mode 100644 index b9c5538b..00000000 --- a/api/src/main/java/org/openmrs/module/billing/api/model/Timesheet.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.api.model; - -import java.util.Date; - -import org.openmrs.BaseOpenmrsData; -import org.openmrs.Provider; - -/** - * Model class to represent a cashier timesheet entry. - */ -public class Timesheet extends BaseOpenmrsData { - - private static final long serialVersionUID = 0L; - - private Integer timesheetId; - - private Provider cashier; - - private CashPoint cashPoint; - - private Date clockIn; - - private Date clockOut; - - @Override - public Integer getId() { - return timesheetId; - } - - @Override - public void setId(Integer id) { - this.timesheetId = id; - } - - public Provider getCashier() { - return cashier; - } - - public void setCashier(Provider cashier) { - this.cashier = cashier; - } - - public CashPoint getCashPoint() { - return cashPoint; - } - - public void setCashPoint(CashPoint cashPoint) { - this.cashPoint = cashPoint; - } - - public Date getClockIn() { - return clockIn; - } - - public void setClockIn(Date clockIn) { - this.clockIn = clockIn; - } - - public Date getClockOut() { - return clockOut; - } - - public void setClockOut(Date clockOut) { - this.clockOut = clockOut; - } -} diff --git a/api/src/main/java/org/openmrs/module/billing/api/tasks/AutoCloseTimesheetsTask.java b/api/src/main/java/org/openmrs/module/billing/api/tasks/AutoCloseTimesheetsTask.java deleted file mode 100644 index 82c2cd69..00000000 --- a/api/src/main/java/org/openmrs/module/billing/api/tasks/AutoCloseTimesheetsTask.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.api.tasks; - -import lombok.extern.slf4j.Slf4j; -import org.openmrs.api.context.Context; -import org.openmrs.module.billing.api.ITimesheetService; -import org.openmrs.scheduler.tasks.AbstractTask; - -/** - * A scheduled task that automatically closes all open timesheets - */ -@Slf4j -public class AutoCloseTimesheetsTask extends AbstractTask { - - @Override - public void execute() { - if (!isExecuting) { - if (log.isDebugEnabled()) { - log.debug("Starting Auto Close Timesheets Task..."); - } - - startExecuting(); - - try { - ITimesheetService timesheetService = Context.getService(ITimesheetService.class); - - timesheetService.closeOpenTimesheets(); - } - catch (Exception e) { - log.error("Error while auto closing open timesheets:", e); - } - finally { - stopExecuting(); - } - } - } -} diff --git a/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java b/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java index f0d59d1e..4087b971 100644 --- a/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java +++ b/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java @@ -45,12 +45,6 @@ public class PrivilegeConstants { public static final String PURGE_METADATA = "Purge Cashier Metadata"; - public static final String MANAGE_TIMESHEETS = "Manage Cashier Timesheets"; - - public static final String VIEW_TIMESHEETS = "View Cashier Timesheets"; - - public static final String PURGE_TIMESHEETS = "Purge Cashier Timesheets"; - public static final String APP_VIEW_CASHIER_APP = "App: View Cashier App"; public static final String APP_ACCESS_CASHIER_TASKS_PAGE = "App: Access Cashier Tasks"; @@ -59,8 +53,6 @@ public class PrivilegeConstants { public static final String TASK_ADJUST_CASHIER_BILL = "Task: Adjust Cashier Bills"; - public static final String TASK_CASHIER_TIMESHEETS_PAGE = "Task: Cashier Timesheets"; - public static final String TASK_MANAGE_CASHIER_MODULE_PAGE = "Task: Manage Cashier Module"; public static final String TASK_MANAGE_CASHIER_METADATA = "Task: Manage Cashier Metadata"; @@ -68,10 +60,9 @@ public class PrivilegeConstants { public static final String TASK_VIEW_CASHIER_REPORTS = "Task: View Cashier Reports"; public static final String[] PRIVILEGE_NAMES = new String[] { MANAGE_BILLS, ADJUST_BILLS, VIEW_BILLS, PURGE_BILLS, - REFUND_MONEY, REPRINT_RECEIPT, MANAGE_TIMESHEETS, VIEW_TIMESHEETS, PURGE_TIMESHEETS, MANAGE_METADATA, - VIEW_METADATA, PURGE_METADATA, APP_VIEW_CASHIER_APP, TASK_CREATE_NEW_BILL_PAGE, TASK_ADJUST_CASHIER_BILL, - TASK_CASHIER_TIMESHEETS_PAGE, TASK_MANAGE_CASHIER_MODULE_PAGE, TASK_MANAGE_CASHIER_METADATA, - TASK_CASHIER_TIMESHEETS_PAGE, TASK_MANAGE_CASHIER_MODULE_PAGE, TASK_VIEW_CASHIER_REPORTS, + REFUND_MONEY, REPRINT_RECEIPT, MANAGE_METADATA, VIEW_METADATA, PURGE_METADATA, APP_VIEW_CASHIER_APP, + TASK_CREATE_NEW_BILL_PAGE, TASK_ADJUST_CASHIER_BILL, TASK_MANAGE_CASHIER_MODULE_PAGE, + TASK_MANAGE_CASHIER_METADATA, TASK_MANAGE_CASHIER_MODULE_PAGE, TASK_VIEW_CASHIER_REPORTS, APP_ACCESS_CASHIER_TASKS_PAGE }; /** diff --git a/api/src/main/java/org/openmrs/module/billing/api/util/TimesheetRequiredException.java b/api/src/main/java/org/openmrs/module/billing/api/util/TimesheetRequiredException.java deleted file mode 100644 index 77aecc66..00000000 --- a/api/src/main/java/org/openmrs/module/billing/api/util/TimesheetRequiredException.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.api.util; - -/** - * Utility class to handle exception errors from {@link TimesheetUtil} - */ -public class TimesheetRequiredException extends Exception { - - private static final long serialVersionUID = 2440375803625380589L; - - public TimesheetRequiredException() { - } - - public TimesheetRequiredException(Throwable cause) { - super(cause); - } -} diff --git a/api/src/main/java/org/openmrs/module/billing/api/util/TimesheetUtil.java b/api/src/main/java/org/openmrs/module/billing/api/util/TimesheetUtil.java deleted file mode 100644 index 8551493b..00000000 --- a/api/src/main/java/org/openmrs/module/billing/api/util/TimesheetUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.api.util; - -import lombok.extern.slf4j.Slf4j; -import org.openmrs.Provider; -import org.openmrs.api.APIException; -import org.openmrs.api.AdministrationService; -import org.openmrs.api.ProviderService; -import org.openmrs.api.context.Context; -import org.openmrs.module.billing.ModuleSettings; -import org.openmrs.module.billing.api.ITimesheetService; -import org.openmrs.module.billing.api.base.ProviderUtil; -import org.openmrs.module.billing.api.model.Timesheet; - -/** - * Utility class fo {@link Timesheet} - */ -@Slf4j -public class TimesheetUtil { - - protected TimesheetUtil() { - } - - public static Timesheet getCurrentTimesheet() { - Provider provider; - Timesheet timesheet; - ProviderService providerService = Context.getProviderService(); - try { - provider = ProviderUtil.getCurrentProvider(providerService); - } - catch (Exception e) { - throw new APIException("Error retrieving provider for current user.", e); - } - - ITimesheetService tsService = Context.getService(ITimesheetService.class); - try { - timesheet = tsService.getCurrentTimesheet(provider); - } - catch (Exception e) { - log.error("Error occured while trying to get the current timesheet{}", String.valueOf(e)); - return null; - } - - return timesheet; - } - - public static boolean isTimesheetRequired() { - AdministrationService adminService = Context.getAdministrationService(); - boolean timesheetRequired; - try { - timesheetRequired = Boolean - .parseBoolean(adminService.getGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY)); - } - catch (Exception e) { - log.error("Error occured while trying to parse the boolean value{}", String.valueOf(e)); - timesheetRequired = false; - } - return timesheetRequired; - } -} diff --git a/api/src/main/resources/Cashier.hbm.xml b/api/src/main/resources/Cashier.hbm.xml index ff8a9ef4..9d9fe6c8 100644 --- a/api/src/main/resources/Cashier.hbm.xml +++ b/api/src/main/resources/Cashier.hbm.xml @@ -39,36 +39,4 @@ - - - - - - cashier_timesheet_timesheet_id_seq - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api/src/main/resources/messages.properties b/api/src/main/resources/messages.properties index 28b530aa..0a654fed 100644 --- a/api/src/main/resources/messages.properties +++ b/api/src/main/resources/messages.properties @@ -26,39 +26,18 @@ openhmis.cashier.admin.cashierSettings=Cashier Settings # Cashier openhmis.cashier.page=Cashier openhmis.cashier.admin.task.dashboard=Cashier Task Dashboard -openhmis.cashier.page.timesheet=Cashier Timesheet Entry openhmis.cashier.page.reports=Cashier Reports -openhmis.cashier.page.reports.error.timesheetRequired=You must select a timesheet to run the report. -openhmis.cashier.page.timesheet.box.title=Timesheet Entry -openhmis.cashier.page.timesheet.box.cash.point=Cash Point -openhmis.cashier.page.timesheet.box.clock.in=Clock In -openhmis.cashier.page.timesheet.box.clock.out=Clock Out -openhmis.cashier.page.timesheet.box.clockIn.message=You have clocked in successfully -openhmis.cashier.page.timesheet.box.clockOut.message=You have clocked out. -openhmis.cashier.page.timesheet.box.cashpoint.empty=You have not selected a cash point. Please select one to continue. openhmis.cashier.page.reports.box.title=Reports openhmis.cashier.page.reports.box.select.shift.date.label=Select Shift Date: -openhmis.cashier.page.reports.box.timesheets.shift.date=Timesheets on Shift Date: -openhmis.cashier.page.reports.box.timesheets.shift.date.error=No timesheet was found for selected date - -openhmis.cashier.page.timesheet.box.button.clock.in=Clock In -openhmis.cashier.page.timesheet.box.button.clock.out=Clock Out -openhmis.cashier.page.timesheet.box.button.save=Save openhmis.cashier.page.reports.box.generate.report=Generate Report openhmis.cashier.page.reports.box.generate.cashier.shift.report.popup.header=Generate Cashier shift report openhmis.cashier.page.reports.box.generate.cashier.shift.report.download.button=Cashier shift report -openhmis.cashier.page.timesheet.rest_name=timesheet openhmis.cashier.page.reports.box.select.shift.date.error=Please select a shift to generate the report openhmis.cashier.page.reports.box.select.clock.in.error=Please fill in the clock in time. #Cashpoints openhmis.cashier.cashpoints=Cash Point openhmis.cashier.cashpointsPlural=Cash Points openhmis.cashier.selectCashpoint=-- Select Cash Point -- -# Timesheet -openhmis.cashier.timesheet.entry.error.clockIn.empty=The clock in date/time must be defined. -openhmis.cashier.timesheet.entry.error.clockIn.future=The clock in date/time cannot be in the future. -openhmis.cashier.timesheet.entry.error.clockOut.future=The clock out date/time cannot be in the future. -openhmis.cashier.timesheet.entry.error.clockOut.before.clockIn=The clock out date/time cannot be before clock in date. -openhmis.cashier.timesheet.entry.error.notProvider=Your are not authorised to access this page. # Gutter openhmis.cashier.menuItem=New Bill # Bills @@ -199,12 +178,8 @@ openhmis.cashier.setting.billAdjustment.field.header=Allow Bill Adjustment openhmis.cashier.setting.billAdjustment.field.description=True/false weather or not the adjustment field feature should be turned on. openhmis.cashier.setting.autofillPaymentAmount.field.header=Autofill Payment Amount. openhmis.cashier.setting.autofillPaymentAmount.field.description=True/false weather or not the payment amount should be automatically filled with the remaining balance -openhmis.cashier.setting.timesheet.field.header=Require Timesheet. -openhmis.cashier.setting.timesheet.field.description=Whether or not to require an active timesheet when creating a new bill. True or false. openhmis.cashier.setting.receiptReportId.field.header=Default Receipt Report ID openhmis.cashier.setting.receiptReportId.field.description=ID of the default Jasper report to use for generating a receipt on the Bill page. -openhmis.cashier.setting.shiftReportId.field.header=Timesheet Shift Report ID -openhmis.cashier.setting.shiftReportId.field.description=ID of the Timesheet Shift report. openhmis.cashier.setting.departmentCollectionsReportId.field.header=Department Collections Report ID openhmis.cashier.setting.departmentCollectionsReportId.field.description=ID of the Department Collections report. openhmis.cashier.setting.departmentRevenueReportId.field.header=Department Revenue Report ID diff --git a/api/src/main/resources/moduleApplicationContext.xml b/api/src/main/resources/moduleApplicationContext.xml index c319aa65..18aab390 100644 --- a/api/src/main/resources/moduleApplicationContext.xml +++ b/api/src/main/resources/moduleApplicationContext.xml @@ -56,14 +56,6 @@ - - - - org.openmrs.module.billing.api.ITimesheetService - - - - @@ -156,12 +148,6 @@ - - - - - - @@ -292,3 +278,4 @@ + diff --git a/api/src/test/java/org/openmrs/module/billing/ICashierOptionsServiceTest.java b/api/src/test/java/org/openmrs/module/billing/ICashierOptionsServiceTest.java index ca6956e4..b6e53473 100644 --- a/api/src/test/java/org/openmrs/module/billing/ICashierOptionsServiceTest.java +++ b/api/src/test/java/org/openmrs/module/billing/ICashierOptionsServiceTest.java @@ -45,7 +45,6 @@ public void getOptions_shouldLoadOptions() { Assert.assertEquals(3, options.getDefaultReceiptReportId()); Assert.assertEquals(CashierOptions.RoundingMode.MID, options.getRoundingMode()); Assert.assertEquals(0, (int) options.getRoundToNearest()); - Assert.assertTrue(options.isTimesheetRequired()); } /** @@ -61,7 +60,6 @@ public void getOptions_shouldRevertToDefaultsIfThereAreProblemsLoadingOptions() Assert.assertEquals(reference.getDefaultReceiptReportId(), options.getDefaultReceiptReportId()); Assert.assertEquals(reference.getRoundingMode(), options.getRoundingMode()); Assert.assertEquals(reference.getRoundToNearest(), options.getRoundToNearest()); - Assert.assertEquals(reference.isTimesheetRequired(), options.isTimesheetRequired()); } } diff --git a/api/src/test/java/org/openmrs/module/billing/ITimesheetServiceTest.java b/api/src/test/java/org/openmrs/module/billing/ITimesheetServiceTest.java deleted file mode 100644 index fed8d6fc..00000000 --- a/api/src/test/java/org/openmrs/module/billing/ITimesheetServiceTest.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing; - -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openmrs.Provider; -import org.openmrs.api.ProviderService; -import org.openmrs.api.context.Context; -import org.openmrs.module.billing.api.CashPointService; -import org.openmrs.module.billing.api.ITimesheetService; -import org.openmrs.module.billing.api.model.Timesheet; -import org.openmrs.module.billing.base.entity.IEntityDataServiceTest; - -public class ITimesheetServiceTest extends IEntityDataServiceTest { - - private ProviderService providerService; - - private CashPointService cashPointService; - - public static final String TIMESHEET_DATASET = TestConstants.BASE_DATASET_DIR + "TimesheetTest.xml"; - - @Override - public void before() throws Exception { - super.before(); - - providerService = Context.getProviderService(); - cashPointService = Context.getService(CashPointService.class); - - executeDataSet(TestConstants.CORE_DATASET); - executeDataSet(ICashPointServiceTest.CASH_POINT_DATASET); - executeDataSet(TIMESHEET_DATASET); - } - - @Override - public Timesheet createEntity(boolean valid) { - Timesheet timesheet = new Timesheet(); - - if (valid) { - timesheet.setCashier(providerService.getProvider(0)); - timesheet.setCashPoint(cashPointService.getCashPoint(0)); - } - - // Holy crap, date stuff really sucks in Java... there must be a more sane library out there? - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, -1); - cal.set(Calendar.HOUR, 9); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - - timesheet.setClockIn(cal.getTime()); - - cal.add(Calendar.HOUR, 8); - timesheet.setClockOut(cal.getTime()); - - return timesheet; - } - - @Override - protected int getTestEntityCount() { - return 8; - } - - @Override - protected void updateEntityFields(Timesheet entity) { - entity.setCashier(providerService.getProvider(1)); - entity.setCashPoint(cashPointService.getCashPoint(1)); - - Calendar cal = Calendar.getInstance(); - - cal.setTime(entity.getClockIn()); - cal.add(Calendar.DAY_OF_MONTH, -10); - entity.setClockIn(cal.getTime()); - - if (entity.getClockOut() == null) { - cal.setTime(entity.getClockIn()); - cal.add(Calendar.HOUR, 8); - } else { - cal.setTime(entity.getClockOut()); - } - - cal.add(Calendar.DAY_OF_MONTH, -10); - entity.setClockOut(cal.getTime()); - } - - @Override - protected void assertEntity(Timesheet expected, Timesheet actual) { - super.assertEntity(expected, actual); - - Assert.assertNotNull(expected.getCashier()); - Assert.assertNotNull(actual.getCashier()); - Assert.assertEquals(expected.getCashier().getId(), actual.getCashier().getId()); - Assert.assertNotNull(expected.getCashPoint()); - Assert.assertNotNull(actual.getCashPoint()); - Assert.assertEquals(expected.getCashPoint().getId(), actual.getCashPoint().getId()); - - Assert.assertEquals(expected.getClockIn(), actual.getClockIn()); - Assert.assertEquals(expected.getClockOut(), actual.getClockOut()); - } - - /** - * @verifies return the current timesheet for the cashier - * @see ITimesheetService#getCurrentTimesheet(org.openmrs.Provider) - */ - @Test - public void getCurrentTimesheet_shouldReturnTheCurrentTimesheetForTheCashier() { - Timesheet timesheet = createEntity(true); - timesheet.setClockOut(null); - - timesheet = service.save(timesheet); - Context.flushSession(); - - Timesheet current = service.getCurrentTimesheet(timesheet.getCashier()); - - Assert.assertNotNull(current); - assertEntity(timesheet, current); - } - - /** - * @verifies return null if the cashier has no timesheets - * @see ITimesheetService#getCurrentTimesheet(org.openmrs.Provider) - */ - @Test - public void getCurrentTimesheet_shouldReturnNullIfTheCashierHasNoTimesheets() { - Provider cashier = providerService.getProvider(2); - Assert.assertNotNull(cashier); - - Timesheet timesheet = service.getCurrentTimesheet(cashier); - Assert.assertNull(timesheet); - } - - /** - * @verifies return the most recent timesheet if the cashier is clocked into multiple timesheets - * @see ITimesheetService#getCurrentTimesheet(org.openmrs.Provider) - */ - @Test - public void getCurrentTimesheet_shouldReturnTheMostRecentTimesheetIfTheCashierIsClockedIntoMultipleTimesheets() { - Provider cashier = providerService.getProvider(0); - Timesheet original = service.getCurrentTimesheet(cashier); - - Assert.assertNotNull(original); - - Timesheet timesheet = createEntity(true); - timesheet.setCashier(cashier); - timesheet.setClockOut(null); - - service.save(timesheet); - Context.flushSession(); - - Timesheet current = service.getCurrentTimesheet(cashier); - Assert.assertNotNull(current); - Assert.assertNotEquals(original.getId(), current.getId()); - } - - /** - * @verifies return null if the timesheet is clocked out - * @see ITimesheetService#getCurrentTimesheet(org.openmrs.Provider) - */ - @Test - public void getCurrentTimesheet_shouldReturnNullIfTheTimesheetIsClockedOut() { - Provider cashier = providerService.getProvider(1); - Assert.assertNotNull(cashier); - - Timesheet timesheet = service.getCurrentTimesheet(cashier); - Assert.assertNull(timesheet); - } - - /** - * @verifies return empty list if there are no timesheets for date - * @see ITimesheetService#getTimesheetsByDate(org.openmrs.Provider, java.util.Date) - */ - @Test - public void getTimesheetsByDate_shouldReturnEmptyListIfThereAreNoTimesheetsForDate() { - Provider cashier = providerService.getProvider(0); - List results = service.getTimesheetsByDate(cashier, - new GregorianCalendar(2011, Calendar.JANUARY, 1).getTime()); - - Assert.assertNotNull(results); - Assert.assertEquals(0, results.size()); - } - - /** - * @verifies return timesheets that start and end on date - * @see ITimesheetService#getTimesheetsByDate(org.openmrs.Provider, java.util.Date) - */ - @Test - public void getTimesheetsByDate_shouldReturnTimesheetsThatStartAndEndOnDate() { - Provider cashier = providerService.getProvider(0); - List results = service.getTimesheetsByDate(cashier, - new GregorianCalendar(2011, Calendar.FEBRUARY, 10).getTime()); - - Assert.assertNotNull(results); - Assert.assertEquals(1, results.size()); - Assert.assertEquals(3, (int) results.get(0).getId()); - } - - /** - * @verifies return timesheets that start on date and end on different date - * @see ITimesheetService#getTimesheetsByDate(org.openmrs.Provider, java.util.Date) - */ - @Test - public void getTimesheetsByDate_shouldReturnTimesheetsThatStartOnDateAndEndOnDifferentDate() { - Provider cashier = providerService.getProvider(0); - List results = service.getTimesheetsByDate(cashier, - new GregorianCalendar(2011, Calendar.FEBRUARY, 11).getTime()); - - Assert.assertNotNull(results); - Assert.assertEquals(1, results.size()); - Assert.assertEquals(4, (int) results.get(0).getId()); - } - - /** - * @verifies return timesheet that start on different date and end on date - * @see ITimesheetService#getTimesheetsByDate(org.openmrs.Provider, java.util.Date) - */ - @Test - public void getTimesheetsByDate_shouldReturnTimesheetThatStartOnDifferentDateAndEndOnDate() { - Provider cashier = providerService.getProvider(0); - List results = service.getTimesheetsByDate(cashier, - new GregorianCalendar(2011, Calendar.FEBRUARY, 14).getTime()); - - Assert.assertNotNull(results); - Assert.assertEquals(1, results.size()); - Assert.assertEquals(5, (int) results.get(0).getId()); - } - - /** - * @verifies return timesheets that start before date but end after date - * @see ITimesheetService#getTimesheetsByDate(org.openmrs.Provider, java.util.Date) - */ - @Test - public void getTimesheetsByDate_shouldReturnTimesheetsThatStartBeforeDateButEndAfterDate() { - Provider cashier = providerService.getProvider(0); - List results = service.getTimesheetsByDate(cashier, - new GregorianCalendar(2011, Calendar.FEBRUARY, 16).getTime()); - - Assert.assertNotNull(results); - Assert.assertEquals(1, results.size()); - Assert.assertEquals(6, (int) results.get(0).getId()); - } - - /** - * @verifies return timesheets that start before date and have not ended - * @see ITimesheetService#getTimesheetsByDate(org.openmrs.Provider, java.util.Date) - */ - @Test - public void getTimesheetsByDate_shouldReturnTimesheetsThatStartBeforeDateAndHaveNotEnded() { - Provider cashier = providerService.getProvider(0); - List results = service.getTimesheetsByDate(cashier, - new GregorianCalendar(2011, Calendar.FEBRUARY, 20).getTime()); - - Assert.assertNotNull(results); - Assert.assertEquals(1, results.size()); - Assert.assertEquals(7, (int) results.get(0).getId()); - } -} diff --git a/api/src/test/java/org/openmrs/module/billing/impl/CashierOptionsServiceGpImplTest.java b/api/src/test/java/org/openmrs/module/billing/impl/CashierOptionsServiceGpImplTest.java index 11cf20a1..45f6baee 100644 --- a/api/src/test/java/org/openmrs/module/billing/impl/CashierOptionsServiceGpImplTest.java +++ b/api/src/test/java/org/openmrs/module/billing/impl/CashierOptionsServiceGpImplTest.java @@ -22,7 +22,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; public class CashierOptionsServiceGpImplTest extends BaseModuleContextSensitiveTest { @@ -36,78 +35,6 @@ public void setup() { adminService = Context.getAdministrationService(); } - /** - * @see org.openmrs.module.billing.api.impl.CashierOptionsServiceGpImpl#getOptions() - */ - @Test - public void getOptions_shouldReturnCashierOptionsWithDefaults() { - CashierOptions options = service.getOptions(); - assertNotNull(options); - assertFalse(options.isTimesheetRequired()); - assertEquals(CashierOptions.RoundingMode.MID, options.getRoundingMode()); - assertEquals(0, options.getRoundToNearest()); - } - - /** - * @see org.openmrs.module.billing.api.impl.CashierOptionsServiceGpImpl#getOptions() - */ - @Test - public void getOptions_shouldLoadDefaultReceiptReportIdFromGlobalProperty() { - adminService.setGlobalProperty(ModuleSettings.RECEIPT_REPORT_ID_PROPERTY, "123"); - - CashierOptions options = service.getOptions(); - assertNotNull(options); - assertEquals(123, options.getDefaultReceiptReportId()); - } - - /** - * @see org.openmrs.module.billing.api.impl.CashierOptionsServiceGpImpl#getOptions() - */ - @Test - public void getOptions_shouldHandleInvalidReceiptReportId() { - adminService.setGlobalProperty(ModuleSettings.RECEIPT_REPORT_ID_PROPERTY, "invalid"); - - CashierOptions options = service.getOptions(); - assertNotNull(options); - assertEquals(0, options.getDefaultReceiptReportId()); - } - - /** - * @see org.openmrs.module.billing.api.impl.CashierOptionsServiceGpImpl#getOptions() - */ - @Test - public void getOptions_shouldLoadTimesheetRequiredFromGlobalProperty() { - adminService.setGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY, "true"); - - CashierOptions options = service.getOptions(); - assertNotNull(options); - assertTrue(options.isTimesheetRequired()); - } - - /** - * @see org.openmrs.module.billing.api.impl.CashierOptionsServiceGpImpl#getOptions() - */ - @Test - public void getOptions_shouldDefaultToFalseIfTimesheetRequiredIsNotSpecified() { - adminService.setGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY, ""); - - CashierOptions options = service.getOptions(); - assertNotNull(options); - assertFalse(options.isTimesheetRequired()); - } - - /** - * @see org.openmrs.module.billing.api.impl.CashierOptionsServiceGpImpl#getOptions() - */ - @Test - public void getOptions_shouldHandleInvalidTimesheetRequiredValue() { - adminService.setGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY, "invalid"); - - CashierOptions options = service.getOptions(); - assertNotNull(options); - assertFalse(options.isTimesheetRequired()); - } - /** * @see org.openmrs.module.billing.api.impl.CashierOptionsServiceGpImpl#getOptions() */ @@ -139,12 +66,10 @@ public void getOptions_shouldNotThrowExceptionIfNumericOptionsAreNull() { @Test public void getOptions_shouldHandleMultiplePropertiesSet() { adminService.setGlobalProperty(ModuleSettings.RECEIPT_REPORT_ID_PROPERTY, "456"); - adminService.setGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY, "true"); CashierOptions options = service.getOptions(); assertNotNull(options); assertEquals(456, options.getDefaultReceiptReportId()); - assertTrue(options.isTimesheetRequired()); } /** @@ -153,7 +78,6 @@ public void getOptions_shouldHandleMultiplePropertiesSet() { @Test public void getOptions_shouldLoadCashierOptionsFromTheDatabase() { adminService.setGlobalProperty(ModuleSettings.RECEIPT_REPORT_ID_PROPERTY, "1"); - adminService.setGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY, "true"); CashierOptions options = service.getOptions(); @@ -161,7 +85,6 @@ public void getOptions_shouldLoadCashierOptionsFromTheDatabase() { assertEquals(1, options.getDefaultReceiptReportId()); assertEquals(CashierOptions.RoundingMode.MID, options.getRoundingMode()); assertEquals(0, options.getRoundToNearest()); - assertTrue(options.isTimesheetRequired()); } /** @@ -172,7 +95,6 @@ public void getOptions_shouldHandleNullGlobalProperties() { adminService.setGlobalProperty(ModuleSettings.RECEIPT_REPORT_ID_PROPERTY, null); adminService.setGlobalProperty(ModuleSettings.ROUNDING_MODE_PROPERTY, null); adminService.setGlobalProperty(ModuleSettings.ROUND_TO_NEAREST_PROPERTY, null); - adminService.setGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY, null); CashierOptions options = service.getOptions(); @@ -180,6 +102,5 @@ public void getOptions_shouldHandleNullGlobalProperties() { assertEquals(0, options.getDefaultReceiptReportId()); assertEquals(CashierOptions.RoundingMode.MID, options.getRoundingMode()); assertEquals(0, options.getRoundToNearest()); - assertFalse(options.isTimesheetRequired()); } } diff --git a/api/src/test/resources/org/openmrs/module/billing/api/include/TimesheetTest.xml b/api/src/test/resources/org/openmrs/module/billing/api/include/TimesheetTest.xml deleted file mode 100644 index 8e780e18..00000000 --- a/api/src/test/resources/org/openmrs/module/billing/api/include/TimesheetTest.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - diff --git a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/BillAddEditController.java b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/BillAddEditController.java index 6f2a130f..943d6919 100644 --- a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/BillAddEditController.java +++ b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/BillAddEditController.java @@ -26,9 +26,7 @@ import org.openmrs.module.billing.api.base.util.UrlUtil; import org.openmrs.module.billing.api.model.Bill; import org.openmrs.module.billing.api.model.CashierOptions; -import org.openmrs.module.billing.api.model.Timesheet; import org.openmrs.module.billing.api.util.PrivilegeConstants; -import org.openmrs.module.billing.api.util.TimesheetUtil; import org.openmrs.module.billing.web.CashierWebConstants; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -52,21 +50,6 @@ public BillAddEditController() { @RequestMapping(method = RequestMethod.GET) public String bill(ModelMap model, @RequestParam(value = "billUuid", required = false) String billUuid, @RequestParam(value = "patientUuid", required = false) String patientUuid, HttpServletRequest request) { - Timesheet timesheet; - try { - timesheet = TimesheetUtil.getCurrentTimesheet(); - } - catch (Exception e) { - log.error("Error retrieving provider for current user. ", e); - return "redirect:/login.htm"; - - } - - if (timesheet == null && TimesheetUtil.isTimesheetRequired()) { - return buildRedirectUrl(request); - } - - model.addAttribute("timesheet", timesheet); model.addAttribute("user", Context.getAuthenticatedUser()); model.addAttribute("url", buildUrlModelAttribute(request)); @@ -93,7 +76,6 @@ public String bill(ModelMap model, @RequestParam(value = "billUuid", required = } else { addPatientAttributes(model, patientUuid); model.addAttribute("showPrint", true); - model.addAttribute("cashPoint", timesheet != null ? timesheet.getCashPoint() : null); } return CashierWebConstants.BILL_PAGE; diff --git a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/CashierController.java b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/CashierController.java deleted file mode 100644 index 6ad179db..00000000 --- a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/CashierController.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.web.legacyweb.controller; - -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.openmrs.Provider; -import org.openmrs.api.APIException; -import org.openmrs.api.ProviderService; -import org.openmrs.api.context.Context; -import org.openmrs.module.billing.api.CashPointService; -import org.openmrs.module.billing.api.ITimesheetService; -import org.openmrs.module.billing.api.base.ProviderUtil; -import org.openmrs.module.billing.api.model.CashPoint; -import org.openmrs.module.billing.api.model.Timesheet; -import org.openmrs.module.billing.web.CashierWebConstants; -import org.openmrs.module.billing.web.propertyeditor.CashPointPropertyEditor; -import org.openmrs.module.billing.web.propertyeditor.ProviderPropertyEditor; -import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.Errors; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.context.request.WebRequest; - -import javax.servlet.http.HttpServletRequest; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -/** - * Controller to manahe the Cashier page. - */ -@Controller -@RequestMapping(value = CashierWebConstants.CASHIER_PAGE) -@Slf4j -public class CashierController { - - public CashierController() { - - } - - @InitBinder - public void initBinder(WebDataBinder binder) { - binder.registerCustomEditor(CashPoint.class, new CashPointPropertyEditor()); - binder.registerCustomEditor(Provider.class, new ProviderPropertyEditor()); - - SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm"); - dateFormat.setLenient(false); - - binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); - } - - @RequestMapping(method = RequestMethod.GET) - public void render(@RequestParam(value = "providerId", required = false) Integer providerId, - @RequestParam(value = "returnUrl", required = false) String returnUrl, ModelMap modelMap) { - Provider provider; - ProviderService providerService = Context.getProviderService(); - if (providerId != null) { - provider = providerService.getProvider(providerId); - } else { - provider = ProviderUtil.getCurrentProvider(providerService); - } - - if (provider == null) { - throw new APIException("ERROR: Could not locate the provider. Please make sure the user is listed as provider " - + "(Admin -> Manage providers)"); - } - - String returnTo = returnUrl; - if (StringUtils.isEmpty(returnTo)) { - HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - returnTo = req.getHeader("Referer"); - - if (!StringUtils.isEmpty(returnTo)) { - try { - URL url = new URL(returnTo); - - returnTo = url.getPath(); - if (StringUtils.startsWith(returnTo, req.getContextPath())) { - - returnTo = returnTo.substring(req.getContextPath().length()); - } - } - catch (MalformedURLException e) { - log.warn("Could not parse referrer url '{}'", returnTo); - returnTo = ""; - } - } - } - - // Load the current timesheet information - Timesheet timesheet = Context.getService(ITimesheetService.class).getCurrentTimesheet(provider); - if (timesheet == null) { - timesheet = new Timesheet(); - timesheet.setCashier(provider); - timesheet.setClockIn(new Date()); - } - - addRenderAttributes(modelMap, timesheet, provider, returnTo); - } - - @RequestMapping(method = RequestMethod.POST) - public String post(Timesheet timesheet, Errors errors, WebRequest request, ModelMap modelMap) { - String returnUrl = request.getParameter("returnUrl"); - - new TimesheetEntryValidator().validate(timesheet, errors); - if (errors.hasErrors()) { - addRenderAttributes(modelMap, timesheet, timesheet.getCashier(), returnUrl); - - return null; - } - - Context.getService(ITimesheetService.class).save(timesheet); - - if (StringUtils.isEmpty(returnUrl)) { - returnUrl = "redirect:"; - } else { - returnUrl = "redirect:" + returnUrl; - } - return returnUrl; - } - - @ModelAttribute("cashPoints") - public List getCashPoints() { - return Context.getService(CashPointService.class).getAllCashPoints(false); - } - - private void addRenderAttributes(ModelMap modelMap, Timesheet timesheet, Provider cashier, String returnUrl) { - modelMap.addAttribute("returnUrl", returnUrl); - modelMap.addAttribute("cashier", cashier); - modelMap.addAttribute("timesheet", timesheet); - } -} diff --git a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/CashierModuleSettingsController.java b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/CashierModuleSettingsController.java index 016d543a..afc48582 100644 --- a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/CashierModuleSettingsController.java +++ b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/CashierModuleSettingsController.java @@ -11,8 +11,6 @@ import org.apache.commons.lang3.StringUtils; import org.openmrs.api.context.Context; -import org.openmrs.module.billing.api.model.Timesheet; -import org.openmrs.module.billing.api.util.TimesheetUtil; import org.openmrs.module.billing.web.CashierWebConstants; import org.openmrs.module.webservices.rest.SimpleObject; import org.springframework.stereotype.Controller; @@ -29,7 +27,6 @@ public class CashierModuleSettingsController { public CashierModuleSettingsController() { - } @ResponseBody @@ -37,31 +34,8 @@ public CashierModuleSettingsController() { public SimpleObject get(@RequestParam("setting") String setting) { SimpleObject results = new SimpleObject(); if (StringUtils.isNotEmpty(setting)) { - if (StringUtils.equalsIgnoreCase(setting, "timesheet")) { - results.put("isTimeSheetRequired", TimesheetUtil.isTimesheetRequired()); - Timesheet currentTimesheet = getCurrentTimesheet(); - if (currentTimesheet != null) { - SimpleObject cashPoint = new SimpleObject(); - cashPoint.put("name", currentTimesheet.getCashPoint().getName()); - cashPoint.put("uuid", currentTimesheet.getCashPoint().getUuid()); - results.put("cashPoint", cashPoint); - results.put("cashier", currentTimesheet.getCashier().getName()); - } - } else { - results.put("results", Context.getAdministrationService().getGlobalProperty(setting)); - } + results.put("results", Context.getAdministrationService().getGlobalProperty(setting)); } return results; } - - private Timesheet getCurrentTimesheet() { - Timesheet timesheet; - try { - timesheet = TimesheetUtil.getCurrentTimesheet(); - } - catch (Exception e) { - timesheet = null; - } - return timesheet; - } } diff --git a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/TimesheetEntryValidator.java b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/TimesheetEntryValidator.java deleted file mode 100644 index 3881cb27..00000000 --- a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/TimesheetEntryValidator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.web.legacyweb.controller; - -import java.util.Date; - -import org.openmrs.module.billing.api.model.Timesheet; -import org.springframework.validation.Errors; -import org.springframework.validation.Validator; - -/** - * Validates the Timesheet entry. Implents {@link Validator} - */ -public class TimesheetEntryValidator implements Validator { - - @Override - public boolean supports(Class clazz) { - return Timesheet.class.isAssignableFrom(clazz); - } - - @Override - public void validate(Object target, Errors errors) { - Timesheet timesheet = (Timesheet) target; - - if (timesheet.getClockIn() == null) { - errors.rejectValue("clockIn", "openhmis.cashier.timesheet.entry.error.clockIn.empty"); - } else if (timesheet.getClockIn().after(new Date())) { - errors.rejectValue("clockIn", "openhmis.cashier.timesheet.entry.error.clockIn.future"); - } - - if (timesheet.getClockOut() != null && timesheet.getClockOut().after(new Date())) { - errors.rejectValue("clockOut", "openhmis.cashier.timesheet.entry.error.clockOut.future"); - } - - if (timesheet.getClockOut() != null && timesheet.getClockOut().before(timesheet.getClockIn())) { - errors.rejectValue("clockOut", "openhmis.cashier.timesheet.entry.error.clockOut.before.clockIn"); - } - } -} diff --git a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/filter/CashierLogoutFilter.java b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/filter/CashierLogoutFilter.java deleted file mode 100644 index 393cac20..00000000 --- a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/filter/CashierLogoutFilter.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.web.legacyweb.filter; - -import java.io.IOException; -import java.util.Date; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -import lombok.extern.slf4j.Slf4j; -import org.openmrs.Provider; -import org.openmrs.User; -import org.openmrs.api.context.Context; -import org.openmrs.module.billing.api.ITimesheetService; -import org.openmrs.module.billing.api.base.ProviderUtil; -import org.openmrs.module.billing.api.model.Timesheet; -import org.openmrs.module.billing.api.util.PrivilegeConstants; -import org.springframework.stereotype.Component; - -/** - * Performs the neccessary filters when a cashier logs out. Implements {@link Filter} - */ -@Component -@Slf4j -public class CashierLogoutFilter implements Filter { - - private static final String PROVIDER_ERROR_LOG_MESSAGE = "Could not locate the Provider"; - - private static final String TIMESHEET_ERROR_LOG_MESSAGE = "Could not locate Timesheet"; - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - log.debug("doCashierLogoutFilter"); - clockOutCashier(); - chain.doFilter(request, response); - } - - @Override - public void init(FilterConfig filterConfig) { - - } - - @Override - public void destroy() { - - } - - private void clockOutCashier() { - if (!userIsCashier()) { - return; - } - - Provider provider = ProviderUtil.getCurrentProvider(Context.getProviderService()); - if (provider == null) { - log.error(PROVIDER_ERROR_LOG_MESSAGE); - return; - } - - ITimesheetService timesheetService = Context.getService(ITimesheetService.class); - Timesheet timesheet = timesheetService.getCurrentTimesheet(provider); - if (timesheet == null) { - log.error(TIMESHEET_ERROR_LOG_MESSAGE); - return; - } - - if (cashierIsClockedIn(timesheet)) { - timesheet.setClockOut(new Date()); - timesheetService.save(timesheet); - } - } - - private boolean userIsCashier() { - boolean result = false; - User authenticatedUser = Context.getAuthenticatedUser(); - if (authenticatedUser != null) { - result = authenticatedUser.hasPrivilege(PrivilegeConstants.MANAGE_TIMESHEETS); - } - - return result; - } - - private boolean cashierIsClockedIn(Timesheet timesheet) { - return timesheet != null && timesheet.getClockIn() != null; - } - -} diff --git a/omod/src/main/java/org/openmrs/module/billing/web/rest/resource/BillResource.java b/omod/src/main/java/org/openmrs/module/billing/web/rest/resource/BillResource.java index 9f282c16..c9873f39 100644 --- a/omod/src/main/java/org/openmrs/module/billing/web/rest/resource/BillResource.java +++ b/omod/src/main/java/org/openmrs/module/billing/web/rest/resource/BillResource.java @@ -18,19 +18,15 @@ import org.apache.commons.lang3.StringUtils; import org.openmrs.Provider; -import org.openmrs.api.AdministrationService; import org.openmrs.api.context.Context; import org.openmrs.module.billing.api.base.ProviderUtil; -import org.openmrs.module.billing.ModuleSettings; import org.openmrs.module.billing.api.BillService; -import org.openmrs.module.billing.api.ITimesheetService; import org.openmrs.module.billing.api.base.PagingInfo; import org.openmrs.module.billing.api.model.Bill; import org.openmrs.module.billing.api.model.BillLineItem; import org.openmrs.module.billing.api.model.BillStatus; import org.openmrs.module.billing.api.model.CashPoint; import org.openmrs.module.billing.api.model.Payment; -import org.openmrs.module.billing.api.model.Timesheet; import org.openmrs.module.billing.api.search.BillSearch; import org.openmrs.module.billing.api.util.RoundingUtil; import org.openmrs.module.billing.web.base.resource.BaseRestDataResource; @@ -216,33 +212,10 @@ private Provider getCurrentCashier() { } private void loadBillCashPoint(Bill bill) { - ITimesheetService service = Context.getService(ITimesheetService.class); - Timesheet timesheet = service.getCurrentTimesheet(bill.getCashier()); - if (timesheet == null) { - AdministrationService adminService = Context.getAdministrationService(); - boolean timesheetRequired; - try { - timesheetRequired = Boolean - .parseBoolean(adminService.getGlobalProperty(ModuleSettings.TIMESHEET_REQUIRED_PROPERTY)); - } - catch (Exception e) { - timesheetRequired = false; - } - - if (timesheetRequired) { - throw new RestClientException("A current timesheet does not exist for cashier " + bill.getCashier()); - } else if (bill.getBillAdjusted() != null) { - // If this is an adjusting bill, copy cash point from billAdjusted - bill.setCashPoint(bill.getBillAdjusted().getCashPoint()); - } else { - throw new RestClientException("Cash point cannot be null!"); - } + if (bill.getBillAdjusted() != null) { + bill.setCashPoint(bill.getBillAdjusted().getCashPoint()); } else { - CashPoint cashPoint = timesheet.getCashPoint(); - if (cashPoint == null) { - throw new RestClientException("No cash points defined for the current timesheet!"); - } - bill.setCashPoint(cashPoint); + throw new RestClientException("Cash point cannot be null!"); } } diff --git a/omod/src/main/java/org/openmrs/module/billing/web/rest/resource/TimesheetResource.java b/omod/src/main/java/org/openmrs/module/billing/web/rest/resource/TimesheetResource.java deleted file mode 100644 index 585c0916..00000000 --- a/omod/src/main/java/org/openmrs/module/billing/web/rest/resource/TimesheetResource.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.web.rest.resource; - -import org.openmrs.module.billing.web.base.resource.BaseRestDataResource; -import org.openmrs.module.billing.web.rest.controller.base.CashierResourceController; -import org.openmrs.module.billing.api.ITimesheetService; -import org.openmrs.module.billing.api.base.entity.IEntityDataService; -import org.openmrs.module.billing.api.model.Timesheet; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.representation.RefRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.util.LocaleUtility; - -import java.text.DateFormat; - -/** - * REST resource representing a {@link Timesheet}. - */ -@Resource(name = RestConstants.VERSION_2 + CashierResourceController.BILLING_NAMESPACE - + "/timesheet", supportedClass = Timesheet.class, supportedOpenmrsVersions = { "2.0 - 2.*" }) -public class TimesheetResource extends BaseRestDataResource { - - @Override - public Timesheet newDelegate() { - return new Timesheet(); - } - - @Override - public Class> getServiceClass() { - return ITimesheetService.class; - } - - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); - description.addProperty("cashier", Representation.REF); - description.addProperty("cashPoint", Representation.REF); - description.addProperty("clockIn"); - description.addProperty("clockOut"); - if (rep instanceof RefRepresentation) { - description.addProperty("id"); - description.addProperty("uuid"); - } - - return description; - } - - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = super.getCreatableProperties(); - description.addProperty("cashier"); - description.addProperty("cashpoint"); - return description; - } - - public String getDisplayString(Timesheet instance) { - DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT, - LocaleUtility.getDefaultLocale()); - return dateFormat.format(instance.getClockIn()) + " to " - + (instance.getClockOut() != null ? dateFormat.format(instance.getClockOut()) : " open"); - } -} diff --git a/omod/src/main/java/org/openmrs/module/billing/web/rest/search/TimesheetSearchHandler.java b/omod/src/main/java/org/openmrs/module/billing/web/rest/search/TimesheetSearchHandler.java deleted file mode 100644 index 1bac382d..00000000 --- a/omod/src/main/java/org/openmrs/module/billing/web/rest/search/TimesheetSearchHandler.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.billing.web.rest.search; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.openmrs.Provider; -import org.openmrs.api.APIException; -import org.openmrs.api.context.Context; -import org.openmrs.module.billing.api.ITimesheetService; -import org.openmrs.module.billing.api.base.ProviderUtil; -import org.openmrs.module.billing.api.model.Timesheet; -import org.openmrs.module.billing.web.base.resource.AlreadyPagedWithLength; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.api.SearchConfig; -import org.openmrs.module.webservices.rest.web.resource.api.SearchHandler; -import org.openmrs.module.webservices.rest.web.resource.api.SearchQuery; -import org.springframework.stereotype.Component; - -/** - * Search handler for {@link Timesheet}s. - */ -@Component -public class TimesheetSearchHandler implements SearchHandler { - - private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_2 + "/billing/timesheet", - Collections.singletonList("*"), - new SearchQuery.Builder("Find a timesheet by date").withRequiredParameters("date").build()); - - @Override - public PageableResult search(RequestContext context) { - ITimesheetService service = Context.getService(ITimesheetService.class); - Provider provider = ProviderUtil.getCurrentProvider(); - Date date; - if (provider == null) { - return null; - } - try { - date = new SimpleDateFormat("MM/dd/yyyy").parse(context.getParameter("date")); - } - catch (ParseException e) { - throw new APIException("Invalid date parameter: " + context.getParameter("date")); - } - List timesheets = service.getTimesheetsByDate(provider, date); - return new AlreadyPagedWithLength<>(context, timesheets, false, timesheets.size()); - } - - @Override - public SearchConfig getSearchConfig() { - return searchConfig; - } -} diff --git a/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml index 0c667ea4..0a04d911 100644 --- a/omod/src/main/resources/config.xml +++ b/omod/src/main/resources/config.xml @@ -50,17 +50,6 @@ ID of the default Jasper report to use for generating a receipt on the Bill page - - ${project.parent.artifactId}.defaultShiftReportId - ID of the Jasper Cashier Shift report. - - - - ${project.parent.artifactId}.timesheetRequired - Whether or not to require an active timesheet when creating a new bill. True or false. - - - ${project.parent.artifactId}.roundingMode How to do rounding to bill totals (FLOOR, MID, CEILING) @@ -128,20 +117,6 @@ - - ${project.parent.artifactId}.reports.shiftSummary - - The ID of the Shift Summary report. - - - - - ${project.parent.artifactId}.reports.dailyShiftSummary - - The ID of the Daily Shift Summary report. - - - ${project.parent.artifactId}.reports.paymentsByPaymentMode @@ -228,22 +203,6 @@ Able to purge cashier module metadata - - - View Cashier Timesheets - Able to view timesheets - - - - Manage Cashier Timesheets - Able to add/edit/delete timesheets - - - - Purge Cashier Timesheets - Able to purge timesheets - - App: View Cashier App @@ -265,11 +224,6 @@ Able to adjust cashier bills - - Task: Cashier Timesheets - Able to access timesheets page - - Task: Manage Cashier Module Able to access the management page @@ -324,3 +278,4 @@ + diff --git a/omod/src/main/resources/liquibase.xml b/omod/src/main/resources/liquibase.xml index 56734afd..539dee52 100644 --- a/omod/src/main/resources/liquibase.xml +++ b/omod/src/main/resources/liquibase.xml @@ -1120,4 +1120,13 @@ referencedTableName="provider" referencedColumnNames="provider_id" onDelete="SET NULL" onUpdate="CASCADE"/> + + + + + + Remove cashier_timesheet table - timesheet feature removed + + + From a867df8271c44614e14620077c83d5f29e54b478 Mon Sep 17 00:00:00 2001 From: solomonfortune Date: Wed, 20 May 2026 21:28:41 +0300 Subject: [PATCH 2/4] Fix syntax error in PrivilegeConstants.java --- .../openmrs/module/billing/api/util/PrivilegeConstants.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java b/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java index d3891dfd..d4673773 100644 --- a/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java +++ b/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java @@ -73,7 +73,11 @@ public class PrivilegeConstants { public static final String TASK_VIEW_CASHIER_REPORTS = "Task: View Cashier Reports"; - public static final String[] PRIVILEGE_NAMES = new String[] { MANAGE_BILLS, ADJUST_BILLS, VIEW_BILLS, PURGE_BILLS, + public static final String[] PRIVILEGE_NAMES = new String[] { MANAGE_BILLS, ADJUST_BILLS, VIEW_BILLS, PURGE_BILLS, DELETE_BILLS, REFUND_MONEY, REPRINT_RECEIPT, MANAGE_BILL_DISCOUNTS, APPROVE_BILL_DISCOUNTS, + VIEW_BILL_DISCOUNTS, REQUEST_REFUNDS, APPROVE_REFUNDS, COMPLETE_REFUNDS, VIEW_REFUNDS, MANAGE_METADATA, + VIEW_METADATA, PURGE_METADATA, APP_VIEW_CASHIER_APP, APP_ACCESS_CASHIER_TASKS_PAGE, + TASK_CREATE_NEW_BILL_PAGE, TASK_ADJUST_CASHIER_BILL, TASK_MANAGE_CASHIER_MODULE_PAGE, + TASK_MANAGE_CASHIER_METADATA, TASK_VIEW_CASHIER_REPORTS }; /** From d142989be846e4e2ee84d0de0caf1b89aed9573f Mon Sep 17 00:00:00 2001 From: solomonfortune Date: Sat, 23 May 2026 13:37:17 +0300 Subject: [PATCH 3/4] Fix Sonar issues: remove unused methods and make PRIVILEGE_NAMES protected --- .vscode/settings.json | 3 +++ .../module/billing/ModuleSettings.java | 9 --------- .../billing/api/util/PrivilegeConstants.java | 12 +++++------- .../controller/BillAddEditController.java | 19 ------------------- 4 files changed, 8 insertions(+), 35 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..7b016a89 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java b/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java index 53cc837e..fce3839c 100644 --- a/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java +++ b/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java @@ -167,15 +167,6 @@ public static void saveSettings(CashierSettings cashierSettings) { } // TODO: These functions should be moved to a commons-level base class for module settings classes - private static Boolean getBoolProperty(String propertyName) { - Boolean result = null; - String property = administrationService.getGlobalProperty(propertyName); - if (!StringUtils.isEmpty(property)) { - result = Boolean.parseBoolean(property); - } - - return result; - } private static void getBoolProperty(String propertyName, Action1 action) { getBoolProperty(propertyName, null, action); diff --git a/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java b/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java index d4673773..9f4cc70c 100644 --- a/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java +++ b/api/src/main/java/org/openmrs/module/billing/api/util/PrivilegeConstants.java @@ -73,12 +73,11 @@ public class PrivilegeConstants { public static final String TASK_VIEW_CASHIER_REPORTS = "Task: View Cashier Reports"; - public static final String[] PRIVILEGE_NAMES = new String[] { MANAGE_BILLS, ADJUST_BILLS, VIEW_BILLS, PURGE_BILLS, DELETE_BILLS, REFUND_MONEY, REPRINT_RECEIPT, MANAGE_BILL_DISCOUNTS, APPROVE_BILL_DISCOUNTS, - VIEW_BILL_DISCOUNTS, REQUEST_REFUNDS, APPROVE_REFUNDS, COMPLETE_REFUNDS, VIEW_REFUNDS, MANAGE_METADATA, - VIEW_METADATA, PURGE_METADATA, APP_VIEW_CASHIER_APP, APP_ACCESS_CASHIER_TASKS_PAGE, - TASK_CREATE_NEW_BILL_PAGE, TASK_ADJUST_CASHIER_BILL, TASK_MANAGE_CASHIER_MODULE_PAGE, - TASK_MANAGE_CASHIER_METADATA, TASK_VIEW_CASHIER_REPORTS }; - + protected static final String[] PRIVILEGE_NAMES = new String[] { MANAGE_BILLS, ADJUST_BILLS, VIEW_BILLS, PURGE_BILLS, + DELETE_BILLS, REFUND_MONEY, REPRINT_RECEIPT, MANAGE_BILL_DISCOUNTS, APPROVE_BILL_DISCOUNTS, VIEW_BILL_DISCOUNTS, + REQUEST_REFUNDS, APPROVE_REFUNDS, COMPLETE_REFUNDS, VIEW_REFUNDS, MANAGE_METADATA, VIEW_METADATA, PURGE_METADATA, + APP_VIEW_CASHIER_APP, APP_ACCESS_CASHIER_TASKS_PAGE, TASK_CREATE_NEW_BILL_PAGE, TASK_ADJUST_CASHIER_BILL, + TASK_MANAGE_CASHIER_MODULE_PAGE, TASK_MANAGE_CASHIER_METADATA, TASK_VIEW_CASHIER_REPORTS }; /** * Gets all the privileges defined by the module. @@ -145,4 +144,3 @@ public static Set getDefaultPrivileges() { } } - diff --git a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/BillAddEditController.java b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/BillAddEditController.java index 943d6919..aa936030 100644 --- a/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/BillAddEditController.java +++ b/omod/src/main/java/org/openmrs/module/billing/web/legacyweb/controller/BillAddEditController.java @@ -33,7 +33,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.util.UriUtils; /** * Controller to manage the Bill page. @@ -161,22 +160,4 @@ private String buildUrlModelAttribute(HttpServletRequest request) { + ((request.getQueryString() != null) ? "?" + request.getQueryString() : ""); } - private String buildRedirectUrl(HttpServletRequest request) { - String redirectUrl = "redirect:" + UrlUtil.formUrl(CashierWebConstants.CASHIER_PAGE); - String returnUrlParam = "?returnUrl=" + UrlUtil.formUrl(CashierWebConstants.BILL_PAGE); - String requestQueryParam = ""; - - if (request.getQueryString() != null) { - requestQueryParam = encodeRequestQuery(request); - } - - return redirectUrl + returnUrlParam + requestQueryParam; - } - - private String encodeRequestQuery(HttpServletRequest request) { - String requestQueryParam; - requestQueryParam = UriUtils.encodeQuery("?" + request.getQueryString(), "UTF-8"); - - return requestQueryParam; - } } From 63ff850203d6cc3daa2a7868742af0aaf2137674 Mon Sep 17 00:00:00 2001 From: solomonfortune Date: Sat, 23 May 2026 20:58:37 +0300 Subject: [PATCH 4/4] Remove unused getBoolProperty overload in ModuleSettings --- .../main/java/org/openmrs/module/billing/ModuleSettings.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java b/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java index fce3839c..db1e4edb 100644 --- a/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java +++ b/api/src/main/java/org/openmrs/module/billing/ModuleSettings.java @@ -168,10 +168,6 @@ public static void saveSettings(CashierSettings cashierSettings) { // TODO: These functions should be moved to a commons-level base class for module settings classes - private static void getBoolProperty(String propertyName, Action1 action) { - getBoolProperty(propertyName, null, action); - } - private static void getBoolProperty(String propertyName, Boolean defaultValue, Action1 action) { String property = administrationService.getGlobalProperty(propertyName); if (!StringUtils.isEmpty(property)) {