use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.
the class InvoiceLineGenerator method computeCompanyTotal.
public void computeCompanyTotal(InvoiceLine invoiceLine) throws AxelorException {
if (typeSelect == InvoiceLineRepository.TYPE_TITLE) {
return;
}
Company company = invoice.getCompany();
Currency companyCurrency = company.getCurrency();
if (companyCurrency == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVOICE_LINE_GENERATOR_2), company.getName());
}
invoiceLine.setCompanyExTaxTotal(currencyService.getAmountCurrencyConvertedAtDate(invoice.getCurrency(), companyCurrency, exTaxTotal, today).setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP));
invoiceLine.setCompanyInTaxTotal(currencyService.getAmountCurrencyConvertedAtDate(invoice.getCurrency(), companyCurrency, inTaxTotal, today).setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP));
}
use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.
the class InvoiceServiceImpl method getBankDetails.
@Override
public BankDetails getBankDetails(Invoice invoice) throws AxelorException {
BankDetails bankDetails;
if (invoice.getSchedulePaymentOk() && invoice.getPaymentSchedule() != null) {
bankDetails = invoice.getPaymentSchedule().getBankDetails();
if (bankDetails != null) {
return bankDetails;
}
}
bankDetails = invoice.getBankDetails();
if (bankDetails != null) {
return bankDetails;
}
Partner partner = invoice.getPartner();
Preconditions.checkNotNull(partner);
bankDetails = Beans.get(BankDetailsRepository.class).findDefaultByPartner(partner);
if (bankDetails != null) {
return bankDetails;
}
throw new AxelorException(invoice, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.PARTNER_BANK_DETAILS_MISSING), partner.getName());
}
use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.
the class BatchDoubtfulCustomer method createDoubtFulCustomerRejectMove.
/**
* Procédure permettant de créer les écritures de passage en client douteux pour chaque ligne
* d'écriture de rejet de facture
*
* @param moveLineList Une liste de lignes d'écritures de rejet de facture
* @param doubtfulCustomerAccount Un compte client douteux
* @param debtPassReason Un motif de passage en client douteux
* @throws AxelorException
*/
public void createDoubtFulCustomerRejectMove(List<MoveLine> moveLineList, Account doubtfulCustomerAccount, String debtPassReason) {
int i = 0;
for (MoveLine moveLine : moveLineList) {
try {
doubtfulCustomerService.createDoubtFulCustomerRejectMove(moveLineRepo.find(moveLine.getId()), accountRepo.find(doubtfulCustomerAccount.getId()), debtPassReason);
updateInvoice(moveLineRepo.find(moveLine.getId()).getInvoiceReject());
i++;
} catch (AxelorException e) {
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get("Invoice") + " %s", moveLine.getInvoiceReject().getInvoiceId()), ExceptionOriginRepository.DOUBTFUL_CUSTOMER, batch.getId());
incrementAnomaly();
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get("Invoice") + " %s", moveLine.getInvoiceReject().getInvoiceId()), e), ExceptionOriginRepository.DOUBTFUL_CUSTOMER, batch.getId());
incrementAnomaly();
log.error("Bug(Anomalie) généré(e) pour la facture {}", moveLineRepo.find(moveLine.getId()).getInvoiceReject().getInvoiceId());
} finally {
if (i % 10 == 0) {
JPA.clear();
}
}
}
}
use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.
the class BatchReimbursementExport method runReimbursementExportProcess.
public void runReimbursementExportProcess(Company company) {
int i = 0;
// On récupère les remboursements dont les trop perçu ont été annulés
List<Reimbursement> reimbursementToCancelList = reimbursementRepo.all().filter("self.company = ?1 and self.statusSelect = ?2 and self.amountToReimburse = 0", ReimbursementRepository.STATUS_VALIDATED, company).fetch();
// On annule les remboursements
for (Reimbursement reimbursement : reimbursementToCancelList) {
reimbursement.setStatusSelect(ReimbursementRepository.STATUS_CANCELED);
}
// On récupère les remboursement à rembourser
List<Reimbursement> reimbursementList = reimbursementRepo.all().filter("self.company = ?1 and self.statusSelect = ?2 and self.amountToReimburse > 0 AND self.partner", company, ReimbursementRepository.STATUS_VALIDATED).fetch();
List<Reimbursement> reimbursementToExport = new ArrayList<>();
for (Reimbursement reimbursement : reimbursementList) {
try {
reimbursement = reimbursementRepo.find(reimbursement.getId());
if (reimbursementExportService.canBeReimbursed(reimbursement.getPartner(), reimbursement.getCompany())) {
reimbursementExportService.reimburse(reimbursement, company);
updateReimbursement(reimbursementRepo.find(reimbursement.getId()));
reimbursementToExport.add(reimbursement);
this.totalAmount = this.totalAmount.add(reimbursementRepo.find(reimbursement.getId()).getAmountReimbursed());
i++;
}
} catch (AxelorException e) {
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get("Reimbursement") + " %s", reimbursementRepo.find(reimbursement.getId()).getRef()), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get("Reimbursement") + " %s", reimbursementRepo.find(reimbursement.getId()).getRef()), e), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
log.error("Bug(Anomalie) généré(e) pour l'export du remboursement {}", reimbursementRepo.find(reimbursement.getId()).getRef());
} finally {
if (i % 10 == 0) {
JPA.clear();
}
}
}
if (reimbursementToExport != null && !reimbursementToExport.isEmpty()) {
try {
cfonbExportService.exportCFONB(companyRepo.find(company.getId()), batchRepo.find(batch.getId()).getStartDate(), reimbursementToExport, batchRepo.find(batch.getId()).getAccountingBatch().getBankDetails());
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_1), batch.getId()), e), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
log.error("Bug(Anomalie) généré(e)e dans l'export CFONB - Batch {}", batch.getId());
}
}
}
use of com.axelor.exception.AxelorException in project axelor-open-suite by axelor.
the class BatchReimbursementImport method validateMove.
public void validateMove(Move move, LocalDate rejectDate, int seq) {
try {
if (seq != 1) {
MoveLine oppositeMoveLine = reimbursementImportService.createOppositeRejectMoveLine(moveRepo.find(move.getId()), seq, rejectDate);
reimbursementImportService.validateMove(moveRepo.find(move.getId()));
this.totalAmount = this.totalAmount.add(moveLineRepo.find(oppositeMoveLine.getId()).getDebit());
} else {
reimbursementImportService.deleteMove(moveRepo.find(move.getId()));
}
} catch (AxelorException e) {
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), e), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
log.error("Bug(Anomalie) généré(e) pour le batch d'import des remboursements {}", batch.getId());
}
}
Aggregations