use of com.axelor.apps.hr.db.TimesheetLine in project axelor-open-suite by axelor.
the class TimesheetLineController method setTimesheet.
public void setTimesheet(ActionRequest request, ActionResponse response) {
TimesheetLine timesheetLine = request.getContext().asType(TimesheetLine.class);
timesheetLine = Beans.get(TimesheetLineServiceImpl.class).setTimesheet(timesheetLine);
response.setValues(timesheetLine);
}
use of com.axelor.apps.hr.db.TimesheetLine in project axelor-open-suite by axelor.
the class TimesheetTimerHRRepository method updateTimesheetLine.
public void updateTimesheetLine(TSTimer tsTimer) {
TimesheetLine timesheetLine = tsTimer.getTimesheetLine();
timesheetLine.setProject(tsTimer.getProject());
timesheetLine.setProduct(tsTimer.getProduct());
timesheetLine.setHoursDuration(tsTimerService.convertSecondDurationInHours(tsTimer.getDuration()));
timesheetLine.setComments(tsTimer.getComments());
Beans.get(TimesheetLineRepository.class).save(timesheetLine);
}
use of com.axelor.apps.hr.db.TimesheetLine in project axelor-open-suite by axelor.
the class HumanResourceMobileController method insertOrUpdateTSLine.
/*
* This method is used in mobile application.
* It was in TimesheetServiceImpl
* @param request
* @param response
*
* POST /open-suite-webapp/ws/action/com.axelor.apps.hr.mobile.HumanResourceMobileController:insertOrUpdateTSLine
* Content-Type: application/json
*
* URL: com.axelor.apps.hr.mobile.HumanResourceMobileController:insertOrUpdateTSLine
* fields: (id,) project, activity, date, duration, comments
*
* payload:
* { "data": {
* "action": "com.axelor.apps.hr.mobile.HumanResourceMobileController:insertOrUpdateTSLine",
* "id": 1,
* "project": 1,
* "activity": 2,
* "date": "2018-02-22",
* "duration": 10,
* "comments": "no"
* } }
*/
@Transactional
public void insertOrUpdateTSLine(ActionRequest request, ActionResponse response) {
// insert TimesheetLine
try {
Map<String, Object> requestData = request.getData();
User user = AuthUtils.getUser();
Project project = Beans.get(ProjectRepository.class).find(new Long(request.getData().get("project").toString()));
Product product = Beans.get(ProductRepository.class).find(new Long(request.getData().get("activity").toString()));
LocalDate date = LocalDate.parse(request.getData().get("date").toString(), DateTimeFormatter.ISO_DATE);
TimesheetRepository timesheetRepository = Beans.get(TimesheetRepository.class);
TimesheetService timesheetService = Beans.get(TimesheetService.class);
TimesheetLineService timesheetLineService = Beans.get(TimesheetLineService.class);
if (user != null) {
Timesheet timesheet = timesheetRepository.all().filter("self.statusSelect = 1 AND self.user.id = ?1", user.getId()).order("-id").fetchOne();
if (timesheet == null) {
timesheet = timesheetService.createTimesheet(user, date, date);
}
BigDecimal hours = new BigDecimal(request.getData().get("duration").toString());
TimesheetLine line;
Object idO = requestData.get("id");
if (idO != null) {
line = timesheetLineService.updateTimesheetLine(Beans.get(TimesheetLineRepository.class).find(Long.valueOf(idO.toString())), project, product, user, date, timesheet, hours, request.getData().get("comments").toString());
} else {
line = timesheetLineService.createTimesheetLine(project, product, user, date, timesheet, hours, request.getData().get("comments").toString());
}
// convert hours to what is defined in timeLoggingPreferenceSelect
BigDecimal duration = timesheetLineService.computeHoursDuration(timesheet, hours, false);
line.setDuration(duration);
timesheet.addTimesheetLineListItem(line);
timesheetRepository.save(timesheet);
response.setTotal(1);
HashMap<String, Object> data = new HashMap<>();
data.put("id", line.getId());
response.setData(data);
}
} catch (Exception e) {
TraceBackService.trace(e);
}
}
use of com.axelor.apps.hr.db.TimesheetLine in project axelor-open-suite by axelor.
the class InvoicingProjectService method populate.
public List<InvoiceLine> populate(Invoice invoice, InvoicingProject folder) throws AxelorException {
List<SaleOrderLine> saleOrderLineList = new ArrayList<SaleOrderLine>(folder.getSaleOrderLineSet());
List<PurchaseOrderLine> purchaseOrderLineList = new ArrayList<PurchaseOrderLine>(folder.getPurchaseOrderLineSet());
List<TimesheetLine> timesheetLineList = new ArrayList<TimesheetLine>(folder.getLogTimesSet());
List<ExpenseLine> expenseLineList = new ArrayList<ExpenseLine>(folder.getExpenseLineSet());
List<ProjectTask> projectTaskList = new ArrayList<ProjectTask>(folder.getProjectTaskSet());
List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>();
invoiceLineList.addAll(this.createSaleOrderInvoiceLines(invoice, saleOrderLineList, folder.getSaleOrderLineSetPrioritySelect()));
invoiceLineList.addAll(this.createPurchaseOrderInvoiceLines(invoice, purchaseOrderLineList, folder.getPurchaseOrderLineSetPrioritySelect()));
invoiceLineList.addAll(timesheetService.createInvoiceLines(invoice, timesheetLineList, folder.getLogTimesSetPrioritySelect()));
invoiceLineList.addAll(expenseService.createInvoiceLines(invoice, expenseLineList, folder.getExpenseLineSetPrioritySelect()));
invoiceLineList.addAll(projectTaskBusinessProjectService.createInvoiceLines(invoice, projectTaskList, folder.getProjectTaskSetPrioritySelect()));
Collections.sort(invoiceLineList, new InvoiceLineComparator());
for (InvoiceLine invoiceLine : invoiceLineList) {
invoiceLine.setSequence(sequence);
sequence++;
}
return invoiceLineList;
}
use of com.axelor.apps.hr.db.TimesheetLine in project axelor-open-suite by axelor.
the class BatchUpdateTaskService method updateTimesheetLines.
private void updateTimesheetLines(Map<String, Object> contextValues) {
List<Object> updatedTimesheetLineList = new ArrayList<Object>();
Query<TimesheetLine> timesheetLineQuery = timesheetLineRepo.all().filter("((self.projectTask.parentTask.invoicingType = :_invoicingType " + "AND self.projectTask.parentTask.toInvoice = :_teamTaskToInvoice) " + " OR (self.projectTask.parentTask IS NULL " + "AND self.projectTask.invoicingType = :_invoicingType " + "AND self.projectTask.toInvoice = :_projectTaskToInvoice)) " + "AND self.projectTask.project.isBusinessProject = :_isBusinessProject " + "AND self.toInvoice = :_toInvoice").bind("_invoicingType", ProjectTaskRepository.INVOICING_TYPE_TIME_SPENT).bind("_isBusinessProject", true).bind("_projectTaskToInvoice", true).bind("_toInvoice", false).order("id");
int offset = 0;
List<TimesheetLine> timesheetLineList;
while (!(timesheetLineList = timesheetLineQuery.fetch(FETCH_LIMIT, offset)).isEmpty()) {
findBatch();
offset += timesheetLineList.size();
for (TimesheetLine timesheetLine : timesheetLineList) {
try {
timesheetLine = timesheetLineBusinessService.updateTimesheetLines(timesheetLine);
if (timesheetLine.getToInvoice()) {
offset--;
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", timesheetLine.getId());
updatedTimesheetLineList.add(map);
}
} catch (Exception e) {
incrementAnomaly();
TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.BATCH_TIMESHEETLINE_UPDATION_1), timesheetLine.getId()), e), ExceptionOriginRepository.INVOICE_ORIGIN, batch.getId());
}
}
JPA.clear();
}
findBatch();
ProjectInvoicingAssistantBatchService.updateJsonObject(batch, updatedTimesheetLineList, "updatedTimesheetLineSet", contextValues);
}
Aggregations