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));
}
}
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;
}
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;
}
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;
}
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());
}
}
Aggregations