use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class PaymentScheduleServiceImpl method getPaymentSchedulerMoveLineToPay.
/**
* This method is used to get the movelines to be paid based on a paymentSchedule It loops on the
* invoice M2M content and gets the movelines which are to pay
*
* @param paymentSchedule
* @return
*/
@Override
public List<MoveLine> getPaymentSchedulerMoveLineToPay(PaymentSchedule paymentSchedule) {
log.debug("In getPaymentSchedulerMoveLineToPay ....");
List<MoveLine> moveLines = new ArrayList<MoveLine>();
for (Invoice invoice : paymentSchedule.getInvoiceSet()) {
if (invoice.getCompanyInTaxTotalRemaining().compareTo(BigDecimal.ZERO) > 0 && invoice.getMove() != null && invoice.getMove().getMoveLineList() != null) {
for (MoveLine moveLine : invoice.getMove().getMoveLineList()) {
if (moveLine.getAccount().getUseForPartnerBalance() && moveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) > 0 && moveLine.getDebit().compareTo(BigDecimal.ZERO) > 0) {
moveLines.add(moveLine);
}
}
}
}
log.debug("End getPaymentSchedulerMoveLineToPay.");
return moveLines;
}
use of com.axelor.apps.account.db.MoveLine 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.MoveLine 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.MoveLine in project axelor-open-suite by axelor.
the class IrrecoverableService method notPassInIrrecoverable.
/**
* Procédure permettant d'annuler le passage en irrécouvrable d'une échéancier de lissage de
* paiement La procédure annulera aussi le passage en irrécouvrable des lignes d'écriture de rejet
* d'échéance en irrécouvrable, ainsi que des 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 notPassInIrrecoverable(PaymentSchedule paymentSchedule) throws AxelorException {
paymentSchedule.setIrrecoverableStatusSelect(PaymentScheduleRepository.IRRECOVERABLE_STATUS_NOT_IRRECOUVRABLE);
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.notPassInIrrecoverable(moveLine, false);
}
for (Invoice invoice : paymentSchedule.getInvoiceSet()) {
this.notPassInIrrecoverable(invoice);
}
paymentScheduleRepo.save(paymentSchedule);
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class ReimbursementExportService method fillMoveLineSet.
public void fillMoveLineSet(Reimbursement reimbursement, List<MoveLine> moveLineList, BigDecimal total) {
log.debug("In fillMoveLineSet");
log.debug("Nombre de trop-perçus trouvés : {}", moveLineList.size());
for (MoveLine moveLine : moveLineList) {
// On passe les lignes d'écriture (trop perçu) à l'état 'en cours de remboursement'
moveLine.setReimbursementStatusSelect(MoveLineRepository.REIMBURSEMENT_STATUS_REIMBURSING);
}
reimbursement.setMoveLineSet(new HashSet<MoveLine>());
reimbursement.getMoveLineSet().addAll(moveLineList);
log.debug("End fillMoveLineSet");
}
Aggregations