Search in sources :

Example 6 with MoveLine

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;
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList)

Example 7 with MoveLine

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);
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) ManagementObject(com.axelor.apps.account.db.ManagementObject) MoveLine(com.axelor.apps.account.db.MoveLine) Transactional(com.google.inject.persist.Transactional)

Example 8 with MoveLine

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);
}
Also used : Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) ManagementObject(com.axelor.apps.account.db.ManagementObject) PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) Transactional(com.google.inject.persist.Transactional)

Example 9 with MoveLine

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);
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) Transactional(com.google.inject.persist.Transactional)

Example 10 with MoveLine

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");
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine)

Aggregations

MoveLine (com.axelor.apps.account.db.MoveLine)135 BigDecimal (java.math.BigDecimal)60 Move (com.axelor.apps.account.db.Move)51 Transactional (com.google.inject.persist.Transactional)42 AxelorException (com.axelor.exception.AxelorException)40 Company (com.axelor.apps.base.db.Company)38 ArrayList (java.util.ArrayList)38 Partner (com.axelor.apps.base.db.Partner)33 Account (com.axelor.apps.account.db.Account)28 LocalDate (java.time.LocalDate)27 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)25 Journal (com.axelor.apps.account.db.Journal)22 Reconcile (com.axelor.apps.account.db.Reconcile)22 AccountConfig (com.axelor.apps.account.db.AccountConfig)17 Invoice (com.axelor.apps.account.db.Invoice)15 List (java.util.List)13 TaxPaymentMoveLine (com.axelor.apps.account.db.TaxPaymentMoveLine)8 Tax (com.axelor.apps.account.db.Tax)7 TaxLine (com.axelor.apps.account.db.TaxLine)7 MoveLineRepository (com.axelor.apps.account.db.repo.MoveLineRepository)7