Search in sources :

Example 11 with Batch

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

the class AccountingCutOffServiceImpl method getStockMoveLines.

public List<Long> getStockMoveLines(Batch batch) {
    int offset = 0;
    Boolean includeNotStockManagedProduct = batch.getSupplychainBatch().getIncludeNotStockManagedProduct();
    List<StockMoveLine> stockMoveLineList;
    List<Long> stockMoveLineIdList = new ArrayList<>();
    Query<StockMove> stockMoveQuery = stockMoverepository.all().filter(":batch MEMBER OF self.batchSet").bind("batch", batch);
    List<Long> stockMoveIdList = stockMoveQuery.select("id").fetch(0, 0).stream().map(m -> (Long) m.get("id")).collect(Collectors.toList());
    if (stockMoveIdList.isEmpty()) {
        stockMoveLineIdList.add(0L);
    } else {
        Query<StockMoveLine> stockMoveLineQuery = stockMoveLineRepository.all().filter("self.stockMove.id IN :stockMoveIdList").bind("stockMoveIdList", stockMoveIdList).order("id");
        while (!(stockMoveLineList = stockMoveLineQuery.fetch(FETCH_LIMIT, offset)).isEmpty()) {
            offset += stockMoveLineList.size();
            for (StockMoveLine stockMoveLine : stockMoveLineList) {
                Product product = stockMoveLine.getProduct();
                if (!checkStockMoveLine(stockMoveLine, product, includeNotStockManagedProduct)) {
                    stockMoveLineIdList.add(stockMoveLine.getId());
                }
            }
            JPA.clear();
        }
    }
    return stockMoveLineIdList;
}
Also used : TaxAccountService(com.axelor.apps.account.service.TaxAccountService) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) Move(com.axelor.apps.account.db.Move) Inject(com.google.inject.Inject) Transactional(com.google.inject.persist.Transactional) BigDecimal(java.math.BigDecimal) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) TaxLine(com.axelor.apps.account.db.TaxLine) MoveCreateService(com.axelor.apps.account.service.move.MoveCreateService) MoveToolService(com.axelor.apps.account.service.move.MoveToolService) MoveValidateService(com.axelor.apps.account.service.move.MoveValidateService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) RoundingMode(java.math.RoundingMode) AnalyticMoveLineRepository(com.axelor.apps.account.db.repo.AnalyticMoveLineRepository) AccountManagementAccountService(com.axelor.apps.account.service.AccountManagementAccountService) InvoiceLineManagement(com.axelor.apps.account.service.invoice.generator.line.InvoiceLineManagement) FETCH_LIMIT(com.axelor.apps.base.service.administration.AbstractBatch.FETCH_LIMIT) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository) Collectors(java.util.stream.Collectors) Currency(com.axelor.apps.base.db.Currency) List(java.util.List) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) Product(com.axelor.apps.base.db.Product) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) AccountConfigSupplychainService(com.axelor.apps.supplychain.service.config.AccountConfigSupplychainService) LocalDate(java.time.LocalDate) Partner(com.axelor.apps.base.db.Partner) Company(com.axelor.apps.base.db.Company) Query(com.axelor.db.Query) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) StockMoveLineRepository(com.axelor.apps.stock.db.repo.StockMoveLineRepository) AccountConfig(com.axelor.apps.account.db.AccountConfig) PurchaseOrderRepository(com.axelor.apps.purchase.db.repo.PurchaseOrderRepository) AnalyticMoveLineService(com.axelor.apps.account.service.AnalyticMoveLineService) ArrayList(java.util.ArrayList) AxelorException(com.axelor.exception.AxelorException) MoveLine(com.axelor.apps.account.db.MoveLine) UnitConversionService(com.axelor.apps.base.service.UnitConversionService) Batch(com.axelor.apps.base.db.Batch) AppAccountRepository(com.axelor.apps.base.db.repo.AppAccountRepository) MoveLineService(com.axelor.apps.account.service.move.MoveLineService) JPA(com.axelor.db.JPA) Iterator(java.util.Iterator) SupplychainBatchRepository(com.axelor.apps.supplychain.db.repo.SupplychainBatchRepository) ReconcileService(com.axelor.apps.account.service.ReconcileService) AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate) Account(com.axelor.apps.account.db.Account) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Comparator(java.util.Comparator) Collections(java.util.Collections) MoveRepository(com.axelor.apps.account.db.repo.MoveRepository) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Tax(com.axelor.apps.account.db.Tax) StockMove(com.axelor.apps.stock.db.StockMove) ArrayList(java.util.ArrayList) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product)

Example 12 with Batch

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

the class AccountingBatchController method actionMoveLineExport.

/**
 * Lancer le batch de calcul du compte client
 *
 * @param request
 * @param response
 */
public void actionMoveLineExport(ActionRequest request, ActionResponse response) {
    AccountingBatch accountingBatch = request.getContext().asType(AccountingBatch.class);
    Batch batch = null;
    batch = Beans.get(AccountingBatchService.class).moveLineExport(Beans.get(AccountingBatchRepository.class).find(accountingBatch.getId()));
    if (batch != null)
        response.setFlash(batch.getComments());
    response.setReload(true);
}
Also used : Batch(com.axelor.apps.base.db.Batch) AccountingBatch(com.axelor.apps.account.db.AccountingBatch) AccountingBatch(com.axelor.apps.account.db.AccountingBatch) AccountingBatchRepository(com.axelor.apps.account.db.repo.AccountingBatchRepository)

Example 13 with Batch

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

the class AccountingBatchController method run.

// WS
/**
 * Lancer le batch à travers un web service.
 *
 * @param request
 * @param response
 * @throws AxelorException
 */
public void run(ActionRequest request, ActionResponse response) throws AxelorException {
    Batch batch = Beans.get(AccountingBatchService.class).run((String) request.getContext().get("code"));
    Map<String, Object> mapData = new HashMap<String, Object>();
    mapData.put("anomaly", batch.getAnomaly());
    response.setData(mapData);
}
Also used : Batch(com.axelor.apps.base.db.Batch) AccountingBatch(com.axelor.apps.account.db.AccountingBatch) HashMap(java.util.HashMap) AccountingBatchService(com.axelor.apps.account.service.batch.AccountingBatchService)

Example 14 with Batch

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

the class AccountingBatchController method actionDirectDebit.

/**
 * Lancer le batch de prélèvement
 *
 * @param request
 * @param response
 */
public void actionDirectDebit(ActionRequest request, ActionResponse response) {
    try {
        AccountingBatch accountingBatch = request.getContext().asType(AccountingBatch.class);
        accountingBatch = Beans.get(AccountingBatchRepository.class).find(accountingBatch.getId());
        Batch batch = Beans.get(AccountingBatchService.class).directDebit(accountingBatch);
        response.setFlash(batch.getComments());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : Batch(com.axelor.apps.base.db.Batch) AccountingBatch(com.axelor.apps.account.db.AccountingBatch) AccountingBatch(com.axelor.apps.account.db.AccountingBatch) AxelorException(com.axelor.exception.AxelorException) AccountingBatchService(com.axelor.apps.account.service.batch.AccountingBatchService)

Example 15 with Batch

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

the class MailBatchController method remindTimesheet.

public void remindTimesheet(ActionRequest request, ActionResponse response) throws AxelorException {
    MailBatch mailBatch = request.getContext().asType(MailBatch.class);
    Batch batch = null;
    batch = Beans.get(MailBatchService.class).remindMail(Beans.get(MailBatchRepository.class).find(mailBatch.getId()));
    if (batch != null)
        response.setFlash(batch.getComments());
    response.setReload(true);
}
Also used : MailBatch(com.axelor.apps.base.db.MailBatch) MailBatchRepository(com.axelor.apps.base.db.repo.MailBatchRepository) Batch(com.axelor.apps.base.db.Batch) MailBatch(com.axelor.apps.base.db.MailBatch)

Aggregations

Batch (com.axelor.apps.base.db.Batch)43 AccountingBatch (com.axelor.apps.account.db.AccountingBatch)12 AxelorException (com.axelor.exception.AxelorException)12 AccountingBatchService (com.axelor.apps.account.service.batch.AccountingBatchService)6 AccountingBatchRepository (com.axelor.apps.account.db.repo.AccountingBatchRepository)5 HashMap (java.util.HashMap)5 CrmBatch (com.axelor.apps.crm.db.CrmBatch)4 InvoiceBatch (com.axelor.apps.account.db.InvoiceBatch)3 BankPaymentBatch (com.axelor.apps.bankpayment.db.BankPaymentBatch)3 ProjectInvoicingAssistantBatch (com.axelor.apps.businessproject.db.ProjectInvoicingAssistantBatch)3 CrmBatchService (com.axelor.apps.crm.service.batch.CrmBatchService)3 SupplychainBatch (com.axelor.apps.supplychain.db.SupplychainBatch)3 SupplychainBatchService (com.axelor.apps.supplychain.service.batch.SupplychainBatchService)3 InvoiceBatchService (com.axelor.apps.account.service.invoice.InvoiceBatchService)2 BaseBatch (com.axelor.apps.base.db.BaseBatch)2 MailBatch (com.axelor.apps.base.db.MailBatch)2 MailBatchRepository (com.axelor.apps.base.db.repo.MailBatchRepository)2 ProjectInvoicingAssistantBatchService (com.axelor.apps.businessproject.service.batch.ProjectInvoicingAssistantBatchService)2 Account (com.axelor.apps.account.db.Account)1 AccountConfig (com.axelor.apps.account.db.AccountConfig)1