Search in sources :

Example 11 with Sequence

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

the class SequenceScript method computeFullname.

public Object computeFullname(Object bean, Map<String, Object> values) {
    assert bean instanceof Sequence;
    Sequence sequence = ((Sequence) bean);
    sequence.setFullName(Beans.get(SequenceService.class).computeFullName(sequence));
    return sequence;
}
Also used : Sequence(com.axelor.apps.base.db.Sequence)

Example 12 with Sequence

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

the class ABCAnalysisServiceImpl method setSequence.

@Override
public void setSequence(ABCAnalysis abcAnalysis) {
    String abcAnalysisSequence = abcAnalysis.getAbcAnalysisSeq();
    if (abcAnalysisSequence != null && !abcAnalysisSequence.isEmpty()) {
        return;
    }
    Sequence sequence = sequenceService.getSequence(abcAnalysisSequenceCode, abcAnalysis.getCompany());
    if (sequence == null) {
        return;
    }
    abcAnalysis.setAbcAnalysisSeq(sequenceService.getSequenceNumber(sequence));
}
Also used : Sequence(com.axelor.apps.base.db.Sequence)

Example 13 with Sequence

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

the class ManufOrderServiceImpl method getManufOrderSeq.

@Override
public String getManufOrderSeq(ManufOrder manufOrder) throws AxelorException {
    ProductionConfigService productionConfigService = Beans.get(ProductionConfigService.class);
    ProductionConfig productionConfig = productionConfigService.getProductionConfig(manufOrder.getCompany());
    Sequence sequence = productionConfigService.getManufOrderSequence(productionConfig, manufOrder.getWorkshopStockLocation());
    String seq = sequenceService.getSequenceNumber(sequence);
    if (seq == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.MANUF_ORDER_SEQ));
    }
    return seq;
}
Also used : AxelorException(com.axelor.exception.AxelorException) ProductionConfigService(com.axelor.apps.production.service.config.ProductionConfigService) ProductionConfig(com.axelor.apps.production.db.ProductionConfig) Sequence(com.axelor.apps.base.db.Sequence)

Example 14 with Sequence

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

the class ProductionConfigService method getManufOrderSequence.

/**
 * Find the configured sequence for a manufacturing order.
 *
 * <p>A company can have a different sequence per workshop. If no sequence is found per workshop,
 * then return {@link ProductionConfig#manufOrderSequence}.
 *
 * @param productionConfig the config corresponding to the company.
 * @param workshop the workshop of the manufacturing order.
 * @return the found sequence.
 * @throws AxelorException if no sequence is found for the given workshop, and if no default
 *     sequence is filled.
 */
public Sequence getManufOrderSequence(ProductionConfig productionConfig, StockLocation workshop) throws AxelorException {
    Sequence sequence = null;
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (appProductionService.isApp("production")) {
        if (productionConfig.getWorkshopSequenceConfigLineList() != null && appProductionService.getAppProduction().getManageWorkshop()) {
            sequence = productionConfig.getWorkshopSequenceConfigLineList().stream().filter(workshopSequenceConfigLine -> workshopSequenceConfigLine.getWorkshopStockLocation().equals(workshop)).map(WorkshopSequenceConfigLine::getSequence).findFirst().orElseGet(productionConfig::getManufOrderSequence);
        } else {
            sequence = productionConfig.getManufOrderSequence();
        }
    }
    if (sequence == null) {
        throw new AxelorException(productionConfig, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PRODUCTION_CONFIG_MISSING_MANUF_ORDER_SEQ), productionConfig.getCompany().getName());
    }
    return sequence;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Sequence(com.axelor.apps.base.db.Sequence) AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Example 15 with Sequence

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

the class VentilateState method setInvoiceId.

/**
 * Détermine le numéro de facture
 *
 * @throws AxelorException
 */
protected void setInvoiceId() throws AxelorException {
    if (!sequenceService.isEmptyOrDraftSequenceNumber(invoice.getInvoiceId())) {
        return;
    }
    Sequence sequence = this.getSequence();
    if (!InvoiceToolService.isPurchase(invoice)) {
        this.checkInvoiceDate(sequence);
    }
    invoice.setInvoiceId(sequenceService.getSequenceNumber(sequence, invoice.getInvoiceDate()));
    if (invoice.getInvoiceId() != null) {
        return;
    }
    throw new AxelorException(invoice, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.VENTILATE_STATE_4), invoice.getCompany().getName());
}
Also used : AxelorException(com.axelor.exception.AxelorException) 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