use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceServiceImpl method compute.
/**
* Fonction permettant de calculer l'intégralité d'une facture :
*
* <ul>
* <li>Détermine les taxes;
* <li>Détermine la TVA;
* <li>Détermine les totaux.
* </ul>
*
* (Transaction)
*
* @param invoice Une facture.
* @throws AxelorException
*/
@Override
public Invoice compute(final Invoice invoice) throws AxelorException {
log.debug("Calcul de la facture");
InvoiceGenerator invoiceGenerator = new InvoiceGenerator() {
@Override
public Invoice generate() throws AxelorException {
List<InvoiceLine> invoiceLines = new ArrayList<InvoiceLine>();
if (invoice.getInvoiceLineList() != null) {
invoiceLines.addAll(invoice.getInvoiceLineList());
}
populate(invoice, invoiceLines);
return invoice;
}
};
Invoice invoice1 = invoiceGenerator.generate();
invoice1.setAdvancePaymentInvoiceSet(this.getDefaultAdvancePaymentInvoice(invoice1));
return invoice1;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceServiceImpl method getInvoiceLinesFromInvoiceList.
@Override
public List<InvoiceLine> getInvoiceLinesFromInvoiceList(List<Invoice> invoiceList) {
List<InvoiceLine> invoiceLines = new ArrayList<InvoiceLine>();
for (Invoice invoice : invoiceList) {
int countLine = 1;
for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
invoiceLine.setSequence(countLine * 10);
invoiceLines.add(invoiceLine);
countLine++;
}
}
return invoiceLines;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class RefundInvoice method refundInvoiceLines.
/**
* Mets à jour les lignes de facture en appliquant la négation aux prix unitaires et au total hors
* taxe.
*
* @param invoiceLines
*/
@Deprecated
protected void refundInvoiceLines(List<InvoiceLine> invoiceLines) {
for (InvoiceLine invoiceLine : invoiceLines) {
invoiceLine.setQty(invoiceLine.getQty().negate());
invoiceLine.setExTaxTotal(invoiceLine.getExTaxTotal().negate());
}
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class RefundInvoice method generate.
@Override
public Invoice generate() throws AxelorException {
LOG.debug("Creating a refund for invoice {}", invoice.getInvoiceId());
Invoice refund = JPA.copy(invoice, true);
InvoiceToolService.resetInvoiceStatusOnCopy(refund);
refund.setOperationTypeSelect(this.inverseOperationType(refund.getOperationTypeSelect()));
List<InvoiceLine> refundLines = new ArrayList<>();
if (refund.getInvoiceLineList() != null) {
refundLines.addAll(refund.getInvoiceLineList());
}
populate(refund, refundLines);
// Payment mode should not be the invoice payment mode. It must come
// from the partner or the company, or be null.
refund.setPaymentMode(InvoiceToolService.getPaymentMode(refund));
if (refund.getPaymentMode() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.REFUND_INVOICE_1), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION));
}
return refund;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineGenerator method createInvoiceLine.
/**
* @return
* @throws AxelorException
*/
protected InvoiceLine createInvoiceLine() throws AxelorException {
InvoiceLine invoiceLine = new InvoiceLine();
boolean isPurchase = InvoiceToolService.isPurchase(invoice);
Partner partner = invoice.getPartner();
Company company = invoice.getCompany();
invoiceLine.setInvoice(invoice);
invoiceLine.setProduct(product);
invoiceLine.setProductName(productName);
if (product != null) {
invoiceLine.setProductCode((String) productCompanyService.get(product, "code", company));
Account account = accountManagementService.getProductAccount(product, company, partner.getFiscalPosition(), isPurchase, invoiceLine.getFixedAssets());
invoiceLine.setAccount(account);
}
invoiceLine.setDescription(description);
invoiceLine.setPrice(price);
invoiceLine.setInTaxPrice(inTaxPrice);
invoiceLine.setPriceDiscounted(priceDiscounted);
invoiceLine.setQty(qty);
invoiceLine.setUnit(unit);
invoiceLine.setTypeSelect(typeSelect);
if (taxLine == null) {
this.determineTaxLine();
}
if (product != null) {
TaxEquiv taxEquiv = Beans.get(AccountManagementService.class).getProductTaxEquiv(product, company, partner.getFiscalPosition(), isPurchase);
invoiceLine.setTaxEquiv(taxEquiv);
}
invoiceLine.setTaxLine(taxLine);
if (taxLine != null) {
invoiceLine.setTaxRate(taxLine.getValue());
invoiceLine.setTaxCode(taxLine.getTax().getCode());
}
if ((exTaxTotal == null || inTaxTotal == null)) {
this.computeTotal();
}
invoiceLine.setExTaxTotal(exTaxTotal);
invoiceLine.setInTaxTotal(inTaxTotal);
this.computeCompanyTotal(invoiceLine);
invoiceLine.setSequence(sequence);
invoiceLine.setDiscountTypeSelect(discountTypeSelect);
invoiceLine.setDiscountAmount(discountAmount);
return invoiceLine;
}
Aggregations