Search in sources :

Example 21 with PaymentScheduleLine

use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.

the class CfonbExportService method exportPaymentScheduleCFONB.

/**
 * Méthode permettant d'exporter les prélèvements d'échéance de mensu au format CFONB
 *
 * @param paymentScheduleExport
 * @param paymentScheduleLineList
 * @param company
 * @throws AxelorException
 */
public void exportPaymentScheduleCFONB(ZonedDateTime processingDateTime, LocalDate scheduleDate, List<PaymentScheduleLine> paymentScheduleLineList, Company company, BankDetails bankDetails) throws AxelorException {
    if (paymentScheduleLineList == null || paymentScheduleLineList.isEmpty()) {
        return;
    }
    this.testCompanyExportCFONBField(company);
    // paramètre obligatoire : au minimum
    // un enregistrement emetteur par date de règlement (code 03)
    // un enregistrement destinataire (code 06)
    // un enregistrement total (code 08)
    String senderCFONB = this.createSenderMonthlyExportCFONB(scheduleDate, bankDetails);
    List<String> multiRecipientCFONB = new ArrayList<String>();
    for (PaymentScheduleLine paymentScheduleLine : paymentScheduleLineList) {
        paymentScheduleLine = paymentScheduleLineRepo.find(paymentScheduleLine.getId());
        multiRecipientCFONB.add(this.createRecipientCFONB(paymentScheduleLine, true));
    }
    String totalCFONB = this.createPaymentScheduleTotalCFONB(company, this.getTotalAmountPaymentSchedule(paymentScheduleLineList));
// cfonbToolService.testLength(senderCFONB, totalCFONB, multiRecipientCFONB, company);
// List<String> cFONB = this.createCFONBExport(senderCFONB, multiRecipientCFONB, totalCFONB);
// Mise en majuscule des enregistrement
// cFONB = this.toUpperCase(cFONB);
// this.createCFONBFile(cFONB, processingDateTime,
// company.getAccountConfig().getPaymentScheduleExportFolderPathCFONB(), "prelevement");
}
Also used : PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) ArrayList(java.util.ArrayList)

Example 22 with PaymentScheduleLine

use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.

the class PaymentScheduleLineServiceImpl method createPaymentScheduleLines.

/**
 * En fonction des infos d'entête d'un échéancier, crée les lignes d'échéances
 *
 * @param paymentSchedule
 */
@Override
public List<PaymentScheduleLine> createPaymentScheduleLines(PaymentSchedule paymentSchedule) {
    List<PaymentScheduleLine> paymentScheduleLines = new ArrayList<PaymentScheduleLine>();
    int nbrTerm = paymentSchedule.getNbrTerm();
    BigDecimal inTaxAmount = paymentSchedule.getInTaxAmount();
    log.debug("Création de lignes pour l'échéancier numéro {} (nombre d'échéance : {}, montant : {})", new Object[] { paymentSchedule.getPaymentScheduleSeq(), nbrTerm, inTaxAmount });
    if (nbrTerm > 0 && inTaxAmount.compareTo(BigDecimal.ZERO) == 1) {
        BigDecimal termAmount = inTaxAmount.divide(new BigDecimal(nbrTerm), 2, RoundingMode.HALF_UP);
        BigDecimal cumul = BigDecimal.ZERO;
        for (int i = 1; i < nbrTerm + 1; i++) {
            if (i == nbrTerm) {
                termAmount = inTaxAmount.subtract(cumul);
            } else {
                cumul = cumul.add(termAmount);
            }
            paymentScheduleLines.add(this.createPaymentScheduleLine(paymentSchedule, termAmount, i, paymentSchedule.getStartDate().plusMonths(i - 1)));
        }
    }
    return paymentScheduleLines;
}
Also used : PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal)

Example 23 with PaymentScheduleLine

use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.

the class PaymentScheduleLineServiceImpl method createPaymentScheduleLine.

/**
 * Création d'une ligne d'échéancier
 *
 * @param paymentSchedule L'échéancié attaché.
 * @param inTaxAmount Le montant TTC.
 * @param scheduleLineSeq Le numéro d'échéance.
 * @param scheduleDate La date d'échéance.
 * @return
 */
@Override
public PaymentScheduleLine createPaymentScheduleLine(PaymentSchedule paymentSchedule, BigDecimal inTaxAmount, int scheduleLineSeq, LocalDate scheduleDate) {
    PaymentScheduleLine paymentScheduleLine = new PaymentScheduleLine();
    paymentScheduleLine.setScheduleLineSeq(scheduleLineSeq);
    paymentScheduleLine.setScheduleDate(scheduleDate);
    paymentScheduleLine.setInTaxAmount(inTaxAmount);
    paymentScheduleLine.setStatusSelect(PaymentScheduleLineRepository.STATUS_DRAFT);
    if (paymentSchedule != null) {
        paymentSchedule.addPaymentScheduleLineListItem(paymentScheduleLine);
    }
    log.debug("Création de la ligne de l'échéancier numéro {} pour la date du {} et la somme de {}", new Object[] { paymentScheduleLine.getScheduleLineSeq(), paymentScheduleLine.getScheduleDate(), paymentScheduleLine.getInTaxAmount() });
    return paymentScheduleLine;
}
Also used : PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine)

Example 24 with PaymentScheduleLine

use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.

the class PaymentScheduleServiceImpl method closePaymentSchedule.

/**
 * Méthode permettant de passer les statuts des lignes d'échéances et de l'échéancier à 'clo' ie
 * cloturé
 *
 * @param paymentSchedule
 * @throws AxelorException
 */
@Override
public void closePaymentSchedule(PaymentSchedule paymentSchedule) throws AxelorException {
    log.debug("Cloture de l'échéancier");
    for (PaymentScheduleLine paymentScheduleLine : paymentSchedule.getPaymentScheduleLineList()) {
        paymentScheduleLine.setStatusSelect(PaymentScheduleLineRepository.STATUS_CLOSED);
    }
    paymentSchedule.setStatusSelect(PaymentScheduleRepository.STATUS_CLOSED);
}
Also used : PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine)

Example 25 with PaymentScheduleLine

use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.

the class PaymentScheduleServiceImpl method getInvoiceTermTotal.

/**
 * Obtenir le total des factures des lignes d'un échéancier.
 *
 * @param paymentSchedule L'échéancier cible.
 * @return Le somme des montants TTC des lignes de l'échéancier.
 */
@Override
public BigDecimal getInvoiceTermTotal(PaymentSchedule paymentSchedule) {
    BigDecimal totalAmount = BigDecimal.ZERO;
    if (paymentSchedule != null && paymentSchedule.getPaymentScheduleLineList() != null && !paymentSchedule.getPaymentScheduleLineList().isEmpty()) {
        for (PaymentScheduleLine paymentScheduleLine : paymentSchedule.getPaymentScheduleLineList()) {
            if (paymentScheduleLine.getInTaxAmount() != null) {
                log.debug("Somme TTC des lignes de l'échéancier {} : total = {}, ajout = {}", new Object[] { paymentSchedule.getPaymentScheduleSeq(), totalAmount, paymentScheduleLine.getInTaxAmount() });
                totalAmount = totalAmount.add(paymentScheduleLine.getInTaxAmount());
            }
        }
    }
    log.debug("Obtention de la somme TTC des lignes de l'échéancier {} : {}", new Object[] { paymentSchedule.getPaymentScheduleSeq(), totalAmount });
    return totalAmount;
}
Also used : PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) BigDecimal(java.math.BigDecimal)

Aggregations

PaymentScheduleLine (com.axelor.apps.account.db.PaymentScheduleLine)29 Transactional (com.google.inject.persist.Transactional)12 Invoice (com.axelor.apps.account.db.Invoice)11 AxelorException (com.axelor.exception.AxelorException)10 ArrayList (java.util.ArrayList)8 PaymentSchedule (com.axelor.apps.account.db.PaymentSchedule)7 BigDecimal (java.math.BigDecimal)6 LocalDate (java.time.LocalDate)5 MoveLine (com.axelor.apps.account.db.MoveLine)4 BankDetails (com.axelor.apps.base.db.BankDetails)4 Company (com.axelor.apps.base.db.Company)4 Partner (com.axelor.apps.base.db.Partner)4 Move (com.axelor.apps.account.db.Move)3 PaymentMode (com.axelor.apps.account.db.PaymentMode)3 AccountingBatch (com.axelor.apps.account.db.AccountingBatch)2 PaymentModeService (com.axelor.apps.account.service.payment.PaymentModeService)2 BankOrder (com.axelor.apps.bankpayment.db.BankOrder)2 EntityTransaction (javax.persistence.EntityTransaction)2 Account (com.axelor.apps.account.db.Account)1 AccountManagement (com.axelor.apps.account.db.AccountManagement)1