Search in sources :

Example 1 with TaxPaymentMoveLine

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

the class TaxPaymentMoveLineServiceImpl method getReverseTaxPaymentMoveLine.

@Override
public TaxPaymentMoveLine getReverseTaxPaymentMoveLine(TaxPaymentMoveLine taxPaymentMoveLine) throws AxelorException {
    TaxPaymentMoveLine reversetaxPaymentMoveLine = new TaxPaymentMoveLine(taxPaymentMoveLine.getMoveLine(), taxPaymentMoveLine.getOriginTaxLine(), taxPaymentMoveLine.getReconcile(), taxPaymentMoveLine.getTaxRate(), taxPaymentMoveLine.getDetailPaymentAmount().negate(), Beans.get(AppBaseService.class).getTodayDate(taxPaymentMoveLine.getReconcile().getCompany()));
    reversetaxPaymentMoveLine = this.computeTaxAmount(reversetaxPaymentMoveLine);
    reversetaxPaymentMoveLine.setIsAlreadyReverse(true);
    taxPaymentMoveLine.setIsAlreadyReverse(true);
    return reversetaxPaymentMoveLine;
}
Also used : TaxPaymentMoveLine(com.axelor.apps.account.db.TaxPaymentMoveLine)

Example 2 with TaxPaymentMoveLine

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

the class MoveLineServiceImpl method reverseTaxPaymentMoveLines.

@Override
@Transactional(rollbackOn = { Exception.class })
public MoveLine reverseTaxPaymentMoveLines(MoveLine customerMoveLine, Reconcile reconcile) throws AxelorException {
    List<TaxPaymentMoveLine> reverseTaxPaymentMoveLines = new ArrayList<TaxPaymentMoveLine>();
    for (TaxPaymentMoveLine taxPaymentMoveLine : customerMoveLine.getTaxPaymentMoveLineList()) {
        if (!taxPaymentMoveLine.getIsAlreadyReverse() && taxPaymentMoveLine.getReconcile().equals(reconcile)) {
            TaxPaymentMoveLine reverseTaxPaymentMoveLine = taxPaymentMoveLineService.getReverseTaxPaymentMoveLine(taxPaymentMoveLine);
            reverseTaxPaymentMoveLines.add(reverseTaxPaymentMoveLine);
        }
    }
    for (TaxPaymentMoveLine reverseTaxPaymentMoveLine : reverseTaxPaymentMoveLines) {
        customerMoveLine.addTaxPaymentMoveLineListItem(reverseTaxPaymentMoveLine);
    }
    this.computeTaxAmount(customerMoveLine);
    return Beans.get(MoveLineRepository.class).save(customerMoveLine);
}
Also used : TaxPaymentMoveLine(com.axelor.apps.account.db.TaxPaymentMoveLine) ArrayList(java.util.ArrayList) AnalyticMoveLineRepository(com.axelor.apps.account.db.repo.AnalyticMoveLineRepository) MoveLineRepository(com.axelor.apps.account.db.repo.MoveLineRepository) Transactional(com.google.inject.persist.Transactional)

Example 3 with TaxPaymentMoveLine

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

the class MoveLineServiceImpl method generateTaxPaymentMoveLineList.

@Override
@Transactional(rollbackOn = { Exception.class })
public MoveLine generateTaxPaymentMoveLineList(MoveLine customerMoveLine, Invoice invoice, Reconcile reconcile) throws AxelorException {
    BigDecimal paymentAmount = reconcile.getAmount();
    BigDecimal invoiceTotalAmount = invoice.getCompanyInTaxTotal();
    for (InvoiceLineTax invoiceLineTax : invoice.getInvoiceLineTaxList()) {
        TaxLine taxLine = invoiceLineTax.getTaxLine();
        BigDecimal vatRate = taxLine.getValue();
        BigDecimal baseAmount = invoiceLineTax.getCompanyExTaxBase();
        BigDecimal detailPaymentAmount = baseAmount.multiply(paymentAmount).divide(invoiceTotalAmount, 6, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
        TaxPaymentMoveLine taxPaymentMoveLine = new TaxPaymentMoveLine(customerMoveLine, taxLine, reconcile, vatRate, detailPaymentAmount, Beans.get(AppBaseService.class).getTodayDate(reconcile.getCompany()));
        taxPaymentMoveLine = taxPaymentMoveLineService.computeTaxAmount(taxPaymentMoveLine);
        customerMoveLine.addTaxPaymentMoveLineListItem(taxPaymentMoveLine);
    }
    this.computeTaxAmount(customerMoveLine);
    return Beans.get(MoveLineRepository.class).save(customerMoveLine);
}
Also used : TaxPaymentMoveLine(com.axelor.apps.account.db.TaxPaymentMoveLine) AnalyticMoveLineRepository(com.axelor.apps.account.db.repo.AnalyticMoveLineRepository) MoveLineRepository(com.axelor.apps.account.db.repo.MoveLineRepository) InvoiceLineTax(com.axelor.apps.account.db.InvoiceLineTax) BigDecimal(java.math.BigDecimal) TaxLine(com.axelor.apps.account.db.TaxLine) Transactional(com.google.inject.persist.Transactional)

Aggregations

TaxPaymentMoveLine (com.axelor.apps.account.db.TaxPaymentMoveLine)3 AnalyticMoveLineRepository (com.axelor.apps.account.db.repo.AnalyticMoveLineRepository)2 MoveLineRepository (com.axelor.apps.account.db.repo.MoveLineRepository)2 Transactional (com.google.inject.persist.Transactional)2 InvoiceLineTax (com.axelor.apps.account.db.InvoiceLineTax)1 TaxLine (com.axelor.apps.account.db.TaxLine)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1