use of com.axelor.apps.account.db.ManagementObject in project axelor-open-suite by axelor.
the class IrrecoverableService method passInIrrecoverable.
/**
* Procédure permettant de passer une facture en irrécouvrable
*
* @param invoice Une facture
* @param generateEvent Un évènement à t'il déjà été créé par un autre objet ?
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public void passInIrrecoverable(Invoice invoice, boolean generateEvent) throws AxelorException {
invoice.setIrrecoverableStatusSelect(InvoiceRepository.IRRECOVERABLE_STATUS_TO_PASS_IN_IRRECOUVRABLE);
if (generateEvent) {
Company company = invoice.getCompany();
ManagementObject managementObject = this.createManagementObject("IRR", accountConfigService.getIrrecoverableReasonPassage(accountConfigService.getAccountConfig(company)));
invoice.setManagementObject(managementObject);
MoveLine moveLine = moveService.getMoveToolService().getCustomerMoveLineByQuery(invoice);
if (moveLine == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.IRRECOVERABLE_3), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), invoice.getInvoiceId());
}
this.passInIrrecoverable(moveLine, managementObject, false);
}
invoiceRepo.save(invoice);
}
use of com.axelor.apps.account.db.ManagementObject in project axelor-open-suite by axelor.
the class IrrecoverableService method passInIrrecoverable.
/**
* Procédure permettant de passer un échéancier de lissage de paiement en irrécouvrable La
* procédure passera aussi les lignes d'écriture de rejet d'échéance en irrécouvrable, ainsi que
* les factures pas complètement payée selectionnées sur l'échéancier
*
* @param paymentSchedule Un échéancier de paiement
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public void passInIrrecoverable(PaymentSchedule paymentSchedule) throws AxelorException {
Company company = paymentSchedule.getCompany();
paymentSchedule.setIrrecoverableStatusSelect(PaymentScheduleRepository.IRRECOVERABLE_STATUS_TO_PASS_IN_IRRECOUVRABLE);
ManagementObject managementObject = this.createManagementObject("IRR", accountConfigService.getIrrecoverableReasonPassage(accountConfigService.getAccountConfig(company)));
paymentSchedule.setManagementObject(managementObject);
List<MoveLine> paymentScheduleLineRejectMoveLineList = new ArrayList<MoveLine>();
for (PaymentScheduleLine paymentScheduleLine : paymentSchedule.getPaymentScheduleLineList()) {
if (paymentScheduleLine.getRejectMoveLine() != null && paymentScheduleLine.getRejectMoveLine().getAmountRemaining().compareTo(BigDecimal.ZERO) > 0) {
paymentScheduleLineRejectMoveLineList.add(paymentScheduleLine.getRejectMoveLine());
}
}
for (MoveLine moveLine : paymentScheduleLineRejectMoveLineList) {
this.passInIrrecoverable(moveLine, managementObject, true);
}
for (Invoice invoice : paymentSchedule.getInvoiceSet()) {
if (invoice.getCompanyInTaxTotalRemaining().compareTo(BigDecimal.ZERO) > 0) {
this.passInIrrecoverable(invoice, managementObject);
}
}
paymentScheduleService.cancelPaymentSchedule(paymentSchedule);
paymentScheduleRepo.save(paymentSchedule);
}
use of com.axelor.apps.account.db.ManagementObject in project axelor-open-suite by axelor.
the class IrrecoverableService method passInIrrecoverable.
/**
* Procédure permettant de passer en irrécouvrable une ligne d'écriture
*
* @param moveLine Une ligne d'écriture
* @param generateEvent Un évènement à t'il déjà été créé par un autre objet ?
* @param passInvoice La procédure doit-elle passer aussi en irrécouvrable la facture ?
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public void passInIrrecoverable(MoveLine moveLine, boolean generateEvent, boolean passInvoice) throws AxelorException {
moveLine.setIrrecoverableStatusSelect(MoveLineRepository.IRRECOVERABLE_STATUS_TO_PASS_IN_IRRECOUVRABLE);
ManagementObject managementObject = null;
if (generateEvent) {
Company company = moveLine.getMove().getCompany();
managementObject = this.createManagementObject("IRR", accountConfigService.getIrrecoverableReasonPassage(accountConfigService.getAccountConfig(company)));
moveLine.setManagementObject(managementObject);
}
if (moveLine.getMove().getInvoice() != null && passInvoice) {
this.passInIrrecoverable(moveLine.getMove().getInvoice(), managementObject);
}
moveLineRepo.save(moveLine);
}
use of com.axelor.apps.account.db.ManagementObject in project axelor-open-suite by axelor.
the class IrrecoverableService method createManagementObject.
/**
* Fonction permettant de créer un objet de gestion
*
* @param code
* @param message
* @return
*/
public ManagementObject createManagementObject(String code, String message) {
ManagementObject managementObject = managementObjectRepo.all().filter("self.code = ?1 AND self.name = ?2", code, message).fetchOne();
if (managementObject != null) {
return managementObject;
}
managementObject = new ManagementObject();
managementObject.setCode(code);
managementObject.setName(message);
return managementObject;
}
Aggregations