Search in sources :

Example 1 with IrrecoverableReportLine

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

the class IrrecoverableService method createIrrecoverableReportLineList.

/**
 * Fonction permettant de créer une liste de ligne de reporting pour une ligne Echéance rejetée
 *
 * @param iil Une ligne Echéance rejetée
 * @param invoice Une échéance rejetée
 * @param prorataRate Un taux de restant à payer d'une échéance rejetée
 * @return
 * @throws AxelorException
 */
public List<IrrecoverableReportLine> createIrrecoverableReportLineList(IrrecoverablePaymentScheduleLineLine ipsll, PaymentScheduleLine paymentScheduleLine, Tax tax) throws AxelorException {
    List<IrrecoverableReportLine> irlList = new ArrayList<IrrecoverableReportLine>();
    BigDecimal taxRate = taxService.getTaxRate(tax, appAccountService.getTodayDate(paymentScheduleLine.getPaymentSchedule() != null ? paymentScheduleLine.getPaymentSchedule().getCompany() : Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null)));
    BigDecimal amount = paymentScheduleLine.getInTaxAmount();
    BigDecimal divid = taxRate.add(BigDecimal.ONE);
    // Montant hors-Taxe
    BigDecimal irrecoverableAmount = amount.divide(divid, 6, RoundingMode.HALF_UP).setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP);
    // Montant Tax
    BigDecimal taxAmount = amount.subtract(irrecoverableAmount);
    irlList.add(this.createIrrecoverableReportLine(ipsll, "HT", irrecoverableAmount, 1));
    irlList.add(this.createIrrecoverableReportLine(ipsll, tax.getName(), taxAmount, 2));
    return irlList;
}
Also used : User(com.axelor.auth.db.User) ArrayList(java.util.ArrayList) IrrecoverableReportLine(com.axelor.apps.account.db.IrrecoverableReportLine) BigDecimal(java.math.BigDecimal)

Example 2 with IrrecoverableReportLine

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

the class IrrecoverableService method createIrrecoverableReportLine.

/**
 * Fonction permettant de créer une ligne Reporting
 *
 * @param iil Une ligne Echéance rejetée
 * @param label Un libellé
 * @param value Une valeur
 * @param seq Un numéro de séquence
 * @return
 */
public IrrecoverableReportLine createIrrecoverableReportLine(IrrecoverablePaymentScheduleLineLine ipsll, String label, BigDecimal value, int seq) {
    IrrecoverableReportLine irl = new IrrecoverableReportLine();
    irl.setReportLineSeq(seq);
    irl.setLabel(label);
    irl.setValue(value);
    irl.setIrrecoverablePaymentScheduleLineLine(ipsll);
    log.debug("Ligne reporting : {}", irl);
    return irl;
}
Also used : IrrecoverableReportLine(com.axelor.apps.account.db.IrrecoverableReportLine)

Example 3 with IrrecoverableReportLine

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

the class IrrecoverableService method createIrrecoverableReportLineList.

/**
 * Fonction permettant de créer une liste de ligne de reporting pour une ligne Facture
 *
 * @param iil Une ligne Facture
 * @param invoice Une facture
 * @param prorataRate Un taux de restant à payer d'une facture
 * @return
 */
public List<IrrecoverableReportLine> createIrrecoverableReportLineList(IrrecoverableInvoiceLine iil, Invoice invoice, BigDecimal prorataRate) {
    int seq = 1;
    List<IrrecoverableReportLine> irlList = new ArrayList<IrrecoverableReportLine>();
    for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
        irlList.add(this.createIrrecoverableReportLine(iil, invoiceLine.getName(), invoiceLine.getExTaxTotal().multiply(prorataRate).setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP), seq));
        seq++;
    }
    for (InvoiceLineTax invoiceLineTax : invoice.getInvoiceLineTaxList()) {
        irlList.add(this.createIrrecoverableReportLine(iil, invoiceLineTax.getTaxLine().getTax().getName(), invoiceLineTax.getTaxTotal().multiply(prorataRate).setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP), seq));
        seq++;
    }
    // Afin de ne pas modifier les valeurs des lignes de factures, on les recharges depuis la base
    invoiceRepo.refresh(invoice);
    return irlList;
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine) IrrecoverableInvoiceLine(com.axelor.apps.account.db.IrrecoverableInvoiceLine) ArrayList(java.util.ArrayList) IrrecoverableReportLine(com.axelor.apps.account.db.IrrecoverableReportLine) InvoiceLineTax(com.axelor.apps.account.db.InvoiceLineTax)

Example 4 with IrrecoverableReportLine

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

the class IrrecoverableService method createIrrecoverableReportLine.

/**
 * Fonction permettant de créer une ligne Reporting
 *
 * @param iil Une ligne Facture
 * @param label Un libellé
 * @param value Une valeur
 * @param seq Un numéro de séquence
 * @return
 */
public IrrecoverableReportLine createIrrecoverableReportLine(IrrecoverableInvoiceLine iil, String label, BigDecimal value, int seq) {
    IrrecoverableReportLine irl = new IrrecoverableReportLine();
    irl.setReportLineSeq(seq);
    irl.setLabel(label);
    irl.setValue(value);
    irl.setIrrecoverableInvoiceLine(iil);
    log.debug("Ligne reporting : {}", irl);
    return irl;
}
Also used : IrrecoverableReportLine(com.axelor.apps.account.db.IrrecoverableReportLine)

Aggregations

IrrecoverableReportLine (com.axelor.apps.account.db.IrrecoverableReportLine)4 ArrayList (java.util.ArrayList)2 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)1 InvoiceLineTax (com.axelor.apps.account.db.InvoiceLineTax)1 IrrecoverableInvoiceLine (com.axelor.apps.account.db.IrrecoverableInvoiceLine)1 User (com.axelor.auth.db.User)1 BigDecimal (java.math.BigDecimal)1