Search in sources :

Example 6 with Sequence

use of com.axelor.apps.base.db.Sequence in project axelor-open-suite by axelor.

the class ExpenseServiceImpl method setExpenseSeq.

private void setExpenseSeq(Expense expense) throws AxelorException {
    if (!Beans.get(SequenceService.class).isEmptyOrDraftSequenceNumber(expense.getExpenseSeq())) {
        return;
    }
    HRConfig hrConfig = hrConfigService.getHRConfig(expense.getCompany());
    Sequence sequence = hrConfigService.getExpenseSequence(hrConfig);
    if (sequence != null) {
        expense.setExpenseSeq(Beans.get(SequenceService.class).getSequenceNumber(sequence, expense.getSentDate()));
        if (expense.getExpenseSeq() != null) {
            return;
        }
    }
    throw new AxelorException(expense, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.HR_CONFIG_NO_EXPENSE_SEQUENCE), expense.getCompany().getName());
}
Also used : AxelorException(com.axelor.exception.AxelorException) HRConfig(com.axelor.apps.hr.db.HRConfig) Sequence(com.axelor.apps.base.db.Sequence)

Example 7 with Sequence

use of com.axelor.apps.base.db.Sequence in project axelor-open-suite by axelor.

the class ImportSequence method importSequence.

@Transactional(rollbackOn = Exception.class)
public Object importSequence(Object bean, Map<String, Object> values) throws AxelorException {
    assert bean instanceof Sequence;
    Sequence sequence = (Sequence) bean;
    sequence.setFullName(sequenceService.computeFullName(sequence));
    SequenceVersion seqVersion = sequenceService.getVersion(sequence, LocalDate.now());
    sequenceVersionRepository.save(seqVersion);
    sequence.setVersion(seqVersion.getId().intValue());
    sequenceRepository.save(sequence);
    return sequence;
}
Also used : SequenceVersion(com.axelor.apps.base.db.SequenceVersion) Sequence(com.axelor.apps.base.db.Sequence) Transactional(com.google.inject.persist.Transactional)

Example 8 with Sequence

use of com.axelor.apps.base.db.Sequence in project axelor-open-suite by axelor.

the class BankOrderServiceImpl method generateSequence.

@Override
@Transactional(rollbackOn = { Exception.class })
public BankOrder generateSequence(BankOrder bankOrder) throws AxelorException {
    if (bankOrder.getBankOrderSeq() == null) {
        Sequence sequence = getSequence(bankOrder);
        setBankOrderSeq(bankOrder, sequence);
        bankOrderRepo.save(bankOrder);
    }
    return bankOrder;
}
Also used : Sequence(com.axelor.apps.base.db.Sequence) Transactional(com.google.inject.persist.Transactional)

Example 9 with Sequence

use of com.axelor.apps.base.db.Sequence in project axelor-open-suite by axelor.

the class SequenceController method getDefaultTitle.

public void getDefaultTitle(ActionRequest request, ActionResponse response) {
    Sequence sequence = request.getContext().asType(Sequence.class);
    if (!Strings.isNullOrEmpty(sequence.getCodeSelect())) {
        String defautlTitle = Beans.get(SequenceService.class).getDefaultTitle(sequence);
        response.setValue("name", I18n.get(defautlTitle));
    }
}
Also used : SequenceService(com.axelor.apps.base.service.administration.SequenceService) Sequence(com.axelor.apps.base.db.Sequence)

Example 10 with Sequence

use of com.axelor.apps.base.db.Sequence in project axelor-open-suite by axelor.

the class SequenceController method computeFullName.

public void computeFullName(ActionRequest request, ActionResponse response) {
    Sequence sequence = request.getContext().asType(Sequence.class);
    String fullName = Beans.get(SequenceService.class).computeFullName(sequence);
    response.setValue("fullName", fullName);
}
Also used : SequenceService(com.axelor.apps.base.service.administration.SequenceService) Sequence(com.axelor.apps.base.db.Sequence)

Aggregations

Sequence (com.axelor.apps.base.db.Sequence)17 AxelorException (com.axelor.exception.AxelorException)8 Transactional (com.google.inject.persist.Transactional)4 Account (com.axelor.apps.account.db.Account)3 Partner (com.axelor.apps.base.db.Partner)3 SequenceVersion (com.axelor.apps.base.db.SequenceVersion)2 SequenceService (com.axelor.apps.base.service.administration.SequenceService)2 TrackingNumberConfiguration (com.axelor.apps.stock.db.TrackingNumberConfiguration)2 HRConfig (com.axelor.apps.hr.db.HRConfig)1 ProductionConfig (com.axelor.apps.production.db.ProductionConfig)1 AppProductionService (com.axelor.apps.production.service.app.AppProductionService)1 ProductionConfigService (com.axelor.apps.production.service.config.ProductionConfigService)1 TrackingNumber (com.axelor.apps.stock.db.TrackingNumber)1