Search in sources :

Example 1 with SequenceService

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()));
}
Also used : AxelorException(com.axelor.exception.AxelorException) SequenceService(com.axelor.apps.base.service.administration.SequenceService) Transactional(com.google.inject.persist.Transactional)

Example 2 with SequenceService

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());
}
Also used : AxelorException(com.axelor.exception.AxelorException) SequenceService(com.axelor.apps.base.service.administration.SequenceService)

Example 3 with SequenceService

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;
}
Also used : AxelorException(com.axelor.exception.AxelorException) PersistenceException(javax.persistence.PersistenceException) SequenceService(com.axelor.apps.base.service.administration.SequenceService) Inventory(com.axelor.apps.stock.db.Inventory)

Example 4 with SequenceService

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);
    }
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove) PersistenceException(javax.persistence.PersistenceException) SequenceService(com.axelor.apps.base.service.administration.SequenceService) PersistenceException(javax.persistence.PersistenceException)

Example 5 with SequenceService

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);
    }
}
Also used : StockLocation(com.axelor.apps.stock.db.StockLocation) SequenceService(com.axelor.apps.base.service.administration.SequenceService) Inventory(com.axelor.apps.stock.db.Inventory) BirtException(org.eclipse.birt.core.exception.BirtException) NoResultException(javax.persistence.NoResultException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Aggregations

SequenceService (com.axelor.apps.base.service.administration.SequenceService)8 AxelorException (com.axelor.exception.AxelorException)7 Inventory (com.axelor.apps.stock.db.Inventory)2 Transactional (com.google.inject.persist.Transactional)2 PersistenceException (javax.persistence.PersistenceException)2 ManufOrder (com.axelor.apps.production.db.ManufOrder)1 OperationOrder (com.axelor.apps.production.db.OperationOrder)1 AppProductionService (com.axelor.apps.production.service.app.AppProductionService)1 ProductionOrderService (com.axelor.apps.production.service.productionorder.ProductionOrderService)1 StockLocation (com.axelor.apps.stock.db.StockLocation)1 StockMove (com.axelor.apps.stock.db.StockMove)1 IOException (java.io.IOException)1 NoResultException (javax.persistence.NoResultException)1 BirtException (org.eclipse.birt.core.exception.BirtException)1