use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class SaleOrderWorkflowServiceBusinessProductionImpl method cancelSaleOrder.
@Override
@Transactional(rollbackOn = Exception.class)
public void cancelSaleOrder(SaleOrder saleOrder, CancelReason cancelReason, String cancelReasonStr) {
super.cancelSaleOrder(saleOrder, cancelReason, cancelReasonStr);
for (SaleOrderLine saleOrderLine : saleOrder.getSaleOrderLineList()) {
for (AnalyticMoveLine analyticMoveLine : saleOrderLine.getAnalyticMoveLineList()) {
analyticMoveLine.setProject(null);
analyticMoveLineRepository.save(analyticMoveLine);
}
}
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class MoveLineServiceImpl method findConsolidateMoveLine.
@Override
public MoveLine findConsolidateMoveLine(Map<List<Object>, MoveLine> map, MoveLine moveLine, List<Object> keys) {
if (map != null && !map.isEmpty()) {
Map<List<Object>, MoveLine> copyMap = new HashMap<List<Object>, MoveLine>(map);
while (!copyMap.isEmpty()) {
if (map.containsKey(keys)) {
MoveLine moveLineIt = map.get(keys);
int count = 0;
if (moveLineIt.getAnalyticMoveLineList() == null && moveLine.getAnalyticMoveLineList() == null) {
return moveLineIt;
} else if (moveLineIt.getAnalyticMoveLineList() == null || moveLine.getAnalyticMoveLineList() == null) {
break;
}
List<AnalyticMoveLine> list1 = moveLineIt.getAnalyticMoveLineList();
List<AnalyticMoveLine> list2 = moveLine.getAnalyticMoveLineList();
List<AnalyticMoveLine> copyList = new ArrayList<AnalyticMoveLine>(list1);
if (list1.size() == list2.size()) {
for (AnalyticMoveLine analyticDistributionLine : list2) {
for (AnalyticMoveLine analyticDistributionLineIt : copyList) {
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()))) {
copyList.remove(analyticDistributionLineIt);
count++;
break;
}
}
}
if (count == list1.size()) {
return moveLineIt;
}
}
} else {
return null;
}
}
}
return null;
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class IntercoServiceImpl method createIntercoSaleLineFromPurchaseLine.
/**
* @param purchaseOrderLine the purchase order line needed to create the sale order line
* @param saleOrder the sale order line belongs to this purchase order
* @return the created purchase order line
*/
protected SaleOrderLine createIntercoSaleLineFromPurchaseLine(PurchaseOrderLine purchaseOrderLine, SaleOrder saleOrder) {
SaleOrderLine saleOrderLine = new SaleOrderLine();
saleOrderLine.setSaleOrder(saleOrder);
saleOrderLine.setProduct(purchaseOrderLine.getProduct());
saleOrderLine.setProductName(purchaseOrderLine.getProductName());
saleOrderLine.setDescription(purchaseOrderLine.getDescription());
saleOrderLine.setQty(purchaseOrderLine.getQty());
saleOrderLine.setUnit(purchaseOrderLine.getUnit());
// compute amount
saleOrderLine.setPrice(purchaseOrderLine.getPrice());
saleOrderLine.setInTaxPrice(purchaseOrderLine.getInTaxPrice());
saleOrderLine.setExTaxTotal(purchaseOrderLine.getExTaxTotal());
saleOrderLine.setDiscountTypeSelect(purchaseOrderLine.getDiscountTypeSelect());
saleOrderLine.setDiscountAmount(purchaseOrderLine.getDiscountAmount());
// compute price discounted
BigDecimal priceDiscounted = Beans.get(SaleOrderLineService.class).computeDiscount(saleOrderLine, saleOrder.getInAti());
saleOrderLine.setPriceDiscounted(priceDiscounted);
// delivery
saleOrderLine.setEstimatedDelivDate(purchaseOrderLine.getEstimatedDelivDate());
// tax
saleOrderLine.setTaxLine(purchaseOrderLine.getTaxLine());
// analyticDistribution
saleOrderLine = Beans.get(SaleOrderLineServiceSupplyChainImpl.class).getAndComputeAnalyticDistribution(saleOrderLine, saleOrder);
for (AnalyticMoveLine obj : saleOrderLine.getAnalyticMoveLineList()) {
obj.setSaleOrderLine(saleOrderLine);
}
saleOrder.addSaleOrderLineListItem(saleOrderLine);
return saleOrderLine;
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class AccountingCutOffServiceImpl method getAndComputeAnalyticDistribution.
protected void getAndComputeAnalyticDistribution(Product product, Move move, MoveLine moveLine) {
if (appAccountService.getAppAccount().getAnalyticDistributionTypeSelect() == AppAccountRepository.DISTRIBUTION_TYPE_FREE) {
return;
}
AnalyticDistributionTemplate analyticDistributionTemplate = analyticMoveLineService.getAnalyticDistributionTemplate(move.getPartner(), product, move.getCompany());
moveLine.setAnalyticDistributionTemplate(analyticDistributionTemplate);
List<AnalyticMoveLine> analyticMoveLineList = moveLineService.createAnalyticDistributionWithTemplate(moveLine).getAnalyticMoveLineList();
for (AnalyticMoveLine analyticMoveLine : analyticMoveLineList) {
analyticMoveLine.setMoveLine(moveLine);
}
analyticMoveLineList.stream().forEach(analyticMoveLineRepository::save);
}
use of com.axelor.apps.account.db.AnalyticMoveLine in project axelor-open-suite by axelor.
the class ContractServiceImpl method copyAnalyticMoveLines.
public void copyAnalyticMoveLines(List<AnalyticMoveLine> originalAnalyticMoveLineList, InvoiceLine invoiceLine) {
if (originalAnalyticMoveLineList == null) {
return;
}
AnalyticMoveLineRepository analyticMoveLineRepo = Beans.get(AnalyticMoveLineRepository.class);
for (AnalyticMoveLine originalAnalyticMoveLine : originalAnalyticMoveLineList) {
AnalyticMoveLine analyticMoveLine = analyticMoveLineRepo.copy(originalAnalyticMoveLine, false);
analyticMoveLine.setTypeSelect(AnalyticMoveLineRepository.STATUS_FORECAST_INVOICE);
analyticMoveLine.setContractLine(null);
invoiceLine.addAnalyticMoveLineListItem(analyticMoveLine);
}
}
Aggregations