use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class WorkflowVentilationServiceSupplychainImpl method saleOrderProcess.
private void saleOrderProcess(Invoice invoice) throws AxelorException {
// Get all different saleOrders from invoice
Set<SaleOrder> saleOrderSet = new HashSet<>();
for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
SaleOrder saleOrder = null;
saleOrder = this.saleOrderLineProcess(invoice, invoiceLine);
if (saleOrder != null) {
saleOrderSet.add(saleOrder);
}
}
for (SaleOrder saleOrder : saleOrderSet) {
log.debug("Update the invoiced amount of the sale order : {}", saleOrder.getSaleOrderSeq());
saleOrderInvoiceService.update(saleOrder, invoice.getId(), false);
saleOrderRepository.save(saleOrder);
accountingSituationSupplychainService.updateUsedCredit(saleOrder.getClientPartner());
// determine if the invoice is a balance invoice.
if (saleOrder.getAmountInvoiced().compareTo(saleOrder.getExTaxTotal()) == 0 && invoice.getOperationSubTypeSelect() != InvoiceRepository.OPERATION_SUB_TYPE_SUBSCRIPTION) {
invoice.setOperationSubTypeSelect(InvoiceRepository.OPERATION_SUB_TYPE_BALANCE);
}
}
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class ExpenseServiceProjectImpl method createInvoiceLines.
@Override
public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<ExpenseLine> expenseLineList, int priority) throws AxelorException {
if (!Beans.get(AppAccountService.class).isApp("business-project")) {
return super.createInvoiceLines(invoice, expenseLineList, priority);
}
List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>();
int count = 0;
for (ExpenseLine expenseLine : expenseLineList) {
invoiceLineList.addAll(this.createInvoiceLine(invoice, expenseLine, priority * 100 + count));
count++;
invoiceLineList.get(invoiceLineList.size() - 1).setProject(expenseLine.getProject());
}
return invoiceLineList;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceServiceProjectImpl method updateLines.
@Transactional(rollbackOn = Exception.class)
public Invoice updateLines(Invoice invoice) {
AnalyticMoveLineRepository analyticMoveLineRepository = Beans.get(AnalyticMoveLineRepository.class);
for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
invoiceLine.setProject(invoice.getProject());
for (AnalyticMoveLine analyticMoveLine : invoiceLine.getAnalyticMoveLineList()) {
analyticMoveLine.setProject(invoice.getProject());
analyticMoveLineRepository.save(analyticMoveLine);
}
}
return invoice;
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoicingProjectService method createInvoiceLine.
public List<InvoiceLine> createInvoiceLine(Invoice invoice, SaleOrderLine saleOrderLine, int priority) throws AxelorException {
Product product = saleOrderLine.getProduct();
InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGeneratorSupplyChain(invoice, product, saleOrderLine.getProductName(), saleOrderLine.getDescription(), saleOrderLine.getQty(), saleOrderLine.getUnit(), priority, false, saleOrderLine, null, null) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
invoiceLine.setProject(saleOrderLine.getProject());
List<InvoiceLine> invoiceLines = new ArrayList<InvoiceLine>();
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 InvoicingProjectService method createSaleOrderInvoiceLines.
public List<InvoiceLine> createSaleOrderInvoiceLines(Invoice invoice, List<SaleOrderLine> saleOrderLineList, int priority) throws AxelorException {
List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>();
int count = 1;
for (SaleOrderLine saleOrderLine : saleOrderLineList) {
invoiceLineList.addAll(this.createInvoiceLine(invoice, saleOrderLine, priority * 100 + count));
count++;
}
return invoiceLineList;
}
Aggregations