use of com.axelor.apps.supplychain.service.invoice.generator.InvoiceLineGeneratorSupplyChain in project axelor-open-suite by axelor.
the class InvoicingProjectService method createInvoiceLine.
public List<InvoiceLine> createInvoiceLine(Invoice invoice, PurchaseOrderLine purchaseOrderLine, int priority) throws AxelorException {
Product product = purchaseOrderLine.getProduct();
InvoiceLineGeneratorSupplyChain invoiceLineGenerator = new InvoiceLineGeneratorSupplyChain(invoice, product, purchaseOrderLine.getProductName(), purchaseOrderLine.getDescription(), purchaseOrderLine.getQty(), purchaseOrderLine.getUnit(), priority, false, null, purchaseOrderLine, null) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<InvoiceLine>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
return invoiceLineGenerator.creates();
}
use of com.axelor.apps.supplychain.service.invoice.generator.InvoiceLineGeneratorSupplyChain 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.supplychain.service.invoice.generator.InvoiceLineGeneratorSupplyChain 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.supplychain.service.invoice.generator.InvoiceLineGeneratorSupplyChain in project axelor-open-suite by axelor.
the class PurchaseOrderInvoiceServiceImpl method createInvoiceLine.
@Override
public List<InvoiceLine> createInvoiceLine(Invoice invoice, PurchaseOrderLine purchaseOrderLine) throws AxelorException {
Product product = purchaseOrderLine.getProduct();
InvoiceLineGeneratorSupplyChain invoiceLineGenerator = new InvoiceLineGeneratorSupplyChain(invoice, product, purchaseOrderLine.getProductName(), purchaseOrderLine.getDescription(), purchaseOrderLine.getQty(), purchaseOrderLine.getUnit(), purchaseOrderLine.getSequence(), false, null, purchaseOrderLine, null) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<InvoiceLine>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
return invoiceLineGenerator.creates();
}
use of com.axelor.apps.supplychain.service.invoice.generator.InvoiceLineGeneratorSupplyChain in project axelor-open-suite by axelor.
the class StockMoveInvoiceServiceImpl method createInvoiceLine.
@Override
public InvoiceLine createInvoiceLine(Invoice invoice, StockMoveLine stockMoveLine, BigDecimal qty) throws AxelorException {
Product product = stockMoveLine.getProduct();
boolean isTitleLine = false;
int sequence = InvoiceLineGenerator.DEFAULT_SEQUENCE;
SaleOrderLine saleOrderLine = stockMoveLine.getSaleOrderLine();
PurchaseOrderLine purchaseOrderLine = stockMoveLine.getPurchaseOrderLine();
if (saleOrderLine != null) {
sequence = saleOrderLine.getSequence();
} else if (purchaseOrderLine != null) {
if (purchaseOrderLine.getIsTitleLine()) {
isTitleLine = true;
}
sequence = purchaseOrderLine.getSequence();
}
// do not create lines with no qties
if ((qty == null || qty.signum() == 0 || stockMoveLine.getRealQty().signum() == 0) && !isTitleLine) {
return null;
}
if (product == null && !isTitleLine) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.STOCK_MOVE_INVOICE_1), stockMoveLine.getStockMove().getStockMoveSeq());
}
InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGeneratorSupplyChain(invoice, product, stockMoveLine.getProductName(), stockMoveLine.getDescription(), qty, stockMoveLine.getUnit(), sequence, false, stockMoveLine.getSaleOrderLine(), stockMoveLine.getPurchaseOrderLine(), stockMoveLine) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
List<InvoiceLine> invoiceLines = invoiceLineGenerator.creates();
InvoiceLine invoiceLine = null;
if (invoiceLines != null && !invoiceLines.isEmpty()) {
invoiceLine = invoiceLines.get(0);
if (!stockMoveLine.getIsMergedStockMoveLine()) {
// not a consolidated line so we can set the reference.
invoiceLine.setStockMoveLine(stockMoveLine);
} else {
// set the reference to a correct stock move line by following either the sale order line or
// purchase order line. We cannot have a consolidated line without purchase order line or
// sale order line reference
StockMoveLine nonConsolidatedStockMoveLine = null;
StockMove stockMove = stockMoveLine.getStockMove();
if (saleOrderLine != null) {
nonConsolidatedStockMoveLine = stockMoveLineRepository.all().filter("self.saleOrderLine.id = :saleOrderLineId " + "AND self.stockMove.id = :stockMoveId " + "AND self.id != :stockMoveLineId").bind("saleOrderLineId", saleOrderLine.getId()).bind("stockMoveId", stockMove.getId()).bind("stockMoveLineId", stockMoveLine.getId()).order("id").fetchOne();
} else if (purchaseOrderLine != null) {
nonConsolidatedStockMoveLine = stockMoveLineRepository.all().filter("self.purchaseOrderLine.id = :purchaseOrderLineId " + "AND self.stockMove.id = :stockMoveId " + "AND self.id != :stockMoveLineId").bind("purchaseOrderLineId", purchaseOrderLine.getId()).bind("stockMoveId", stockMove.getId()).bind("stockMoveLineId", stockMoveLine.getId()).order("id").fetchOne();
}
invoiceLine.setStockMoveLine(nonConsolidatedStockMoveLine);
deleteConsolidatedStockMoveLine(stockMoveLine);
}
}
return invoiceLine;
}
Aggregations