Search in sources :

Example 16 with AnalyticMoveLine

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);
        }
    }
}
Also used : SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Transactional(com.google.inject.persist.Transactional)

Example 17 with 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;
}
Also used : HashMap(java.util.HashMap) TaxPaymentMoveLine(com.axelor.apps.account.db.TaxPaymentMoveLine) MoveLine(com.axelor.apps.account.db.MoveLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Example 18 with AnalyticMoveLine

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;
}
Also used : SaleOrderLineService(com.axelor.apps.sale.service.saleorder.SaleOrderLineService) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) BigDecimal(java.math.BigDecimal) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Example 19 with AnalyticMoveLine

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);
}
Also used : AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Example 20 with AnalyticMoveLine

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);
    }
}
Also used : AnalyticMoveLineRepository(com.axelor.apps.account.db.repo.AnalyticMoveLineRepository) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Aggregations

AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)30 MoveLine (com.axelor.apps.account.db.MoveLine)7 Transactional (com.google.inject.persist.Transactional)6 BigDecimal (java.math.BigDecimal)6 AnalyticMoveLineRepository (com.axelor.apps.account.db.repo.AnalyticMoveLineRepository)5 ArrayList (java.util.ArrayList)5 Account (com.axelor.apps.account.db.Account)4 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)4 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)4 AxelorException (com.axelor.exception.AxelorException)4 TaxPaymentMoveLine (com.axelor.apps.account.db.TaxPaymentMoveLine)3 Company (com.axelor.apps.base.db.Company)3 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)3 LocalDate (java.time.LocalDate)3 AnalyticAccount (com.axelor.apps.account.db.AnalyticAccount)2 Move (com.axelor.apps.account.db.Move)2 TaxLine (com.axelor.apps.account.db.TaxLine)2 AnalyticMoveLineService (com.axelor.apps.account.service.AnalyticMoveLineService)2 InvoiceLineService (com.axelor.apps.account.service.invoice.InvoiceLineService)2 Partner (com.axelor.apps.base.db.Partner)2