use of com.axelor.apps.account.db.InvoiceLine 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;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceGenerator method computeInvoice.
/**
* Compute the invoice total amounts
*
* @param invoice
* @throws AxelorException
*/
public void computeInvoice(Invoice invoice) throws AxelorException {
// In the invoice currency
invoice.setExTaxTotal(BigDecimal.ZERO);
invoice.setTaxTotal(BigDecimal.ZERO);
invoice.setInTaxTotal(BigDecimal.ZERO);
// In the company accounting currency
invoice.setCompanyExTaxTotal(BigDecimal.ZERO);
invoice.setCompanyTaxTotal(BigDecimal.ZERO);
invoice.setCompanyInTaxTotal(BigDecimal.ZERO);
for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
if (invoiceLine.getTypeSelect() != InvoiceLineRepository.TYPE_NORMAL) {
continue;
}
// In the invoice currency
invoice.setExTaxTotal(invoice.getExTaxTotal().add(invoiceLine.getExTaxTotal()));
// In the company accounting currency
invoice.setCompanyExTaxTotal(invoice.getCompanyExTaxTotal().add(invoiceLine.getCompanyExTaxTotal()));
}
for (InvoiceLineTax invoiceLineTax : invoice.getInvoiceLineTaxList()) {
// In the invoice currency
invoice.setTaxTotal(invoice.getTaxTotal().add(invoiceLineTax.getTaxTotal()));
// In the company accounting currency
invoice.setCompanyTaxTotal(invoice.getCompanyTaxTotal().add(invoiceLineTax.getCompanyTaxTotal()));
}
// In the invoice currency
invoice.setInTaxTotal(invoice.getExTaxTotal().add(invoice.getTaxTotal()));
// In the company accounting currency
invoice.setCompanyInTaxTotal(invoice.getCompanyExTaxTotal().add(invoice.getCompanyTaxTotal()));
invoice.setAmountRemaining(invoice.getInTaxTotal());
invoice.setHasPendingPayments(false);
logger.debug("Invoice amounts : W.T. = {}, Tax = {}, A.T.I. = {}", new Object[] { invoice.getExTaxTotal(), invoice.getTaxTotal(), invoice.getInTaxTotal() });
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineGenerator method substractInvoiceLine.
protected InvoiceLine substractInvoiceLine(InvoiceLine invoiceLine1, InvoiceLine invoiceLine2) {
InvoiceLine substract = JPA.copy(invoiceLine1, false);
substract.setQty(invoiceLine1.getQty().add(invoiceLine2.getQty()));
substract.setExTaxTotal(computeAmount(substract.getQty(), substract.getPrice()));
LOG.debug("Soustraction de deux lignes de factures: {}", substract);
return substract;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineGenerator method refundInvoiceLine.
/**
* Rembourser une ligne de facture.
*
* @param invoice La facture concernée.
* @param invoiceLine La ligne de facture.
* @return La ligne de facture de remboursement.
*/
protected InvoiceLine refundInvoiceLine(InvoiceLine invoiceLine, boolean daysQty) {
LOG.debug("Remboursement d'une ligne de facture (quantité = nb jour ? {}).", daysQty);
InvoiceLine refundInvoiceLine = JPA.copy(invoiceLine, true);
refundInvoiceLine.setInvoice(invoice);
BigDecimal quantity = invoiceLine.getQty();
refundInvoiceLine.setQty(quantity.negate());
LOG.debug("Quantité remboursée : {}", refundInvoiceLine.getQty());
refundInvoiceLine.setExTaxTotal(computeAmount(refundInvoiceLine.getQty(), refundInvoiceLine.getPrice()));
LOG.debug("Remboursement de la ligne de facture {} => montant HT: {}", new Object[] { invoiceLine.getId(), refundInvoiceLine.getExTaxTotal() });
return refundInvoiceLine;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceServiceImpl method mergeInvoice.
@Override
@Transactional(rollbackOn = { Exception.class })
public Invoice mergeInvoice(List<Invoice> invoiceList, Company company, Currency currency, Partner partner, Partner contactPartner, PriceList priceList, PaymentMode paymentMode, PaymentCondition paymentCondition) throws AxelorException {
String numSeq = "";
String externalRef = "";
for (Invoice invoiceLocal : invoiceList) {
if (!numSeq.isEmpty()) {
numSeq += "-";
}
if (invoiceLocal.getInternalReference() != null) {
numSeq += invoiceLocal.getInternalReference();
}
if (!externalRef.isEmpty()) {
externalRef += "|";
}
if (invoiceLocal.getExternalReference() != null) {
externalRef += invoiceLocal.getExternalReference();
}
}
InvoiceGenerator invoiceGenerator = new InvoiceGenerator(InvoiceRepository.OPERATION_TYPE_CLIENT_SALE, company, paymentCondition, paymentMode, partnerService.getInvoicingAddress(partner), partner, contactPartner, currency, priceList, numSeq, externalRef, null, company.getDefaultBankDetails(), null, null) {
@Override
public Invoice generate() throws AxelorException {
return super.createInvoiceHeader();
}
};
Invoice invoiceMerged = invoiceGenerator.generate();
List<InvoiceLine> invoiceLines = this.getInvoiceLinesFromInvoiceList(invoiceList);
invoiceGenerator.populate(invoiceMerged, invoiceLines);
this.setInvoiceForInvoiceLines(invoiceLines, invoiceMerged);
invoiceRepo.save(invoiceMerged);
return invoiceMerged;
}
Aggregations