use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class PurchaseOrderInvoiceServiceImpl method createInvoiceLine.
public List<InvoiceLine> createInvoiceLine(Invoice invoice, PurchaseOrderLine purchaseOrderLine, BigDecimal qtyToInvoice) throws AxelorException {
Product product = purchaseOrderLine.getProduct();
InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGeneratorSupplyChain(invoice, product, purchaseOrderLine.getProductName(), purchaseOrderLine.getDescription(), qtyToInvoice, purchaseOrderLine.getUnit(), purchaseOrderLine.getSequence(), false, null, purchaseOrderLine, null) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
return invoiceLineGenerator.creates();
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class SaleOrderInvoiceServiceImpl method createInvoiceLines.
// TODO ajouter tri sur les séquences
@Override
public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<SaleOrderLine> saleOrderLineList, Map<Long, BigDecimal> qtyToInvoiceMap) throws AxelorException {
List<InvoiceLine> invoiceLineList = new ArrayList<>();
for (SaleOrderLine saleOrderLine : saleOrderLineList) {
if (qtyToInvoiceMap.containsKey(saleOrderLine.getId())) {
List<InvoiceLine> invoiceLines = createInvoiceLine(invoice, saleOrderLine, qtyToInvoiceMap.get(saleOrderLine.getId()));
invoiceLineList.addAll(invoiceLines);
saleOrderLine.setInvoiced(true);
}
}
return invoiceLineList;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class SaleOrderInvoiceServiceImpl method createInvoiceLine.
@Override
public List<InvoiceLine> createInvoiceLine(Invoice invoice, SaleOrderLine saleOrderLine, BigDecimal qtyToInvoice) throws AxelorException {
Product product = saleOrderLine.getProduct();
InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGeneratorSupplyChain(invoice, product, saleOrderLine.getProductName(), saleOrderLine.getDescription(), qtyToInvoice, saleOrderLine.getUnit(), saleOrderLine.getSequence(), false, saleOrderLine, null, null) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
return invoiceLineGenerator.creates();
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class SaleOrderInvoiceServiceImpl method mergeInvoice.
@Override
@Transactional
public Invoice mergeInvoice(List<Invoice> invoiceList, Company company, Currency currency, Partner partner, Partner contactPartner, PriceList priceList, PaymentMode paymentMode, PaymentCondition paymentCondition, SaleOrder saleOrder) throws AxelorException {
log.debug("service supplychain 1 (saleOrder) {}", saleOrder);
if (saleOrder != null) {
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 = this.createInvoiceGenerator(saleOrder);
Invoice invoiceMerged = invoiceGenerator.generate();
invoiceMerged.setExternalReference(externalRef);
invoiceMerged.setInternalReference(numSeq);
if (paymentMode != null)
invoiceMerged.setPaymentMode(paymentMode);
if (paymentCondition != null)
invoiceMerged.setPaymentCondition(paymentCondition);
List<InvoiceLine> invoiceLines = invoiceService.getInvoiceLinesFromInvoiceList(invoiceList);
invoiceGenerator.populate(invoiceMerged, invoiceLines);
invoiceService.setInvoiceForInvoiceLines(invoiceLines, invoiceMerged);
invoiceMerged.setSaleOrder(null);
invoiceRepo.save(invoiceMerged);
swapStockMoveInvoices(invoiceList, invoiceMerged);
invoiceService.deleteOldInvoices(invoiceList);
return invoiceMerged;
} else {
Invoice invoiceMerged = invoiceService.mergeInvoice(invoiceList, company, currency, partner, contactPartner, priceList, paymentMode, paymentCondition);
swapStockMoveInvoices(invoiceList, invoiceMerged);
invoiceService.deleteOldInvoices(invoiceList);
return invoiceMerged;
}
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class SaleOrderInvoiceServiceImpl method createInvoiceLinesFromTax.
@Override
public List<InvoiceLine> createInvoiceLinesFromTax(Invoice invoice, List<SaleOrderLineTax> taxLineList, Product invoicingProduct, BigDecimal percentToInvoice) throws AxelorException {
List<InvoiceLine> createdInvoiceLineList = new ArrayList<>();
if (taxLineList != null) {
for (SaleOrderLineTax saleOrderLineTax : taxLineList) {
BigDecimal lineAmountToInvoice = percentToInvoice.multiply(saleOrderLineTax.getExTaxBase()).divide(new BigDecimal("100"), 4, BigDecimal.ROUND_HALF_UP);
TaxLine taxLine = saleOrderLineTax.getTaxLine();
BigDecimal lineAmountToInvoiceInclTax = (taxLine != null) ? lineAmountToInvoice.add(lineAmountToInvoice.multiply(taxLine.getValue())) : lineAmountToInvoice;
InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGenerator(invoice, invoicingProduct, invoicingProduct.getName(), lineAmountToInvoice, lineAmountToInvoiceInclTax, invoice.getInAti() ? lineAmountToInvoiceInclTax : lineAmountToInvoice, invoicingProduct.getDescription(), BigDecimal.ONE, invoicingProduct.getUnit(), taxLine, InvoiceLineGenerator.DEFAULT_SEQUENCE, BigDecimal.ZERO, PriceListLineRepository.AMOUNT_TYPE_NONE, lineAmountToInvoice, null, false) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
List<InvoiceLine> invoiceOneLineList = invoiceLineGenerator.creates();
// link to the created invoice line the first line of the sale order.
for (InvoiceLine invoiceLine : invoiceOneLineList) {
SaleOrderLine saleOrderLine = saleOrderLineTax.getSaleOrder().getSaleOrderLineList().get(0);
invoiceLine.setSaleOrderLine(saleOrderLine);
}
createdInvoiceLineList.addAll(invoiceOneLineList);
}
}
return createdInvoiceLineList;
}
Aggregations