use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class ContractLineServiceImpl method createAnalyticDistributionWithTemplate.
@Override
public ContractLine createAnalyticDistributionWithTemplate(ContractLine contractLine, Contract contract) {
AppAccountService appAccountService = Beans.get(AppAccountService.class);
List<AnalyticMoveLine> analyticMoveLineList = Beans.get(AnalyticMoveLineService.class).generateLines(contractLine.getAnalyticDistributionTemplate(), contractLine.getExTaxTotal(), AnalyticMoveLineRepository.STATUS_FORECAST_CONTRACT, appAccountService.getTodayDate(contract.getCompany()));
contractLine.setAnalyticMoveLineList(analyticMoveLineList);
return contractLine;
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class InvoiceLineGeneratorSupplyChain method createInvoiceLine.
/**
* @return
* @throws AxelorException
*/
@Override
protected InvoiceLine createInvoiceLine() throws AxelorException {
InvoiceLine invoiceLine = super.createInvoiceLine();
if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
return invoiceLine;
}
InvoiceLineService invoiceLineService = Beans.get(InvoiceLineService.class);
this.assignOriginElements(invoiceLine);
List<AnalyticMoveLine> analyticMoveLineList = null;
if (saleOrderLine != null) {
switch(saleOrderLine.getTypeSelect()) {
case SaleOrderLineRepository.TYPE_END_OF_PACK:
invoiceLine.setIsHideUnitAmounts(saleOrderLine.getIsHideUnitAmounts());
invoiceLine.setIsShowTotal(saleOrderLine.getIsShowTotal());
break;
case SaleOrderLineRepository.TYPE_NORMAL:
if (saleOrderLine.getAnalyticDistributionTemplate() != null || !ObjectUtils.isEmpty(saleOrderLine.getAnalyticMoveLineList())) {
invoiceLine.setAnalyticDistributionTemplate(saleOrderLine.getAnalyticDistributionTemplate());
this.copyAnalyticMoveLines(saleOrderLine.getAnalyticMoveLineList(), invoiceLine);
analyticMoveLineList = invoiceLineService.computeAnalyticDistribution(invoiceLine);
} else {
analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
}
break;
default:
return invoiceLine;
}
} else if (purchaseOrderLine != null) {
if (purchaseOrderLine.getAnalyticDistributionTemplate() != null || !ObjectUtils.isEmpty(purchaseOrderLine.getAnalyticMoveLineList())) {
invoiceLine.setAnalyticDistributionTemplate(purchaseOrderLine.getAnalyticDistributionTemplate());
this.copyAnalyticMoveLines(purchaseOrderLine.getAnalyticMoveLineList(), invoiceLine);
analyticMoveLineList = invoiceLineService.computeAnalyticDistribution(invoiceLine);
} else {
analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
}
this.copyBudgetDistributionList(purchaseOrderLine.getBudgetDistributionList(), invoiceLine);
invoiceLine.setBudget(purchaseOrderLine.getBudget());
invoiceLine.setBudgetDistributionSumAmount(purchaseOrderLine.getBudgetDistributionSumAmount());
invoiceLine.setFixedAssets(purchaseOrderLine.getFixedAssets());
if (product != null) {
invoiceLine.setProductCode((String) productCompanyService.get(product, "code", invoice.getCompany()));
Account account = accountManagementService.getProductAccount(product, invoice.getCompany(), invoice.getPartner().getFiscalPosition(), InvoiceToolService.isPurchase(invoice), invoiceLine.getFixedAssets());
invoiceLine.setAccount(account);
}
if (product != null && purchaseOrderLine.getFixedAssets()) {
FixedAssetCategory fixedAssetCategory = accountManagementService.getProductFixedAssetCategory(product, invoice.getCompany());
invoiceLine.setFixedAssetCategory(fixedAssetCategory);
}
} else if (stockMoveLine != null) {
this.price = stockMoveLine.getUnitPriceUntaxed();
this.inTaxPrice = stockMoveLine.getUnitPriceTaxed();
this.price = unitConversionService.convert(stockMoveLine.getUnit(), this.unit, this.price, appBaseService.getNbDecimalDigitForUnitPrice(), product);
this.inTaxPrice = unitConversionService.convert(stockMoveLine.getUnit(), this.unit, this.inTaxPrice, appBaseService.getNbDecimalDigitForUnitPrice(), product);
invoiceLine.setPrice(price);
invoiceLine.setInTaxPrice(inTaxPrice);
analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
}
return invoiceLine;
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class InvoiceLineGeneratorSupplyChain method copyAnalyticMoveLines.
public void copyAnalyticMoveLines(List<AnalyticMoveLine> originalAnalyticMoveLineList, InvoiceLine invoiceLine) {
if (originalAnalyticMoveLineList == null) {
return;
}
for (AnalyticMoveLine originalAnalyticMoveLine : originalAnalyticMoveLineList) {
AnalyticMoveLine analyticMoveLine = Beans.get(AnalyticMoveLineRepository.class).copy(originalAnalyticMoveLine, false);
analyticMoveLine.setTypeSelect(AnalyticMoveLineMngtRepository.STATUS_FORECAST_INVOICE);
invoiceLine.addAnalyticMoveLineListItem(analyticMoveLine);
}
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class MoveLineManagementRepository method save.
@Override
public MoveLine save(MoveLine entity) {
List<AnalyticMoveLine> analyticMoveLineList = entity.getAnalyticMoveLineList();
if (analyticMoveLineList != null) {
for (AnalyticMoveLine analyticMoveLine : analyticMoveLineList) {
analyticMoveLine.setAccount(entity.getAccount());
analyticMoveLine.setAccountType(entity.getAccount().getAccountType());
}
}
try {
Beans.get(MoveLineService.class).validateMoveLine(entity);
} catch (Exception e) {
TraceBackService.traceExceptionFromSaveMethod(e);
throw new PersistenceException(e.getMessage(), e);
}
return super.save(entity);
}
use of com.axelor.apps.account.db.AnalyticMoveLine 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;
}
Aggregations