Search in sources :

Example 21 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class PurchaseOrderLinePurchaseRepository method populate.

@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
    if (context.get("_model") != null && context.get("_model").toString().contains("PurchaseOrder") && context.get("id") != null) {
        Long id = (Long) json.get("id");
        if (id != null) {
            PurchaseOrderLine purchaseOrderLine = find(id);
            PurchaseOrder purchaseOrder = purchaseOrderLine.getPurchaseOrder();
            Product product = purchaseOrderLine.getProduct();
            json.put("$hasWarning", purchaseOrder != null && product != null && product.getDefaultSupplierPartner() != null && purchaseOrder.getSupplierPartner() != null && product.getDefaultSupplierPartner() != purchaseOrder.getSupplierPartner());
        }
    }
    return super.populate(json, context);
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) Product(com.axelor.apps.base.db.Product)

Example 22 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class PurchaseOrderServiceImpl method _computePurchaseOrder.

/**
 * Compute the purchase order total amounts
 *
 * @param purchaseOrder
 * @throws AxelorException
 */
@Override
public void _computePurchaseOrder(PurchaseOrder purchaseOrder) throws AxelorException {
    purchaseOrder.setExTaxTotal(BigDecimal.ZERO);
    purchaseOrder.setCompanyExTaxTotal(BigDecimal.ZERO);
    purchaseOrder.setTaxTotal(BigDecimal.ZERO);
    purchaseOrder.setInTaxTotal(BigDecimal.ZERO);
    for (PurchaseOrderLine purchaseOrderLine : purchaseOrder.getPurchaseOrderLineList()) {
        purchaseOrder.setExTaxTotal(purchaseOrder.getExTaxTotal().add(purchaseOrderLine.getExTaxTotal()));
        // In the company accounting currency
        purchaseOrder.setCompanyExTaxTotal(purchaseOrder.getCompanyExTaxTotal().add(purchaseOrderLine.getCompanyExTaxTotal()));
    }
    for (PurchaseOrderLineTax purchaseOrderLineVat : purchaseOrder.getPurchaseOrderLineTaxList()) {
        // In the purchase order currency
        purchaseOrder.setTaxTotal(purchaseOrder.getTaxTotal().add(purchaseOrderLineVat.getTaxTotal()));
    }
    purchaseOrder.setInTaxTotal(purchaseOrder.getExTaxTotal().add(purchaseOrder.getTaxTotal()));
    logger.debug("Montant de la facture: HTT = {},  HT = {}, TVA = {}, TTC = {}", new Object[] { purchaseOrder.getExTaxTotal(), purchaseOrder.getTaxTotal(), purchaseOrder.getInTaxTotal() });
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrderLineTax(com.axelor.apps.purchase.db.PurchaseOrderLineTax)

Example 23 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class PurchaseOrderManagementRepository method copy.

@Override
public PurchaseOrder copy(PurchaseOrder entity, boolean deep) {
    PurchaseOrder copy = super.copy(entity, deep);
    copy.setStatusSelect(PurchaseOrderRepository.STATUS_DRAFT);
    copy.setPurchaseOrderSeq(null);
    copy.setVersionNumber(1);
    copy.setDeliveryDate(null);
    copy.setValidatedByUser(null);
    copy.setValidationDate(null);
    if (copy.getPurchaseOrderLineList() != null) {
        for (PurchaseOrderLine purchaseOrderLine : copy.getPurchaseOrderLineList()) {
            purchaseOrderLine.setDesiredDelivDate(null);
            purchaseOrderLine.setEstimatedDelivDate(null);
        }
    }
    return copy;
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 24 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class PurchaseOrderSupplierLineService method accept.

@Transactional(rollbackOn = { Exception.class })
public void accept(PurchaseOrderSupplierLine purchaseOrderSupplierLine) throws AxelorException {
    PurchaseOrderLine purchaseOrderLine = purchaseOrderSupplierLine.getPurchaseOrderLine();
    purchaseOrderLine.setEstimatedDelivDate(purchaseOrderSupplierLine.getEstimatedDelivDate());
    Partner supplierPartner = purchaseOrderSupplierLine.getSupplierPartner();
    Company company = purchaseOrderLine.getPurchaseOrder().getCompany();
    if (Beans.get(BlockingService.class).getBlocking(supplierPartner, company, BlockingRepository.PURCHASE_BLOCKING) != null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SUPPLIER_BLOCKED), supplierPartner);
    }
    purchaseOrderLine.setSupplierPartner(supplierPartner);
    purchaseOrderLine.setPrice(purchaseOrderSupplierLine.getPrice());
    purchaseOrderLine.setExTaxTotal(PurchaseOrderLineServiceImpl.computeAmount(purchaseOrderLine.getQty(), purchaseOrderLine.getPrice()));
    purchaseOrderSupplierLine.setStateSelect(PurchaseOrderSupplierLineRepository.STATE_ACCEPTED);
    poSupplierLineRepo.save(purchaseOrderSupplierLine);
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Example 25 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class PurchaseOrderLineController method generateSuppliersRequests.

public void generateSuppliersRequests(ActionRequest request, ActionResponse response) {
    PurchaseOrderLine purchaseOrderLine = Beans.get(PurchaseOrderLineRepository.class).find(request.getContext().asType(PurchaseOrderLine.class).getId());
    try {
        if (purchaseOrderLine.getPurchaseOrder() == null) {
            PurchaseOrder purchaseOrder = request.getContext().getParent().asType(PurchaseOrder.class);
            Beans.get(PurchaseOrderSupplierService.class).generateSuppliersRequests(purchaseOrderLine, purchaseOrder);
        } else {
            Beans.get(PurchaseOrderSupplierService.class).generateSuppliersRequests(purchaseOrderLine);
        }
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrderLineRepository(com.axelor.apps.purchase.db.repo.PurchaseOrderLineRepository) PurchaseOrderSupplierService(com.axelor.apps.suppliermanagement.service.PurchaseOrderSupplierService) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Aggregations

PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)76 BigDecimal (java.math.BigDecimal)28 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)26 Transactional (com.google.inject.persist.Transactional)18 Product (com.axelor.apps.base.db.Product)14 ArrayList (java.util.ArrayList)13 AxelorException (com.axelor.exception.AxelorException)11 Context (com.axelor.rpc.Context)10 Company (com.axelor.apps.base.db.Company)9 Unit (com.axelor.apps.base.db.Unit)9 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)9 PurchaseOrderLineService (com.axelor.apps.purchase.service.PurchaseOrderLineService)8 LocalDate (java.time.LocalDate)8 Partner (com.axelor.apps.base.db.Partner)7 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)7 HashMap (java.util.HashMap)7 BudgetDistribution (com.axelor.apps.account.db.BudgetDistribution)5 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)5 TaxLine (com.axelor.apps.account.db.TaxLine)5 List (java.util.List)5