Search in sources :

Example 6 with Reimbursement

use of com.axelor.apps.account.db.Reimbursement in project axelor-open-suite by axelor.

the class ReimbursementController method validateReimbursement.

public void validateReimbursement(ActionRequest request, ActionResponse response) {
    Reimbursement reimbursement = request.getContext().asType(Reimbursement.class);
    Beans.get(ReimbursementService.class).updatePartnerCurrentRIB(reimbursement);
    if (reimbursement.getBankDetails() != null) {
        response.setValue("statusSelect", ReimbursementRepository.STATUS_VALIDATED);
    } else {
        response.setFlash(I18n.get(IExceptionMessage.REIMBURSEMENT_4));
    }
}
Also used : Reimbursement(com.axelor.apps.account.db.Reimbursement) ReimbursementService(com.axelor.apps.account.service.ReimbursementService)

Example 7 with Reimbursement

use of com.axelor.apps.account.db.Reimbursement in project axelor-open-suite by axelor.

the class BatchCreditTransferPartnerReimbursementBankPayment method createBankOrder.

/**
 * Create a bank order for the specified list of reimbursements.
 *
 * @param accountingBatch
 * @param reimbursementList
 * @return
 * @throws AxelorException
 * @throws DatatypeConfigurationException
 * @throws IOException
 * @throws JAXBException
 */
@Transactional(rollbackOn = { Exception.class })
protected BankOrder createBankOrder(AccountingBatch accountingBatch, List<Reimbursement> reimbursementList) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
    LocalDate bankOrderDate = accountingBatch.getDueDate() != null ? accountingBatch.getDueDate() : appBaseService.getTodayDate(accountingBatch.getCompany());
    BankOrder bankOrder = bankOrderCreateService.createBankOrder(accountingBatch.getPaymentMode(), BankOrderRepository.PARTNER_TYPE_CUSTOMER, bankOrderDate, accountingBatch.getCompany(), accountingBatch.getBankDetails(), accountingBatch.getCompany().getCurrency(), null, null, BankOrderRepository.TECHNICAL_ORIGIN_AUTOMATIC);
    for (Reimbursement reimbursement : reimbursementList) {
        BankOrderLine bankOrderLine = bankOrderLineService.createBankOrderLine(accountingBatch.getPaymentMode().getBankOrderFileFormat(), null, reimbursement.getPartner(), reimbursement.getBankDetails(), reimbursement.getAmountToReimburse(), accountingBatch.getCompany().getCurrency(), bankOrderDate, reimbursement.getRef(), reimbursement.getDescription(), reimbursement);
        bankOrder.addBankOrderLineListItem(bankOrderLine);
        Beans.get(ReimbursementExportService.class).reimburse(reimbursement, accountingBatch.getCompany());
    }
    bankOrder = bankOrderRepo.save(bankOrder);
    bankOrderService.confirm(bankOrder);
    return bankOrder;
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) ReimbursementExportService(com.axelor.apps.account.service.ReimbursementExportService) Reimbursement(com.axelor.apps.account.db.Reimbursement) BatchCreditTransferPartnerReimbursement(com.axelor.apps.account.service.batch.BatchCreditTransferPartnerReimbursement) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) LocalDate(java.time.LocalDate) Transactional(com.google.inject.persist.Transactional)

Example 8 with Reimbursement

use of com.axelor.apps.account.db.Reimbursement in project axelor-open-suite by axelor.

the class ReimbursementExportService method runCreateReimbursement.

@Transactional(rollbackOn = { Exception.class })
public Reimbursement runCreateReimbursement(List<MoveLine> moveLineList, Company company, Partner partner) throws AxelorException {
    log.debug("In runReimbursementProcess");
    BigDecimal total = this.getTotalAmountRemaining(moveLineList);
    AccountConfig accountConfig = company.getAccountConfig();
    // Seuil bas respecté et remboursement manuel autorisé
    if (total.compareTo(accountConfig.getLowerThresholdReimbursement()) > 0) {
        Reimbursement reimbursement = createReimbursement(partner, company);
        fillMoveLineSet(reimbursement, moveLineList, total);
        if (total.compareTo(accountConfig.getUpperThresholdReimbursement()) > 0 || reimbursement.getBankDetails() == null) {
            // Seuil haut dépassé
            reimbursement.setStatusSelect(ReimbursementRepository.STATUS_TO_VALIDATE);
        } else {
            reimbursement.setStatusSelect(ReimbursementRepository.STATUS_VALIDATED);
        }
        reimbursement = reimbursementRepo.save(reimbursement);
        return reimbursement;
    }
    log.debug("End runReimbursementProcess");
    return null;
}
Also used : Reimbursement(com.axelor.apps.account.db.Reimbursement) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 9 with Reimbursement

use of com.axelor.apps.account.db.Reimbursement in project axelor-open-suite by axelor.

the class ReimbursementImportService method createReimbursementRejectMoveLine.

@Transactional(rollbackOn = { Exception.class })
public Reimbursement createReimbursementRejectMoveLine(String[] reject, Company company, int seq, Move move, LocalDate rejectDate) throws AxelorException {
    String refReject = reject[1];
    // String amountReject = reject[2];
    InterbankCodeLine causeReject = rejectImportService.getInterbankCodeLine(reject[3], 0);
    MoveLineRepository moveLineRepo = Beans.get(MoveLineRepository.class);
    Reimbursement reimbursement = reimbursementRepo.all().filter("UPPER(self.ref) = ?1 AND self.company = ?2", refReject, company).fetchOne();
    if (reimbursement == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.REIMBURSEMENT_3), refReject, company.getName());
    }
    Partner partner = reimbursement.getPartner();
    BigDecimal amount = reimbursement.getAmountReimbursed();
    // Création de la ligne au crédit
    MoveLine creditMoveLine = moveLineService.createMoveLine(move, partner, company.getAccountConfig().getCustomerAccount(), amount, false, rejectDate, seq, refReject, null);
    move.getMoveLineList().add(creditMoveLine);
    moveLineRepo.save(creditMoveLine);
    moveRepo.save(move);
    creditMoveLine.setInterbankCodeLine(causeReject);
    reimbursement.setRejectedOk(true);
    reimbursement.setRejectDate(rejectDate);
    reimbursement.setRejectMoveLine(creditMoveLine);
    reimbursement.setInterbankCodeLine(causeReject);
    reimbursementRepo.save(reimbursement);
    return reimbursement;
}
Also used : AxelorException(com.axelor.exception.AxelorException) InterbankCodeLine(com.axelor.apps.account.db.InterbankCodeLine) MoveLine(com.axelor.apps.account.db.MoveLine) Reimbursement(com.axelor.apps.account.db.Reimbursement) MoveLineRepository(com.axelor.apps.account.db.repo.MoveLineRepository) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Example 10 with Reimbursement

use of com.axelor.apps.account.db.Reimbursement in project axelor-open-suite by axelor.

the class BatchCreditTransferPartnerReimbursementBankPayment method process.

@Override
protected void process() {
    super.process();
    AccountingBatch accountingBatch = batch.getAccountingBatch();
    if (!accountingBatch.getPaymentMode().getGenerateBankOrder()) {
        return;
    }
    // Fetch all reimbursements that are validated for the specified company.
    Query<Reimbursement> query = reimbursementRepo.all().filter("self.statusSelect = :statusSelect AND self.company = :company");
    query.bind("statusSelect", ReimbursementRepository.STATUS_VALIDATED);
    query.bind("company", accountingBatch.getCompany());
    List<Reimbursement> reimbursementList = query.fetch();
    if (reimbursementList.isEmpty()) {
        return;
    }
    accountingBatch = Beans.get(AccountingBatchRepository.class).find(accountingBatch.getId());
    try {
        createBankOrder(accountingBatch, reimbursementList);
    } catch (Exception ex) {
        TraceBackService.trace(ex);
        logger.error(ex.getLocalizedMessage());
    }
}
Also used : AccountingBatch(com.axelor.apps.account.db.AccountingBatch) Reimbursement(com.axelor.apps.account.db.Reimbursement) BatchCreditTransferPartnerReimbursement(com.axelor.apps.account.service.batch.BatchCreditTransferPartnerReimbursement) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException)

Aggregations

Reimbursement (com.axelor.apps.account.db.Reimbursement)14 AxelorException (com.axelor.exception.AxelorException)6 Transactional (com.google.inject.persist.Transactional)5 MoveLine (com.axelor.apps.account.db.MoveLine)4 BigDecimal (java.math.BigDecimal)4 Partner (com.axelor.apps.base.db.Partner)3 AccountConfig (com.axelor.apps.account.db.AccountConfig)2 AccountingBatch (com.axelor.apps.account.db.AccountingBatch)2 BatchCreditTransferPartnerReimbursement (com.axelor.apps.account.service.batch.BatchCreditTransferPartnerReimbursement)2 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2 InterbankCodeLine (com.axelor.apps.account.db.InterbankCodeLine)1 Move (com.axelor.apps.account.db.Move)1 MoveLineRepository (com.axelor.apps.account.db.repo.MoveLineRepository)1 ReimbursementExportService (com.axelor.apps.account.service.ReimbursementExportService)1 ReimbursementService (com.axelor.apps.account.service.ReimbursementService)1 BankOrder (com.axelor.apps.bankpayment.db.BankOrder)1 BankOrderLine (com.axelor.apps.bankpayment.db.BankOrderLine)1 BankDetails (com.axelor.apps.base.db.BankDetails)1 Company (com.axelor.apps.base.db.Company)1