use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class ContractLineServiceProjectImpl method createAnalyticDistributionWithTemplate.
@Override
public ContractLine createAnalyticDistributionWithTemplate(ContractLine contractLine, Contract contract) {
contractLine = super.createAnalyticDistributionWithTemplate(contractLine, contract);
Project project = contract.getProject();
if (project != null) {
List<AnalyticMoveLine> analyticMoveLineList = contractLine.getAnalyticMoveLineList();
analyticMoveLineList.forEach(analyticMoveLine -> analyticMoveLine.setProject(project));
contractLine.setAnalyticMoveLineList(analyticMoveLineList);
}
return contractLine;
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class SaleOrderLineProjectServiceImpl method createAnalyticDistributionWithTemplate.
@Override
public SaleOrderLine createAnalyticDistributionWithTemplate(SaleOrderLine saleOrderLine) {
SaleOrderLine soLine = super.createAnalyticDistributionWithTemplate(saleOrderLine);
List<AnalyticMoveLine> analyticMoveLineList = soLine.getAnalyticMoveLineList();
if (soLine.getProject() != null && analyticMoveLineList != null) {
analyticMoveLineList.forEach(analyticLine -> analyticLine.setProject(soLine.getProject()));
}
return soLine;
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class ProjectAnalyticMoveLineServiceImpl method updateLines.
@Override
@Transactional(rollbackOn = Exception.class)
public PurchaseOrder updateLines(PurchaseOrder purchaseOrder) {
for (PurchaseOrderLine orderLine : purchaseOrder.getPurchaseOrderLineList()) {
orderLine.setProject(purchaseOrder.getProject());
for (AnalyticMoveLine analyticMoveLine : orderLine.getAnalyticMoveLineList()) {
analyticMoveLine.setProject(purchaseOrder.getProject());
analyticMoveLineRepository.save(analyticMoveLine);
}
}
return purchaseOrder;
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class MoveLineServiceImpl method updateAccountTypeOnAnalytic.
@Override
public void updateAccountTypeOnAnalytic(MoveLine moveLine, List<AnalyticMoveLine> analyticMoveLineList) {
if ((analyticMoveLineList == null || analyticMoveLineList.isEmpty())) {
return;
}
for (AnalyticMoveLine analyticMoveLine : analyticMoveLineList) {
if (moveLine.getAccount() != null) {
analyticMoveLine.setAccount(moveLine.getAccount());
analyticMoveLine.setAccountType(moveLine.getAccount().getAccountType());
}
}
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class MoveLineServiceImpl method consolidateMoveLines.
/**
* Consolider des lignes d'écritures par compte comptable.
*
* @param moveLines
*/
@Override
public List<MoveLine> consolidateMoveLines(List<MoveLine> moveLines) {
Map<List<Object>, MoveLine> map = new HashMap<List<Object>, MoveLine>();
MoveLine consolidateMoveLine = null;
for (MoveLine moveLine : moveLines) {
List<Object> keys = new ArrayList<Object>();
keys.add(moveLine.getAccount());
keys.add(moveLine.getTaxLine());
keys.add(moveLine.getAnalyticDistributionTemplate());
consolidateMoveLine = this.findConsolidateMoveLine(map, moveLine, keys);
if (consolidateMoveLine != null) {
BigDecimal consolidateCurrencyAmount = BigDecimal.ZERO;
log.debug("MoveLine :: Debit : {}, Credit : {}, Currency amount : {}", moveLine.getDebit(), moveLine.getCredit(), moveLine.getCurrencyAmount());
log.debug("Consolidate moveLine :: Debit : {}, Credit : {}, Currency amount : {}", consolidateMoveLine.getDebit(), consolidateMoveLine.getCredit(), consolidateMoveLine.getCurrencyAmount());
if (moveLine.getDebit().subtract(moveLine.getCredit()).compareTo(BigDecimal.ZERO) != consolidateMoveLine.getDebit().subtract(consolidateMoveLine.getCredit()).compareTo(BigDecimal.ZERO)) {
consolidateCurrencyAmount = consolidateMoveLine.getCurrencyAmount().subtract(moveLine.getCurrencyAmount());
} else {
consolidateCurrencyAmount = consolidateMoveLine.getCurrencyAmount().add(moveLine.getCurrencyAmount());
}
consolidateMoveLine.setCurrencyAmount(consolidateCurrencyAmount.abs());
consolidateMoveLine.setCredit(consolidateMoveLine.getCredit().add(moveLine.getCredit()));
consolidateMoveLine.setDebit(consolidateMoveLine.getDebit().add(moveLine.getDebit()));
if (consolidateMoveLine.getAnalyticMoveLineList() != null && !consolidateMoveLine.getAnalyticMoveLineList().isEmpty()) {
for (AnalyticMoveLine analyticDistributionLine : consolidateMoveLine.getAnalyticMoveLineList()) {
for (AnalyticMoveLine analyticDistributionLineIt : moveLine.getAnalyticMoveLineList()) {
if (analyticDistributionLine.getAnalyticAxis().equals(analyticDistributionLineIt.getAnalyticAxis()) && analyticDistributionLine.getAnalyticAccount().equals(analyticDistributionLineIt.getAnalyticAccount()) && analyticDistributionLine.getAccount().equals(analyticDistributionLineIt.getAccount()) && analyticDistributionLine.getPercentage().equals(analyticDistributionLineIt.getPercentage()) && ((analyticDistributionLine.getAnalyticJournal() == null && analyticDistributionLineIt.getAnalyticJournal() == null) || analyticDistributionLine.getAnalyticJournal().equals(analyticDistributionLineIt.getAnalyticJournal()))) {
analyticDistributionLine.setAmount(analyticDistributionLine.getAmount().add(analyticDistributionLineIt.getAmount()));
break;
}
}
}
}
} else {
map.put(keys, moveLine);
}
}
BigDecimal credit = null;
BigDecimal debit = null;
int moveLineId = 1;
moveLines.clear();
for (MoveLine moveLine : map.values()) {
credit = moveLine.getCredit();
debit = moveLine.getDebit();
moveLine.setCurrencyAmount(moveLine.getCurrencyAmount().abs());
if (debit.compareTo(BigDecimal.ZERO) == 1 && credit.compareTo(BigDecimal.ZERO) == 1) {
if (debit.compareTo(credit) == 1) {
moveLine.setDebit(debit.subtract(credit));
moveLine.setCredit(BigDecimal.ZERO);
moveLine.setCounter(moveLineId++);
moveLines.add(moveLine);
} else if (credit.compareTo(debit) == 1) {
moveLine.setCredit(credit.subtract(debit));
moveLine.setDebit(BigDecimal.ZERO);
moveLine.setCounter(moveLineId++);
moveLines.add(moveLine);
}
} else if (debit.compareTo(BigDecimal.ZERO) == 1 || credit.compareTo(BigDecimal.ZERO) == 1) {
moveLine.setCounter(moveLineId++);
moveLines.add(moveLine);
}
}
return moveLines;
}
Aggregations