use of com.axelor.apps.base.service.administration.SequenceService in project axelor-open-suite by axelor.
the class SubrogationReleaseServiceImpl method transmitRelease.
@Override
@Transactional(rollbackOn = { Exception.class })
public void transmitRelease(SubrogationRelease subrogationRelease) throws AxelorException {
SequenceService sequenceService = Beans.get(SequenceService.class);
String sequenceNumber = sequenceService.getSequenceNumber("subrogationRelease", subrogationRelease.getCompany());
if (Strings.isNullOrEmpty(sequenceNumber)) {
throw new AxelorException(Sequence.class, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get(IExceptionMessage.SUBROGATION_RELEASE_MISSING_SEQUENCE), subrogationRelease.getCompany().getName());
}
this.checkIfAnOtherSubrogationAlreadyExist(subrogationRelease);
subrogationRelease.setSequenceNumber(sequenceNumber);
subrogationRelease.setStatusSelect(SubrogationReleaseRepository.STATUS_TRANSMITTED);
subrogationRelease.setTransmissionDate(appBaseService.getTodayDate(subrogationRelease.getCompany()));
}
use of com.axelor.apps.base.service.administration.SequenceService in project axelor-open-suite by axelor.
the class AccountingReportServiceImpl method getSequence.
public String getSequence(AccountingReport accountingReport) throws AxelorException {
SequenceService sequenceService = Beans.get(SequenceService.class);
if (accountingReport.getReportType() == null) {
throw new AxelorException(accountingReport, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNTING_REPORT_NO_REPORT_TYPE));
}
int accountingReportTypeSelect = accountingReport.getReportType().getTypeSelect();
if (accountingReportTypeSelect >= 0 && accountingReportTypeSelect < 1000) {
String seq = sequenceService.getSequenceNumber(SequenceRepository.ACCOUNTING_REPORT, accountingReport.getCompany());
if (seq == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNTING_REPORT_1), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), accountingReport.getCompany().getName());
}
return seq;
} else if (accountingReportTypeSelect >= 1000 && accountingReportTypeSelect < 2000) {
String seq = sequenceService.getSequenceNumber(SequenceRepository.MOVE_LINE_EXPORT, accountingReport.getCompany());
if (seq == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNTING_REPORT_2), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), accountingReport.getCompany().getName());
}
return seq;
} else if (accountingReportTypeSelect >= 2000 && accountingReportTypeSelect < 3000) {
String seq = sequenceService.getSequenceNumber(SequenceRepository.ANALYTIC_REPORT, accountingReport.getCompany());
if (seq == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNTING_REPORT_ANALYTIC_REPORT), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), accountingReport.getCompany().getName());
}
return seq;
} else if (accountingReportTypeSelect == 3000) {
String seq = sequenceService.getSequenceNumber(SequenceRepository.CUSTOM_ACCOUNTING_REPORT, accountingReport.getCompany());
if (seq == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNTING_REPORT_7), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), accountingReport.getCompany().getName());
}
return seq;
}
throw new AxelorException(accountingReport, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNTING_REPORT_UNKNOWN_ACCOUNTING_REPORT_TYPE), accountingReport.getReportType().getTypeSelect());
}
use of com.axelor.apps.base.service.administration.SequenceService in project axelor-open-suite by axelor.
the class InventoryManagementRepository method save.
@Override
public Inventory save(Inventory entity) {
Inventory inventory = super.save(entity);
SequenceService sequenceService = Beans.get(SequenceService.class);
try {
if (Strings.isNullOrEmpty(inventory.getInventorySeq())) {
inventory.setInventorySeq(sequenceService.getDraftSequenceNumber(inventory));
}
} catch (AxelorException e) {
TraceBackService.traceExceptionFromSaveMethod(e);
throw new PersistenceException(e.getMessage(), e);
}
entity.setInventoryTitle(Beans.get(InventoryService.class).computeTitle(entity));
return inventory;
}
use of com.axelor.apps.base.service.administration.SequenceService in project axelor-open-suite by axelor.
the class StockMoveManagementRepository method save.
@Override
public StockMove save(StockMove entity) {
try {
StockMove stockMove = super.save(entity);
SequenceService sequenceService = Beans.get(SequenceService.class);
if (Strings.isNullOrEmpty(stockMove.getStockMoveSeq())) {
stockMove.setStockMoveSeq(sequenceService.getDraftSequenceNumber(stockMove));
}
if (Strings.isNullOrEmpty(stockMove.getName()) || stockMove.getName().startsWith(stockMove.getStockMoveSeq())) {
stockMove.setName(Beans.get(StockMoveToolService.class).computeName(stockMove));
}
return stockMove;
} catch (Exception e) {
TraceBackService.traceExceptionFromSaveMethod(e);
throw new PersistenceException(e.getMessage(), e);
}
}
use of com.axelor.apps.base.service.administration.SequenceService in project axelor-open-suite by axelor.
the class InventoryController method setInventorySequence.
public void setInventorySequence(ActionRequest request, ActionResponse response) {
try {
Inventory inventory = request.getContext().asType(Inventory.class);
SequenceService sequenceService = Beans.get(SequenceService.class);
if (sequenceService.isEmptyOrDraftSequenceNumber(inventory.getInventorySeq())) {
StockLocation stockLocation = inventory.getStockLocation();
response.setValue("inventorySeq", Beans.get(InventoryService.class).getInventorySequence(stockLocation.getCompany()));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations